Jump to content
Sign in to follow this  
redarmy

Handle damage acting funny

Recommended Posts

Maybe im not remembering correctly,its been a while since testing,but handle damage is not working as i remember.. as i recall its meant to reduce dame taken if used like so..

 

this addEventHandler ["HandleDamage", {(_this select 2)*0.25}];

i have this in init on a tank for example. it seems to handle random damage based on where tank is hit ofourse,but frequently,when say the tank is at 60% health,the next hit actually shows the tank returned to 70 or 80%. Making tank invunreble.

 

im just trying to reduce a tanks recieved damage,im sure i had it working years ago but since wiped drive have no records or tests. any help appreciated.

Share this post


Link to post
Share on other sites
3 hours ago, redarmy said:

have this in init on a tank for example. it seems to handle random damage based on where tank is hit ofourse,but frequently,when say the tank is at 60% health,the next hit actually shows the tank returned to 70 or 80%. Making tank invunreble

 

From HandleDamage wiki:

Quote

If code provided returns a numeric value, this value will overwrite the default damage of given selection after processing. 

 

From the explanation thread linked on the same page:

Quote

_this select 2 (damage): Damage to the above selection (sum of dealt and prior damage)

With your current setup you are setting the damage for the selection to 25% of the resulting damage level, hence the healing effect.

 

AFAIK the event handler executes before the damage is applied, if true you need to subtract the current damage (getHit) from the damage parameter to get the delta (incoming damage).

 

Multiply that by 0.25 to get the reduction and add the current damage back to get the modified resulting damage level.

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
Sign in to follow this  

×