]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
items: add loot despawn effects
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 11 Jun 2023 16:59:52 +0000 (02:59 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 15 Jun 2023 20:36:24 +0000 (06:36 +1000)
Closes #1046

effectinfo.txt
qcsrc/client/items/items.qc
qcsrc/common/effects/all.inc
qcsrc/common/effects/effectinfo.inc

index 7fc732b7da5037d59c87a0762f85c71f6be3a813..81b71a57900173ad2ba3bb0878d480f206c22111 100644 (file)
@@ -8390,3 +8390,19 @@ effect respawn_ghost
        originoffset 0 0 -8
        originjitter 28 28 16
        velocityjitter 0 0 256
+effect item_despawn
+       type snow
+//     type smoke
+       blend add
+       alpha 192 256 256
+       color 0xff9600 0xffefb8
+       count 32
+       originjitter 8 8 8
+       sizeincrease 1
+       size 0.5 1
+       tex 48 55
+       velocityjitter 16 16 32
+       lightradius 48
+       lightradiusfade 64
+       lightcolor 1 0.75 0.36
+       lightshadow 1
index b7c1b8de08efd206771b6d6211e04455f7f0fdc6..1eae223d806c93a9a56904ae4de704aa4b1d3956 100644 (file)
@@ -14,6 +14,7 @@
 .bool pushable;
 .float anim_start_time; // reusing for bob waveform synchronisation
 .vector angles_held; // reusing for (re)storing original angles
+.float wait, delay, pointtime; // reusing for despawn effects
 
 void ItemDraw(entity this)
 {
@@ -124,6 +125,30 @@ void ItemDraw(entity this)
                this.colormod = this.glowmod = autocvar_cl_ghost_items_color;
        }
 
+       if(!this.alpha)
+               return;
+
+       // loot item despawn effects
+       if(this.ItemStatus & ITS_EXPIRING)
+       {
+               if(!this.wait) // when receiving the first message with ITS_EXPIRING set
+               {
+                       this.wait = time + IT_DESPAWNFX_TIME; // it will despawn then
+                       this.delay = 0.25;
+               }
+
+               if(autocvar_cl_items_animate & 2)
+                       this.alpha *= (this.wait - time) / IT_DESPAWNFX_TIME;
+
+               if(autocvar_cl_items_animate & 4 && time >= this.pointtime)
+               {
+                       pointparticles(EFFECT_ITEM_DESPAWN, this.origin + '0 0 16', '0 0 0', 1);
+                       if (this.delay > 0.0625)
+                               this.delay *= 0.5;
+                       this.pointtime = time + this.delay;
+               }
+       }
+
        this.drawmask = this.alpha <= 0 ? 0 : MASK_NORMAL;
 }
 
index 179d96224ed5109a764cef8570e8217fab7a4f24..d7654f06ad6370ba864b9568fafca49552e450f9 100644 (file)
@@ -231,6 +231,7 @@ entity EFFECT_CAP(int teamid)
 
 EFFECT(0, ITEM_PICKUP,              "item_pickup")
 EFFECT(0, ITEM_RESPAWN,             "item_respawn")
+EFFECT(0, ITEM_DESPAWN,             "item_despawn")
 
 EFFECT(0, ONS_GENERATOR_DAMAGED,    "torch_small")
 EFFECT(0, ONS_GENERATOR_GIB,        "onslaught_generator_gib_explode")
index 090d2b111902b66247a52978b1c404598a5b4c1a..e6909e4cdbcd60a1860f8124578b3c0d416a854e 100644 (file)
@@ -9107,4 +9107,29 @@ SUB(respawn_ghost) {
        MY(velocityjitter) = '0 0 256';
 }
 
+// originally based on goldendust
+DEF(item_despawn);
+SUB(item_despawn) {
+       MY(type) = "snow";
+//     MY(type) = "smoke";
+       MY(blend) = "add";
+       MY(alpha_min) = 192;
+       MY(alpha_max) = 256;
+       MY(alpha_fade) = 256;
+       MY(color_min) = "0xff9600";
+       MY(color_max) = "0xffefb8";
+       MY(count) = 32;
+       MY(originjitter) = '8 8 8';
+       MY(sizeincrease) = 1;
+       MY(size_min) = 0.5;
+       MY(size_max) = 1;
+       MY(tex_min) = 48;
+       MY(tex_max) = 55;
+       MY(velocityjitter) = '16 16 32';
+       MY(lightradius) = 48;
+       MY(lightradiusfade) 64;
+       MY(lightcolor) '1 0.75 0.36';
+       MY(lightshadow) 1;
+}
+
 // always add new effects to the bottom of the list. And keep this comment in the bottom line of this file!