Jump to content

Recommended Posts

How would you go about caching units only to be deleted later, but doing it all locally?


Ive set up a nice script that populates towns with random patrols, now i just need a way for the patrols to get deleted once the player leaves the area.


enemyFaction = [
	(configfile >> "CfgGroups" >> "Indep" >> "IND_C_F"),
] call BIS_fnc_returnChildren select {inheritsFrom _x isEqualTo (configFile >> "Man")};
publicVariable "enemyFaction";

centerposition = [worldSize / 2, worldsize / 2, 0];
publicVariable "centerposition";

Locations = nearestLocations [centerposition, ["NameVillage","NameCityCapital","NameCity","NameLocal","Airport"], worldSize / 2];
publicVariable "Locations";

trigArea = 2000;
publicVariable "trigArea";

HNK_fnc_createInfPatrols = {
	params ["_trig","_locName","_activation"];
		for "_x" from (floor random 2) to 0 step -1 do {
			_pos = position _trig;
			_safePos = [_pos, 0, trigArea] call BIS_fnc_findSafePos;
			_grp = [_safepos, resistance, selectRandom enemyFaction] call BIS_fnc_spawnGroup;
			_grp deleteGroupWhenEmpty true;
			myCurator addCuratorEditableObjects [units _grp,true ]; //debug
			[_grp, getPos leader _grp, 1000] call bis_fnc_taskPatrol;

HNK_fnc_createVehPatrols = {
	params ["_trig","_locName","_activation"];
		for "_x" from (floor random [0,0,1]) to 0 step -1 do {
			_pos = position _trig;
			_safePos = [_pos, 0, trigArea] call BIS_fnc_findSafePos;

HNK_fnc_setupTrigger = {
	params ["_trig","_locName","_activation"];
	if (_activation) then {
		[_trig,_locName,_activation] spawn HNK_fnc_createInfPatrols;
	} else {

HNK_fnc_createTrigger = {
	   _pos = position _x;
	   _trg = createTrigger ["EmptyDetector", _pos];
	   _trg setTriggerArea [trigArea, trigArea, 0, false];
	   _trg setTriggerActivation ["ANYPLAYER", "PRESENT", true];
	   _trg setTriggerStatements ["this", "[thisTrigger,_x,true] call HNK_fnc_setupTrigger", "[thisTrigger,_x,false] call HNK_fnc_setupTrigger"];
	   _m = createMarker [format ["mrk%1",random 100000],_pos]; //debug 5 V
	   _m setMarkerShape "ELLIPSE";
	   _m setMarkerSize [trigArea,trigArea];
	   _m setMarkerBrush "Solid";
	   _m setMarkerAlpha 0.25;
	   _m setMarkerColor "ColorRed"; 

	} forEach Locations;

[] spawn HNK_fnc_createTrigger;



HNK_fnc_createVehPatrols does nothing, thats for later once i figure out how to delete the spawned units. :P Also i ment to type selectRandom instead of floor random.

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