Jump to content
doc. caliban

Detecting a hit on an object that has damage disabled

Recommended Posts

I'm using a script to manage the damage and effects of a missile hit on an aircraft.  Because of that, I have allowdamage false on the aircraft.

 

I tried using "MPhit" but it doesn't seem to work. (I could be doing the EH incorrectly)   I would like to have a hit kick off an .sqf script.

 

As always, any help is appreciated.

 

-Doc

Share this post


Link to post
Share on other sites

Hi Doc

You can use the event handler "handleDamage" and forget the allowDamage false, as far as you can override the final result with a "damage" value.

Read the explanations here and here.

By the way, I'm no more on Armaholic.

Share this post


Link to post
Share on other sites

Thanks!  

 

I too have decided to start posting here instead.  I understand the changes at Armaholic, but I can't justify the cost. 

Share this post


Link to post
Share on other sites
10 hours ago, pierremgi said:

Hi Doc

You can use the event handler "handleDamage" and forget the allowDamage false, as far as you can override the final result with a "damage" value.

Read the explanations here and here.

By the way, I'm no more on Armaholic.

I thought the whole point of HandleDamage was that when the unit is damaged, the handler is supposed to fire?

versus just being "hit" 

Share this post


Link to post
Share on other sites

Right, and that works for me.  It seemed like everything else needed to detect damage being done in order to fire, so my having the aircraft damage disabled prevented them from firing.  At least that was the experience I had with "hit".  (though I could have been using it incorrectly.)  This works for me though.

 

Using HandleDamage allows me to leave damage enabled, but manage how much damage the aircraft actually takes once the EH fires.  The EH returns, among other things, how much damage was done, so I can take that a cap it at whatever I want:

this addEventHandler ["HandleDamage", {  
	_dam = _this select 2;  
	if (_dam > 0.85) then {_dam = 0.85}; 
}];

a bonus of this EH is that any damage less than the threshold that I set is left alone, so the vehicle damage indicators may be yellow, red, or undamaged.  What I had been doing was setting the entire vehicle damage to 0.85 which made the experience less dynamic and entirely predictable.   Now if I get hit, anything up to the threshold can happen for any system, so every hit can result in different things.

 

In my version of that I also kick off a script that creates other affects related to the event.

 

Thank you again, Pierre!

 

-Doc

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×