This tutorial will introduct you to the amazingly big quantity of scripts
available in FA2 to create an offensive AI, or just to make nice teamtype
One thing to point out is that its a shame there is no Guard Unit script.
That would make some awesome AITriggers. An alternative way is using the
follow friendlies, but has not the same effect. I really miss that from
Homeworld, as you could set units to guard your harvesters permanently.
First af all, thanks to DeeZire, for letting us know the unsupported
Actions. And also, cause i learnt all what i know about AI.INI from his
tutorials. Thanks also to Cannis, as i know about the Psychic Amplifier
bug because of him.
Well, let´s now start with what is important, the scripttypes.
The scripttypes are the instructions we give to units to accomplish objetives,
i.e move from a point to another, patrol an area, or simply attack. I will
describe here the types existant, and also the ones not supported by the
editor FA2 on its YR version, that should be written manually.
Before, we will analyse how the script is written on the file, and also,
how you need to write it if doing it manually. The structure is the following:
Name=Move To Waypoint 3
ID must be an unused HEX entry, though in maps its more tidy to use
the next unused ID created by FA2, something like . In HEX this
is much easier, as any string can be used no oreder needed, as for debug
purposes, the only one using it is the creator. So you can use an unused
HEX string like 0C8E57AC-G , HEX strings on AI.INI seem to need that -G
at the end, not sure about this though.
Name is used just to recognize easily what the script does
0 is a little more complicated to explain. Actions in scripttypes are
listed, and this list starts at 0. So action 1 is 0=, action 2 will be
1=, and so on. The other three numbers mean, actiontype and parameter.
The ActionTypes will be described here, so the parameters for each
one which vary depending on the action type, in this case parameter is
Orders the team to attack the target indicated by the parameter. Parmeters
are: 0 (cancel), 1 (anything, threat logic used here), 2 (Structures, any
BuildingTypes), 3 (Harvesters, VehicleTypes with Harvester=yes), 4 (Infantry),
5 (Vehicles), 6 (Factories, Buildings with Factory=yes), 7 Base Defenses
(Buildings with IsBaseDefense=yes), 8 (Enemies Attacking), 9 (PowerPlants,
Buildings with Power=yes), 10 (Civilian Occupiable buildings, In RA2 CanBEOccupied
defines them, in YR CanOccupyFire), 11 Tech Buildings (anyone with NeedsEngineer=yes
and defined in NeutralTechBuildings=).
This was used in ra2 to order units to garrison, infiltrate, capture,
c4, etc structures. However in YR this action is not used for that. Makes
units fire at waypoint defined as parameter.
2=Go Berzerk, no parameter
Makes units in team with Cyborg=yes go attack nearest enemies. (No
units in RA2 use that sentence, unless u add it it won´t work)
3=Move To, Waypoint
Orders the team to move into the specified waypoint.
4=Move To, Cell
Orders the team to move into the specified cell. This is underused,
because its use on missions can be effectively replaced with Move to Waypoint.
5=Guard Area, Time to guard area in seconds
Orders team to guard area for the defined number of seconds. Some docs,
say it´s other quantity of time, but for my experience these are
seconds. So if line is 0=5,10 , script orders team to guard the area where
they are for 10 seconds
6=Jump To Action, Number of Action in ScriptType
This action is used for patrol loops mostly, it makes the team repeat
the specified action on the same script it is written on, and the next
ones till he finds again this jump to accomplish again all. So you put,
Move To Waypoint 1, Guard for 5 seconds, Move To Waypoint 2, Guard for
5 seconds, and Jump to Line 1, so that the team makes action 1 again, and
that way you create a patrol loop. Parameter is lines, and lines are not
listed here so the first action you add, will be line 1, though code says
action 0 (cause actions are LISTED).
7=Force Player Win
Forces the owner of the teamtype to win the game.
8=Unload, type of unload
Used for units with Passengers=yes, what they do is unload their passengers.
Parameters are 4 and are referred to what units will continue achieving
the rest of the script. 0 means transport and units will comply rest of
the scripts, 1 means only transports, 2 means only units, and 3 no one
Makes deployable units (like GIs) deploy (Deployable units are the
ones which have Deployer=yes, DeployFire=yes, DeploysInto=(BuildingType),
and Deploy To Fire, this last was the concept used for Juggeranut and Artillery
As mentioned this script will make units in team follow the nearest
friendly units, works for escirt but not for guard as mentioned before
This makes units do what the parameter, says, note some of the MissionTypes
(Defined in Mission Control in rules.ini) are obsolete.
0 Sleep (object will not acquire targets), 1 Attack not specifed, 2
Move (no use for this here, just as support for previous move action),
3 QMove (move after other queued moves occur, haven´t tried this
yet), 4 Retreat (object retreats, it can even leave the map), 5 Guard (fire
at whatever that enters his weapon range), 6 Sticky (Same as previous,
but will not follow target) 7 Enter (building or transport, found no good
use for this) 8 Capture (used for MultiEngineer logic, no use either),
9 Eaten (something to do with repairs), 10 Harvest (Go collect ore and
unload at refinery), 11 Area Guard (guard the area where object is), 12
Return (makes a spawne unit,like a hornet, return to spawner, i.e carrier).
13 Stop (stand, stop firing and moving), 14 Ambush (force fire in YR, obsolete
in RA2), 15 Hunt (seek and attack enemies), 16 Unload (..., not used since
we have another script fo this, though it is useful on some special cases,
i.e transports with weapons), 17 Sabotage (Units with C4 or Ivan runs place
explosives on buildings), 18 Construction (seems to have no effect un units,
as its internal for structures), 19 Selling (seems to have no effect un
units, as its internal for structures) 20 Repair (repairing an object in
Service Depot), 21 Rescue (haven´t seen it used yet) 22 Missile (Nuke
launch mission, internal only) 23 Harmless (object not considered threat,
doesn´t retaliate or passive acquire) 24 Open (opening or closing
a gate, internal only) 25 Patrol (Patrol waypoints, internal use) 26 Paradrop
Approach (order plane to appreoach drop site, internal) 27 Paradrop Overfly
(order plane to drop the paratroopers) 28 Wait (waiting new mission) 29
Move (used for chrono moves), 30 Attack (for weapons with area effect),31
Spyplane Approach (Spay Plane on route YR) 32 Spyplane Overfly 8Spy Plane
You should have noticed that i said internal in seveal missions, this
is because this actions are used for superweapons and buildings, or special
locomotors like Chrono. Missile is ID for nuke launch, and approach are
missions that make pdplane approach and recognize the landing zone. Actually,
maybe there is a way thorugh adding new superweapons by modifying the mission
types, problem is it would modify all of the same type.
12=Set Global, variable
Sets the specified Global variable.
13=Play Idle, sequence number
SHP Infantry will play its specified Idle animation, usually there
14=Load Onto Transport
Units able to do so in team will enter a transport if present on team.
15=Spy on Building at waypoint, waypoint
This is obsolete from TS, used for Chameleon Spy logic, as he returned
when he infiltrated (didn´t remain in structure) That´s now
replaced by attack structure...desired structure, but make sure to use
move to enemy building before, and place a secondary option, spo that if
building to spy is destroyed, spy tries something else, and does not sit
waiting for death.
16=Patrol To Waypoint
This action is used for teams to move to a waypoint by scanning enemies
on each step. DeeZire is right on his docs, these script makes slowdowns,
because having too much of them causes the processor to work more, as units
scan enemies for every cell they move, and all have different Sight values.
Luckily, this problem can be solved by using time defined patrols. Consits
on give birth of a team at the other edge of the map where the player still
cannot enter, when another dies, this mantains the same quantity of work
on processor and keeps fps estable.
17=Change Script, number of script in ScriptTypes list
Makes units do another script it´s like a GOTO sentence in VB.
Parameter is number of script in the list of ScriptTypes (remember list
starts at 0, so script 1 will be number 0)
18=Join Team, specified team from TeamTypes list
Orders taskforce to join the specified team, and accomplish it´s
orders. Same list note, starts at 0.
Makes units in team with Fraidycat=yes and an anim in the SHP play
their panic animation.
20=Change House, House
Makes units in team change its owner to the house specified (0=America,
1=Korea, 2=France, 3=Germany, etc, defined in the houses list)
Instructs taskforce to scatter from threats
22=Run To shoroud
Object will get afraid and go to nearest shroud, when fired at it,
it will scatter, and will not return fire, or acquire targets
Forces a loss condition for owner of teamtype
24=Play Speech, Speech number in EVA.INI
Plays the specified speech, parameter is number of speech in [DialogList]
in EVA/EVAMD.INI. Author (EVA, Zofia, or the other guy) is defined by ParentCountry
on the correspondant house.
25=Play Sound, sound number in sound.ini
Plays the specified sound, parameter is also number from list in sound.ini
26=Play Movie, movie number in art.ini
Plays the specified movie (pauses game and plays it centered, as common
videos and not as transmission)
27=Play Theme, theme number in theme.ini
Plays the specified theme, parameter is number of theme in theme.ini
Reduces ore in the cell the team is on, used for Harvest action
Forces Owner to start AI standard behaviour (skirmish). Use only on
Owner of teamtype will sell all his structures.
Units in team .... suicide. Used for civilian movements on map and
out map, so that edges do not clutter up. Used also to make something be
32=Start Weather Storm Ambient
Starts te intro of the weather storm, parameter is a number of seconds
that causes a delay on reproduction. This is intro of storm, NOT storm
33=End Storm Ambient
Ends the effect of the previous script, restoring standard lighting.
34=Center Map On Team, Speed
Very useful script, moves camera to focus on the teamtype, parameter
is speed of move, 0 is instant. Like hitting the F key while an objects
35=Shroud Map For, Frames
This shrouds map for the specified number of frames (15 frames = 1
second approx). Then explored areas are revealed again
36=Reveal Map For, Frames
This reveals the map for the specified number of frames. Then unexplored
areas are shrouded again.
37=Delete Team Members
Deletes members of a the team, by making them leave the map.
Clears the value of the specifed global (number on globlas list in
Sets the value of the specified local to 1 (or true). Parameter is
number of local in the list of LocalVariables in the map file
Clears the value of the specified local cariable. Parameter is same
as above action
Team memebers which are in panic mission will return to normality.
42=Change Facing, facing to... face.
Changes the facing of the units, parameter is number of direction,
0 is north, 1is northeast and so on going clockwise.
43=Wait until loaded
Used for several things like expecting a transport to be full before
executing other action.It also enables use of TransportsReturnOnUnload
sentence, and also sets the transport to be recruitable after performing
the following action/s. No need to use it really.
Converts TRUCKB units into TRUCKA (the ones in team), used as graphical
effect to give the impression truck has unloaded. Residual from TS, as
in RA2 the TRUCKA image is the Demo Truck. But if you add a new TRUCKA
45=Load Truck, Same as above but inverted, converts TRUCKA in TRUCKB
46=Attack Enemy Structure, structure
Orders team to attack, c4, infiltrate, capture, depending on type of
unit, the specified building. As side note, you might see certain numbers
as parameters, like 131072, that still means PowerPlant, this and more
numbers are used for internal tables. There should be no problem on defining
the given number of structure though the Psychic Amplifier is listed twice
so all down there should be substracted by 1, and there might also be more
unused numbers, so several number parameters in FA2 might be uncorrect.
47=Move To Enemy Building
Orders team to move near the specified enemy building. Used specially
for spies. And same parameter and editor bug as above,
Makes units move to a random (preferably shrouded) point till they
cannot do so more. Action means reveal as more of the map as u can. Problem
is that when it arrives to the point it stands there and do nothing, it
is slovable by looping the action.
49=Repeat Until Success
Used to make sure teams complete missions, i.e, you set an Attack Infantry
Action, and then this, and as result you will get team will not follow
script until ALL enemy infantry is killed. Sort of do until cannot do anymore.
50=Flash, number of flashes
Makes object do the flash effect, so that it has a little glow of light.
Parameter is the number of flashes you want to happen
51=Play Anim, animation
Plays the specified animation (they are defined in rules.ini) Parameter
is list number. Be careful as the list is uncorrect, and the numbers in
FA2 do not work as they should, as in the array, the eidtor does not write
jump numbers so if 2 is unexistant for game, then 3 is 2, but in-game this
can vary. This is the biggest headache for Map-Makers, certainly, besides
This was used in TS for expressing emotions on units, on certain missions,
andits residual, but works if you add the file TALKBUBL.SHP, the parameter
is the emotion to display (concerns with the animation frame). 1 is *,
2 is ? and 3 is!
53=Gather at enemy
This action makes taskforce gather forces at a distance of enemy base
defined by AISafeDistance in rules.ini
54=Regroup at friendly base
Make steam members stick all together leaving no spaces or empty cells
between them. Used before Chronosphere and IronCurtain Actions
55=Wait for Iron Curtain
Team members will be Iron Curtained by their AI owner, if AI chooses
it. This is defined by AIMinorSuperReadyPercent in rules.ini . The higher
the percent is the higher chances you will get the tem Iron Curtained.
Using the same statement as previous action defines a favourite for
chronosphere use, parameter is building to be teleported to (number of
building in BuildingTypes list, notice there is the same Psychic Amplifier
bug) Needs following action to work
Orders an attack quarry for the team and points a target to be teleported
to (still don´t get this, as it´s defined twice??). Also uses
58=Move To Friendly structure, nº of structure
Basicly, same as move to enemy building, just with allied buildings
(even other house) Parameter is the number of structure in BuildingTypes
list, and the same Psychic Amplifier bug is present
ONLY YR: (Thanks to DeeZire for pointing these ones out)
59=Attack Structure at Waypoint
Used to substitute the attafck building, infiltrate or capture orders
in SP missions, infiltrators will infiltrate, engineers will capture/repair,
c4 will blow em up, etc. Parameter is waypoint (Note waypoint must be placed
on a structure)
Objects will enter the nearest structure with Grinding=yes
61=Enter Tank Bunker
Bunkerable vehicles will enter nearest Bunker=yes structure
62=Enter Bio Reactor
Infantry units will enter nearest building with InfantryAbsorb=yes
set, checking before if building is full.
63=Occupy Battle Bunker
Occupants will enter nearest OWN bunkerable structure
64=Garrison Nearest Structure
Occupants will enter nearest CIVILIAN bunkerable structure. Substitutes
Attack Waypoint garrison method
Well that´s all, mess around with these actions, something really
interesting can be done.