From 9ad8f67ce9a3b4f615fdb241502490f730c37270 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Dec 2022 20:54:41 +0100 Subject: [PATCH] - added isEffector inline and exported NATURALLIGHTNING which got a bit in the way. --- source/core/namedef_custom.h | 1 + source/games/duke/src/actors_d.cpp | 4 ++-- source/games/duke/src/actors_r.cpp | 2 +- source/games/duke/src/animatesprites_d.cpp | 9 +-------- source/games/duke/src/inlines.h | 6 ++++++ source/games/duke/src/namelist_r.h | 1 + source/games/duke/src/player_r.cpp | 4 ++-- source/games/duke/src/premap.cpp | 6 +++--- source/games/duke/src/premap_d.cpp | 4 ++-- source/games/duke/src/premap_r.cpp | 4 ++-- source/games/duke/src/sectors.cpp | 4 ++-- source/games/duke/src/sectors_d.cpp | 2 +- source/games/duke/src/sectors_r.cpp | 2 +- source/games/duke/src/spawn.cpp | 4 ++-- source/games/duke/src/spawn_d.cpp | 4 ---- .../static/filter/dukelike/engine/engine.def | 1 + wadsrc/static/zscript.txt | 1 + .../games/duke/actors/naturallightning.zs | 19 +++++++++++++++++++ 18 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/naturallightning.zs diff --git a/source/core/namedef_custom.h b/source/core/namedef_custom.h index 495159f70..ecaa87c35 100644 --- a/source/core/namedef_custom.h +++ b/source/core/namedef_custom.h @@ -23,6 +23,7 @@ xx(DukeGenericDestructible) xx(DukeGlassPieces) xx(DukeGlassPieces1) xx(DukeGlassPieces2) +xx(DukeNaturalLightning) xx(spawnstate) xx(brokenstate) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 9118e0339..7d1c93eae 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1413,7 +1413,7 @@ static void handle_se28(DDukeActor* actor) DukeStatIterator it(STAT_DEFAULT); while (auto act2 = it.Next()) { - if (act2->spr.picnum == NATURALLIGHTNING && act2->spr.hitag == actor->spr.hitag) + if (act2->GetClass()->TypeName == NAME_DukeNaturalLightning && act2->spr.hitag == actor->spr.hitag) act2->spr.cstat |= CSTAT_SPRITE_INVISIBLE; } } @@ -1430,7 +1430,7 @@ static void handle_se28(DDukeActor* actor) DukeStatIterator it(STAT_DEFAULT); while (auto act2 = it.Next()) { - if (act2->spr.picnum == NATURALLIGHTNING && act2->spr.hitag == actor->spr.hitag) + if (act2->GetClass()->TypeName == NAME_DukeNaturalLightning && act2->spr.hitag == actor->spr.hitag) { if (rnd(32) && (actor->temp_data[2] & 1)) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 460f8f256..a14670d1a 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1540,7 +1540,7 @@ void handle_se06_r(DDukeActor *actor) } if (!hulkspawn) { - ns = CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), actor->sector()->ceilingz + 466.5), 3677, -8, DVector2(0.25, 0.25), nullAngle, 0., 0., actor, 5); + ns = CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), actor->sector()->ceilingz + 466.5), UFOLIGHT, -8, DVector2(0.25, 0.25), nullAngle, 0., 0., actor, 5); if (ns) { ns->spr.cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index eccf69362..08d6674a3 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -109,9 +109,8 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi h = static_cast(t->ownerActor); auto OwnerAc = h->GetOwner(); - switch (h->spr.picnum) + if (iseffector(h)) { - case SECTOREFFECTOR: if (t->lotag == SE_27_DEMO_CAM && ud.recstat == 1) { t->picnum = 11 + ((PlayClock >> 3) & 1); @@ -120,12 +119,6 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi else t->scale = DVector2(0, 0); break; - case NATURALLIGHTNING: - t->shade = -127; - break; - - default: - break; } if (t->statnum == 99) continue; diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index fbe5414b0..99703c4d5 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -44,6 +44,12 @@ inline int islocator(DDukeActor* actor) return actor->GetClass()->TypeName == NAME_DukeLocator; } +inline int iseffector(DDukeActor* actor) +{ + return actor->spr.picnum == SECTOREFFECTOR; +} + + inline int badguypic(int const tileNum) { return ((gs.actorinfo[tileNum].flags & (SFLAG_INTERNAL_BADGUY | SFLAG_BADGUY)) != 0); diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index 43856d719..8544141e2 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -1052,6 +1052,7 @@ y(RRTILE3653, 3653) y(RRTILE3668, 3668) y(RRTILE3671, 3671) y(RRTILE3673, 3673) +x(UFOLIGHT, 3677) y(RRTILE3684, 3684) y(RRTILE3708, 3708) y(RRTILE3714, 3714) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 6d0fd0f09..7e334fb7b 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -111,7 +111,7 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a DukeStatIterator its(STAT_EFFECTOR); while (auto effector = its.Next()) { - if (effector->sector() == hit.hitSector && effector->spr.picnum == SECTOREFFECTOR && effector->GetOwner() + if (effector->sector() == hit.hitSector && iseffector(effector) && effector->GetOwner() && effector->spr.lotag == SE_7_TELEPORT) { DVector3 npos; @@ -260,7 +260,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int while (auto effector = its.Next()) { auto Owner = effector->GetOwner(); - if (effector->sector() == hit.hitSector && effector->spr.picnum == SECTOREFFECTOR && Owner && effector->spr.lotag == SE_7_TELEPORT) + if (effector->sector() == hit.hitSector && iseffector(effector) && Owner && effector->spr.lotag == SE_7_TELEPORT) { DVector3 npos; npos.XY() = hit.hitpos.XY() + (Owner->spr.pos.XY() - effector->spr.pos.XY()); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 40dd8a342..4237281f0 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -46,7 +46,7 @@ int which_palookup = 9; void premapcontroller(DDukeActor* ac) { CallStaticSetup(ac); - if (ac->spr.picnum == SECTOREFFECTOR) + if (iseffector(ac)) { ac->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN | CSTAT_SPRITE_ALIGNMENT_MASK); } @@ -824,7 +824,7 @@ static void SpawnPortals() DukeStatIterator it(STAT_RAROR); while (auto act = it.Next()) { - if (act->spr.picnum == SECTOREFFECTOR && act->spr.lotag == tag) + if (iseffector(act) && act->spr.lotag == tag) { int hitag = act->spr.hitag; if (processedTags.Find(hitag) == processedTags.Size()) @@ -832,7 +832,7 @@ static void SpawnPortals() DukeStatIterator it2(STAT_RAROR); while (auto act2 = it2.Next()) { - if (act2->spr.picnum == SECTOREFFECTOR && act2->spr.lotag == tag + 1 && act2->spr.hitag == hitag) + if (iseffector(act2) && act2->spr.lotag == tag + 1 && act2->spr.hitag == hitag) { if (processedTags.Find(act->spr.hitag) == processedTags.Size()) { diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index 14df7214f..29ac670c3 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -290,7 +290,7 @@ void prelevel_d(int g, TArray& actors) { if (actor->exists()) { - if (actor->spr.picnum == SECTOREFFECTOR && actor->spr.lotag == SE_14_SUBWAY_CAR) + if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR) continue; spriteinit_d(actor, actors); } @@ -300,7 +300,7 @@ void prelevel_d(int g, TArray& actors) { if (actor->exists()) { - if (actor->spr.picnum == SECTOREFFECTOR && actor->spr.lotag == SE_14_SUBWAY_CAR) + if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR) spriteinit_d(actor, actors); } } diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 446977b5f..a04af4b8f 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -583,7 +583,7 @@ void prelevel_r(int g, TArray& actors) { if (actor->exists()) { - if (actor->spr.picnum == SECTOREFFECTOR && actor->spr.lotag == SE_14_SUBWAY_CAR) + if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR) continue; spriteinit_r(actor, actors); } @@ -593,7 +593,7 @@ void prelevel_r(int g, TArray& actors) { if (actor->exists()) { - if (actor->spr.picnum == SECTOREFFECTOR && actor->spr.lotag == SE_14_SUBWAY_CAR) + if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR) spriteinit_r(actor, actors); if (actor->spr.picnum == RRTILE19) actor->Destroy(); diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index a3345af59..17c7ec6c7 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -648,7 +648,7 @@ static void handle_st15(sectortype* sptr, DDukeActor* actor) DDukeActor* a2; while ((a2 = it.Next())) { - if (a2->spr.picnum == SECTOREFFECTOR && a2->spr.lotag == ST_17_PLATFORM_UP) break; + if (iseffector(a2) && a2->spr.lotag == ST_17_PLATFORM_UP) break; } if (!a2) return; @@ -1255,7 +1255,7 @@ void operateforcefields_common(DDukeActor *effector, int low, const std::initial { wal->cstat = 0; - if (effector && effector->spr.picnum == SECTOREFFECTOR && effector->spr.lotag == 30) + if (effector && iseffector(effector) && effector->spr.lotag == 30) wal->lotag = 0; } else diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 6f821fd58..56bacaa6a 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -898,7 +898,7 @@ bool checkhitceiling_d(sectortype* sectp) DukeSectIterator it(sectp); while (auto act = it.Next()) { - if (act->spr.picnum == SECTOREFFECTOR && act->spr.lotag == SE_12_LIGHT_SWITCH) + if (iseffector(act) && act->spr.lotag == SE_12_LIGHT_SWITCH) { DukeStatIterator it1(STAT_EFFECTOR); while (auto act2 = it1.Next()) diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 7c5435b3e..141bb209e 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1264,7 +1264,7 @@ bool checkhitceiling_r(sectortype* sectp) DukeSectIterator it(sectp); while (auto act1 = it.Next()) { - if (act1->spr.picnum == SECTOREFFECTOR && (act1->spr.lotag == SE_12_LIGHT_SWITCH || (isRRRA() && (act1->spr.lotag == 47 || act1->spr.lotag == 48)))) + if (iseffector(act1) && (act1->spr.lotag == SE_12_LIGHT_SWITCH || (isRRRA() && (act1->spr.lotag == 47 || act1->spr.lotag == 48)))) { DukeStatIterator itr(STAT_EFFECTOR); while (auto act2 = itr.Next()) diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index fb8a66ff6..4a2796870 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -455,7 +455,7 @@ void spawneffector(DDukeActor* actor, TArray* actors) for(auto act2 : *actors) { - if (act2->spr.statnum < MAXSTATUS && act2->spr.picnum == SECTOREFFECTOR && (act2->spr.lotag == SE_7_TELEPORT || act2->spr.lotag == SE_23_ONE_WAY_TELEPORT) && + if (act2->spr.statnum < MAXSTATUS && iseffector(act2) && (act2->spr.lotag == SE_7_TELEPORT || act2->spr.lotag == SE_23_ONE_WAY_TELEPORT) && actor != act2 && act2->spr.hitag == actor->spr.hitag) { actor->SetOwner(act2); @@ -767,7 +767,7 @@ void spawneffector(DDukeActor* actor, TArray* actors) if (actors) for (auto act2 : *actors) { if (act2->spr.statnum < MAXSTATUS) - if (act2->spr.picnum == SECTOREFFECTOR && + if (iseffector(act2) && act2->spr.lotag == SE_1_PIVOT && act2->spr.hitag == actor->spr.hitag) { diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 6467fd454..50e080052 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -151,10 +151,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* act->spr.scale = DVector2(0, 0); ChangeActorStat(act, STAT_MISC); break; - case NATURALLIGHTNING: - act->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; - act->spr.cstat |= CSTAT_SPRITE_INVISIBLE; - break; case TRANSPORTERSTAR: case TRANSPORTERBEAM: spawntransporter(actj, act, act->spr.picnum == TRANSPORTERBEAM); diff --git a/wadsrc/static/filter/dukelike/engine/engine.def b/wadsrc/static/filter/dukelike/engine/engine.def index 46d757433..197dbcfd2 100644 --- a/wadsrc/static/filter/dukelike/engine/engine.def +++ b/wadsrc/static/filter/dukelike/engine/engine.def @@ -11,6 +11,7 @@ spawnclasses 8 = DukeMasterSwitch 9 = DukeRespawnController 10 = DukeGPSpeed + 4890 = DukeNaturalLightning 1221 = DukeCranePole 1222 = DukeCrane diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index c977aa948..0a1428d56 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -59,6 +59,7 @@ version "4.10" #include "zscript/games/duke/actors/respawnmarker.zs" #include "zscript/games/duke/actors/genericdestructible.zs" #include "zscript/games/duke/actors/frameeffect.zs" +#include "zscript/games/duke/actors/naturallightning.zs" #include "zscript/games/duke/actors/projectiles.zs" #include "zscript/games/duke/actors/rat.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/naturallightning.zs b/wadsrc/static/zscript/games/duke/actors/naturallightning.zs new file mode 100644 index 000000000..a72afc3c0 --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/naturallightning.zs @@ -0,0 +1,19 @@ +class DukeNaturalLightning : DukeActor +{ + default + { + pic "NATURALLIGHTNING"; + } + + override void Initialize() + { + self.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; + self.cstat |= CSTAT_SPRITE_INVISIBLE; + } + + override bool Animate(tspritetype t) + { + t.shade = -127; + return true; + } +}