Merge pull request #52 from BjossiAlfreds/insta-powerups

Fix for some items playing wrong sound when instantly activated
This commit is contained in:
Yamagi 2020-04-20 08:49:20 +02:00 committed by GitHub
commit 3a073766c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 33 deletions

View File

@ -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,36 @@ 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->item->use == Use_QuadFire)) &&
(ent->spawnflags & DROPPED_PLAYER_ITEM)))
{
if (ent->spawnflags & DROPPED_PLAYER_ITEM)
{
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)
{
ent->item->use(other, ent->item);
}
}
}
}
if (!(ent->spawnflags & ITEM_TARGETS_USED))
@ -2393,7 +2396,7 @@ gitem_t itemlist[] = {
2,
60,
NULL,
IT_POWERUP,
IT_POWERUP | IT_INSTANT_USE,
0,
NULL,
0,
@ -2418,7 +2421,7 @@ gitem_t itemlist[] = {
2,
60,
NULL,
IT_POWERUP,
IT_POWERUP | IT_INSTANT_USE,
0,
NULL,
0,
@ -2442,7 +2445,7 @@ gitem_t itemlist[] = {
2,
300,
NULL,
IT_POWERUP,
IT_POWERUP | IT_INSTANT_USE,
0,
NULL,
0,
@ -2466,7 +2469,7 @@ gitem_t itemlist[] = {
2,
60,
NULL,
IT_POWERUP,
IT_POWERUP | IT_INSTANT_USE,
0,
NULL,
0,
@ -2490,7 +2493,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 +2517,7 @@ gitem_t itemlist[] = {
2,
60,
NULL,
IT_STAY_COOP | IT_POWERUP,
IT_STAY_COOP | IT_POWERUP | IT_INSTANT_USE,
0,
NULL,
0,

View File

@ -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