Jump to content
Sign in to follow this  
Tankbuster

HandleDamage, unexpected results. resets damage to zero.

Recommended Posts

I know that handledamage can be used to bestow invulnerability on a unit - I've done it myself by intentionally and accidentally, but this is confusing me a bit.

In my domi edit, there's a mission to destroy a truck and we fought our way in but the truck was invulnerable. Satchels, Titan, 762, harsh language, nothing scratched it. Before I looked into the mission code, I knocked up a little test mission and sure enough, my test mission showed the same problem.

At first I thought it was a model problem, specifically, the OPFOR trucks, but further investigations make me think a malformed handledamage eventhandler is to blame here. Which is odd, because I've used them lots of times before and they've always worked just fine, but now... well...

Basically, this eventhandler is resetting the damage of the vehicle it's on to zero every time you damage it.

_eh = myobject addEventHandler ["HandleDamage", {hint format ["%1\n Damage %2", _this,damage myobject];}];

It hints the fact the vehicle is being damaged by rifle fire and that it's me doing it, but the damage in %2 stays at zero. Moreover, if I damage the vehicle with a debug tool, shooting it resets the vehicles damage to zero.

Am I being stupid here?

---------- Post added at 22:52 ---------- Previous post was at 22:42 ----------

Share this post


Link to post
Share on other sites

You might need to update to the way the handledamage works for arma 3:

If code provided returns a numeric value, this value will overwrite the default damage of given selection after processing. Return value of 0 will make the unit invulnerable if damage is not scripted in other ways (i.e using setDamage and/or setHit for additional damage handling). If no value is returned, the default damage processing will be done. This allows for safe stacking of this event handler. Only the return value of the last added "HandleDamage" EH is considered.

Having pointed at this, that code does not appear to return anything, so it should be working.

Share this post


Link to post
Share on other sites

Having pointed at this, that code does not appear to return anything, so it should be working.

That's what I thought. Biki says;

This code makes Bob invulnerable: _eh = Bob addEventHandler ["HandleDamage", {hint "IMMA INVINCIBLED!"; 0}];

And yes, I get that. I've used it to my advantage. The biki goes on to say;

This code will log damage values without interfering with default damage processing: _eh = Bob addEventHandler ["HandleDamage", {diag_log format ["T=%1 : %2", time, _this];}];

But that's essentially the same as what I'm doing. So I'm confused as to why the damage is being reset to zero by HandleDamage.

---------- Post added at 01:47 ---------- Previous post was at 00:55 ----------

So, I've had a good read of the biki and this does exactly the same as the original code I posted earlier - no damage taken and shooting it resets any damage the thing already has.

_eh = myobject addEventHandler ["HandleDamage", {hint format ["%1\n Damage %2", _this, damage myobject];0}];

Whereas the code below destroys the thing the moment you shoot it with anything.

_eh = myobject addEventHandler ["HandleDamage", {hint format ["%1\n Damage %2", _this, damage myobject];1}];

So, I'm no further forward. :(

Share this post


Link to post
Share on other sites

I might be wrong but I think that this has been fixed on devbranch. It may be worth it to look through the changelogs.

Share this post


Link to post
Share on other sites
I might be wrong but I think that this has been fixed on devbranch. It may be worth it to look through the changelogs.

That sounds about right. *sigh* It was certainly working until the current 'stable' build.

---------- Post added at 10:17 ---------- Previous post was at 10:14 ----------

Ah yes. Here we go! From 6/11/13

If no handleDamage handler returns a value the damage remains unchanged instead of setting it to zero

Thanks 13. Well spotted.

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  

×