From: bones_was_here Date: Sun, 11 Jun 2023 18:42:21 +0000 (+1000) Subject: items: move particle effects to CSQC for bandwidth and consistency X-Git-Tag: xonotic-v0.8.6~7^2~5 X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=841123173504be131cfe1819fdf850070c15f284;p=xonotic%2Fxonotic-data.pk3dir.git items: move particle effects to CSQC for bandwidth and consistency If some packets get delayed and/or resent, it should no longer be possible see the item appear or disappear without the particles, or vice versa. --- diff --git a/qcsrc/client/items/items.qc b/qcsrc/client/items/items.qc index 2fa911d44..834406c41 100644 --- a/qcsrc/client/items/items.qc +++ b/qcsrc/client/items/items.qc @@ -215,6 +215,9 @@ void ItemDraw(entity this) void ItemRemove(entity this) { + if(this.alpha) + if(!this.wait || time < this.wait - ticrate) // despawning loot items have their own effects + pointparticles(EFFECT_ITEM_PICKUP, (this.absmin + this.absmax) * 0.5, '0 0 0', 1); strfree(this.mdl); } @@ -242,6 +245,7 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew) if(sf & ISF_STATUS) // need to read/write status first so model can handle simple, fb etc. { + int prevItemStatus = this.ItemStatus; this.ItemStatus = ReadByte(); if(this.ItemStatus & ITS_ALLOWFB) @@ -259,6 +263,8 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew) if(this.ItemStatus & ITS_GLOW) this.effects |= (EF_ADDITIVE | EF_FULLBRIGHT); + if(!(prevItemStatus & ITS_AVAILABLE) && this.alpha && !isnew) + pointparticles(EFFECT_ITEM_RESPAWN, (this.absmin + this.absmax) * 0.5, '0 0 0', 1); } else { @@ -270,6 +276,8 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew) if(this.ItemStatus & ITS_GLOW) this.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT); + if(prevItemStatus & ITS_AVAILABLE && this.alpha) + pointparticles(EFFECT_ITEM_PICKUP, (this.absmin + this.absmax) * 0.5, '0 0 0', 1); } } diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index 6633c54f2..ca912d036 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -243,9 +243,6 @@ void Item_Respawn(entity this) setthink(this, Item_Think); this.nextthink = time; - - //Send_Effect(EFFECT_ITEM_RESPAWN, this.origin + this.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1); - Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(this), '0 0 0', 1); } void Item_RespawnCountdown(entity this) @@ -731,7 +728,6 @@ LABEL(pickup) STAT(LAST_PICKUP, toucher) = time; - Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1); GameItem def = this.itemdef; int ch = ((def.instanceOfPowerup && def.m_itemid != IT_RESOURCE) ? CH_TRIGGER_SINGLE : CH_TRIGGER); string snd = (this.item_pickupsound ? this.item_pickupsound : Sound_fixpath(this.item_pickupsound_ent)); @@ -850,7 +846,6 @@ void RemoveItem(entity this) if(wasfreed(this) || !this) { return; } if(this.waypointsprite_attached) WaypointSprite_Kill(this.waypointsprite_attached); - Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1); delete(this); }