Home   Help Search Login Register  

Author Topic: Checking distance enemy<->player and trigger event when too close  (Read 1162 times)

0 Members and 1 Guest are viewing this topic.

Offline Dobermann

  • Members
  • *
  • Ready to disturb you anytime

Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
hi Dobermann,

this resource can help you get started: http://www.ofpec.com/ed_depot/index.php?action=details&id=442&page=0&game=ArmA&type=sc&cat=xyz

You could probably adjust what's in here to fit your mission idea.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
this should make a condition for when the average of all enemy units in the desired distance reachest a certain point, rather that just the closest one.

first make a repeating trigger detecting enemies to follow the player, then in the init of the trigger make a list e.g. triglist

then in a script, attach the list to a variable array e.g.   _list = _this select 0; (0 being the name of the list)

then make a loop that goes something like this:

Code: [Select]
// call {[triggerlist, minimum distance, maximum distance, time before detected] execVM "thisscript.sqf"}

_list = _this select 0;
_min = _this select 1;
_max = _this select 2;
_detec = _this select 3;
_timer = 0;

while {alive player} do
{
_distArray = _distArray + player distance {_x} foreach _list;
_m = 0 + {_x} foreach _list;
_c = count distArray;
_ans = _m / _c;

  if (_ans <_min AND _ans >_max) then
  {
  _timer = _timer + 1;

  } else
    {
    _timer = 0;
    };

  if (_timer == _detec) then
  {
  //guns go blazing, everyone who hates you is shooting at you etc.
  exit;
  };

sleep 1;
};


btw, i have no idea if this works, i havent tested it.
« Last Edit: 11 Dec 2007, 22:42:51 by Surdus Priest »
Campaigns are hard, I'll stick with scripting for now!