TAI file modding - EE-modders/Empire-Earth-toolbox GitHub Wiki
I asked a while ago if anyone knew anything about modding with the Unit TAI (Unit AI) files. Nobody did, so I left it at that. However, lately JCGF's hex editing has got me back into the spirit of modding, so I started looking into these files more.
.TAI files are pretty easy to understand, fortunately. They can be opened in notepad and are basically just a script - they're mostly understandable to anyone who opens them.
The different .TAI files belong to different classes of units and buildings - helicopters, citizens, gates, everything.
Modding TAI files will change the way units react to their different states and other units around them. Some theoretical uses:
- Stop units from tracking enemies (make them stationary)
- Stop requiring units to reload before attacking (see below for some fun pictures of this!)
- Make units indestructable
- Stop transports from loading or unloading units
- Make units track enemies that wouldn't normally
Fly Through the Air with the Greatest of Ease: http://i429.photobucket.com/albums/qq18/bmaczero/Keep/FunWithMissiles.jpg
Machine-Gun Towers: http://i429.photobucket.com/albums/qq18/bmaczero/Keep/FunWithTowers.jpg
The Sky is Falling: http://i429.photobucket.com/albums/qq18/bmaczero/Keep/Volcano.jpg
I've also learned some interesting things from reading the comments in the AI files. For example, did you know that Trojan Horses can go through enemy gates, even if they're locked?
The TAI files also give insight into some units that the developers may have intended to include, but didn't. There are several unused TAI files, such as one for a priest-prophet hybrid, a unit-producing building that also acts as a tower, and a building that gathers resources.
I have a theory that these unused files can be assigned to units via hex-editing the dbobjects file. By changing the unit's classification in the dbobjects file, I think EE might assign it a different AI file. It would be neat to have a barracks that could shoot at enemies .
But you don't need to hex to mod with TAIs!
The scripting language used by these files seems to work in a pretty straightforward fashion.
At the beginning, we have a block of text containing the name of the AI, what it's intended to do, and some other comments. These lines are all started with //. This prefix comments out the line - the program will completely ignore any line with // before it.
Then comes the code. The main part of the code consists of statements in this form:
State { Condition true(SetState) false(SetState) }
The "State" part will be the name of a state the unit might be in. If the unit is in that state, the program will check any conditions inside the statement and execute the result.
The "Condition" will be a statement of something the unit might be doing or that might be happening around it. This is followed by true() with a state in parenthesis and/or a false() with a state in parenthesis. If the condition is true, the unit will be set to the state after the true(). If it is false, the unit will become the state after the false().
Multiple conditions can be accounted for by putting anyof() and listing comma-delimited conditions in the parenthesis. This will be true if any one or more of the conditions are true. There is also allof(), which will only be true if every condition listed is true.
Only certain words and phrases are legitimate states and conditions, so look through the files to see what you can use.
Oh, there's one last command that is used often in the TAIs. This is #include(filename). In the parenthesis will be the name of another TAI file. The #include command will append the entered file onto the one containing the command. This is used a lot for including often-used states such as dying and attacking.
I bet you want to try out that missile example I put a picture of up above. For that, open up the "missile base.tai" file.
In there, you can see a state called "WaitForReload". Guess what this does? The condition in there is "Reloaded". Replace this, and the other "Reloaded" condition below it with AlwaysTrue. Save the files as "missile base.tai" in Empire Earth/Data/Unit AI Scripts.
Run and have fun.