void powerups_DropItem_Think(entity this)
{
- TakeResource(this, RES_HEALTH, 1);
-
- if(GetResource(this, RES_HEALTH) < 1) {
- RemoveItem(this);
- return;
- }
-
// Only needed to update if the timer of the powerup is running
if(!GetResource(this, RES_ARMOR))
- WaypointSprite_UpdateHealth(this.waypointsprite_attached, GetResource(this, RES_HEALTH));
-
- this.nextthink = time + 1;
+ {
+ float timeleft = floor(this.wait - time);
+ if (timeleft)
+ WaypointSprite_UpdateHealth(this.waypointsprite_attached, timeleft);
+ else
+ WaypointSprite_Kill(this.waypointsprite_attached);
+ }
}
void powerups_DropItem(entity this, StatusEffects effect, bool freezeTimer)
if(!freezeTimer)
Item_SetExpiring(e, true);
- // Use health as time left to live
- SetResourceExplicit(e, RES_HEALTH, time_to_live);
-
// Use armor as timer freezer
if(freezeTimer)
SetResourceExplicit(e, RES_ARMOR, 1);
wp.wp_extra = item.m_id;
WaypointSprite_UpdateMaxHealth(e.waypointsprite_attached, maxtime);
WaypointSprite_UpdateHealth(e.waypointsprite_attached, timeleft);
-
- // Start dropping its time to live
- setthink(e, powerups_DropItem_Think);
- e.nextthink = time + 1;
+ // Item_Think() will call powerups_DropItem_Think() to update the waypoint
}
MUTATOR_HOOKFUNCTION(powerups, ItemTouched)