fusion13 11 Posted December 18, 2013 Hello I am using the following script to spawn a wave of two enemy groups, After dead I want it to playSound "Over"; but it will play sound when only one spawns, I know its probably the fact Im delcaring two "_groups" but and help?? private ["_group"]; _SpawnWave = { _group = [getMarkerPos "spawn1", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; _group = [getMarkerPos "spawn2", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; //set skill array works magic { _x setSkill ["general",1]; _x setSkill ["aimingAccuracy",0.1]; _x setSkill ["aimingShake",1]; _x setSkill ["aimingSpeed",0.1]; _x setSkill ["endurance",0.3]; //no longer works? _x setSkill ["spotDistance",0.2]; _x setSkill ["spotTime",0.7]; _x setSkill ["courage",1]; _x setSkill ["reloadspeed",0.5]; _x setSkill ["commanding",1]; _x doMove getpos movetoPosition; //make the unit move to the position } forEach units _group; }; for "_i" from 1 to 1 do { [] call _SpawnWave; waituntil {{alive _x} count units _group == 0}; }; Share this post Link to post Share on other sites
mikie boy 18 Posted December 18, 2013 place the group creation in a for loop - remove one of the groups completely - in that loop add a spawn to the spawnwave function you can format the spawn marker using format - that way it iterates through the markers on each creation Share this post Link to post Share on other sites
fusion13 11 Posted December 18, 2013 Could you expand on this, I suck at loops :// Share this post Link to post Share on other sites
mikie boy 18 Posted December 18, 2013 Top of my head - not in any shape has this been tested, but its a concept... _SpawnWave = { for [{_x=0},{_x<=1},{_x=_x+1}] do { _group = [getMarkerPos format ["spawn%1", _x] EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; //set skill array works magic { _x setSkill ["general",1]; _x setSkill ["aimingAccuracy",0.1]; _x setSkill ["aimingShake",1]; _x setSkill ["aimingSpeed",0.1]; _x setSkill ["endurance",0.3]; //no longer works? _x setSkill ["spotDistance",0.2]; _x setSkill ["spotTime",0.7]; _x setSkill ["courage",1]; _x setSkill ["reloadspeed",0.5]; _x setSkill ["commanding",1]; _x doMove getpos movetoPosition; //make the unit move to the position } forEach units _group; [] call _SpawnWave; }; }; _SpawnWave = { //your code plus this waituntil {{alive _x} count units _group == 0}; }; Share this post Link to post Share on other sites
Falsche9 11 Posted December 18, 2013 (edited) //_hdl = [] execVM "test.sqf"; private ["_group1","_group2","_attackPos"]; DEAD_VAR_GROUP1 = 0; DEAD_VAR_GROUP2 = 0; _group1 = [getMarkerPos "spawn1", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; _group2 = [getMarkerPos "spawn2", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; _attackPos = getPosATL player; _SpawnWave = { { _x setSkill ["general",1]; _x setSkill ["aimingAccuracy",0.1]; _x setSkill ["aimingShake",1]; _x setSkill ["aimingSpeed",0.1]; _x setSkill ["endurance",0.3]; _x setSkill ["spotDistance",0.2]; _x setSkill ["spotTime",0.7]; _x setSkill ["courage",1]; _x setSkill ["reloadspeed",0.5]; _x setSkill ["commanding",1]; _x doMove _attackPos; } forEach (units _group1 + units _group2); }; {_x addEventHandler ["killed", { _grp = group (_this select 0); if ({ alive _x } count units _grp < 1) then { hint "All units gruppe1 dead"; DEAD_VAR_GROUP1 = 1; }; }]; } forEach units _group1; {_x addEventHandler ["killed", { _grp = group (_this select 0); if ({ alive _x } count units _grp < 1) then { hint "All units gruppe2 dead"; DEAD_VAR_GROUP2 = 1; }; }]; } forEach units _group2; [] call _SpawnWave; waituntil {(DEAD_VAR_GROUP1 == 1 && DEAD_VAR_GROUP2 == 1)}; _alarm = createSoundSource ["Sound_Alarm", position player, [], 0]; //{if (side _x == EAST) then {_x setDamage 1;};} forEach allUnits;// test for debug - kill them all I made a test of this in the editor - it is working. edit: updated - needed a variable for each group. Edited December 19, 2013 by Falsche9 Share this post Link to post Share on other sites
fusion13 11 Posted December 19, 2013 Falsche it still plays the sound and execs the shit after you kill one group :/ this what I am using private ["_group1","_group2"]; DEAD_VAR = 0; _SpawnWave = { _attackPos = getPosATL player; _group1 = [getMarkerPos "spawn1", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; _group2 = [getMarkerPos "spawn2", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; { _x setSkill ["general",1]; _x setSkill ["aimingAccuracy",0.1]; _x setSkill ["aimingShake",1]; _x setSkill ["aimingSpeed",0.1]; _x setSkill ["endurance",0.3]; _x setSkill ["spotDistance",0.2]; _x setSkill ["spotTime",0.7]; _x setSkill ["courage",1]; _x setSkill ["reloadspeed",0.5]; _x setSkill ["commanding",1]; _x doMove _attackPos; _x addEventHandler ["killed", { _grp = group (_this select 0); if ({ alive _x } count units _grp < 1) then { hint "All units dead"; DEAD_VAR = 1; }; }]; } forEach (units _group1 + units _group2); }; [] call _SpawnWave; waituntil {(DEAD_VAR == 1)}; cutText ["Wave 2 Completed", "PLAIN"]; cutText ["Explosives Added!", "PLAIN"]; _box1 = getMarkerPos "exp"; exps setPos _box1; _box2 = getMarkerPos "expscase2"; exps_1 setPos _box2; playSound "Over"; sleep 5; cutText ["Wave 3 will begin in 30 Seconds", "PLAIN"]; sleep 15; cutText ["Get Ready, 15 Seconds!", "PLAIN"]; sleep 15; cutText ["Wave 3 Has Begun!!!!!!!!!", "PLAIN"]; Share this post Link to post Share on other sites
Falsche9 11 Posted December 19, 2013 Yes there was an error - it required a variable to check each group. - updated. I added: DEAD_VAR_GROUP1 = 0; DEAD_VAR_GROUP2 = 0; and the killed eventHandler for each group Share this post Link to post Share on other sites