Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
johnnyboy

Create LOADED weapon on ground? [SOLVED]

Recommended Posts

I'm using the following command to create a WeaponHolder for a single weapon:

 

_weaponHolder = "WeaponHolderSimulated" createVehicle [0,0,0];

_weaponHolder addWeaponCargo ["M16",1];

 

I need this weapon to be loaded.  The above always gives you an empty weapon.  I know I can add magazines as cargo, but that is not what I want.

 

Any way to create a single loaded weapon?

 

Solved:  See Grumpy Old Man's solution here.

Share this post


Link to post
Share on other sites

Here you go.

 

Cheers

 

Thanks GOM!   I may have to run this at startup to cache various loaded weapons ahead of time.  That way I won't have wait for the long sleep required to give time to DropWeapon.  My use case is I have a dog attacking a dude, whose weapon flies out of his hand during the scuffle.  I need it loaded when it hits the ground, and not sure I can wait 5 seconds for that.

 

BTW, why are you grumpy...you don't seem grumpy to me?  :)

Share this post


Link to post
Share on other sites

BTW, why are you grumpy...you don't seem grumpy to me?  :)

 

I'm usually caffeinated when typing, so there's that.

 

If you only want to make a unit drop its weapon then use this after the dog disarmed the unit:

_unit = player;
_pos = _unit getRelPos [direction _unit, 1];
_wh = createVehicle ["GroundWeaponHolder",_pos,[],0,"CAN COLLIDE"];
_unit action ["DropWeapon", _wh , currentWeapon _unit];

Make sure the unit is still alive while this is being performed, since a dead unit can't drop its weapon for some reason.

This still needs a short delay on top of that since the unit needs to perform the drop action.

Kinda calls for a forceDropWeapon action of sorts.

 

Edit: fixed the snippet.

 

Cheers

Share this post


Link to post
Share on other sites
Guest

since a dead unit can't drop its weapon for some reason.

 

Cheers

You made my day x).

Share this post


Link to post
Share on other sites
Guest

Sorry for the double post. I was wondering if killing the unit + deleting its body + get nearest GroudWpnHolder + Moving the Weapon holder to where you want is faster. (Probably less efficient but faster I believe)

Share this post


Link to post
Share on other sites

Units don't create groundweaponholders when killed, at least not all of the time.

A seperate command would be best to do this.

 

Cheers

Share this post


Link to post
Share on other sites

If you only want to make a unit drop its weapon then use this after the dog disarmed the unit:

Thanks for the suggestion.  But I'm using the code below for a more "involuntary" tossing of weapon, rather than a controlled "dropWeapon".  But I might use your suggestion for "Guard/Watch" mode of dog, where dog confronts without attacking (in this "Guard" mode victim currently plays "Surrender" animation, but DropWeapon may augment this nicely).

 

When dog attacks, I'm using this for attacked dude to lose weapon:

_weapon = currentWeapon gDOG_TARGET;       
gDOG_TARGET removeWeapon (currentWeapon gDOG_TARGET);
sleep .1;
_weaponHolder = "WeaponHolderSimulated" createVehicle [0,0,0];
_weaponHolder addWeaponCargo [_weapon,1];
_weaponHolder setPos (gDOG_TARGET modelToWorld [0,.2,1.2]);
_weaponHolder disableCollisionWith gDOG_TARGET;
_dir = random(360);
_speed = 1.5;
_weaponHolder setVelocity [_speed * sin(_dir), _speed * cos(_dir),4];  // weapon tossed up a bit...

I'll likely improve the above code to replace the weaponholder with a cached dropped weapon that has ammo (per your suggestion).

  • Like 1

Share this post


Link to post
Share on other sites
Guest

Units don't create groundweaponholders when killed, at least not all of the time.

A seperate command would be best to do this.

 

Cheers

Bohemia y u do dis.

Thanks for the answer, that's sad we don't have such things in a sandbox game.

Edit : We can still detect the empty weapon equipped and force load a magazine into it. Still trying to find proper ways than spawning an ai :p

Share this post


Link to post
Share on other sites

×