Soapbox0331 17 Posted May 22, 2023 I may be asking too much of the ARMA AI here, but I wanted to run this by the experts here. I am still searching for a way to have Ai hunt players but avoid contact...like an AI anti-recon tracker keeping tabs on a recon team, both elements seriously trying to avoid contact. I have used the below code (from @opusfmspol) in the unit's 2nd waypoint, which works, and thinking easier to get the desired effect than BIS_fnc_stalk. I was hoping there was a way to modify this to do the following: 1) When AI is within 200m of nearest player, executes a MyScriptHere.sqf. 2) AI moves back to a waypoint 300m from the direction they came from (so if approached player from the south, move south). 3) Hold at that waypoint for 5 minutes and then start the hunt again. Any ideas? if (isServer) then { _null = this spawn { Hunt_players_fnc = { _player = objNull; _players = +(allPlayers - (entities "HeadlessClient_F")); _distance = 100000; { if (alive _x && _x distance (Leader _this) < _distance) then { _distance = _x distance (Leader _this); _player = _x; }; } foreach _players; if !(isNull _player) then { _wp = (Group _this) addWaypoint [getPos _player, (50 + (floor(random 100)))]; _wp setWaypointStatements ["true","_null = this spawn Hunt_players_fnc;"]; _wp setWaypointType "SAD"; _wp setWaypointCombatMode "GREEN"; _wp setWaypointSpeed "LIMITED"; }; }; _null = _this spawn Hunt_players_fnc; }; }; Share this post Link to post Share on other sites
jazzraill 3 Posted May 23, 2023 try this _grp spawn { private _grp = _this; waitUntil { sleep 3; private _nearestPlayer = player; //Get nearest player here. if (((leader _grp) distance _nearestPlayer) < 200) then { _posPlayer = getPos player; _posLeader = getPos (leader _grp); _posPlayer set [2,1.75]; _posLeader set [2,1.75]; if !(((terrainIntersect [_posPlayer,_posLeader]) or (lineIntersects [(ATLToASL _posPlayer),(ATLToASL _posLeader),(leader _grp),_nearestPlayer]))) then { {doStop _x; _x commandTarget _nearestPlayer;} foreach (units _grp); }else{ for '_i' from ((count waypoints _grp) - 1) to 0 step -1 do { deleteWaypoint [_grp, _i]; }; _wp = _grp addWaypoint [getPos _nearestPlayer,0]; _wp setWaypointType 'MOVE'; }; }; (({alive _x} count (units _grp)) == 0) }; }; Share this post Link to post Share on other sites
Soapbox0331 17 Posted May 23, 2023 Wow, thanks @jazzraill! I will check as soon as I can tonight. This is ok to run On Activation in 2nd waypoint as I have been doing with the prior version? Share this post Link to post Share on other sites
Soapbox0331 17 Posted May 24, 2023 @jazzraill I am probably doing something wrong on this, but AI closes with me. Share this post Link to post Share on other sites