mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-20 18:42:26 +00:00
- converted FuncLion into a class
This commit is contained in:
parent
45e7b7c4d5
commit
b772200dd4
2 changed files with 457 additions and 437 deletions
|
@ -492,6 +492,14 @@ struct AILavaDudeLimb : public ExhumedAI
|
|||
void Draw(RunListEvent* ev) override;
|
||||
};
|
||||
|
||||
struct AILion : public ExhumedAI
|
||||
{
|
||||
void Tick(RunListEvent* ev) override;
|
||||
void Damage(RunListEvent* ev) override;
|
||||
void Draw(RunListEvent* ev) override;
|
||||
void RadialDamage(RunListEvent* ev) override;
|
||||
};
|
||||
|
||||
|
||||
void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage, int nRun);
|
||||
|
||||
|
|
|
@ -139,469 +139,481 @@ void BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
|
|||
nCreaturesTotal++;
|
||||
}
|
||||
|
||||
void FuncLion(int nObject, int nMessage, int nDamage, int nRun)
|
||||
void AILion::Draw(RunListEvent* ev)
|
||||
{
|
||||
short nLion = RunData[nRun].nVal;
|
||||
short nLion = RunData[ev->nRun].nVal;
|
||||
assert(nLion >= 0 && nLion < (int)LionList.Size());
|
||||
short nAction = LionList[nLion].nAction;
|
||||
|
||||
seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqLion] + LionSeq[nAction].a, LionList[nLion].nFrame, LionSeq[nAction].b);
|
||||
}
|
||||
|
||||
void AILion::RadialDamage(RunListEvent* ev)
|
||||
{
|
||||
short nLion = RunData[ev->nRun].nVal;
|
||||
assert(nLion >= 0 && nLion < (int)LionList.Size());
|
||||
|
||||
short nSprite = LionList[nLion].nSprite;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
|
||||
ev->nDamage = runlist_CheckRadialDamage(nSprite);
|
||||
// now fall through to 0x80000
|
||||
Damage(ev);
|
||||
}
|
||||
|
||||
void AILion::Damage(RunListEvent* ev)
|
||||
{
|
||||
short nLion = RunData[ev->nRun].nVal;
|
||||
assert(nLion >= 0 && nLion < (int)LionList.Size());
|
||||
|
||||
short nSprite = LionList[nLion].nSprite;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
short nAction = LionList[nLion].nAction;
|
||||
|
||||
if (ev->nDamage && LionList[nLion].nHealth > 0)
|
||||
{
|
||||
LionList[nLion].nHealth -= dmgAdjust(ev->nDamage);
|
||||
if (LionList[nLion].nHealth <= 0)
|
||||
{
|
||||
// R.I.P.
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
pSprite->zvel = 0;
|
||||
pSprite->cstat &= 0xFEFE;
|
||||
|
||||
LionList[nLion].nHealth = 0;
|
||||
|
||||
nCreaturesKilled++;
|
||||
|
||||
if (nAction < 10)
|
||||
{
|
||||
DropMagic(nSprite);
|
||||
|
||||
if (ev->nMessage == EMessageType::RadialDamage)
|
||||
{
|
||||
LionList[nLion].nAction = 11;
|
||||
}
|
||||
else
|
||||
{
|
||||
LionList[nLion].nAction = 10;
|
||||
}
|
||||
|
||||
LionList[nLion].nFrame = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
short nTarget = ev->nIndex;
|
||||
|
||||
if (nTarget > -1)
|
||||
{
|
||||
if (sprite[nTarget].statnum < 199) {
|
||||
LionList[nLion].nTarget = nTarget;
|
||||
}
|
||||
|
||||
if (nAction != 6)
|
||||
{
|
||||
if (RandomSize(8) <= (LionList[nLion].nHealth >> 2))
|
||||
{
|
||||
LionList[nLion].nAction = 4;
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
}
|
||||
else if (RandomSize(1))
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
LionList[nLion].nAction = 5;
|
||||
LionList[nLion].nCount = RandomSize(3);
|
||||
pSprite->ang = (pSprite->ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code
|
||||
}
|
||||
else
|
||||
{
|
||||
LionList[nLion].nAction = 8;
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
pSprite->cstat &= 0xFEFE;
|
||||
}
|
||||
|
||||
LionList[nLion].nFrame = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AILion::Tick(RunListEvent* ev)
|
||||
{
|
||||
short nLion = RunData[ev->nRun].nVal;
|
||||
assert(nLion >= 0 && nLion < (int)LionList.Size());
|
||||
|
||||
short nSprite = LionList[nLion].nSprite;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
short nAction = LionList[nLion].nAction;
|
||||
|
||||
bool bVal = false;
|
||||
|
||||
switch (nMessage)
|
||||
|
||||
if (nAction != 7) {
|
||||
Gravity(nSprite);
|
||||
}
|
||||
|
||||
short nSeq = SeqOffsets[kSeqLion] + LionSeq[nAction].a;
|
||||
|
||||
pSprite->picnum = seq_GetSeqPicnum2(nSeq, LionList[nLion].nFrame);
|
||||
|
||||
seq_MoveSequence(nSprite, nSeq, LionList[nLion].nFrame);
|
||||
|
||||
LionList[nLion].nFrame++;
|
||||
if (LionList[nLion].nFrame >= SeqSize[nSeq])
|
||||
{
|
||||
default:
|
||||
{
|
||||
Printf("unknown msg %d for Lion\n", nMessage);
|
||||
return;
|
||||
}
|
||||
LionList[nLion].nFrame = 0;
|
||||
bVal = true;
|
||||
}
|
||||
|
||||
case 0x90000:
|
||||
{
|
||||
seq_PlotSequence(nObject, SeqOffsets[kSeqLion] + LionSeq[nAction].a, LionList[nLion].nFrame, LionSeq[nAction].b);
|
||||
return;
|
||||
}
|
||||
short nFlag = FrameFlag[SeqBase[nSeq] + LionList[nLion].nFrame];
|
||||
short nTarget = LionList[nLion].nTarget;
|
||||
|
||||
case 0xA0000:
|
||||
int nMov = MoveCreatureWithCaution(nSprite);
|
||||
|
||||
switch (nAction)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
if ((LionList[nLion].nIndex & 0x1F) == (totalmoves & 0x1F))
|
||||
{
|
||||
nDamage = runlist_CheckRadialDamage(nSprite);
|
||||
// now fall through to 0x80000
|
||||
fallthrough__;
|
||||
}
|
||||
case 0x80000:
|
||||
{
|
||||
if (nDamage && LionList[nLion].nHealth > 0)
|
||||
if (nTarget < 0)
|
||||
{
|
||||
LionList[nLion].nHealth -= dmgAdjust(nDamage);
|
||||
if (LionList[nLion].nHealth <= 0)
|
||||
nTarget = FindPlayer(nSprite, 40);
|
||||
if (nTarget >= 0)
|
||||
{
|
||||
// R.I.P.
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
pSprite->zvel = 0;
|
||||
pSprite->cstat &= 0xFEFE;
|
||||
D3PlayFX(StaticSound[kSound24], nSprite);
|
||||
LionList[nLion].nAction = 2;
|
||||
LionList[nLion].nFrame = 0;
|
||||
|
||||
LionList[nLion].nHealth = 0;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
LionList[nLion].nTarget = nTarget;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nCreaturesKilled++;
|
||||
|
||||
if (nAction < 10)
|
||||
{
|
||||
DropMagic(nSprite);
|
||||
|
||||
if (nMessage == 0xA0000) {
|
||||
LionList[nLion].nAction = 11;
|
||||
}
|
||||
else
|
||||
{
|
||||
LionList[nLion].nAction = 10;
|
||||
}
|
||||
|
||||
LionList[nLion].nFrame = 0;
|
||||
return;
|
||||
}
|
||||
if (nAction && !easy())
|
||||
{
|
||||
LionList[nLion].nCount--;
|
||||
if (LionList[nLion].nCount <= 0)
|
||||
{
|
||||
if (RandomBit())
|
||||
{
|
||||
pSprite->ang = RandomWord() & kAngleMask;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
short nTarget = nObject;
|
||||
|
||||
if (nTarget > -1)
|
||||
{
|
||||
if (sprite[nTarget].statnum < 199) {
|
||||
LionList[nLion].nTarget = nTarget;
|
||||
}
|
||||
|
||||
if (nAction != 6)
|
||||
{
|
||||
if (RandomSize(8) <= (LionList[nLion].nHealth >> 2))
|
||||
{
|
||||
LionList[nLion].nAction = 4;
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
}
|
||||
else if (RandomSize(1))
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
LionList[nLion].nAction = 5;
|
||||
LionList[nLion].nCount = RandomSize(3);
|
||||
pSprite->ang = (pSprite->ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code
|
||||
}
|
||||
else
|
||||
{
|
||||
LionList[nLion].nAction = 8;
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
pSprite->cstat &= 0xFEFE;
|
||||
}
|
||||
|
||||
LionList[nLion].nFrame = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case 0x20000:
|
||||
{
|
||||
if (nAction != 7) {
|
||||
Gravity(nSprite);
|
||||
}
|
||||
|
||||
short nSeq = SeqOffsets[kSeqLion] + LionSeq[nAction].a;
|
||||
|
||||
pSprite->picnum = seq_GetSeqPicnum2(nSeq, LionList[nLion].nFrame);
|
||||
|
||||
seq_MoveSequence(nSprite, nSeq, LionList[nLion].nFrame);
|
||||
|
||||
LionList[nLion].nFrame++;
|
||||
if (LionList[nLion].nFrame >= SeqSize[nSeq])
|
||||
{
|
||||
LionList[nLion].nFrame = 0;
|
||||
bVal = true;
|
||||
}
|
||||
|
||||
short nFlag = FrameFlag[SeqBase[nSeq] + LionList[nLion].nFrame];
|
||||
short nTarget = LionList[nLion].nTarget;
|
||||
|
||||
int nMov = MoveCreatureWithCaution(nSprite);
|
||||
|
||||
switch (nAction)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
if ((LionList[nLion].nIndex & 0x1F) == (totalmoves & 0x1F))
|
||||
{
|
||||
if (nTarget < 0)
|
||||
{
|
||||
nTarget = FindPlayer(nSprite, 40);
|
||||
if (nTarget >= 0)
|
||||
{
|
||||
D3PlayFX(StaticSound[kSound24], nSprite);
|
||||
LionList[nLion].nAction = 2;
|
||||
LionList[nLion].nFrame = 0;
|
||||
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
LionList[nLion].nTarget = nTarget;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nAction && !easy())
|
||||
{
|
||||
LionList[nLion].nCount--;
|
||||
if (LionList[nLion].nCount <= 0)
|
||||
{
|
||||
if (RandomBit())
|
||||
{
|
||||
pSprite->ang = RandomWord() & kAngleMask;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
}
|
||||
|
||||
LionList[nLion].nCount = 100;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if ((totalmoves & 0x1F) == (LionList[nLion].nIndex & 0x1F))
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
|
||||
int nAng = pSprite->ang & 0xFFF8;
|
||||
|
||||
if (pSprite->cstat & 0x8000)
|
||||
{
|
||||
pSprite->xvel = bcos(nAng, 1);
|
||||
pSprite->yvel = bsin(nAng, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSprite->xvel = bcos(nAng, -1);
|
||||
pSprite->yvel = bsin(nAng, -1);
|
||||
}
|
||||
}
|
||||
|
||||
if ((nMov & 0xC000) < 0x8000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if ((nMov & 0xC000) == 0x8000)
|
||||
{
|
||||
// loc_378FA:
|
||||
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
break;
|
||||
}
|
||||
else if ((nMov & 0xC000) == 0xC000)
|
||||
{
|
||||
if ((nMov & 0x3FFF) == nTarget)
|
||||
{
|
||||
if (pSprite->cstat & 0x8000)
|
||||
{
|
||||
LionList[nLion].nAction = 9;
|
||||
pSprite->cstat &= 0x7FFF;
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int nAng = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
||||
|
||||
if (AngleDiff(pSprite->ang, nAng) < 64)
|
||||
{
|
||||
LionList[nLion].nAction = 3;
|
||||
}
|
||||
}
|
||||
|
||||
LionList[nLion].nFrame = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// loc_378FA:
|
||||
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
if (nTarget == -1)
|
||||
{
|
||||
LionList[nLion].nAction = 1;
|
||||
LionList[nLion].nCount = 50;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlotCourseToSprite(nSprite, nTarget) >= 768)
|
||||
{
|
||||
LionList[nLion].nAction = 2;
|
||||
}
|
||||
else if (nFlag & 0x80)
|
||||
{
|
||||
runlist_DamageEnemy(nTarget, nSprite, 10);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
LionList[nLion].nAction = 2;
|
||||
LionList[nLion].nFrame = 0;
|
||||
}
|
||||
|
||||
if (nMov & 0x20000)
|
||||
{
|
||||
pSprite->xvel >>= 1;
|
||||
pSprite->yvel >>= 1;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 5: // Jump away when damaged
|
||||
{
|
||||
LionList[nLion].nCount--;
|
||||
if (LionList[nLion].nCount <= 0)
|
||||
{
|
||||
pSprite->zvel = -4000;
|
||||
LionList[nLion].nCount = 0;
|
||||
|
||||
int x = pSprite->x;
|
||||
int y = pSprite->y;
|
||||
int z = pSprite->z - (GetSpriteHeight(nSprite) >> 1);
|
||||
|
||||
int nCheckDist = 0x7FFFFFFF;
|
||||
|
||||
short nAngle = pSprite->ang;
|
||||
short nScanAngle = (pSprite->ang - 512) & kAngleMask;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
short hitwall;
|
||||
int hitx, hity;
|
||||
vec3_t startPos = { x, y, z };
|
||||
hitdata_t hitData;
|
||||
|
||||
hitscan(&startPos, pSprite->sectnum, bcos(nScanAngle), bsin(nScanAngle), 0, &hitData, CLIPMASK1);
|
||||
|
||||
hitx = hitData.pos.x;
|
||||
hity = hitData.pos.y;
|
||||
hitwall = hitData.wall;
|
||||
|
||||
if (hitwall > -1)
|
||||
{
|
||||
int theX = abs(hitx - x);
|
||||
int theY = abs(hity - y);
|
||||
|
||||
if ((theX + theY) < nCheckDist)
|
||||
{
|
||||
nCheckDist = theX;
|
||||
nAngle = nScanAngle;
|
||||
}
|
||||
}
|
||||
|
||||
nScanAngle += 256;
|
||||
nScanAngle &= kAngleMask;
|
||||
}
|
||||
|
||||
pSprite->ang = nAngle;
|
||||
|
||||
LionList[nLion].nAction = 6;
|
||||
pSprite->xvel = bcos(pSprite->ang) - bcos(pSprite->ang, -3);
|
||||
pSprite->yvel = bsin(pSprite->ang) - bsin(pSprite->ang, -3);
|
||||
D3PlayFX(StaticSound[kSound24], nSprite);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 6:
|
||||
{
|
||||
if (nMov & 0x30000)
|
||||
{
|
||||
LionList[nLion].nAction = 2;
|
||||
LionList[nLion].nFrame = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((nMov & 0xC000) == 0x8000)
|
||||
{
|
||||
LionList[nLion].nAction = 7;
|
||||
pSprite->ang = (GetWallNormal(nMov & 0x3FFF) + 1024) & kAngleMask;
|
||||
LionList[nLion].nCount = RandomSize(4);
|
||||
return;
|
||||
}
|
||||
else if ((nMov & 0xC000) == 0xC000)
|
||||
{
|
||||
if ((nMov & 0x3FFF) == nTarget)
|
||||
{
|
||||
int nAng = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
||||
if (AngleDiff(pSprite->ang, nAng) < 64)
|
||||
{
|
||||
LionList[nLion].nAction = 3;
|
||||
LionList[nLion].nFrame = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// loc_378FA:
|
||||
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 7:
|
||||
{
|
||||
LionList[nLion].nCount--;
|
||||
|
||||
if (LionList[nLion].nCount <= 0)
|
||||
{
|
||||
LionList[nLion].nCount = 0;
|
||||
if (nTarget > -1)
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSprite->ang = (RandomSize(9) + (pSprite->ang + 768)) & kAngleMask;
|
||||
}
|
||||
|
||||
pSprite->zvel = -1000;
|
||||
|
||||
LionList[nLion].nAction = 6;
|
||||
pSprite->xvel = bcos(pSprite->ang) - bcos(pSprite->ang, -3);
|
||||
pSprite->yvel = bsin(pSprite->ang) - bsin(pSprite->ang, -3);
|
||||
D3PlayFX(StaticSound[kSound24], nSprite);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 8:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
LionList[nLion].nAction = 2;
|
||||
LionList[nLion].nFrame = 0;
|
||||
pSprite->cstat |= 0x8000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case 9:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
LionList[nLion].nFrame = 0;
|
||||
LionList[nLion].nAction = 2;
|
||||
pSprite->cstat |= 0x101;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case 10:
|
||||
case 11:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
runlist_SubRunRec(pSprite->owner);
|
||||
runlist_SubRunRec(LionList[nLion].nRun);
|
||||
pSprite->cstat = 0x8000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// loc_379AD: ?
|
||||
if (nAction != 1 && nTarget != -1)
|
||||
{
|
||||
if (!(sprite[nTarget].cstat & 0x101))
|
||||
{
|
||||
LionList[nLion].nAction = 1;
|
||||
LionList[nLion].nFrame = 0;
|
||||
LionList[nLion].nCount = 100;
|
||||
LionList[nLion].nTarget = -1;
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
}
|
||||
|
||||
LionList[nLion].nCount = 100;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if ((totalmoves & 0x1F) == (LionList[nLion].nIndex & 0x1F))
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
|
||||
int nAng = pSprite->ang & 0xFFF8;
|
||||
|
||||
if (pSprite->cstat & 0x8000)
|
||||
{
|
||||
pSprite->xvel = bcos(nAng, 1);
|
||||
pSprite->yvel = bsin(nAng, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSprite->xvel = bcos(nAng, -1);
|
||||
pSprite->yvel = bsin(nAng, -1);
|
||||
}
|
||||
}
|
||||
|
||||
if ((nMov & 0xC000) < 0x8000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if ((nMov & 0xC000) == 0x8000)
|
||||
{
|
||||
// loc_378FA:
|
||||
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
break;
|
||||
}
|
||||
else if ((nMov & 0xC000) == 0xC000)
|
||||
{
|
||||
if ((nMov & 0x3FFF) == nTarget)
|
||||
{
|
||||
if (pSprite->cstat & 0x8000)
|
||||
{
|
||||
LionList[nLion].nAction = 9;
|
||||
pSprite->cstat &= 0x7FFF;
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int nAng = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
||||
|
||||
if (AngleDiff(pSprite->ang, nAng) < 64)
|
||||
{
|
||||
LionList[nLion].nAction = 3;
|
||||
}
|
||||
}
|
||||
|
||||
LionList[nLion].nFrame = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// loc_378FA:
|
||||
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
if (nTarget == -1)
|
||||
{
|
||||
LionList[nLion].nAction = 1;
|
||||
LionList[nLion].nCount = 50;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlotCourseToSprite(nSprite, nTarget) >= 768)
|
||||
{
|
||||
LionList[nLion].nAction = 2;
|
||||
}
|
||||
else if (nFlag & 0x80)
|
||||
{
|
||||
runlist_DamageEnemy(nTarget, nSprite, 10);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
LionList[nLion].nAction = 2;
|
||||
LionList[nLion].nFrame = 0;
|
||||
}
|
||||
|
||||
if (nMov & 0x20000)
|
||||
{
|
||||
pSprite->xvel >>= 1;
|
||||
pSprite->yvel >>= 1;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 5: // Jump away when damaged
|
||||
{
|
||||
LionList[nLion].nCount--;
|
||||
if (LionList[nLion].nCount <= 0)
|
||||
{
|
||||
pSprite->zvel = -4000;
|
||||
LionList[nLion].nCount = 0;
|
||||
|
||||
int x = pSprite->x;
|
||||
int y = pSprite->y;
|
||||
int z = pSprite->z - (GetSpriteHeight(nSprite) >> 1);
|
||||
|
||||
int nCheckDist = 0x7FFFFFFF;
|
||||
|
||||
short nAngle = pSprite->ang;
|
||||
short nScanAngle = (pSprite->ang - 512) & kAngleMask;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
short hitwall;
|
||||
int hitx, hity;
|
||||
vec3_t startPos = { x, y, z };
|
||||
hitdata_t hitData;
|
||||
|
||||
hitscan(&startPos, pSprite->sectnum, bcos(nScanAngle), bsin(nScanAngle), 0, &hitData, CLIPMASK1);
|
||||
|
||||
hitx = hitData.pos.x;
|
||||
hity = hitData.pos.y;
|
||||
hitwall = hitData.wall;
|
||||
|
||||
if (hitwall > -1)
|
||||
{
|
||||
int theX = abs(hitx - x);
|
||||
int theY = abs(hity - y);
|
||||
|
||||
if ((theX + theY) < nCheckDist)
|
||||
{
|
||||
nCheckDist = theX;
|
||||
nAngle = nScanAngle;
|
||||
}
|
||||
}
|
||||
|
||||
nScanAngle += 256;
|
||||
nScanAngle &= kAngleMask;
|
||||
}
|
||||
|
||||
pSprite->ang = nAngle;
|
||||
|
||||
LionList[nLion].nAction = 6;
|
||||
pSprite->xvel = bcos(pSprite->ang) - bcos(pSprite->ang, -3);
|
||||
pSprite->yvel = bsin(pSprite->ang) - bsin(pSprite->ang, -3);
|
||||
D3PlayFX(StaticSound[kSound24], nSprite);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 6:
|
||||
{
|
||||
if (nMov & 0x30000)
|
||||
{
|
||||
LionList[nLion].nAction = 2;
|
||||
LionList[nLion].nFrame = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((nMov & 0xC000) == 0x8000)
|
||||
{
|
||||
LionList[nLion].nAction = 7;
|
||||
pSprite->ang = (GetWallNormal(nMov & 0x3FFF) + 1024) & kAngleMask;
|
||||
LionList[nLion].nCount = RandomSize(4);
|
||||
return;
|
||||
}
|
||||
else if ((nMov & 0xC000) == 0xC000)
|
||||
{
|
||||
if ((nMov & 0x3FFF) == nTarget)
|
||||
{
|
||||
int nAng = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
||||
if (AngleDiff(pSprite->ang, nAng) < 64)
|
||||
{
|
||||
LionList[nLion].nAction = 3;
|
||||
LionList[nLion].nFrame = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// loc_378FA:
|
||||
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
|
||||
pSprite->xvel = bcos(pSprite->ang, -1);
|
||||
pSprite->yvel = bsin(pSprite->ang, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 7:
|
||||
{
|
||||
LionList[nLion].nCount--;
|
||||
|
||||
if (LionList[nLion].nCount <= 0)
|
||||
{
|
||||
LionList[nLion].nCount = 0;
|
||||
if (nTarget > -1)
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSprite->ang = (RandomSize(9) + (pSprite->ang + 768)) & kAngleMask;
|
||||
}
|
||||
|
||||
pSprite->zvel = -1000;
|
||||
|
||||
LionList[nLion].nAction = 6;
|
||||
pSprite->xvel = bcos(pSprite->ang) - bcos(pSprite->ang, -3);
|
||||
pSprite->yvel = bsin(pSprite->ang) - bsin(pSprite->ang, -3);
|
||||
D3PlayFX(StaticSound[kSound24], nSprite);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 8:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
LionList[nLion].nAction = 2;
|
||||
LionList[nLion].nFrame = 0;
|
||||
pSprite->cstat |= 0x8000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case 9:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
LionList[nLion].nFrame = 0;
|
||||
LionList[nLion].nAction = 2;
|
||||
pSprite->cstat |= 0x101;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case 10:
|
||||
case 11:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
runlist_SubRunRec(pSprite->owner);
|
||||
runlist_SubRunRec(LionList[nLion].nRun);
|
||||
pSprite->cstat = 0x8000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// loc_379AD: ?
|
||||
if (nAction != 1 && nTarget != -1)
|
||||
{
|
||||
if (!(sprite[nTarget].cstat & 0x101))
|
||||
{
|
||||
LionList[nLion].nAction = 1;
|
||||
LionList[nLion].nFrame = 0;
|
||||
LionList[nLion].nCount = 100;
|
||||
LionList[nLion].nTarget = -1;
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FuncLion(int nObject, int nMessage, int nDamage, int nRun)
|
||||
{
|
||||
AILion ai;
|
||||
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
|
||||
}
|
||||
|
||||
END_PS_NS
|
||||
|
|
Loading…
Reference in a new issue