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

This commit is contained in:
Christoph Oelckers 2021-12-23 17:08:24 +01:00
parent 013cf05042
commit b34a4af15e

View file

@ -40,43 +40,39 @@ static actionSeq ScorpSeq[] = {
void BuildScorp(DExhumedActor* pActor, int x, int y, int z, sectortype* pSector, int nAngle, int nChannel)
{
spritetype* pSprite;
if (pActor == nullptr)
{
pActor = insertActor(pSector, 122);
pSprite = &pActor->s();
}
else
{
ChangeActorStat(pActor, 122);
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 = 70;
pSprite->shade = -12;
pSprite->xrepeat = 80;
pSprite->yrepeat = 80;
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->extra = -1;
pSprite->hitag = 0;
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 = 70;
pActor->spr.shade = -12;
pActor->spr.xrepeat = 80;
pActor->spr.yrepeat = 80;
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.extra = -1;
pActor->spr.hitag = 0;
// GrabTimeSlot(3);
@ -90,7 +86,7 @@ void BuildScorp(DExhumedActor* pActor, int x, int y, int z, sectortype* pSector,
pActor->nChannel = nChannel;
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, pActor, 0x220000);
pActor->spr.owner = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x220000);
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x220000);
nCreaturesTotal++;
@ -121,9 +117,6 @@ void AIScorp::Damage(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
auto pSprite = &pActor->s();
DExhumedActor* pTarget = nullptr;
if (pActor->nHealth <= 0) {
@ -139,10 +132,10 @@ void AIScorp::Damage(RunListEvent* ev)
pActor->nFrame = 0;
pActor->nCount = 10;
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;
nCreaturesKilled++;
return;
@ -153,7 +146,7 @@ void AIScorp::Damage(RunListEvent* ev)
if (pTarget)
{
if (pSprite->statnum == 100 || (pSprite->statnum < 199 && !RandomSize(5)))
if (pActor->spr.statnum == 100 || (pActor->spr.statnum < 199 && !RandomSize(5)))
{
pActor->pTarget = pTarget;
}
@ -180,10 +173,7 @@ void AIScorp::Tick(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
int nAction = pActor->nAction;
auto pSprite = &pActor->s();
bool bVal = false;
DExhumedActor* pTarget = nullptr;
@ -194,7 +184,7 @@ void AIScorp::Tick(RunListEvent* ev)
int nSeq = SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a;
pSprite->picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
seq_MoveSequence(pActor, nSeq, pActor->nFrame);
pActor->nFrame++;
@ -232,8 +222,8 @@ void AIScorp::Tick(RunListEvent* ev)
D3PlayFX(StaticSound[kSound41], pActor);
pActor->nFrame = 0;
pSprite->xvel = bcos(pSprite->ang);
pSprite->yvel = bsin(pSprite->ang);
pActor->spr.xvel = bcos(pActor->spr.ang);
pActor->spr.yvel = bsin(pActor->spr.ang);
pActor->nAction = 1;
pActor->pTarget = pTarget;
@ -260,8 +250,8 @@ void AIScorp::Tick(RunListEvent* ev)
{
if (pTarget == nMov.actor())
{
int nAngle = getangle(pTarget->spr.pos.X - pSprite->pos.X, pTarget->spr.pos.Y - pSprite->pos.Y);
if (AngleDiff(pSprite->ang, nAngle) < 64)
int nAngle = getangle(pTarget->spr.pos.X - pActor->spr.pos.X, pTarget->spr.pos.Y - pActor->spr.pos.Y);
if (AngleDiff(pActor->spr.ang, nAngle) < 64)
{
pActor->nAction = 2;
pActor->nFrame = 0;
@ -317,8 +307,8 @@ void AIScorp::Tick(RunListEvent* ev)
{
pActor->nAction = 1;
pSprite->xvel = bcos(pSprite->ang);
pSprite->yvel = bsin(pSprite->ang);
pActor->spr.xvel = bcos(pActor->spr.ang);
pActor->spr.yvel = bsin(pActor->spr.ang);
pActor->nFrame = 0;
return;
@ -329,7 +319,7 @@ void AIScorp::Tick(RunListEvent* ev)
return;
}
auto nBulletSprite = BuildBullet(pActor, 16, -1, pSprite->ang, pTarget, 1);
auto nBulletSprite = BuildBullet(pActor, 16, -1, pActor->spr.ang, pTarget, 1);
if (nBulletSprite)
{
PlotCourseToSprite(nBulletSprite, pTarget);
@ -379,7 +369,7 @@ void AIScorp::Tick(RunListEvent* ev)
return;
}
auto pSpiderActor = BuildSpider(nullptr, pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z, pSprite->sector(), pSprite->ang);
auto pSpiderActor = BuildSpider(nullptr, pActor->spr.pos.X, pActor->spr.pos.Y, pActor->spr.pos.Z, pActor->spr.sector(), pActor->spr.ang);
if (pSpiderActor)
{
auto pSpiderSprite = &pSpiderActor->s();
@ -397,13 +387,13 @@ void AIScorp::Tick(RunListEvent* ev)
case 9:
{
pSprite->cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
pActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
if (bVal)
{
runlist_SubRunRec(pActor->nRun);
runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(pSprite->lotag - 1);
runlist_DoSubRunRec(pActor->spr.owner);
runlist_FreeRun(pActor->spr.lotag - 1);
DeleteActor(pActor);
}
@ -419,16 +409,15 @@ void AIScorp::Effect(RunListEvent* ev, DExhumedActor* pTarget, int mode)
if (!pActor) return;
int nAction = pActor->nAction;
auto pSprite = &pActor->s();
if (mode == 0)
{
PlotCourseToSprite(pActor, pTarget);
pSprite->ang += RandomSize(7) - 63;
pSprite->ang &= kAngleMask;
pActor->spr.ang += RandomSize(7) - 63;
pActor->spr.ang &= kAngleMask;
pSprite->xvel = bcos(pSprite->ang);
pSprite->yvel = bsin(pSprite->ang);
pActor->spr.xvel = bcos(pActor->spr.ang);
pActor->spr.yvel = bsin(pActor->spr.ang);
}
if (mode <= 1)
{
@ -440,12 +429,12 @@ void AIScorp::Effect(RunListEvent* ev, DExhumedActor* pTarget, int mode)
{
pActor->nCount = 45;
if (cansee(pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - GetActorHeight(pActor), pSprite->sector(),
if (cansee(pActor->spr.pos.X, pActor->spr.pos.Y, pActor->spr.pos.Z - GetActorHeight(pActor), pActor->spr.sector(),
pTarget->spr.pos.X, pTarget->spr.pos.Y, pTarget->spr.pos.Z - GetActorHeight(pTarget), pTarget->spr.sector()))
{
pSprite->xvel = 0;
pSprite->yvel = 0;
pSprite->ang = GetMyAngle(pTarget->spr.pos.X - pSprite->pos.X, pTarget->spr.pos.Y - pSprite->pos.Y);
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
pActor->spr.ang = GetMyAngle(pTarget->spr.pos.X - pActor->spr.pos.X, pTarget->spr.pos.Y - pActor->spr.pos.Y);
pActor->nIndex = RandomSize(2) + RandomSize(3);
@ -472,8 +461,8 @@ void AIScorp::Effect(RunListEvent* ev, DExhumedActor* pTarget, int mode)
pActor->nCount = 30;
pActor->pTarget = nullptr;
pSprite->xvel = 0;
pSprite->yvel = 0;
pActor->spr.xvel = 0;
pActor->spr.yvel = 0;
}
}