OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blanco on 04 Apr 2005, 23:48:42

Title: dynamic infinite ammoscript
Post by: Blanco on 04 Apr 2005, 23:48:42
I'm working on a dynamic infinite ammo script.
I don't want to add parameters or so, you can determine the ammo type via a "fired" eventhandler, transport the ammotype to a script that checks the ammo and add that magazine type again.

It goes like this, put this in the init :

Code: [Select]
this addeventhandler ["fired",{_this exec "fired.sqs"}]

The fired script

Code: [Select]
_unit = _this select 0
_muzzle = _this select 2

[_unit,_muzzle] exec "addmag.sqs"
_unit removealleventhandlers "fired"
exit

the addmag script

Code: [Select]
_unit = _this select 0
_ammo = _this select 1

#L
?!alive _unit : exit
?_unit ammo _ammo < 1 :goto "R"
~2
goto "L"

#R
_unit addmagazine _ammo
~1
goto "L"

The problem is that the fired script only checks one ammotype ,When the unit switches to grenades, law or handgun , the script fails.
What can be done to make this work?

 
Title: Re:dynamic infinite ammoscript
Post by: Planck on 05 Apr 2005, 00:04:24
You might have to detect the rest another way, they don't seem to have a 'muzzle' setting.


Planck
Title: Re:dynamic infinite ammoscript
Post by: Blanco on 05 Apr 2005, 00:31:08
True, for grenades you'll need the _ammo = _this select 4 to get the correct ammotype.
 
*edit*
 :P Wrong again.
_ammo = _this select 4 when you throw a grenade is "grenadehand". to add a grenade you'll need "handgrenade"

I did this and it works :

Code: [Select]
?_weapon == "throw" && _ammo == "grenadehand" : _ammo = "Handgrenade";[_unit,_ammo] exec "reloadnades.sqs"
But there is no logical system behind those ammoclasses...it a real mess...
I think the only way to do this , is to make a database inside the fired script. But I still have a real life, so I'll give up.  :(

 

 
Title: Re:dynamic infinite ammoscript
Post by: General Barron on 05 Apr 2005, 02:34:55
Yeah, there isn't really a way to detect what MAGAZINE type was fired either, so you would have to create some sort of database any way you cut it.