Ionflux 0 Posted July 9, 2009 (edited) Hi everyone, Is it possible to give some of the AI in my squad unlimited ammo? Thanks in advance, Ion :pray: Edited July 9, 2009 by Ionflux Share this post Link to post Share on other sites
This is Bosnia 10 Posted July 10, 2009 trini scourge had a post some where on this here is the info what u can do is use a addeventhandler with setvehicleammo. this addeventhandler ["fired", {(_this select 0) setvehicleammo 1}] Share this post Link to post Share on other sites
Ionflux 0 Posted July 10, 2009 (edited) Awesome thanks bud! Will this work for infantry units aswell? :) *EDIT* - works on infantry No worries dude got it working :) thanks allot! Edited July 10, 2009 by Ionflux Share this post Link to post Share on other sites
megagoth1702 252 Posted July 15, 2010 Duuuude, unlimted A10 training, carpet bombing, beautiful! Thank you so much! Share this post Link to post Share on other sites
Varkrag 10 Posted January 20, 2011 Is there a way to do this in a way that does unlimited reloads instead of rounds in the chamber? I want A.I. MANPADs to have unlimited reloads, not exactly a stream of missiles. Thanks for any assistance. Share this post Link to post Share on other sites
celery 8 Posted January 20, 2011 (edited) Is there a way to do this in a way that does unlimited reloads instead of rounds in the chamber? I want A.I. MANPADs to have unlimited reloads, not exactly a stream of missiles.Thanks for any assistance. this addeventhandler ["Fired",{if (_this select 1=="Strela") then {_this select 0 addMagazine (_this select 5)}}] Edited January 20, 2011 by Celery 1 Share this post Link to post Share on other sites
Varkrag 10 Posted January 21, 2011 (edited) Amazing! Thank you, will try it now. [Edit] - It's good to go, much appreciated. Edited January 21, 2011 by Varkrag Share this post Link to post Share on other sites
scifer 10 Posted July 10, 2011 Does anybody know a function that returns how much ammo the unit has? I could use it when ammo < 0.5. This way the unit would always reload when needed. Share this post Link to post Share on other sites
cobra4v320 27 Posted July 10, 2011 Does anybody know a function that returns how much ammo the unit has? I could use it when ammo < 0.5. This way the unit would always reload when needed. Create a radio trigger set to repeat. On act. nul = [player, "m16a4"] execVM "checkammo.sqf" checkammo.sqf _unit = _this select 0; _weapon = _this select 1; _count = _unit ammo _weapon; hintsilent format ["You have %1 rounds of ammo in your magazine.", _count]; I used a basic USMC rifleman with the m16a4 rifle. Another command you might want to look at is someammo. Share this post Link to post Share on other sites
scifer 10 Posted July 10, 2011 Is there a way to do this in a way that does unlimited reloads instead of rounds in the chamber? I want A.I. MANPADs to have unlimited reloads, not exactly a stream of missiles. _ammo = createTrigger["EmptyDetector",getPos player]; _ammo setTriggerStatements["needReload player == 1", "reload player; player setVehicleAmmo 1", ""]; Share this post Link to post Share on other sites
maturin 12 Posted November 24, 2011 (edited) this addeventhandler ["Fired",{if (_this select 1=="Strela") then {_this select 0 addMagazine (_this select 5)}}] Edit: Nevermind, the reload time of the unit was the problem. Edited November 24, 2011 by maturin Share this post Link to post Share on other sites
PartyHead 10 Posted November 10, 2012 this addeventhandler ["Fired",{if (_this select 1=="Strela") then {_this select 0 addMagazine (_this select 5)}}] The above code by Celery gives a Strela unlimited reloads. Would anyone know what i need to do to the above code so it gives unlimited reloads to a static AA or static MG weapon ? Share this post Link to post Share on other sites
doc_no1UK 10 Posted November 11, 2012 Unlimited for everything is as follows without even having to reload,put in units ini this addEventHandler ["Fired",{[_this select 0,getNumber (configFile/"CfgAmmo"/(_this select 4)/"explosive")] spawn {if (_this select 1==1) then {sleep 0.75};_this select 0 setVehicleAmmo 1}}] Share this post Link to post Share on other sites
PartyHead 10 Posted November 11, 2012 Unlimited for everything is as follows without even having to reload,put in units inithis addEventHandler ["Fired",{[_this select 0,getNumber (configFile/"CfgAmmo"/(_this select 4)/"explosive")] spawn {if (_this select 1==1) then {sleep 0.75};_this select 0 setVehicleAmmo 1}}] Thanks for your reply Jim I will give that a try mate, but i did still want the reload effect to happen as normal and not just a constant flow of bullets or AA rockets, so this may not be what I'm looking for yet. I'll let you know if its not. Thanks again mate. Share this post Link to post Share on other sites
PartyHead 10 Posted January 28, 2013 I ended up putting this script together and thought i would post it for anyone else to use. This reload script will give a player or AI unit unlimited magazine reloads for a static weapon. I'm not an advanced scriptwriter so there is probably an easier way of doing this but this is just what i came up with. I did it this way because i wanted static MG's to still have the reload animation instead of a constant flow of bullets. Some of the script code is for the debug hints which i needed for learning. staticreload.sqf // script by PartyHead. // Unlimited magazine reloads for AI and player units as gunner of a static weapon. // place the following code in the init field of a static weapon and you or AI units // will get unlimited magazine reloads. // _nil = [this] execVM "staticreload.sqf"; //hintSilent "DEBUG\n\nAuto reloading script started."; _static = _this select 0; while {true} do { sleep 2; //hintSilent "DEBUG\n\nStatic weapons are waiting."; if (_static isKindOf "StaticWeapon") then { waitUntil {((_static emptypositions "gunner") == 0) && (alive _static)}; _type = typeOf _static; _gunner = gunner _static; _weapons = weapons _static; _weapon = currentWeapon _static; _magazines = magazines _static; _magazine = currentMagazine _static; _magCount = {_x == _magazine} count magazines _static; _ammo = ((_static) ammo (_weapon)); _reload = _magCount - 1; _static setVehicleAmmo 1; for [{_loop = 0},{_loop >= 0},{_loop = _loop}] do { _weapon = currentWeapon _static; _magazine = currentMagazine _static; _magCount = {_x == _magazine} count magazines _static; _ammo = ((_static) ammo (_weapon)); //hintSilent format ["DEBUG\n\nAuto reloading activated.\n\nVehicle: %1.\nGunner: %2.\nWeapons: %3.\nCurrent weapon: %4.\nMagazines: %5.\nRounds: %6.", _type, name _gunner, _weapons, _weapon, _magCount, _ammo]; if (_magCount <= _reload) then {_static setVehicleAmmo 1}; sleep 0.01; if (!(alive _static) || ((_weapons select 0) != (weapons (vehicle _gunner) select 0)) || ((_static emptypositions "gunner") == 1)) then { _loop = -1; //hintSilent "DEBUG\n\nAuto reloading deactivated."; }; }; }; }; Share this post Link to post Share on other sites
ulamlang 10 Posted October 31, 2014 _ammo = createTrigger["EmptyDetector",getPos player]; _ammo setTriggerStatements["needReload player == 1", "reload player; player setVehicleAmmo 1", ""]; Scifer, it doesnt work in AI.. :( It only works in player how to make it work for AI? TY (sorry for poor english) Share this post Link to post Share on other sites