Home   Help Search Login Register  

Author Topic: HIT eventhandler  (Read 5122 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.

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Re: HIT eventhandler
« Reply #15 on: 12 Jan 2008, 11:33:28 »
ahhh Ok I'll try it...
any chance of getting smoke when you shot at the hummer with an AK for example? cause in mogadishu all the somalis got one...
Oh, in the script I posted, I left the exit after the first line _unit = _this select 0, sorry, I mistyped it.
btw your way works cause you didn't put the exit after the getDammage condition (IMO)

See: every time a grenade hit the hummer, it should start the script, and the condition that if the damage of the unit is >= to 0.6 then it doesn't continue, but skip to the #DAMAGED label, but if the damage is < 0.6, then it should exit cause at 0.1 there's no need to have smoke coming from the engine. That's what I want to obtain... :)

Thanks for your help -h btw...

@wolfrug

well, I don't know if you know anything about our MOD, but we are trying to achieve best results in all the addon making fields (modelling, scripting, island making and so on) of course we should need also other 3d-party scripts, that's right :)
But we are also making our own... and when we will decide what to do, we will ask permission to add them :)
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 #16 on: 12 Jan 2008, 11:51:56 »
Quote
any chance of getting smoke when you shot at the hummer with an AK for example?
That's probably a bit hard to do because apparently even the .50 cal sniper rifle doesn't trigger the hit event  :blink:
So I guess it's down to the shotBullet (or whatever it was) simulation and that's hardcoded..
But this is all BIS stock humwee, I have no idea how your humwee armor values are set. It's possible though that the armor values don't even matter..

You could use a looping script (launched by the vehicle init) to monitor the vehicle damage and add smoke when damage reaches certain level.. :dunno:

Quote
btw your way works cause you didn't put the exit after the getDammage condition (IMO)
Didn't do anything about that, just removed the premature exit I was talking about and changed the first damage check to 0.15..

I fully realise what you're trying to obtain, I've been tinkering with a hit event based thing myself recently..
The problem lays in the way BIS have made the damage handling because getDammage/getDamage/damage returns only the overall damage of the vehicle, and not the partial damage which may cause the vehicle to explode :( ..
Which is why a vehicle with low overall damage may explode because the engine has full damage, or something like that..
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 #17 on: 12 Jan 2008, 11:57:50 »
Ok thanks h- I'll let you know... :)
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 #18 on: 12 Jan 2008, 12:10:36 »
Just went and tested the loop stuff by modifying your script a bit and yes, that way it is possible to make the vehicle smoke after receiving certain amount of smalls arms fire.

Be carefull with the damage amounts though, 0.6 is maybe too much because I emptied all the mags a BIS default OPFOR carries and it didn't produce smoking.. A mag or two with the 'Barret' did the trick though.
Also I think the AI is very keen on exiting damaged vehicles so the 0.6 might too much for them too.. :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 #19 on: 12 Jan 2008, 12:26:03 »
yes, not it works as you said  h-.
 I add 0.4 of damage to start the script.. :)
thanks all!

Anyway, I'll continue searching some solutions to the hit eventhandler... :)

Cya all guys!
Oh and download our BETA when it will be out (in a few weeks)  :whistle: :good:

ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline Sparky

  • Former Staff
  • ****
    • Hellenic Warfare Mod
Re: HIT eventhandler
« Reply #20 on: 27 Jan 2008, 17:10:20 »
ok, here is some tip of how you can do your effec depending where you got dammage.
We created this script for HWM_huey, for the indicators on the cockpit.
Hope that helps you to take an idea.

; **************************************************************
; **HWM script for damage indigators for Huey **      v1 1 Dec 2007
; **this is for HWM-HAC  USE**
; **DO NOT modify or use with out asking us, we like to know **
; **contact us at hac@unreal.gr **
; **************************************************************

_uh1h = _this select 0
;;##debug##
_section = _this select 1
_dmg = _this select 2


if (_section == "mala vrtule") then {goto "indic01"};
if (_section == "velka vrtule") then {goto "indic02"};
if (_section == "engine") then {goto "indic03"};
if (_section == "flaps") then {goto "indic04"};
if (_section == "electronics") then {goto "indic05"};
if (_section == "body") then {goto "indic06"};
if (_section == "deposit") then {goto "indic07"};
exit;

#indic01
code.....
exit;

#indic02
code.....
exit;

#indic03
code.....
exit;

#indic04
code.....
exit;

#indic05
code......
exit;

#indic06
code.......
exit;

#indic07
code.......
exit;


you can call it like this

dammaged = "_this exec ""\HWM_Core\scripts\dammage.sqs"";";

now what you should have...
in order to work correct each component should be defined with class hit inside the vehicles config.
class HitHull {
         armor = 1;
         material = 51;
         name = "body";
         visual = "body";
         passThrough = 1;
      };
      class HitEngine {
         armor = 0.5;
         material = 51;
         name = "engine";
         visual = "engine";
         passThrough = 1;
      };
      class HitAvionics {
         armor = 0.25;
         material = 51;
         name = "electronics";
         visual = "electronics";
         passThrough = 0;
      };
      class HitVRotor {
         armor = 0.3;
         material = 52;
         name = "mala vrtule";
         visual = "mala vrtule";
         passThrough = 0;
      };
      class HitHRotor {
         armor = 0.2;
         material = 52;
         name = "velka vrtule";
         visual = "velka vrtule";
         passThrough = 0;
      };
      class HitFuel {
         armor = 1.4;
         material = 51;
         name = "deposit";
         visual = "deposit";
         passThrough = 1;
      };
      class HitMissiles {
         armor = 0.4;
         material = 59;
         name = "flaps";
         visual = "flaps";
         passThrough = 0;
      };


also the appropriate selection should be made in the p3d.

NOTICE.
i've notice that damaged event handler is triggered for values above 0.5.
also you can use _dmg = _this select 2 line in the script, to check the value of damage that triggers the event handler.
example add to each code block, the line
hint format["section = %1 damage = %2",_section,_dmg];

anyway i know it sounds complicated but it's not, basicaly this way you can identify the section that is dammaged and do what you like.
for example the engine of the nummer.
PLUS BIS has already give the Hummer in MLOD together with the model.cfg file, so you can see the selection names in the config and adopt them in your script.