Jump to content
aie-boshell

Make AI Unit Drop Weapons/Items On Ground Without Animation

Recommended Posts

Hello, what I'm trying to do is when an enemy AI surrenders, have them drop their weapons on the ground by using and addaction "Secure Prisoner" command.  Of course, I could use "Remove allweapons" but this just deletes the weapons but I'd like to be able to confiscate the weapons for me to use.  I've also used the action "dropweapon" but that causes a lengthy animation where the AI first aims the weapon as if ready to fire before slowly throwing the weapon out which reduces immersion.  What I'd like to happen is the exact thing that happens when a player goes into inventory by pressing "i" and then moves a weapon to the ground.  I don't need animations, I just need the enemy to be disarmed and have their weapons available for me to pickup off of the ground.  Is this possible?  As always, any help from the extremely smart community here is very much appreciated :-)

Share this post


Link to post
Share on other sites

What you need to do is create a weapon holder via script.

 

something like this (code not tested): 

wh = "WeaponHolder" createVehicle pos; 

wh addWeaponCargo ["arifle_Khaybar_C_ACO_F",1];

 

There's a lot of information about this available with google:

 

https://www.google.fi/search?biw=1489&bih=922&ei=smFkWvK-DoegsgGQ3b3YAQ&q=weaponholder+site%3Aforums.bohemia.net&oq=weaponholder+site%3Aforums.bohemia.net&gs_l=psy-ab.3...124729.124729.0.124920.1.1.0.0.0.0.148.148.0j1.1.0....0...1c.1.64.psy-ab..0.0.0....0.h5evPJwkt4I

 

HTH

  • Thanks 1

Share this post


Link to post
Share on other sites

Here's some code from JBOY_Dog.  When dog attacking an armed guy there is a chance he drops his weapon.  With this code you see the weapon drop so it looks more natural.  You might want to adjust the z velocity for your case (I'm having the guy toss the weapon up a little bit via z velocity of 4).

 

Note that WeaponHolderSimulated has physics enabeled, so weapon drops nicley.  WeaponHolder does not have physics.

_weapon = currentWeapon _dude;       
_dude removeWeapon (currentWeapon _dude);
sleep .1;
_weaponHolder = "WeaponHolderSimulated" createVehicle [0,0,0];
_weaponHolder addWeaponCargoGlobal [_weapon,1];
_weaponHolder setPos (_dude modelToWorld [0,.2,1.2]);
_weaponHolder disableCollisionWith _dude;
_dir = random(360);
_speed = 1.5;
_weaponHolder setVelocity [_speed * sin(_dir), _speed * cos(_dir),4];  

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

I was so excited about the information you guys have provided that I forgot to properly thank you gentlemen.  

 

GC8, you answered my question perfectly and gave me the solution I needed to move forward.  

 

Johnnyboy, you provided some additional information which I have used.  That code works fantastic and I have modified it to suit my scenario.  

 

Both of you have helped me tremendously and are two very valuable pieces of this awesome community.  Thank you again :-)

 

  • 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

×