2020-08-02 17:59:14 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "compat.h"
|
|
|
|
#include "build.h"
|
|
|
|
#include "v_font.h"
|
|
|
|
|
2020-12-09 14:56:32 +00:00
|
|
|
#include "blood.h"
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
#include "zstring.h"
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "razemenu.h"
|
2020-08-02 17:59:14 +00:00
|
|
|
#include "gstrings.h"
|
|
|
|
#include "v_2ddrawer.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "v_font.h"
|
2021-04-05 11:55:36 +00:00
|
|
|
#include "hw_voxels.h"
|
2021-04-13 18:33:21 +00:00
|
|
|
#include "gamefuncs.h"
|
2020-08-02 17:59:14 +00:00
|
|
|
#include "glbackend/glbackend.h"
|
|
|
|
|
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
static fixed_t gCameraAng;
|
2020-08-02 17:59:14 +00:00
|
|
|
int dword_172CE0[16][3];
|
|
|
|
|
|
|
|
static void RotateYZ(int *, int *pY, int *pZ, int ang)
|
|
|
|
{
|
|
|
|
int oY, oZ, angSin, angCos;
|
|
|
|
oY = *pY;
|
|
|
|
oZ = *pZ;
|
|
|
|
angSin = Sin(ang);
|
|
|
|
angCos = Cos(ang);
|
|
|
|
*pY = dmulscale30r(oY,angCos,oZ,-angSin);
|
|
|
|
*pZ = dmulscale30r(oY,angSin,oZ,angCos);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void RotateXZ(int *pX, int *, int *pZ, int ang)
|
|
|
|
{
|
|
|
|
int oX, oZ, angSin, angCos;
|
|
|
|
oX = *pX;
|
|
|
|
oZ = *pZ;
|
|
|
|
angSin = Sin(ang);
|
|
|
|
angCos = Cos(ang);
|
|
|
|
*pX = dmulscale30r(oX,angCos,oZ,-angSin);
|
|
|
|
*pZ = dmulscale30r(oX,angSin,oZ,angCos);
|
|
|
|
}
|
|
|
|
|
2021-04-02 08:28:40 +00:00
|
|
|
template<typename T> tspritetype* viewInsertTSprite(spritetype* tsprite, int& spritesortcnt, int nSector, int nStatnum, T const * const pSprite)
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-07-26 05:59:59 +00:00
|
|
|
if (spritesortcnt >= MAXSPRITESONSCREEN)
|
|
|
|
return nullptr;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
int nTSprite = spritesortcnt;
|
|
|
|
tspritetype *pTSprite = &tsprite[nTSprite];
|
|
|
|
memset(pTSprite, 0, sizeof(tspritetype));
|
|
|
|
pTSprite->cstat = 128;
|
|
|
|
pTSprite->xrepeat = 64;
|
|
|
|
pTSprite->yrepeat = 64;
|
|
|
|
pTSprite->owner = -1;
|
|
|
|
pTSprite->extra = -1;
|
|
|
|
pTSprite->type = -spritesortcnt;
|
|
|
|
pTSprite->statnum = nStatnum;
|
|
|
|
pTSprite->sectnum = nSector;
|
|
|
|
spritesortcnt++;
|
|
|
|
if (pSprite)
|
|
|
|
{
|
|
|
|
pTSprite->x = pSprite->x;
|
|
|
|
pTSprite->y = pSprite->y;
|
|
|
|
pTSprite->z = pSprite->z;
|
|
|
|
pTSprite->owner = pSprite->owner;
|
|
|
|
pTSprite->ang = pSprite->ang;
|
|
|
|
}
|
2020-12-01 22:57:39 +00:00
|
|
|
pTSprite->x += Cos(gCameraAng)>>25;
|
|
|
|
pTSprite->y += Sin(gCameraAng)>>25;
|
2020-08-02 17:59:14 +00:00
|
|
|
return pTSprite;
|
|
|
|
}
|
|
|
|
|
2021-07-26 05:59:59 +00:00
|
|
|
static const int effectDetail[kViewEffectMax] = {
|
2020-08-02 17:59:14 +00:00
|
|
|
4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 4, 4, 0, 0, 0, 1, 0, 0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct WEAPONICON {
|
|
|
|
short nTile;
|
|
|
|
char zOffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WEAPONICON gWeaponIcon[] = {
|
|
|
|
{ -1, 0 },
|
|
|
|
{ -1, 0 }, // 1: pitchfork
|
|
|
|
{ 524, 6 }, // 2: flare gun
|
|
|
|
{ 559, 6 }, // 3: shotgun
|
|
|
|
{ 558, 8 }, // 4: tommy gun
|
|
|
|
{ 526, 6 }, // 5: napalm launcher
|
|
|
|
{ 589, 11 }, // 6: dynamite
|
|
|
|
{ 618, 11 }, // 7: spray can
|
|
|
|
{ 539, 6 }, // 8: tesla gun
|
|
|
|
{ 800, 0 }, // 9: life leech
|
|
|
|
{ 525, 11 }, // 10: voodoo doll
|
|
|
|
{ 811, 11 }, // 11: proxy bomb
|
|
|
|
{ 810, 11 }, // 12: remote bomb
|
|
|
|
{ -1, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-04-02 08:28:40 +00:00
|
|
|
static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int nTSprite, VIEW_EFFECT nViewEffect)
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nViewEffect >= 0 && nViewEffect < kViewEffectMax);
|
2020-08-02 17:59:14 +00:00
|
|
|
auto pTSprite = &tsprite[nTSprite];
|
2021-03-25 22:16:32 +00:00
|
|
|
if (gDetail < effectDetail[nViewEffect] || nTSprite >= MAXSPRITESONSCREEN) return NULL;
|
2020-08-02 17:59:14 +00:00
|
|
|
switch (nViewEffect)
|
|
|
|
{
|
2021-08-23 09:12:32 +00:00
|
|
|
case kViewEffectSpotProgress: {
|
|
|
|
XSPRITE* pXSprite = &xsprite[pTSprite->extra];
|
|
|
|
int perc = (100 * pXSprite->data3) / kMaxPatrolSpotValue;
|
|
|
|
int width = (94 * pXSprite->data3) / kMaxPatrolSpotValue;
|
|
|
|
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
|
|
|
|
|
|
|
auto pNSprite2 = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
|
|
|
if (!pNSprite2)
|
|
|
|
break;
|
|
|
|
|
|
|
|
pNSprite2->picnum = 2203;
|
|
|
|
|
|
|
|
pNSprite2->xrepeat = width;
|
|
|
|
pNSprite2->yrepeat = 20;
|
|
|
|
pNSprite2->pal = 10;
|
|
|
|
if (perc >= 75) pNSprite2->pal = 0;
|
|
|
|
else if (perc >= 50) pNSprite2->pal = 6;
|
|
|
|
|
|
|
|
pNSprite2->z = top - 2048;
|
|
|
|
pNSprite2->shade = -128;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectAtom:
|
2020-08-02 17:59:14 +00:00
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2021-02-18 10:46:36 +00:00
|
|
|
int ang = (PlayClock*2048)/120;
|
2020-08-02 17:59:14 +00:00
|
|
|
int nRand1 = dword_172CE0[i][0];
|
|
|
|
int nRand2 = dword_172CE0[i][1];
|
|
|
|
int nRand3 = dword_172CE0[i][2];
|
|
|
|
ang += nRand3;
|
2021-01-04 11:36:54 +00:00
|
|
|
int x = MulScale(512, Cos(ang), 30);
|
|
|
|
int y = MulScale(512, Sin(ang), 30);
|
2020-08-02 17:59:14 +00:00
|
|
|
int z = 0;
|
|
|
|
RotateYZ(&x, &y, &z, nRand1);
|
|
|
|
RotateXZ(&x, &y, &z, nRand2);
|
|
|
|
pNSprite->x = pTSprite->x + x;
|
|
|
|
pNSprite->y = pTSprite->y + y;
|
|
|
|
pNSprite->z = pTSprite->z + (z<<4);
|
|
|
|
pNSprite->picnum = 1720;
|
|
|
|
pNSprite->shade = -128;
|
|
|
|
}
|
|
|
|
break;
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectFlag:
|
|
|
|
case kViewEffectBigFlag:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->shade = -128;
|
|
|
|
pNSprite->pal = 0;
|
|
|
|
pNSprite->z = top;
|
2021-06-16 19:13:04 +00:00
|
|
|
if (nViewEffect == kViewEffectFlag)
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = 24;
|
|
|
|
else
|
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = 64;
|
|
|
|
pNSprite->picnum = 3558;
|
|
|
|
return pNSprite;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectTesla:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->z = pTSprite->z;
|
|
|
|
pNSprite->cstat |= 2;
|
|
|
|
pNSprite->shade = -128;
|
|
|
|
pNSprite->xrepeat = pTSprite->xrepeat;
|
|
|
|
pNSprite->yrepeat = pTSprite->yrepeat;
|
|
|
|
pNSprite->picnum = 2135;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectShoot:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->shade = -128;
|
|
|
|
pNSprite->pal = 0;
|
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = 64;
|
|
|
|
pNSprite->picnum = 2605;
|
|
|
|
return pNSprite;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectReflectiveBall:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->shade = 26;
|
|
|
|
pNSprite->pal = 0;
|
|
|
|
pNSprite->cstat |= 2;
|
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = 64;
|
|
|
|
pNSprite->picnum = 2089;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectPhase:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
|
|
|
pNSprite->shade = 26;
|
|
|
|
pNSprite->pal = 0;
|
|
|
|
pNSprite->cstat |= 2;
|
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = 24;
|
|
|
|
pNSprite->picnum = 626;
|
|
|
|
pNSprite->z = top;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectTrail:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
|
|
|
int nAng = pTSprite->ang;
|
|
|
|
if (pTSprite->cstat & 16)
|
|
|
|
{
|
|
|
|
nAng = (nAng+512)&2047;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nAng = (nAng+1024)&2047;
|
|
|
|
}
|
2021-03-25 22:16:32 +00:00
|
|
|
for (int i = 0; i < 5 && spritesortcnt < MAXSPRITESONSCREEN; i++)
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
|
|
|
int nSector = pTSprite->sectnum;
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite<tspritetype>(tsprite, spritesortcnt, nSector, 32767, NULL);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
int nLen = 128+(i<<7);
|
2021-01-04 11:36:54 +00:00
|
|
|
int x = MulScale(nLen, Cos(nAng), 30);
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->x = pTSprite->x + x;
|
2021-01-04 11:36:54 +00:00
|
|
|
int y = MulScale(nLen, Sin(nAng), 30);
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->y = pTSprite->y + y;
|
|
|
|
pNSprite->z = pTSprite->z;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector >= 0 && nSector < kMaxSectors);
|
2020-08-02 17:59:14 +00:00
|
|
|
FindSector(pNSprite->x, pNSprite->y, pNSprite->z, &nSector);
|
|
|
|
pNSprite->sectnum = nSector;
|
|
|
|
pNSprite->owner = pTSprite->owner;
|
|
|
|
pNSprite->picnum = pTSprite->picnum;
|
|
|
|
pNSprite->cstat |= 2;
|
|
|
|
if (i < 2)
|
|
|
|
pNSprite->cstat |= 514;
|
|
|
|
pNSprite->shade = ClipLow(pTSprite->shade-16, -128);
|
|
|
|
pNSprite->xrepeat = pTSprite->xrepeat;
|
|
|
|
pNSprite->yrepeat = pTSprite->yrepeat;
|
|
|
|
pNSprite->picnum = pTSprite->picnum;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectFlame:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->shade = -128;
|
|
|
|
pNSprite->z = pTSprite->z;
|
|
|
|
pNSprite->picnum = 908;
|
|
|
|
pNSprite->statnum = kStatDecoration;
|
2020-11-22 23:18:07 +00:00
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = (tileWidth(pTSprite->picnum)*pTSprite->xrepeat)/64;
|
2020-08-02 17:59:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectSmokeHigh:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
|
|
|
pNSprite->z = top;
|
|
|
|
if (IsDudeSprite(pTSprite))
|
|
|
|
pNSprite->picnum = 672;
|
|
|
|
else
|
|
|
|
pNSprite->picnum = 754;
|
|
|
|
pNSprite->cstat |= 2;
|
|
|
|
pNSprite->shade = 8;
|
|
|
|
pNSprite->xrepeat = pTSprite->xrepeat;
|
|
|
|
pNSprite->yrepeat = pTSprite->yrepeat;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectSmokeLow:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
|
|
|
pNSprite->z = bottom;
|
|
|
|
if (pTSprite->type >= kDudeBase && pTSprite->type < kDudeMax)
|
|
|
|
pNSprite->picnum = 672;
|
|
|
|
else
|
|
|
|
pNSprite->picnum = 754;
|
|
|
|
pNSprite->cstat |= 2;
|
|
|
|
pNSprite->shade = 8;
|
|
|
|
pNSprite->xrepeat = pTSprite->xrepeat;
|
|
|
|
pNSprite->yrepeat = pTSprite->yrepeat;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectTorchHigh:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
|
|
|
pNSprite->z = top;
|
|
|
|
pNSprite->picnum = 2101;
|
|
|
|
pNSprite->shade = -128;
|
2020-11-22 23:18:07 +00:00
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = (tileWidth(pTSprite->picnum)*pTSprite->xrepeat)/32;
|
2020-08-02 17:59:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectTorchLow:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
|
|
|
pNSprite->z = bottom;
|
|
|
|
pNSprite->picnum = 2101;
|
|
|
|
pNSprite->shade = -128;
|
2020-11-22 23:18:07 +00:00
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = (tileWidth(pTSprite->picnum)*pTSprite->xrepeat)/32;
|
2020-08-02 17:59:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectShadow:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
|
|
|
if (r_shadows)
|
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->z = getflorzofslope(pTSprite->sectnum, pNSprite->x, pNSprite->y);
|
|
|
|
pNSprite->shade = 127;
|
|
|
|
pNSprite->cstat |= 2;
|
|
|
|
pNSprite->xrepeat = pTSprite->xrepeat;
|
|
|
|
pNSprite->yrepeat = pTSprite->yrepeat >> 2;
|
|
|
|
pNSprite->picnum = pTSprite->picnum;
|
|
|
|
pNSprite->pal = 5;
|
2020-11-22 23:18:07 +00:00
|
|
|
int height = tileHeight(pNSprite->picnum);
|
2020-08-02 17:59:14 +00:00
|
|
|
int center = height / 2 + tileTopOffset(pNSprite->picnum);
|
|
|
|
pNSprite->z -= (pNSprite->yrepeat << 2) * (height - center);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectFlareHalo:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->shade = -128;
|
|
|
|
pNSprite->pal = 2;
|
|
|
|
pNSprite->cstat |= 2;
|
|
|
|
pNSprite->z = pTSprite->z;
|
|
|
|
pNSprite->xrepeat = pTSprite->xrepeat;
|
|
|
|
pNSprite->yrepeat = pTSprite->yrepeat;
|
|
|
|
pNSprite->picnum = 2427;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectCeilGlow:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
sectortype *pSector = §or[pTSprite->sectnum];
|
|
|
|
pNSprite->x = pTSprite->x;
|
|
|
|
pNSprite->y = pTSprite->y;
|
|
|
|
pNSprite->z = pSector->ceilingz;
|
|
|
|
pNSprite->picnum = 624;
|
|
|
|
pNSprite->shade = ((pTSprite->z-pSector->ceilingz)>>8)-64;
|
|
|
|
pNSprite->pal = 2;
|
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = 64;
|
|
|
|
pNSprite->cstat |= 106;
|
|
|
|
pNSprite->ang = pTSprite->ang;
|
|
|
|
pNSprite->owner = pTSprite->owner;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectFloorGlow:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
sectortype *pSector = §or[pTSprite->sectnum];
|
|
|
|
pNSprite->x = pTSprite->x;
|
|
|
|
pNSprite->y = pTSprite->y;
|
|
|
|
pNSprite->z = pSector->floorz;
|
|
|
|
pNSprite->picnum = 624;
|
|
|
|
char nShade = (pSector->floorz-pTSprite->z)>>8;
|
|
|
|
pNSprite->shade = nShade-32;
|
|
|
|
pNSprite->pal = 2;
|
|
|
|
pNSprite->xrepeat = pNSprite->yrepeat = nShade;
|
|
|
|
pNSprite->cstat |= 98;
|
|
|
|
pNSprite->ang = pTSprite->ang;
|
|
|
|
pNSprite->owner = pTSprite->owner;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectSpear:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->z = pTSprite->z;
|
|
|
|
if (gDetail > 1)
|
|
|
|
pNSprite->cstat |= 514;
|
|
|
|
pNSprite->shade = ClipLow(pTSprite->shade-32, -128);
|
|
|
|
pNSprite->xrepeat = pTSprite->xrepeat;
|
|
|
|
pNSprite->yrepeat = 64;
|
|
|
|
pNSprite->picnum = 775;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-16 19:13:04 +00:00
|
|
|
case kViewEffectShowWeapon:
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pTSprite->type >= kDudePlayer1 && pTSprite->type <= kDudePlayer8);
|
2020-08-02 17:59:14 +00:00
|
|
|
PLAYER *pPlayer = &gPlayer[pTSprite->type-kDudePlayer1];
|
|
|
|
WEAPONICON weaponIcon = gWeaponIcon[pPlayer->curWeapon];
|
2021-08-18 09:56:06 +00:00
|
|
|
auto& nTile = weaponIcon.nTile;
|
2020-08-02 17:59:14 +00:00
|
|
|
if (nTile < 0) break;
|
2021-04-02 08:28:40 +00:00
|
|
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
2021-07-26 05:59:59 +00:00
|
|
|
if (!pNSprite)
|
|
|
|
break;
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->x = pTSprite->x;
|
|
|
|
pNSprite->y = pTSprite->y;
|
|
|
|
pNSprite->z = pTSprite->z-(32<<8);
|
2021-08-23 09:12:32 +00:00
|
|
|
pNSprite->z -= weaponIcon.zOffset<<8; // offset up
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->picnum = nTile;
|
|
|
|
pNSprite->shade = pTSprite->shade;
|
|
|
|
pNSprite->xrepeat = 32;
|
|
|
|
pNSprite->yrepeat = 32;
|
2021-08-18 09:56:06 +00:00
|
|
|
auto& nVoxel = voxelIndex[nTile];
|
2020-11-11 12:03:47 +00:00
|
|
|
if (cl_showweapon == 2 && r_voxels && nVoxel != -1)
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-08-23 09:12:32 +00:00
|
|
|
pNSprite->ang = (gView->pSprite->ang + 512) & 2047; // always face viewer
|
2020-08-02 17:59:14 +00:00
|
|
|
pNSprite->cstat |= 48;
|
|
|
|
pNSprite->cstat &= ~8;
|
|
|
|
pNSprite->picnum = nVoxel;
|
2021-08-23 09:12:32 +00:00
|
|
|
if (pPlayer->curWeapon == kWeapLifeLeech) // position lifeleech behind player
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-08-23 09:12:32 +00:00
|
|
|
pNSprite->x += MulScale(128, Cos(gView->pSprite->ang), 30);
|
|
|
|
pNSprite->y += MulScale(128, Sin(gView->pSprite->ang), 30);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
2021-08-23 09:12:32 +00:00
|
|
|
if ((pPlayer->curWeapon == kWeapLifeLeech) || (pPlayer->curWeapon == kWeapVoodooDoll)) // make lifeleech/voodoo doll always face viewer like sprite
|
|
|
|
pNSprite->ang = (pNSprite->ang + 512) & 2047; // offset angle 90 degrees
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void viewApplyDefaultPal(tspritetype *pTSprite, sectortype const *pSector)
|
|
|
|
{
|
2021-08-18 09:56:06 +00:00
|
|
|
auto& nXSector = pSector->extra;
|
2020-08-02 17:59:14 +00:00
|
|
|
XSECTOR const *pXSector = nXSector >= 0 ? &xsector[nXSector] : NULL;
|
|
|
|
if (pXSector && pXSector->color && (VanillaMode() || pSector->floorpal != 0))
|
|
|
|
{
|
2021-04-13 18:33:21 +00:00
|
|
|
copyfloorpal(pTSprite, pSector);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-02 08:28:40 +00:00
|
|
|
void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smoothratio)
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2020-09-01 18:02:37 +00:00
|
|
|
// shift before interpolating to increase precision.
|
2021-02-18 10:46:36 +00:00
|
|
|
int myclock = (PlayClock<<3) + MulScale(4<<3, smoothratio, 16);
|
2021-03-25 22:16:32 +00:00
|
|
|
assert(spritesortcnt <= MAXSPRITESONSCREEN);
|
2020-08-02 17:59:14 +00:00
|
|
|
gCameraAng = cA;
|
|
|
|
int nViewSprites = spritesortcnt;
|
|
|
|
for (int nTSprite = spritesortcnt-1; nTSprite >= 0; nTSprite--)
|
|
|
|
{
|
|
|
|
tspritetype *pTSprite = &tsprite[nTSprite];
|
2021-08-29 16:13:15 +00:00
|
|
|
auto owneractor = &bloodActors[pTSprite->owner];
|
2020-08-02 17:59:14 +00:00
|
|
|
//int nXSprite = pTSprite->extra;
|
|
|
|
int nXSprite = sprite[pTSprite->owner].extra;
|
|
|
|
XSPRITE *pTXSprite = NULL;
|
2020-10-02 20:42:54 +00:00
|
|
|
if (sprite[pTSprite->owner].detail > gDetail)
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
|
|
|
pTSprite->xrepeat = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (nXSprite > 0)
|
|
|
|
{
|
|
|
|
pTXSprite = &xsprite[nXSprite];
|
|
|
|
}
|
|
|
|
int nTile = pTSprite->picnum;
|
|
|
|
if (nTile < 0 || nTile >= kMaxTiles)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nSprite = pTSprite->owner;
|
2020-11-26 16:19:42 +00:00
|
|
|
if (cl_interpolate && gInterpolateSprite[nSprite] && !(pTSprite->flags&512))
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
2021-01-05 12:48:20 +00:00
|
|
|
pTSprite->pos = pTSprite->interpolatedvec3(gInterpolate);
|
|
|
|
pTSprite->ang = pTSprite->interpolatedang(gInterpolate);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
int nAnim = 0;
|
|
|
|
switch (picanm[nTile].extra & 7) {
|
|
|
|
case 0:
|
2020-10-11 10:38:17 +00:00
|
|
|
//assert(nXSprite > 0 && nXSprite < kMaxXSprites);
|
2020-08-02 17:59:14 +00:00
|
|
|
if (nXSprite <= 0 || nXSprite >= kMaxXSprites) break;
|
|
|
|
switch (pTSprite->type) {
|
|
|
|
case kSwitchToggle:
|
|
|
|
case kSwitchOneWay:
|
|
|
|
if (xsprite[nXSprite].state) nAnim = 1;
|
|
|
|
break;
|
|
|
|
case kSwitchCombo:
|
|
|
|
nAnim = xsprite[nXSprite].data1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
if (tilehasmodelorvoxel(pTSprite->picnum, pTSprite->pal) && !(spriteext[nSprite].flags&SPREXT_NOTMD))
|
|
|
|
{
|
|
|
|
pTSprite->cstat &= ~4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
int dX = cX - pTSprite->x;
|
|
|
|
int dY = cY - pTSprite->y;
|
|
|
|
RotateVector(&dX, &dY, 128-pTSprite->ang);
|
|
|
|
nAnim = GetOctant(dX, dY);
|
|
|
|
if (nAnim <= 4)
|
|
|
|
{
|
|
|
|
pTSprite->cstat &= ~4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nAnim = 8 - nAnim;
|
|
|
|
pTSprite->cstat |= 4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
if (tilehasmodelorvoxel(pTSprite->picnum, pTSprite->pal) && !(spriteext[nSprite].flags&SPREXT_NOTMD))
|
|
|
|
{
|
|
|
|
pTSprite->cstat &= ~4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
int dX = cX - pTSprite->x;
|
|
|
|
int dY = cY - pTSprite->y;
|
|
|
|
RotateVector(&dX, &dY, 128-pTSprite->ang);
|
|
|
|
nAnim = GetOctant(dX, dY);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
if (nXSprite > 0)
|
|
|
|
{
|
2021-08-29 17:09:29 +00:00
|
|
|
if (owneractor->hit.florhit.type == kHitNone)
|
2020-08-02 17:59:14 +00:00
|
|
|
nAnim = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
|
|
|
if (getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) > bottom)
|
|
|
|
nAnim = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
if (hw_models && md_tilehasmodel(pTSprite->picnum, pTSprite->pal) >= 0 && !(spriteext[nSprite].flags&SPREXT_NOTMD))
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Can be overridden by def script
|
2020-11-11 12:03:47 +00:00
|
|
|
if (r_voxels && tiletovox[pTSprite->picnum] == -1 && voxelIndex[pTSprite->picnum] != -1 && !(spriteext[nSprite].flags&SPREXT_NOTMD))
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
|
|
|
if ((pTSprite->flags&kHitagRespawn) == 0)
|
|
|
|
{
|
|
|
|
pTSprite->cstat |= 48;
|
|
|
|
pTSprite->cstat &= ~(4|8);
|
|
|
|
pTSprite->yoffset += tileTopOffset(pTSprite->picnum);
|
|
|
|
pTSprite->picnum = voxelIndex[pTSprite->picnum];
|
|
|
|
if ((picanm[nTile].extra&7) == 7)
|
|
|
|
{
|
2020-09-01 18:02:37 +00:00
|
|
|
pTSprite->ang = myclock & 2047;
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (nAnim > 0)
|
|
|
|
{
|
|
|
|
pTSprite->picnum += picanm[pTSprite->picnum].num+1;
|
|
|
|
nAnim--;
|
|
|
|
}
|
|
|
|
|
2020-12-01 22:57:39 +00:00
|
|
|
if ((pTSprite->cstat&48) != 48 && r_voxels && !(spriteext[nSprite].flags&SPREXT_NOTMD))
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
|
|
|
int const nRootTile = pTSprite->picnum;
|
|
|
|
int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (tiletovox[nAnimTile] != -1)
|
|
|
|
{
|
|
|
|
pTSprite->yoffset += tileTopOffset(nAnimTile);
|
|
|
|
pTSprite->xoffset += tileLeftOffset(nAnimTile);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int const nVoxel = tiletovox[pTSprite->picnum];
|
|
|
|
|
2021-04-04 08:33:29 +00:00
|
|
|
if (nVoxel != -1 && (picanm[nRootTile].extra & 7) == 7)
|
2021-09-05 10:25:52 +00:00
|
|
|
pTSprite->cstat2 |= CSTAT2_SPRITE_MDLROTATE; // per-sprite rotation setting.
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((pTSprite->cstat&48) != 48 && hw_models && !(spriteext[nSprite].flags&SPREXT_NOTMD))
|
|
|
|
{
|
|
|
|
int const nRootTile = pTSprite->picnum;
|
|
|
|
int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner);
|
|
|
|
|
|
|
|
if (tile2model[Ptile2tile(nAnimTile, pTSprite->pal)].modelid >= 0 &&
|
|
|
|
tile2model[Ptile2tile(nAnimTile, pTSprite->pal)].framenum >= 0)
|
|
|
|
{
|
|
|
|
pTSprite->yoffset += tileTopOffset(nAnimTile);
|
|
|
|
pTSprite->xoffset += tileLeftOffset(nAnimTile);
|
|
|
|
|
|
|
|
if ((picanm[nRootTile].extra&7) == 7)
|
2021-09-05 10:25:52 +00:00
|
|
|
pTSprite->cstat2 |= CSTAT2_SPRITE_MDLROTATE; // per-sprite rotation setting.
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sectortype *pSector = §or[pTSprite->sectnum];
|
|
|
|
XSECTOR *pXSector;
|
|
|
|
int nShade = pTSprite->shade;
|
|
|
|
if (pSector->extra > 0)
|
|
|
|
{
|
|
|
|
pXSector = &xsector[pSector->extra];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pXSector = NULL;
|
|
|
|
}
|
|
|
|
if ((pSector->ceilingstat&1) && (pSector->floorstat&32768) == 0)
|
|
|
|
{
|
|
|
|
nShade += tileShade[pSector->ceilingpicnum]+pSector->ceilingshade;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nShade += tileShade[pSector->floorpicnum]+pSector->floorshade;
|
|
|
|
}
|
|
|
|
nShade += tileShade[pTSprite->picnum];
|
|
|
|
pTSprite->shade = ClipRange(nShade, -128, 127);
|
|
|
|
if ((pTSprite->flags&kHitagRespawn) && sprite[pTSprite->owner].owner == 3)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pTXSprite != NULL);
|
2020-08-02 17:59:14 +00:00
|
|
|
pTSprite->xrepeat = 48;
|
|
|
|
pTSprite->yrepeat = 48;
|
|
|
|
pTSprite->shade = -128;
|
|
|
|
pTSprite->picnum = 2272 + 2*pTXSprite->respawnPending;
|
|
|
|
pTSprite->cstat &= ~514;
|
|
|
|
if (((IsItemSprite(pTSprite) || IsAmmoSprite(pTSprite)) && gGameOptions.nItemSettings == 2)
|
|
|
|
|| (IsWeaponSprite(pTSprite) && gGameOptions.nWeaponSettings == 3))
|
|
|
|
{
|
|
|
|
pTSprite->xrepeat = pTSprite->yrepeat = 48;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pTSprite->xrepeat = pTSprite->yrepeat = 0;
|
|
|
|
}
|
|
|
|
}
|
2021-03-25 22:16:32 +00:00
|
|
|
if (spritesortcnt >= MAXSPRITESONSCREEN) continue;
|
2020-08-02 17:59:14 +00:00
|
|
|
if (pTXSprite && pTXSprite->burnTime > 0)
|
|
|
|
{
|
|
|
|
pTSprite->shade = ClipRange(pTSprite->shade-16-QRandom(8), -128, 127);
|
|
|
|
}
|
|
|
|
if (pTSprite->flags&256)
|
|
|
|
{
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectSmokeHigh);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
if (pTSprite->flags&1024)
|
|
|
|
{
|
|
|
|
pTSprite->cstat |= 4;
|
|
|
|
}
|
|
|
|
if (pTSprite->flags&2048)
|
|
|
|
{
|
|
|
|
pTSprite->cstat |= 8;
|
|
|
|
}
|
|
|
|
switch (pTSprite->statnum) {
|
|
|
|
case kStatDecoration: {
|
|
|
|
switch (pTSprite->type) {
|
|
|
|
case kDecorationCandle:
|
|
|
|
if (!pTXSprite || pTXSprite->state == 1) {
|
|
|
|
pTSprite->shade = -128;
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectPhase);
|
2020-08-02 17:59:14 +00:00
|
|
|
} else {
|
|
|
|
pTSprite->shade = -8;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kDecorationTorch:
|
|
|
|
if (!pTXSprite || pTXSprite->state == 1) {
|
|
|
|
pTSprite->picnum++;
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectTorchHigh);
|
2020-08-02 17:59:14 +00:00
|
|
|
} else {
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectSmokeHigh);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
viewApplyDefaultPal(pTSprite, pSector);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kStatItem: {
|
|
|
|
switch (pTSprite->type) {
|
|
|
|
case kItemFlagABase:
|
|
|
|
if (pTXSprite && pTXSprite->state > 0 && gGameOptions.nGameType == 3) {
|
2021-06-16 19:13:04 +00:00
|
|
|
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectBigFlag);
|
2020-08-02 17:59:14 +00:00
|
|
|
if (pNTSprite) pNTSprite->pal = 10;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kItemFlagBBase:
|
|
|
|
if (pTXSprite && pTXSprite->state > 0 && gGameOptions.nGameType == 3) {
|
2021-06-16 19:13:04 +00:00
|
|
|
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectBigFlag);
|
2020-08-02 17:59:14 +00:00
|
|
|
if (pNTSprite) pNTSprite->pal = 7;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kItemFlagA:
|
|
|
|
pTSprite->pal = 10;
|
|
|
|
pTSprite->cstat |= 1024;
|
|
|
|
break;
|
|
|
|
case kItemFlagB:
|
|
|
|
pTSprite->pal = 7;
|
|
|
|
pTSprite->cstat |= 1024;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (pTSprite->type >= kItemKeySkull && pTSprite->type < kItemKeyMax)
|
|
|
|
pTSprite->shade = -128;
|
|
|
|
|
|
|
|
viewApplyDefaultPal(pTSprite, pSector);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kStatProjectile: {
|
|
|
|
switch (pTSprite->type) {
|
|
|
|
case kMissileTeslaAlt:
|
|
|
|
pTSprite->yrepeat = 128;
|
|
|
|
pTSprite->cstat |= 32;
|
|
|
|
break;
|
|
|
|
case kMissileTeslaRegular:
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectTesla);
|
2020-08-02 17:59:14 +00:00
|
|
|
break;
|
|
|
|
case kMissileButcherKnife:
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectTrail);
|
2020-08-02 17:59:14 +00:00
|
|
|
break;
|
|
|
|
case kMissileFlareRegular:
|
|
|
|
case kMissileFlareAlt:
|
|
|
|
if (pTSprite->statnum == kStatFlare) {
|
2021-08-29 16:13:15 +00:00
|
|
|
if (owneractor->GetTarget() == gView->actor())
|
|
|
|
{
|
2020-08-02 17:59:14 +00:00
|
|
|
pTSprite->xrepeat = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectFlareHalo);
|
2020-08-02 17:59:14 +00:00
|
|
|
if (pTSprite->type != kMissileFlareRegular) break;
|
|
|
|
sectortype *pSector = §or[pTSprite->sectnum];
|
|
|
|
|
|
|
|
int zDiff = (pTSprite->z - pSector->ceilingz) >> 8;
|
|
|
|
if ((pSector->ceilingstat&1) == 0 && zDiff < 64) {
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectCeilGlow);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zDiff = (pSector->floorz - pTSprite->z) >> 8;
|
|
|
|
if ((pSector->floorstat&1) == 0 && zDiff < 64) {
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectFloorGlow);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kStatDude:
|
|
|
|
{
|
|
|
|
if (pTSprite->type == kDudeHand && pTXSprite->aiState == &hand13A3B4)
|
|
|
|
{
|
2021-08-29 16:13:15 +00:00
|
|
|
auto target = owneractor->GetTarget();
|
|
|
|
if (target && target->IsPlayerActor())
|
2020-08-02 17:59:14 +00:00
|
|
|
{
|
|
|
|
pTSprite->xrepeat = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-13 18:33:21 +00:00
|
|
|
if (pXSector && pXSector->color) copyfloorpal(pTSprite, pSector);
|
2020-08-02 17:59:14 +00:00
|
|
|
if (powerupCheck(gView, kPwUpBeastVision) > 0) pTSprite->shade = -128;
|
|
|
|
|
|
|
|
if (IsPlayerSprite(pTSprite)) {
|
|
|
|
PLAYER *pPlayer = &gPlayer[pTSprite->type-kDudePlayer1];
|
|
|
|
if (powerupCheck(pPlayer, kPwUpShadowCloak) && !powerupCheck(gView, kPwUpBeastVision)) {
|
|
|
|
pTSprite->cstat |= 2;
|
|
|
|
pTSprite->pal = 5;
|
|
|
|
} else if (powerupCheck(pPlayer, kPwUpDeathMask)) {
|
|
|
|
pTSprite->shade = -128;
|
|
|
|
pTSprite->pal = 5;
|
|
|
|
} else if (powerupCheck(pPlayer, kPwUpDoppleganger)) {
|
|
|
|
pTSprite->pal = 11+(gView->teamId&3);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (powerupCheck(pPlayer, kPwUpReflectShots)) {
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectReflectiveBall);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cl_showweapon && gGameOptions.nGameType > 0 && gView) {
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShowWeapon);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pPlayer->flashEffect && (gView != pPlayer || gViewPos != VIEWPOS_0)) {
|
2021-06-16 19:13:04 +00:00
|
|
|
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShoot);
|
2020-08-02 17:59:14 +00:00
|
|
|
if (pNTSprite) {
|
|
|
|
POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
|
2021-01-04 11:36:54 +00:00
|
|
|
pNTSprite->x += MulScale(pPosture->zOffset, Cos(pTSprite->ang), 28);
|
|
|
|
pNTSprite->y += MulScale(pPosture->zOffset, Sin(pTSprite->ang), 28);
|
2020-08-02 17:59:14 +00:00
|
|
|
pNTSprite->z = pPlayer->pSprite->z-pPosture->xOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPlayer->hasFlag > 0 && gGameOptions.nGameType == 3) {
|
|
|
|
if (pPlayer->hasFlag&1) {
|
2021-06-16 19:13:04 +00:00
|
|
|
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectFlag);
|
2020-08-02 17:59:14 +00:00
|
|
|
if (pNTSprite)
|
|
|
|
{
|
|
|
|
pNTSprite->pal = 10;
|
|
|
|
pNTSprite->cstat |= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pPlayer->hasFlag&2) {
|
2021-06-16 19:13:04 +00:00
|
|
|
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectFlag);
|
2020-08-02 17:59:14 +00:00
|
|
|
if (pNTSprite)
|
|
|
|
{
|
|
|
|
pNTSprite->pal = 7;
|
|
|
|
pNTSprite->cstat |= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pTSprite->owner != gView->pSprite->index || gViewPos != VIEWPOS_0) {
|
|
|
|
if (getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) >= cZ)
|
|
|
|
{
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShadow);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-23 09:12:32 +00:00
|
|
|
|
|
|
|
if (gModernMap) { // add target spot indicator for patrol dudes
|
|
|
|
XSPRITE* pTXSprite = &xsprite[pTSprite->extra];
|
|
|
|
if (pTXSprite->dudeFlag4 && aiInPatrolState(pTXSprite->aiState) && pTXSprite->data3 > 0 && pTXSprite->data3 <= kMaxPatrolSpotValue)
|
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectSpotProgress);
|
|
|
|
}
|
2020-08-02 17:59:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kStatTraps: {
|
|
|
|
if (pTSprite->type == kTrapSawCircular) {
|
|
|
|
if (pTXSprite->state) {
|
|
|
|
if (pTXSprite->data1) {
|
|
|
|
pTSprite->picnum = 772;
|
|
|
|
if (pTXSprite->data2)
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectSpear);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pTXSprite->data1) pTSprite->picnum = 773;
|
|
|
|
else pTSprite->picnum = 656;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kStatThing: {
|
|
|
|
viewApplyDefaultPal(pTSprite, pSector);
|
|
|
|
|
2021-08-29 17:09:29 +00:00
|
|
|
if (pTSprite->type < kThingBase || pTSprite->type >= kThingMax || owneractor->hit.florhit.type == kHitNone)
|
2021-09-02 18:23:51 +00:00
|
|
|
{
|
2020-08-02 17:59:14 +00:00
|
|
|
if ((pTSprite->flags & kPhysMove) && getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) >= cZ)
|
2021-06-16 19:13:04 +00:00
|
|
|
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShadow);
|
2020-08-02 17:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int nTSprite = spritesortcnt-1; nTSprite >= nViewSprites; nTSprite--)
|
|
|
|
{
|
|
|
|
tspritetype *pTSprite = &tsprite[nTSprite];
|
|
|
|
int nAnim = 0;
|
|
|
|
switch (picanm[pTSprite->picnum].extra&7)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
int dX = cX - pTSprite->x;
|
|
|
|
int dY = cY - pTSprite->y;
|
|
|
|
RotateVector(&dX, &dY, 128-pTSprite->ang);
|
|
|
|
nAnim = GetOctant(dX, dY);
|
|
|
|
if (nAnim <= 4)
|
|
|
|
{
|
|
|
|
pTSprite->cstat &= ~4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nAnim = 8 - nAnim;
|
|
|
|
pTSprite->cstat |= 4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
int dX = cX - pTSprite->x;
|
|
|
|
int dY = cY - pTSprite->y;
|
|
|
|
RotateVector(&dX, &dY, 128-pTSprite->ang);
|
|
|
|
nAnim = GetOctant(dX, dY);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (nAnim > 0)
|
|
|
|
{
|
|
|
|
pTSprite->picnum += picanm[pTSprite->picnum].num+1;
|
|
|
|
nAnim--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-02 08:28:40 +00:00
|
|
|
void GameInterface::processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
|
2021-03-20 22:01:16 +00:00
|
|
|
{
|
2021-04-02 08:28:40 +00:00
|
|
|
viewProcessSprites(tsprite, spritesortcnt, viewx, viewy, viewz, viewang.asbuild(), int(smoothRatio));
|
2021-03-20 22:01:16 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 19:48:23 +00:00
|
|
|
int display_mirror;
|
|
|
|
|
|
|
|
void GameInterface::EnterPortal(spritetype* viewer, int type)
|
|
|
|
{
|
|
|
|
if (type == PORTAL_WALL_MIRROR)
|
|
|
|
{
|
|
|
|
display_mirror++;
|
|
|
|
if (viewer) viewer->cstat &= ~CSTAT_SPRITE_INVISIBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::LeavePortal(spritetype* viewer, int type)
|
|
|
|
{
|
|
|
|
if (type == PORTAL_WALL_MIRROR)
|
|
|
|
{
|
|
|
|
display_mirror--;
|
|
|
|
if (viewer && display_mirror == 0 && !(viewer->cstat & CSTAT_SPRITE_TRANSLUCENT)) viewer->cstat |= CSTAT_SPRITE_INVISIBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-02 17:59:14 +00:00
|
|
|
END_BLD_NS
|