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 "sequence.h"
|
|
|
|
#include "exhumed.h"
|
2019-09-21 15:47:55 +00:00
|
|
|
#include "sound.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2020-10-11 09:33:28 +00:00
|
|
|
static actionSeq FishSeq[] = {
|
2019-08-31 07:47:15 +00:00
|
|
|
{8, 0},
|
|
|
|
{8, 0},
|
|
|
|
{0, 0},
|
|
|
|
{24, 0},
|
|
|
|
{8, 0},
|
|
|
|
{32, 1},
|
|
|
|
{33, 1},
|
|
|
|
{34, 1},
|
|
|
|
{35, 1},
|
|
|
|
{39, 1}
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
void BuildFishLimb(DExhumedActor* pActor, short anim)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pChunkActor = insertActor(pSprite->sectnum, 99);
|
|
|
|
auto pSprite2 = &pChunkActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
pChunkActor->nCount = anim + 40;
|
|
|
|
pChunkActor->nFrame = RandomSize(3) % SeqSize[SeqOffsets[kSeqFish] + anim + 40];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite2->x = pSprite->x;
|
|
|
|
pSprite2->y = pSprite->y;
|
|
|
|
pSprite2->z = pSprite->z;
|
|
|
|
pSprite2->cstat = 0;
|
|
|
|
pSprite2->shade = -12;
|
|
|
|
pSprite2->pal = 0;
|
|
|
|
pSprite2->xvel = (RandomSize(5) - 16) << 8;
|
|
|
|
pSprite2->yvel = (RandomSize(5) - 16) << 8;
|
|
|
|
pSprite2->xrepeat = 64;
|
|
|
|
pSprite2->yrepeat = 64;
|
|
|
|
pSprite2->xoffset = 0;
|
|
|
|
pSprite2->yoffset = 0;
|
|
|
|
pSprite2->zvel = (-(RandomByte() + 512)) * 2;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
seq_GetSeqPicnum(kSeqFish, pChunkActor->nCount, 0);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
pSprite2->picnum = anim;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite2->lotag = runlist_HeadRun() + 1;
|
|
|
|
pSprite2->clipdist = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite2->extra = -1;
|
2021-10-23 11:02:43 +00:00
|
|
|
pSprite2->owner = runlist_AddRunRec(pSprite2->lotag - 1, pChunkActor, 0x200000);
|
|
|
|
pSprite2->hitag = runlist_AddRunRec(NewRun, pChunkActor, 0x200000);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 16:27:54 +00:00
|
|
|
void BuildBlood(int x, int y, int z, int nSector)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
BuildAnim(nullptr, kSeqFish, 36, x, y, z, nSector, 75, 128);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
void AIFishLimb::Tick(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
|
|
|
|
|
|
|
auto pSprite = &pActor->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
int nSeq = SeqOffsets[kSeqFish] + pActor->nCount;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
pSprite->picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
Gravity(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
pActor->nFrame++;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
if (pActor->nFrame >= SeqSize[nSeq])
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
pActor->nFrame = 0;
|
2021-10-15 19:17:25 +00:00
|
|
|
if (RandomBit()) {
|
|
|
|
BuildBlood(pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
|
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-08 23:24:04 +00:00
|
|
|
int FloorZ = pSprite->sector()->floorz;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
if (FloorZ <= pSprite->z)
|
|
|
|
{
|
|
|
|
pSprite->z += 256;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
if ((pSprite->z - FloorZ) > 25600)
|
|
|
|
{
|
|
|
|
pSprite->zvel = 0;
|
|
|
|
runlist_DoSubRunRec(pSprite->owner);
|
|
|
|
runlist_FreeRun(pSprite->lotag - 1);
|
|
|
|
runlist_SubRunRec(pSprite->hitag);
|
2021-10-23 11:02:43 +00:00
|
|
|
DeleteActor(pActor);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
else if ((pSprite->z - FloorZ) > 0)
|
|
|
|
{
|
|
|
|
pSprite->zvel = 1024;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto coll = movesprite(pActor, pSprite->xvel << 8, pSprite->yvel << 8, pSprite->zvel, 2560, -2560, CLIPMASK1);
|
|
|
|
if (coll.type != kHitNone)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 19:17:25 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-15 19:17:25 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void AIFishLimb::Draw(RunListEvent* ev)
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (pActor == nullptr) return;
|
|
|
|
int nSeq = SeqOffsets[kSeqFish] + pActor->nCount;
|
|
|
|
seq_PlotSequence(ev->nParam, nSeq, pActor->nFrame, 1);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
void BuildFish(DExhumedActor* pActor, int x, int y, int z, int nSector, int nAngle)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
spritetype* pSprite;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
if (pActor == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
pActor = insertActor(nSector, 103);
|
|
|
|
pSprite = &pActor->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
pSprite = &pActor->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
x = pSprite->x;
|
|
|
|
y = pSprite->y;
|
|
|
|
z = pSprite->z;
|
|
|
|
nAngle = pSprite->ang;
|
2021-10-23 11:02:43 +00:00
|
|
|
ChangeActorStat(pActor, 103);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->x = x;
|
|
|
|
pSprite->y = y;
|
|
|
|
pSprite->z = z;
|
|
|
|
pSprite->cstat = 0x101;
|
|
|
|
pSprite->shade = -12;
|
|
|
|
pSprite->clipdist = 80;
|
|
|
|
pSprite->xrepeat = 40;
|
|
|
|
pSprite->yrepeat = 40;
|
2021-11-08 23:24:04 +00:00
|
|
|
pSprite->pal = pSprite->sector()->ceilingpal;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xoffset = 0;
|
|
|
|
pSprite->yoffset = 0;
|
|
|
|
pSprite->picnum = seq_GetSeqPicnum(kSeqFish, FishSeq[0].a, 0);
|
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = 0;
|
|
|
|
pSprite->ang = nAngle;
|
|
|
|
pSprite->lotag = runlist_HeadRun() + 1;
|
|
|
|
pSprite->hitag = 0;
|
|
|
|
pSprite->extra = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nHealth = 200;
|
2021-10-23 11:02:43 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nCount = 60;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, pActor, 0x120000);
|
|
|
|
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x120000);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 12:39:14 +00:00
|
|
|
nCreaturesTotal++;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
void IdleFish(DExhumedActor* pActor, short edx)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->ang += (256 - RandomSize(9)) + 1024;
|
|
|
|
pSprite->ang &= kAngleMask;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = bcos(pSprite->ang, -8);
|
|
|
|
pSprite->yvel = bsin(pSprite->ang, -8);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = RandomSize(9);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (!edx)
|
|
|
|
{
|
|
|
|
if (RandomBit()) {
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = -pSprite->zvel;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (edx < 0)
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = -pSprite->zvel;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
void DestroyFish(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
runlist_DoSubRunRec(pSprite->owner);
|
|
|
|
runlist_FreeRun(pSprite->lotag - 1);
|
2021-10-23 10:33:33 +00:00
|
|
|
runlist_SubRunRec(pActor->nRun);
|
2021-10-23 11:02:43 +00:00
|
|
|
DeleteActor(pActor);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
void AIFish::Draw(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (pActor == nullptr) return;
|
2021-10-23 10:33:33 +00:00
|
|
|
short nAction = pActor->nAction;
|
2021-10-15 19:17:25 +00:00
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqFish] + FishSeq[nAction].a, pActor->nFrame, FishSeq[nAction].b);
|
2021-10-15 19:17:25 +00:00
|
|
|
ev->pTSprite->owner = -1;
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
void AIFish::RadialDamage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (pActor == nullptr) return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
if (pActor->nHealth <= 0) {
|
2021-10-15 19:17:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
ev->nDamage = runlist_CheckRadialDamage(pActor);
|
2021-10-15 19:17:25 +00:00
|
|
|
if (!ev->nDamage) {
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nCount = 10;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
// fall through
|
|
|
|
Damage(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AIFish::Damage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
2021-10-15 19:17:25 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
if (!ev->nDamage || !pActor) {
|
2021-10-15 19:17:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-11-15 22:18:54 +00:00
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nHealth -= dmgAdjust(ev->nDamage);
|
|
|
|
if (pActor->nHealth <= 0)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nHealth = 0;
|
2021-10-15 19:17:25 +00:00
|
|
|
nCreaturesKilled++;
|
|
|
|
|
|
|
|
pSprite->cstat &= 0xFEFE;
|
|
|
|
|
2021-10-28 16:08:03 +00:00
|
|
|
if (!ev->isRadialEvent())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 19:17:25 +00:00
|
|
|
for (int i = 0; i < 3; i++)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
BuildFishLimb(pActor, i);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 19:17:25 +00:00
|
|
|
|
|
|
|
PlayFXAtXYZ(StaticSound[kSound40], pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
|
2021-10-23 11:02:43 +00:00
|
|
|
DestroyFish(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 19:17:25 +00:00
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nAction = 9;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pTarget = ev->pOtherActor;
|
|
|
|
if (pTarget && pTarget->s().statnum < 199)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
pActor->pTarget = pTarget;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nAction = 4;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nCount += 10;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
void AIFish::Tick(RunListEvent* ev)
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (pActor == nullptr) return;
|
|
|
|
auto pSprite = &pActor->s();
|
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
short nAction = pActor->nAction;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
if (!(SectFlag[pSprite->sectnum] & kSectUnderwater))
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
Gravity(pActor);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
short nSeq = SeqOffsets[kSeqFish] + FishSeq[nAction].a;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
pSprite->picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
seq_MoveSequence(pActor, nSeq, pActor->nFrame);
|
2021-10-15 19:17:25 +00:00
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nFrame++;
|
|
|
|
if (pActor->nFrame >= SeqSize[nSeq]) {
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
auto pTargetActor = pActor->pTarget;
|
2021-10-15 19:17:25 +00:00
|
|
|
|
|
|
|
switch (nAction)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
case 0:
|
|
|
|
{
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nCount--;
|
|
|
|
if (pActor->nCount <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
pTargetActor = FindPlayer(pActor, 60);
|
|
|
|
if (pTargetActor)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
pActor->pTarget = pTargetActor;
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nAction = 2;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
int nAngle = GetMyAngle(pTargetActor->s().x - pSprite->x, pTargetActor->s().z - pSprite->z);
|
2021-10-15 19:17:25 +00:00
|
|
|
pSprite->zvel = bsin(nAngle, -5);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nCount = RandomSize(6) + 90;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
IdleFish(pActor, 0);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
case 1:
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
{
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nCount--;
|
|
|
|
if (pActor->nCount <= 0)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
IdleFish(pActor, 0);
|
2021-10-15 19:17:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
PlotCourseToSprite(pActor, pTargetActor);
|
|
|
|
int nHeight = GetActorHeight(pActor) >> 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
int z = abs(pTargetActor->s().z - pSprite->z);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
if (z <= nHeight)
|
|
|
|
{
|
|
|
|
pSprite->xvel = bcos(pSprite->ang, -5) - bcos(pSprite->ang, -7);
|
|
|
|
pSprite->yvel = bsin(pSprite->ang, -5) - bsin(pSprite->ang, -7);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
pSprite->zvel = (pTargetActor->s().z - pSprite->z) >> 3;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
case 4:
|
|
|
|
{
|
2021-10-23 10:33:33 +00:00
|
|
|
if (pActor->nFrame == 0)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
IdleFish(pActor, 0);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
case 9:
|
|
|
|
{
|
2021-10-23 10:33:33 +00:00
|
|
|
if (pActor->nFrame == 0)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
DestroyFish(pActor);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
|
|
|
int z = pSprite->z;
|
2021-11-09 16:27:54 +00:00
|
|
|
int nSector =pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
// loc_2EF54
|
2021-10-23 11:02:43 +00:00
|
|
|
Collision coll = movesprite(pActor, pSprite->xvel << 13, pSprite->yvel << 13, pSprite->zvel << 2, 0, 0, CLIPMASK0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
if (!(SectFlag[pSprite->sectnum] & kSectUnderwater))
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
ChangeActorSect(pActor, nSector);
|
2021-10-15 19:17:25 +00:00
|
|
|
pSprite->x = x;
|
|
|
|
pSprite->y = y;
|
|
|
|
pSprite->z = z;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
IdleFish(pActor, 0);
|
2021-10-15 19:17:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nAction >= 5) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
if (coll.type == kHitNone)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
|
|
|
if (nAction == 3)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nAction = 2;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-23 11:02:43 +00:00
|
|
|
if (!coll.exbits)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
if (coll.type == kHitWall)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
IdleFish(pActor, 0);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-23 11:02:43 +00:00
|
|
|
else if (coll.type == kHitSprite)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
|
|
|
|
auto pHitSpr = &coll.actor->s();
|
|
|
|
if (pHitSpr->statnum == 100)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
pActor->pTarget = coll.actor;
|
|
|
|
pSprite->ang = GetMyAngle(pHitSpr->x - pSprite->x, pHitSpr->y - pSprite->y);
|
2021-10-15 19:17:25 +00:00
|
|
|
|
|
|
|
if (nAction != 3)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 10:33:33 +00:00
|
|
|
pActor->nAction = 3;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-23 10:33:33 +00:00
|
|
|
if (!pActor->nFrame)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
runlist_DamageEnemy(coll.actor, pActor, 2);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
2021-10-23 11:02:43 +00:00
|
|
|
else if (coll.exbits & kHitAux2)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
IdleFish(pActor, -1);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
IdleFish(pActor, 1);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2021-10-15 19:17:25 +00:00
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|