Damage and CONST_DESTROYONDAMAGE

Started by planetfall, April 20, 2014, 12:17:42 AM

Previous topic - Next topic

planetfall

It seems that even if a crpl core has CONST_DESTROYONDAMAGE set to false, it can still be destroyed by the Damage crpl function (though not CONST_HEALTH + SetUnitAttribute) -- my previous understanding was that such a core could only be destroyed by the Destroy function.

What is the intended behavior for this?

Obviously this isn't really breaking anything since I can just replace the offending instances of Damage with SetUnitAttribute. At this point I'm just curious.
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.

knucracker

Are you sure?  Maybe you are tying a different case than the following:


once
SetUnitAttribute(Self CONST_DESTROYONDAMAGE FALSE)
endonce

Damage(Self 0.01)
SetText(GetUnitAttribute(Self CONST_HEALTH))


This will decrease the health of the core down to 0 but the core doesn't die when it hits 0.  Are you trying it a different way, or maybe a across a save/load or something like that?

planetfall

No, it was being called from a different core than the one being damaged. Though thank you for reminding me to make it persist across saves :)

It's fixed now, anyway.
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.

knucracker

I'm not following why it's fixed :)  Are you saying that you have to call SetUnitAttribute(<-unit CONST_DESTROYONDAMAGE FALSE) after a load on a unit?

For a given core, this setting should be persisted for you so that you only have to set it once.

planetfall

Well, it was only a guess. I remember there being a bug that involved trying to make runners not destroy on damage, and that saving and reloading would fix said bug. In any case, it can't hurt anything if I do.

By "it's fixed now" I mean I replaced <-unit 1 Damage with <-unit CONST_HEALTH <-unit CONST_HEALTH GetUnitAttribute 1 sub SetUnitAttribute and it seems to work as intended now.
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.