From: bones_was_here Date: Wed, 14 Jun 2023 13:53:57 +0000 (+1000) Subject: powerups: use Item_Think() for dropped powerups X-Git-Tag: xonotic-v0.8.6~7^2~2 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=a6423f485060d59253426c339add259c876ae6f6;p=xonotic%2Fxonotic-data.pk3dir.git powerups: use Item_Think() for dropped powerups Fixes lack of updates sent to CSQC ItemDraw() for position, velocity, etc. --- diff --git a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc index d655ae19a..7b15d34a0 100644 --- a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc +++ b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc @@ -79,18 +79,15 @@ MUTATOR_HOOKFUNCTION(powerups, MonsterValidTarget) 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) @@ -130,9 +127,6 @@ 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); @@ -142,10 +136,7 @@ void powerups_DropItem(entity this, StatusEffects effect, bool freezeTimer) 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) diff --git a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qh b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qh index 06098c95e..005cbcba4 100644 --- a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qh +++ b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qh @@ -14,5 +14,7 @@ REGISTER_MUTATOR(powerups, true); .float prevstrengthsound; .float prevstrengthsoundattempt; +void powerups_DropItem_Think(entity this); + // q3compat .float count; diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index 0f764c862..7c3fd969b 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -202,6 +202,9 @@ void Item_Think(entity this) } } + if (this.itemdef.instanceOfPowerup) + powerups_DropItem_Think(this); + // enable pickup by the player who threw it this.owner = NULL;