float h;
if (!(this.spawnflags & BREAKABLE_INDICATE_DAMAGE))
return;
- h = this.health / this.max_health;
+ h = GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health;
if(h < 0.25)
this.colormod = '1 0 0';
else if(h <= 0.75)
void func_breakable_behave_destroyed(entity this)
{
- this.health = this.max_health;
+ SetResourceAmountExplicit(this, RESOURCE_HEALTH, this.max_health);
this.takedamage = DAMAGE_NO;
if(this.bot_attack)
IL_REMOVE(g_bot_targets, this);
void func_breakable_destroy(entity this, entity actor, entity trigger);
void func_breakable_behave_restore(entity this)
{
- this.health = this.max_health;
+ SetResourceAmountExplicit(this, RESOURCE_HEALTH, this.max_health);
if(this.sprite)
{
WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
- WaypointSprite_UpdateHealth(this.sprite, this.health);
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
}
if(!(this.spawnflags & BREAKABLE_NODAMAGE))
{
if(attacker.team == this.team)
return;
this.pain_finished = time;
- this.health = this.health - damage;
+ SetResourceAmountExplicit(this, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH) - damage);
if(this.sprite)
{
WaypointSprite_Ping(this.sprite);
- WaypointSprite_UpdateHealth(this.sprite, this.health);
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
}
func_breakable_colormod(this);
- if(this.health <= 0)
+ if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
{
debrisforce = force;
spawnfunc(func_breakable)
{
float n, i;
- if(!this.health)
- this.health = 100;
- this.max_health = this.health;
+ if(!GetResourceAmount(this, RESOURCE_HEALTH))
+ SetResourceAmountExplicit(this, RESOURCE_HEALTH, 100);
+ this.max_health = GetResourceAmount(this, RESOURCE_HEALTH);
// yes, I know, MOVETYPE_NONE is not available here, not that one would want it here anyway
if(!this.debrismovetype) this.debrismovetype = MOVETYPE_BOUNCE;