OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: chops on 18 Aug 2007, 04:39:03
-
Hi,
I'm trying to create a script where a flare is created at a certain height (on the way down), after an artillery shell having been fired...
this AddEventHandler ["fired",{_this exec "scripts\flare.sqs"}] calls...
"flare.sqs"
_firer = _this select 0
_ammo = _this select 4
_shell = nearestObject [_firer, _ammo]
~5
@ (getpos _shell select 2 <=100)
player sidechat "Flares"
flare1 = "F_40mm_White" createvehicle getpos _shell
deletevehicle _shell
flare1 setVelocity [0, 0, 1]
_firer removeEventHandler ["fired",0]
exit
It's for an artillery script I'm working on, it just doesn't seem to work. I get the "Flares" sidechat five seconds after firing, so I guess the problem lies with detecting the height of the shell. The shell itself is also not being deleted.
I originally wrote this for OFP and it worked fine.
Any help would be greatly appreciated!
Thanks.
-
As far as I know the projectiles fired from the arty pieces in ArmA timeout after a certain period of time and are removed from the 'world'.
This is why artillery must still be scripted in ArmA for anything other than a close range "Line of sight" type deal.
I'd say throw in some more debugging sidechats to see what's going on.
-
firecontrol is right, more than problably the shell is removed automatically by ArmA in less than 5 secs, anyway you want to chek the "way down" of the shell so your condition should be different.
_firer = _this select 0
_ammo = _this select 4
_shell = nearestObject [_firer, _ammo]
@ (velocity _shell select 2 < 0) || (isNull _shell)
? isNull _shell: hint "NULL SHELL";exit
@ (getpos _shell select 2 <=100) || (isNull _shell)
? isNull _shell: hint "NULL SHELL";exit
flare1 = "F_40mm_White" createvehicle getpos _shell
deletevehicle _shell
flare1 setVelocity [0, 0, 1]
_firer removeEventHandler ["fired",0]
Aslo, using exec in ArmA to detect a shell is not the best idea, in many cases you may simply miss the shell because _shell = nearestObject [_firer, _ammo] is executed when the shell is already further than 50m from the firer, so the returned shell will be null. Check this (http://www.ofpec.com/forum/index.php?topic=29883.0) for a better way to execute the event handler code.
-
Arty shells 'live' for 20 seconds.
Bullets about 3 secs, missiles about 12 secs, IIRC bombs lived about 30 secs..
Haven't tested since 1.00 I guess so they might have changed things, but just tested the arty and it is 20 secs.
EDIT:
Chops, note that this is wrong in your script
@ (getpos _shell select 2 <=100)That line says 'wait until the shell is at 100 meters or lower', which means the condition is true the moment you fire the weapon and the flare is created right in front of the arty piece instead of the sky..
Change that to
@ (getpos _shell select 2 >=100)