semedar 0 Posted December 6, 2011 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
Kushluk 21 Posted December 6, 2011 I think an eventhandler may be easier. aiMortar1 addEventHandler ["fired", "aiMortar1 setVehicleAmmo 1"] Share this post Link to post Share on other sites
semedar 0 Posted December 6, 2011 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
fleepee 10 Posted December 6, 2011 If he dies, he can't fire anymore... Share this post Link to post Share on other sites
semedar 0 Posted December 6, 2011 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
igneous01 19 Posted December 6, 2011 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
buliwyf 4 Posted December 6, 2011 aiMortar1 addEventHandler ["fired", "if (!isPlayer (gunner aiMortar1)) then {aiMortar1 setVehicleAmmo 1"}] :j: Share this post Link to post Share on other sites
semedar 0 Posted December 6, 2011 (edited) 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 December 6, 2011 by Semedar Share this post Link to post Share on other sites