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
|
|
|
};
|
|
|
|
|
2021-11-23 00:18:20 +00:00
|
|
|
void BuildSet(DExhumedActor* pActor, int x, int y, int z, sectortype* pSector, int nAngle, int nChannel)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if (pActor == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-23 00:18:20 +00:00
|
|
|
pActor = insertActor(pSector, 120);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
ChangeActorStat(pActor, 120);
|
2022-01-31 22:33:44 +00:00
|
|
|
x = pActor->int_pos().X;
|
|
|
|
y = pActor->int_pos().Y;
|
2022-02-02 23:46:04 +00:00
|
|
|
z = pActor->sector()->int_floorz();
|
2021-12-23 16:08:37 +00:00
|
|
|
nAngle = pActor->spr.ang;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 19:07:15 +00:00
|
|
|
pActor->set_int_pos({ x, y, z });
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
|
|
|
pActor->spr.shade = -12;
|
|
|
|
pActor->spr.clipdist = 110;
|
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
|
|
|
pActor->spr.zvel = 0;
|
|
|
|
pActor->spr.xrepeat = 87;
|
|
|
|
pActor->spr.yrepeat = 96;
|
2021-12-30 15:51:56 +00:00
|
|
|
pActor->spr.pal = pActor->sector()->ceilingpal;
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xoffset = 0;
|
|
|
|
pActor->spr.yoffset = 0;
|
|
|
|
pActor->spr.ang = nAngle;
|
|
|
|
pActor->spr.picnum = 1;
|
|
|
|
pActor->spr.hitag = 0;
|
|
|
|
pActor->spr.lotag = runlist_HeadRun() + 1;
|
|
|
|
pActor->spr.extra = -1;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 1;
|
|
|
|
pActor->nHealth = 8000;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-19 17:53:42 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nCount = 90;
|
|
|
|
pActor->nIndex = 0;
|
|
|
|
pActor->nIndex2 = 0;
|
2021-10-19 17:53:42 +00:00
|
|
|
pActor->nPhase = Counters[kCountSet]++;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nChannel = nChannel;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-05-23 22:30:41 +00:00
|
|
|
pActor->spr.intowner = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x190000);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
// this isn't stored anywhere.
|
2021-10-19 17:53:42 +00:00
|
|
|
runlist_AddRunRec(NewRun, pActor, 0x190000);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-08-23 12:39:14 +00:00
|
|
|
nCreaturesTotal++;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
void BuildSoul(DExhumedActor* pSet)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pActor = insertActor(pSet->sector(), 0);
|
2021-12-23 16:08:37 +00:00
|
|
|
|
|
|
|
pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
|
|
|
pActor->spr.shade = -127;
|
|
|
|
pActor->spr.xrepeat = 1;
|
|
|
|
pActor->spr.yrepeat = 1;
|
|
|
|
pActor->spr.pal = 0;
|
|
|
|
pActor->spr.clipdist = 5;
|
|
|
|
pActor->spr.xoffset = 0;
|
|
|
|
pActor->spr.yoffset = 0;
|
|
|
|
pActor->spr.picnum = seq_GetSeqPicnum(kSeqSet, 75, 0);
|
|
|
|
pActor->spr.ang = RandomSize(11);
|
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
|
|
|
pActor->spr.zvel = (-256) - RandomSize(10);
|
2022-02-02 23:46:04 +00:00
|
|
|
pActor->set_int_pos({ pSet->int_pos().X, pSet->int_pos().Y, (RandomSize(8) << 8) + 8192 + pActor->sector()->int_ceilingz() - GetActorHeight(pActor) });
|
2021-12-23 16:08:37 +00:00
|
|
|
|
|
|
|
//pActor->spr.hitag = nSet;
|
2021-10-19 17:53:42 +00:00
|
|
|
pActor->pTarget = pSet;
|
|
|
|
pActor->nPhase = Counters[kCountSoul]++;
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.lotag = runlist_HeadRun() + 1;
|
|
|
|
pActor->spr.extra = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
// GrabTimeSlot(3);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-05-23 22:30:41 +00:00
|
|
|
pActor->spr.intowner = runlist_AddRunRec(NewRun, pActor, 0x230000);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
void AISoul::Tick(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
|
|
|
|
|
|
|
seq_MoveSequence(pActor, SeqOffsets[kSeqSet] + 75, 0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
if (pActor->spr.xrepeat < 32)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xrepeat++;
|
|
|
|
pActor->spr.yrepeat++;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.extra += (pActor->nPhase & 0x0F) + 5;
|
|
|
|
pActor->spr.extra &= kAngleMask;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
int nVel = bcos(pActor->spr.extra, -7);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
auto coll = movesprite(pActor, bcos(pActor->spr.ang) * nVel, bsin(pActor->spr.ang) * nVel, pActor->spr.zvel, 5120, 0, CLIPMASK0);
|
2021-10-19 17:53:42 +00:00
|
|
|
if (coll.exbits & 0x10000)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-12-07 17:53:02 +00:00
|
|
|
DExhumedActor* pSet = pActor->pTarget;
|
2021-10-19 17:53:42 +00:00
|
|
|
if (!pSet) return;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.cstat = 0;
|
|
|
|
pActor->spr.yrepeat = 1;
|
|
|
|
pActor->spr.xrepeat = 1;
|
2022-01-31 22:33:44 +00:00
|
|
|
pActor->set_int_pos({ pSet->int_pos().X, pSet->int_pos().Y, pSet->int_pos().Z - (GetActorHeight(pSet) >> 1) });
|
2021-12-30 15:51:56 +00:00
|
|
|
ChangeActorSect(pActor, pSet->sector());
|
2021-10-15 21:18:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
void AISet::RadialDamage(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2021-11-21 20:09:27 +00:00
|
|
|
int nAction = pActor->nAction;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
if (nAction == 5)
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
ev->nDamage = runlist_CheckRadialDamage(pActor);
|
2021-10-15 21:18:58 +00:00
|
|
|
// fall through to case 0x80000
|
|
|
|
}
|
|
|
|
Damage(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AISet::Damage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2020-03-02 21:08:31 +00:00
|
|
|
|
2021-11-21 20:09:27 +00:00
|
|
|
int nAction = pActor->nAction;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
if (ev->nDamage && pActor->nHealth > 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:18:58 +00:00
|
|
|
if (nAction != 1)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nHealth -= dmgAdjust(ev->nDamage);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
if (pActor->nHealth <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
|
|
|
pActor->spr.zvel = 0;
|
|
|
|
pActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nHealth = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
|
|
|
nCreaturesKilled++;
|
|
|
|
|
|
|
|
if (nAction < 10)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nAction = 10;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
else if (nAction == 1)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 2;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
void AISet::Draw(RunListEvent* ev)
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2021-11-21 20:09:27 +00:00
|
|
|
int nAction = pActor->nAction;
|
2020-03-02 21:08:31 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqSet] + SetSeq[nAction].a, pActor->nFrame, SetSeq[nAction].b);
|
2021-10-15 21:18:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
void AISet::Tick(RunListEvent* ev)
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-11-21 20:09:27 +00:00
|
|
|
int nAction = pActor->nAction;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
|
|
|
bool bVal = false;
|
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
Gravity(pActor);
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-11-21 20:09:27 +00:00
|
|
|
int nSeq = SeqOffsets[kSeqSet] + SetSeq[pActor->nAction].a;
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
|
2021-10-19 17:53:42 +00:00
|
|
|
seq_MoveSequence(pActor, nSeq, pActor->nFrame);
|
2021-10-15 21:18:58 +00:00
|
|
|
|
|
|
|
if (nAction == 3)
|
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
if (pActor->nIndex2) {
|
|
|
|
pActor->nFrame++;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nFrame++;
|
|
|
|
if (pActor->nFrame >= SeqSize[nSeq])
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
bVal = true;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-21 20:09:27 +00:00
|
|
|
int nFlag = FrameFlag[SeqBase[nSeq] + pActor->nFrame];
|
2021-12-07 17:53:02 +00:00
|
|
|
DExhumedActor* pTarget = pActor->pTarget;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
if (pTarget && nAction < 10)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-12-21 22:18:23 +00:00
|
|
|
if (!(pTarget->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-19 17:53:42 +00:00
|
|
|
pTarget = nullptr;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
auto nMov = MoveCreature(pActor);
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sect = pActor->sector();
|
2022-01-31 19:07:15 +00:00
|
|
|
pushmove(pActor, §, pActor->spr.clipdist << 2, 5120, -5120, CLIPMASK0);
|
2021-12-30 15:36:04 +00:00
|
|
|
pActor->setsector(sect);
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
if (pActor->spr.zvel > 4000)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if (nMov.exbits & kHitAux2)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
SetQuake(pActor, 100);
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
switch (nAction)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 0:
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if ((pActor->nPhase & 0x1F) == (totalmoves & 0x1F))
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if (pTarget == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
pTarget = FindPlayer(pActor, 1000);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
if (pTarget)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 3;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-19 17:53:42 +00:00
|
|
|
pActor->pTarget = pTarget;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = bcos(pActor->spr.ang, -1);
|
|
|
|
pActor->spr.yvel = bsin(pActor->spr.ang, -1);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 1:
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if (FindPlayer(pActor, 1000))
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nCount--;
|
|
|
|
if (pActor->nCount <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 2;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
if (bVal)
|
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 7;
|
|
|
|
pActor->nIndex = 0;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
pActor->pTarget = FindPlayer(pActor, 1000);
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if (pTarget != nullptr)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if ((nFlag & 0x10) && (nMov.exbits & kHitAux2))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
SetQuake(pActor, 100);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
int nCourse = PlotCourseToSprite(pActor, pTarget);
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
if ((pActor->nPhase & 0x1F) == (totalmoves & 0x1F))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:18:58 +00:00
|
|
|
int nRand = RandomSize(3);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
switch (nRand)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
case 0:
|
2021-10-15 21:18:58 +00:00
|
|
|
case 2:
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nIndex = 0;
|
|
|
|
pActor->nAction = 7;
|
|
|
|
pActor->nFrame = 0;
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
PlotCourseToSprite(pActor, pTarget);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 6;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nRun = 5;
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
default:
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:18:58 +00:00
|
|
|
if (nCourse <= 100)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nIndex2 = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nIndex2 = 1;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
// loc_338E2
|
2021-12-23 16:08:37 +00:00
|
|
|
int nAngle = pActor->spr.ang & 0xFFF8;
|
|
|
|
pActor->spr.xvel = bcos(nAngle, -1);
|
|
|
|
pActor->spr.yvel = bsin(nAngle, -1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
if (pActor->nIndex2)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel *= 2;
|
|
|
|
pActor->spr.yvel *= 2;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
if (nMov.type == kHitWall)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-11-26 13:26:03 +00:00
|
|
|
auto pSector = nMov.hitWall->nextSector();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-22 21:20:53 +00:00
|
|
|
if (pSector)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2022-02-02 23:46:04 +00:00
|
|
|
if ((pActor->int_pos().Z - pSector->int_floorz()) < 55000)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2022-02-02 23:46:04 +00:00
|
|
|
if (pActor->int_pos().Z > pSector->int_ceilingz())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nIndex = 1;
|
|
|
|
pActor->nAction = 7;
|
|
|
|
pActor->nFrame = 0;
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.ang = (pActor->spr.ang + 256) & kAngleMask;
|
|
|
|
pActor->spr.xvel = bcos(pActor->spr.ang, -1);
|
|
|
|
pActor->spr.yvel = bsin(pActor->spr.ang, -1);
|
2021-10-15 21:18:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-10-19 17:53:42 +00:00
|
|
|
else if (nMov.type == kHitSprite)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-11-26 13:26:03 +00:00
|
|
|
if (pTarget == nMov.actor())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2022-01-31 22:33:44 +00:00
|
|
|
int nAng = getangle(pTarget->int_pos().X - pActor->int_pos().X, pTarget->int_pos().Y - pActor->int_pos().Y);
|
2021-12-23 16:08:37 +00:00
|
|
|
if (AngleDiff(pActor->spr.ang, nAng) < 64)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 4;
|
|
|
|
pActor->nFrame = 0;
|
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
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nIndex = 1;
|
|
|
|
pActor->nAction = 7;
|
|
|
|
pActor->nFrame = 0;
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 4:
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if (pTarget == nullptr)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nCount = 50;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if (PlotCourseToSprite(pActor, pTarget) >= 768)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 3;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
else if (nFlag & 0x80)
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
runlist_DamageEnemy(pTarget, pActor, 5);
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
if (bVal)
|
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nCount = 15;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
if (nFlag & 0x80)
|
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
auto pBullet = BuildBullet(pActor, 11, -1, pActor->spr.ang, pTarget, 1);
|
2021-10-19 17:53:42 +00:00
|
|
|
if (pBullet)
|
2021-10-16 20:04:21 +00:00
|
|
|
SetBulletEnemy(pBullet->nPhase, pTarget);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nRun--;
|
|
|
|
if (pActor->nRun <= 0 || !RandomBit())
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
if (bVal)
|
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
if (pActor->nIndex)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.zvel = -10000;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.zvel = -(PlotCourseToSprite(pActor, pTarget));
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 8;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = bcos(pActor->spr.ang);
|
|
|
|
pActor->spr.yvel = bsin(pActor->spr.ang);
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
if (bVal)
|
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nFrame = SeqSize[nSeq] - 1;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
if (nMov.exbits & kHitAux2)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
SetQuake(pActor, 200);
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 9;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 9:
|
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel >>= 1;
|
|
|
|
pActor->spr.yvel >>= 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
if (bVal)
|
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-19 17:53:42 +00:00
|
|
|
PlotCourseToSprite(pActor, pTarget);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 6;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nRun = 5;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 10:
|
|
|
|
{
|
|
|
|
if (nFlag & 0x80)
|
|
|
|
{
|
2022-01-31 19:07:15 +00:00
|
|
|
pActor->add_int_z(-GetActorHeight(pActor));
|
2021-10-26 19:15:07 +00:00
|
|
|
BuildCreatureChunk(pActor, seq_GetSeqPicnum(kSeqSet, 76, 0));
|
2022-01-31 19:07:15 +00:00
|
|
|
pActor->add_int_z(GetActorHeight(pActor));
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bVal)
|
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 11;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
|
2021-10-25 16:57:10 +00:00
|
|
|
runlist_ChangeChannel(pActor->nChannel, 1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
for (int i = 0; i < 20; i++)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
BuildSoul(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:18:58 +00:00
|
|
|
case 11:
|
|
|
|
{
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
2021-10-15 21:18:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_33AE3: ?
|
|
|
|
if (nAction)
|
|
|
|
{
|
2021-10-19 17:53:42 +00:00
|
|
|
if (pTarget)
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-12-21 22:18:23 +00:00
|
|
|
if (!(pTarget->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))
|
2021-10-15 21:18:58 +00:00
|
|
|
{
|
2021-10-25 16:57:10 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nCount = 100;
|
2021-10-19 17:53:42 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2021-12-23 16:08:37 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2021-10-15 21:18:58 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-15 21:18:58 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|