Ambushes

Ambushes are scripted events, as seen in many campaign maps, that cause AI to spawn without a command post. An ambush can either be activated by entering a region or by triggering some event.

The First Method

To create an ambush the first way, first one needs to lay spawn paths for the AI to spawn from. This path may be named arbitrarily, but the name will need to be referenced later. The number of nodes is also arbitrary but will also be referenced later. A trigger region must also be created. The name for this region is also arbitrary, but will be referenced later as well (Note: the Region ID is just for reference within Zeroeditor, the important name to remember is the Class Properties/Type name).

The rest of the process is dealt with in the .lua script of the mode that has been edited. Open up this .lua script and add the line

ScriptCB_DoFile("ambush")

below the other similar lines at the beginning of the script. The ambush team must be a separate team from the two already established, so a new team must be created with arbitrary name and number. Under SetupTeams{…}, units should equal the number of spawn nodes added in Zeroeditor, reinforcements should be -1, and the max and min values for the soldier added should be the same and both be equal to the units number. Use SetTeamAsFriend and SetTeamAsEnemy to make sure that the ambush team is allied to the side that they should be (if either). Make sure to add
ClearAIGoals(***)
AddAIGoal(***,"DeathMatch",100)

where the *** is the name of the ambush team so that the ambush will work like it should. The DeathMatch is suggested because then they will kill until they are killed, and the 100 is just a large number that is the number of units killed before the goal is complete. It is also advisable to add
SetTeamName(***,###)

where *** is again the ambush team and the ### is the team they are allied to, so that the ambushers don't show as [null] in game. The last addition is SetupAmbushTrigger with four arguments, the name of the region used for the ambush (in quotes), the name of the spawn path (in quotes), the number of spawn nodes placed, and the team from which the ambushers come. This last bit of scripting is placed below the EnableSPHeroRules() in the .lua.

The Second Method

The other way to cause an ambush is by using Ambush(), which has three arguments, the spawn path (in quotes), the number of ambushers, and the team from which they come. This ambush happens immediately, so it is necessary to incorporate it within a looping structure.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License