After many hours of frustration and trial and error, I think I finally have AI scripting figured out. It has taken a lot of time, as there is a lot of contradictory information out there. Some of it works, much of it doesn't. Here I want to present the facts on adding AI in to a mission. I think this might be lengthy, so I am going to do a little bit at a time. I'm going to begin with one simple example, scripting AI for an enemy ship.
1. Create Ship event - the ship must be named manually when you create it (e.g. T26). The creation of the ship must occur in a separate event to any event in which you want to assign it AI commands. Set up a variable and a timer (only 1 second is needed) to trigger the AI event.
2. AI event - this event contains all the code for what you want the ship to do. When both the variable has been triggered and the timer has finished, this event will run. Note; the delay from the timer is essential. Without it, some events in this block will not activate properly; "Add_ai" and "Object_property" commands need the delay.
3. Script the AI - now you can add commands to your hearts content using the different commands.
- Base AI for a ship seems to be simply "Attack Player ship". The enemy vessel will set a course to attack your ship.
- "Clear AI" should be used if you want to
completely rewrite the AI. The enemy ship will move towards coordinate 0,0,0 on the sector map (top right corner) ignoring everything. It will not attack anything, or retaliate if attacked. You must add new AI to make the ship function as you want. Ensure that it is the
first instruction in the event if you want to completely rewrite a ship's AI.
- Order is key in AI scripting. "Clear_AI" (if used) should be your first action. Under that, "Add_AI" actions will be prioritised based on their
actual order.
E.g. Setting "Attack Artemis when it is within 1000m"
above "Attack friendly bases" will result in the following:
--- The enemy ship will move to attack your base if you are more than 1000m away from the enemy ship.
--- When you come to within 1000m of the enemy ship, it will turn to attack you.
--- When you move over 1000m away from the enemy ship, it will turn back to attack your base.
That's some of the basics. I will add and edit more later.
If you need anything clarified, please ask. The information has been gathered through observation, trial and error, and research and reading on what other people do. It has been tested and I have used it in my mission scripts successfully. The methods outlined above work. If for some reason you find they don't, please contact me directly and I will check and correct any errors.
[Last edited Jun 14, 2013 23:07:21]