From 527f3d9845d6a0c3cd0761d256a47057c5088302 Mon Sep 17 00:00:00 2001 From: BjossiAlfreds Date: Sat, 11 Apr 2020 01:17:55 +0000 Subject: [PATCH 1/2] Fix for some items playing wrong sound when instantly activated --- src/g_items.c | 79 +++++++++++++++++++++++++++------------------- src/header/local.h | 1 + 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/src/g_items.c b/src/g_items.c index f922026..7b677e6 100644 --- a/src/g_items.c +++ b/src/g_items.c @@ -205,33 +205,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); - } - else if (((int)dmflags->value & DF_INSTANT_ITEMS) || - ((ent->item->use == Use_QuadFire) && - (ent->spawnflags & DROPPED_PLAYER_ITEM))) - { - if ((ent->item->use == Use_QuadFire) && - (ent->spawnflags & DROPPED_PLAYER_ITEM)) - { - quad_fire_drop_timeout_hack = - (ent->nextthink - level.time) / FRAMETIME; - } - - ent->item->use(other, ent->item); - } } return true; @@ -1292,6 +1265,46 @@ Touch_Item(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf) 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); + } + } + else if ((((int)dmflags->value & DF_INSTANT_ITEMS) && + (ent->item->flags & IT_INSTANT_USE)) || + ((ent->item->use == Use_QuadFire) && + (ent->spawnflags & DROPPED_PLAYER_ITEM))) + { + if ((ent->item->use == Use_QuadFire) && + (ent->spawnflags & DROPPED_PLAYER_ITEM)) + { + quad_fire_drop_timeout_hack = + (ent->nextthink - level.time) / FRAMETIME; + } + + if (ent->item->use) + { + ent->item->use(other, ent->item); + } + } + } } if (!(ent->spawnflags & ITEM_TARGETS_USED)) @@ -2393,7 +2406,7 @@ gitem_t itemlist[] = { 2, 60, NULL, - IT_POWERUP, + IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2418,7 +2431,7 @@ gitem_t itemlist[] = { 2, 60, NULL, - IT_POWERUP, + IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2442,7 +2455,7 @@ gitem_t itemlist[] = { 2, 300, NULL, - IT_POWERUP, + IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2466,7 +2479,7 @@ gitem_t itemlist[] = { 2, 60, NULL, - IT_POWERUP, + IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2490,7 +2503,7 @@ gitem_t itemlist[] = { 2, 60, NULL, - IT_STAY_COOP | IT_POWERUP, + IT_STAY_COOP | IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, @@ -2514,7 +2527,7 @@ gitem_t itemlist[] = { 2, 60, NULL, - IT_STAY_COOP | IT_POWERUP, + IT_STAY_COOP | IT_POWERUP | IT_INSTANT_USE, 0, NULL, 0, diff --git a/src/header/local.h b/src/header/local.h index 6fa73b4..fb7955a 100644 --- a/src/header/local.h +++ b/src/header/local.h @@ -202,6 +202,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 From dc38e968ff475c9d6d78691da793dfe68435d540 Mon Sep 17 00:00:00 2001 From: BjossiAlfreds Date: Sat, 11 Apr 2020 02:48:42 +0000 Subject: [PATCH 2/2] Fix original xatrix bug that made DF_QUADFIRE_DROP not work correctly --- src/g_items.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/g_items.c b/src/g_items.c index 7b677e6..4561147 100644 --- a/src/g_items.c +++ b/src/g_items.c @@ -1272,31 +1272,21 @@ Touch_Item(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf) { if ((((int)dmflags->value & DF_INSTANT_ITEMS) && (ent->item->flags & IT_INSTANT_USE)) || - ((ent->item->use == Use_Quad) && + (((ent->item->use == Use_Quad) || (ent->item->use == Use_QuadFire)) && (ent->spawnflags & DROPPED_PLAYER_ITEM))) { - if ((ent->item->use == Use_Quad) && - (ent->spawnflags & DROPPED_PLAYER_ITEM)) + if (ent->spawnflags & DROPPED_PLAYER_ITEM) { - quad_drop_timeout_hack = - (ent->nextthink - level.time) / FRAMETIME; - } - - if (ent->item->use) - { - ent->item->use(other, ent->item); - } - } - else if ((((int)dmflags->value & DF_INSTANT_ITEMS) && - (ent->item->flags & IT_INSTANT_USE)) || - ((ent->item->use == Use_QuadFire) && - (ent->spawnflags & DROPPED_PLAYER_ITEM))) - { - if ((ent->item->use == Use_QuadFire) && - (ent->spawnflags & DROPPED_PLAYER_ITEM)) - { - quad_fire_drop_timeout_hack = - (ent->nextthink - level.time) / FRAMETIME; + if (ent->item->use == Use_Quad) + { + quad_drop_timeout_hack = + (ent->nextthink - level.time) / FRAMETIME; + } + else if (ent->item->use == Use_QuadFire) + { + quad_fire_drop_timeout_hack = + (ent->nextthink - level.time) / FRAMETIME; + } } if (ent->item->use)