2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-10-09 16:09:05 +00:00
|
|
|
#include "ns.h"
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
#include "names2.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "light.h"
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2022-09-04 20:52:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-01 13:44:27 +00:00
|
|
|
void SectorLightShade(DSWActor* actor, short intensity)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
int8_t* wall_shade;
|
2015-05-19 21:54:34 +00:00
|
|
|
short base_shade;
|
|
|
|
|
2021-12-24 22:39:06 +00:00
|
|
|
if (TEST_BOOL8(actor))
|
2015-05-19 21:54:34 +00:00
|
|
|
intensity = -intensity;
|
|
|
|
|
2021-12-24 22:39:06 +00:00
|
|
|
if (!TEST_BOOL2(actor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
if (!TEST_BOOL6(actor))
|
2021-12-30 15:51:56 +00:00
|
|
|
actor->sector()->floorpal = actor->spr.pal;
|
|
|
|
actor->sector()->floorshade = LIGHT_FloorShade(actor) + intensity; // floor change
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-24 22:39:06 +00:00
|
|
|
if (!TEST_BOOL3(actor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
if (!TEST_BOOL6(actor))
|
2021-12-30 15:51:56 +00:00
|
|
|
actor->sector()->ceilingpal = actor->spr.pal;
|
|
|
|
actor->sector()->ceilingshade = LIGHT_CeilingShade(actor) + intensity; // ceiling change
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// change wall
|
2021-12-24 22:39:06 +00:00
|
|
|
if (!TEST_BOOL4(actor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-25 21:13:03 +00:00
|
|
|
ASSERT(actor->hasU() && actor->user.WallShade.Data());
|
|
|
|
wall_shade = actor->user.WallShade.Data();
|
2021-11-24 19:11:50 +00:00
|
|
|
int wallcount = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
for(auto &wal : wallsofsector(actor->sector()))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
base_shade = wall_shade[wallcount];
|
2021-11-24 19:11:50 +00:00
|
|
|
wal.shade = base_shade + intensity;
|
2021-12-24 22:39:06 +00:00
|
|
|
if (!TEST_BOOL6(actor))
|
|
|
|
wal.pal = actor->spr.pal;
|
2015-05-19 21:54:34 +00:00
|
|
|
wallcount++;
|
|
|
|
|
2021-12-29 05:53:36 +00:00
|
|
|
if ((actor->spr.extra & SPRX_BOOL5))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-24 19:11:50 +00:00
|
|
|
if (wal.twoSided())
|
2019-11-27 07:33:34 +00:00
|
|
|
{
|
2021-11-24 19:11:50 +00:00
|
|
|
auto nextWall = wal.nextWall();
|
2019-11-27 07:33:34 +00:00
|
|
|
base_shade = wall_shade[wallcount];
|
2021-11-24 19:11:50 +00:00
|
|
|
nextWall->shade = base_shade + intensity;
|
2021-12-24 22:39:06 +00:00
|
|
|
if (!TEST_BOOL6(actor))
|
|
|
|
nextWall->pal = actor->spr.pal;
|
2019-11-27 07:33:34 +00:00
|
|
|
wallcount++;
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-04 20:52:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-01 13:44:27 +00:00
|
|
|
void DiffuseLighting(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-10-15 15:45:07 +00:00
|
|
|
int i;
|
2015-05-19 21:54:34 +00:00
|
|
|
short count;
|
|
|
|
short shade;
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// diffused lighting
|
|
|
|
count = 0;
|
2021-11-01 13:44:27 +00:00
|
|
|
SWStatIterator it(STAT_LIGHTING_DIFFUSE);
|
|
|
|
while (auto itActor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// make sure matchs match
|
2021-12-24 13:12:21 +00:00
|
|
|
if (LIGHT_Match(itActor) != LIGHT_Match(actor))
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
2021-12-24 22:39:06 +00:00
|
|
|
shade = actor->spr.shade + ((LIGHT_DiffuseNum(itActor) + 1) * LIGHT_DiffuseMult(itActor));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-24 22:34:21 +00:00
|
|
|
if (shade > LIGHT_MaxDark(actor))
|
|
|
|
shade = LIGHT_MaxDark(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-24 22:34:21 +00:00
|
|
|
if (!TEST_BOOL6(itActor))
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.pal = actor->spr.pal;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-01 13:44:27 +00:00
|
|
|
SectorLightShade(itActor, shade);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 20:52:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DoLightingMatch(short match, short state)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-01 13:44:27 +00:00
|
|
|
SWStatIterator it(STAT_LIGHTING);
|
|
|
|
while (auto itActor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 13:12:21 +00:00
|
|
|
if (LIGHT_Match(itActor) != match)
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
2021-12-24 14:21:44 +00:00
|
|
|
switch (LIGHT_Type(itActor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
case LIGHT_CONSTANT:
|
|
|
|
|
|
|
|
// initialized
|
2021-12-24 22:34:21 +00:00
|
|
|
SET_BOOL9(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// toggle
|
|
|
|
if (state == -1)
|
2021-12-24 22:34:21 +00:00
|
|
|
state = !TEST_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-29 08:27:13 +00:00
|
|
|
if (state == 1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
SET_BOOL1(itActor);
|
|
|
|
itActor->spr.shade = -LIGHT_MaxBright(itActor);
|
2021-12-25 21:13:03 +00:00
|
|
|
itActor->spr.pal = itActor->user.spal; // on
|
2021-12-24 22:34:21 +00:00
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
RESET_BOOL1(itActor);
|
|
|
|
itActor->spr.shade = LIGHT_MaxDark(itActor);
|
|
|
|
itActor->spr.pal = 0; // off
|
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIGHT_FLICKER:
|
|
|
|
case LIGHT_FADE:
|
|
|
|
// initialized
|
2021-12-24 22:34:21 +00:00
|
|
|
SET_BOOL9(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// toggle
|
|
|
|
if (state == -1)
|
2021-12-24 22:34:21 +00:00
|
|
|
state = !TEST_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-29 08:27:13 +00:00
|
|
|
if (state == 1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// allow fade or flicker
|
2021-12-24 22:34:21 +00:00
|
|
|
SET_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
RESET_BOOL1(itActor);
|
|
|
|
itActor->spr.shade = LIGHT_MaxDark(itActor);
|
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIGHT_FADE_TO_ON_OFF:
|
|
|
|
|
|
|
|
// initialized
|
2021-12-24 22:34:21 +00:00
|
|
|
SET_BOOL9(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// toggle
|
|
|
|
//if (state == -1)
|
2021-12-24 22:34:21 +00:00
|
|
|
// state = !TEST_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-29 08:27:13 +00:00
|
|
|
if (state == 1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
if (LIGHT_Dir(itActor) == 1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_DirChange(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-29 05:40:52 +00:00
|
|
|
else if (state == 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
if (LIGHT_Dir(itActor) == 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_DirChange(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// allow fade or flicker
|
2021-12-24 22:34:21 +00:00
|
|
|
SET_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LIGHT_FLICKER_ON:
|
|
|
|
|
|
|
|
// initialized
|
2021-12-24 22:34:21 +00:00
|
|
|
SET_BOOL9(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// toggle
|
|
|
|
if (state == -1)
|
2021-12-24 22:34:21 +00:00
|
|
|
state = !TEST_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-29 08:27:13 +00:00
|
|
|
if (state == 1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// allow fade or flicker
|
2021-12-24 22:34:21 +00:00
|
|
|
SET_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// turn it off till next switch
|
2021-12-24 22:34:21 +00:00
|
|
|
auto spal = itActor->spr.pal;
|
|
|
|
RESET_BOOL1(itActor);
|
|
|
|
itActor->spr.pal = 0;
|
|
|
|
itActor->spr.shade = LIGHT_MaxDark(itActor);
|
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2021-12-24 22:34:21 +00:00
|
|
|
itActor->spr.pal = spal;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 20:52:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void InitLighting(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// processed on level startup
|
|
|
|
// puts lights in correct state
|
2021-11-01 13:44:27 +00:00
|
|
|
SWStatIterator it(STAT_LIGHTING);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
if (!TEST_BOOL9(actor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
DoLightingMatch(LIGHT_Match(actor), !!TEST_BOOL1(actor));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 20:52:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DoLighting(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-01 13:44:27 +00:00
|
|
|
SWStatIterator it(STAT_LIGHTING);
|
|
|
|
while (auto itActor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// on/off test
|
2021-12-29 05:40:52 +00:00
|
|
|
if (TEST_BOOL1(itActor) == 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
2021-12-24 14:21:44 +00:00
|
|
|
switch (LIGHT_Type(itActor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
case LIGHT_CONSTANT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIGHT_FLICKER:
|
|
|
|
|
2021-12-24 22:00:33 +00:00
|
|
|
LIGHT_Tics(itActor) += synctics;
|
2021-12-24 22:34:21 +00:00
|
|
|
while (LIGHT_Tics(itActor) >= LIGHT_MaxTics(itActor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_Tics(itActor) -= LIGHT_MaxTics(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if ((RANDOM_P2(128 << 8) >> 8) > 64)
|
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.shade = -LIGHT_MaxBright(itActor) + RandomRange(LIGHT_MaxBright(itActor) + LIGHT_MaxDark(itActor));
|
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// turn off lighting - even colored lighting
|
2021-12-24 22:39:06 +00:00
|
|
|
auto spal = itActor->spr.pal;
|
|
|
|
itActor->spr.pal = 0;
|
|
|
|
itActor->spr.shade = LIGHT_MaxDark(itActor);
|
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.pal = spal;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIGHT_FADE:
|
|
|
|
|
2021-12-24 22:00:33 +00:00
|
|
|
LIGHT_Tics(itActor) += synctics;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-24 22:34:21 +00:00
|
|
|
while (LIGHT_Tics(itActor) >= LIGHT_MaxTics(itActor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_Tics(itActor) -= LIGHT_MaxTics(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-24 22:34:21 +00:00
|
|
|
if (LIGHT_Dir(itActor) == 1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.shade += LIGHT_ShadeInc(itActor);
|
|
|
|
if (itActor->spr.shade >= LIGHT_MaxDark(itActor))
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_DirChange(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.shade -= LIGHT_ShadeInc(itActor);
|
|
|
|
if (itActor->spr.shade <= -LIGHT_MaxBright(itActor))
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_DirChange(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-24 22:39:06 +00:00
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIGHT_FADE_TO_ON_OFF:
|
|
|
|
|
2021-12-24 22:00:33 +00:00
|
|
|
LIGHT_Tics(itActor) += synctics;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-24 22:34:21 +00:00
|
|
|
while (LIGHT_Tics(itActor) >= LIGHT_MaxTics(itActor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_Tics(itActor) -= LIGHT_MaxTics(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-24 22:34:21 +00:00
|
|
|
if (LIGHT_Dir(itActor) == 1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.shade += LIGHT_ShadeInc(itActor);
|
|
|
|
if (itActor->spr.shade >= LIGHT_MaxDark(itActor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.pal = 0; // off
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_DirChange(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
// stop it until switch is hit
|
2021-12-24 22:34:21 +00:00
|
|
|
RESET_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.shade -= LIGHT_ShadeInc(itActor);
|
2021-12-25 21:13:03 +00:00
|
|
|
itActor->spr.pal = itActor->user.spal; // on
|
2021-12-24 22:39:06 +00:00
|
|
|
if (itActor->spr.shade <= -LIGHT_MaxBright(itActor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_DirChange(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
// stop it until switch is hit
|
2021-12-24 22:34:21 +00:00
|
|
|
RESET_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-24 22:39:06 +00:00
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIGHT_FLICKER_ON:
|
|
|
|
|
2021-12-24 22:00:33 +00:00
|
|
|
LIGHT_Tics(itActor) += synctics;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-24 22:34:21 +00:00
|
|
|
while (LIGHT_Tics(itActor) >= LIGHT_MaxTics(itActor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 22:34:21 +00:00
|
|
|
LIGHT_Tics(itActor) -= LIGHT_MaxTics(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if ((RANDOM_P2(128 << 8) >> 8) > 64)
|
|
|
|
{
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.shade = -LIGHT_MaxBright(itActor) + RandomRange(LIGHT_MaxBright(itActor) + LIGHT_MaxDark(itActor));
|
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// turn off lighting - even colored lighting
|
2021-12-24 22:39:06 +00:00
|
|
|
auto spal = itActor->spr.pal;
|
|
|
|
itActor->spr.pal = 0;
|
|
|
|
itActor->spr.shade = LIGHT_MaxDark(itActor);
|
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.pal = spal;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((RANDOM_P2(128 << 8) >> 8) < 8)
|
|
|
|
{
|
|
|
|
// set to full brightness
|
2021-12-24 22:39:06 +00:00
|
|
|
itActor->spr.shade = -LIGHT_MaxBright(itActor);
|
|
|
|
SectorLightShade(itActor, itActor->spr.shade);
|
2021-11-01 13:44:27 +00:00
|
|
|
DiffuseLighting(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
// turn it off until a swith happens
|
2021-12-24 22:34:21 +00:00
|
|
|
RESET_BOOL1(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|