From 927d014cea66682c3804ee3a1587687491919778 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 29 Dec 2022 16:38:15 +0100 Subject: [PATCH] - final cleanup on hitradius. Several dead code paths were also removed that are unable to be triggered by any event in the game - due to the spaghetti-style checks this hadn't been obvious before. Also one more flag that handles the WT flamethrower's special case of not hurting any actors of the shooter's kind in a more generalized form --- source/core/thingdef_data.cpp | 1 + source/games/duke/src/actors_d.cpp | 16 ++++++---------- source/games/duke/src/actors_r.cpp | 3 +-- source/games/duke/src/classnames.h | 1 + source/games/duke/src/constants.h | 1 + .../games/duke/actors/flamethrowerflame.zs | 1 + 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/source/core/thingdef_data.cpp b/source/core/thingdef_data.cpp index 3404b5513..6e752e6fb 100644 --- a/source/core/thingdef_data.cpp +++ b/source/core/thingdef_data.cpp @@ -182,6 +182,7 @@ static FFlagDef DukeActorFlagDefs[] = DEFINE_FLAG(SFLAG3, HITRADIUS_DONTHURTSHOOTER, DDukeActor, flags3), DEFINE_FLAG(SFLAG3, HITRADIUS_NODAMAGE, DDukeActor, flags3), DEFINE_FLAG(SFLAG3, HITRADIUS_NOEFFECT, DDukeActor, flags3), + DEFINE_FLAG(SFLAG3, HITRADIUS_DONTHURTSPECIES, DDukeActor, flags3), }; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 5b621618c..135b8ad58 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -165,14 +165,14 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h DukeStatIterator itj(statlist[x]); while (auto act2 = itj.Next()) { - if (isWorldTour() && Owner) + if (Owner) { - if (Owner->isPlayer() && act2->isPlayer() && ud.coop != 0 && ud.ffire == 0 && Owner != act2) + if (Owner->isPlayer() && act2->isPlayer() && ud.coop != 0 && ud.ffire == 0 && Owner != act2 /* && (dmflags & NOFRIENDLYRADIUSDMG)*/) { continue; } - if (actor->spr.picnum == DTILE_FLAMETHROWERFLAME && ((Owner->spr.picnum == DTILE_FIREFLY && act2->spr.picnum == DTILE_FIREFLY) || (Owner->spr.picnum == DTILE_BOSS5 && act2->spr.picnum == DTILE_BOSS5))) + if (actor->flags3 & SFLAG3_HITRADIUS_DONTHURTSPECIES && !Owner->isPlayer() && Owner->GetClass() == act2->GetClass()) { continue; } @@ -180,7 +180,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h if (x == 0 || x >= 5 || (act2->flags1 & SFLAG_HITRADIUS_CHECKHITONLY)) { - if (actor->spr.picnum != DTILE_SHRINKSPARK || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)) + if (!(actor->flags3 & SFLAG3_HITRADIUS_NODAMAGE) || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)) if ((actor->spr.pos - act2->spr.pos).Length() < radius) { if (badguy(act2) && !cansee(act2->spr.pos.plusZ(q), act2->sector(), actor->spr.pos.plusZ(q), actor->sector())) @@ -190,10 +190,6 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h } else if (act2->spr.extra >= 0 && act2 != actor && ((act2->flags1 & SFLAG_HITRADIUS_FORCEEFFECT) || badguy(act2) || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))) { - if (actor->spr.picnum == DTILE_SHRINKSPARK && act2->spr.picnum != DTILE_SHARK && (act2->spr.scale.X < 0.375)) - { - continue; - } if (actor->flags3 & SFLAG3_HITRADIUS_DONTHURTSHOOTER && act2 == Owner) { continue; @@ -235,11 +231,11 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h } else if (actor->spr.extra == 0) act2->hitextra = 0; - if (act2->spr.picnum != DTILE_RADIUSEXPLOSION && Owner && Owner->spr.statnum < MAXSTATUS) + if (act2->GetClass() != DukeRadiusExplosionClass && Owner && Owner->spr.statnum < MAXSTATUS) { if (act2->isPlayer()) { - int p = act2->spr.yint; + int p = act2->PlayerIndex(); if (act2->attackertype == DukeFlamethrowerFlameClass && Owner->isPlayer()) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 22a636f96..03011354f 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -218,8 +218,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h if ((act2->flags1 & SFLAG_HITRADIUSCHECK)) checkhitsprite(act2, actor); - if (act2->spr.picnum != RTILE_RADIUSEXPLOSION && - Owner && Owner->spr.statnum < MAXSTATUS) + if (act2->GetClass() != DukeRadiusExplosionClass && Owner && Owner->spr.statnum < MAXSTATUS) { if (act2->isPlayer()) { diff --git a/source/games/duke/src/classnames.h b/source/games/duke/src/classnames.h index 62e480018..75f10d0be 100644 --- a/source/games/duke/src/classnames.h +++ b/source/games/duke/src/classnames.h @@ -111,3 +111,4 @@ xx(RedneckPorkRinds) xx(RedneckMoonshine) xx(RedneckTitgun) xx(RedneckTitAmmo) +xx(DukeRadiusExplosion) diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 6ba15738e..5f7df9793 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -415,6 +415,7 @@ enum sflags3_t SFLAG3_HITRADIUS_DONTHURTSHOOTER = 0x00002000, SFLAG3_HITRADIUS_NODAMAGE = 0x00004000, // Hitradius inflicts no damage, only a damage type. SFLAG3_HITRADIUS_NOEFFECT = 0x00008000, // Completely immune to hitradius + SFLAG3_HITRADIUS_DONTHURTSPECIES = 0x00010000, // don't hurt others of the shooter's species. }; diff --git a/wadsrc/static/zscript/games/duke/actors/flamethrowerflame.zs b/wadsrc/static/zscript/games/duke/actors/flamethrowerflame.zs index 79b34d850..7bd86b5d7 100644 --- a/wadsrc/static/zscript/games/duke/actors/flamethrowerflame.zs +++ b/wadsrc/static/zscript/games/duke/actors/flamethrowerflame.zs @@ -3,6 +3,7 @@ class DukeFlamethrowerFlame : DukeActor default { pic "FLAMETHROWERFLAME"; + +HITRADIUS_DONTHURTSPECIES; } override void Tick()