Jump to content
Sign in to follow this  
hogmason

deleting enemy once task is finished

Recommended Posts

hi im using the below code to generate a task and spawn enemy using upsmon, it all works great but i cant seem to figure out how to delete the remaining enemy once the task is finished.

the code ((((((( spawning enemy are in bold )))))))))

if isserver then {

sleep 10;  /// give time for UPSMON to start
_task5=task5;
_name = "MAZ_543_SCUD_TK_EP1" createVehicle getpos _task5;  // create scud
/////Only Destroy by satch
_name setVehicleInit "_name addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
processInitCommands;

_mrkradar2 = createmarker ["marker_radar2",getpos _task5];
_mrkradar2 setmarkershape "ELLIPSE";
_mrkradar2 setmarkersize [190,190];
//"marker_radar2" setMarkerAlpha 0;  /// unmark to not show
sleep .5;

///Spawn OPFOR  /// 
//if ((paramsarray select 19) == 1) then { 


[b]	_upsgrp1 = [1,getpos _task5,1,["marker_radar2","spawned","random","fortify","nomove","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task5,1,["marker_radar2","spawned","random","fortify","nomove","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task5,1,["marker_radar2","spawned","random","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task5,1,["marker_radar2","spawned","random","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task5,1,["marker_radar2","spawned","random","nomove","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task5,1,["marker_radar2","spawned","random","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp1 = [getmarkerpos "task5", east,["ZSU_TK_EP1", "T34_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp1) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp2 = [getmarkerpos "task5", east,["BRDM2_ATGM_TK_EP1", "T72_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp2) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp3 = [getmarkerpos "task5", east,["BRDM2_ATGM_TK_EP1", "T72_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp3) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp4 = [getmarkerpos "task3", east,["T34_TK_EP1", "ZSU_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp4) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp5 = [getmarkerpos "task3", east,["BRDM2_ATGM_TK_EP1", "T34_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp5) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";[/b]

//};
///////this now waits scud is dead/////

waitUntil{!alive _name }; 



["task5","succeeded"] call SHK_Taskmaster_upd;
[] call SHK_addTask;

/////////////////CLEAN UP/////////////////////

deletemarker "marker_radar2";



};

as i have over 60 tasks after a while the remaining enemy from the old tasks start to lag the server as you would imagine.

cheers in advance

Share this post


Link to post
Share on other sites

never used upsmon - but you use spawn group - can you just delete the said group if they have no impact on the current objective -

if you cant delete the groups you are using via spawn group, you could - not sure how efficient - count the nearest enemy "man" - side east - around a specific location, and then delete those counted.

be careful with dead units, from what i can tell deleting units does not delete the group per se - the units are deleted but the group remains empty or as null. it therefore still shows as a group and your max 144 groups builds up quickly. need to delete groups.

just food for thought.

Edited by Mikie boy

Share this post


Link to post
Share on other sites

The way I would do it would be to make an array containing all OPFOR units you've spawned and then just do a simple:

{deleteVehicle _x} forEach _objUnitsArray;

How you build the array is up to you, but I would suggest making it as efficient as possible. :)

Share this post


Link to post
Share on other sites

cheers guys,

mikie Upsmon only spawns empty vehicles so we had to inter twine upsmon and spawngroup togeather to get the vehicles manned.

Share this post


Link to post
Share on other sites

so would something like this work to delete my groups.

i.e to delete this group


_upsgrp1 = [1,getpos _task6,1,["marker_radar2","spawned","random","nomove","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";

id use this at the end of the script


_upsgrp1 spawn {
_units = units _this;
waitUntil {sleep 2; ({alive _x} count _units) == 0};
{deleteVehicle _x} foreach _units;
deleteGroup _this;
};

now just repeat for the remaining groups

so it would look like this


//////////////////////////////////////////////////////////////////
// Created for Operation HOG SOCOMD Command
//////////////////////////////////////////////////////////////////

if isserver then {

sleep 10;  /// give time for UPSMON to start
_task6=task6;
_name = "GuerillaCacheBox" createVehicle getpos _task6;  // create Radar
/////Only Destroy by satch
_name setVehicleInit "_name addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
processInitCommands;

_mrkradar2 = createmarker ["marker_radar2",getpos _task6];
_mrkradar2 setmarkershape "ELLIPSE";
_mrkradar2 setmarkersize [190,190];
//"marker_radar2" setMarkerAlpha 0;  /// unmark to not show
sleep .5;

///Spawn OPFOR  /// 
//if ((paramsarray select 19) == 1) then { 


_upsgrp1 = [1,getpos _task6,1,["marker_radar2","spawned","random","nomove","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task6,1,["marker_radar2","spawned","random","fortify","nomove","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task6,1,["marker_radar2","spawned","random","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task6,1,["marker_radar2","spawned","random","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task6,1,["marker_radar2","spawned","random","nomove","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
sleep .2;
_upsgrp1 = [1,getpos _task6,1,["marker_radar2","spawned","random","delete:",120]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp1 = [getmarkerpos "task6", east,["LandRover_MG_TK_EP1", "ZSU_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp1) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp2 = [getmarkerpos "task6", east,["T34_TK_EP1", "T34_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp2) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp3 = [getmarkerpos "task6", east,["LandRover_MG_TK_EP1", "BRDM2_ATGM_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp3) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp4 = [getmarkerpos "task3", east,["T34_TK_EP1", "ZSU_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp4) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";
_dis = 180;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
       _positionToSpawnIn = [((getmarkerpos _radar2) select 0) + _dx, ((getmarkerpos _radar2) select 1) + _dy, 0];
_armourgrp5 = [getmarkerpos "task3", east,["BRDM2_ATGM_TK_EP1", "T34_TK_EP1"],[[-3,-3], [3,3]]]  call BIS_fnc_spawnGroup;
[(units _armourgrp5) select 0, "marker_radar2","spawned","showmarker","nofollow","random","nowait","delete:",120] execVM "scripts\upsmon.sqf";

//};
///////this now waits until he is dead and also no AI are in area/////

waitUntil{!alive Insurgent_funder}; 



["task6","succeeded"] call SHK_Taskmaster_upd;
[] call SHK_addTask;

/////////////////CLEAN UP/////////////////////

deletemarker "marker_radar2";
[b]
_upsgrp1 spawn {
_units = units _this;
waitUntil {sleep 2; ({alive _x} count _units) == 0};
{deleteVehicle _x} foreach _units;
deleteGroup _this;
};
_armourgrp1 spawn {
_units = units _this;
waitUntil {sleep 2; ({alive _x} count _units) == 0};
{deleteVehicle _x} foreach _units;
deleteGroup _this;
};
_armourgrp2 spawn {
_units = units _this;
waitUntil {sleep 2; ({alive _x} count _units) == 0};
{deleteVehicle _x} foreach _units;
deleteGroup _this;
};
_armourgrp3 spawn {
_units = units _this;
waitUntil {sleep 2; ({alive _x} count _units) == 0};
{deleteVehicle _x} foreach _units;
deleteGroup _this;
};
_armourgrp4 spawn {
_units = units _this;
waitUntil {sleep 2; ({alive _x} count _units) == 0};
{deleteVehicle _x} foreach _units;
deleteGroup _this;
};
_armourgrp5 spawn {
_units = units _this;
waitUntil {sleep 2; ({alive _x} count _units) == 0};
{deleteVehicle _x} foreach _units;
deleteGroup _this;[/b]
};


};

is that correct

Edited by hogmason

Share this post


Link to post
Share on other sites

Pop some debug code in there to help you out. Make sure that everything fits - so for example that things are returning the variables you are expecting them to, etc.

Share this post


Link to post
Share on other sites

can i just create a trigger by script to kill all east i.e


_triggerkill = createTrigger["EmptyDetector",[getmarkerPos _pos select 0,getmarkerPos _pos select 1,0]];
_triggerkill setTriggerArea [600,600,0,false];
_triggerkill setTriggerActivation ["EAST",true];
_triggerkill setTriggerTimeout [1,1,1,true];
_triggerkill setTriggerStatements ["this", "{_x setDammage 1} foreach thisList;hint 'Detected",""];

and place it at the end of the code.

---------- Post added at 19:12 ---------- Previous post was at 19:11 ----------

i tried what i typed in the trigger but it doesnt work can you just check the {_x setDammage 1} foreach thisList; part have i typed that correct

Share this post


Link to post
Share on other sites

This is what i use - works fine

I use the main objective marker as the point of reference. sure it will work with whatever...

probably not that efficient - but it works

/////////////////////////////////
//[FOCK] Delete Alive Group
// [FOCK] Mikie J
/////////////////////////////////

	_list = ((getmarkerpos "counter") nearEntities [["Man"],20]);
	_num = WEST countside _list;
//	hint format ["EAST: %1", _num];
//	sleep 2;
	  {
	    if (side _x == EAST) then 

			{_playerGrp = group _x;



				{deletevehicle _x;} forEach units _playerGrp;
				deletegroup _playerGrp;
				};

	   } foreach _list;

Share this post


Link to post
Share on other sites

cheer mate,

im just trying to execute it at the end of my task script im using

[] execVM "delete_enemy.sqf";

is that right

Share this post


Link to post
Share on other sites

no reason why you cant do it that way. If you are using it a lot - and since you don't need the sleep in the command (testing only) should

try [] spawn DeleteGrpAlive;

init.sqf

DeleteGrpAlive = compile (preprocessFileLineNumbers "delete_enemy.sqf");

but [] execVM "delete_enemy.sqf"; should work - let me know if you have any probs

Share this post


Link to post
Share on other sites

that works great mikie but it does not get rid of the armor only men

---------- Post added at 21:55 ---------- Previous post was at 21:53 ----------

1 question about it so i understand the script is the 20

_list = ((getmarkerpos "marker_radar2") nearEntities [["Man"],20]);

the radius or does it go on the markers radius i link it to

Share this post


Link to post
Share on other sites

added the deletevehicle _x; this should take care of the remaining units

///////////////////////////
//[FOCK] Deletegroup ALIVE
//[FOCK] Mikie J
/////////////////////////


	_list = ((getmarkerpos "counter") nearEntities [["Man"],20]);
	//_num = EAST countside _list;
	//hint format ["EAST: %1", _num];
	//sleep 2;
	  {
	    if (side _x == EAST) then 

			{

				_playerGrp = group _x;					
				{deletevehicle _x;} forEach units _playerGrp;
				deletegroup _playerGrp;
				deletevehicle _x;
				};

	   } foreach _list;

the 20 is a radius from the marker. obviously the bigger the radius the more the cpu has to process. not sure of its impact.

Share this post


Link to post
Share on other sites

Just for future reference for people the delete script that mikie posted above works great i just had issues using it with UPSMON as UPSMON takes control of the enemy ai, a huge thanks goes out to Mikie for grabbing my code and solving the issue not to mention cleaning my code up for me

Mikie your a legend mate.

Edited by hogmason
it works great just wanted to let every one know and Mikies a legend

Share this post


Link to post
Share on other sites

post your code - ive tested the above and it works.

ill test it for you- cant see why it would not work - happy to help

mike

Share this post


Link to post
Share on other sites

thanks mate ill gather it for you now

---------- Post added at 21:43 ---------- Previous post was at 21:33 ----------

here you go mikie download the script its clean with nothing ealse in it with a txt file inside for you to read

http://ds5758.hostname.net.au/downloads/=HARDCORE=%20Downloads/ARMADownloads/masons%20editing/mikie_task_test.Chernarus.rar

thanks heaps mate

---------- Post added at 21:46 ---------- Previous post was at 21:43 ----------

thats no addons just combined ops

---------- Post added at 21:47 ---------- Previous post was at 21:46 ----------

for testing reasons i have 1 guys on the map when it loads just kill him after everything spawns to test your delete script

Share this post


Link to post
Share on other sites

Just for future reference for people the delete script that mikie posted above works great i just had issues using it with UPSMON as UPSMON takes control of the enemy ai, a huge thanks goes out to Mikie for grabbing my code and solving the issue ;) not to mention cleaning my code up for me ;)

Mikie your a legend mate.

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  

×