From 5484290078c5295490f0c9b19e6d631fed24044a Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Mon, 12 Jun 2023 02:59:52 +1000 Subject: [PATCH] items: add loot despawn effects Closes #1046 --- effectinfo.txt | 16 ++++++++++++++++ qcsrc/client/items/items.qc | 25 +++++++++++++++++++++++++ qcsrc/common/effects/all.inc | 1 + qcsrc/common/effects/effectinfo.inc | 25 +++++++++++++++++++++++++ 4 files changed, 67 insertions(+) diff --git a/effectinfo.txt b/effectinfo.txt index 7fc732b7d..81b71a579 100644 --- a/effectinfo.txt +++ b/effectinfo.txt @@ -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 diff --git a/qcsrc/client/items/items.qc b/qcsrc/client/items/items.qc index b7c1b8de0..1eae223d8 100644 --- a/qcsrc/client/items/items.qc +++ b/qcsrc/client/items/items.qc @@ -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; } diff --git a/qcsrc/common/effects/all.inc b/qcsrc/common/effects/all.inc index 179d96224..d7654f06a 100644 --- a/qcsrc/common/effects/all.inc +++ b/qcsrc/common/effects/all.inc @@ -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") diff --git a/qcsrc/common/effects/effectinfo.inc b/qcsrc/common/effects/effectinfo.inc index 090d2b111..e6909e4cd 100644 --- a/qcsrc/common/effects/effectinfo.inc +++ b/qcsrc/common/effects/effectinfo.inc @@ -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! -- 2.39.2