- Exhumed: pActor->s() in lion.cpp

This commit is contained in:
Christoph Oelckers 2021-12-23 17:04:12 +01:00
parent 5700b8ade6
commit ca88e241e1

View file

@ -43,41 +43,38 @@ static actionSeq LionSeq[] = {
void BuildLion(DExhumedActor* pActor, int x, int y, int z, sectortype* pSector, int nAngle)
{
spritetype* pSprite;
if (pActor == nullptr)
{
pActor = insertActor(pSector, 104);
pSprite = &pActor->s();
}
else
{
ChangeActorStat(pActor, 104);
pSprite = &pActor->s();
x = pSprite->pos.X;
y = pSprite->pos.Y;
z = pSprite->sector()->floorz;
nAngle = pSprite->ang;
x = pActor->spr.pos.X;
y = pActor->spr.pos.Y;
z = pActor->spr.sector()->floorz;
nAngle = pActor->spr.ang;
}
pSprite->pos.X = x;
pSprite->pos.Y = y;
pSprite->pos.Z = z;
pSprite->cstat = CSTAT_SPRITE_BLOCK_ALL;
pSprite->clipdist = 60;
pSprite->shade = -12;
pSprite->xrepeat = 40;
pSprite->yrepeat = 40;
pSprite->picnum = 1;
pSprite->pal = pSprite->sector()->ceilingpal;
pSprite->xoffset = 0;
pSprite->yoffset = 0;
pSprite->ang = nAngle;
pSprite->xvel = 0;
pSprite->yvel = 0;
pSprite->zvel = 0;
pSprite->lotag = runlist_HeadRun() + 1;
pSprite->hitag = 0;
pSprite->extra = -1;
pActor->spr.pos.X = x;
pActor->spr.pos.Y = y;
pActor->spr.pos.Z = z;
pActor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
pActor->spr.clipdist = 60;
pActor->spr.shade = -12;
pActor->spr.xrepeat = 40;
pActor->spr.yrepeat = 40;
pActor->spr.picnum = 1;
pActor->spr.pal = pActor->spr.sector()->ceilingpal;
pActor->spr.xoffset = 0;
pActor->spr.yoffset = 0;
pActor->spr.ang = nAngle;
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
pActor->spr.zvel = 0;
pActor->spr.lotag = runlist_HeadRun() + 1;
pActor->spr.hitag = 0;
pActor->spr.extra = -1;
// GrabTimeSlot(3);
@ -88,7 +85,7 @@ void BuildLion(DExhumedActor* pActor, int x, int y, int z, sectortype* pSector,
pActor->nCount = 0;
pActor->nPhase = Counters[kCountLion]++;
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, pActor, 0x130000);
pActor->spr.owner = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x130000);
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x130000);
@ -118,7 +115,6 @@ void AILion::Damage(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
auto pSprite = &pActor->s();
int nAction = pActor->nAction;
if (ev->nDamage && pActor->nHealth > 0)
@ -127,10 +123,10 @@ void AILion::Damage(RunListEvent* ev)
if (pActor->nHealth <= 0)
{
// R.I.P.
pSprite->xvel = 0;
pSprite->yvel = 0;
pSprite->zvel = 0;
pSprite->cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
pActor->spr.zvel = 0;
pActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
pActor->nHealth = 0;
@ -168,22 +164,22 @@ void AILion::Damage(RunListEvent* ev)
if (RandomSize(8) <= (pActor->nHealth >> 2))
{
pActor->nAction = 4;
pSprite->xvel = 0;
pSprite->yvel = 0;
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
}
else if (RandomSize(1))
{
PlotCourseToSprite(pActor, pTarget);
pActor->nAction = 5;
pActor->nCount = RandomSize(3);
pSprite->ang = (pSprite->ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code
pActor->spr.ang = (pActor->spr.ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code
}
else
{
pActor->nAction = 8;
pSprite->xvel = 0;
pSprite->yvel = 0;
pSprite->cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
pActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
}
pActor->nFrame = 0;
@ -198,7 +194,6 @@ void AILion::Tick(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
auto pSprite = &pActor->s();
int nAction = pActor->nAction;
bool bVal = false;
@ -210,7 +205,7 @@ void AILion::Tick(RunListEvent* ev)
int nSeq = SeqOffsets[kSeqLion] + LionSeq[nAction].a;
pSprite->picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
seq_MoveSequence(pActor, nSeq, pActor->nFrame);
@ -245,8 +240,8 @@ void AILion::Tick(RunListEvent* ev)
pActor->nAction = 2;
pActor->nFrame = 0;
pSprite->xvel = bcos(pSprite->ang, -1);
pSprite->yvel = bsin(pSprite->ang, -1);
pActor->spr.xvel = bcos(pActor->spr.ang, -1);
pActor->spr.yvel = bsin(pActor->spr.ang, -1);
pActor->pTarget = pTarget;
return;
}
@ -260,14 +255,14 @@ void AILion::Tick(RunListEvent* ev)
{
if (RandomBit())
{
pSprite->ang = RandomWord() & kAngleMask;
pSprite->xvel = bcos(pSprite->ang, -1);
pSprite->yvel = bsin(pSprite->ang, -1);
pActor->spr.ang = RandomWord() & kAngleMask;
pActor->spr.xvel = bcos(pActor->spr.ang, -1);
pActor->spr.yvel = bsin(pActor->spr.ang, -1);
}
else
{
pSprite->xvel = 0;
pSprite->yvel = 0;
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
}
pActor->nCount = 100;
@ -283,44 +278,44 @@ void AILion::Tick(RunListEvent* ev)
{
PlotCourseToSprite(pActor, pTarget);
int nAng = pSprite->ang & 0xFFF8;
int nAng = pActor->spr.ang & 0xFFF8;
if (pSprite->cstat & CSTAT_SPRITE_INVISIBLE)
if (pActor->spr.cstat & CSTAT_SPRITE_INVISIBLE)
{
pSprite->xvel = bcos(nAng, 1);
pSprite->yvel = bsin(nAng, 1);
pActor->spr.xvel = bcos(nAng, 1);
pActor->spr.yvel = bsin(nAng, 1);
}
else
{
pSprite->xvel = bcos(nAng, -1);
pSprite->yvel = bsin(nAng, -1);
pActor->spr.xvel = bcos(nAng, -1);
pActor->spr.yvel = bsin(nAng, -1);
}
}
if (nMov.type == kHitWall)
{
// loc_378FA:
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
pSprite->xvel = bcos(pSprite->ang, -1);
pSprite->yvel = bsin(pSprite->ang, -1);
pActor->spr.ang = (pActor->spr.ang + 256) & kAngleMask;
pActor->spr.xvel = bcos(pActor->spr.ang, -1);
pActor->spr.yvel = bsin(pActor->spr.ang, -1);
break;
}
else if (nMov.type == kHitSprite)
{
if (nMov.actor() == pTarget)
{
if (pSprite->cstat & CSTAT_SPRITE_INVISIBLE)
if (pActor->spr.cstat & CSTAT_SPRITE_INVISIBLE)
{
pActor->nAction = 9;
pSprite->cstat &= ~CSTAT_SPRITE_BLOCK;
pSprite->xvel = 0;
pSprite->yvel = 0;
pActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK;
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
}
else
{
int nAng = getangle(pTarget->spr.pos.X - pSprite->pos.X, pTarget->spr.pos.Y - pSprite->pos.Y);
int nAng = getangle(pTarget->spr.pos.X - pActor->spr.pos.X, pTarget->spr.pos.Y - pActor->spr.pos.Y);
if (AngleDiff(pSprite->ang, nAng) < 64)
if (AngleDiff(pActor->spr.ang, nAng) < 64)
{
pActor->nAction = 3;
}
@ -332,9 +327,9 @@ void AILion::Tick(RunListEvent* ev)
else
{
// loc_378FA:
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
pSprite->xvel = bcos(pSprite->ang, -1);
pSprite->yvel = bsin(pSprite->ang, -1);
pActor->spr.ang = (pActor->spr.ang + 256) & kAngleMask;
pActor->spr.xvel = bcos(pActor->spr.ang, -1);
pActor->spr.yvel = bsin(pActor->spr.ang, -1);
break;
}
}
@ -374,8 +369,8 @@ void AILion::Tick(RunListEvent* ev)
if (nMov.exbits & kHitAux2)
{
pSprite->xvel >>= 1;
pSprite->yvel >>= 1;
pActor->spr.xvel >>= 1;
pActor->spr.yvel >>= 1;
}
return;
@ -386,23 +381,23 @@ void AILion::Tick(RunListEvent* ev)
pActor->nCount--;
if (pActor->nCount <= 0)
{
pSprite->zvel = -4000;
pActor->spr.zvel = -4000;
pActor->nCount = 0;
int x = pSprite->pos.X;
int y = pSprite->pos.Y;
int z = pSprite->pos.Z - (GetActorHeight(pActor) >> 1);
int x = pActor->spr.pos.X;
int y = pActor->spr.pos.Y;
int z = pActor->spr.pos.Z - (GetActorHeight(pActor) >> 1);
int nCheckDist = 0x7FFFFFFF;
int nAngle = pSprite->ang;
int nScanAngle = (pSprite->ang - 512) & kAngleMask;
int nAngle = pActor->spr.ang;
int nScanAngle = (pActor->spr.ang - 512) & kAngleMask;
for (int i = 0; i < 5; i++)
{
HitInfo hit{};
hitscan({ x, y, z }, pSprite->sector(), { bcos(nScanAngle), bsin(nScanAngle), 0 }, hit, CLIPMASK1);
hitscan({ x, y, z }, pActor->spr.sector(), { bcos(nScanAngle), bsin(nScanAngle), 0 }, hit, CLIPMASK1);
if (hit.hitWall)
{
@ -420,11 +415,11 @@ void AILion::Tick(RunListEvent* ev)
nScanAngle &= kAngleMask;
}
pSprite->ang = nAngle;
pActor->spr.ang = nAngle;
pActor->nAction = 6;
pSprite->xvel = bcos(pSprite->ang) - bcos(pSprite->ang, -3);
pSprite->yvel = bsin(pSprite->ang) - bsin(pSprite->ang, -3);
pActor->spr.xvel = bcos(pActor->spr.ang) - bcos(pActor->spr.ang, -3);
pActor->spr.yvel = bsin(pActor->spr.ang) - bsin(pActor->spr.ang, -3);
D3PlayFX(StaticSound[kSound24], pActor);
}
@ -443,7 +438,7 @@ void AILion::Tick(RunListEvent* ev)
if (nMov.type == kHitWall)
{
pActor->nAction = 7;
pSprite->ang = (GetWallNormal(nMov.hitWall) + 1024) & kAngleMask;
pActor->spr.ang = (GetWallNormal(nMov.hitWall) + 1024) & kAngleMask;
pActor->nCount = RandomSize(4);
return;
}
@ -451,8 +446,8 @@ void AILion::Tick(RunListEvent* ev)
{
if (nMov.actor() == pTarget)
{
int nAng = getangle(pTarget->spr.pos.X - pSprite->pos.X, pTarget->spr.pos.Y - pSprite->pos.Y);
if (AngleDiff(pSprite->ang, nAng) < 64)
int nAng = getangle(pTarget->spr.pos.X - pActor->spr.pos.X, pTarget->spr.pos.Y - pActor->spr.pos.Y);
if (AngleDiff(pActor->spr.ang, nAng) < 64)
{
pActor->nAction = 3;
pActor->nFrame = 0;
@ -461,9 +456,9 @@ void AILion::Tick(RunListEvent* ev)
else
{
// loc_378FA:
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
pSprite->xvel = bcos(pSprite->ang, -1);
pSprite->yvel = bsin(pSprite->ang, -1);
pActor->spr.ang = (pActor->spr.ang + 256) & kAngleMask;
pActor->spr.xvel = bcos(pActor->spr.ang, -1);
pActor->spr.yvel = bsin(pActor->spr.ang, -1);
break;
}
}
@ -484,14 +479,14 @@ void AILion::Tick(RunListEvent* ev)
}
else
{
pSprite->ang = (RandomSize(9) + (pSprite->ang + 768)) & kAngleMask;
pActor->spr.ang = (RandomSize(9) + (pActor->spr.ang + 768)) & kAngleMask;
}
pSprite->zvel = -1000;
pActor->spr.zvel = -1000;
pActor->nAction = 6;
pSprite->xvel = bcos(pSprite->ang) - bcos(pSprite->ang, -3);
pSprite->yvel = bsin(pSprite->ang) - bsin(pSprite->ang, -3);
pActor->spr.xvel = bcos(pActor->spr.ang) - bcos(pActor->spr.ang, -3);
pActor->spr.yvel = bsin(pActor->spr.ang) - bsin(pActor->spr.ang, -3);
D3PlayFX(StaticSound[kSound24], pActor);
}
@ -504,7 +499,7 @@ void AILion::Tick(RunListEvent* ev)
{
pActor->nAction = 2;
pActor->nFrame = 0;
pSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
pActor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
}
return;
}
@ -515,7 +510,7 @@ void AILion::Tick(RunListEvent* ev)
{
pActor->nFrame = 0;
pActor->nAction = 2;
pSprite->cstat |= CSTAT_SPRITE_BLOCK_ALL;
pActor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
}
return;
}
@ -525,9 +520,9 @@ void AILion::Tick(RunListEvent* ev)
{
if (bVal)
{
runlist_SubRunRec(pSprite->owner);
runlist_SubRunRec(pActor->spr.owner);
runlist_SubRunRec(pActor->nRun);
pSprite->cstat = CSTAT_SPRITE_INVISIBLE;
pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
}
return;
}
@ -542,8 +537,8 @@ void AILion::Tick(RunListEvent* ev)
pActor->nFrame = 0;
pActor->nCount = 100;
pActor->pTarget = nullptr;
pSprite->xvel = 0;
pSprite->yvel = 0;
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
}
}
}