Jump to content
Sign in to follow this  
moeburn

I just want an AI recon helicopter to hover in one spot...

Recommended Posts

  • Arma 2 Combined Ops v1.60 beta 88027 (latest beta I could get working)
  • ACE Mod v1.13.0.522 (+ACEX/RU/USNavy/SoundMod/CBA)
  • RKSL Mod

I'm trying to make a mission where an AI recon helicopter acts as a spotter for a player-controlled artillery. But I'm having a very hard time getting the helo to stay in the air. It starts out at the preset altitude just fine, but then it decides to slowly land. I've given it a "hold" waypoint at its own location, as well as the following script in its init line:

this flyInHeight 600;                                           //tell AI to aim for an alt of 600
this setPos [getPos this select 0, getPos this selec 1, 600];   //set helo's alt to 600
this action ["autoHover", this];                                //for when player switches to helo for spotter's view
(driver this) disableAI "MOVE";                                 //supposed to stop the AI from going anywhere

These are also in order of which ones I tried first: IE originally I tried just flyInHeight, then I combined that with SetPos, then I added AutoHover, then I put disableAI on top of all that. So I know that the code issue isn't something I need to remove. The helo appears to land just as if the player had selected "autohover on" and released the throttle: IE a very gentle and slow landing, I have to speed up the game to 4x just to view it.

And if possible, I would like this helo to be in the same group as my player-controlled arty so that the helo can relay the positions of spotted targets to the arty; I believe only grouped units can do this?

Any suggestions or help would be greatly appreciated!

Share this post


Link to post
Share on other sites

Well.... if the helicopter sees enemy it's not going to just sit there... it's going to attack or evade. I'm not sure if what you want is possible.

Share this post


Link to post
Share on other sites

Hello,

disableAI "Move"; is the wrong command for this, it won't affect the Pilot as long as he's in a vehicle. The command only prevents men (on foot) from moving.

You can either use:

(driver this) disableAI "Target";
(driver this) disableAI "Autotarget";

This will make him ignore targets.

Or this (which I recommend):

(driver this) setBehaviour "Careless"; // He stays relaxed, even if enemies are around
(driver this) setCombatMode "Blue"; // He won't attack anything, anymore

flyInHeight needs a move command in order to work. Like this:

this doMove (getPosATL this);
this flyInHeight 600;

It doesn't have to be doMove, a waypoint should be working as well. Just make sure to issue the move/waypoint before flyInHeight.

The action "autoHover" is not working (obsolete) with AI controlled vehicles, they are in auto hover automatically. The action only affects human controlled vehicles.

I hope this helps.

Share this post


Link to post
Share on other sites
Hello,

disableAI "Move"; is the wrong command for this, it won't affect the Pilot as long as he's in a vehicle. The command only prevents men (on foot) from moving.

You can either use:

(driver this) disableAI "Target";
(driver this) disableAI "Autotarget";

This will make him ignore targets.

Or this (which I recommend):

(driver this) setBehaviour "Careless"; // He stays relaxed, even if enemies are around
(driver this) setCombatMode "Blue"; // He won't attack anything, anymore

flyInHeight needs a move command in order to work. Like this:

this doMove (getPosATL this);
this flyInHeight 600;

It doesn't have to be doMove, a waypoint should be working as well. Just make sure to issue the move/waypoint before flyInHeight.

The action "autoHover" is not working (obsolete) with AI controlled vehicles, they are in auto hover automatically. The action only affects human controlled vehicles.

I hope this helps.

All of those sound great, but won't the AI pilot stop reporting target locations if it stops targeting them altogether? I need it to still be able to report targets.

Also, I know autohover is for a player-controlled helicopter only, I shouldnt have mentioned it. I'm using it for when the player switches to the pilot's view.

Share this post


Link to post
Share on other sites

The above will still allow the gunner to see and fire on targets he just won't do it as often and the pilot won't turn to engage the enemy.

I did this script a while back but never finished it.

if you place this in a waypoint or trigger nul=[heli] execvm "hold.sqf" it will slow a chopper and have him hold position. He is however free to turn and engage the enemy when he sees it. If you give him heli domove getpos targetpos commands you have control of his direction, he will turn to that direction. Maybe not in battle, I haven't checked.

To cancel the action just use halt_heli=false placed in a trigger and he will return to normal flying.

There is more you could add such as adjust his height so he could pop up and down.

save as "hold.sqf"

//nul=[heli] execvm "hold.sqf";
halt_heli = true ;// heli will stop when script is run
_plane = _this select 0;

_pitchbank = _plane call BIS_fnc_getPitchBank;
_pitch     = _pitchbank select 0;
_bank      = _pitchbank select 1;

//hint format ["Pitch %1  Bank %2",_pitch,_bank];

_nspeed_x = 0;
_nspeed_y = 0;

while {alive _plane and halt_heli} do 
{

if (_pitch > -5 ) then {_pitch = _pitch - 0.1} else {_pitch = _pitch + 0.1};// slight nose down for better response
if (_bank  > 0  ) then {_bank = _bank - 0.1} else {_bank = _bank + 0.1};

_speed_Veh =  velocity _plane;
_speed_x = _speed_Veh select 0;
_speed_y = _speed_Veh select 1;
_speed_z = _speed_Veh select 2;

if (_speed_x > 0) then {_nspeed_x = _speed_x / 1.01;};
if (_speed_y > 0) then {_nspeed_y = _speed_y / 1.01;};
if (_speed_z > 0) then {_nspeed_z = _speed_z / 1.0001;};
//

[_plane, _Pitch,_Bank] call BIS_fnc_setPitchBank;
_plane setVelocity [_nspeed_x,_nspeed_y,_speed_z];
sleep 0.001;
};

I don't think forcespeed works on chopper or planes.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thanks, f2k! Now is there a way to allow the helo to target and report enemies, without firing on them? I think I might just have to remove the chopper's ammunition...

Share this post


Link to post
Share on other sites

If your grouped to the chopper it will report positions with or without ammo, it will also hold position if you tell it to.

If it's not in your group then I'm not sure how you'd broadcast the choppers messages.

Share this post


Link to post
Share on other sites

Ok I got it working by removing the helo's ammo and using a hold waypoint. Now I have a new problem.

In order to get the helo to report targets, it has to be in the same group as the player. If the helo is the leader, then the player can't enter a vehicle. The moment I try, the helo says "2, dismount!" and my player is automatically kicked out of the vehicle. If the player is the leader, then the helo starts "in formation" (even though I made sure to change the player's status to 'none' and the helo's status to 'flying') right above my player's head, regardless of the helo's editor placement position.

So can I make the helo report targets, keep the helo in the editor's placement position, AND allow my player to enter a vehicle without immediately getting kicked out?

Share this post


Link to post
Share on other sites

Could you use attachto to root it to something unseen on the ground, and then let it try to follow you so the rotor would be turning?

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  

×