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-11-21 19:34:15 +00:00
|
|
|
void BuildFishLimb(DExhumedActor* pActor, int anim)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pChunkActor = insertActor(pActor->sector(), 99);
|
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
|
|
|
|
2022-01-31 22:33:44 +00:00
|
|
|
pChunkActor->set_int_pos(pActor->int_pos());
|
2021-12-23 16:26:44 +00:00
|
|
|
pChunkActor->spr.cstat = 0;
|
|
|
|
pChunkActor->spr.shade = -12;
|
|
|
|
pChunkActor->spr.pal = 0;
|
|
|
|
pChunkActor->spr.xvel = (RandomSize(5) - 16) << 8;
|
|
|
|
pChunkActor->spr.yvel = (RandomSize(5) - 16) << 8;
|
|
|
|
pChunkActor->spr.xrepeat = 64;
|
|
|
|
pChunkActor->spr.yrepeat = 64;
|
|
|
|
pChunkActor->spr.xoffset = 0;
|
|
|
|
pChunkActor->spr.yoffset = 0;
|
|
|
|
pChunkActor->spr.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-12-23 16:26:44 +00:00
|
|
|
pChunkActor->spr.picnum = anim;
|
|
|
|
pChunkActor->spr.lotag = runlist_HeadRun() + 1;
|
|
|
|
pChunkActor->spr.clipdist = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
2021-12-23 16:26:44 +00:00
|
|
|
pChunkActor->spr.extra = -1;
|
2022-05-23 22:30:41 +00:00
|
|
|
pChunkActor->spr.intowner = runlist_AddRunRec(pChunkActor->spr.lotag - 1, pChunkActor, 0x200000);
|
2021-12-23 16:26:44 +00:00
|
|
|
pChunkActor->spr.hitag = runlist_AddRunRec(NewRun, pChunkActor, 0x200000);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-22 22:35:11 +00:00
|
|
|
void BuildBlood(int x, int y, int z, sectortype* pSector)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-11-22 22:35:11 +00:00
|
|
|
BuildAnim(nullptr, kSeqFish, 36, x, y, z, pSector, 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;
|
|
|
|
|
|
|
|
int nSeq = SeqOffsets[kSeqFish] + pActor->nCount;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.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()) {
|
2022-01-31 22:33:44 +00:00
|
|
|
BuildBlood(pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector());
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-02-02 23:46:04 +00:00
|
|
|
int FloorZ = pActor->sector()->int_floorz();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-01-31 22:33:44 +00:00
|
|
|
if (FloorZ <= pActor->int_pos().Z)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2022-01-31 18:57:12 +00:00
|
|
|
pActor->add_int_z(256);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-01-31 22:33:44 +00:00
|
|
|
if ((pActor->int_pos().Z - FloorZ) > 25600)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.zvel = 0;
|
2022-05-23 22:30:41 +00:00
|
|
|
runlist_DoSubRunRec(pActor->spr.intowner);
|
2021-12-23 16:02:47 +00:00
|
|
|
runlist_FreeRun(pActor->spr.lotag - 1);
|
|
|
|
runlist_SubRunRec(pActor->spr.hitag);
|
2021-10-23 11:02:43 +00:00
|
|
|
DeleteActor(pActor);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
2022-01-31 22:33:44 +00:00
|
|
|
else if ((pActor->int_pos().Z - FloorZ) > 0)
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.zvel = 1024;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 16:02:47 +00:00
|
|
|
auto coll = movesprite(pActor, pActor->spr.xvel << 8, pActor->spr.yvel << 8, pActor->spr.zvel, 2560, -2560, CLIPMASK1);
|
2021-10-23 11:02:43 +00:00
|
|
|
if (coll.type != kHitNone)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.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-11-23 00:18:20 +00:00
|
|
|
void BuildFish(DExhumedActor* pActor, int x, int y, int z, sectortype* pSector, int nAngle)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-23 11:02:43 +00:00
|
|
|
if (pActor == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-23 00:18:20 +00:00
|
|
|
pActor = insertActor(pSector, 103);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-31 22:33:44 +00:00
|
|
|
x = pActor->int_pos().X;
|
|
|
|
y = pActor->int_pos().Y;
|
|
|
|
z = pActor->int_pos().Z;
|
2022-08-16 21:17:01 +00:00
|
|
|
nAngle = pActor->int_ang();
|
2021-10-23 11:02:43 +00:00
|
|
|
ChangeActorStat(pActor, 103);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 18:57:12 +00:00
|
|
|
pActor->set_int_pos({ x, y, z });
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
|
|
|
pActor->spr.shade = -12;
|
|
|
|
pActor->spr.clipdist = 80;
|
|
|
|
pActor->spr.xrepeat = 40;
|
|
|
|
pActor->spr.yrepeat = 40;
|
2021-12-30 15:51:56 +00:00
|
|
|
pActor->spr.pal = pActor->sector()->ceilingpal;
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.xoffset = 0;
|
|
|
|
pActor->spr.yoffset = 0;
|
|
|
|
pActor->spr.picnum = seq_GetSeqPicnum(kSeqFish, FishSeq[0].a, 0);
|
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
|
|
|
pActor->spr.zvel = 0;
|
2022-08-16 21:21:10 +00:00
|
|
|
pActor->set_int_ang(nAngle);
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.lotag = runlist_HeadRun() + 1;
|
|
|
|
pActor->spr.hitag = 0;
|
|
|
|
pActor->spr.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
|
|
|
|
2022-05-23 22:30:41 +00:00
|
|
|
pActor->spr.intowner = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x120000);
|
2021-10-23 11:02:43 +00:00
|
|
|
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-11-21 19:34:15 +00:00
|
|
|
void IdleFish(DExhumedActor* pActor, int edx)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2022-08-16 21:26:39 +00:00
|
|
|
pActor->add_int_ang((256 - RandomSize(9)) + 1024);
|
2022-08-16 21:15:16 +00:00
|
|
|
pActor->spr.__int_angle &= kAngleMask;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-08-16 21:17:01 +00:00
|
|
|
pActor->spr.xvel = bcos(pActor->int_ang(), -8);
|
|
|
|
pActor->spr.yvel = bsin(pActor->int_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-12-23 16:02:47 +00:00
|
|
|
pActor->spr.zvel = RandomSize(9);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (!edx)
|
|
|
|
{
|
|
|
|
if (RandomBit()) {
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.zvel = -pActor->spr.zvel;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (edx < 0)
|
|
|
|
{
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.zvel = -pActor->spr.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
|
|
|
{
|
2022-05-23 22:30:41 +00:00
|
|
|
runlist_DoSubRunRec(pActor->spr.intowner);
|
2021-12-23 16:02:47 +00:00
|
|
|
runlist_FreeRun(pActor->spr.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-11-21 19:34:15 +00:00
|
|
|
int 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-12-04 18:08:50 +00:00
|
|
|
ev->pTSprite->ownerActor = nullptr;
|
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
|
|
|
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;
|
|
|
|
}
|
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++;
|
|
|
|
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
2021-10-15 19:17:25 +00:00
|
|
|
|
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
|
|
|
|
2022-01-31 22:33:44 +00:00
|
|
|
PlayFXAtXYZ(StaticSound[kSound40], pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z);
|
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;
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pTarget && pTarget->spr.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;
|
|
|
|
|
2021-11-21 19:34:15 +00:00
|
|
|
int nAction = pActor->nAction;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (!(pActor->sector()->Flag & kSectUnderwater))
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
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-11-21 19:34:15 +00:00
|
|
|
int nSeq = SeqOffsets[kSeqFish] + FishSeq[nAction].a;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.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-12-07 17:53:02 +00:00
|
|
|
DExhumedActor* 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
|
|
|
|
2022-01-31 22:33:44 +00:00
|
|
|
int nAngle = GetMyAngle(pTargetActor->int_pos().X - pActor->int_pos().X, pTargetActor->int_pos().Z - pActor->int_pos().Z);
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.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
|
|
|
|
2022-01-31 22:33:44 +00:00
|
|
|
int z = abs(pTargetActor->int_pos().Z - pActor->int_pos().Z);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
if (z <= nHeight)
|
|
|
|
{
|
2022-08-16 21:17:01 +00:00
|
|
|
pActor->spr.xvel = bcos(pActor->int_ang(), -5) - bcos(pActor->int_ang(), -7);
|
|
|
|
pActor->spr.yvel = bsin(pActor->int_ang(), -5) - bsin(pActor->int_ang(), -7);
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 16:02:47 +00:00
|
|
|
pActor->spr.xvel = 0;
|
|
|
|
pActor->spr.yvel = 0;
|
2021-10-15 19:17:25 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-01-31 22:33:44 +00:00
|
|
|
pActor->spr.zvel = (pTargetActor->int_pos().Z - pActor->int_pos().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
|
|
|
|
2022-01-31 22:33:44 +00:00
|
|
|
int x = pActor->int_pos().X;
|
|
|
|
int y = pActor->int_pos().Y;
|
|
|
|
int z = pActor->int_pos().Z;
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pSector =pActor->sector();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 19:17:25 +00:00
|
|
|
// loc_2EF54
|
2021-12-23 16:02:47 +00:00
|
|
|
Collision coll = movesprite(pActor, pActor->spr.xvel << 13, pActor->spr.yvel << 13, pActor->spr.zvel << 2, 0, 0, CLIPMASK0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (!(pActor->sector()->Flag & kSectUnderwater))
|
2021-10-15 19:17:25 +00:00
|
|
|
{
|
2021-11-22 23:13:30 +00:00
|
|
|
ChangeActorSect(pActor, pSector);
|
2022-01-31 18:57:12 +00:00
|
|
|
pActor->set_int_pos({ x, y, 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
|
|
|
|
2021-12-23 16:26:44 +00:00
|
|
|
auto pHitAct = coll.actor();
|
|
|
|
if (pHitAct->spr.statnum == 100)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-26 13:26:03 +00:00
|
|
|
pActor->pTarget = coll.actor();
|
2022-08-16 21:21:10 +00:00
|
|
|
pActor->set_int_ang(GetMyAngle(pHitAct->int_pos().X - pActor->int_pos().X, pHitAct->int_pos().Y - pActor->int_pos().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-11-26 13:26:03 +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
|