Home   Help Search Login Register  

Author Topic: HIT eventhandler  (Read 5157 times)

0 Members and 1 Guest are viewing this topic.

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
HIT eventhandler
« on: 11 Jan 2008, 00:31:31 »
ok, I got a problem with my Hummer for the BHD MOD.
I'm trying to add a script that I made for OFP (of course I changed something to suit ArmA new Commands) via HIT eventhandler, but i got some problems: it seems not to work.
I mean, even if I voluntarily make a mistake writing the script path, when I shoot ingame the hummer, no error is given (even no "cannot find script.sqs blabla") so now I assume the HIT eventhandler has changed fro OFP.

here it is the config.cpp HIT eventhandler I added:

Quote
class EventHandlers
  {
     Hit="(_this select 0) exec ""\BHD_script\Wheeled\hit.sqs""";
  };

I don't post the script cause as i said, it currently works if not attached to the eventhandler (tried it ingame)

what is wrong?
I've searched around the WWW, but nothing returned...
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline Loyalguard

  • Former Staff
  • ****
Re: HIT eventhandler
« Reply #1 on: 11 Jan 2008, 00:53:45 »
I am going to look into it deeper, but in the meantime, just out of curiosity...In the Biki it is mentioned that a "hit" event will not always occur if too little damage is caused.  I know this would probably be more common with small arms against an armored vehicle (M16 vs M1A1), but have you tried to hit it with a variety of different damage causing weapons to make sure it doesn't work for any type of hit?

Edit: Then again if it works apart from the addon in a script I guess is most likely not the problem.
« Last Edit: 11 Jan 2008, 00:55:47 by Loyalguard »

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Re: HIT eventhandler
« Reply #2 on: 11 Jan 2008, 01:55:48 »
well, what also tried was to hit with hand-grenades, but nothing happened!
really i don't know what to do, even the DAMAGED eventhandler seems not to work ...:(

Is the sintax in the CPP correct?
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: HIT eventhandler
« Reply #3 on: 11 Jan 2008, 03:02:08 »
You could try:

hit = "(_this select 0) exec  {\BHD_script\Wheeled\hit.sqs}";

instead.


Planck
I know a little about a lot, and a lot about a little.

Offline Loyalguard

  • Former Staff
  • ****
Re: HIT eventhandler
« Reply #4 on: 11 Jan 2008, 12:57:22 »
Good to know Linker...I didn't think it would be the problem but it was one of the first things that came to me.  Pardon me if I may have led you temporarily astray as addon configs are not my specialty!

Planck's suggestion looks like it has potential.  If that doesn't work, from looking at some other example event handler classes in addons (strangely I haven't been able to find any "hit" event handlers though) it seems that often you find _this select 0 bracketed outside the parenthesis or the entire _this array is passed (even if you will only use select 0 in the script):).  So maybe try these as well:


Code: [Select]
hit =  "[(_this select 0)] exec ""\BHD_script\Wheeled\hit.sqs""";
OR

Code: [Select]
hit = "_this exec ""\BHD_script\Wheeled\hit.sqs""";
Now, here is where I really default to someone with more addon knowledge than me and apologize if this question is meritless, but:  Can you have a "hit" event handler in the CfgVehicles class?

I did find it strange that I couldn't find any examples looking through about a dozen vehicle addons (far from exlusive though) and there is no mention of a "hit" event handler in the CfgVehicles Config Reference in the Biki either ( but it does mention "fired", "killed",  and "init").

Good luck!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: HIT eventhandler
« Reply #5 on: 11 Jan 2008, 17:22:20 »
Frankly, though, you should be using the Extended Eventhandlers addon by Solus & Killswitch. I don't know if it can solve your problem (probably not ;)), but for the sake of future generations and whatnot, it really is the way to go.

Otherwise, your eventhandler will overwrite all other possible eventhandlers that other addonmakers might want to apply. But I'm sure you knew that. Anyway, let's not go down the route of uncompatible OFP-addons here, we've got a system now get with it :D

That is all.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Re: HIT eventhandler
« Reply #6 on: 11 Jan 2008, 23:53:23 »
well Wolfrug, since we are making a MOD, I think that either we will ask to use the various eventhandlers people do, or we will create them on our own :)
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Re: HIT eventhandler
« Reply #7 on: 12 Jan 2008, 00:04:27 »
@ Plank

well, the sintax you gave me is correct (it doesn't give any errors) but still no effect (no script inizialized)
So now i post the start of the script:

Code: [Select]
#CHECK
_unit = _this select 0

? (getdammage _unit >= 0.6) : goto "DAMAGED"
~0.1
exit

after this, the particle part of the script starts (and that works) when the getdammage command checks the damage of the vehicle (in this case >= 0.6)
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: HIT eventhandler
« Reply #8 on: 12 Jan 2008, 08:06:54 »
No consecutive posting please, a couple of days should pass before 'replying to yourself'.
If you have something to add to yor post modify it instead.

Quote
since we are making a MOD
Quite, was about to post this myself..
The particular EH addon has it's uses in singular addons, mods are a different thing..

Quote
no error is given
For some reason ArmA doesn't show error messages with incorrect script paths in the config (at least it didn't for me) but they do show up in the ArmA.rpt..

Quote
_unit = _this select 0
So this means you need to have an array passed into your script, which in turn means that the second example by Loyalguard should be used, as in
Code: [Select]
hit = "_this exec ""\BHD_script\Wheeled\hit.sqs""";because that will pass the entire array returned by the handler.

You should also probably use hit instead of Hit because ArmA seems to be more case sensitive than OFP was, at least when it comes to strings..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Re: HIT eventhandler
« Reply #9 on: 12 Jan 2008, 10:04:02 »
sorry for the double post, my fault.

Ok, it's not working... in any way! :dry:

Now in the wheeled.hpp (yeah I'm using headers) I got:

Code: [Select]
class EventHandlers
  {
  hit="[_this select 0] exec  {\BHD_script\Wheeled\hit.sqs}";
  };

I also tried
Code: [Select]
class EventHandlers
  {
  hit="_this exec  {\BHD_script\Wheeled\hit.sqs}";
  };
without any results

and the script is:

Code: [Select]
;hit.sqs

_unit = _this select 0

exit
? (getdammage _unit >= 0.6) : goto "DAMAGED"
~0.1
exit

#DAMAGED

drop ["\Ca\Data\cl_basic.p3d","","Billboard",1,2,"engine",[0,random 3,0],1,1.6,1.8,random 3,[1,random 3,random 4],[[0.0118,0.0118,0.0118,0.70],[0.0118,0.0196,0.0118,0.22],[0.7490,0.7490,0.7490,0.22]],[0,1,0],1,4,"","",_unit]
~0.1
? (getDammage _unit >= 0.83) : goto "REAL_DAMAGED"
?(! alive _unit): exit
goto "DAMAGED"
exit

#REAL_DAMAGED
drop ["\Ca\Data\cl_basic.p3d","","Billboard",1,2,"engine",[0,random 3,0],1,1.6,1.8,random 3,[1,random 3,random 4],[[0.0118,0.0118,0.0118,0.70],[0.0118,0.0196,0.0118,0.22],[0.7490,0.7490,0.7490,0.22]],[0,1,0],1,4,"","",_unit]

drop ["\Ca\Data\cl_basic.p3d","","Billboard",1,2,"engine",[0,random 3,0],1,1.6,1.8,random 3,[1,1,1],[[0.0118,0.0118,0.0118,0.70],[0.0118,0.0196,0.0118,0.6],[0.7490,0.7490,0.7490,0.9]],[0,1,0],1,4,"","",_unit]

~0.1
goto "REAL_DAMAGED"

now, wat the hell is happening????? i'm really getting bored of this... cause in no way it works...
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: HIT eventhandler
« Reply #10 on: 12 Jan 2008, 10:51:28 »
Umm, at first try removing the first exit you have in the script because that terminates the script right after the unit is passed into it..  :scratch:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Re: HIT eventhandler
« Reply #11 on: 12 Jan 2008, 11:02:31 »
well no -h, because as you can see, the script should start the real damage system only when the damage of the hummer reached 60 %:
Code: [Select]
getdammage _unit >= 0.6. if not, the script should exit (if damage is < 60%)

Because I know that the hit eventhandler starts every time you fire the unit (in this case the hummer), I need to stop it in the script unless I don't want the car to start smoking from the engine if it got 10% of damage... The script worked like a charm in OFP, now it doesn't...

i also tried to add these 2 lines:

Code: [Select]
_unit setDamage 1
player setDammage 1
in the script between
_unit = _this select 0 and exit (at the start) just to check if when i shot the hummer, it initializes the script, but nothing happened...
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: HIT eventhandler
« Reply #12 on: 12 Jan 2008, 11:17:04 »
Quote
_unit = _this select 0

exit
? (getdammage _unit >= 0.6) : goto "DAMAGED"
~0.1
exit
This will exit the script, period. It has no change of detecting any damage..

Then, try using lover damage levels, I threw a nade at BIS stock humwee, the hit eventhandler reported damage being 0.29 and after a few secs the car blew up..
Tried editing yout script to use 0.15 instead of 0.6 and after throwing a nade close to the car it started smoking.

Quote
Because I know that the hit eventhandler starts every time you fire the unit
It fires up only when enough damage is caused to the vehicle (I guess this depends on the different armor values in the config), if you add an eventhandler with some hint and shoot the vehicle with say AK the event will not trigger, not even with auto fire..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: HIT eventhandler
« Reply #13 on: 12 Jan 2008, 11:19:36 »
No, but...seriously. I don't know much about addon editing, but that looks pretty cut and dry:

hit="[_this select 0] exec  {\BHD_script\Wheeled\hit.sqs}";

-> is the exact same thing as

hummer addeventhandler ["hit", {[_this select 0] exec "\BHD_script\Wheeled\hit.sqs"}];

Right? So since it's just a normal script getting run whenever the "hit" eventhandler is activated, what you need to do is remove the first exit, like h- says:

Code: [Select]
;hit.sqs

_unit = _this select 0

[b]exit[/b]
? (getdammage _unit >= 0.6) : goto "DAMAGED"
~0.1
exit

Since otherwise the script will simply exit before even reaching the getdammage check! Unless there're some humongous differences in how stuff works with addon eventhandlers.[/s] (H- outwrote me)

As to the arguments about "this is a MOD" and such: if you're planning on a Total Conversion mod which replaces all the default units, possibly default islands, then I understand (to a degree). Also if you're insisting on all your own effects and refuse any third-party ones, then I suppose I also understand (although it's a bit...meh...to do that). However in the interest of user-friendliness, I see no reason why you wouldn't support XEH. XAM 1.4 finally incorporated it in their latest release due to popular pressure! If you don't, there's a good chance you'll get people whining about wanting their sight adjustment/effects/whatever else mods working with your MOD as well (which they won't, if you're going to use other init eventhandlers).

:D Srsly, by using XEH, you'll be saving yourself the effort of going in afterwards and changing everything. But each to his own.

Wolfrug out.

"When 900 years YOU reach, look as good you will not!"

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: HIT eventhandler
« Reply #14 on: 12 Jan 2008, 11:29:58 »
It depends on the mod, and the things people want to achieve with it.

This far I myself have not used basicly any 3rd party scripts merely because a) they never ever fit the needs the mod has and b) you don't learn anything by just injecting other peoples code into your stuff.
Then, if a mod is focusing on say WW2 and the aim is to provide as realistic depiction (or what ever the word to use is) of events possible (and playable) then for example modern tank ballistics and sight adjustment stuff is a moot point..
And if someone would like to use them with that mod, tough luck..  :P

@Linker
Oh, and by "add an eventhandler with some hint" I meant hit eventhandler of course, typed too fast and words were left out  :D
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.