]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
items: move particle effects to CSQC for bandwidth and consistency
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 11 Jun 2023 18:42:21 +0000 (04:42 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 15 Jun 2023 20:36:25 +0000 (06:36 +1000)
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.

qcsrc/client/items/items.qc
qcsrc/server/items/items.qc

index 2fa911d444ba9319b1e5f5a6bb726759f7310e07..834406c41871b6b6bf313ea6b640f1ebe8aa98f6 100644 (file)
@@ -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);
                }
        }
 
index 6633c54f286f1c48cb0e2b32eee8789dbab5e2f5..ca912d036b9c52cad3c75a93f102fe00b4e9ed72 100644 (file)
@@ -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);
 }