Jump to content
Sign in to follow this  
obrez

Adding and removing ammo for backpack static weapon.

Recommended Posts

HI all, been away from editing for a while but I'm trying to get back into it. What I want to do is change the number of missiles the player gets with the backpack Metis launcher in CUP. I know how to add and remove ammo for pre-placed turrets but I want to change amount of ammo for the launcher that a player can carry as a backpack. How can I go about this?

 

I tested for ammo capacity or even any items in the backpack and it returns nothing. I'm assuming the backpack just adds the action to assemble/disassemble weapon which then spawns/despawns a turret. Knowing this, how can I get the turret itself to change the number of missiles? I tried getting it with the assemble weapon event handler, but that only seems to return the model name, not the in-game object itself.

 

What am I missing here?

 

Thanks for any help.

Share this post


Link to post
Share on other sites

The weaponAssembled EH returns two things. From the Biki entry:

this addEventHandler ["WeaponAssembled", {
	params ["_unit", "_staticWeapon"];
}];

"_unit" is the object to which the EH is assigned (generally, a player) and "_staticWeapon" is the assembled weapon object.

 

So, to do what you want:

 

 

We do it this way to avoid the possibility of infinite ammo (extra magazines added every time the weapon is assembled).

this addEventHandler ["WeaponAssembled", {
    params ["_unit", "_staticWeapon"];
    _mags = _staticWeapon magazinesTurret [0];
    _staticWeapon removeMagazinesTurret [_mags select 0, [0]];
    for "_i" from 1 to 3 do {_staticWeapon addMagazineTurret [_mags select 0, [0]]};
    _unit removeEventHandler ["WeaponAssembled", _thisEventHandler];
}];

Line five defines how many magazines the turret will have:

for "_i" from 1 to N

where "N" is the number of desired magazines.

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×