OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: rhysduk on 15 Feb 2004, 17:14:49

Title: Eventhandlers and FlareTrap
Post by: rhysduk on 15 Feb 2004, 17:14:49
Hi All,

Im having a spot of bother with eventhandlers. :( I understand the basics of them but not much more

I want a flare to be fired by a flaretrap (trigger executing a flare script) but the flare has smoke tails effects...

I can get the flare to have the smoke tail effects when me, hte player, fires a flare from a flare gun but not when it is not fired from the trigger/script...

I get the smoketail affect by putting this in the players INIT feild:-

Code: [Select]
this AddEventHandler ["fired",{_this exec "flareFX.sqs"}]
and this script :-

Code: [Select]
_man = _this select 0
_projectile = _this select 4

?_projectile != "flare" : exit
_object=nearestobject [_man,"flare"]

_pos=getpos _object
_life =30
_delay = 0.01
_lifeTicks = _life / _delay
_life = _lifeTicks


;;yeah... I added a flare sound
~1.4
;;playsound "flare"

#Begin
_pos=getpos _object

_shade = 0.65 +random 0.3
_smoke=drop["cl_basic","","Billboard",1,5,_pos,[0,0,0],0,1,1,0,[0.5,3],[[_shade,_shade,_shade,0.9],[0.8,0.8,0.8,.1]],[0,1],2.8,1,"","",""]  

~0.0001*_delay
_life = _life - 1
?_life > 0 : goto "Begin"
exit

This works perfectly when i fire the flare myself... but what i want to do is to get this effect when a flare is fired from a script (cam created)..

I take it the event handler wont work on this??

Rhys

Title: Re:Eventhandlers and FlareTrap
Post by: Blanco on 15 Feb 2004, 18:48:05
eh, that script looks familiar :)


you don't need the eventhandler when the flare's camcreated. Eventhandler "fired" is only used to activate a script or code when a unit fires his weapon, in your case the the flare's created with camcreate

Just run the flareFX script when the flare's created.
Run the variable as first and only param

In your flare trapscript there should something like that:

_flare = "flare" camcreate <position> ;

<position> is probably a marker or gamelogic.

add this line after the flare's created

[_flare] exec "flarefx.sqs"

 
but flareFX.sqs is a bit different

Code: [Select]
_object = _this select 0

_pos=getpos _object
_life =30
_delay = 0.01
_lifeTicks = _life / _delay
_life = _lifeTicks


#Begin
_pos=getpos _object

_shade = 0.65 +random 0.3
_smoke=drop["cl_basic","","Billboard",1,5,_pos,[0,0,0],0,1,1,0,[0.5,3],[[_shade,_shade,_shade,0.9],[0.8,0.8,0.8,.1]],[0,1],2.8,1,"","",""]  

~0.0001*_delay
_life = _life - 1
?_life > 0 : goto "Begin"
exit

not tested, tho
but I have to say the effect is better with the flare sound :)

Title: Re:Eventhandlers and FlareTrap
Post by: rhysduk on 15 Feb 2004, 18:55:23
Thanks a bunch mate - ur a genius  :-*

Rhys

Topic Locked!