Results 1 to 6 of 6

Thread: How do i script an AI event

  1. #1
    Member Member Delenda est Carthago's Avatar
    Join Date
    Jun 2005
    Location
    A small hole at the bottom of a lake
    Posts
    26

    Default How do i script an AI event

    If, for example, i wanted to script it so that an AI army went from point A on the map to point B, moving every turn, but not in the player's control (i.e a computer controlled opponent) how would i do it? Is it possible?
    Creedy: WE HAVE GUNS!

    V: No. What you have are bullets and the solemn hope that once your guns are empty I will no longer be standing before you, for if I am you will all be dead before you can reload.

  2. #2
    Member Member Dromikaites's Avatar
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    151

    Default Re: How do i script an AI event

    Quote Originally Posted by Delenda est Carthago
    If, for example, i wanted to script it so that an AI army went from point A on the map to point B, moving every turn, but not in the player's control (i.e a computer controlled opponent) how would i do it? Is it possible?
    Yes, you can, but you need to make sure that no other AI faction attack your army on the way to it's destination. So it works best if the army crosses its own lands or passes through friendly ones (military access granted).

    Here's how you can do it (based on an ideea originally by Myrddraal):
    1) You decide for a position were to "hide" that captain. The best would be to create some sort of "labyrinth" of impassable forest and hide your captain there. Unlike generals, captains are immortal so they can wait in hidding for hundreds of turns.
    2) When time comes (an event trigger or a certain turn) you give your captain his army (command_console create_unit ...) then you move him out of the labyrinth and towards his target. You should know how many turns it takes to get him to the intended destination so at every turn your script should check what turn it is and if it's still "early" to order him to move forward.
    3) You may want to send your captain to his destination at a precise moment in history because otherwise (random event-triggered departure) you need to go through hoops in order to preserve the information about how many turns are left till he reaches his destination.
    4) Your captain's army might get attacked on its way to the destination. If the captain is killed, no more expedition. If his army is only defeated, you could replenish it like they do in Prologue but it will be probably impossible to find out where it ran away and how to get from there to the original destination.

  3. #3

    Default Re: How do i script an AI event

    Moved from the Scriptorium to the General forum where all questions belong.
    Epistolary Richard's modding Rules of Cool
    Cool modders make their mods with the :mod command line switch
    If they don't, then Cool mod-users use the Mod Enabler (JSGME)
    Cool modders use show_err
    Cool modders use the tutorials database Cool modders check out the Welcome to the Modding Forums! thread Cool modders keep backups Cool modders help each other out

  4. #4
    Member Member Delenda est Carthago's Avatar
    Join Date
    Jun 2005
    Location
    A small hole at the bottom of a lake
    Posts
    26

    Default Re: How do i script an AI event

    Thank you, i am trying to make a crusade mechanic for Byzantium total war and so i am trying to get this working, could you possibly be more specific about the creation of an event trigger to make the guy actually move and how to make him hide in a forest etc?

    I would be most grateful...

    Quote Originally Posted by Dromikaites
    Yes, you can, but you need to make sure that no other AI faction attack your army on the way to it's destination. So it works best if the army crosses its own lands or passes through friendly ones (military access granted).

    Here's how you can do it (based on an ideea originally by Myrddraal):
    1) You decide for a position were to "hide" that captain. The best would be to create some sort of "labyrinth" of impassable forest and hide your captain there. Unlike generals, captains are immortal so they can wait in hidding for hundreds of turns.
    2) When time comes (an event trigger or a certain turn) you give your captain his army (command_console create_unit ...) then you move him out of the labyrinth and towards his target. You should know how many turns it takes to get him to the intended destination so at every turn your script should check what turn it is and if it's still "early" to order him to move forward.
    3) You may want to send your captain to his destination at a precise moment in history because otherwise (random event-triggered departure) you need to go through hoops in order to preserve the information about how many turns are left till he reaches his destination.
    4) Your captain's army might get attacked on its way to the destination. If the captain is killed, no more expedition. If his army is only defeated, you could replenish it like they do in Prologue but it will be probably impossible to find out where it ran away and how to get from there to the original destination.
    Creedy: WE HAVE GUNS!

    V: No. What you have are bullets and the solemn hope that once your guns are empty I will no longer be standing before you, for if I am you will all be dead before you can reload.

  5. #5
    Member Member Dromikaites's Avatar
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    151

    Default Re: How do i script an AI event

    Quote Originally Posted by Delenda est Carthago
    Thank you, i am trying to make a crusade mechanic for Byzantium total war and so i am trying to get this working, could you possibly be more specific about the creation of an event trigger to make the guy actually move and how to make him hide in a forest etc?

    I would be most grateful...
    Forget all the complicated stuff I suggested above. As of today we know the correct syntax for spawn_army:

    https://forums.totalwar.org/vb/showt...419#post928419

    So you simply spawn the whole "crusade" when you need to. Even though you don't need the "hidding in a labyrinth" solution, here is what I meant by that:
    1) You need to "paint" the impassable forest labyrinth on the map_ground_types.tga (see the map-making tutorials). The purpose of the labyrinth was to prevent an invader to find your captain too easily.
    2)You write down the coordinates of the key points on the way out of the labyrinth, because you need to guide your captain.

    Now about the events that would trigger the Crusades, you can inspire yourself from the code of "4 turns per year" mod here:
    https://forums.totalwar.org/vb/showthread.php?t=44648

    You count the number of turns like it's done there and when it is the right turn you spawn the crusade.

  6. #6
    Member Member Delenda est Carthago's Avatar
    Join Date
    Jun 2005
    Location
    A small hole at the bottom of a lake
    Posts
    26

    Default Re: How do i script an AI event

    You are a life saver, thank you very much!
    Creedy: WE HAVE GUNS!

    V: No. What you have are bullets and the solemn hope that once your guns are empty I will no longer be standing before you, for if I am you will all be dead before you can reload.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO