- radial stuff.

This commit is contained in:
Christoph Oelckers 2021-10-21 18:22:14 +02:00
parent df9d1b1ceb
commit e6c7e5bc18
4 changed files with 25 additions and 34 deletions

View file

@ -738,8 +738,6 @@ extern FreeListArray<RunStruct, kMaxRuns> RunData;
extern RunChannel sRunChannels[kMaxChannels];
extern short NewRun;
extern int nRadialOwner;
extern short nRadialSpr;
void runlist_InitRun();

View file

@ -2176,9 +2176,9 @@ void AIObject::RadialDamage(RunListEvent* ev)
if (pActor->nHealth > 0 && pSprite->cstat & 0x101
&& (nStat != kStatExplodeTarget
|| sprite[nRadialSpr].statnum == 201
|| ev->pRadialActor->s().statnum == 201
|| (nRadialBullet != 3 && nRadialBullet > -1)
|| sprite[nRadialSpr].statnum == kStatExplodeTrigger))
|| ev->pRadialActor->s().statnum == kStatExplodeTrigger))
{
int nDamage = runlist_CheckRadialDamage(pActor);
if (nDamage <= 0) {

View file

@ -647,7 +647,6 @@ void AIPlayer::RadialDamage(RunListEvent* ev)
void AIPlayer::Damage(RunListEvent* ev)
{
int nSprite2;
int nDamage = ev->nDamage;
short nPlayer = RunData[ev->nRun].nObjIndex;
short nAction = PlayerList[nPlayer].nAction;
@ -659,11 +658,7 @@ void AIPlayer::Damage(RunListEvent* ev)
return;
}
if (ev->nMessage != EMessageType::RadialDamage)
{
nSprite2 = ev->nParam;
}
else nSprite2 = nRadialOwner;
DExhumedActor* pActor2 = (ev->nMessage != EMessageType::RadialDamage) ? ev->pOtherActor : ev->pRadialActor->pTarget;
// ok continue case 0x80000 as normal, loc_1C57C
if (!PlayerList[nPlayer].nHealth) {
@ -703,7 +698,7 @@ void AIPlayer::Damage(RunListEvent* ev)
PlayerList[nPlayer].field_2 = 0;
PlayerList[nPlayer].nAction = 4;
if (nSprite2 > -1)
if (pActor2)
{
PlayerList[nPlayer].nPlayerSwear--;
if (PlayerList[nPlayer].nPlayerSwear <= 0)
@ -721,9 +716,9 @@ void AIPlayer::Damage(RunListEvent* ev)
else
{
// player has died
if (nSprite2 > -1 && sprite[nSprite2].statnum == 100)
if (pActor2 && pActor2->s().statnum == 100)
{
short nPlayer2 = GetPlayerFromSprite(nSprite2);
short nPlayer2 = GetPlayerFromActor(pActor2);
if (nPlayer2 == nPlayer) // player caused their own death
{
@ -734,7 +729,7 @@ void AIPlayer::Damage(RunListEvent* ev)
PlayerList[nPlayer].nPlayerScore++;
}
}
else if (nSprite2 < 0)
else if (pActor2 == nullptr)
{
PlayerList[nPlayer].nPlayerScore--;
}

View file

@ -32,13 +32,12 @@ enum
};
short nRadialSpr = -1;
DExhumedActor* pRadialActor;
short nStackCount = 0;
short word_966BE = 0;
short ChannelList = -1;
short ChannelLast = -1;
int nRadialOwner;
int nDamageRadius;
int nRadialDamage;
short RunChain;
@ -68,12 +67,10 @@ void SerializeRunList(FSerializer& arc)
if (arc.BeginObject("runlist"))
{
arc("data", RunData)
("radialspr", nRadialSpr)
("stackcount", nStackCount)
("w966be", word_966BE)
("list", ChannelList)
("last", ChannelLast)
("radialowner", nRadialOwner)
("damageradius", nDamageRadius)
("radialdamage", nRadialDamage)
("runchain", RunChain)
@ -179,7 +176,7 @@ void runlist_InitRun()
PlayerList[i].nRun = -1;
}
nRadialSpr = -1;
pRadialActor = nullptr;
}
void runlist_UnlinkRun(int nRun)
@ -1562,9 +1559,11 @@ void runlist_ProcessWallTag(int nWall, short nLotag, short nHitag)
int runlist_CheckRadialDamage(short nSprite)
{
auto pActor = &exhumedActors[nSprite];
auto pSprite = &sprite[nSprite];
auto pRadialSpr = &pRadialActor->s();
if (nSprite == nRadialSpr) {
if (nSprite == pRadialActor->GetSpriteIndex()) {
return 0;
}
@ -1572,17 +1571,17 @@ int runlist_CheckRadialDamage(short nSprite)
return 0;
}
if (pSprite->statnum >= kMaxStatus || sprite[nRadialSpr].statnum >= kMaxStatus) {
if (pSprite->statnum >= kMaxStatus || pRadialSpr->statnum >= kMaxStatus) {
return 0;
}
if (pSprite->statnum != 100 && nSprite == nRadialOwner) {
if (pSprite->statnum != 100 && pActor == pRadialActor->pTarget) {
return 0;
}
int x = (pSprite->x - sprite[nRadialSpr].x) >> 8;
int y = (pSprite->y - sprite[nRadialSpr].y) >> 8;
int z = (pSprite->z - sprite[nRadialSpr].z) >> 12;
int x = (pSprite->x - pRadialSpr->x) >> 8;
int y = (pSprite->y - pRadialSpr->y) >> 8;
int z = (pSprite->z - pRadialSpr->z) >> 12;
if (abs(x) > nDamageRadius) {
return 0;
@ -1617,10 +1616,10 @@ int runlist_CheckRadialDamage(short nSprite)
pSprite->cstat = 0x101;
if (((kStatExplodeTarget - pSprite->statnum) <= 1) ||
cansee(sprite[nRadialSpr].x,
sprite[nRadialSpr].y,
sprite[nRadialSpr].z - 512,
sprite[nRadialSpr].sectnum,
cansee(pRadialSpr->x,
pRadialSpr->y,
pRadialSpr->z - 512,
pRadialSpr->sectnum,
pSprite->x,
pSprite->y,
pSprite->z - 8192,
@ -1663,16 +1662,15 @@ void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius)
return;
}
if (nRadialSpr == -1)
if (pRadialActor == nullptr)
{
nRadialDamage = nDamage * 4;
nDamageRadius = nRadius;
nRadialSpr = nSprite;
nRadialOwner = pSprite->owner;
pRadialActor = &exhumedActors[nSprite];
runlist_ExplodeSignalRun();
nRadialSpr = -1;
pRadialActor = nullptr;
}
}
@ -1780,7 +1778,7 @@ void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage
ev.nRadialDamage = nRadialDamage;
ev.nDamageRadius = nDamageRadius;
ev.pOtherActor = nullptr; // &exhumedActors[nObject]; nObject is always 0 here, this was setting some random invalid target
ev.pRadialActor = &exhumedActors[nRadialSpr];
ev.pRadialActor = pRadialActor;
ai->RadialDamage(&ev);
break;
}