Warning: include(/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php): failed to open stream: No such file or directory in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Warning: include(): Failed opening '/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Notice: Undefined index: OFPEC in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152
    Home   Help Login Register  

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

0 Members and 2 Guests are viewing this topic.

Offline Dobermann

  • Members
  • *
  • Ready to disturb you anytime
I´m thinking about a way to determine the players distance to enemies in a loop in a certain zone.
When the player gets too close to an enemy and stays in that range for too long the enemy should be
alerted, verbally adress the player and open fire at the player. In the next version I want to have the enemy adress the player and give the player the options to show false papers or talk to the enemies. This should be working for all enemies in a zone (base)

How can I set something like this up ?
What I need is a script or trigger setup that constantly checks the distance of the player to the enemies in a certain radius around him.
I guess if I loopcheck the distance to all enemies within the base it would hit the performance. So best would be to have a radius around the player that "moves" with the player and lists the units within the radius. Now if those units are hostile, for example east-side a timer should be started, the unit should doWatch the player and if the player stays near the unit for a certain time, let´s say 5 seconds, the unit should doTarget the player and use a voicesample to tell the player to stop. If the player moves away from the enemy unit the enemy should open fire.
If the player gets too close to enemy, let´s say 1m, the enemy should immmedeately shout and open fire, disregarding the 5 seconds from above.

If the player leaves the "zone" within the 5 seconds the enemy unit should disengage and doTarget 0 and continue with it´s regular stuff.

Is someone willing to waste some minutes on a script for that purpose ?
It´s basically for a stealth mission within an enemy base where I want to use setcaptive on the player or use rating to make him appear friendly to enemies unless he gets too close , they smell the deal and take further actions.




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!