Home   Help Search Login Register  

Author Topic: "Hit" eventhandler  (Read 934 times)

0 Members and 1 Guest are viewing this topic.

Offline SEAL84

  • Members
  • *
  • Always lurking
"Hit" eventhandler
« on: 25 Mar 2005, 06:11:45 »
So I added the eventhandler "hit" to the men in a squad.  When they're hit, a tiny little script is run that makes them shout one of the three "Medic, I'm hit!" sounds:

Code: [Select]
_unit = _this select 0
_var = (random 3)

?(_var < 1): _unit say "eng32"
?(_var >=1) and (_var < 2): _unit say "eng33"
?(_var >= 2) and (_var <=3): _unit say "eng34"
~1
exit

Probably really noobish, but it works.  I shoot a guy and he yells one of the three files...

Actually he yells two.  I tried this using only one sound file, just to see if I screwed it up with the random selection of the sound, but no - every time I wound a guy, he yells twice.

Why? ???

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:"Hit" eventhandler
« Reply #1 on: 25 Mar 2005, 06:20:23 »
Not sure why.  Does this have the same problem:



Code: [Select]
_unit = _this select 0
_messages = ["eng32","eng33","eng34"]

_var = random count _messages
_var = _var - (_var % 1)

_msg = _messages select _var

_unit say _msg
exit

I have not checked the syntax.  

If it does then is the guy only being hit once?  
« Last Edit: 25 Mar 2005, 06:22:37 by THobson »

Offline SEAL84

  • Members
  • *
  • Always lurking
Re:"Hit" eventhandler
« Reply #2 on: 25 Mar 2005, 06:30:16 »
Yes, he's still yelling twice after I shoot him once in the leg.  I was using an M16, but I popped him with a Beretta instead - weapon power made no difference.

I vaguely remember some discussion a while ago about "hit" being buggy when used on a helicopter...is it just not precise enough to do this?

(incidentally I did find another script - not using eventhandlers - in the ed depot that works perfectly)


Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:"Hit" eventhandler
« Reply #3 on: 25 Mar 2005, 07:59:17 »
Quote
I did find another script - not using eventhandlers - in the ed depot that works perfectly
Sound like it is problem with the {hit} eventhandler.  

The only time I have used a {hit} EH is when I want to setDammage 0 so it has not caused me any problem.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:"Hit" eventhandler
« Reply #4 on: 25 Mar 2005, 12:40:00 »
It seems that when inflicted damage is low the eventhandler is executed twice...

If you shoot a guy on the legs with M16, it causes a damage of about 0.11xxxx and the EH is executed twice...

But when using some more powerful weapon, which in this case was some knife addon hasle (throwable knives) that caused a damage of 0.66xxxxx when hit on the legs, the EH got executed only once...

And if the soldier dies from the hit the hit EH is executed only once...

Not the most extensive research data ::)
But would seems that there's a slight bug in hit EH...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:"Hit" eventhandler
« Reply #5 on: 25 Mar 2005, 13:00:29 »
Could it be the bullet hits both legs but the knife only hits one? ;)

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:"Hit" eventhandler
« Reply #6 on: 26 Mar 2005, 02:29:17 »
...yeah... I tend to shy away from hit Eventhandlers.

The script will execute for everytime he is 'hit' (which can be multiple times per projectile).
Try hitting him with a grenade... he'll yell about 17 times ;D

I'd suggest putting a condition at the start of your script that detects whether it's already running and exits if so ;)

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:"Hit" eventhandler
« Reply #7 on: 26 Mar 2005, 02:38:21 »
Or you can use the "dammaged" eventhandler. That one will only run ONCE, until the unit is healed again. Well, it will only run once for each part of the body that is damaged, so that means it could run 4 times max. Also, the eventhandler won't run until the unit takes a sizable amount of damage in a specific part.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:"Hit" eventhandler
« Reply #8 on: 26 Mar 2005, 19:02:00 »
Quote
Try hitting him with a grenade... he'll yell about 17 times
And you tried this?
Because when I tried the guy only 'shouted' once.. ;)

Tried this when I made my huge scientific full spectrum study on this matter... ::)

Quote
Could it be the bullet hits both legs but the knife only hits one?
Last that I checked OFP does not simulate bullet ricochets...
Which the bullet would've needed to do if it had hit both legs when only the other is shot...
I didn't shoot the guy from the side...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:"Hit" eventhandler
« Reply #9 on: 27 Mar 2005, 01:34:51 »
And you tried this?
Because when I tried the guy only 'shouted' once.. ;)

Hmm... ah well. If it works, use it :)

The last time I played with hit event handlers was when I was trying to detect if the player was shooting friendlies....
Put it this way, they player ended up getting court martialled about 17 times per offense (now that's dis-incentive ;D)