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;
}
LOG_INFOF("WARNING: sprite of name %s has no color, using pink so you notice it", spriteimage);
}
- if (time - floor(time) > 0.5)
+ float health_val = GetResourceAmount(this, RESOURCE_HEALTH);
+ float blink_time = (health_val >= 0) ? (health_val * 10) : time;
+ if (blink_time - floor(blink_time) > 0.5)
{
if (this.helpme && time < this.helpme)
a *= SPRITE_HELPME_BLINK;
- else if (this.lifetime > 0) // fading out waypoints don't blink
+ else if (!this.lifetime) // fading out waypoints don't blink
a *= spritelookupblinkvalue(this, spriteimage);
}
ang += M_PI;
float f1 = d.x / vid_conwidth;
- float f2 = d.y / vid_conheight;
+ float f2 = d.y / vid_conheight;
if (f1 == 0) { f1 = 0.000001; }
if (f2 == 0) { f2 = 0.000001; }
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 WaypointSprite_DeployFixed(
entity spr,
- float limited_range,
+ bool limited_range,
entity player,
vector ofs,
entity icon // initial icon
entity WaypointSprite_Attach(
entity spr,
entity player,
- float limited_range,
+ bool limited_range,
entity icon // initial icon
)
{
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;
}