The What, When, Where, and How on AI Ambushing (FAQ)
Posted: Sun Jul 16, 2006 9:46 pm
The tutorial will cover on the use of the Ambush.lua script.
EDIT: 2nd scripting method has been added.
What is AI ambushing?
It's a system that allows you to spawn AIs wherever and whenever you want. It was used heavily in the campaigns.
How is the tutorial going to teach me?
Showing the process needed to create an Ambush, including 2 different ways to script it
To Begin
Make a template map with conquest and Clone Wars only. (hopefully you know that much already)
Open zeroeditor and load the the map you just created.
First thing needed for an ambush is path that the AI ambushes will spawn from.
Enter Path Editing mode and create a Path with 6 nodes (must be 6 you will see why later in tutorial) as shown in the picture below. Name this path "ambushpath" (without quotes)
Second thing needed is a region that will act as a trigger to spawn the ambushers
Enter Region Editing mode and create a region and name it "ambushregion" as shown below.
ALSO: It is highly recommended that you place an object in the region to mark the region in game.
Save zeroeditor and close.
Open the clone wars conquest script
Add the highlighted parts:
This calls the script used for ambushing
We must create a new team for the ambushers (i'm calling it team 5. You can also create as many ambush teams as you want, the engine can handle it
Set up the team here: (note: six path nodes, six units)
Set up friendly and enemy stuff and ai goals. (Note I forgot something in this pic. ADD THIS TOO: SetTeamName(ATM, CIS) this keeps the names oof the individual dudes from being [NULL].
Add this line to ScriptPostLoad. This is the actual code that makes it happen.
AHHH!! HOW DID I SCREW THIS UP??? IT'S SUPPOSED TO BE
SetupAmbushTrigger
The generic stuff on the parameters of SetupAmbush is this:
SetupAmbushTrigger(TriggerRegion, PathName, numDudes, fromTeam)
Now munge everything. Play the map and enter the region which you should have marked earlier and BOOM you're surrounded.
THE OTHER METHOD: AMBUSH()
Alternatively, you can you use a function called Ambush(). Ambush() doesn't have a trigger region and will force the ambushers to spawn immediantly when called so it's best to link Ambush() to another event like when an object dies or a timer elapses.
The generic parameters for Ambush() as follows
Ambush(ambushpath, numDudes, fromTeam)
IMPORTANT RULES:
1) The number of ai that you spawn MUST be the same as the number of nodes you added to the path in zeroeditor.
2) The AmbushTeam cannot capture cps nor should it ever possess any cps.
EDIT: 2nd scripting method has been added.
What is AI ambushing?
It's a system that allows you to spawn AIs wherever and whenever you want. It was used heavily in the campaigns.
How is the tutorial going to teach me?
Showing the process needed to create an Ambush, including 2 different ways to script it
To Begin
Make a template map with conquest and Clone Wars only. (hopefully you know that much already)
Open zeroeditor and load the the map you just created.
First thing needed for an ambush is path that the AI ambushes will spawn from.
Enter Path Editing mode and create a Path with 6 nodes (must be 6 you will see why later in tutorial) as shown in the picture below. Name this path "ambushpath" (without quotes)
Hidden/Spoiler:
Enter Region Editing mode and create a region and name it "ambushregion" as shown below.
Hidden/Spoiler:
Save zeroeditor and close.
Open the clone wars conquest script
Add the highlighted parts:
This calls the script used for ambushing
Hidden/Spoiler:
Hidden/Spoiler:
Set up the team here: (note: six path nodes, six units)
Hidden/Spoiler:
Hidden/Spoiler:
AHHH!! HOW DID I SCREW THIS UP??? IT'S SUPPOSED TO BE
SetupAmbushTrigger
Hidden/Spoiler:
SetupAmbushTrigger(TriggerRegion, PathName, numDudes, fromTeam)
Now munge everything. Play the map and enter the region which you should have marked earlier and BOOM you're surrounded.
THE OTHER METHOD: AMBUSH()
Alternatively, you can you use a function called Ambush(). Ambush() doesn't have a trigger region and will force the ambushers to spawn immediantly when called so it's best to link Ambush() to another event like when an object dies or a timer elapses.
The generic parameters for Ambush() as follows
Ambush(ambushpath, numDudes, fromTeam)
IMPORTANT RULES:
1) The number of ai that you spawn MUST be the same as the number of nodes you added to the path in zeroeditor.
2) The AmbushTeam cannot capture cps nor should it ever possess any cps.