Jump to content
Sign in to follow this  
ArmAriffic

Delete all west units <20 meters from object

Recommended Posts

I'm trying to create zones where AI spawn when the player enters and de-spawn when he leaves, so far I have

dist.sqf

 
_unit = _this select 0;
_targ = _this select 1;
_ZoneDis = _this select 2;
_Mkr = _this select 3;

_inzone = false;

while {true} do { 
  _DisX = _unit distance _targ; 

  if (_DisX < _ZoneDis and not _inzone) then {Hint "Debug: In Zone";nul = [_Mkr, 50] exec "SpawnWest.sqf";_inzone = true};
  if (_DisX > _ZoneDis and _inzone) then {Hint "Debug: Not In Zone";_inzone = false;};

  sleep 1;

};

spawnwest.sqf

_US_groups = ["US_Team"];

_markerPos = getMarkerPos (_this select 0);

_grp = [_markerPos, West, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >> "Infantry" >> (_US_groups select (floor(random(count _US_groups)))))] call BIS_fnc_spawnGroup;
[_grp, _markerPos, (_this select 1)] call bis_fnc_taskPatrol;

called like

 nul = [P1, Car1, 10, "test1"] execVM "dist.sqf"; 

everything is going awesomely but I haven't been able to find a way to detect which AI units are <_C meters from the target and delete them when the Player is >_C meters from the target, thanks in advance :)

Edited by ArmAriffic

Share this post


Link to post
Share on other sites

Just add something like waitUntil unit distance player > _C then delete them in the spawn script? Also, _C is a horrible variable name. :) Why not use something like deleteDistance or timeToGoByeByeRange? :)

Share this post


Link to post
Share on other sites
Just add something like waitUntil unit distance player > _C then delete them in the spawn script?)

Nah that wont work, as I need to do it on multiple zones

Also, _C is a horrible variable name. :) Why not use something like deleteDistance or timeToGoByeByeRange? :)

I was just using it as a temporary name lol :D

PS. I updated the script at the top, I forgot about the spawn marker so you probably thought that I meant it for one area

Edited by ArmAriffic

Share this post


Link to post
Share on other sites

solved my own problem


_center = _this select 0;
_dist = _this select 1;

_aitarg = nearestobjects [_center,["man"],_dist]; 
{if (side _x == west && _x != Player) exitwith {deleteVehicle _x};} forEach _aitarg;

sleep 1;

_aitarg2 = nearestobjects [_center,["man"],_dist]; 
{if (side _x == west && _x != Player) exitwith {deleteVehicle _x};} forEach _aitarg2;

sleep 1;

_aitarg3 = nearestobjects [_center,["man"],_dist]; 
{if (side _x == west && _x != Player) exitwith {deleteVehicle _x};} forEach _aitarg3;

sleep 1;

_aitarg4 = nearestobjects [_center,["man"],_dist]; 
{if (side _x == west && _x != Player) exitwith {deleteVehicle _x};} forEach _aitarg4;

and


  if (_DisX > _ZoneDis and _inzone) then {Hint "Debug: Not In Zone";_inzone = false;nul = [_DZ, _DZS] execVM "deletewest.sqf";};

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  

×