OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Triggerhappy on 12 Jul 2005, 17:27:17

Title: Changing kits between soldiers
Post by: Triggerhappy on 12 Jul 2005, 17:27:17
here's a little script i put together that lets any 2 units switch kits(all their weapons and ammo).
it should be mp compatible, but i can't test that.

it can be used as an action like it is in the demo mission, but you can also call the script to change 2 ai units or force the player to change,etc

[unit1,unit2] exec "kitswitch.sqs"

order doesn't matter ( [unit2,unit1] )

known bugs:
1: if you don't reload and you switch weapons, it will gain back its ammo in the mag you hadn't reloaded
2: when you switch weapons you have to hit your "toggle weapons" key to be able to fire

i don't think 1 can be fixed, but what about 2? does anyone have any ideas?
Title: Re:Changing kits between soldiers
Post by: bedges on 12 Jul 2005, 17:51:06
question 2 - use 'selectweapon' (http://www.ofpec.com/editors/comref.php?letter=S#selectWeapon)...
Title: Re:Changing kits between soldiers
Post by: Triggerhappy on 12 Jul 2005, 18:28:29
odd, its still didn't work... the same thing happens:
you have your gun out, but you have to toggle between single,burst, grenades (whatever button that is)  to be able to shoot.
Title: Re:Changing kits between soldiers
Post by: Blanco on 12 Jul 2005, 19:50:00
Try a combination of selectweapon and
Quote
unitname action ["weaponinhand"]
Title: Re:Changing kits between soldiers
Post by: Triggerhappy on 13 Jul 2005, 06:32:58
the weapon is in their hand.

if you dl the script you'll see what i mean
there is a little demo mission where you can take people kits through actions.
Title: Re:Changing kits between soldiers
Post by: Terox on 13 Jul 2005, 17:16:05

_primary = primaryweapon _unit
_ammo = magazines _unit
_weps = weapons _unit

{_unit addMagazine _x} forEach _ammo
{_unit addWeapon _x} forEach _weps
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"


_unit selectWeapon _primary


most addon grenade launcher weapons are also "XXXMuzzle"

there are a few exceptions to the rule

but use the lines above will auto select normal fire muzzle without having to toggle through weapons
Title: Re:Changing kits between soldiers
Post by: Triggerhappy on 13 Jul 2005, 23:21:27
well, if thats the only problem, than why won't a regular m16 get selected, or any other weapon that isn't a grenade launcher
Title: Re:Changing kits between soldiers
Post by: Terox on 14 Jul 2005, 00:33:46
odd, its still didn't work... the same thing happens:
you have your gun out, but you have to toggle between single,burst, grenades (whatever button that is)  to be able to shoot.

i was replying to that post