Jump to content
Sign in to follow this  
NickThissen

Ambush: make AI move without caution

Recommended Posts

Hi,

I have set up a sort of ambush in my co-op mission where a large number of enemy soldiers spawn on a trigger and start to converge on the players via a single 'chokepoint' on the map (the area where the players are is only accessible via that one passage way). I make them move with waypoints, with the combat mode set to 'Open fire, engage at will' and speed to 'Full'. I have tried various behavior settings.

When I don't engage the enemy (eg if I spawn as an enemy unit to test) they do what I want; they run through the passageway to follow their waypoints as fast as they can. However, when they are engaged (as in a real mission scenario), they completely fail to do that. As soon as I fire a shot or two, they will all drop to the ground and stay there. I have tried various waypoint behaviors to change this (eg 'careless', 'aware' and 'combat') but it doesn't really change. It seems only 'aware' is a behavior that fits with an ambush scenario (soldiers running), if I choose careless they are just walking with their weapons to their sides, and if I choose combat they will use cover on their way to the ambush point (takes too long to get there).

What I want is simple: make the AI run through the passageway as fast as they can to ambush the players. When they are shot at, they may crouch or try to find cover to return fire, but the other enemies should not "care", but keep running. Certainly they should not drop to the ground and stop in their tracks, that completely destroys the purpose of an ambush since all the players have to do is shoot a few times and they have all the time in the world to get away because the 30 enemy soldiers are all chickening behind a wall some 100 feet away, out of sight...

How can I force this behavior and make them less careful? Is it possibly because they are part of a group so that one soldier in the group getting shot at means they are all going into 'cautious mode'?

Share this post


Link to post
Share on other sites

I tried it but it does not seem to do anything at all. They still drop down and stop in their tracks when other enemies around them get shot.

Here's my script:

hint "A large amount of enemy troops were spotted converging on your area, get ready to defend the chokepoint!";

// Show some markers on the map 
"ambushMarker1" setMarkerAlpha 1;
"ambushMarker2" setMarkerAlpha 1;
"ambushMarker3" setMarkerAlpha 1;

// Array of possible soldiers (regular soldier listed more often so it has a bigger chance)
_soldiers = [
	"O_Soldier_F", 
	"O_Soldier_F",
	"O_Soldier_F",
	"O_Soldier_F",
	"O_Soldier_F",
	"O_Soldier_F",
	"O_Soldier_lite_F", 
	"O_Soldier_AR_F", 
	"O_medic_F"
];

// Spawn position
_pos = getMarkerPos "ambushSpawnMarker";
_range = 2;

// Get the group of the unit that defines the waypoints
_grp2 = group ambushUnit;

// Spawn 16 units
for "_i" from 0 to 15 step 1 do
{
// Create a new group for each unit
_grp = format["group%1", _i];
_grp = createGroup east;

// Copy the waypoints of the ambushUnit to make the new unit follow the waypoints
_grp copyWaypoints _grp2;

// Create a new unit
_soldier = _soldiers select floor(random(count _soldiers));
_unit = format["_unit%1", _i];
_unit = _grp createUnit [_soldier, _pos, [], _range, "FORM"];

// Allow fleeing to 0 so they don't flee when getting shot at
_unit allowFleeing 0;

sleep 1;
};

The way it works is as follows:

- I have a enemy unit 'ambushUnit' that has some waypoints defined. These waypoints will be copied to the units spawned in the script.

- The ambushUnit gets teleported to the other side of the map when he reaches the first waypoint. This is done to prevent him being killed (when he is killed his waypoints are gone and the spawned units don't follow them).

- When I hit a trigger the script gets executed.

- The script gets the group of the ambushUnit (now safely out of the way) so it can copy his waypoints to the new groups

- In a for loop, 16 new groups and new units are created. One unit per group, which I thought might make them work together less (eg they don't care if another unit nearby is shot, because they are not in the same group). No clue if this works but it's worth a shot I guess.

- I also set the allowFleeing to 0 for each unit.

Should this work or am I doing something wrong? Thanks.

Share this post


Link to post
Share on other sites

Might be worth trying

_unit setUnitPos "up";

Will stop them from trying to crawl. You will need to setUnitPos "auto" when they reach their waypoint if you want them to be able to crawl or crouch.

Share this post


Link to post
Share on other sites

In the leaders init line:

{_x allowFleeing 0; _x disableAI "FSM"; _x setUnitPos "UP"} forEach (units this); group this enableAttack false;

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×