OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: haroon1992 on 30 Jul 2009, 16:44:07
-
I have a large scale battle mission (check forum)
I have made an air strike but i don't know how to rearm the chopper via SCRIPTING method......
How can i rearm the chopper every three minutes so that it doesn't run out of ammo? ???
Haroon1992...............
-
You need a script like this one here:
_chopper = _this select 0
#Status
?NOT (SomeAmmo _chopper): goto "Rearm"
goto "Status"
#Rearm
_chopper addmagazine "HellfireLauncherCobra"
_chopper addmagazine "ZuniLauncher38"
goto "status"
exit
This script is called from the init line of the chopper:
[this] exec "rearm.sqs"
However, i dont know a command that can restore a vehicle's ammo without adding the weapons manually. Which is quite difficult as i dont know the different types of weapons :confused:
If only there was a command like 'setvehicleammo' :(
(Ive tried SetAmmoCargo but nothing happens :no: )
Hope this helps
Gruntage
-
At least this adds some ammo to my chopper....
Thanks...... ;)
-
Here is a more general script that will work on any vehicle with any ammo type. The script must be run before the unit runs out of ammo so that it "knows" the magazine types before they are expended.
;reload.sqs by Raptorsaurus
_craft = _this select 0
_mags = magazines _craft
#start
@ (! (someAmmo _craft) || ! alive _craft
? ! alive _craft : exit
{_craft removeMagazine _x} forEach _mags
{_craft addMagazine _x} forEach _mags
? alive _craft : goto "start"
exit
To run the script just use: [this] exec "reload.sqs" in the init field of the vehicle that you want to have perpetual ammo. This will work for soldiers also.
-
I think using the someAmmo (http://www.ofpec.com/COMREF/index.php?action=details&id=354&game=All) command will prove more trouble than it's worth, because it only becomes not true when the vehicle is out of all possible magazines. In other words, your chopper may use up its rockets but, as long as it can fire its gun, it won't rearm.
Use the majority of Raptosaurus' script, but, as you originally wanted, have it looping every three minutes:_craft = _this select 0
_mags = magazines _craft
#start
? ! alive _craft : exit
{_craft removeMagazine _x} forEach _mags
{_craft addMagazine _x} forEach _mags
~180
goto "start"
-
Thanks you very much for the help (both of you) :clap:
I have been confused that i can't find the ammo class for FFAR missiles.....
With this ,i think it will work ,thanks....everyone
-
Here (http://www.ofpec.com/COMREF/index.php?action=read&id=67).
Planck
-
Can you tell me which one is the FFAR.....? ???
-
ZuniLauncher38
-
Thanks Walter.................................................................. :D