AI basics
the problem
solutions?
AI scripts
the triggers
the .zip file
prefabs
'office'
[email protected]
|
I don't know wether I've stated this before or not, but this page
CANNOT REPLACE modmaker's tutorial and the docs that came with the tools
(I'm talking about the avp2_AI_notes.doc file). Read them if you plan on
expanding this prefab; you'll need some info about AI Volumes and AI commands
that can be found in those docs. If you're only after a copy-paste prefab,
or you're experienced enough with AvP2's AI, you can skip them.
a. Describing the problem
What does an escort actually does? It follows the player anywhere he/she
goes and, when spotting an enemy, opens fire. The AI that escorts the
player must be able to receive orders like 'Follow me' and 'Hold ground'.
Either way, the AI must attack any enemy within his range.
So all we have to do is to give our AI an iddlescript and keep adding
commands like scr+ (run; mt player;) to the script. We can continuously add
this command using some sort of loop.
The fact that it's an iddlescript will alow the AI to break the script to
engage enemies. Although it's something that we want, it does have one bad
effect: the AI, having the script terminated by engaging the enemy, will
not obey further scr+ commands. We'll need another loop that periodically
starts a new iddle script.
How do we 'persuade' this pesky marine to stop following us? Well, that's
easy: kill it's scripts (the 'killscripts' command) and terminate the loops.
To make it follow the player again, give it a script and restart the two
loops.
b. Looped triggers
Place two triggers, both of them with a 'SendDelay' of one second and make
them trigger each other: triggerA should have as target triggerB and
viceversa. Trigger any of them and you'll get a 2 seconds period loop. Each
two seconds triggerA gets triggered. To break the loop, send the 'lock'
message to one of the triggers. To restart the loop, send the 'unlock' message
to the locked trigger and then trigger any of them. That easy.
In our case, we'll need two loops, one with a short period that'll send the
'scr+' commands and one with a longer delay, that kills the script and start
a fresh one.
c. The scripts
The following images contain explicit scenes and should not be viewed by
any audience. This images are for mappers' eyes only :-)
First, the structure of one AI escort unit:
 |
The EAIMarine0 is the A.I. unit that
gets to follow your ass.
loopA0 and loopB0
make up the
'short-fused' loop.
loopC0 and loopD0 make up the second
loop; it keeps killing the AI's script
and starts a fresh one.
|
FollowMe0 unlocks the loops and restarts them after starting a new
script. HoldGround0 does the oposite: kills all scripts and locks the loops.
Here are the settings and commands for the AI unit:
 |
I know this is a little bit unusual,
but I've set the AI unit to be
indestructible. That was achieved by
setting the 'NeverDestroy' flag to
TRUE (see 'DamageProperties' for the
AI unit).
However, the interesting part takes
place in the 'Commands' section and
the goals selected in 'Goals'.
As you can see, I choosed only the
'Attack' and 'Iddlescript' goals:
|
The third goal makes the unit look more natural while holding ground.
The other stuff I was talking about is the 'Commands' section. Placing
messages in here will alow you to use the AI unit much like a switch:
Although the AI unit works fine without the initial section, I've placed
a message there too; it will start an iddlescript that tells the unit to
move towards the player. This string is send when you 'USE' the unit for
the first time.
So, if we press 'USE' while facing EAIMarine0, we'll trigger either
FollowMe0 or HoldGround0.
As stated earlier, these two triggers unlock and start the loops or do
the oposite. The settings and targets for the FollowMe0 trigger:
What does it do? Unlocks and starts the 'short-fused' loop that sends the
scr+ messages, unlocks and starts the lazy loop (the one that kills all
it's script and starts a fresh new one, to make the AI escort you even after
engaging an enemy). It also starts the iddlescript for the AI unit, makes
it say something and allows it to move anywhere (leash lenght is set to 0).
The 'short-fused' loop has the loopA0 trigger and
loopB0 trigger. Those two are almost identical, except
the last target. The settings and targets for the loopA0 trigger:
The loopB0 trigger has it's second target set to
loopA0. Except that, they're twins.
The second loop contains the other two triggers I was talking about:
loopC0 and loopD0. As in the previous
case, the triggers are almost identical, except the last target.
Settings for loopC0:
As seen here, the second loop kills all the scrips the AI had and starts a
fresh new one. It also makes sure to keep the short-fused loop runing. The
last target makes sure the lazy loop itself is kept runing.
The loopD0 counterpart has the same settings and targets, except
TargetName3; it's value is 'loopC0', to keep the lazy loop runing.
From 'HoldGround0' we'll expect to kill all scripts and lock one trigger
in each loop:
And you were right; it also makes the AI say one phrase and gives him a
384 units leash around the point it was ordered to guard.
If you plan to add more units like these, the only thing you should be
aware of is to change the 'Commands' section so that EAIMarineXX sends
his messages to FollowMeXX and HoldGroundXX. The triggers themselves
are excellent connected, so you won't need to change anthing there when
copy-paste -ing folders containing units like these; your only concern will
be the 'Commands' section. So, copy-paste whole folders and change the
'Commands' section for each AI unit.
The .zip file will have both the .ed and this .html page. The .ed file is
a small map, that has 3 EscortUnits and a multispawner, triggered by 4 wall
switches. Toy with your escort, make them guard you or their last position
with or without enemies. See how they behave.
Hopefully, this will spell the end for those SP missions that left you
alone to deal with your enemies.
|