- RR: thunder may only be triggered when the player sees a sector with an activating texture as sky.

This commit is contained in:
Christoph Oelckers 2023-06-19 20:45:16 +02:00
parent 5bbcb82ef2
commit c4cb44f5f0
3 changed files with 34 additions and 8 deletions

View file

@ -74,6 +74,7 @@ struct WindowLightning
static TArray<jaildoor> jaildoors;
static TArray<minecart> minecarts;
static TArray<WindowLightning> windowlightning;
static TArray<sectortype*> 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;

View file

@ -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);

View file

@ -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(&sect);
thunderon = 1;
}
}
SpawnPortals();