From 0ffeb2378acb5aee063aa44ee33833800ad2b57d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2022 21:58:05 +0100 Subject: [PATCH] - generalize Duke's purple lava check. --- source/games/duke/src/constants.h | 1 + source/games/duke/src/funct.h | 1 + source/games/duke/src/player.cpp | 32 +++++++++++++++++++ source/games/duke/src/player_d.cpp | 22 ++----------- source/games/duke/src/player_r.cpp | 3 +- wadsrc/static/filter/dukeengine/constants.mi | 2 ++ .../static/filter/dukelike/rmapinfo.texflags | 1 + wadsrc/static/zscript/games/duke/dukegame.zs | 1 + 8 files changed, 43 insertions(+), 20 deletions(-) diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index fd54c226b..a62682231 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -424,6 +424,7 @@ enum TFLAG_NOBLOODSPLAT = 1 << 8, TFLAG_NOCIRCLEREFLECT = 1 << 9, TFLAG_MUDDY = 1 << 10, + TFLAG_PURPLELAVA = 1 << 11, // very special kind of terrain type. }; enum diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 7fe225944..027676062 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -115,6 +115,7 @@ void quickkill(player_struct* p); int setpal(player_struct* p); int madenoise(int playerNum); int haskey(sectortype* sect, int snum); +void purplelavacheck(player_struct* p); bool checkhitceiling(sectortype* sectp); void checkhitwall(DDukeActor* spr, walltype* wal, const DVector3& pos); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 1eaf696e9..aa6cb48e3 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -990,5 +990,37 @@ int haskey(sectortype* sectp, int snum) return 0; } +//--------------------------------------------------------------------------- +// +// taken out of Duke, now that it is no longer hard coded. +// +//--------------------------------------------------------------------------- + +void purplelavacheck(player_struct* p) +{ + auto pact = p->actor; + if (p->spritebridge == 0 && pact->insector()) + { + auto sect = pact->sector(); + // one texflag for a single texture again, just to avoid one hard coded check... + if ((tileflags(sect->floortexture()) & TFLAG_PURPLELAVA) || (tileflags(sect->ceilingtexture()) & TFLAG_PURPLELAVA)) + { + if (p->boot_amount > 0) + { + p->boot_amount--; + p->inven_icon = 7; + if (p->boot_amount <= 0) + checkavailinven(p); + } + else + { + if (!S_CheckActorSoundPlaying(pact, DUKE_LONGTERM_PAIN)) + S_PlayActorSound(DUKE_LONGTERM_PAIN, pact); + SetPlayerPal(p, PalEntry(32, 0, 8, 0)); + pact->spr.extra--; + } + } + } +} END_DUKE_NS diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index a7f3a1082..53a529a04 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2883,33 +2883,17 @@ void processinput_d(int snum) } p->Angles.doYawKeys(&actions); + purplelavacheck(p); if (p->spritebridge == 0 && pact->insector()) { - int j = pact->sector()->floorpicnum; - - if (j == DTILE_PURPLELAVA || pact->sector()->ceilingpicnum == DTILE_PURPLELAVA) - { - if (p->boot_amount > 0) - { - p->boot_amount--; - p->inven_icon = 7; - if (p->boot_amount <= 0) - checkavailinven(p); - } - else - { - if (!S_CheckActorSoundPlaying(pact, DUKE_LONGTERM_PAIN)) - S_PlayActorSound(DUKE_LONGTERM_PAIN, pact); - SetPlayerPal(p, PalEntry(32, 0, 8, 0)); - pact->spr.extra--; - } - } + auto sect = pact->sector(); k = 0; if (p->on_ground && truefdist <= gs.playerheight + 16) { + int j = sect->floorpicnum; int whichsound = (tileflags(tileGetTextureID(j)) & TFLAG_ELECTRIC) ? 0 : j == DTILE_FLOORSLIME ? 1 : j == DTILE_FLOORPLASMA ? 2 : -1; if (j >= 0) k = makepainsounds(snum, whichsound); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 524553506..8e7cf3d7e 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3494,6 +3494,7 @@ void processinput_r(int snum) } p->Angles.doYawKeys(&actions); + purplelavacheck(p); if (p->spritebridge == 0 && pact->insector()) { @@ -3524,7 +3525,7 @@ void processinput_r(int snum) if (isRRRA() && p->spritebridge == 0 && p->on_ground) { - if (psectlotag == 1) + if (psectlotag == ST_1_ABOVE_WATER) p->NotOnWater = 0; else if (p->OnBoat) { diff --git a/wadsrc/static/filter/dukeengine/constants.mi b/wadsrc/static/filter/dukeengine/constants.mi index f58e304cd..67ef45e61 100644 --- a/wadsrc/static/filter/dukeengine/constants.mi +++ b/wadsrc/static/filter/dukeengine/constants.mi @@ -14,4 +14,6 @@ constants TFLAG_NOBLOODSPLAT = 256 TFLAG_NOCIRCLEREFLECT = 512 TFLAG_MUDDY = 1024 + TFLAG_PURPLELAVA = 2048 + } diff --git a/wadsrc/static/filter/dukelike/rmapinfo.texflags b/wadsrc/static/filter/dukelike/rmapinfo.texflags index ac68960d8..88da5a86b 100644 --- a/wadsrc/static/filter/dukelike/rmapinfo.texflags +++ b/wadsrc/static/filter/dukelike/rmapinfo.texflags @@ -131,4 +131,5 @@ textureflags TFLAG_ELECTRIC = HURTRAIL TFLAG_SLIME = FLOORSLIME, FLOORSLIME1, FLOORSLIME2 TFLAG_OUTERSPACE = MOONSKY1, BIGORBIT1 + TFLAG_PURPLELAVA = PURPLELAVA } \ No newline at end of file diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index c2d9c90a6..68d7dad84 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -81,6 +81,7 @@ struct Duke native TFLAG_NOBLOODSPLAT = 1 << 8, TFLAG_NOCIRCLEREFLECT = 1 << 9, TFLAG_MUDDY = 1 << 10, + TFLAG_PURPLELAVA = 1 << 11, // very special kind of terrain type. }; enum ESoundFlags