From 35a088ba04a5413bf2b59594131aa918db0f18f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 30 Dec 2022 14:05:39 +0100 Subject: [PATCH] - added map flags to enable RR's special sector types in Duke as well. --- source/games/duke/src/actors.cpp | 8 +-- source/games/duke/src/actors_d.cpp | 4 +- source/games/duke/src/actors_r.cpp | 65 ++++++++++--------- source/games/duke/src/constants.h | 12 ++++ source/games/duke/src/player.cpp | 2 +- source/games/duke/src/player_d.cpp | 2 +- source/games/duke/src/player_r.cpp | 2 +- source/games/duke/src/premap.cpp | 2 + source/games/duke/src/spawn.cpp | 2 +- source/games/duke/src/types.h | 1 + source/games/duke/src/vmexports.cpp | 1 + .../games/duke/actors/dukeweapons/hitscan.zs | 3 +- .../games/duke/actors/dukeweapons/melee.zs | 3 +- .../zscript/games/duke/actors/mortar.zs | 2 +- .../zscript/games/duke/actors/powderkeg.zs | 2 +- wadsrc/static/zscript/games/duke/dukegame.zs | 5 ++ 16 files changed, 71 insertions(+), 45 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 79cdef3e6..bcd180ad3 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -2197,13 +2197,13 @@ void handle_se10(DDukeActor* actor, const int* specialtags) auto sc = actor->sector(); int sh = actor->spr.hitag; - if ((sc->lotag & 0xff) == 27 || (sc->floorz > sc->ceilingz && (sc->lotag & 0xff) != 23) || sc->lotag == 32791 - 65536) + if ((sc->lotag & 0xff) == ST_27_STRETCH_BRIDGE || (sc->floorz > sc->ceilingz && (sc->lotag & 0xff) != ST_23_SWINGING_DOOR) || sc->lotag == 32791 - 65536) { int j = 1; - if ((sc->lotag & 0xff) != 27) + if ((sc->lotag & 0xff) != ST_27_STRETCH_BRIDGE) for (int p = connecthead; p >= 0; p = connectpoint2[p]) - if (sc->lotag != 30 && sc->lotag != 31 && sc->lotag != 0) + if (sc->lotag != ST_30_ROTATE_RISE_BRIDGE && sc->lotag != ST_31_TWO_WAY_TRAIN && sc->lotag != ST_0_NO_EFFECT) if (actor->sector() == ps[p].GetActor()->sector()) j = 0; @@ -4113,7 +4113,7 @@ void spawndebris(DDukeActor* g_ac, int dnum, int count) void actoroperate(DDukeActor* g_ac) { - if (g_ac->sector()->lotag == 0) + if (g_ac->sector()->lotag == ST_0_NO_EFFECT) { HitInfo hit{}; neartag(g_ac->spr.pos.plusZ(-32), g_ac->sector(), g_ac->spr.Angles.Yaw, hit, 48, NT_Lotag | NT_NoSpriteCheck); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index dc03f2120..1eaf5fa35 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -295,7 +295,7 @@ void movetransports_d(void) if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0) { - if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0) + if (ps[p].on_ground && sectlotag == ST_0_NO_EFFECT && onfloorz && ps[p].jetpack_on == 0) { if (act->spr.pal == 0) { @@ -440,7 +440,7 @@ void movetransports_d(void) if (ll && sectlotag == 1 && act2->spr.pos.Z > (sectp->floorz - ll) && act2->vel.Z > 0) warpspriteto = 1; - if (sectlotag == 0 && (onfloorz || abs(act2->spr.pos.Z - act->spr.pos.Z) < 16)) + if (sectlotag == ST_0_NO_EFFECT && (onfloorz || abs(act2->spr.pos.Z - act->spr.pos.Z) < 16)) { if ((!Owner || Owner->GetOwner() != Owner) && onfloorz && act->counter > 0 && act2->spr.statnum != STAT_MISC) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 58ef12623..5ff2c9109 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -279,7 +279,7 @@ void movetransports_r(void) if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0) { - if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0) + if (ps[p].on_ground && sectlotag == ST_0_NO_EFFECT && onfloorz && ps[p].jetpack_on == 0) { spawn(act, DukeTransporterBeamClass); S_PlayActorSound(TELEPORTER, act); @@ -335,7 +335,7 @@ void movetransports_r(void) k = 0; - if (isRRRA()) + if (ud.mapflags & MFLAG_ALLSECTORTYPES) { if (onfloorz && sectlotag == ST_160_FLOOR_TELEPORT && ps[p].GetActor()->getOffsetZ() > sectp->floorz - 48) { @@ -434,7 +434,7 @@ void movetransports_r(void) if (ll && sectlotag == ST_1_ABOVE_WATER && act2->spr.pos.Z > (sectp->floorz - ll)) warpspriteto = 1; - if (isRRRA()) + if (ud.mapflags & MFLAG_ALLSECTORTYPES) { if (ll && sectlotag == ST_161_CEILING_TELEPORT && act2->spr.pos.Z < (sectp->ceilingz + ll) && warpdir == 1) { @@ -458,7 +458,7 @@ void movetransports_r(void) } } - if (sectlotag == 0 && (onfloorz || abs(act2->spr.pos.Z - act->spr.pos.Z) < 16)) + if (sectlotag == ST_0_NO_EFFECT && (onfloorz || abs(act2->spr.pos.Z - act->spr.pos.Z) < 16)) { if (Owner->GetOwner() != Owner && onfloorz && act->counter > 0 && act2->spr.statnum != 5) { @@ -481,7 +481,7 @@ void movetransports_r(void) } [[fallthrough]]; default: - if (act2->spr.statnum == 5 && !(sectlotag == ST_1_ABOVE_WATER || sectlotag == ST_2_UNDERWATER || (isRRRA() && (sectlotag == ST_160_FLOOR_TELEPORT || sectlotag == ST_161_CEILING_TELEPORT)))) + if (act2->spr.statnum == STAT_MISC && !(sectlotag == ST_1_ABOVE_WATER || sectlotag == ST_2_UNDERWATER || ((ud.mapflags & MFLAG_ALLSECTORTYPES) && (sectlotag == ST_160_FLOOR_TELEPORT || sectlotag == ST_161_CEILING_TELEPORT)))) break; [[fallthrough]]; @@ -554,7 +554,7 @@ void movetransports_r(void) break; case ST_160_FLOOR_TELEPORT: - if (!isRRRA()) break; + if (!(ud.mapflags & MFLAG_ALLSECTORTYPES)) break; act2->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY(); act2->spr.pos.Z = Owner->sector()->ceilingz + ll2; act2->backupz(); @@ -565,7 +565,7 @@ void movetransports_r(void) break; case ST_161_CEILING_TELEPORT: - if (!isRRRA()) break; + if (!(ud.mapflags & MFLAG_ALLSECTORTYPES)) break; act2->spr.pos += Owner->spr.pos.XY() - act->spr.pos.XY(); act2->spr.pos.Z = Owner->sector()->floorz - ll; act2->backupz(); @@ -1034,9 +1034,9 @@ void fakebubbaspawn(DDukeActor *actor, player_struct* p) static int fallspecial(DDukeActor *actor, int playernum) { int sphit = 0; - if (isRRRA()) + if (ud.mapflags & MFLAG_ALLSECTORTYPES) { - if (actor->sector()->lotag == 801) + if (actor->sector()->lotag == ST_801_ROCKY) { if (actor->spr.picnum == RTILE_ROCK) { @@ -1046,7 +1046,7 @@ static int fallspecial(DDukeActor *actor, int playernum) } return 0; } - else if (actor->sector()->lotag == 802) + else if (actor->sector()->lotag == ST_802_KILLBADGUYS) { if (!actor->isPlayer() && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F) { @@ -1056,38 +1056,41 @@ static int fallspecial(DDukeActor *actor, int playernum) } return 0; } - else if (actor->sector()->lotag == 803) + else if (actor->sector()->lotag == ST_803_KILLROCKS) { if (actor->spr.picnum == RTILE_ROCK2) addspritetodelete(); return 0; } } - if (actor->sector()->lotag == 800) + if (ud.mapflags & (MFLAG_ALLSECTORTYPES | MFLAG_SECTORTYPE800)) { - if (actor->spr.picnum == RTILE_AMMO) + if (actor->sector()->lotag == ST_800_KILLSTUFF) { - addspritetodelete(); - return 0; - } - if (!actor->isPlayer() && (badguy(actor) || actor->spr.picnum == RTILE_HEN || actor->spr.picnum == RTILE_COW || actor->spr.picnum == RTILE_PIG || actor->spr.picnum == RTILE_DOGRUN || actor->spr.picnum == RTILE_RABBIT) && (!isRRRA() || actor->spriteextra < 128)) - { - actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F; - actor->vel.Z = 8000 / 256.; - actor->spr.extra = 0; - actor->spriteextra++; - sphit = 1; - } - else if (!actor->isPlayer()) - { - if (!actor->spriteextra) + if (actor->spr.picnum == RTILE_AMMO) + { addspritetodelete(); - return 0; + return 0; + } + if (!actor->isPlayer() && (badguy(actor)) && (!isRRRA() || actor->spriteextra < 128)) + { + actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F; + actor->vel.Z = 8000 / 256.; + actor->spr.extra = 0; + actor->spriteextra++; + sphit = 1; + } + else if (!actor->isPlayer()) + { + if (!actor->spriteextra) + addspritetodelete(); + return 0; + } + actor->attackertype = DukeShotSparkClass; + actor->hitextra = 1; } - actor->attackertype = DukeShotSparkClass; - actor->hitextra = 1; } - else if (tilesurface(actor->sector()->floortexture) == TSURF_MAGMA) + if (tilesurface(actor->sector()->floortexture) == TSURF_MAGMA) { if (actor->spr.picnum != RTILE_MINION && actor->spr.pal != 19) { diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 839510c9c..13943af38 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -140,6 +140,12 @@ enum ST_160_FLOOR_TELEPORT = 160, ST_161_CEILING_TELEPORT = 161, + + ST_800_KILLSTUFF = 800, + ST_801_ROCKY = 801, + ST_802_KILLBADGUYS = 802, + ST_803_KILLROCKS = 803, + // left: ST 32767, 65534, 65535 }; @@ -318,6 +324,12 @@ enum amoveflags_t antifaceplayerslow = 32768 }; +enum mapflags_t +{ + MFLAG_SECTORTYPE800 = 1, // RR only needs 800 by default - this flag is purely internal. For new content ALLSECTORTYPES will do better. + MFLAG_ALLSECTORTYPES =2, // enables RRRA's sector types regardless of the game being played. +}; + enum sflags_t { SFLAG_INVENTORY = 0x00000001, diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 019f49c3a..6599e073f 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -491,7 +491,7 @@ void footprints(int snum) if (j < 0) { p->footprintcount--; - if (p->cursector->lotag == 0 && p->cursector->hitag == 0) + if (p->cursector->lotag == ST_0_NO_EFFECT && p->cursector->hitag == 0) { DDukeActor* fprint = spawn(actor, DukeFootprintsClass); if (fprint) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index e81adfe3e..d262118ed 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -626,7 +626,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, double f } int k; - if (shrunk == 0 && (psectlotag == 0 || psectlotag == 2)) k = 32; + if (shrunk == 0 && (psectlotag == ST_0_NO_EFFECT || psectlotag == ST_2_UNDERWATER)) k = 32; else k = 16; if (psectlotag != 2 && p->scuba_on == 1) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index f59225869..bc95ddbb0 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2866,7 +2866,7 @@ HORIZONLY: // RBG*** SetActor(pact, pact->spr.pos); - if (psectlotag == 800 && (!isRRRA() || !p->lotag800kill)) + if (psectlotag == ST_800_KILLSTUFF && (!isRRRA() || !p->lotag800kill)) { if (isRRRA()) p->lotag800kill = 1; quickkill(p); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 4b94d8620..dd510659f 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -629,6 +629,8 @@ void lava_cleararrays(); void prelevel_common(int g) { + if (isRRRA()) ud.mapflags = MFLAG_ALLSECTORTYPES; + else if (isRR()) ud.mapflags = MFLAG_SECTORTYPE800; auto p = &ps[screenpeek]; p->sea_sick_stat = 0; ud.ufospawnsminion = 0; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 209a43def..323cc728c 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -711,7 +711,7 @@ void spawneffector(DDukeActor* actor, TArray* actors) { if (wal.twoSided() && wal.nextSector()->hitag == 0 && - (wal.nextSector()->lotag < 3 || (isRRRA() && wal.nextSector()->lotag == ST_160_FLOOR_TELEPORT))) + (wal.nextSector()->lotag < 3 || ((ud.mapflags & MFLAG_ALLSECTORTYPES) && wal.nextSector()->lotag == ST_160_FLOOR_TELEPORT))) { s = wal.nextSector(); break; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index bafd981d4..f54ea0a0f 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -179,6 +179,7 @@ struct animwalltype struct user_defs { + int mapflags; uint8_t god, cashman, eog; uint8_t clipping; uint8_t user_pals[MAXPLAYERS]; diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index ae3d177a8..4767e8417 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -1767,6 +1767,7 @@ DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, weaponsandammosprites); DEFINE_GLOBAL_UNSIZED(gs) +DEFINE_FIELD_X(DukeUserDefs, user_defs, mapflags); DEFINE_FIELD_X(DukeUserDefs, user_defs, god); DEFINE_FIELD_X(DukeUserDefs, user_defs, cashman); DEFINE_FIELD_X(DukeUserDefs, user_defs, eog); diff --git a/wadsrc/static/zscript/games/duke/actors/dukeweapons/hitscan.zs b/wadsrc/static/zscript/games/duke/actors/dukeweapons/hitscan.zs index 9b7fd775f..866ac0a91 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeweapons/hitscan.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeweapons/hitscan.zs @@ -83,7 +83,8 @@ extend class DukeActor actor.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; Raze.hitscan(pos, sectp, (ang.ToVector() * vel, zvel * 64), hit, CLIPMASK1); - if (Raze.isRRRA() && hit.hitSector != nullptr && ((hit.hitSector.lotag == ST_160_FLOOR_TELEPORT && zvel > 0) || (hit.hitSector.lotag == ST_161_CEILING_TELEPORT && zvel < 0)) + if ((ud.mapflags & MFLAG_ALLSECTORTYPES) && hit.hitSector != nullptr && + ((hit.hitSector.lotag == ST_160_FLOOR_TELEPORT && zvel > 0) || (hit.hitSector.lotag == ST_161_CEILING_TELEPORT && zvel < 0)) && hit.hitActor == nullptr && hit.hitWall == nullptr) { DukeStatIterator its; diff --git a/wadsrc/static/zscript/games/duke/actors/dukeweapons/melee.zs b/wadsrc/static/zscript/games/duke/actors/dukeweapons/melee.zs index 2fee40018..cd892f80e 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeweapons/melee.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeweapons/melee.zs @@ -35,7 +35,8 @@ class DukeMeleeAttack : DukeActor Raze.hitscan(pos, sectp, (ang.ToVector() * vel, zvel * 64), hit, CLIPMASK1); - if (Raze.isRRRA() && hit.hitSector != nullptr && ((hit.hitSector.lotag == ST_160_FLOOR_TELEPORT && zvel > 0) || (hit.hitSector.lotag == ST_161_CEILING_TELEPORT && zvel < 0)) + if ((ud.mapflags & MFLAG_ALLSECTORTYPES) && hit.hitSector != nullptr && + ((hit.hitSector.lotag == ST_160_FLOOR_TELEPORT && zvel > 0) || (hit.hitSector.lotag == ST_161_CEILING_TELEPORT && zvel < 0)) && hit.hitActor == nullptr && hit.hitWall == nullptr) { DukeStatIterator its; diff --git a/wadsrc/static/zscript/games/duke/actors/mortar.zs b/wadsrc/static/zscript/games/duke/actors/mortar.zs index 2c39291b2..1c7025d19 100644 --- a/wadsrc/static/zscript/games/duke/actors/mortar.zs +++ b/wadsrc/static/zscript/games/duke/actors/mortar.zs @@ -70,7 +70,7 @@ class DukeMortar : DukeActor self.makeitfall(); // Feature check later needs to be map controlled, not game controlled. - if (sectp.lotag != ST_1_ABOVE_WATER && (!Raze.isRRRA() || sectp.lotag != ST_160_FLOOR_TELEPORT) && self.pos.Z >= self.floorz - 1 && self.yint < 3) + if (sectp.lotag != ST_1_ABOVE_WATER && (!(ud.mapflags & MFLAG_ALLSECTORTYPES) || sectp.lotag != ST_160_FLOOR_TELEPORT) && self.pos.Z >= self.floorz - 1 && self.yint < 3) { if (self.yint > 0 || (self.yint == 0 && self.floorz == sectp.floorz)) { diff --git a/wadsrc/static/zscript/games/duke/actors/powderkeg.zs b/wadsrc/static/zscript/games/duke/actors/powderkeg.zs index cdc5f37c5..13b9dd51f 100644 --- a/wadsrc/static/zscript/games/duke/actors/powderkeg.zs +++ b/wadsrc/static/zscript/games/duke/actors/powderkeg.zs @@ -14,7 +14,7 @@ class RedneckPowderKeg : DukeItemBase override void Tick() { let sectp = self.sector; - if (sectp.lotag != ST_1_ABOVE_WATER && (!Raze.isRRRA() && sectp.lotag != ST_160_FLOOR_TELEPORT)) + if (sectp.lotag != ST_1_ABOVE_WATER && (!(ud.mapflags & MFLAG_ALLSECTORTYPES) && sectp.lotag != ST_160_FLOOR_TELEPORT)) if (self.vel.X != 0) { movesprite((self.Angle.ToVector()* self.vel.X, self.vel.Z), CLIPMASK0); diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index b95f879b0..f2799b3af 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -494,9 +494,14 @@ struct DukeGameInfo native } +enum mapflags_t +{ + MFLAG_ALLSECTORTYPES =2, // enables RRRA's sector types regardless of the game being played. +}; struct DukeUserDefs native { + native readonly int mapflags; native uint8 god, cashman, eog; native readonly uint8 clipping; native readonly uint8 user_pals[MAXPLAYERS];