From c4cb44f5f09b9316a9e85d13813d1d791cbc51a2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Jun 2023 20:45:16 +0200 Subject: [PATCH] - RR: thunder may only be triggered when the player sees a sector with an activating texture as sky. --- source/games/duke/src/actors_lava.cpp | 38 +++++++++++++++++++++------ source/games/duke/src/funct.h | 1 + source/games/duke/src/premap.cpp | 3 +++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/source/games/duke/src/actors_lava.cpp b/source/games/duke/src/actors_lava.cpp index 7e868ba3e..07a9954a1 100644 --- a/source/games/duke/src/actors_lava.cpp +++ b/source/games/duke/src/actors_lava.cpp @@ -74,6 +74,7 @@ struct WindowLightning static TArray jaildoors; static TArray minecarts; static TArray windowlightning; +static TArray thundersectors; static uint8_t brightness; @@ -88,6 +89,7 @@ void lava_cleararrays() jaildoors.Clear(); minecarts.Clear(); windowlightning.Clear(); + thundersectors.Clear(); torchcnt = 0; } @@ -141,6 +143,7 @@ void lava_serialize(FSerializer& arc) arc("torchcnt", torchcnt) ("jaildoors", jaildoors) ("minecarts", minecarts) + ("thundersectors", thundersectors) ("windowlightning", windowlightning); if (torchcnt) @@ -155,6 +158,11 @@ void lava_serialize(FSerializer& arc) ("windertime", windowtime); } +void addthundersector(sectortype* sect) +{ + thundersectors.Push(sect); +} + void addtorch(sectortype* sect, int shade, int lotag) { if (torchcnt >= 64) @@ -454,19 +462,32 @@ void thunder(void) if (!thunderflash) { - if (ps[screenpeek].actor->sector()->ceilingstat & CSTAT_SECTOR_SKY) + bool seen = false; + for (auto& sectp : thundersectors) { - g_relvisibility = 0; - if (krand() > 65000) + if (sectp->exflags & SECTOREX_SEEN) { - thunderflash = 1; - thundertime = 256; - S_PlaySound(soundEngine->FindSound("THUNDER")); + seen = true; + sectp->exflags &= ~SECTOREX_SEEN; } } - else + + if (seen) { - brightness = ud.brightness >> 2; + if (ps[screenpeek].actor->sector()->ceilingstat & CSTAT_SECTOR_SKY) + { + g_relvisibility = 0; + if (krand() > 65000) + { + thunderflash = 1; + thundertime = 256; + S_PlaySound(soundEngine->FindSound("THUNDER")); + } + } + else + { + brightness = ud.brightness >> 2; + } } } else @@ -479,6 +500,7 @@ void thunder(void) thunder_brightness = brightness; } } + if (!windowflash) { bool seen = false; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 3a0c55dc4..9cd7bf2af 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -19,6 +19,7 @@ void animatewalls(void); void lava_cleararrays(); void addjaildoor(int p1, int p2, int iht, int jlt, int p3, sectortype* h); void addminecart(int p1, int p2, sectortype* i, int iht, int p3, sectortype* childsectnum); +void addthundersector(sectortype* sect); void addtorch(sectortype* sect, int shade, int lotag); void addlightning(sectortype* sect, int shade); int addambient(int hitag, int lotag); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index a8e106ad7..ed6b62e62 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -1090,7 +1090,10 @@ static int LoadTheMap(MapRecord *mi, player_struct*p, int gamemode) for (auto& sect : sector) { if (tilesurface(sect.ceilingtexture) == TSURF_THUNDERSKY) + { + addthundersector(§); thunderon = 1; + } } SpawnPortals();