Jump to content
Sign in to follow this  
1para{god-father}

AA pods stop fire under hight xx

Recommended Posts

Is there a way to get AA pods to just fire if you are over a certain height ? i.e. if under say 80ft do not fire at them.

Is this possible

Thanks

trying to get pilots to fly low !

Share this post


Link to post
Share on other sites

you can place in init line of any vehicle:

_null = (vehicle this) spawn {
while {(getDammage _this) < 1 AND !isNull _this} do {
	if ((getPos _this select 2) > 80) then {
		_this setCaptive false;
	} else {
		_this setCaptive true;
	};
	sleep 1;
};
};

what it does:

when vehicle is below 80 meter from ground its setCaptive, wich means no one will shoot at it, when its above its normal, all enemys will shoot at it.

script will exit when vehicle is wrecked or deleted.

Note: even if the vehicle is under the height and enemys wont shoot at it, the vehicle will still shoot at the enemys.

for flying altitudes use

vehiclename flyInHeight 70;

now vehicle will try and maintain 70 meter height while flying.

Share this post


Link to post
Share on other sites

You could make a loop which checks the height of your plane/helo, and then when above 80 set the AA's ammo to zero, or use triggers.

I think it will work

Trigger 1
Repeat

Condition: (getpos myHelo1 select 2) > 80
On activation: myAA1 setVehicleAmmo 1

Trigger 2
Repeat

Condition: (getpos myHelo1 select 2) <= 80
On activation: myAA1 setVehicleAmmo 0

The reason I'm not using setcaptive, is that it will prevent ALL infantry as well from shooting at the Helo.

Share this post


Link to post
Share on other sites

You could also check to see what the height is and then just set the AA pod to "never fire" which I believe is the best way to do it. That way other things will shoot at you if you want them to and you won't need to worry about ammo just changing fire modes.

Share this post


Link to post
Share on other sites

Problem is I have a lot of AA pods - how would i set them to "Never Fire" as you suggested ?

Like Demonized solution but i really need other small arms fire to still take pop shots at the pilot ! - It is NOT AI so need some flack :)

Share this post


Link to post
Share on other sites

try this, name all your pods and add the to the array/list as shown:

_null = (vehicle this) spawn {
_aaPods = [pod1,pod2,pod3,etc];
while {(getDammage _this) < 1 AND !isNull _this} do {
	if ((getPos _this select 2) > 80) then {
		{(gunner _x) disableAI "AUTOTARGET"} foreach _aaPods;
	} else {
		{(gunner _x) enableAI "AUTOTARGET"} foreach _aaPods;
	};
	sleep 1;
};
};

Share this post


Link to post
Share on other sites
try this, name all your pods and add the to the array/list as shown:

_null = (vehicle this) spawn {
_aaPods = [pod1,pod2,pod3,etc];
while {(getDammage _this) < 1 AND !isNull _this} do {
	if ((getPos _this select 2) > 80) then {
		{(gunner _x) disableAI "AUTOTARGET"} foreach _aaPods;
	} else {
		{(gunner _x) enableAI "AUTOTARGET"} foreach _aaPods;
	};
	sleep 1;
};
};

OOOO thanks that worked great :)

Share this post


Link to post
Share on other sites

Just a question is this height worked out on ground level or sea level ??

So if flying over a BIG hill or the AA pod was on a Big hill would that make any difference ?

Share this post


Link to post
Share on other sites

@psivalli

getpos is ground level, getPosASL is sea level, flying up a hill as it is now, as long as you have 80 or less altitude youre good, no matter if hill is 2k high.

Share this post


Link to post
Share on other sites

Just tested this and for some reason the AA pods still shoot at me ? have set it to 150 for testing but they shoot me down :(

Any idea ?

Share this post


Link to post
Share on other sites

maybe its because they already have you targeted and the target is not switched off, only checking for new targets, and the isServer part.

here we switch off both current and new targets, and run only on server side.

_null = (vehicle this) spawn {
_veh = _this;
if (!isServer) exitWith {};
_aaPods = [pod1,pod2,pod3,etc];
_disable = ["TARGET","AUTOTARGET"];
while {(getDammage _veh) < 1 AND !isNull _veh} do {
	if ((getPos _veh select 2) > 80) then {
		{
			_gun = gunner _x;
			{_gun disableAI _x} foreach _disable;
		} foreach _aaPods;
	} else {
		{
			_gun = gunner _x;
			{_gun enableAI _x} foreach _disable;
		} foreach _aaPods;
	};
	sleep 1;
};
};

Share this post


Link to post
Share on other sites

Just tested this again but still no luck.

Named the pods , and placed that in the INIT of the heli and set it to 150 for testing and did not fly above 100 but still the buugges shoot me down

Share this post


Link to post
Share on other sites

I removed the gunner from the two _gun = gunner _x; lines and made it less than < 80. It seems to work now.

_null = (vehicle this) spawn {
_veh = _this;
if (!isServer) exitWith {};
_aaPods = [pod1,pod2,pod3];
_disable = ["TARGET","AUTOTARGET"];
while {(getDammage _veh) < 1 AND !isNull _veh} do {
	if ((getPos _veh select 2) < 80) then {
		{
			_gun =  _x;
			{_gun disableAI _x} foreach _disable;
		} foreach _aaPods;
	} else {
		{
			_gun = _x;
			{_gun enableAI _x} foreach _disable;
		} foreach _aaPods;
	};
	sleep 1;
};
};

Share this post


Link to post
Share on other sites

Yep that seemed to work thanks to you both !!!

If I wanted to add this to a spawned helicopter from scrit would this be correct ?


_name setVehicleInit   "_null = (vehicle this) spawn {
_veh = _this;
if (!isServer) exitWith {};
_aaPods = [pod1,pod2,pod3];
_disable = ["TARGET","AUTOTARGET"];
while {(getDammage _veh) < 1 AND !isNull _veh} do {
	if ((getPos _veh select 2) < 80) then {
		{
			_gun =  _x;
			{_gun disableAI _x} foreach _disable;
		} foreach _aaPods;
	} else {
		{
			_gun = _x;
			{_gun enableAI _x} foreach _disable;
		} foreach _aaPods;
	};
	sleep 1;
};
};"

processInitCommands;

Share this post


Link to post
Share on other sites
If I wanted to add this to a spawned helicopter from scrit would this be correct ?

you need to use ""double"" or 'single' inside the outer "qoutes".

so like this with 'single':

_name setVehicleInit "
_null = (vehicle this) spawn {
	_veh = _this;
	if (!isServer) exitWith {};
	_aaPods = [pod1,pod2,pod3];
	_disable = ['TARGET','AUTOTARGET'];
	while {(getDammage _veh) < 1 AND !isNull _veh} do {
		if ((getPos _veh select 2) < 80) then {
			{
				_gun = _x;
				{_gun disableAI _x} foreach _disable;
			} foreach _aaPods;
		} else {
			{
				_gun = _x;
				{_gun enableAI _x} foreach _disable;
			} foreach _aaPods;
		};
		sleep 1;
	};
};
";

processInitCommands;

if there is an issue with that, just save the code as script and just run the code from the setVehicleInit line instead.

save as myscriptname.sqf

if (!isServer) exitWith {};
_veh = _this;
_aaPods = [pod1,pod2,pod3];
_disable = ['TARGET','AUTOTARGET'];
while {(getDammage _veh) < 1 AND !isNull _veh} do {
if ((getPos _veh select 2) < 80) then {
	{
		_gun = _x;
		{_gun disableAI _x} foreach _disable;
	} foreach _aaPods;
} else {
	{
		_gun = _x;
		{_gun enableAI _x} foreach _disable;
	} foreach _aaPods;
};
sleep 1;
};

and run the init on spawned vehicles like this:

_name setVehicleInit "_null = (vehicle this) execVM 'myScriptName.sqf';";
processInitCommands;

this will be much cleaner in your spawn scripts.

Edited by Demonized

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  

×