Jump to content
Sign in to follow this  
Somerville

Determining somebody's loadout

Recommended Posts

I'm looking for a way to determine what weapons a unit has. Then for these weapons to be taken from the unit, and placed in a crate, where they can be picked up at a later time.

It's because I'm making a mission where you can go into a duel with another unit in Paraiso, only with an M9 ^.^ But I want it so you can go there with say an M16A2, and it'll take that off you when you enter the fight and store it in a crate so you can get back to it later.

Share this post


Link to post
Share on other sites

Here's the building blocks for what you need:

1. Find all weapons held by unit (returns array of weapons:

_wpn_array = weapons unit;

_mag_arry  = magazines unit;

2. Remove weapons from unit:

removeAllWeapons unit;

removeAllMagazines unit;

3. Add weapons/magazines to a crate or vehicle:

crate1 addMagazineCargo [magazineName, count] ;

crate1 addWeaponCargo [magazineName, count] ;

4. Addweapon/magazines to unit:

unit addWeapon weaponName ;

unit addMagazine magazineName ;

You will need to get the array of weapons and ammo, then loop throught the array to load an ammo crate from the array.

To give you an idea, below is a simple script that gets the weapons for a unit, then loops the array and displays each weapon name and magazine name.

There are "ammo crate filler" scripts out there at www.OFPEC.com if you look around.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;show_equip.sqs

_dude = _this select 0

_weapons = weapons _dude

_mags = magazines _dude

_cnt = count _weapons

_x = 0

~2

#loop1

TitleText[format["_x= %1, weapon=%2",_x, _weapons select _x], "plain",1]

_x = _x +1

~3

?_x < _cnt: goto "loop1"

_cnt = count _mags

_x = 0

#loop2

TitleText[format["mag=%1",_mags select _x], "plain",1]

_x = _x +1

~1

?_x < _cnt: goto "loop2"

#end

exit

Edit: Schwab beat me to the punch.

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  

×