- converted FuncPlayer into a class

This commit is contained in:
Christoph Oelckers 2021-10-15 22:19:07 +02:00
parent f13e1f2127
commit 93b0a35927
2 changed files with 1900 additions and 1884 deletions

View file

@ -555,6 +555,14 @@ struct AIObject : public ExhumedAI
void RadialDamage(RunListEvent* ev) override;
};
struct AIPlayer : 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);
typedef void(*AiFunc)(int, int, int, int nRun);

View file

@ -652,66 +652,50 @@ void UpdatePlayerSpriteAngle(Player* pPlayer)
inita = sprite[pPlayer->nSprite].ang = pPlayer->angle.ang.asbuild();
}
void FuncPlayer(int nObject, int nMessage, int nDamage, int nRun)
void AIPlayer::Draw(RunListEvent* ev)
{
int var_48 = 0;
int var_40;
bool mplevel = (currentLevel->gameflags & LEVEL_EX_MULTI);
short nPlayer = RunData[ev->nRun].nVal;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
short nAction = PlayerList[nPlayer].nAction;
short nPlayer = RunData[nRun].nVal;
seq_PlotSequence(ev->nIndex, SeqOffsets[PlayerList[nPlayer].nSeq] + PlayerSeq[nAction].a, PlayerList[nPlayer].field_2, PlayerSeq[nAction].b);
}
void AIPlayer::RadialDamage(RunListEvent* ev)
{
short nPlayer = RunData[ev->nRun].nVal;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
short nPlayerSprite = PlayerList[nPlayer].nSprite;
auto pPlayerSprite = &sprite[nPlayerSprite];
if (PlayerList[nPlayer].nHealth <= 0)
{
return;
}
ev->nDamage = runlist_CheckRadialDamage(nPlayerSprite);
Damage(ev);
}
void AIPlayer::Damage(RunListEvent* ev)
{
int nSprite2;
int nDamage = ev->nDamage;
short nPlayer = RunData[ev->nRun].nVal;
short nAction = PlayerList[nPlayer].nAction;
short nPlayerSprite = PlayerList[nPlayer].nSprite;
auto pPlayerSprite = &sprite[nPlayerSprite];
short nDopple = nDoppleSprite[nPlayer];
short nAction = PlayerList[nPlayer].nAction;
short nActionB = PlayerList[nPlayer].nAction;
short nSprite2;
PlayerList[nPlayer].angle.backup();
PlayerList[nPlayer].horizon.backup();
PlayerList[nPlayer].angle.resetadjustment();
PlayerList[nPlayer].horizon.resetadjustment();
oeyelevel[nPlayer] = eyelevel[nPlayer];
switch (nMessage)
{
case 0x90000:
{
seq_PlotSequence(nObject, SeqOffsets[PlayerList[nPlayer].nSeq] + PlayerSeq[nAction].a, PlayerList[nPlayer].field_2, PlayerSeq[nAction].b);
return;
}
case 0xA0000:
{
if (PlayerList[nPlayer].nHealth <= 0) {
return;
}
nDamage = runlist_CheckRadialDamage(nPlayerSprite);
if (!nDamage) {
return;
}
nSprite2 = nRadialOwner;
// fall through to case 0x80000
fallthrough__;
}
case 0x80000:
if (ev->nMessage != EMessageType::RadialDamage)
{
// Dunno how to do this otherwise... we fall through from above but don't want to do this check..
if (nMessage != 0xA0000)
{
if (!nDamage) {
return;
}
nSprite2 = nObject;
nSprite2 = ev->nIndex;
}
else nSprite2 = nRadialOwner;
// ok continue case 0x80000 as normal, loc_1C57C
if (!PlayerList[nPlayer].nHealth) {
@ -787,7 +771,7 @@ void FuncPlayer(int nObject, int nMessage, int nDamage, int nRun)
nPlayerScore[nPlayer]--;
}
if (nMessage == 0xA0000)
if (ev->nMessage == EMessageType::RadialDamage)
{
for (int i = 122; i <= 131; i++)
{
@ -801,12 +785,32 @@ void FuncPlayer(int nObject, int nMessage, int nDamage, int nRun)
StartDeathSeq(nPlayer, 0);
}
}
}
return;
}
case 0x20000:
{
void AIPlayer::Tick(RunListEvent* ev)
{
int var_48 = 0;
int var_40;
bool mplevel = (currentLevel->gameflags & LEVEL_EX_MULTI);
short nPlayer = RunData[ev->nRun].nVal;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
short nPlayerSprite = PlayerList[nPlayer].nSprite;
auto pPlayerSprite = &sprite[nPlayerSprite];
short nDopple = nDoppleSprite[nPlayer];
short nAction = PlayerList[nPlayer].nAction;
short nActionB = PlayerList[nPlayer].nAction;
PlayerList[nPlayer].angle.backup();
PlayerList[nPlayer].horizon.backup();
PlayerList[nPlayer].angle.resetadjustment();
PlayerList[nPlayer].horizon.resetadjustment();
oeyelevel[nPlayer] = eyelevel[nPlayer];
pPlayerSprite->xvel = sPlayerInput[nPlayer].xVel >> 14;
pPlayerSprite->yvel = sPlayerInput[nPlayer].yVel >> 14;
@ -973,7 +977,7 @@ void FuncPlayer(int nObject, int nMessage, int nDamage, int nRun)
}
}
// int _bTouchFloor = bTouchFloor;
// int _bTouchFloor = bTouchFloor;
short bUnderwater = SectFlag[pPlayerSprite->sectnum] & kSectUnderwater;
if (bUnderwater)
@ -1383,7 +1387,7 @@ sectdone:
{
switch (itemtype)
{
do_default:
do_default:
default:
{
// loc_1B3C7
@ -1398,7 +1402,7 @@ do_default:
{
StartRegenerate(nValB);
}
do_default_b:
do_default_b:
// loc_1BA74
if (nPlayer == nLocalPlayer)
{
@ -1407,7 +1411,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -1472,7 +1476,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -1558,7 +1562,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -1627,7 +1631,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -1696,7 +1700,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -1852,7 +1856,7 @@ do_default_b:
pSprite->cstat = 0x8000;
DestroyItemAnim(nValB);
////
////
// loc_1BA74: - repeated block, see in default case
if (nPlayer == nLocalPlayer)
{
@ -1861,7 +1865,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -1870,7 +1874,7 @@ do_default_b:
}
break;
/////
/////
}
case 22: // .357 Magnum Revolver
@ -1914,7 +1918,7 @@ do_default_b:
pSprite->cstat = 0x8000;
DestroyItemAnim(nValB);
////
////
// loc_1BA74: - repeated block, see in default case
if (nPlayer == nLocalPlayer)
{
@ -1923,7 +1927,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -1932,7 +1936,7 @@ do_default_b:
}
break;
/////
/////
}
case 23: // M - 60 Machine Gun
@ -1976,7 +1980,7 @@ do_default_b:
pSprite->cstat = 0x8000;
DestroyItemAnim(nValB);
////
////
// loc_1BA74: - repeated block, see in default case
if (nPlayer == nLocalPlayer)
{
@ -1985,7 +1989,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -1994,7 +1998,7 @@ do_default_b:
}
break;
/////
/////
}
case 24: // Flame Thrower
@ -2038,7 +2042,7 @@ do_default_b:
pSprite->cstat = 0x8000;
DestroyItemAnim(nValB);
////
////
// loc_1BA74: - repeated block, see in default case
if (nPlayer == nLocalPlayer)
{
@ -2047,7 +2051,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -2056,7 +2060,7 @@ do_default_b:
}
break;
/////
/////
}
case 26: // Cobra Staff
@ -2100,7 +2104,7 @@ do_default_b:
pSprite->cstat = 0x8000;
DestroyItemAnim(nValB);
////
////
// loc_1BA74: - repeated block, see in default case
if (nPlayer == nLocalPlayer)
{
@ -2109,7 +2113,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -2118,7 +2122,7 @@ do_default_b:
}
break;
/////
/////
}
case 27: // Eye of Ra Gauntlet
@ -2162,7 +2166,7 @@ do_default_b:
pSprite->cstat = 0x8000;
DestroyItemAnim(nValB);
////
////
// loc_1BA74: - repeated block, see in default case
if (nPlayer == nLocalPlayer)
{
@ -2171,7 +2175,7 @@ do_default_b:
pickupMessage(var_70);
}
TintPalette(var_44*4, var_8C*4, 0);
TintPalette(var_44 * 4, var_8C * 4, 0);
if (var_88 > -1)
{
@ -2180,7 +2184,7 @@ do_default_b:
}
break;
/////
/////
}
case 31: // Cobra staff ammo
@ -2365,7 +2369,7 @@ do_default_b:
eyelevel[nPlayer] += ((-8320 - eyelevel[nPlayer]) >> 1);
}
loc_1BD2E:
loc_1BD2E:
if (totalvel[nPlayer] < 1) {
nActionB = 6;
}
@ -2663,10 +2667,14 @@ loc_1BD2E:
}
MoveWeapons(nPlayer);
}
return;
}
}
void FuncPlayer(int nObject, int nMessage, int nDamage, int nRun)
{
AIPlayer ai;
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
}