2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed 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.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "aistuff.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "sequence.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2021-11-21 19:13:19 +00:00
|
|
|
int nMagicSeq = -1;
|
|
|
|
int nPreMagicSeq = -1;
|
|
|
|
int nSavePointSeq = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 23:47:53 +00:00
|
|
|
|
|
|
|
void SerializeAnim(FSerializer& arc)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject("anims"))
|
|
|
|
{
|
|
|
|
arc("magic", nMagicSeq)
|
|
|
|
("premagic", nPreMagicSeq)
|
|
|
|
("savepoint", nSavePointSeq)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 23:47:53 +00:00
|
|
|
void InitAnims()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
nMagicSeq = SeqOffsets[kSeqItems] + 21;
|
|
|
|
nPreMagicSeq = SeqOffsets[kSeqMagic2];
|
|
|
|
nSavePointSeq = SeqOffsets[kSeqItems] + 12;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-24 18:21:27 +00:00
|
|
|
void DestroyAnim(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
if (pActor)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
StopActorSound(pActor);
|
2021-10-24 18:13:17 +00:00
|
|
|
runlist_SubRunRec(pActor->nRun);
|
2021-12-23 16:02:05 +00:00
|
|
|
runlist_DoSubRunRec(pActor->spr.extra);
|
|
|
|
runlist_FreeRun(pActor->spr.lotag - 1);
|
2021-10-24 18:21:27 +00:00
|
|
|
DeleteActor(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-22 22:35:11 +00:00
|
|
|
DExhumedActor* BuildAnim(DExhumedActor* pActor, int val, int val2, int x, int y, int z, sectortype* pSector, int nRepeat, int nFlag)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
if (pActor == nullptr) {
|
2021-11-22 22:35:11 +00:00
|
|
|
pActor = insertActor(pSector, 500);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-12-23 16:02:05 +00:00
|
|
|
pActor->spr.pos.X = x;
|
|
|
|
pActor->spr.pos.Y = y;
|
|
|
|
pActor->spr.pos.Z = z;
|
|
|
|
pActor->spr.cstat = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nFlag & 4)
|
|
|
|
{
|
2021-12-23 16:02:05 +00:00
|
|
|
pActor->spr.pal = 4;
|
|
|
|
pActor->spr.shade = -64;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 16:02:05 +00:00
|
|
|
pActor->spr.pal = 0;
|
|
|
|
pActor->spr.shade = -12;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 16:02:05 +00:00
|
|
|
pActor->spr.clipdist = 10;
|
|
|
|
pActor->spr.xrepeat = nRepeat;
|
|
|
|
pActor->spr.yrepeat = nRepeat;
|
|
|
|
pActor->spr.picnum = 1;
|
|
|
|
pActor->spr.ang = 0;
|
|
|
|
pActor->spr.xoffset = 0;
|
|
|
|
pActor->spr.yoffset = 0;
|
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
|
|
|
pActor->spr.zvel = 0;
|
|
|
|
pActor->spr.backuppos();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
// CHECKME - where is hitag set otherwise?
|
2021-12-23 16:02:05 +00:00
|
|
|
if (pActor->spr.statnum < 900) {
|
|
|
|
pActor->spr.hitag = -1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 16:02:05 +00:00
|
|
|
pActor->spr.lotag = runlist_HeadRun() + 1;
|
|
|
|
pActor->spr.owner = -1;
|
|
|
|
pActor->spr.extra = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x100000);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 18:21:27 +00:00
|
|
|
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x100000);
|
2021-10-24 18:13:17 +00:00
|
|
|
pActor->nAction = nFlag;
|
|
|
|
pActor->nIndex = 0;
|
|
|
|
pActor->nIndex2 = SeqOffsets[val] + val2;
|
2021-10-24 18:21:27 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2021-11-08 00:13:54 +00:00
|
|
|
pActor->nDamage = pActor->nRun;
|
|
|
|
pActor->nPhase = ITEM_MAGIC;
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nFlag & 0x80) {
|
2021-12-23 16:02:05 +00:00
|
|
|
pActor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT; // set transluscence
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-24 18:21:27 +00:00
|
|
|
return pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 19:06:53 +00:00
|
|
|
void AIAnim::Tick(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-21 19:13:19 +00:00
|
|
|
int nIndex2 = pActor->nIndex2;
|
|
|
|
int nIndex = pActor->nIndex;
|
2021-10-15 19:06:53 +00:00
|
|
|
|
2021-12-23 16:02:05 +00:00
|
|
|
if (!(pActor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
seq_MoveSequence(pActor, nIndex2, nIndex);
|
2021-10-15 19:06:53 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 16:02:05 +00:00
|
|
|
if (pActor->spr.statnum == kStatIgnited)
|
2021-10-15 19:06:53 +00:00
|
|
|
{
|
2021-12-07 17:53:02 +00:00
|
|
|
DExhumedActor* pIgniter = pActor->pTarget;
|
2021-10-24 18:21:27 +00:00
|
|
|
|
|
|
|
if (pIgniter)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-16 22:01:06 +00:00
|
|
|
auto pSpriteB = &pIgniter->s();
|
2021-12-23 16:02:05 +00:00
|
|
|
pActor->spr.pos.X = pSpriteB->pos.X;
|
|
|
|
pActor->spr.pos.Y = pSpriteB->pos.Y;
|
|
|
|
pActor->spr.pos.Z = pSpriteB->pos.Z;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:02:05 +00:00
|
|
|
if (pSpriteB->sector() != pActor->spr.sector())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-22 22:16:21 +00:00
|
|
|
if (!pSpriteB->sector())
|
2021-10-15 19:06:53 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
DestroyAnim(pActor);
|
2021-10-15 19:06:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-22 22:16:21 +00:00
|
|
|
ChangeActorSect(pActor, pSpriteB->sector());
|
2021-10-15 19:06:53 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-24 18:21:27 +00:00
|
|
|
if (!nIndex)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-18 17:40:25 +00:00
|
|
|
if (pSpriteB->cstat != CSTAT_SPRITE_INVISIBLE)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-21 19:13:19 +00:00
|
|
|
int hitag2 = pSpriteB->hitag;
|
2021-10-15 19:06:53 +00:00
|
|
|
pSpriteB->hitag--;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:06:53 +00:00
|
|
|
if (hitag2 >= 15)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
runlist_DamageEnemy(pIgniter, nullptr, (pSpriteB->hitag - 14) * 2);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:06:53 +00:00
|
|
|
if (pSpriteB->shade < 100)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 19:06:53 +00:00
|
|
|
pSpriteB->pal = 0;
|
|
|
|
pSpriteB->shade++;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 19:06:53 +00:00
|
|
|
|
2021-12-18 18:08:55 +00:00
|
|
|
if (!(pSpriteB->cstat & CSTAT_SPRITE_BLOCK_ALL)) // was 101 (decimal), GDX had 0x101 which appears to be correct.
|
2019-11-30 16:04:59 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
DestroyAnim(pActor);
|
2021-10-15 19:06:53 +00:00
|
|
|
return;
|
2019-11-30 16:04:59 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 19:06:53 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pSpriteB->hitag = 1;
|
2021-10-24 18:21:27 +00:00
|
|
|
DestroyAnim(pActor);
|
2021-10-15 19:06:53 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-15 19:06:53 +00:00
|
|
|
pSpriteB->hitag = 1;
|
2021-10-24 18:21:27 +00:00
|
|
|
DestroyAnim(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-15 19:06:53 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 18:13:17 +00:00
|
|
|
pActor->nIndex++;
|
2021-10-24 18:21:27 +00:00
|
|
|
if (pActor->nIndex >= SeqSize[nIndex2])
|
2021-10-15 19:06:53 +00:00
|
|
|
{
|
2021-10-24 18:13:17 +00:00
|
|
|
if (pActor->nAction & 0x10)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 18:13:17 +00:00
|
|
|
pActor->nIndex = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-24 18:21:27 +00:00
|
|
|
else if (nIndex2 == nPreMagicSeq)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 18:13:17 +00:00
|
|
|
pActor->nIndex = 0;
|
|
|
|
pActor->nIndex2 = nMagicSeq;
|
|
|
|
pActor->nAction |= 0x10;
|
2021-12-23 16:02:05 +00:00
|
|
|
pActor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-24 18:21:27 +00:00
|
|
|
else if (nIndex2 == nSavePointSeq)
|
2021-10-15 19:06:53 +00:00
|
|
|
{
|
2021-10-24 18:13:17 +00:00
|
|
|
pActor->nIndex = 0;
|
|
|
|
pActor->nIndex2++;
|
|
|
|
pActor->nAction |= 0x10;
|
2021-10-15 19:06:53 +00:00
|
|
|
}
|
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
DestroyAnim(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 19:06:53 +00:00
|
|
|
void AIAnim::Draw(RunListEvent* ev)
|
|
|
|
{
|
2021-10-24 18:21:27 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2021-11-21 19:13:19 +00:00
|
|
|
int nIndex2 = pActor->nIndex2;
|
2021-10-15 19:06:53 +00:00
|
|
|
|
2021-10-24 18:21:27 +00:00
|
|
|
seq_PlotSequence(ev->nParam, nIndex2, pActor->nIndex, 0x101);
|
2021-12-04 18:08:50 +00:00
|
|
|
ev->pTSprite->ownerActor = nullptr;
|
2021-10-15 19:06:53 +00:00
|
|
|
}
|
|
|
|
|
2021-10-24 17:18:11 +00:00
|
|
|
void BuildExplosion(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-12-23 16:02:05 +00:00
|
|
|
auto pSector = pActor->spr.sector();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int edx = 36;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-22 22:16:21 +00:00
|
|
|
if (pSector->Flag & kSectUnderwater)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
edx = 75;
|
|
|
|
}
|
2021-12-23 16:02:05 +00:00
|
|
|
else if (pActor->spr.pos.Z == pActor->spr.sector()->floorz)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
edx = 34;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-12-23 16:02:05 +00:00
|
|
|
BuildAnim(nullptr, edx, 0, pActor->spr.pos.X, pActor->spr.pos.Y, pActor->spr.pos.Z, pActor->spr.sector(), pActor->spr.xrepeat, 4);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:44:43 +00:00
|
|
|
void BuildSplash(DExhumedActor* pActor, sectortype* pSector)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int nRepeat, nSound;
|
|
|
|
|
2021-12-23 16:02:05 +00:00
|
|
|
if (pActor->spr.statnum != 200)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-23 16:02:05 +00:00
|
|
|
nRepeat = pActor->spr.xrepeat + (RandomWord() % pActor->spr.xrepeat);
|
2019-08-31 07:47:15 +00:00
|
|
|
nSound = kSound0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nRepeat = 20;
|
|
|
|
nSound = kSound1;
|
|
|
|
}
|
|
|
|
|
2021-11-22 21:38:27 +00:00
|
|
|
int bIsLava = pSector->Flag & kSectLava;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
int edx, nFlag;
|
|
|
|
|
|
|
|
if (bIsLava)
|
|
|
|
{
|
|
|
|
edx = 43;
|
|
|
|
nFlag = 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edx = 35;
|
|
|
|
nFlag = 0;
|
|
|
|
}
|
|
|
|
|
2021-12-23 16:02:05 +00:00
|
|
|
auto pSpawned = BuildAnim(nullptr, edx, 0, pActor->spr.pos.X, pActor->spr.pos.Y, pSector->floorz, pSector, nRepeat, nFlag);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (!bIsLava)
|
|
|
|
{
|
2021-12-23 16:02:05 +00:00
|
|
|
D3PlayFX(StaticSound[nSound] | 0xa00, pSpawned);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|