169th_Ice 0 Posted February 3, 2007 Id like to create a Shilka thats invulnerable and never runs out of Ammunition. Is this possible ? Share this post Link to post Share on other sites
fasad 1 Posted February 3, 2007 yes, in many different ways. I'd make a looping script or use eventhandlers. refer to the BI WIKI. Share this post Link to post Share on other sites
169th_Ice 0 Posted February 3, 2007 I did refer to the BI WIKI and couldnt find an answer. That doesnt mean it isnt there. It just means im too dumb to find it. If someone smarter than me could please hold my hand and point out the commands or better still leave a link with a template that I could download. Share this post Link to post Share on other sites
kronzky 5 Posted February 3, 2007 Put this into the init line of your Shilka: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired",{if (count magazines this <2) then {this addmagazine "2000Rnd_23mm_AZP85"}}] Share this post Link to post Share on other sites
Guest Posted February 3, 2007 Nice one Kronzky, event handler is perfect for my mission as well, considering according to ofp info on them, they dont lag, so this could be on any given units in a mission. heres a code for the invulnerable part, works on player unit, id think it would work on any unit/vehicle: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> this addeventhandler ["hit", {_this select 0 setdamage 0}]; this addeventhandler ["dammaged", {_this select 0 setdamage 0}] so, in the init line of the vehicle to put it all together, should look like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> this addEventHandler ["fired",{if (count magazines this <2) then {this addmagazine "2000Rnd_23mm_AZP85"}}];this addeventhandler ["hit", {_this select 0 setdamage 0}]; this addeventhandler ["dammaged", {_this select 0 setdamage 0}] Share this post Link to post Share on other sites
kronzky 5 Posted February 3, 2007 Well, technically, an EventHandler is not really the best solution, especially with a Shilka that fires a few dozen times per second. It's a bit wasteful, since you could get by with something that only loops once every few seconds or so, rather then on every single shot. But it's the easiest to implement, especially if you're a beginner, so that's why I recommended it over a script. Oh, yeah... And I guess I forgot that invulnerability was part of the request... Share this post Link to post Share on other sites
Guest Posted February 3, 2007 Gotcha on that, in my particular case, I do have the option to use a script already made by CSL (infiniteAmmo) but, the mission has like 300 + units across the map, and its only being used primarily for tanks and units, id prefer to use that eventhandler unless u feel even with tanks/units it could fail.. edit/ didnt realize I can just run one script with all units in a global array that loops for like 5 min or sometin.. Share this post Link to post Share on other sites
169th_Ice 0 Posted February 4, 2007 Thank you Kronsky and Special Ed. Quote[/b] ]this addEventHandler ["fired",{if (count magazines this <2) then {this addmagazine "2000Rnd_23mm_AZP85"}}] This gives an error as soon as I start firing ? And doesnt reload. Quote[/b] ]'if count |#|magazines this <2) then {this addmagazine...Error magazines: Type Bool, expected object Another one for you guys. I add extra weapons/Ammo to choppers and such. How to make them respawn with the same extra weapons and Ammo. I tried the "[unit-Name, 0] exec "weapons_respawn.sqs". But this does not seem to work. Share this post Link to post Share on other sites
kronzky 5 Posted February 4, 2007 Looks like the code I gave you only works if you're the gunner yourself. In case the AI is manning the tank you would have to give the tank a name, and refer to that in the event handler. So, let's say the Shilka is named "SH", then the code would be <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired",{if (count magazines SH <2) then {SH addmagazine "2000Rnd_23mm_AZP85"}}] Share this post Link to post Share on other sites
169th_Ice 0 Posted February 24, 2007 Was trying to use this Unlimited Ammo script for the AV8B Quote[/b] ]this addeventhandler ["hit", {_this select 0 setdamage 0}];this addeventhandler ["dammaged", {_this select 0 setdamage 0}]; this addEventHandler ["fired",{if ((count magazines Harrier_1) <2) then {Harrier_1 addmagazine "5Rnd_GBU12_AV8B"}}]; this addEventHandler ["fired",{if ((count magazines Harrier_1) <2) then {Harrier_1 addmagazine "300Rnd_25mm_GAU12"}}]; but for some Reason the bombs do not reload. I'm assuming its because countmagazine os for cannon rounds only. Can this script be modified so i can have unlimited GBU's? Share this post Link to post Share on other sites
quiet_man 8 Posted February 24, 2007 for some Reason the bombs do not reload. I'm assuming its because countmagazine os for cannon rounds only bombs use single shoot mags the problem is that "empty" mags are only removed when a new one is loaded. This means the mag count never goes below 1 same with hand guns (just when you drop the empty weapon and take it again the mag count goes 0) for unlimited bombs simply set the mag limit to 2 (so the plane will always carry one reserve ) there is also a command to count bullets in current mag, but I don't think it is worth the effort. QuietMan Share this post Link to post Share on other sites
celery 8 Posted February 24, 2007 For unlimited ammo, name your machine veh1 and make a trigger with repeated activation: Condition: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">!someammo veh1 Activation: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">veh1 setvehicleammo 1 No need for fancy commands. Share this post Link to post Share on other sites
Platoon_Patton 0 Posted February 24, 2007 Celery your method is simple but resource hungry,a trigger covering the whole batlle area that checks several times each seconds if a unit/vehicle has some ammo... The combination of Kronzky´s EH with your solution would be better IMHO: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired",{(_this select 0) setvehicleammo 1}] It doesnt use an if then and a count condition. Share this post Link to post Share on other sites
169th_Ice 0 Posted February 24, 2007 Quote[/b] ]for unlimited bombs simply set the mag limit to 2 (so the plane will always carry one reserve An example please. Does not make sense to me. Share this post Link to post Share on other sites
169th_Ice 0 Posted February 25, 2007 Platoon_Patton wins in my book. This script is perfect. thanks! Quote[/b] ]this addEventHandler ["fired",{(_this select 0) setvehicleammo 1}] Share this post Link to post Share on other sites
quiet_man 8 Posted February 25, 2007 Quote[/b] ]for unlimited bombs simply set the mag limit to 2 (so the plane will always carry one reserve An example please. Does not make sense to me. sorry I was lazy, you already had 2 in your condition but you count all mags and as you have two weapons (one cannon and one bomb launcher) you never get below two mags on board it works if you count only count the mags for the weapon you want to reload (({_x == "5Rnd_GBU12_AV8B"} count magazines Harrier_1) <2 I don't know if a "fired" eventhandler is good for cannons at all, I would just add 20 mags and run a script which checks every few seconds and add 10 more if required QuietMan Share this post Link to post Share on other sites