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"
|
|
|
|
|
2020-05-29 00:32:53 +00:00
|
|
|
#include "gamecontrol.h"
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "names2.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "tags.h"
|
|
|
|
#include "break.h"
|
|
|
|
#include "pal.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
extern short NormalVisibility; // player.c
|
|
|
|
|
|
|
|
#define VIS_VisCur(sp) (SP_TAG2(sp))
|
|
|
|
#define VIS_VisDir(sp) (SP_TAG3(sp))
|
|
|
|
#define VIS_VisGoal(sp) (SP_TAG4(sp))
|
|
|
|
|
|
|
|
void ProcessVisOn(void)
|
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
|
2021-11-02 23:12:20 +00:00
|
|
|
SWStatIterator it(STAT_VIS_ON);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 23:12:20 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (VIS_VisDir(sp))
|
|
|
|
{
|
|
|
|
// get brighter
|
|
|
|
VIS_VisCur(sp) >>= 1;
|
|
|
|
//VIS_VisCur(sp) -= 16;
|
|
|
|
if (VIS_VisCur(sp) <= VIS_VisGoal(sp))
|
|
|
|
{
|
|
|
|
VIS_VisCur(sp) = VIS_VisGoal(sp);
|
|
|
|
VIS_VisDir(sp) ^= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// get darker
|
|
|
|
VIS_VisCur(sp) <<= 1;
|
|
|
|
VIS_VisCur(sp) += 1;
|
|
|
|
//VIS_VisCur(sp) += 16;
|
|
|
|
if (VIS_VisCur(sp) >= NormalVisibility)
|
|
|
|
{
|
|
|
|
VIS_VisCur(sp) = NormalVisibility;
|
2021-11-02 23:12:20 +00:00
|
|
|
auto own = GetOwner(actor);
|
|
|
|
if (own != nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 23:12:20 +00:00
|
|
|
ASSERT(own->hasU());
|
|
|
|
RESET(own->u()->Flags2, SPR2_VIS_SHADING);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2021-11-02 23:12:20 +00:00
|
|
|
KillActor(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisViewChange(PLAYERp pp, int *vis)
|
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
short BrightestVis = NormalVisibility;
|
|
|
|
int x,y,z;
|
2021-11-24 17:35:42 +00:00
|
|
|
sectortype* sectp;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-29 00:32:53 +00:00
|
|
|
if (paused)
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// find the closest quake - should be a strength value
|
2021-11-02 23:12:20 +00:00
|
|
|
SWStatIterator it(STAT_VIS_ON);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 23:12:20 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 23:12:20 +00:00
|
|
|
auto own = GetOwner(actor);
|
|
|
|
if (own != nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 23:12:20 +00:00
|
|
|
x = own->s().x;
|
|
|
|
y = own->s().y;
|
|
|
|
z = own->s().z;
|
2021-11-24 17:35:42 +00:00
|
|
|
sectp = own->s().sector();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = sp->x;
|
|
|
|
y = sp->y;
|
|
|
|
z = sp->z;
|
2021-11-24 17:35:42 +00:00
|
|
|
sectp = sp->sector();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// save off the brightest vis that you can see
|
2021-11-26 16:50:49 +00:00
|
|
|
if (FAFcansee(pp->posx, pp->posy, pp->posz, pp->cursector, x, y, z, sectp))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (VIS_VisCur(sp) < BrightestVis)
|
|
|
|
BrightestVis = VIS_VisCur(sp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*vis = BrightestVis;
|
|
|
|
}
|
|
|
|
|
2021-11-25 17:30:10 +00:00
|
|
|
void SpawnVis(DSWActor* parentActor, sectortype* sect, int x, int y, int z, int amt)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp sp;
|
2021-11-02 23:12:20 +00:00
|
|
|
if (parentActor != nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 23:12:20 +00:00
|
|
|
auto psp = &parentActor->s();
|
|
|
|
auto pu = parentActor->u();
|
|
|
|
|
2021-11-24 18:25:13 +00:00
|
|
|
if (psp->sector()->floorpal == PALETTE_FOG)
|
2021-11-02 23:12:20 +00:00
|
|
|
return;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-24 18:25:13 +00:00
|
|
|
if (psp->sector()->floorpal == PALETTE_DIVE_LAVA)
|
2021-11-02 23:12:20 +00:00
|
|
|
return;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// kill any others with the same parent
|
2021-11-02 23:12:20 +00:00
|
|
|
SWStatIterator it(STAT_VIS_ON);
|
|
|
|
while (auto itActor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 23:12:20 +00:00
|
|
|
if (GetOwner(itActor) == parentActor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 23:12:20 +00:00
|
|
|
KillActor(itActor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-04 21:04:16 +00:00
|
|
|
auto actorNew = insertActor(psp->sector(), STAT_VIS_ON);
|
2021-11-02 23:12:20 +00:00
|
|
|
sp = &actorNew->s();
|
|
|
|
SetOwner(parentActor, actorNew);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
2021-11-02 23:12:20 +00:00
|
|
|
ASSERT(parentActor->hasU());
|
|
|
|
SET(pu->Flags2, SPR2_CHILDREN);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 23:12:20 +00:00
|
|
|
sp->x = psp->x;
|
|
|
|
sp->y = psp->y;
|
|
|
|
sp->z = psp->z;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 23:12:20 +00:00
|
|
|
SET(pu->Flags2, SPR2_VIS_SHADING);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-25 17:30:10 +00:00
|
|
|
if (sect->floorpal == PALETTE_FOG)
|
2021-11-02 23:12:20 +00:00
|
|
|
return;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-04 21:04:16 +00:00
|
|
|
auto actorNew = insertActor(sect, STAT_VIS_ON);
|
2021-11-02 23:12:20 +00:00
|
|
|
sp = &actorNew->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sp->x = x;
|
|
|
|
sp->y = y;
|
|
|
|
sp->z = z - Z(20);
|
|
|
|
}
|
|
|
|
|
|
|
|
sp->cstat = 0;
|
|
|
|
sp->extra = 0;
|
|
|
|
|
|
|
|
VIS_VisDir(sp) = 1;
|
|
|
|
VIS_VisCur(sp) = NormalVisibility;
|
|
|
|
VIS_VisGoal(sp) = amt;
|
|
|
|
}
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|