OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Homefry31464 on 24 Jan 2004, 00:12:30
-
Now that I have your attention, I have to ask a question. When a unit is killed, is there any delay or is he dead, instantly? I ask this because I was wondering if there was a way to make the unit drop the weapon when he's killed.
Is there a command, much like the unassign command for a unit in a vehicle, which makes the weapon be dropped from a unit?
-
An odd question. As soon as a units dammage reaches 1 then hit is dead. He can be stanidng up while this happens, but then he falls to the floor.
The next part is even more confusing, when a unit dies, you can pick up his weapon, it just shows it in his hand, but you can still take it, and order or script AI to take it. Do you want him to fling it across the map in the throes of his death?
-
The main reason behind it is the fact of when an explosion goes off, the weapon flies with it, only seemingly floating a few inches away from the man's hand.
-
this script is executed by "killed" eventhandler:
_dead = _this select 0
_weapons = weapons _dead
_weapon ="WeaponHolder" CreateVehicle getPos _dead
_weapon addWeaponCargo [format ["%1",_weapons select 0], 1]
_dead removeWeapon format ["%1",_weapons select 0]
exit
someone should add an ammo check, because this gives an empty weapon the dude had...
-
Ok here is the script...
It needs to be refined the position to the weapons dropped....
After a little experimenting I noticed that select 0 is always the primary weapon
and select 1 is the rpg or law etc...
It does not depend on which weapon is in the unit's hand when he is killed...
These script will drop one weapon if he had 1, two if he had two...with the ammo the dude had
_dead = _this select 0
_weapons = weapons _dead
? count _weapons == 1: goto "1weapon"
? count _weapons == 2: goto "2weapons"
#1weapon
_ammo01 = _dead Ammo format ["%1",_weapons select 0]
_weapon01 ="WeaponHolder" CreateVehicle getPos _dead
_weapon01 addWeaponCargo [format ["%1",_weapons select 0], 1]
_weapon01 addMagazineCargo [format ["%1",_weapons select 0], _ammo01]
_dead removeWeapon format ["%1",_weapons select 0]
goto "end"
#2weapons
_ammo01 = _dead Ammo format ["%1",_weapons select 0]
_ammo02 = _dead Ammo format ["%1",_weapons select 1]
_weapon01 ="WeaponHolder" CreateVehicle getPos _dead
_weapon02 ="WeaponHolder" CreateVehicle getPos _dead
_weapon01 addWeaponCargo [format ["%1",_weapons select 0], 1]
_weapon01 addMagazineCargo [format ["%1",_weapons select 0], _ammo01]
_weapon02 addWeaponCargo [format ["%1",_weapons select 1], 1]
_weapon02 addMagazineCargo [format ["%1",_weapons select 1], _ammo02]
_dead removeWeapon format ["%1",_weapons select 0]
_dead removeWeapon format ["%1",_weapons select 1]
#end
exit
-
Thanks a lot dude. How do I impliment this into the mission?? As in, have this script run for every unit on the map when he is killed.
-
name this script to: weapondrop.sqs
Create a trigger covering all unit you want to have this feature
set to: anybody present
type: none
copy this to 'on activation field':
"_x addEventHandler [""killed"",{_this exec ""weapondrop.sqs""}]" forEach thislist
But I let you know, when the rpg or law or AA...dropped, its position is vertical and looks like it is drilled to the ground.
As I said its position needs to be refined...
The primary weapon will be laying nicely... ;)
-
Alright. Thanks a lot. ;D ;D ;D
-
Does anyone know how to fix the secondary weapon's problem??