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"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "aistuff.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "sequence.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2020-10-11 09:33:28 +00:00
|
|
|
static actionSeq SetSeq[] = {
|
2019-08-31 07:47:15 +00:00
|
|
|
{0, 0},
|
|
|
|
{77, 1},
|
|
|
|
{78, 1},
|
|
|
|
{0, 0},
|
|
|
|
{9, 0},
|
|
|
|
{63, 0},
|
|
|
|
{45, 0},
|
|
|
|
{18, 0},
|
|
|
|
{27, 0},
|
|
|
|
{36, 0},
|
|
|
|
{72, 1},
|
|
|
|
{74, 1}
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Set
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nHealth;
|
2020-03-02 21:08:31 +00:00
|
|
|
short nFrame;
|
2019-08-31 07:47:15 +00:00
|
|
|
short nAction;
|
|
|
|
short nSprite;
|
|
|
|
short nTarget;
|
2020-11-29 19:59:42 +00:00
|
|
|
short nCount;
|
|
|
|
short nIndex;
|
|
|
|
short nIndex2;
|
|
|
|
short nRun;
|
|
|
|
short nChannel;
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
|
2020-11-29 19:59:42 +00:00
|
|
|
TArray<Set> SetList;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 19:59:42 +00:00
|
|
|
|
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, Set& w, Set* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("health", w.nHealth)
|
|
|
|
("frame", w.nFrame)
|
|
|
|
("action", w.nAction)
|
|
|
|
("sprite", w.nSprite)
|
|
|
|
("target", w.nTarget)
|
|
|
|
("count", w.nCount)
|
|
|
|
("index", w.nIndex)
|
|
|
|
("index2", w.nIndex2)
|
|
|
|
("run", w.nRun)
|
|
|
|
("channel", w.nChannel)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SerializeSet(FSerializer& arc)
|
|
|
|
{
|
|
|
|
arc("set", SetList);
|
|
|
|
}
|
2019-12-26 21:00:04 +00:00
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
void InitSets()
|
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList.Clear();
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
auto nSet = SetList.Reserve(1);
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nSprite == -1)
|
|
|
|
{
|
|
|
|
nSprite = insertsprite(nSector, 120);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
changespritestat(nSprite, 120);
|
|
|
|
x = sprite[nSprite].x;
|
|
|
|
y = sprite[nSprite].y;
|
|
|
|
z = sector[sprite[nSprite].sectnum].floorz;
|
|
|
|
nAngle = sprite[nSprite].ang;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
|
|
|
|
|
|
|
sprite[nSprite].x = x;
|
|
|
|
sprite[nSprite].y = y;
|
|
|
|
sprite[nSprite].z = z;
|
|
|
|
sprite[nSprite].cstat = 0x101;
|
|
|
|
sprite[nSprite].shade = -12;
|
|
|
|
sprite[nSprite].clipdist = 110;
|
|
|
|
sprite[nSprite].xvel = 0;
|
|
|
|
sprite[nSprite].yvel = 0;
|
|
|
|
sprite[nSprite].zvel = 0;
|
|
|
|
sprite[nSprite].xrepeat = 87;
|
|
|
|
sprite[nSprite].yrepeat = 96;
|
|
|
|
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal;
|
|
|
|
sprite[nSprite].xoffset = 0;
|
|
|
|
sprite[nSprite].yoffset = 0;
|
|
|
|
sprite[nSprite].ang = nAngle;
|
|
|
|
sprite[nSprite].picnum = 1;
|
|
|
|
sprite[nSprite].hitag = 0;
|
|
|
|
sprite[nSprite].lotag = runlist_HeadRun() + 1;
|
|
|
|
sprite[nSprite].extra = -1;
|
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
|
|
|
SetList[nSet].nAction = 1;
|
|
|
|
SetList[nSet].nHealth = 8000;
|
|
|
|
SetList[nSet].nSprite = nSprite;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
SetList[nSet].nTarget = -1;
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nCount = 90;
|
|
|
|
SetList[nSet].nIndex = 0;
|
|
|
|
SetList[nSet].nIndex2 = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nChannel = nChannel;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nSet | 0x190000);
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
// this isn't stored anywhere.
|
2019-08-31 07:47:15 +00:00
|
|
|
runlist_AddRunRec(NewRun, nSet | 0x190000);
|
|
|
|
|
2020-08-23 12:39:14 +00:00
|
|
|
nCreaturesTotal++;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
return nSet | 0x190000;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BuildSoul(int nSet)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int nSetSprite = SetList[nSet].nSprite;
|
|
|
|
int nSprite = insertsprite(sprite[nSetSprite].sectnum, 0);
|
|
|
|
|
|
|
|
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].cstat = 0x8000;
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].shade = -127;
|
|
|
|
sprite[nSprite].xrepeat = 1;
|
|
|
|
sprite[nSprite].yrepeat = 1;
|
|
|
|
sprite[nSprite].pal = 0;
|
|
|
|
sprite[nSprite].clipdist = 5;
|
|
|
|
sprite[nSprite].xoffset = 0;
|
|
|
|
sprite[nSprite].yoffset = 0;
|
|
|
|
sprite[nSprite].picnum = seq_GetSeqPicnum(kSeqSet, 75, 0);
|
|
|
|
sprite[nSprite].ang = RandomSize(11);
|
|
|
|
sprite[nSprite].xvel = 0;
|
|
|
|
sprite[nSprite].yvel = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].zvel = (-256) - RandomSize(10);
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].x = sprite[nSetSprite].x;
|
|
|
|
sprite[nSprite].y = sprite[nSetSprite].y;
|
|
|
|
|
|
|
|
short nSector = sprite[nSprite].sectnum;
|
|
|
|
sprite[nSprite].z = (RandomSize(8) << 8) + 8192 + sector[nSector].ceilingz - GetSpriteHeight(nSprite);
|
|
|
|
|
|
|
|
sprite[nSprite].hitag = nSet;
|
|
|
|
sprite[nSprite].lotag = runlist_HeadRun() + 1;
|
|
|
|
sprite[nSprite].extra = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].owner = runlist_AddRunRec(NewRun, nSprite | 0x230000);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return nSprite | 0x230000;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
void FuncSoul(int a, int, int nRun)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
short nSprite = RunData[nRun].nVal;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
int nMessage = a & kMessageMask;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
case 0x20000:
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
seq_MoveSequence(nSprite, SeqOffsets[kSeqSet] + 75, 0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
if (sprite[nSprite].xrepeat < 32)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].xrepeat++;
|
|
|
|
sprite[nSprite].yrepeat++;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].extra += (nSprite & 0x0F) + 5;
|
|
|
|
sprite[nSprite].extra &= kAngleMask;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-14 08:45:08 +00:00
|
|
|
int nVel = bcos(sprite[nSprite].extra, -7);
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2020-11-14 08:45:08 +00:00
|
|
|
if (movesprite(nSprite, bcos(sprite[nSprite].ang) * nVel, bsin(sprite[nSprite].ang) * nVel, sprite[nSprite].zvel, 5120, 0, CLIPMASK0) & 0x10000)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
int nSet = sprite[nSprite].hitag;
|
2019-08-31 07:47:15 +00:00
|
|
|
int nSetSprite = SetList[nSet].nSprite;
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].cstat = 0;
|
|
|
|
sprite[nSprite].yrepeat = 1;
|
|
|
|
sprite[nSprite].xrepeat = 1;
|
|
|
|
sprite[nSprite].x = sprite[nSetSprite].x;
|
|
|
|
sprite[nSprite].y = sprite[nSetSprite].y;
|
|
|
|
sprite[nSprite].z = sprite[nSetSprite].z - (GetSpriteHeight(nSetSprite) >> 1);
|
|
|
|
mychangespritesect(nSprite, sprite[nSetSprite].sectnum);
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x80000:
|
|
|
|
case 0xA0000:
|
|
|
|
case 0x90000:
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2019-11-24 09:03:19 +00:00
|
|
|
Printf("unknown msg %d for Soul\n", nMessage);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuncSet(int a, int nDamage, int nRun)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSet = RunData[nRun].nVal;
|
2020-11-29 19:59:42 +00:00
|
|
|
assert(nSet >= 0 && nSet < (int)SetList.Size());
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
short nSprite = SetList[nSet].nSprite;
|
|
|
|
short nAction = SetList[nSet].nAction;
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
bool bVal = false;
|
|
|
|
|
|
|
|
int nMessage = a & kMessageMask;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
{
|
2019-11-24 09:03:19 +00:00
|
|
|
Printf("unknown msg %d for Set\n", nMessage);
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0xA0000:
|
|
|
|
{
|
|
|
|
if (nAction == 5)
|
|
|
|
{
|
|
|
|
nDamage = runlist_CheckRadialDamage(nSprite);
|
|
|
|
// fall through to case 0x80000
|
|
|
|
}
|
2019-12-02 14:56:24 +00:00
|
|
|
fallthrough__;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case 0x80000:
|
|
|
|
{
|
|
|
|
if (nDamage && SetList[nSet].nHealth > 0)
|
|
|
|
{
|
|
|
|
if (nAction != 1)
|
|
|
|
{
|
|
|
|
SetList[nSet].nHealth -= nDamage;
|
|
|
|
}
|
|
|
|
|
2019-11-14 22:44:31 +00:00
|
|
|
if (SetList[nSet].nHealth <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
sprite[nSprite].xvel = 0;
|
|
|
|
sprite[nSprite].yvel = 0;
|
|
|
|
sprite[nSprite].zvel = 0;
|
|
|
|
sprite[nSprite].cstat &= 0xFEFE;
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nHealth = 0;
|
|
|
|
|
2020-08-23 12:39:14 +00:00
|
|
|
nCreaturesKilled++;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nAction < 10)
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
SetList[nSet].nAction = 10;
|
|
|
|
}
|
|
|
|
}
|
2019-11-14 22:44:31 +00:00
|
|
|
else if (nAction == 1)
|
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 2;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-11-14 22:44:31 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x90000:
|
|
|
|
{
|
2020-10-11 09:33:28 +00:00
|
|
|
seq_PlotSequence(a, SeqOffsets[kSeqSet] + SetSeq[nAction].a, SetList[nSet].nFrame, SetSeq[nAction].b);
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x20000:
|
|
|
|
{
|
|
|
|
Gravity(nSprite);
|
|
|
|
|
2020-10-11 09:33:28 +00:00
|
|
|
short nSeq = SeqOffsets[kSeqSet] + SetSeq[SetList[nSet].nAction].a;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, SetList[nSet].nFrame);
|
|
|
|
seq_MoveSequence(nSprite, nSeq, SetList[nSet].nFrame);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nAction == 3)
|
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
if (SetList[nSet].nIndex2) {
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame++;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame++;
|
|
|
|
if (SetList[nSet].nFrame >= SeqSize[nSeq])
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
|
|
|
bVal = true;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
short nFlag = FrameFlag[SeqBase[nSeq] + SetList[nSet].nFrame];
|
2019-08-31 07:47:15 +00:00
|
|
|
short nTarget = SetList[nSet].nTarget;
|
|
|
|
|
|
|
|
if (nTarget > -1 && nAction < 10)
|
|
|
|
{
|
|
|
|
if (!(sprite[nTarget].cstat & 0x101))
|
|
|
|
{
|
|
|
|
SetList[nSet].nTarget = -1;
|
|
|
|
SetList[nSet].nAction = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
nTarget = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
int nMov = MoveCreature(nSprite);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
pushmove_old(&sprite[nSprite].x, &sprite[nSprite].y, &sprite[nSprite].z, &sprite[nSprite].sectnum, sprite[nSprite].clipdist << 2, 5120, -5120, CLIPMASK0);
|
|
|
|
|
|
|
|
if (sprite[nSprite].zvel > 4000)
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if (nMov & 0x20000)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
SetQuake(nSprite, 100);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (nAction)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if ((nSet & 0x1F) == (totalmoves & 0x1F))
|
|
|
|
{
|
|
|
|
if (nTarget < 0)
|
|
|
|
{
|
|
|
|
nTarget = FindPlayer(nSprite, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nTarget >= 0)
|
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 3;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
SetList[nSet].nTarget = nTarget;
|
|
|
|
|
2020-11-14 08:45:08 +00:00
|
|
|
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
|
|
|
|
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
if (FindPlayer(nSprite, 1000) >= 0)
|
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nCount--;
|
|
|
|
if (SetList[nSet].nCount <= 0)
|
2019-11-14 22:44:31 +00:00
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 2;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-11-14 22:44:31 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if (bVal)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 7;
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nIndex = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].xvel = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
SetList[nSet].nTarget = FindPlayer(nSprite, 1000);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
if (nTarget != -1)
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if ((nFlag & 0x10) && (nMov & 0x20000))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
SetQuake(nSprite, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
int nCourse = PlotCourseToSprite(nSprite, nTarget);
|
|
|
|
|
|
|
|
if ((nSet & 0x1F) == (totalmoves & 0x1F))
|
|
|
|
{
|
2019-11-14 22:44:31 +00:00
|
|
|
int nRand = RandomSize(3);
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
switch (nRand)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 2:
|
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nIndex = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
SetList[nSet].nAction = 7;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].xvel = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
PlotCourseToSprite(nSprite, nTarget);
|
|
|
|
|
|
|
|
SetList[nSet].nAction = 6;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nRun = 5;
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].xvel = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
if (nCourse <= 100)
|
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nIndex2 = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nIndex2 = 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_338E2
|
2020-03-02 21:08:31 +00:00
|
|
|
int nAngle = sprite[nSprite].ang & 0xFFF8;
|
2020-11-14 08:45:08 +00:00
|
|
|
sprite[nSprite].xvel = bcos(nAngle, -1);
|
|
|
|
sprite[nSprite].yvel = bsin(nAngle, -1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-29 19:59:42 +00:00
|
|
|
if (SetList[nSet].nIndex2)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
sprite[nSprite].xvel *= 2;
|
|
|
|
sprite[nSprite].yvel *= 2;
|
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
if ((nMov & 0xC000) == 0x8000)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
short nWall = nMov & 0x3FFF;
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSector = wall[nWall].nextsector;
|
|
|
|
|
|
|
|
if (nSector >= 0)
|
|
|
|
{
|
|
|
|
if ((sprite[nSprite].z - sector[nSector].floorz) < 55000)
|
|
|
|
{
|
|
|
|
if (sprite[nSprite].z > sector[nSector].ceilingz)
|
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nIndex = 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
SetList[nSet].nAction = 7;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].xvel = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 22:22:37 +00:00
|
|
|
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
|
2020-11-14 08:45:08 +00:00
|
|
|
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
|
|
|
|
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
|
2019-08-31 07:47:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-03-02 21:08:31 +00:00
|
|
|
else if ((nMov & 0xC000) == 0xC000)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if (nTarget == (nMov & 0x3FFF))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
int nAng = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y);
|
|
|
|
if (AngleDiff(sprite[nSprite].ang, nAng) < 64)
|
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 4;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nIndex = 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
SetList[nSet].nAction = 7;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].xvel = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-11-14 22:44:31 +00:00
|
|
|
|
|
|
|
break;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
if (nTarget == -1)
|
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 0;
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nCount = 50;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (PlotCourseToSprite(nSprite, nTarget) >= 768)
|
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 3;
|
|
|
|
}
|
2019-10-29 22:17:04 +00:00
|
|
|
else if (nFlag & 0x80)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-10-29 22:17:04 +00:00
|
|
|
runlist_DamageEnemy(nTarget, nSprite, 5);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-29 22:17:04 +00:00
|
|
|
|
|
|
|
break;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if (bVal)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 0;
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nCount = 15;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
if (nFlag & 0x80)
|
|
|
|
{
|
|
|
|
// low 16 bits of returned var contains the sprite index, the high 16 the bullet number
|
|
|
|
int nBullet = BuildBullet(nSprite, 11, 0, 0, -1, sprite[nSprite].ang, nTarget + 10000, 1);
|
2020-09-01 13:00:35 +00:00
|
|
|
SetBulletEnemy(FixedToInt(nBullet), nTarget); // isolate the bullet number (shift off the sprite index)
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nRun--;
|
|
|
|
if (SetList[nSet].nRun <= 0 || !RandomBit())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-11-14 22:44:31 +00:00
|
|
|
SetList[nSet].nAction = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if (bVal)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-11-29 19:59:42 +00:00
|
|
|
if (SetList[nSet].nIndex)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
sprite[nSprite].zvel = -10000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite[nSprite].zvel = -(PlotCourseToSprite(nSprite, nTarget));
|
|
|
|
}
|
|
|
|
|
|
|
|
SetList[nSet].nAction = 8;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-14 08:45:08 +00:00
|
|
|
sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
|
|
|
|
sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if (bVal)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = SeqSize[nSeq] - 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
if (nMov & 0x20000)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
SetQuake(nSprite, 200);
|
|
|
|
SetList[nSet].nAction = 9;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
sprite[nSprite].xvel >>= 1;
|
|
|
|
sprite[nSprite].yvel >>= 1;
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
if (bVal)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
sprite[nSprite].xvel = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
PlotCourseToSprite(nSprite, nTarget);
|
|
|
|
|
|
|
|
SetList[nSet].nAction = 6;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nRun = 5;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
sprite[nSprite].xvel = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 10:
|
|
|
|
{
|
|
|
|
if (nFlag & 0x80)
|
2019-11-14 22:44:31 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nSprite].z -= GetSpriteHeight(nSprite);
|
|
|
|
BuildCreatureChunk(nSprite, seq_GetSeqPicnum(kSeqSet, 76, 0));
|
|
|
|
sprite[nSprite].z += GetSpriteHeight(nSprite);
|
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
if (bVal)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 11;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-29 19:59:42 +00:00
|
|
|
runlist_ChangeChannel(SetList[nSet].nChannel, 1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 20; i++)
|
|
|
|
{
|
|
|
|
BuildSoul(nSet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
sprite[nSprite].cstat &= 0xFEFE;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_33AE3: ?
|
|
|
|
if (nAction)
|
|
|
|
{
|
|
|
|
if (nTarget != -1)
|
|
|
|
{
|
|
|
|
if (!(sprite[nTarget].cstat & 0x101))
|
|
|
|
{
|
|
|
|
SetList[nSet].nAction = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
SetList[nSet].nFrame = 0;
|
2020-11-29 19:59:42 +00:00
|
|
|
SetList[nSet].nCount = 100;
|
2019-08-31 07:47:15 +00:00
|
|
|
SetList[nSet].nTarget = -1;
|
|
|
|
sprite[nSprite].xvel = 0;
|
|
|
|
sprite[nSprite].yvel = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-11-14 22:44:31 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|