Jump to content
Sign in to follow this  
KC Grimes

Wave by Wave Enemy Fighting

Recommended Posts

So I am working on a CoOp in which your squad is in a building, and wave after wave of spawned enemy assaults the house.

I'm going to keep this as simple as possible.

Get into the building, radio alpha, this execVM "spawngroup1.sqf"; and then the first wave spawns.

spawngroup.sqf

_pos = getmarkerPos "enemygroup1";

_skill = [0.1, 0.5];

_side = EAST;

_units = ["TK_Soldier_SL_EP1", "TK_Soldier_EP1", "TK_Soldier_GL_EP1", "TK_Soldier_AR_EP1", "TK_Soldier_EP1", "TK_Soldier_GL_EP1", "TK_Soldier_AR_EP1", "TK_Soldier_EP1", "TK_Soldier_AT_EP1", "TK_Soldier_EP1", "TK_Soldier_GL_EP1", "TK_Soldier_AR_EP1"];

EnemyGroup1 = [_pos, _side, _units, [], [], _skill] call BIS_fnc_spawnGroup;

sleep 3;

{

_x setskill ["aimingAccuracy",0.15];

_x setskill ["spotDistance",0.75];

_x setskill ["spotTime",0.85];

_x setskill ["courage",0.65];

_x setskill ["commanding",0.85];

_x setskill ["aimingShake",0.15];

_x setskill ["aimingSpeed",0.55];

} foreach units EnemyGroup1;

_ewp1 = EnemyGroup1 addWaypoint [getMarkerpos "enemywp", 10];

_ewp1 = setWaypointType "SAD";

_ewp1 = setWaypointSpeed "NORMAL";

_ewp1 = setWaypointFormation "STAG COLUMN";

That part works. Now, I have another trigger that was placed on the map editor (not spawned).

Condition:

{alive _x} count units EnemyGroup1 == 2

That works. But when I add this to the on act

OnAct:

nul = this execVM "spawngroup2.sqf";

It works the wrong way. Whats happening is when EnemyGroup1 is spawned, the units come in one by one, for a millisecond being 2, which is triggering the spawn of EnemyGroup2.

What I want is for EnemyGroup1 to spawn, then when there are only 2 left in the squad, EnemyGroup2 is spawned by executing "spawngroup2.sqf". Does anyone have any idea how to do this with my current setup, with a change or addition to keep EnemyGroup2 from spawning while EnemyGroup1 is spawning?

Share this post


Link to post
Share on other sites

Add another condition to your trigger, "and okToSpawn", and have the code that spawns the new group set okToSpawn to FALSE when it starts spawning the units, and TRUE when it's done spawning them. Default it to TRUE in your init.sqs or somewhere so that your trigger works the first time. Essentially this disables your trigger until your code is done running.

Share this post


Link to post
Share on other sites

okToSpawn false;

That just stops the script. Did I not put it in right?

Share this post


Link to post
Share on other sites

Couldn't you just get away with a trigger delay of about 5 secs that would give enough time for spawning to take place wouldn't it.

Share this post


Link to post
Share on other sites
Couldn't you just get away with a trigger delay of about 5 secs that would give enough time for spawning to take place wouldn't it.

Yeah, shouldn't that work? Or another sleep behind the first spawn? A condition in the waypoint? A completion radius? An additional condition?

Share this post


Link to post
Share on other sites

A simple while would fix it.

while { waves > 0 } do {
_group = [vars] call your_spawn_function;
while { ({alive _x} count _group) > 2 } do { sleep 5; };
waves = waves - 1;
}

Share this post


Link to post
Share on other sites

Murklor, I was also thinking about a waitUntil. 'while' did not even cross my mind. How would you do that with a waitUntil (or that would not be good)?

Share this post


Link to post
Share on other sites
;1742173']
okToSpawn false;

That just stops the script. Did I not put it in right?

okToSpawn=false, and then when you're done spawning them with your spawning code okToSpawn=true to allow it again. It's just a variable to temporarily disable the trigger while the spawn code is running.

Share this post


Link to post
Share on other sites
okToSpawn=false, and then when you're done spawning them with your spawning code okToSpawn=true to allow it again. It's just a variable to temporarily disable the trigger while the spawn code is running.

Awesome, that works. Thanks very much, never did know how to use that kind of thing.

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  

×