mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-09 15:31:03 +00:00
- converted FuncScorp to a class.
This commit is contained in:
parent
5418c4326f
commit
d77a5208f3
2 changed files with 362 additions and 332 deletions
|
@ -617,6 +617,15 @@ struct AIRoach : public ExhumedAI
|
||||||
void RadialDamage(RunListEvent* ev) override;
|
void RadialDamage(RunListEvent* ev) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AIScorp : public ExhumedAI
|
||||||
|
{
|
||||||
|
void Effect(RunListEvent* ev, int nTarget, int mode);
|
||||||
|
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);
|
void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage, int nRun);
|
||||||
|
|
||||||
typedef void(*AiFunc)(int, int, int, int nRun);
|
typedef void(*AiFunc)(int, int, int, int nRun);
|
||||||
|
|
|
@ -148,12 +148,32 @@ void BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle,
|
||||||
nCreaturesTotal++;
|
nCreaturesTotal++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
void AIScorp::Draw(RunListEvent* ev)
|
||||||
{
|
{
|
||||||
short nScorp = RunData[nRun].nVal;
|
short nScorp = RunData[ev->nRun].nVal;
|
||||||
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||||
|
short nAction = scorpion[nScorp].nAction;
|
||||||
|
|
||||||
|
seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a, scorpion[nScorp].nFrame, ScorpSeq[nAction].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AIScorp::RadialDamage(RunListEvent* ev)
|
||||||
|
{
|
||||||
|
short nScorp = RunData[ev->nRun].nVal;
|
||||||
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||||
short nSprite = scorpion[nScorp].nSprite;
|
short nSprite = scorpion[nScorp].nSprite;
|
||||||
|
|
||||||
|
ev->nDamage = runlist_CheckRadialDamage(nSprite);
|
||||||
|
if (ev->nDamage) Damage(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AIScorp::Damage(RunListEvent* ev)
|
||||||
|
{
|
||||||
|
short nScorp = RunData[ev->nRun].nVal;
|
||||||
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||||
|
short nSprite = scorpion[nScorp].nSprite;
|
||||||
|
|
||||||
short nAction = scorpion[nScorp].nAction;
|
short nAction = scorpion[nScorp].nAction;
|
||||||
auto pSprite = &sprite[nSprite];
|
auto pSprite = &sprite[nSprite];
|
||||||
|
|
||||||
|
@ -161,37 +181,11 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||||
|
|
||||||
short nTarget = -1;
|
short nTarget = -1;
|
||||||
|
|
||||||
switch (nMessage)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
Printf("unknown msg %d for Scorp\n", nMessage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 0x90000:
|
|
||||||
{
|
|
||||||
seq_PlotSequence(nObject, SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a, scorpion[nScorp].nFrame, ScorpSeq[nAction].b);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 0xA0000:
|
|
||||||
{
|
|
||||||
nDamage = runlist_CheckRadialDamage(nSprite);
|
|
||||||
if (!nDamage) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// else fall through to case 0x80000
|
|
||||||
fallthrough__;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 0x80000:
|
|
||||||
{
|
|
||||||
if (scorpion[nScorp].nHealth <= 0) {
|
if (scorpion[nScorp].nHealth <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scorpion[nScorp].nHealth -= dmgAdjust(nDamage);
|
scorpion[nScorp].nHealth -= dmgAdjust(ev->nDamage);
|
||||||
|
|
||||||
if (scorpion[nScorp].nHealth <= 0)
|
if (scorpion[nScorp].nHealth <= 0)
|
||||||
{
|
{
|
||||||
|
@ -210,7 +204,7 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nTarget = nObject;
|
nTarget = ev->nIndex;
|
||||||
|
|
||||||
if (nTarget >= 0)
|
if (nTarget >= 0)
|
||||||
{
|
{
|
||||||
|
@ -232,13 +226,23 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||||
}
|
}
|
||||||
|
|
||||||
D3PlayFX(StaticSound[kSound41], nSprite);
|
D3PlayFX(StaticSound[kSound41], nSprite);
|
||||||
|
Effect(ev, nTarget, 0);
|
||||||
goto FS_Pink_A;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x20000:
|
void AIScorp::Tick(RunListEvent* ev)
|
||||||
{
|
{
|
||||||
|
short nScorp = RunData[ev->nRun].nVal;
|
||||||
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||||
|
short nSprite = scorpion[nScorp].nSprite;
|
||||||
|
|
||||||
|
short nAction = scorpion[nScorp].nAction;
|
||||||
|
auto pSprite = &sprite[nSprite];
|
||||||
|
|
||||||
|
bool bVal = false;
|
||||||
|
|
||||||
|
short nTarget = -1;
|
||||||
|
|
||||||
if (scorpion[nScorp].nHealth) {
|
if (scorpion[nScorp].nHealth) {
|
||||||
Gravity(nSprite);
|
Gravity(nSprite);
|
||||||
}
|
}
|
||||||
|
@ -302,8 +306,7 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||||
if (scorpion[nScorp].nIndex2 <= 0)
|
if (scorpion[nScorp].nIndex2 <= 0)
|
||||||
{
|
{
|
||||||
scorpion[nScorp].nIndex2 = RandomSize(5);
|
scorpion[nScorp].nIndex2 = RandomSize(5);
|
||||||
// GOTO FS_Pink_A:
|
Effect(ev, nTarget, 0);
|
||||||
goto FS_Pink_A;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -318,23 +321,24 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||||
scorpion[nScorp].nAction = 2;
|
scorpion[nScorp].nAction = 2;
|
||||||
scorpion[nScorp].nFrame = 0;
|
scorpion[nScorp].nFrame = 0;
|
||||||
}
|
}
|
||||||
|
Effect(ev, nTarget, 2);
|
||||||
goto FS_Red;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
goto FS_Pink_A;
|
Effect(ev, nTarget, 0);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if ((nMov & 0xC000) == 0x8000)
|
else if ((nMov & 0xC000) == 0x8000)
|
||||||
{
|
{
|
||||||
goto FS_Pink_A;
|
Effect(ev, nTarget, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
goto FS_Pink_B;
|
Effect(ev, nTarget, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -355,8 +359,8 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||||
runlist_DamageEnemy(nTarget, nSprite, 7);
|
runlist_DamageEnemy(nTarget, nSprite, 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Effect(ev, nTarget, 2);
|
||||||
goto FS_Red;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -461,20 +465,30 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_Pink_A:
|
void AIScorp::Effect(RunListEvent* ev, int nTarget, int mode)
|
||||||
|
{
|
||||||
|
short nScorp = RunData[ev->nRun].nVal;
|
||||||
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||||
|
short nSprite = scorpion[nScorp].nSprite;
|
||||||
|
|
||||||
|
short nAction = scorpion[nScorp].nAction;
|
||||||
|
auto pSprite = &sprite[nSprite];
|
||||||
|
|
||||||
|
bool bVal = false;
|
||||||
|
|
||||||
|
if (mode == 0)
|
||||||
|
{
|
||||||
PlotCourseToSprite(nSprite, nTarget);
|
PlotCourseToSprite(nSprite, nTarget);
|
||||||
pSprite->ang += RandomSize(7) - 63;
|
pSprite->ang += RandomSize(7) - 63;
|
||||||
pSprite->ang &= kAngleMask;
|
pSprite->ang &= kAngleMask;
|
||||||
|
|
||||||
pSprite->xvel = bcos(pSprite->ang);
|
pSprite->xvel = bcos(pSprite->ang);
|
||||||
pSprite->yvel = bsin(pSprite->ang);
|
pSprite->yvel = bsin(pSprite->ang);
|
||||||
|
}
|
||||||
FS_Pink_B:
|
if (mode <= 1)
|
||||||
|
{
|
||||||
if (scorpion[nScorp].nCount)
|
if (scorpion[nScorp].nCount)
|
||||||
{
|
{
|
||||||
scorpion[nScorp].nCount--;
|
scorpion[nScorp].nCount--;
|
||||||
|
@ -502,8 +516,8 @@ FS_Pink_B:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FS_Red:
|
|
||||||
if (!nAction || nTarget == -1) {
|
if (!nAction || nTarget == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -519,4 +533,11 @@ FS_Red:
|
||||||
pSprite->yvel = 0;
|
pSprite->yvel = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||||
|
{
|
||||||
|
AIScorp ai;
|
||||||
|
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
|
||||||
|
}
|
||||||
END_PS_NS
|
END_PS_NS
|
||||||
|
|
Loading…
Reference in a new issue