if (WaypointSprite_isteammate(this.owner, WaypointSprite_getviewentity(to)))
{
- float dt = (this.waypointsprite_helpmetime - time) / 0.1;
- if (dt < 0)
- dt = 0;
- if (dt > 255)
- dt = 255;
+ float dt = bound(0, (this.waypointsprite_helpmetime - time) / 0.1, 255);
WriteByte(MSG_ENTITY, dt);
}
else
int t = ReadByte();
if (t < 192)
{
- SetResourceAmountExplicit(this, RESOURCE_HEALTH, t / 191.0);
+ SetResourceAmount(this, RESOURCE_HEALTH, t / 191.0);
this.build_finished = 0;
}
else
}
else
{
- SetResourceAmountExplicit(this, RESOURCE_HEALTH, -1);
+ SetResourceAmount(this, RESOURCE_HEALTH, -1);
this.build_finished = 0;
}
if (time < this.build_finished + 0.25)
{
if (time < this.build_started)
- SetResourceAmountExplicit(this, RESOURCE_HEALTH, this.build_starthealth);
+ SetResourceAmount(this, RESOURCE_HEALTH, this.build_starthealth);
else if (time < this.build_finished)
- SetResourceAmountExplicit(this, RESOURCE_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth);
+ SetResourceAmount(this, RESOURCE_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth);
else
- SetResourceAmountExplicit(this, RESOURCE_HEALTH, 1);
+ SetResourceAmount(this, RESOURCE_HEALTH, 1);
}
else
- SetResourceAmountExplicit(this, RESOURCE_HEALTH, -1);
+ SetResourceAmount(this, RESOURCE_HEALTH, -1);
}
o = drawspritearrow(o, ang, rgb, a, SPRITE_ARROW_SCALE * t);
void WaypointSprite_UpdateHealth(entity e, float f)
{
f = bound(0, f, e.max_health);
- if (f != GetResourceAmount(e, RESOURCE_HEALTH) || e.pain_finished)
+ float step = e.max_health / 40;
+ if ((floor(f / step) != floor(GetResourceAmount(e, RESOURCE_HEALTH) / step)) || e.pain_finished)
{
- SetResourceAmountExplicit(e, RESOURCE_HEALTH, f);
+ SetResourceAmount(e, RESOURCE_HEALTH, f);
e.pain_finished = 0;
e.SendFlags |= 0x80;
}
entity e = WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', NULL, carrier.team, carrier, waypointsprite_attachedforcarrier, false, icon);
if (GetResourceAmount(carrier, RESOURCE_HEALTH))
{
- WaypointSprite_UpdateMaxHealth(e, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id) * 2);
- WaypointSprite_UpdateHealth(e, '1 0 0' * healtharmor_maxdamage(GetResourceAmount(carrier, RESOURCE_HEALTH), GetResourceAmount(carrier, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id));
+ WaypointSprite_UpdateMaxHealth(e, 2 * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
+ WaypointSprite_UpdateHealth(e, healtharmor_maxdamage(GetResourceAmount(carrier, RESOURCE_HEALTH), GetResourceAmount(carrier, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
}
return e;
}