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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Fish
|
|
|
|
{
|
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:16:58 +00:00
|
|
|
short nCount;
|
2020-03-02 21:08:31 +00:00
|
|
|
short nRun;
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Chunk
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSprite;
|
2020-11-29 19:16:58 +00:00
|
|
|
short nIndex;
|
|
|
|
short nSeqIndex;
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
TArray<Fish> FishList;
|
|
|
|
TArray<Chunk> FishChunk;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, Fish& w, Fish* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("health", w.nHealth)
|
|
|
|
("frame", w.nFrame)
|
|
|
|
("action", w.nAction)
|
|
|
|
("sprite", w.nSprite)
|
|
|
|
("target", w.nTarget)
|
|
|
|
("run", w.nRun)
|
|
|
|
("count", w.nCount)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
2019-12-26 21:00:04 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, Chunk& w, Chunk* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc ("sprite", w.nSprite)
|
|
|
|
("index", w.nIndex)
|
|
|
|
("seqindex", w.nSeqIndex)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
void SerializeFish(FSerializer& arc)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-11-29 19:16:58 +00:00
|
|
|
arc("fish", FishList)
|
|
|
|
("fishchunk", FishChunk);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
void InitFishes()
|
|
|
|
{
|
|
|
|
FishList.Clear();
|
|
|
|
FishChunk.Clear();
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 16:37:39 +00:00
|
|
|
void BuildFishLimb(short nFish, short edx)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSprite = FishList[nFish].nSprite;
|
2021-09-06 06:33:02 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
int nFree = FishChunk.Reserve(1);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int nSprite2 = insertsprite(pSprite->sectnum, 99);
|
2019-08-31 07:47:15 +00:00
|
|
|
assert(nSprite2 >= 0 && nSprite2 < kMaxSprites);
|
2021-09-06 06:33:02 +00:00
|
|
|
auto pSprite2 = &sprite[nSprite2];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
FishChunk[nFree].nSprite = nSprite2;
|
2020-11-29 19:16:58 +00:00
|
|
|
FishChunk[nFree].nSeqIndex = edx + 40;
|
|
|
|
FishChunk[nFree].nIndex = RandomSize(3) % SeqSize[SeqOffsets[kSeqFish] + edx + 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
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
seq_GetSeqPicnum(kSeqFish, FishChunk[nFree].nSeqIndex, 0);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite2->picnum = edx;
|
|
|
|
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-15 16:37:39 +00:00
|
|
|
pSprite2->owner = runlist_AddRunRec(pSprite2->lotag - 1, nFree, 0x200000);
|
|
|
|
pSprite2->hitag = runlist_AddRunRec(NewRun, nFree, 0x200000);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BuildBlood(int x, int y, int z, short nSector)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
BuildAnim(-1, kSeqFish, 36, x, y, z, nSector, 75, 128);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 16:49:35 +00:00
|
|
|
void FuncFishLimb(int nObject, int nMessage, int, int nRun)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nFish = RunData[nRun].nVal;
|
|
|
|
short nSprite = FishChunk[nFish].nSprite;
|
|
|
|
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
2021-09-06 06:33:02 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].nSeqIndex;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
case 0x20000:
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->picnum = seq_GetSeqPicnum2(nSeq, FishChunk[nFish].nIndex);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
Gravity(nSprite);
|
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
FishChunk[nFish].nIndex++;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
if (FishChunk[nFish].nIndex >= SeqSize[nSeq])
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-11-29 19:16:58 +00:00
|
|
|
FishChunk[nFish].nIndex = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
if (RandomBit()) {
|
2021-09-06 06:33:02 +00:00
|
|
|
BuildBlood(pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int FloorZ = sector[pSprite->sectnum].floorz;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
if (FloorZ <= pSprite->z)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->z += 256;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
if ((pSprite->z - FloorZ) > 25600)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = 0;
|
|
|
|
runlist_DoSubRunRec(pSprite->owner);
|
|
|
|
runlist_FreeRun(pSprite->lotag - 1);
|
|
|
|
runlist_SubRunRec(pSprite->hitag);
|
2019-08-31 07:47:15 +00:00
|
|
|
mydeletesprite(nSprite);
|
|
|
|
}
|
2021-09-06 06:33:02 +00:00
|
|
|
else if ((pSprite->z - FloorZ) > 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = 1024;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
if (movesprite(nSprite, pSprite->xvel << 8, pSprite->yvel << 8, pSprite->zvel, 2560, -2560, CLIPMASK1))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x90000:
|
|
|
|
{
|
2021-10-15 16:49:35 +00:00
|
|
|
seq_PlotSequence(nObject, nSeq, FishChunk[nFish].nIndex, 1);
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 16:37:39 +00:00
|
|
|
void BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-11-29 19:16:58 +00:00
|
|
|
int nFish = FishList.Reserve(1);
|
2021-09-06 06:33:02 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nSprite == -1)
|
|
|
|
{
|
|
|
|
nSprite = insertsprite(nSector, 103);
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
x = pSprite->x;
|
|
|
|
y = pSprite->y;
|
|
|
|
z = pSprite->z;
|
|
|
|
nAngle = pSprite->ang;
|
2019-08-31 07:47:15 +00:00
|
|
|
changespritestat(nSprite, 103);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
|
|
|
|
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;
|
|
|
|
pSprite->pal = sector[pSprite->sectnum].ceilingpal;
|
|
|
|
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);
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
FishList[nFish].nAction = 0;
|
|
|
|
FishList[nFish].nHealth = 200;
|
|
|
|
FishList[nFish].nSprite = nSprite;
|
|
|
|
FishList[nFish].nTarget = -1;
|
2020-11-29 19:16:58 +00:00
|
|
|
FishList[nFish].nCount = 60;
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].nFrame = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 16:37:39 +00:00
|
|
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nFish, 0x120000);
|
|
|
|
FishList[nFish].nRun = runlist_AddRunRec(NewRun, nFish, 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
|
|
|
}
|
|
|
|
|
|
|
|
void IdleFish(short nFish, short edx)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSprite = FishList[nFish].nSprite;
|
2021-09-06 06:33:02 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
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
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
FishList[nFish].nAction = 0;
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].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
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyFish(short nFish)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSprite = FishList[nFish].nSprite;
|
2021-09-06 06:33:02 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
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);
|
2020-03-02 21:08:31 +00:00
|
|
|
runlist_SubRunRec(FishList[nFish].nRun);
|
2019-08-31 07:47:15 +00:00
|
|
|
mydeletesprite(nSprite);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 16:49:35 +00:00
|
|
|
void FuncFish(int nObject, int nMessage, int nDamage, int nRun)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nFish = RunData[nRun].nVal;
|
2020-11-29 19:16:58 +00:00
|
|
|
assert(nFish >= 0 && nFish < (int)FishList.Size());
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
short nSprite = FishList[nFish].nSprite;
|
|
|
|
short nAction = FishList[nFish].nAction;
|
2021-09-06 06:33:02 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
{
|
2020-02-04 21:45:10 +00:00
|
|
|
Printf("unknown msg %d for Fish\n", nMessage);
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-15 22:18:54 +00:00
|
|
|
case 0x90000:
|
|
|
|
{
|
2021-10-15 16:49:35 +00:00
|
|
|
seq_PlotSequence(nObject, SeqOffsets[kSeqFish] + FishSeq[nAction].a, FishList[nFish].nFrame, FishSeq[nAction].b);
|
|
|
|
mytsprite[nObject].owner = -1;
|
2019-11-15 22:18:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
case 0xA0000:
|
|
|
|
{
|
|
|
|
if (FishList[nFish].nHealth <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nDamage = runlist_CheckRadialDamage(nSprite);
|
|
|
|
if (!nDamage) {
|
|
|
|
return;
|
|
|
|
}
|
2019-11-15 22:18:54 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
FishList[nFish].nCount = 10;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
// fall through
|
2019-12-02 14:56:24 +00:00
|
|
|
fallthrough__;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
case 0x80000:
|
|
|
|
{
|
|
|
|
if (!nDamage) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-27 13:05:55 +00:00
|
|
|
FishList[nFish].nHealth -= dmgAdjust(nDamage);
|
2019-08-31 07:47:15 +00:00
|
|
|
if (FishList[nFish].nHealth <= 0)
|
|
|
|
{
|
|
|
|
FishList[nFish].nHealth = 0;
|
2020-08-23 12:39:14 +00:00
|
|
|
nCreaturesKilled++;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->cstat &= 0xFEFE;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nMessage == 0x80000)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
BuildFishLimb(nFish, i);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
PlayFXAtXYZ(StaticSound[kSound40], pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
|
2019-08-31 07:47:15 +00:00
|
|
|
DestroyFish(nFish);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FishList[nFish].nAction = 9;
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-15 16:49:35 +00:00
|
|
|
short nTarget = nObject;
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nTarget >= 0 && sprite[nTarget].statnum < 199)
|
|
|
|
{
|
|
|
|
FishList[nFish].nTarget = nTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
FishList[nFish].nAction = 4;
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].nFrame = 0;
|
2020-11-29 19:16:58 +00:00
|
|
|
FishList[nFish].nCount += 10;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x20000:
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
if (!(SectFlag[pSprite->sectnum] & kSectUnderwater))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
Gravity(nSprite);
|
|
|
|
}
|
|
|
|
|
2020-10-11 09:33:28 +00:00
|
|
|
short nSeq = SeqOffsets[kSeqFish] + FishSeq[nAction].a;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->picnum = seq_GetSeqPicnum2(nSeq, FishList[nFish].nFrame);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
seq_MoveSequence(nSprite, nSeq, FishList[nFish].nFrame);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].nFrame++;
|
|
|
|
if (FishList[nFish].nFrame >= SeqSize[nSeq]) {
|
|
|
|
FishList[nFish].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
short nTarget = FishList[nFish].nTarget;
|
|
|
|
|
|
|
|
switch (nAction)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
{
|
2020-11-29 19:16:58 +00:00
|
|
|
FishList[nFish].nCount--;
|
|
|
|
if (FishList[nFish].nCount <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
nTarget = FindPlayer(nSprite, 60);
|
|
|
|
if (nTarget >= 0)
|
|
|
|
{
|
|
|
|
FishList[nFish].nTarget = nTarget;
|
|
|
|
FishList[nFish].nAction = 2;
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int nAngle = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].z - pSprite->z);
|
|
|
|
pSprite->zvel = bsin(nAngle, -5);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-29 19:16:58 +00:00
|
|
|
FishList[nFish].nCount = RandomSize(6) + 90;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IdleFish(nFish, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
{
|
2020-11-29 19:16:58 +00:00
|
|
|
FishList[nFish].nCount--;
|
|
|
|
if (FishList[nFish].nCount <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
IdleFish(nFish, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlotCourseToSprite(nSprite, nTarget);
|
|
|
|
int nHeight = GetSpriteHeight(nSprite) >> 1;
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int z = abs(sprite[nTarget].z - pSprite->z);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (z <= nHeight)
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = bcos(pSprite->ang, -5) - bcos(pSprite->ang, -7);
|
|
|
|
pSprite->yvel = bsin(pSprite->ang, -5) - bsin(pSprite->ang, -7);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = (sprite[nTarget].z - pSprite->z) >> 3;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if (FishList[nFish].nFrame == 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
IdleFish(nFish, 0);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if (FishList[nFish].nFrame == 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
DestroyFish(nFish);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
|
|
|
int z = pSprite->z;
|
|
|
|
short nSector = pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
// loc_2EF54
|
2021-09-06 06:33:02 +00:00
|
|
|
int nMov = movesprite(nSprite, pSprite->xvel << 13, pSprite->yvel << 13, pSprite->zvel << 2, 0, 0, CLIPMASK0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
if (!(SectFlag[pSprite->sectnum] & kSectUnderwater))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
mychangespritesect(nSprite, nSector);
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->x = x;
|
|
|
|
pSprite->y = y;
|
|
|
|
pSprite->z = z;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
IdleFish(nFish, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nAction >= 5) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
if (!nMov)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
if (nAction == 3)
|
|
|
|
{
|
|
|
|
FishList[nFish].nAction = 2;
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
if ((nMov & 0x30000) == 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
if ((nMov & 0xC000) == 0x8000)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
IdleFish(nFish, 0);
|
|
|
|
}
|
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 (sprite[nMov & 0x3FFF].statnum == 100)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].nTarget = nMov & 0x3FFF;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->ang = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nAction != 3)
|
|
|
|
{
|
|
|
|
FishList[nFish].nAction = 3;
|
2020-03-02 21:08:31 +00:00
|
|
|
FishList[nFish].nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
if (!FishList[nFish].nFrame)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
runlist_DamageEnemy(nTarget, nSprite, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-02 21:08:31 +00:00
|
|
|
else if (nMov & 0x20000)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
IdleFish(nFish, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IdleFish(nFish, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|