From ef5c0adf0c1c43842129f0d36be69bde13366f09 Mon Sep 17 00:00:00 2001 From: BjossiAlfreds Date: Sat, 11 Apr 2020 01:50:57 +0000 Subject: [PATCH] Fix for some items playing wrong sound when instantly used --- src/game/g_items.c | 47 ++++++++++++++++++++++++----------------- src/game/header/local.h | 1 + 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/game/g_items.c b/src/game/g_items.c index e20752b5..1177870a 100644 --- a/src/game/g_items.c +++ b/src/game/g_items.c @@ -215,20 +215,6 @@ Pickup_Powerup(edict_t *ent, edict_t *other) { SetRespawn(ent, ent->item->quantity); } - - if (((int)dmflags->value & DF_INSTANT_ITEMS) || - ((ent->item->use == Use_Quad) && - (ent->spawnflags & DROPPED_PLAYER_ITEM))) - { - if ((ent->item->use == Use_Quad) && - (ent->spawnflags & DROPPED_PLAYER_ITEM)) - { - quad_drop_timeout_hack = - (ent->nextthink - level.time) / FRAMETIME; - } - - ent->item->use(other, ent->item); - } } return true; @@ -1214,6 +1200,29 @@ Touch_Item(edict_t *ent, edict_t *other, cplane_t *plane /* unused */, csurface_ gi.sound(other, CHAN_ITEM, gi.soundindex( ent->item->pickup_sound), 1, ATTN_NORM, 0); } + + /* activate item instantly if appropriate */ + /* moved down here so activation sounds override the pickup sound */ + if (deathmatch->value) + { + if ((((int)dmflags->value & DF_INSTANT_ITEMS) && + (ent->item->flags & IT_INSTANT_USE)) || + ((ent->item->use == Use_Quad) && + (ent->spawnflags & DROPPED_PLAYER_ITEM))) + { + if ((ent->item->use == Use_Quad) && + (ent->spawnflags & DROPPED_PLAYER_ITEM)) + { + quad_drop_timeout_hack = + (ent->nextthink - level.time) / FRAMETIME; + } + + if (ent->item->use) + { + ent->item->use(other, ent->item); + } + } + } } if (!(ent->spawnflags & ITEM_TARGETS_USED)) @@ -2160,7 +2169,7 @@ static const gitem_t gameitemlist[] = { 2, 60, NULL, - IT_POWERUP, + IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2182,7 +2191,7 @@ static const gitem_t gameitemlist[] = { 2, 300, NULL, - IT_POWERUP, + IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2204,7 +2213,7 @@ static const gitem_t gameitemlist[] = { 2, 60, NULL, - IT_POWERUP, + IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2226,7 +2235,7 @@ static const gitem_t gameitemlist[] = { 2, 60, NULL, - IT_STAY_COOP | IT_POWERUP, + IT_STAY_COOP | IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2248,7 +2257,7 @@ static const gitem_t gameitemlist[] = { 2, 60, NULL, - IT_STAY_COOP | IT_POWERUP, + IT_STAY_COOP | IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, diff --git a/src/game/header/local.h b/src/game/header/local.h index d894ef17..59e4f78c 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -215,6 +215,7 @@ typedef struct #define IT_STAY_COOP 8 #define IT_KEY 16 #define IT_POWERUP 32 +#define IT_INSTANT_USE 64 /* item is insta-used on pickup if dmflag is set */ /* gitem_t->weapmodel for weapons indicates model index */ #define WEAP_BLASTER 1