Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: planetfall on April 20, 2014, 12:17:42 AM

Title: Damage and CONST_DESTROYONDAMAGE
Post by: planetfall on April 20, 2014, 12:17:42 AM
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.
Title: Re: Damage and CONST_DESTROYONDAMAGE
Post by: knucracker on April 20, 2014, 10:41:51 AM
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?
Title: Re: Damage and CONST_DESTROYONDAMAGE
Post by: planetfall on April 20, 2014, 11:11:54 AM
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.
Title: Re: Damage and CONST_DESTROYONDAMAGE
Post by: knucracker on April 20, 2014, 11:18:11 AM
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.
Title: Re: Damage and CONST_DESTROYONDAMAGE
Post by: planetfall on April 20, 2014, 12:32:46 PM
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.