Jump to content
Sign in to follow this  
semedar

Give AI Mortar Unlimited Ammo Until Dead?

Recommended Posts

So I'm trying to have an enemy mortar have unlimited ammo but when it's killed, it stops giving it/refilling it's ammo. So then the player can't get on the mortar and have unlimited ammo.

Would something like this work?

aiMortarAlive = True;

while { aiMortarAlive } do
{ 
if !alive aiMortar1 then aiMortar1 setVehicleAmmo 1 else exit
sleep 150;
};

Share this post


Link to post
Share on other sites

I think an eventhandler may be easier.

aiMortar1 addEventHandler ["fired", "aiMortar1 setVehicleAmmo 1"]

Share this post


Link to post
Share on other sites

It would, but that way, once the AI fires, he will fire continually. Like he's spitting mortars out of nowhere. And also, the unlimited ammo won't stop if the AI dies. Or am I wrong on this part?

Share this post


Link to post
Share on other sites

If he dies, the mortar is still there and you can get on it with unlimited ammo..

Share this post


Link to post
Share on other sites

i believe you should check for alive (gunner mortar) as I believe mortar might not return the gunner in the mortar, but the weapon itself (however I may be wrong, in any case, this will surely solve the issue of infinite ammo after gunners death)

Share this post


Link to post
Share on other sites

aiMortar1 addEventHandler ["fired", "if (!isPlayer (gunner aiMortar1)) then {aiMortar1 setVehicleAmmo 1"}]

:j:

Share this post


Link to post
Share on other sites
aiMortar1 addEventHandler ["fired", "if (!isPlayer (gunner aiMortar1)) then {aiMortar1 setVehicleAmmo 1"}]

:j:

Thanks!

aiMortar1 addEventHandler ["fired", "if (!isPlayer (gunner aiMortar1)) then {aiMortar1 setVehicleAmmo 1}"];

Miss-placed the last comma.

Edited by Semedar

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  

×