mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
- access FishList through a pointer.
To make the following commmit more readably.
This commit is contained in:
parent
5d7d4ce496
commit
f8cab790d4
1 changed files with 61 additions and 53 deletions
|
@ -102,7 +102,8 @@ void InitFishes()
|
||||||
|
|
||||||
void BuildFishLimb(short nFish, short edx)
|
void BuildFishLimb(short nFish, short edx)
|
||||||
{
|
{
|
||||||
short nSprite = FishList[nFish].nSprite;
|
auto pActor = &FishList[nFish];
|
||||||
|
short nSprite = pActor->nSprite;
|
||||||
auto pSprite = &sprite[nSprite];
|
auto pSprite = &sprite[nSprite];
|
||||||
|
|
||||||
int nFree = FishChunk.Reserve(1);
|
int nFree = FishChunk.Reserve(1);
|
||||||
|
@ -220,6 +221,7 @@ void BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
|
||||||
{
|
{
|
||||||
int nFish = FishList.Reserve(1);
|
int nFish = FishList.Reserve(1);
|
||||||
auto pSprite = &sprite[nSprite];
|
auto pSprite = &sprite[nSprite];
|
||||||
|
auto pActor = &FishList[nFish];
|
||||||
|
|
||||||
if (nSprite == -1)
|
if (nSprite == -1)
|
||||||
{
|
{
|
||||||
|
@ -259,22 +261,23 @@ void BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
|
||||||
|
|
||||||
// GrabTimeSlot(3);
|
// GrabTimeSlot(3);
|
||||||
|
|
||||||
FishList[nFish].nAction = 0;
|
pActor->nAction = 0;
|
||||||
FishList[nFish].nHealth = 200;
|
pActor->nHealth = 200;
|
||||||
FishList[nFish].nSprite = nSprite;
|
pActor->nSprite = nSprite;
|
||||||
FishList[nFish].nTarget = -1;
|
pActor->nTarget = -1;
|
||||||
FishList[nFish].nCount = 60;
|
pActor->nCount = 60;
|
||||||
FishList[nFish].nFrame = 0;
|
pActor->nFrame = 0;
|
||||||
|
|
||||||
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nFish, 0x120000);
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nFish, 0x120000);
|
||||||
FishList[nFish].nRun = runlist_AddRunRec(NewRun, nFish, 0x120000);
|
pActor->nRun = runlist_AddRunRec(NewRun, nFish, 0x120000);
|
||||||
|
|
||||||
nCreaturesTotal++;
|
nCreaturesTotal++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdleFish(short nFish, short edx)
|
void IdleFish(short nFish, short edx)
|
||||||
{
|
{
|
||||||
short nSprite = FishList[nFish].nSprite;
|
auto pActor = &FishList[nFish];
|
||||||
|
short nSprite = pActor->nSprite;
|
||||||
auto pSprite = &sprite[nSprite];
|
auto pSprite = &sprite[nSprite];
|
||||||
|
|
||||||
pSprite->ang += (256 - RandomSize(9)) + 1024;
|
pSprite->ang += (256 - RandomSize(9)) + 1024;
|
||||||
|
@ -283,8 +286,8 @@ void IdleFish(short nFish, short edx)
|
||||||
pSprite->xvel = bcos(pSprite->ang, -8);
|
pSprite->xvel = bcos(pSprite->ang, -8);
|
||||||
pSprite->yvel = bsin(pSprite->ang, -8);
|
pSprite->yvel = bsin(pSprite->ang, -8);
|
||||||
|
|
||||||
FishList[nFish].nAction = 0;
|
pActor->nAction = 0;
|
||||||
FishList[nFish].nFrame = 0;
|
pActor->nFrame = 0;
|
||||||
|
|
||||||
pSprite->zvel = RandomSize(9);
|
pSprite->zvel = RandomSize(9);
|
||||||
|
|
||||||
|
@ -302,12 +305,13 @@ void IdleFish(short nFish, short edx)
|
||||||
|
|
||||||
void DestroyFish(short nFish)
|
void DestroyFish(short nFish)
|
||||||
{
|
{
|
||||||
short nSprite = FishList[nFish].nSprite;
|
auto pActor = &FishList[nFish];
|
||||||
|
short nSprite = pActor->nSprite;
|
||||||
auto pSprite = &sprite[nSprite];
|
auto pSprite = &sprite[nSprite];
|
||||||
|
|
||||||
runlist_DoSubRunRec(pSprite->owner);
|
runlist_DoSubRunRec(pSprite->owner);
|
||||||
runlist_FreeRun(pSprite->lotag - 1);
|
runlist_FreeRun(pSprite->lotag - 1);
|
||||||
runlist_SubRunRec(FishList[nFish].nRun);
|
runlist_SubRunRec(pActor->nRun);
|
||||||
mydeletesprite(nSprite);
|
mydeletesprite(nSprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,9 +321,10 @@ void AIFish::Draw(RunListEvent* ev)
|
||||||
{
|
{
|
||||||
short nFish = RunData[ev->nRun].nObjIndex;
|
short nFish = RunData[ev->nRun].nObjIndex;
|
||||||
assert(nFish >= 0 && nFish < (int)FishList.Size());
|
assert(nFish >= 0 && nFish < (int)FishList.Size());
|
||||||
short nAction = FishList[nFish].nAction;
|
auto pActor = &FishList[nFish];
|
||||||
|
short nAction = pActor->nAction;
|
||||||
|
|
||||||
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqFish] + FishSeq[nAction].a, FishList[nFish].nFrame, FishSeq[nAction].b);
|
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqFish] + FishSeq[nAction].a, pActor->nFrame, FishSeq[nAction].b);
|
||||||
ev->pTSprite->owner = -1;
|
ev->pTSprite->owner = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -327,9 +332,10 @@ void AIFish::Draw(RunListEvent* ev)
|
||||||
void AIFish::RadialDamage(RunListEvent* ev)
|
void AIFish::RadialDamage(RunListEvent* ev)
|
||||||
{
|
{
|
||||||
short nFish = RunData[ev->nRun].nObjIndex;
|
short nFish = RunData[ev->nRun].nObjIndex;
|
||||||
short nSprite = FishList[nFish].nSprite;
|
auto pActor = &FishList[nFish];
|
||||||
|
short nSprite = pActor->nSprite;
|
||||||
|
|
||||||
if (FishList[nFish].nHealth <= 0) {
|
if (pActor->nHealth <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -339,7 +345,7 @@ void AIFish::RadialDamage(RunListEvent* ev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FishList[nFish].nCount = 10;
|
pActor->nCount = 10;
|
||||||
}
|
}
|
||||||
// fall through
|
// fall through
|
||||||
Damage(ev);
|
Damage(ev);
|
||||||
|
@ -349,18 +355,19 @@ void AIFish::Damage(RunListEvent* ev)
|
||||||
{
|
{
|
||||||
short nFish = RunData[ev->nRun].nObjIndex;
|
short nFish = RunData[ev->nRun].nObjIndex;
|
||||||
assert(nFish >= 0 && nFish < (int)FishList.Size());
|
assert(nFish >= 0 && nFish < (int)FishList.Size());
|
||||||
short nAction = FishList[nFish].nAction;
|
auto pActor = &FishList[nFish];
|
||||||
short nSprite = FishList[nFish].nSprite;
|
short nAction = pActor->nAction;
|
||||||
|
short nSprite = pActor->nSprite;
|
||||||
auto pSprite = &sprite[nSprite];
|
auto pSprite = &sprite[nSprite];
|
||||||
|
|
||||||
if (!ev->nDamage) {
|
if (!ev->nDamage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FishList[nFish].nHealth -= dmgAdjust(ev->nDamage);
|
pActor->nHealth -= dmgAdjust(ev->nDamage);
|
||||||
if (FishList[nFish].nHealth <= 0)
|
if (pActor->nHealth <= 0)
|
||||||
{
|
{
|
||||||
FishList[nFish].nHealth = 0;
|
pActor->nHealth = 0;
|
||||||
nCreaturesKilled++;
|
nCreaturesKilled++;
|
||||||
|
|
||||||
pSprite->cstat &= 0xFEFE;
|
pSprite->cstat &= 0xFEFE;
|
||||||
|
@ -377,8 +384,8 @@ void AIFish::Damage(RunListEvent* ev)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FishList[nFish].nAction = 9;
|
pActor->nAction = 9;
|
||||||
FishList[nFish].nFrame = 0;
|
pActor->nFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -388,12 +395,12 @@ void AIFish::Damage(RunListEvent* ev)
|
||||||
short nTarget = ev->nParam;
|
short nTarget = ev->nParam;
|
||||||
if (nTarget >= 0 && sprite[nTarget].statnum < 199)
|
if (nTarget >= 0 && sprite[nTarget].statnum < 199)
|
||||||
{
|
{
|
||||||
FishList[nFish].nTarget = nTarget;
|
pActor->nTarget = nTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
FishList[nFish].nAction = 4;
|
pActor->nAction = 4;
|
||||||
FishList[nFish].nFrame = 0;
|
pActor->nFrame = 0;
|
||||||
FishList[nFish].nCount += 10;
|
pActor->nCount += 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,8 +408,9 @@ void AIFish::Tick(RunListEvent* ev)
|
||||||
{
|
{
|
||||||
short nFish = RunData[ev->nRun].nObjIndex;
|
short nFish = RunData[ev->nRun].nObjIndex;
|
||||||
assert(nFish >= 0 && nFish < (int)FishList.Size());
|
assert(nFish >= 0 && nFish < (int)FishList.Size());
|
||||||
short nAction = FishList[nFish].nAction;
|
auto pActor = &FishList[nFish];
|
||||||
short nSprite = FishList[nFish].nSprite;
|
short nAction = pActor->nAction;
|
||||||
|
short nSprite = pActor->nSprite;
|
||||||
auto pSprite = &sprite[nSprite];
|
auto pSprite = &sprite[nSprite];
|
||||||
|
|
||||||
if (!(SectFlag[pSprite->sectnum] & kSectUnderwater))
|
if (!(SectFlag[pSprite->sectnum] & kSectUnderwater))
|
||||||
|
@ -412,16 +420,16 @@ void AIFish::Tick(RunListEvent* ev)
|
||||||
|
|
||||||
short nSeq = SeqOffsets[kSeqFish] + FishSeq[nAction].a;
|
short nSeq = SeqOffsets[kSeqFish] + FishSeq[nAction].a;
|
||||||
|
|
||||||
pSprite->picnum = seq_GetSeqPicnum2(nSeq, FishList[nFish].nFrame);
|
pSprite->picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
|
||||||
|
|
||||||
seq_MoveSequence(nSprite, nSeq, FishList[nFish].nFrame);
|
seq_MoveSequence(nSprite, nSeq, pActor->nFrame);
|
||||||
|
|
||||||
FishList[nFish].nFrame++;
|
pActor->nFrame++;
|
||||||
if (FishList[nFish].nFrame >= SeqSize[nSeq]) {
|
if (pActor->nFrame >= SeqSize[nSeq]) {
|
||||||
FishList[nFish].nFrame = 0;
|
pActor->nFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
short nTarget = FishList[nFish].nTarget;
|
short nTarget = pActor->nTarget;
|
||||||
|
|
||||||
switch (nAction)
|
switch (nAction)
|
||||||
{
|
{
|
||||||
|
@ -430,20 +438,20 @@ void AIFish::Tick(RunListEvent* ev)
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
FishList[nFish].nCount--;
|
pActor->nCount--;
|
||||||
if (FishList[nFish].nCount <= 0)
|
if (pActor->nCount <= 0)
|
||||||
{
|
{
|
||||||
nTarget = FindPlayer(nSprite, 60);
|
nTarget = FindPlayer(nSprite, 60);
|
||||||
if (nTarget >= 0)
|
if (nTarget >= 0)
|
||||||
{
|
{
|
||||||
FishList[nFish].nTarget = nTarget;
|
pActor->nTarget = nTarget;
|
||||||
FishList[nFish].nAction = 2;
|
pActor->nAction = 2;
|
||||||
FishList[nFish].nFrame = 0;
|
pActor->nFrame = 0;
|
||||||
|
|
||||||
int nAngle = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].z - pSprite->z);
|
int nAngle = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].z - pSprite->z);
|
||||||
pSprite->zvel = bsin(nAngle, -5);
|
pSprite->zvel = bsin(nAngle, -5);
|
||||||
|
|
||||||
FishList[nFish].nCount = RandomSize(6) + 90;
|
pActor->nCount = RandomSize(6) + 90;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -460,8 +468,8 @@ void AIFish::Tick(RunListEvent* ev)
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
FishList[nFish].nCount--;
|
pActor->nCount--;
|
||||||
if (FishList[nFish].nCount <= 0)
|
if (pActor->nCount <= 0)
|
||||||
{
|
{
|
||||||
IdleFish(nFish, 0);
|
IdleFish(nFish, 0);
|
||||||
return;
|
return;
|
||||||
|
@ -491,7 +499,7 @@ void AIFish::Tick(RunListEvent* ev)
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
if (FishList[nFish].nFrame == 0)
|
if (pActor->nFrame == 0)
|
||||||
{
|
{
|
||||||
IdleFish(nFish, 0);
|
IdleFish(nFish, 0);
|
||||||
}
|
}
|
||||||
|
@ -505,7 +513,7 @@ void AIFish::Tick(RunListEvent* ev)
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
{
|
{
|
||||||
if (FishList[nFish].nFrame == 0)
|
if (pActor->nFrame == 0)
|
||||||
{
|
{
|
||||||
DestroyFish(nFish);
|
DestroyFish(nFish);
|
||||||
}
|
}
|
||||||
|
@ -541,8 +549,8 @@ void AIFish::Tick(RunListEvent* ev)
|
||||||
{
|
{
|
||||||
if (nAction == 3)
|
if (nAction == 3)
|
||||||
{
|
{
|
||||||
FishList[nFish].nAction = 2;
|
pActor->nAction = 2;
|
||||||
FishList[nFish].nFrame = 0;
|
pActor->nFrame = 0;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -557,16 +565,16 @@ void AIFish::Tick(RunListEvent* ev)
|
||||||
{
|
{
|
||||||
if (sprite[nMov & 0x3FFF].statnum == 100)
|
if (sprite[nMov & 0x3FFF].statnum == 100)
|
||||||
{
|
{
|
||||||
FishList[nFish].nTarget = nMov & 0x3FFF;
|
pActor->nTarget = nMov & 0x3FFF;
|
||||||
pSprite->ang = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
pSprite->ang = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
||||||
|
|
||||||
if (nAction != 3)
|
if (nAction != 3)
|
||||||
{
|
{
|
||||||
FishList[nFish].nAction = 3;
|
pActor->nAction = 3;
|
||||||
FishList[nFish].nFrame = 0;
|
pActor->nFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FishList[nFish].nFrame)
|
if (!pActor->nFrame)
|
||||||
{
|
{
|
||||||
runlist_DamageEnemy(nTarget, nSprite, 2);
|
runlist_DamageEnemy(nTarget, nSprite, 2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue