Home   Help Search Login Register  

Author Topic: Creating a flare at given bullet/shell height, via fired EH.  (Read 1192 times)

0 Members and 1 Guest are viewing this topic.

Offline chops

  • Members
  • *
  • I'm a llama!
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"
Code: [Select]
_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.

Offline firecontrol

  • Members
  • *
Re: Creating a flare at given bullet/shell height, via fired EH.
« Reply #1 on: 18 Aug 2007, 04:47:43 »
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.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Creating a flare at given bullet/shell height, via fired EH.
« Reply #2 on: 18 Aug 2007, 09:38:29 »
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.

Code: [Select]
_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 for a better way to execute the event handler code.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Creating a flare at given bullet/shell height, via fired EH.
« Reply #3 on: 18 Aug 2007, 10:01:17 »
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
Code: [Select]
@ (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
Code: [Select]
@ (getpos _shell select 2 >=100)
« Last Edit: 18 Aug 2007, 10:15:42 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.