Jump to content
Schatten

Using agent as heli pilot

Recommended Posts

Hi, community!
I need to make that helicopter takes group of units to some place. But it is important that pilot does not react to enemy (but it is advisable that pilot can use countermeasures), and gunners react.
In accordance with some topics (https://forums.bohemia.net/forums/topic/191955-make-pilot-ignore-enemy-contacts/, https://forums.bohemia.net/forums/topic/171375-make-ai-pilot-not-react-to-enemies/, https://forums.bohemia.net/forums/topic/88829-ignoring-enemy-fire/), I tried to disable AI (AUTOTARGET, FSM, TARGET...), set behavior to CARELESS and combat mode to BLUE, join gunners to separate group... But nothing helped -- either pilot and gunners react to enemy (then pilot changes route), or nobody reacts.
After many attempts I tried to use agent as pilot and used moveTo and setDestination commands to order to fly, but apparently agents do not want to fly -- it immediately lands helicopter. Can anybody help me?
Thanks.

Share this post


Link to post
Share on other sites

Personally using the behaviour set to SAFE and driver (pilot) disableAI "autoCombat". Nothing more.

Counter-measures seems to be compatible with safe behaviour.

If you add some code like: this flyInHeightASL [30,30,30], write it before the disable for autocombat. There is a slight difference using or not flyinHeightASL, as this command seems to add a little latency on each waypoint (probably for keeping altitude).

  • Like 3

Share this post


Link to post
Share on other sites
7 hours ago, HazJ said:

Why not just make the pilot setCaptive ...?

Not sure that this will help, because I use civilians as enemy.

 

Anyway, thanks for answers, @HazJ and @pierremgi, I will try.

Share this post


Link to post
Share on other sites

Unfortunately, nothing helped -- neither setCaptive, nor setBehaviour "SAFE" and disableAI "AUTOCOMBAT". Helicopter changes route after firing at it -- it starts flies around and gunners try to kill me. There is code that I used for tests:

Spoiler

_heliClassName = selectRandom [
	"B_Heli_Transport_01_F",
	"B_Heli_Transport_01_camo_F",
	"B_CTRG_Heli_Transport_01_sand_F",

	"B_Heli_Transport_03_F",
	"B_Heli_Transport_03_black_F"
];

_worldHalfSize = worldSize / 2;
_worldRadius = (sqrt 2) * _worldHalfSize;

_angle = random 360;

_heliPosition = [
	_worldHalfSize + _worldRadius * (sin _angle),
	_worldHalfSize + _worldRadius * (cos _angle),
	25
];

_helicopter = createVehicle [_heliClassName, _heliPosition, [], 0, "FLY"];

_helicopter setDir (_heliPosition getDir _position);
_helicopter setPosATL _heliPosition;

_helicopter flyInHeight (_heliPosition select 2);

_heliCrewGroup = createGroup civilian; // Civilian is enemy side

_pilot = _heliCrewGroup createUnit ["C_man_1", [0, 0], [], 25, "NONE"];

_pilot disableAI "AUTOCOMBAT";
_pilot moveInDriver _helicopter;
// _pilot setCaptive true;

for "_index" from 1 to 2 do {
	_gunner = _heliCrewGroup createUnit ["C_man_1", [0, 0], [], 25, "NONE"];

	_gunner moveInTurret [_helicopter, [_index]];
};

_helicopter doMove _position;

_heliCrewGroup setBehaviour "SAFE";
_heliCrewGroup setSpeedMode "LIMITED";

 

I also found out that if pilot is agent, gunners (normal units) will not shoot at enemy.

Sadly...

Share this post


Link to post
Share on other sites

 

I'm always wondering why people don't like the bis_fnc_spawnGroup...


 

0 = [] spawn { 
  civilian setfriend [west,0]; west setFriend [civilian,0]; // if not already set
  _heliPosition = [random worldSize,random worldSize, 25]; 
  _heliCrewGroup = [_heliPosition, CIVILIAN,[ selectRandom ["B_Heli_Transport_01_F","B_Heli_Transport_01_camo_F","B_CTRG_Heli_Transport_01_sand_F","B_Heli_Transport_03_F","B_Heli_Transport_03_black_F"]], [],[],[],[],[],_heliPosition getDir selectRandom allPlayers] call BIS_fnc_spawnGroup; 
  _heliCrewGroup setBehaviour "SAFE"; 
  _heliCrewGroup setSpeedMode "LIMITED"; 
  _helicopter = Vehicle leader _heliCrewGroup; 
  _helicopter flyInHeightASL [25,25,25]; 
  _pilot = driver _helicopter; 
  _pilot disableAI "AUTOCOMBAT"; 
  private _wpt = _heliCrewGroup addWaypoint [getpos player,100]; 
  [_wpt,_heliCrewGroup,_helicopter] spawn { 
    params ["_wpt","_heliCrewGroup","_helicopter"]; 
    while {alive _helicopter} do { 
      sleep 2; 
      if (unitReady _helicopter) then { 
        while {count waypoints _heliCrewGroup >0} do {deleteWaypoint [_heliCrewGroup,0]}; 
        _wpt = _heliCrewGroup addWaypoint [getpos(selectRandom allPlayers),100]; 
      }; 
      sleep 3; 
      _wpt setWaypointPosition [getpos player,100]; 
      {if(!isnull (_helicopter turretUnit [_x])) then {_helicopter turretUnit [_x] reveal [(selectRandom allPlayers),4]} } forEach [0,1,2]; 
    }; 
  }; 
};

 

Note: civilian side has specific behavior. The friendship relation is inherited with independent one, by default.

Even if civilian are set to enemies, none will fire at them,... except players ;-)

 

 

 

Edited by pierremgi
Added some poursuit waypoint and targetting for turrets (prefer "unitTurret" rather than "gunner")
  • Thanks 2

Share this post


Link to post
Share on other sites
59 minutes ago, Schatten said:

Unfortunately, nothing helped -- neither setCaptive, nor setBehaviour "SAFE" and disableAI "AUTOCOMBAT". Helicopter changes route after firing at it -- it starts flies around and gunners try to kill me.

 

Of course it does. It's not supposed to be SAFE but CARELESS. No need to disable any AI either.

The gunner will still shoot unless you remove his ammo but the heli will not change its route.

  • Confused 1

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/AI_Behaviour

If you apply a careless behavior, so the group will stay out of combat mode.

Safe mode is useful to automatic shift for combat mode. So, the disableAI "autocombat" has its sense here , as you can apply a endless safe mode for one unit while other team's mates (gunners) are falling in combat mode.

This is a fine way, (i often use it), to make the pilot as careless = endless safe mode, flying regardless of enemies, while gunners fire at troops.

  • Like 1

Share this post


Link to post
Share on other sites

Well, if use BIS_fnc_spawnGroup then everything is generally good -- helicopter flies to destination. But, if use manual creation of crew then helicopter starts flies around after firing at it. It remains to find out what is the matter...
Thanks, @pierremgi!

Share this post


Link to post
Share on other sites

Well, after several tests I found out that the reason why helicopter was changing route was that its crew consisted of civilian units. So, use units of another side (then if it is necessary add them to group of civilian side) and make pilot group leader, then helicopter will not change route.

 

On 6/26/2018 at 12:21 AM, pierremgi said:

Note: civilian side has specific behavior.

Now I can confirm this precisely!

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

×