View Full Version : How do i script an AI event
Delenda est Carthago
09-19-2005, 20:44
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?
Dromikaites
09-19-2005, 23:09
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.
Epistolary Richard
09-19-2005, 23:50
Moved from the Scriptorium to the General forum where all questions belong.
Delenda est Carthago
09-20-2005, 11:33
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...
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.
Dromikaites
09-20-2005, 19:14
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/showthread.php?p=928419#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.
Delenda est Carthago
09-20-2005, 20:59
You are a life saver, thank you very much!
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.