- quick replace of 'pSprite->' with 'actor->spr.' in AI files.

This commit is contained in:
Christoph Oelckers 2021-12-22 20:22:35 +01:00
parent 612167cbf1
commit e123e61f99
18 changed files with 887 additions and 887 deletions

View file

@ -67,10 +67,10 @@ void SlashSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
// Correct ? // Correct ?
int dz = pSprite->pos.Z - target->spr.pos.Z; int dz = actor->spr.pos.Z - target->spr.pos.Z;
dx += Random3(4000 - 700 * gGameOptions.nDifficulty); dx += Random3(4000 - 700 * gGameOptions.nDifficulty);
dy += Random3(4000 - 700 * gGameOptions.nDifficulty); dy += Random3(4000 - 700 * gGameOptions.nDifficulty);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGargSlash); actFireVector(actor, 0, 0, dx, dy, dz, kVectorGargSlash);
@ -82,18 +82,18 @@ void SlashSeqCallback(int, DBloodActor* actor)
void StompSeqCallback(int, DBloodActor* actor) void StompSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
int x = pSprite->pos.X; int x = actor->spr.pos.X;
int y = pSprite->pos.Y; int y = actor->spr.pos.Y;
int z = pSprite->pos.Z; int z = actor->spr.pos.Z;
int vc = 400; int vc = 400;
auto pSector = pSprite->sector(); auto pSector = actor->spr.sector();
int v1c = 5 + 2 * gGameOptions.nDifficulty; int v1c = 5 + 2 * gGameOptions.nDifficulty;
int v10 = 25 + 30 * gGameOptions.nDifficulty; int v10 = 25 + 30 * gGameOptions.nDifficulty;
const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic
auto sectorMap = GetClosestSpriteSectors(pSector, x, y, vc, nullptr, newSectCheckMethod); auto sectorMap = GetClosestSpriteSectors(pSector, x, y, vc, nullptr, newSectCheckMethod);
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
DBloodActor* actor2 = nullptr; DBloodActor* actor2 = nullptr;
actHitcodeToData(hit, &gHitInfo, &actor2); actHitcodeToData(hit, &gHitInfo, &actor2);
@ -116,8 +116,8 @@ void StompSeqCallback(int, DBloodActor* actor)
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (abs(bottom - pSector->floorz) == 0) if (abs(bottom - pSector->floorz) == 0)
{ {
int dx = abs(pSprite->pos.X - pSprite2->pos.X); int dx = abs(actor->spr.pos.X - pSprite2->pos.X);
int dy = abs(pSprite->pos.Y - pSprite2->pos.Y); int dy = abs(actor->spr.pos.Y - pSprite2->pos.Y);
int nDist2 = ksqrt(dx * dx + dy * dy); int nDist2 = ksqrt(dx * dx + dy * dy);
if (nDist2 <= vc) if (nDist2 <= vc)
{ {
@ -146,8 +146,8 @@ void StompSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor2->x(); XSPRITE* pXSprite = &actor2->x();
if (pXSprite->locked) if (pXSprite->locked)
continue; continue;
int dx = abs(pSprite->pos.X - pSprite2->pos.X); int dx = abs(actor->spr.pos.X - pSprite2->pos.X);
int dy = abs(pSprite->pos.Y - pSprite2->pos.Y); int dy = abs(actor->spr.pos.Y - pSprite2->pos.Y);
int nDist2 = ksqrt(dx * dx + dy * dy); int nDist2 = ksqrt(dx * dx + dy * dy);
if (nDist2 <= vc) if (nDist2 <= vc)
{ {
@ -169,7 +169,7 @@ static void MorphToBeast(DBloodActor* actor)
{ {
auto pSprite = &actor->s(); auto pSprite = &actor->s();
actHealDude(actor, dudeInfo[51].startHealth, dudeInfo[51].startHealth); actHealDude(actor, dudeInfo[51].startHealth, dudeInfo[51].startHealth);
pSprite->type = kDudeBeast; actor->spr.type = kDudeBeast;
} }
static void beastThinkSearch(DBloodActor* actor) static void beastThinkSearch(DBloodActor* actor)
@ -183,17 +183,17 @@ static void beastThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto pSector = pSprite->sector(); auto pSector = actor->spr.sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr; auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &beastSwimSearch); aiNewState(actor, &beastSwimSearch);
@ -208,7 +208,7 @@ static void beastThinkChase(DBloodActor* actor)
auto const pSprite = &actor->s(); auto const pSprite = &actor->s();
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
{ {
auto pSector = pSprite->sector(); auto pSector = actor->spr.sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr; auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
@ -217,16 +217,16 @@ static void beastThinkChase(DBloodActor* actor)
aiNewState(actor, &beastSearch); aiNewState(actor, &beastSearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
auto pSector = pSprite->sector(); auto pSector = actor->spr.sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr; auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
if (pXTarget->health == 0) if (pXTarget->health == 0)
@ -248,18 +248,18 @@ static void beastThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = nDist == 0? 0 : DivScale(target->spr.pos.Z - pSprite->pos.Z, nDist, 10); actor->dudeSlope = nDist == 0? 0 : DivScale(target->spr.pos.Z - actor->spr.pos.Z, nDist, 10);
if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (target->spr.flags & 2) if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (target->spr.flags & 2)
&& target->IsPlayerActor() && Chance(0x8000)) && target->IsPlayerActor() && Chance(0x8000))
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
if (pXTarget->health > (unsigned)gPlayerTemplate[0].startHealth / 2) if (pXTarget->health > (unsigned)gPlayerTemplate[0].startHealth / 2)
{ {
switch (hit) switch (hit)
@ -269,7 +269,7 @@ static void beastThinkChase(DBloodActor* actor)
aiNewState(actor, &beastStomp); aiNewState(actor, &beastStomp);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type) if (actor->spr.type != gHitInfo.actor()->spr.type)
{ {
if (!pXSector || !pXSector->Underwater) if (!pXSector || !pXSector->Underwater)
aiNewState(actor, &beastStomp); aiNewState(actor, &beastStomp);
@ -291,7 +291,7 @@ static void beastThinkChase(DBloodActor* actor)
} }
if (nDist < 921 && abs(nDeltaAngle) < 28) if (nDist < 921 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -301,7 +301,7 @@ static void beastThinkChase(DBloodActor* actor)
aiNewState(actor, &beastSlash); aiNewState(actor, &beastSlash);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type) if (actor->spr.type != gHitInfo.actor()->spr.type)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &beastSwimSlash); aiNewState(actor, &beastSwimSlash);
@ -340,14 +340,14 @@ static void beastThinkSwimGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &beastSwimSearch); aiNewState(actor, &beastSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -360,13 +360,13 @@ static void beastThinkSwimChase(DBloodActor* actor)
aiNewState(actor, &beastSwimGoto); aiNewState(actor, &beastSwimGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -381,11 +381,11 @@ static void beastThinkSwimChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = pDudeInfo->eyeHeight + pSprite->pos.Z; int height = pDudeInfo->eyeHeight + actor->spr.pos.Z;
int top, bottom; int top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
@ -411,43 +411,43 @@ static void beastMoveForward(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= 0x400 && Random(64) < 32) if (nDist <= 0x400 && Random(64) < 32)
return; return;
actor->xvel += MulScale(pDudeInfo->frontSpeed, Cos(pSprite->ang), 30); actor->xvel += MulScale(pDudeInfo->frontSpeed, Cos(actor->spr.ang), 30);
actor->yvel += MulScale(pDudeInfo->frontSpeed, Sin(pSprite->ang), 30); actor->yvel += MulScale(pDudeInfo->frontSpeed, Sin(actor->spr.ang), 30);
} }
static void sub_628A0(DBloodActor* actor) static void sub_628A0(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang + 256) & 2047; actor->spr.ang = (actor->spr.ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400) if (Random(64) < 32 && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -464,29 +464,29 @@ static void sub_62AE0(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int z = pSprite->pos.Z + getDudeInfo(pSprite->type)->eyeHeight; int z = actor->spr.pos.Z + getDudeInfo(actor->spr.type)->eyeHeight;
int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight; int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang + 512) & 2047; pXSprite->goalAng = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int dz = z2 - z; int dz = z2 - z;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400) if (Chance(0x600) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -501,29 +501,29 @@ static void sub_62D7C(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int z = pSprite->pos.Z + getDudeInfo(pSprite->type)->eyeHeight; int z = actor->spr.pos.Z + getDudeInfo(actor->spr.type)->eyeHeight;
int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight; int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang + 512) & 2047; actor->spr.ang = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int dz = (z2 - z) << 3; int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400) if (Chance(0x4000) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);

View file

@ -79,12 +79,12 @@ void eelBiteSeqCallback(int, DBloodActor* actor)
} }
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type); DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type);
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2; int height = (actor->spr.yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2; int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2;
actFireVector(actor, 0, 0, dx, dy, height2 - height, kVectorBoneelBite); actFireVector(actor, 0, 0, dx, dy, height2 - height, kVectorBoneelBite);
} }
@ -93,8 +93,8 @@ static void eelThinkTarget(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++; pDudeExtraE->thinkTime++;
@ -114,18 +114,18 @@ static void eelThinkTarget(DBloodActor* actor)
PLAYER* pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->pos.X; int x = pPlayer->actor->spr.pos.X;
int y = pPlayer->pSprite->pos.Y; int y = pPlayer->actor->spr.pos.Y;
int z = pPlayer->pSprite->pos.Z; int z = pPlayer->actor->spr.pos.Z;
auto pSector = pPlayer->pSprite->sector(); auto pSector = pPlayer->actor->spr.sector();
int dx = x - pSprite->pos.X; int dx = x - actor->spr.pos.X;
int dy = y - pSprite->pos.Y; int dy = y - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
if (!cansee(x, y, z, pSector, pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) if (!cansee(x, y, z, pSector, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - ((pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2), actor->spr.sector()))
continue; continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->thinkTime = 0; pDudeExtraE->thinkTime = 0;
@ -156,14 +156,14 @@ static void eelThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
eelThinkTarget(actor); eelThinkTarget(actor);
} }
@ -176,12 +176,12 @@ static void eelThinkPonder(DBloodActor* actor)
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -191,12 +191,12 @@ static void eelThinkPonder(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
int height2 = (getDudeInfo(target->spr.type)->eyeHeight * target->spr.yrepeat) << 2; int height2 = (getDudeInfo(target->spr.type)->eyeHeight * target->spr.yrepeat) << 2;
int top, bottom; int top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
if (height2 - height < -0x2000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) if (height2 - height < -0x2000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
@ -226,13 +226,13 @@ static void eelMoveDodgeUp(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int dx = actor->xvel; int dx = actor->xvel;
int dy = actor->yvel; int dy = actor->yvel;
int t1 = DMulScale(dx, nCos, dy, nSin, 30); int t1 = DMulScale(dx, nCos, dy, nSin, 30);
@ -251,15 +251,15 @@ static void eelMoveDodgeDown(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (pXSprite->dodgeDir == 0) if (pXSprite->dodgeDir == 0)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int dx = actor->xvel; int dx = actor->xvel;
int dy = actor->yvel; int dy = actor->yvel;
int t1 = DMulScale(dx, nCos, dy, nSin, 30); int t1 = DMulScale(dx, nCos, dy, nSin, 30);
@ -282,12 +282,12 @@ static void eelThinkChase(DBloodActor* actor)
aiNewState(actor, &eelGoto); aiNewState(actor, &eelGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -302,13 +302,13 @@ static void eelThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
int top, bottom; int top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
int top2, bottom2; int top2, bottom2;
GetActorExtents(target, &top2, &bottom2); GetActorExtents(target, &top2, &bottom2);
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
@ -334,23 +334,23 @@ static void eelMoveForward(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2; int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang + 256) & 2047; actor->spr.ang = (actor->spr.ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= 0x399) if (nDist <= 0x399)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -367,21 +367,21 @@ static void eelMoveSwoop(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2; int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x8000) && nDist <= 0x399) if (Chance(0x8000) && nDist <= 0x399)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -396,21 +396,21 @@ static void eelMoveAscend(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2; int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x399) if (Chance(0x4000) && nDist <= 0x399)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -425,18 +425,18 @@ void eelMoveToCeil(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
int x = pSprite->pos.X; int x = actor->spr.pos.X;
int y = pSprite->pos.Y; int y = actor->spr.pos.Y;
int z = pSprite->pos.Z; int z = actor->spr.pos.Z;
if (z - pXSprite->targetZ < 0x1000) if (z - pXSprite->targetZ < 0x1000)
{ {
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 0; pDudeExtraE->active = 0;
pSprite->flags = 0; actor->spr.flags = 0;
aiNewState(actor, &eelIdle); aiNewState(actor, &eelIdle);
} }
else else
aiSetTarget(actor, x, y, pSprite->sector()->ceilingz); aiSetTarget(actor, x, y, actor->spr.sector()->ceilingz);
} }
END_BLD_NS END_BLD_NS

View file

@ -85,16 +85,16 @@ static void burnThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pSprite->type) switch (actor->spr.type)
{ {
case kDudeBurningCultist: case kDudeBurningCultist:
aiNewState(actor, &cultistBurnSearch); aiNewState(actor, &cultistBurnSearch);
@ -129,7 +129,7 @@ static void burnThinkChase(DBloodActor* actor)
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
{ {
switch (pSprite->type) switch (actor->spr.type)
{ {
case kDudeBurningCultist: case kDudeBurningCultist:
aiNewState(actor, &cultistBurnGoto); aiNewState(actor, &cultistBurnGoto);
@ -157,16 +157,16 @@ static void burnThinkChase(DBloodActor* actor)
} }
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
switch (pSprite->type) switch (actor->spr.type)
{ {
case kDudeBurningCultist: case kDudeBurningCultist:
aiNewState(actor, &cultistBurnSearch); aiNewState(actor, &cultistBurnSearch);
@ -197,16 +197,16 @@ static void burnThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
if (nDist < 0x333 && abs(nDeltaAngle) < 85) if (nDist < 0x333 && abs(nDeltaAngle) < 85)
{ {
switch (pSprite->type) switch (actor->spr.type)
{ {
case kDudeBurningCultist: case kDudeBurningCultist:
aiNewState(actor, &cultistBurnAttack); aiNewState(actor, &cultistBurnAttack);
@ -238,7 +238,7 @@ static void burnThinkChase(DBloodActor* actor)
} }
} }
switch (pSprite->type) switch (actor->spr.type)
{ {
case kDudeBurningCultist: case kDudeBurningCultist:
aiNewState(actor, &cultistBurnGoto); aiNewState(actor, &cultistBurnGoto);

View file

@ -60,8 +60,8 @@ AISTATE tinycaleb139698 = { kAiStateOther, 8, -1, 120, NULL, aiMoveTurn, NULL, &
void SeqAttackCallback(int, DBloodActor* actor) void SeqAttackCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
int dz = actor->dudeSlope; int dz = actor->dudeSlope;
dx += Random2(1500); dx += Random2(1500);
dy += Random2(1500); dy += Random2(1500);
@ -92,18 +92,18 @@ static void calebThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto pSector = pSprite->sector(); auto pSector = actor->spr.sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr; auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &tinycalebSwimSearch); aiNewState(actor, &tinycalebSwimSearch);
@ -116,7 +116,7 @@ static void calebThinkGoto(DBloodActor* actor)
static void calebThinkChase(DBloodActor* actor) static void calebThinkChase(DBloodActor* actor)
{ {
auto const pSprite = &actor->s(); auto const pSprite = &actor->s();
auto pSector = pSprite->sector(); auto pSector = actor->spr.sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr; auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
@ -127,12 +127,12 @@ static void calebThinkChase(DBloodActor* actor)
aiNewState(actor, &tinycalebSearch); aiNewState(actor, &tinycalebSearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -156,17 +156,17 @@ static void calebThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->spr.pos.Z-pSprite->pos.Z, nDist, 10); actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->spr.pos.Z-actor->spr.pos.Z, nDist, 10);
if (nDist < 0x599 && abs(nDeltaAngle) < 28) if (nDist < 0x599 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -176,7 +176,7 @@ static void calebThinkChase(DBloodActor* actor)
aiNewState(actor, &tinycalebAttack); aiNewState(actor, &tinycalebAttack);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type) if (actor->spr.type != gHitInfo.actor()->spr.type)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &tinycalebSwimAttack); aiNewState(actor, &tinycalebSwimAttack);
@ -217,14 +217,14 @@ static void calebThinkSwimGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tinycalebSwimSearch); aiNewState(actor, &tinycalebSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -237,12 +237,12 @@ static void calebThinkSwimChase(DBloodActor* actor)
aiNewState(actor, &tinycalebSwimGoto); aiNewState(actor, &tinycalebSwimGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -257,11 +257,11 @@ static void calebThinkSwimChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = pDudeInfo->eyeHeight + pSprite->pos.Z; int height = pDudeInfo->eyeHeight + actor->spr.pos.Z;
int top, bottom; int top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
@ -282,23 +282,23 @@ static void sub_65D04(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang + 256) & 2047; actor->spr.ang = (actor->spr.ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400) if (Random(64) < 32 && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -315,30 +315,30 @@ static void sub_65F44(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int z = pSprite->pos.Z + getDudeInfo(pSprite->type)->eyeHeight; int z = actor->spr.pos.Z + getDudeInfo(actor->spr.type)->eyeHeight;
int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight; int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang + 512) & 2047; pXSprite->goalAng = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int dz = z2 - z; int dz = z2 - z;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400) if (Chance(0x600) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -353,30 +353,30 @@ static void sub_661E0(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int z = pSprite->pos.Z + getDudeInfo(pSprite->type)->eyeHeight; int z = actor->spr.pos.Z + getDudeInfo(actor->spr.type)->eyeHeight;
int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight; int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang + 512) & 2047; actor->spr.ang = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int dz = (z2 - z) << 3; int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400) if (Chance(0x4000) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);

View file

@ -58,16 +58,16 @@ AISTATE cerberus1398AC = { kAiStateOther, 7, -1, 120, NULL, aiMoveTurn, NULL, &c
void cerberusBiteSeqCallback(int, DBloodActor* actor) void cerberusBiteSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int dz = target->spr.pos.Z - pSprite->pos.Z; int dz = target->spr.pos.Z - actor->spr.pos.Z;
actFireVector(actor, 350, -100, dx, dy, dz, kVectorCerberusHack); actFireVector(actor, 350, -100, dx, dy, dz, kVectorCerberusHack);
actFireVector(actor, -350, 0, dx, dy, dz, kVectorCerberusHack); actFireVector(actor, -350, 0, dx, dy, dz, kVectorCerberusHack);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorCerberusHack); actFireVector(actor, 0, 0, dx, dy, dz, kVectorCerberusHack);
@ -76,17 +76,17 @@ void cerberusBiteSeqCallback(int, DBloodActor* actor)
void cerberusBurnSeqCallback(int, DBloodActor* actor) void cerberusBurnSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int height = pDudeInfo->eyeHeight * pSprite->yrepeat; int height = pDudeInfo->eyeHeight * actor->spr.yrepeat;
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
int x = pSprite->pos.X; int x = actor->spr.pos.X;
int y = pSprite->pos.Y; int y = actor->spr.pos.Y;
int z = height; // ??? int z = height; // ???
TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa }; TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
Aim aim; Aim aim;
aim.dx = bcos(pSprite->ang); aim.dx = bcos(actor->spr.ang);
aim.dy = bsin(pSprite->ang); aim.dy = bsin(actor->spr.ang);
aim.dz = actor->dudeSlope; aim.dz = actor->dudeSlope;
int nClosest = 0x7fffffff; int nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
@ -108,8 +108,8 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
y2 += (actor2->yvel * t) >> 12; y2 += (actor2->yvel * t) >> 12;
z2 += (actor2->zvel * t) >> 8; z2 += (actor2->zvel * t) >> 8;
} }
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30); int tx = x + MulScale(Cos(actor->spr.ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30); int ty = y + MulScale(Sin(actor->spr.ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10); int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10); int tsr = MulScale(9460, nDist, 10);
int top, bottom; int top, bottom;
@ -123,11 +123,11 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
if (nDist2 < nClosest) if (nDist2 < nClosest)
{ {
int nAngle = getangle(x2 - x, y2 - y); int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024; int nDeltaAngle = ((nAngle - actor->spr.ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt1.at8) if (abs(nDeltaAngle) <= tt1.at8)
{ {
int tz = actor2->spr.pos.Z - pSprite->pos.Z; int tz = actor2->spr.pos.Z - actor->spr.pos.Z;
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, actor2->spr.sector())) if (cansee(x, y, z, actor->spr.sector(), x2, y2, z2, actor2->spr.sector()))
{ {
nClosest = nDist2; nClosest = nDist2;
aim.dx = bcos(nAngle); aim.dx = bcos(nAngle);
@ -139,7 +139,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
} }
} }
} }
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
actFireMissile(actor, -350, 0, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus); actFireMissile(actor, -350, 0, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus);
actFireMissile(actor, 350, -100, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus); actFireMissile(actor, 350, -100, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus);
@ -154,17 +154,17 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int height = pDudeInfo->eyeHeight * pSprite->yrepeat; int height = pDudeInfo->eyeHeight * actor->spr.yrepeat;
int x = pSprite->pos.X; int x = actor->spr.pos.X;
int y = pSprite->pos.Y; int y = actor->spr.pos.Y;
int z = height; // ??? int z = height; // ???
TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa }; TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
Aim aim; Aim aim;
int ax, ay, az; int ax, ay, az;
aim.dx = ax = bcos(pSprite->ang); aim.dx = ax = bcos(actor->spr.ang);
aim.dy = ay = bsin(pSprite->ang); aim.dy = ay = bsin(actor->spr.ang);
aim.dz = actor->dudeSlope; aim.dz = actor->dudeSlope;
az = 0; az = 0;
int nClosest = 0x7fffffff; int nClosest = 0x7fffffff;
@ -186,8 +186,8 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
y2 += (actor->yvel * t) >> 12; y2 += (actor->yvel * t) >> 12;
z2 += (actor->zvel * t) >> 8; z2 += (actor->zvel * t) >> 8;
} }
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30); int tx = x + MulScale(Cos(actor->spr.ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30); int ty = y + MulScale(Sin(actor->spr.ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10); int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10); int tsr = MulScale(9460, nDist, 10);
int top, bottom; int top, bottom;
@ -201,13 +201,13 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
if (nDist2 < nClosest) if (nDist2 < nClosest)
{ {
int nAngle = getangle(x2 - x, y2 - y); int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024; int nDeltaAngle = ((nAngle - actor->spr.ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt1.at8) if (abs(nDeltaAngle) <= tt1.at8)
{ {
DUDEINFO* pDudeInfo2 = getDudeInfo(actor2->spr.type); DUDEINFO* pDudeInfo2 = getDudeInfo(actor2->spr.type);
int height = (pDudeInfo2->aimHeight * actor2->spr.yrepeat) << 2; int height = (pDudeInfo2->aimHeight * actor2->spr.yrepeat) << 2;
int tz = (z2 - height) - z; int tz = (z2 - height) - z;
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, actor2->spr.sector())) if (cansee(x, y, z, actor->spr.sector(), x2, y2, z2, actor2->spr.sector()))
{ {
nClosest = nDist2; nClosest = nDist2;
aim.dx = bcos(nAngle); aim.dx = bcos(nAngle);
@ -219,7 +219,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
} }
} }
} }
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
actFireMissile(actor, 350, -100, aim.dx, aim.dy, -aim.dz, kMissileFlameHound); actFireMissile(actor, 350, -100, aim.dx, aim.dy, -aim.dz, kMissileFlameHound);
actFireMissile(actor, -350, 0, ax, ay, az, kMissileFlameHound); actFireMissile(actor, -350, 0, ax, ay, az, kMissileFlameHound);
@ -241,12 +241,12 @@ static void cerberusThinkTarget(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++; pDudeExtraE->thinkTime++;
@ -255,7 +255,7 @@ static void cerberusThinkTarget(DBloodActor* actor)
pXSprite->goalAng += 256; pXSprite->goalAng += 256;
POINT3D* pTarget = &actor->basePoint; POINT3D* pTarget = &actor->basePoint;
aiSetTarget(actor, pTarget->X, pTarget->Y, pTarget->Z); aiSetTarget(actor, pTarget->X, pTarget->Y, pTarget->Z);
if (pSprite->type == kDudeCerberusTwoHead) if (actor->spr.type == kDudeCerberusTwoHead)
aiNewState(actor, &cerberus139890); aiNewState(actor, &cerberus139890);
else else
aiNewState(actor, &cerberus1398AC); aiNewState(actor, &cerberus1398AC);
@ -268,18 +268,18 @@ static void cerberusThinkTarget(DBloodActor* actor)
PLAYER* pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->pos.X; int x = pPlayer->actor->spr.pos.X;
int y = pPlayer->pSprite->pos.Y; int y = pPlayer->actor->spr.pos.Y;
int z = pPlayer->pSprite->pos.Z; int z = pPlayer->actor->spr.pos.Z;
auto pSector = pPlayer->pSprite->sector(); auto pSector = pPlayer->actor->spr.sector();
int dx = x - pSprite->pos.X; int dx = x - actor->spr.pos.X;
int dy = y - pSprite->pos.Y; int dy = y - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
if (!cansee(x, y, z, pSector, pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) if (!cansee(x, y, z, pSector, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - ((pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2), actor->spr.sector()))
continue; continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->thinkTime = 0; pDudeExtraE->thinkTime = 0;
@ -303,20 +303,20 @@ static void cerberusThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusSearch); aiNewState(actor, &cerberusSearch);
break; break;
@ -332,7 +332,7 @@ static void cerberusThinkChase(DBloodActor* actor)
{ {
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (actor->GetTarget() == nullptr) { if (actor->GetTarget() == nullptr) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusGoto); aiNewState(actor, &cerberusGoto);
break; break;
@ -343,23 +343,23 @@ static void cerberusThinkChase(DBloodActor* actor)
return; return;
} }
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) { if (pXTarget->health == 0) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusSearch); aiNewState(actor, &cerberusSearch);
break; break;
@ -371,7 +371,7 @@ static void cerberusThinkChase(DBloodActor* actor)
} }
if (target->IsPlayerActor() && powerupCheck(&gPlayer[target->spr.type - kDudePlayer1], kPwUpShadowCloak) > 0) { if (target->IsPlayerActor() && powerupCheck(&gPlayer[target->spr.type - kDudePlayer1], kPwUpShadowCloak) > 0) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusSearch); aiNewState(actor, &cerberusSearch);
break; break;
@ -385,15 +385,15 @@ static void cerberusThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
if (nDist < 0x1b00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) { if (nDist < 0x1b00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusBurn); aiNewState(actor, &cerberusBurn);
break; break;
@ -404,7 +404,7 @@ static void cerberusThinkChase(DBloodActor* actor)
} }
else if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85) { else if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberus3Burn); aiNewState(actor, &cerberus3Burn);
break; break;
@ -415,15 +415,15 @@ static void cerberusThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x200 && abs(nDeltaAngle) < 85) else if (nDist < 0x200 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
switch (hit) { switch (hit) {
case -1: case -1:
aiNewState(actor, &cerberusBite); aiNewState(actor, &cerberusBite);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeHellHound) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeHellHound)
aiNewState(actor, &cerberusBite); aiNewState(actor, &cerberusBite);
break; break;
case 0: case 0:
@ -440,7 +440,7 @@ static void cerberusThinkChase(DBloodActor* actor)
aiNewState(actor, &cerberus2Bite); aiNewState(actor, &cerberus2Bite);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeHellHound) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeHellHound)
aiNewState(actor, &cerberus2Bite); aiNewState(actor, &cerberus2Bite);
break; break;
case 0: case 0:
@ -458,7 +458,7 @@ static void cerberusThinkChase(DBloodActor* actor)
} }
} }
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusGoto); aiNewState(actor, &cerberusGoto);
break; break;

View file

@ -75,8 +75,8 @@ AISTATE cultistSwimRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &culti
void TommySeqCallback(int, DBloodActor* actor) void TommySeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
int dz = actor->dudeSlope; int dz = actor->dudeSlope;
dx += Random3((5 - gGameOptions.nDifficulty) * 1000); dx += Random3((5 - gGameOptions.nDifficulty) * 1000);
dy += Random3((5 - gGameOptions.nDifficulty) * 1000); dy += Random3((5 - gGameOptions.nDifficulty) * 1000);
@ -90,8 +90,8 @@ void TeslaSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (Chance(dword_138BB0[gGameOptions.nDifficulty])) if (Chance(dword_138BB0[gGameOptions.nDifficulty]))
{ {
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
int dz = actor->dudeSlope; int dz = actor->dudeSlope;
dx += Random3((5 - gGameOptions.nDifficulty) * 1000); dx += Random3((5 - gGameOptions.nDifficulty) * 1000);
dy += Random3((5 - gGameOptions.nDifficulty) * 1000); dy += Random3((5 - gGameOptions.nDifficulty) * 1000);
@ -104,8 +104,8 @@ void TeslaSeqCallback(int, DBloodActor* actor)
void ShotSeqCallback(int, DBloodActor* actor) void ShotSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
int dz = actor->dudeSlope; int dz = actor->dudeSlope;
dx += Random2((5 - gGameOptions.nDifficulty) * 1000 - 500); dx += Random2((5 - gGameOptions.nDifficulty) * 1000 - 500);
dy += Random2((5 - gGameOptions.nDifficulty) * 1000 - 500); dy += Random2((5 - gGameOptions.nDifficulty) * 1000 - 500);
@ -133,10 +133,10 @@ void cultThrowSeqCallback(int, DBloodActor* actor)
sfxPlay3DSound(actor, 455, -1, 0); sfxPlay3DSound(actor, 455, -1, 0);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
int dz = target->spr.pos.Z - pSprite->pos.Z; int dz = target->spr.pos.Z - actor->spr.pos.Z;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
int nDist2 = nDist / 540; int nDist2 = nDist / 540;
if (nDist > 0x1e00) if (nDist > 0x1e00)
@ -167,10 +167,10 @@ void sub_68230(int, DBloodActor* actor)
sfxPlay3DSound(actor, 455, -1, 0); sfxPlay3DSound(actor, 455, -1, 0);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
int dz = target->spr.pos.Z - pSprite->pos.Z; int dz = target->spr.pos.Z - actor->spr.pos.Z;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
int nDist2 = nDist / 540; int nDist2 = nDist / 540;
auto pMissile = actFireThing(actor, 0, 0, dz / 128 - 14500, nMissile, (nDist2 << 17) / 120); auto pMissile = actFireThing(actor, 0, 0, dz / 128 - 14500, nMissile, (nDist2 << 17) / 120);
@ -199,14 +199,14 @@ static void cultThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 5120 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 5120 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -240,12 +240,12 @@ static void cultThinkChase(DBloodActor* actor)
} }
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -253,7 +253,7 @@ static void cultThinkChase(DBloodActor* actor)
{ {
case kMediumNormal: case kMediumNormal:
aiNewState(actor, &cultistSearch); aiNewState(actor, &cultistSearch);
if (pSprite->type == kDudeCultistTommy) if (actor->spr.type == kDudeCultistTommy)
aiPlay3DSound(actor, 4021 + Random(4), AI_SFX_PRIORITY_1, -1); aiPlay3DSound(actor, 4021 + Random(4), AI_SFX_PRIORITY_1, -1);
else else
aiPlay3DSound(actor, 1021 + Random(4), AI_SFX_PRIORITY_1, -1); aiPlay3DSound(actor, 1021 + Random(4), AI_SFX_PRIORITY_1, -1);
@ -282,21 +282,21 @@ static void cultThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > 0 && nDist <= pDudeInfo->seeDist) if (nDist > 0 && nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->spr.pos.Z - pSprite->pos.Z, nDist, 10); actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->spr.pos.Z - actor->spr.pos.Z, nDist, 10);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeCultistTommy: case kDudeCultistTommy:
if (nDist < 0x1e00 && nDist > 0xe00 && abs(nDeltaAngle) < 85 && !TargetNearExplosion(target->spr.sector()) if (nDist < 0x1e00 && nDist > 0xe00 && abs(nDeltaAngle) < 85 && !TargetNearExplosion(target->spr.sector())
&& (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning && (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning
&& Chance(0x8000)) && Chance(0x8000))
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -307,7 +307,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistTThrow); aiNewState(actor, &cultistTThrow);
break; break;
default: default:
@ -317,7 +317,7 @@ static void cultThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x4600 && abs(nDeltaAngle) < 28) else if (nDist < 0x4600 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -329,7 +329,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistTSwimFire); aiNewState(actor, &cultistTSwimFire);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun)
{ {
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal) if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
aiNewState(actor, &cultistTFire); aiNewState(actor, &cultistTFire);
@ -364,7 +364,7 @@ static void cultThinkChase(DBloodActor* actor)
&& (target->spr.flags & 2) && gGameOptions.nDifficulty >= 2 && target->IsPlayerActor() && !gPlayer[target->spr.type - kDudePlayer1].isRunning && (target->spr.flags & 2) && gGameOptions.nDifficulty >= 2 && target->IsPlayerActor() && !gPlayer[target->spr.type - kDudePlayer1].isRunning
&& Chance(0x8000)) && Chance(0x8000))
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -375,7 +375,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistSThrow); aiNewState(actor, &cultistSThrow);
break; break;
default: default:
@ -385,7 +385,7 @@ static void cultThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x3200 && abs(nDeltaAngle) < 28) else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -397,7 +397,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistSSwimFire); aiNewState(actor, &cultistSSwimFire);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy)
{ {
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal) if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
aiNewState(actor, &cultistSFire); aiNewState(actor, &cultistSFire);
@ -432,7 +432,7 @@ static void cultThinkChase(DBloodActor* actor)
&& (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning && (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning
&& Chance(0x8000)) && Chance(0x8000))
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -443,7 +443,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistTsThrow); aiNewState(actor, &cultistTsThrow);
break; break;
default: default:
@ -453,7 +453,7 @@ static void cultThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x3200 && abs(nDeltaAngle) < 28) else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -465,7 +465,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistTsSwimFire); aiNewState(actor, &cultistTsSwimFire);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy)
{ {
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal) if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
aiNewState(actor, &cultistTsFire); aiNewState(actor, &cultistTsFire);
@ -499,7 +499,7 @@ static void cultThinkChase(DBloodActor* actor)
if (nDist < 0x2c00 && nDist > 0x1400 && abs(nDeltaAngle) < 85 if (nDist < 0x2c00 && nDist > 0x1400 && abs(nDeltaAngle) < 85
&& (target->spr.flags & 2) && target->IsPlayerActor()) && (target->spr.flags & 2) && target->IsPlayerActor())
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -509,7 +509,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistDThrow); aiNewState(actor, &cultistDThrow);
break; break;
default: default:
@ -520,7 +520,7 @@ static void cultThinkChase(DBloodActor* actor)
else if (nDist < 0x1400 && abs(nDeltaAngle) < 85 else if (nDist < 0x1400 && abs(nDeltaAngle) < 85
&& (target->spr.flags & 2) && target->IsPlayerActor()) && (target->spr.flags & 2) && target->IsPlayerActor())
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -530,7 +530,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultist139A78); aiNewState(actor, &cultist139A78);
break; break;
default: default:
@ -544,7 +544,7 @@ static void cultThinkChase(DBloodActor* actor)
&& (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning && (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning
&& Chance(0x8000)) && Chance(0x8000))
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -555,7 +555,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistSThrow); aiNewState(actor, &cultistSThrow);
break; break;
default: default:
@ -565,7 +565,7 @@ static void cultThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x3200 && abs(nDeltaAngle) < 28) else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -577,7 +577,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistSSwimFire); aiNewState(actor, &cultistSSwimFire);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy)
{ {
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal) if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
aiNewState(actor, &cultistSFire); aiNewState(actor, &cultistSFire);

View file

@ -80,13 +80,13 @@ void SlashFSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type); DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type);
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2; int height = (actor->spr.yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2; int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2;
int dz = height - height2; int dz = height - height2;
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGargSlash); actFireVector(actor, 0, 0, dx, dy, dz, kVectorGargSlash);
int r1 = Random(50); int r1 = Random(50);
int r2 = Random(50); int r2 = Random(50);
@ -108,14 +108,14 @@ void BlastSSeqCallback(int, DBloodActor* actor)
wrand(); // ??? wrand(); // ???
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int height = (pSprite->yrepeat * getDudeInfo(pSprite->type)->eyeHeight) << 2; int height = (actor->spr.yrepeat * getDudeInfo(actor->spr.type)->eyeHeight) << 2;
int x = pSprite->pos.X; int x = actor->spr.pos.X;
int y = pSprite->pos.Y; int y = actor->spr.pos.Y;
int z = height; int z = height;
TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa }; TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
Aim aim; Aim aim;
aim.dx = bcos(pSprite->ang); aim.dx = bcos(actor->spr.ang);
aim.dy = bsin(pSprite->ang); aim.dy = bsin(actor->spr.ang);
aim.dz = actor->dudeSlope; aim.dz = actor->dudeSlope;
int nClosest = 0x7fffffff; int nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
@ -136,8 +136,8 @@ void BlastSSeqCallback(int, DBloodActor* actor)
y2 += (actor->yvel * t) >> 12; y2 += (actor->yvel * t) >> 12;
z2 += (actor->zvel * t) >> 8; z2 += (actor->zvel * t) >> 8;
} }
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30); int tx = x + MulScale(Cos(actor->spr.ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30); int ty = y + MulScale(Sin(actor->spr.ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10); int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10); int tsr = MulScale(9460, nDist, 10);
int top, bottom; int top, bottom;
@ -151,11 +151,11 @@ void BlastSSeqCallback(int, DBloodActor* actor)
if (nDist2 < nClosest) if (nDist2 < nClosest)
{ {
int nAngle = getangle(x2 - x, y2 - y); int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024; int nDeltaAngle = ((nAngle - actor->spr.ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt.at8) if (abs(nDeltaAngle) <= tt.at8)
{ {
int tz = actor2->spr.pos.Z - pSprite->pos.Z; int tz = actor2->spr.pos.Z - actor->spr.pos.Z;
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, actor2->spr.sector())) if (cansee(x, y, z, actor->spr.sector(), x2, y2, z2, actor2->spr.sector()))
{ {
nClosest = nDist2; nClosest = nDist2;
aim.dx = bcos(nAngle); aim.dx = bcos(nAngle);
@ -201,12 +201,12 @@ static void gargThinkTarget(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++; pDudeExtraE->thinkTime++;
@ -225,18 +225,18 @@ static void gargThinkTarget(DBloodActor* actor)
PLAYER* pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->pos.X; int x = pPlayer->actor->spr.pos.X;
int y = pPlayer->pSprite->pos.Y; int y = pPlayer->actor->spr.pos.Y;
int z = pPlayer->pSprite->pos.Z; int z = pPlayer->actor->spr.pos.Z;
auto pSector = pPlayer->pSprite->sector(); auto pSector = pPlayer->actor->spr.sector();
int dx = x - pSprite->pos.X; int dx = x - actor->spr.pos.X;
int dy = y - pSprite->pos.Y; int dy = y - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
if (!cansee(x, y, z, pSector, pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) if (!cansee(x, y, z, pSector, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - ((pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2), actor->spr.sector()))
continue; continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->thinkTime = 0; pDudeExtraE->thinkTime = 0;
@ -267,18 +267,18 @@ static void gargThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gargoyleFSearch); aiNewState(actor, &gargoyleFSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -287,17 +287,17 @@ static void gargMoveDodgeUp(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int dx = actor->xvel; int dx = actor->xvel;
int dy = actor->yvel; int dy = actor->yvel;
int t1 = DMulScale(dx, nCos, dy, nSin, 30); int t1 = DMulScale(dx, nCos, dy, nSin, 30);
@ -316,19 +316,19 @@ static void gargMoveDodgeDown(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (pXSprite->dodgeDir == 0) if (pXSprite->dodgeDir == 0)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int dx = actor->xvel; int dx = actor->xvel;
int dy = actor->yvel; int dy = actor->yvel;
int t1 = DMulScale(dx, nCos, dy, nSin, 30); int t1 = DMulScale(dx, nCos, dy, nSin, 30);
@ -351,16 +351,16 @@ static void gargThinkChase(DBloodActor* actor)
aiNewState(actor, &gargoyleFGoto); aiNewState(actor, &gargoyleFGoto);
return; return;
} }
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -375,24 +375,24 @@ static void gargThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
// Should be dudeInfo[target->spr.type-kDudeBase] // Should be dudeInfo[target->spr.type-kDudeBase]
int height2 = (pDudeInfo->eyeHeight * target->spr.yrepeat) << 2; int height2 = (pDudeInfo->eyeHeight * target->spr.yrepeat) << 2;
int top, bottom; int top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
int floorZ = getflorzofslopeptr(pSprite->sector(), pSprite->pos.X, pSprite->pos.Y); int floorZ = getflorzofslopeptr(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y);
switch (pSprite->type) switch (actor->spr.type)
{ {
case kDudeGargoyleFlesh: case kDudeGargoyleFlesh:
if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -403,7 +403,7 @@ static void gargThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeGargoyleStone) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeGargoyleStone)
{ {
sfxPlay3DSound(actor, 1408, 0, 0); sfxPlay3DSound(actor, 1408, 0, 0);
aiNewState(actor, &gargoyleFThrow); aiNewState(actor, &gargoyleFThrow);
@ -417,7 +417,7 @@ static void gargThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x400 && abs(nDeltaAngle) < 85) else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -428,7 +428,7 @@ static void gargThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeGargoyleStone) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeGargoyleStone)
{ {
sfxPlay3DSound(actor, 1406, 0, 0); sfxPlay3DSound(actor, 1406, 0, 0);
aiNewState(actor, &gargoyleFSlash); aiNewState(actor, &gargoyleFSlash);
@ -451,7 +451,7 @@ static void gargThinkChase(DBloodActor* actor)
case kDudeGargoyleStone: case kDudeGargoyleStone:
if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -462,7 +462,7 @@ static void gargThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeGargoyleFlesh) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeGargoyleFlesh)
{ {
sfxPlay3DSound(actor, 1457, 0, 0); sfxPlay3DSound(actor, 1457, 0, 0);
aiNewState(actor, &gargoyleSBlast); aiNewState(actor, &gargoyleSBlast);
@ -476,7 +476,7 @@ static void gargThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x400 && abs(nDeltaAngle) < 85) else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -486,7 +486,7 @@ static void gargThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeGargoyleFlesh) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeGargoyleFlesh)
aiNewState(actor, &gargoyleFSlash); aiNewState(actor, &gargoyleFSlash);
break; break;
default: default:
@ -496,7 +496,7 @@ static void gargThinkChase(DBloodActor* actor)
} }
else if ((height2 - height > 0x2000 || floorZ - bottom > 0x2000) && nDist < 0x1400 && nDist > 0x800) else if ((height2 - height > 0x2000 || floorZ - bottom > 0x2000) && nDist < 0x1400 && nDist > 0x800)
{ {
if (pSprite->type == kDudeGargoyleFlesh) if (actor->spr.type == kDudeGargoyleFlesh)
aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1);
else else
aiPlay3DSound(actor, 1450, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(actor, 1450, AI_SFX_PRIORITY_1, -1);
@ -525,7 +525,7 @@ static void entryFStatue(DBloodActor* actor)
auto pSprite = &actor->s(); auto pSprite = &actor->s();
DUDEINFO* pDudeInfo = &dudeInfo[6]; DUDEINFO* pDudeInfo = &dudeInfo[6];
actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth); actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth);
pSprite->type = kDudeGargoyleFlesh; actor->spr.type = kDudeGargoyleFlesh;
} }
static void entrySStatue(DBloodActor* actor) static void entrySStatue(DBloodActor* actor)
@ -533,34 +533,34 @@ static void entrySStatue(DBloodActor* actor)
auto pSprite = &actor->s(); auto pSprite = &actor->s();
DUDEINFO* pDudeInfo = &dudeInfo[7]; DUDEINFO* pDudeInfo = &dudeInfo[7];
actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth); actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth);
pSprite->type = kDudeGargoyleStone; actor->spr.type = kDudeGargoyleStone;
} }
static void gargMoveForward(DBloodActor* actor) static void gargMoveForward(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang + 256) & 2047; actor->spr.ang = (actor->spr.ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400) if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -577,28 +577,28 @@ static void gargMoveSlow(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang + 512) & 2047; pXSprite->goalAng = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400) if (Chance(0x600) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -607,7 +607,7 @@ static void gargMoveSlow(DBloodActor* actor)
t2 >>= 1; t2 >>= 1;
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30); actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30); actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeGargoyleFlesh: case kDudeGargoyleFlesh:
actor->zvel = 0x44444; actor->zvel = 0x44444;
break; break;
@ -621,28 +621,28 @@ static void gargMoveSwoop(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang + 512) & 2047; pXSprite->goalAng = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400) if (Chance(0x600) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -650,7 +650,7 @@ static void gargMoveSwoop(DBloodActor* actor)
t1 += nAccel >> 1; t1 += nAccel >> 1;
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30); actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30); actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeGargoyleFlesh: case kDudeGargoyleFlesh:
actor->zvel = t1; actor->zvel = t1;
break; break;
@ -664,28 +664,28 @@ static void gargMoveFly(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang + 512) & 2047; actor->spr.ang = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400) if (Chance(0x4000) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -693,7 +693,7 @@ static void gargMoveFly(DBloodActor* actor)
t1 += nAccel >> 1; t1 += nAccel >> 1;
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30); actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30); actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeGargoyleFlesh: case kDudeGargoyleFlesh:
actor->zvel = -t1; actor->zvel = -t1;
break; break;

View file

@ -65,13 +65,13 @@ void ghostSlashSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type); DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type);
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2; int height = (actor->spr.yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2; int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2;
int dz = height - height2; int dz = height - height2;
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
sfxPlay3DSound(actor, 1406, 0, 0); sfxPlay3DSound(actor, 1406, 0, 0);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGhost); actFireVector(actor, 0, 0, dx, dy, dz, kVectorGhost);
int r1 = Random(50); int r1 = Random(50);
@ -94,14 +94,14 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
wrand(); // ??? wrand(); // ???
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int height = (pSprite->yrepeat * getDudeInfo(pSprite->type)->eyeHeight) << 2; int height = (actor->spr.yrepeat * getDudeInfo(actor->spr.type)->eyeHeight) << 2;
int x = pSprite->pos.X; int x = actor->spr.pos.X;
int y = pSprite->pos.Y; int y = actor->spr.pos.Y;
int z = height; int z = height;
TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa }; TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
Aim aim; Aim aim;
aim.dx = bcos(pSprite->ang); aim.dx = bcos(actor->spr.ang);
aim.dy = bsin(pSprite->ang); aim.dy = bsin(actor->spr.ang);
aim.dz = actor->dudeSlope; aim.dz = actor->dudeSlope;
int nClosest = 0x7fffffff; int nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
@ -122,8 +122,8 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
y2 += (actor->yvel * t) >> 12; y2 += (actor->yvel * t) >> 12;
z2 += (actor->zvel * t) >> 8; z2 += (actor->zvel * t) >> 8;
} }
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30); int tx = x + MulScale(Cos(actor->spr.ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30); int ty = y + MulScale(Sin(actor->spr.ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10); int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10); int tsr = MulScale(9460, nDist, 10);
int top, bottom; int top, bottom;
@ -137,11 +137,11 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
if (nDist2 < nClosest) if (nDist2 < nClosest)
{ {
int nAngle = getangle(x2 - x, y2 - y); int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024; int nDeltaAngle = ((nAngle - actor->spr.ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt.at8) if (abs(nDeltaAngle) <= tt.at8)
{ {
int tz = actor2->spr.pos.Z - pSprite->pos.Z; int tz = actor2->spr.pos.Z - actor->spr.pos.Z;
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, actor2->spr.sector())) if (cansee(x, y, z, actor->spr.sector(), x2, y2, z2, actor2->spr.sector()))
{ {
nClosest = nDist2; nClosest = nDist2;
aim.dx = bcos(nAngle); aim.dx = bcos(nAngle);
@ -181,12 +181,12 @@ static void ghostThinkTarget(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++; pDudeExtraE->thinkTime++;
@ -205,18 +205,18 @@ static void ghostThinkTarget(DBloodActor* actor)
PLAYER* pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->pos.X; int x = pPlayer->actor->spr.pos.X;
int y = pPlayer->pSprite->pos.Y; int y = pPlayer->actor->spr.pos.Y;
int z = pPlayer->pSprite->pos.Z; int z = pPlayer->actor->spr.pos.Z;
auto pSector = pPlayer->pSprite->sector(); auto pSector = pPlayer->actor->spr.sector();
int dx = x - pSprite->pos.X; int dx = x - actor->spr.pos.X;
int dy = y - pSprite->pos.Y; int dy = y - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
if (!cansee(x, y, z, pSector, pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) if (!cansee(x, y, z, pSector, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - ((pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2), actor->spr.sector()))
continue; continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->thinkTime = 0; pDudeExtraE->thinkTime = 0;
@ -246,18 +246,18 @@ static void ghostThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ghostSearch); aiNewState(actor, &ghostSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -266,17 +266,17 @@ static void ghostMoveDodgeUp(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int dx = actor->xvel; int dx = actor->xvel;
int dy = actor->yvel; int dy = actor->yvel;
int t1 = DMulScale(dx, nCos, dy, nSin, 30); int t1 = DMulScale(dx, nCos, dy, nSin, 30);
@ -295,19 +295,19 @@ static void ghostMoveDodgeDown(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (pXSprite->dodgeDir == 0) if (pXSprite->dodgeDir == 0)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int dx = actor->xvel; int dx = actor->xvel;
int dy = actor->yvel; int dy = actor->yvel;
int t1 = DMulScale(dx, nCos, dy, nSin, 30); int t1 = DMulScale(dx, nCos, dy, nSin, 30);
@ -331,16 +331,16 @@ static void ghostThinkChase(DBloodActor* actor)
aiNewState(actor, &ghostGoto); aiNewState(actor, &ghostGoto);
return; return;
} }
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -355,22 +355,22 @@ static void ghostThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
// Should be dudeInfo[target->spr.type-kDudeBase] // Should be dudeInfo[target->spr.type-kDudeBase]
int height2 = (pDudeInfo->eyeHeight * target->spr.yrepeat) << 2; int height2 = (pDudeInfo->eyeHeight * target->spr.yrepeat) << 2;
int top, bottom; int top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
int floorZ = getflorzofslopeptr(pSprite->sector(), pSprite->pos.X, pSprite->pos.Y); int floorZ = getflorzofslopeptr(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePhantasm: case kDudePhantasm:
if (nDist < 0x2000 && nDist > 0x1000 && abs(nDeltaAngle) < 85) { if (nDist < 0x2000 && nDist > 0x1000 && abs(nDeltaAngle) < 85) {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -380,7 +380,7 @@ static void ghostThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudePhantasm) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudePhantasm)
aiNewState(actor, &ghostBlast); aiNewState(actor, &ghostBlast);
break; break;
default: default:
@ -390,7 +390,7 @@ static void ghostThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x400 && abs(nDeltaAngle) < 85) else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -400,7 +400,7 @@ static void ghostThinkChase(DBloodActor* actor)
case 4: case 4:
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudePhantasm) if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudePhantasm)
aiNewState(actor, &ghostSlash); aiNewState(actor, &ghostSlash);
break; break;
default: default:
@ -435,27 +435,27 @@ static void ghostMoveForward(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang + 256) & 2047; actor->spr.ang = (actor->spr.ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400) if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -472,28 +472,28 @@ static void ghostMoveSlow(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang + 512) & 2047; pXSprite->goalAng = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400) if (Chance(0x600) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -502,7 +502,7 @@ static void ghostMoveSlow(DBloodActor* actor)
t2 >>= 1; t2 >>= 1;
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30); actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30); actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePhantasm: case kDudePhantasm:
actor->zvel = 0x44444; actor->zvel = 0x44444;
break; break;
@ -513,28 +513,28 @@ static void ghostMoveSwoop(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang + 512) & 2047; pXSprite->goalAng = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400) if (Chance(0x600) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -542,7 +542,7 @@ static void ghostMoveSwoop(DBloodActor* actor)
t1 += nAccel >> 1; t1 += nAccel >> 1;
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30); actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30); actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePhantasm: case kDudePhantasm:
actor->zvel = t1; actor->zvel = t1;
break; break;
@ -553,28 +553,28 @@ static void ghostMoveFly(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang + 512) & 2047; actor->spr.ang = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400) if (Chance(0x4000) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -582,7 +582,7 @@ static void ghostMoveFly(DBloodActor* actor)
t1 += nAccel >> 1; t1 += nAccel >> 1;
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30); actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30); actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePhantasm: case kDudePhantasm:
actor->zvel = -t1; actor->zvel = -t1;
break; break;

View file

@ -62,9 +62,9 @@ void GillBiteSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
int dz = pSprite->pos.Z - target->spr.pos.Z; int dz = actor->spr.pos.Z - target->spr.pos.Z;
dx += Random3(2000); dx += Random3(2000);
dy += Random3(2000); dy += Random3(2000);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGillBite); actFireVector(actor, 0, 0, dx, dy, dz, kVectorGillBite);
@ -83,18 +83,18 @@ static void gillThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto pSector = pSprite->sector(); auto pSector = actor->spr.sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr; auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
@ -107,7 +107,7 @@ static void gillThinkGoto(DBloodActor* actor)
static void gillThinkChase(DBloodActor* actor) static void gillThinkChase(DBloodActor* actor)
{ {
auto const pSprite = &actor->s(); auto const pSprite = &actor->s();
auto pSector = pSprite->sector(); auto pSector = actor->spr.sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr; auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
@ -118,13 +118,13 @@ static void gillThinkChase(DBloodActor* actor)
aiNewState(actor, &gillBeastSearch); aiNewState(actor, &gillBeastSearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -145,17 +145,17 @@ static void gillThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->spr.pos.Z - pSprite->pos.Z, nDist, 10); actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->spr.pos.Z - actor->spr.pos.Z, nDist, 10);
if (nDist < 921 && abs(nDeltaAngle) < 28) if (nDist < 921 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
@ -165,7 +165,7 @@ static void gillThinkChase(DBloodActor* actor)
aiNewState(actor, &gillBeastBite); aiNewState(actor, &gillBeastBite);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type) if (actor->spr.type != gHitInfo.actor()->spr.type)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &gillBeastSwimBite); aiNewState(actor, &gillBeastSwimBite);
@ -205,14 +205,14 @@ static void gillThinkSwimGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -225,13 +225,13 @@ static void gillThinkSwimChase(DBloodActor* actor)
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -246,11 +246,11 @@ static void gillThinkSwimChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = pDudeInfo->eyeHeight + pSprite->pos.Z; int height = pDudeInfo->eyeHeight + actor->spr.pos.Z;
int top, bottom; int top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
@ -277,23 +277,23 @@ static void sub_6CB00(DBloodActor* actor)
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2; int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang + 256) & 2047; actor->spr.ang = (actor->spr.ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400) if (Random(64) < 32 && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -310,29 +310,29 @@ static void sub_6CD74(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int z = pSprite->pos.Z + getDudeInfo(pSprite->type)->eyeHeight; int z = actor->spr.pos.Z + getDudeInfo(actor->spr.type)->eyeHeight;
int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight; int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2; int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang + 512) & 2047; pXSprite->goalAng = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int dz = z2 - z; int dz = z2 - z;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400) if (Chance(0x600) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
@ -347,29 +347,29 @@ static void sub_6D03C(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int z = pSprite->pos.Z + getDudeInfo(pSprite->type)->eyeHeight; int z = actor->spr.pos.Z + getDudeInfo(actor->spr.type)->eyeHeight;
int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight; int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024; int nAng = ((pXSprite->goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2; int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang + 512) & 2047; actor->spr.ang = (actor->spr.ang + 512) & 2047;
return; return;
} }
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int dz = (z2 - z) << 3; int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400) if (Chance(0x4000) && nDist <= 0x400)
return; return;
int nCos = Cos(pSprite->ang); int nCos = Cos(actor->spr.ang);
int nSin = Sin(pSprite->ang); int nSin = Sin(actor->spr.ang);
int vx = actor->xvel; int vx = actor->xvel;
int vy = actor->yvel; int vy = actor->yvel;
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);

View file

@ -67,14 +67,14 @@ static void handThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &handSearch); aiNewState(actor, &handSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -87,13 +87,13 @@ static void handThinkChase(DBloodActor* actor)
aiNewState(actor, &handGoto); aiNewState(actor, &handGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -108,9 +108,9 @@ static void handThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {

View file

@ -45,11 +45,11 @@ AISTATE houndBurn = { kAiStateChase, 7, nHoundBurnClient, 60, NULL, NULL, NULL,
void houndBiteSeqCallback(int, DBloodActor* actor) void houndBiteSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
@ -57,17 +57,17 @@ void houndBiteSeqCallback(int, DBloodActor* actor)
auto target = actor->GetTarget(); auto target = actor->GetTarget();
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
if (target->IsPlayerActor() || gModernMap) // allow to hit non-player targets if (target->IsPlayerActor() || gModernMap) // allow to hit non-player targets
actFireVector(actor, 0, 0, dx, dy, target->spr.pos.Z - pSprite->pos.Z, kVectorHoundBite); actFireVector(actor, 0, 0, dx, dy, target->spr.pos.Z - actor->spr.pos.Z, kVectorHoundBite);
#else #else
if (target->IsPlayerActor()) if (target->IsPlayerActor())
actFireVector(actor, 0, 0, dx, dy, target->spr.z - pSprite->z, kVectorHoundBite); actFireVector(actor, 0, 0, dx, dy, target->spr.z - actor->spr.z, kVectorHoundBite);
#endif #endif
} }
void houndBurnSeqCallback(int, DBloodActor* actor) void houndBurnSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
actFireMissile(actor, 0, 0, bcos(pSprite->ang), bsin(pSprite->ang), 0, kMissileFlameHound); actFireMissile(actor, 0, 0, bcos(actor->spr.ang), bsin(actor->spr.ang), 0, kMissileFlameHound);
} }
static void houndThinkSearch(DBloodActor* actor) static void houndThinkSearch(DBloodActor* actor)
@ -81,19 +81,19 @@ static void houndThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &houndSearch); aiNewState(actor, &houndSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -106,16 +106,16 @@ static void houndThinkChase(DBloodActor* actor)
aiNewState(actor, &houndGoto); aiNewState(actor, &houndGoto);
return; return;
} }
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -130,9 +130,9 @@ static void houndThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {

View file

@ -52,14 +52,14 @@ static void innocThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &innocentSearch); aiNewState(actor, &innocentSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -73,13 +73,13 @@ static void innocThinkChase(DBloodActor* actor)
aiNewState(actor, &innocentGoto); aiNewState(actor, &innocentGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -94,9 +94,9 @@ static void innocThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {

View file

@ -67,16 +67,16 @@ void podAttack(int, DBloodActor* actor)
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int x = target->spr.pos.X - pSprite->pos.X; int x = target->spr.pos.X - actor->spr.pos.X;
int y = target->spr.pos.Y - pSprite->pos.Y; int y = target->spr.pos.Y - actor->spr.pos.Y;
int dz = target->spr.pos.Z - pSprite->pos.Z; int dz = target->spr.pos.Z - actor->spr.pos.Z;
x += Random2(1000); x += Random2(1000);
y += Random2(1000); y += Random2(1000);
int nDist = approxDist(x, y); int nDist = approxDist(x, y);
int nDist2 = nDist / 540; int nDist2 = nDist / 540;
DBloodActor* pMissile = nullptr; DBloodActor* pMissile = nullptr;
switch (pSprite->type) switch (actor->spr.type)
{ {
case kDudePodGreen: case kDudePodGreen:
dz += 8000; dz += 8000;
@ -112,7 +112,7 @@ void sub_70284(int, DBloodActor* actor)
sfxPlay3DSound(actor, 2502, -1, 0); sfxPlay3DSound(actor, 2502, -1, 0);
int nDist, nBurn; int nDist, nBurn;
DAMAGE_TYPE dmgType; DAMAGE_TYPE dmgType;
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeTentacleGreen: case kDudeTentacleGreen:
default: // ??? default: // ???
nBurn = 0; nBurn = 0;
@ -125,7 +125,7 @@ void sub_70284(int, DBloodActor* actor)
nDist = 75; nDist = 75;
break; break;
} }
actRadiusDamage(actor, pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z, pSprite->sector(), nDist, 1, 5 * (1 + gGameOptions.nDifficulty), dmgType, 2, nBurn); actRadiusDamage(actor, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->spr.sector(), nDist, 1, 5 * (1 + gGameOptions.nDifficulty), dmgType, 2, nBurn);
} }
static void aiPodSearch(DBloodActor* actor) static void aiPodSearch(DBloodActor* actor)
@ -139,20 +139,20 @@ static void aiPodMove(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) { if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
aiNewState(actor, &podSearch); aiNewState(actor, &podSearch);
@ -170,7 +170,7 @@ static void aiPodChase(DBloodActor* actor)
{ {
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (actor->GetTarget() == nullptr) { if (actor->GetTarget() == nullptr) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
aiNewState(actor, &podMove); aiNewState(actor, &podMove);
@ -182,20 +182,20 @@ static void aiPodChase(DBloodActor* actor)
} }
return; return;
} }
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) { if (pXTarget->health == 0) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
aiNewState(actor, &podSearch); aiNewState(actor, &podSearch);
@ -210,15 +210,15 @@ static void aiPodChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
if (abs(nDeltaAngle) < 85 && target->spr.type != kDudePodGreen && target->spr.type != kDudePodFire) { if (abs(nDeltaAngle) < 85 && target->spr.type != kDudePodGreen && target->spr.type != kDudePodFire) {
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
aiNewState(actor, &podStartChase); aiNewState(actor, &podStartChase);
@ -234,7 +234,7 @@ static void aiPodChase(DBloodActor* actor)
} }
} }
switch (pSprite->type) { switch (actor->spr.type) {
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
aiNewState(actor, &podMove); aiNewState(actor, &podMove);

View file

@ -44,13 +44,13 @@ AISTATE ratBite = { kAiStateChase, 6, nRatBiteClient, 120, NULL, NULL, NULL, &ra
void ratBiteSeqCallback(int, DBloodActor* actor) void ratBiteSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
if (target->IsPlayerActor()) if (target->IsPlayerActor())
actFireVector(actor, 0, 0, dx, dy, target->spr.pos.Z - pSprite->pos.Z, kVectorRatBite); actFireVector(actor, 0, 0, dx, dy, target->spr.pos.Z - actor->spr.pos.Z, kVectorRatBite);
} }
static void ratThinkSearch(DBloodActor* actor) static void ratThinkSearch(DBloodActor* actor)
@ -64,14 +64,14 @@ static void ratThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ratSearch); aiNewState(actor, &ratSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -84,12 +84,12 @@ static void ratThinkChase(DBloodActor* actor)
aiNewState(actor, &ratGoto); aiNewState(actor, &ratGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -104,9 +104,9 @@ static void ratThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {

View file

@ -50,7 +50,7 @@ static void spidBlindEffect(DBloodActor* actor, int nBlind, int max)
{ {
nBlind <<= 4; nBlind <<= 4;
max <<= 4; max <<= 4;
PLAYER* pPlayer = &gPlayer[pSprite->type - kDudePlayer1]; PLAYER* pPlayer = &gPlayer[actor->spr.type - kDudePlayer1];
if (pPlayer->blindEffect < max) if (pPlayer->blindEffect < max)
{ {
pPlayer->blindEffect = ClipHigh(pPlayer->blindEffect + nBlind, max); pPlayer->blindEffect = ClipHigh(pPlayer->blindEffect + nBlind, max);
@ -61,23 +61,23 @@ static void spidBlindEffect(DBloodActor* actor, int nBlind, int max)
void SpidBiteSeqCallback(int, DBloodActor* actor) void SpidBiteSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
dx += Random2(2000); dx += Random2(2000);
dy += Random2(2000); dy += Random2(2000);
int dz = Random2(2000); int dz = Random2(2000);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto const target = actor->GetTarget(); auto const target = actor->GetTarget();
if (target->IsPlayerActor()) if (target->IsPlayerActor())
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
if (hit == 3 && gHitInfo.actor()->IsPlayerActor()) if (hit == 3 && gHitInfo.actor()->IsPlayerActor())
{ {
dz += target->spr.pos.Z - pSprite->pos.Z; dz += target->spr.pos.Z - actor->spr.pos.Z;
PLAYER* pPlayer = &gPlayer[target->spr.type - kDudePlayer1]; PLAYER* pPlayer = &gPlayer[target->spr.type - kDudePlayer1];
switch (pSprite->type) switch (actor->spr.type)
{ {
case kDudeSpiderBrown: case kDudeSpiderBrown:
actFireVector(actor, 0, 0, dx, dy, dz, kVectorSpiderBite); actFireVector(actor, 0, 0, dx, dy, dz, kVectorSpiderBite);
@ -110,17 +110,17 @@ void SpidBiteSeqCallback(int, DBloodActor* actor)
void SpidJumpSeqCallback(int, DBloodActor* actor) void SpidJumpSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int dx = bcos(pSprite->ang); int dx = bcos(actor->spr.ang);
int dy = bsin(pSprite->ang); int dy = bsin(actor->spr.ang);
dx += Random2(200); dx += Random2(200);
dy += Random2(200); dy += Random2(200);
int dz = Random2(200); int dz = Random2(200);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
if (target->IsPlayerActor()) { if (target->IsPlayerActor()) {
dz += target->spr.pos.Z - pSprite->pos.Z; dz += target->spr.pos.Z - actor->spr.pos.Z;
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeSpiderBrown: case kDudeSpiderBrown:
case kDudeSpiderRed: case kDudeSpiderRed:
case kDudeSpiderBlack: case kDudeSpiderBlack:
@ -136,25 +136,25 @@ void SpidBirthSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
DBloodActor* spawned = nullptr; DBloodActor* spawned = nullptr;
if (target->IsPlayerActor() && pDudeExtraE->birthCounter < 10) if (target->IsPlayerActor() && pDudeExtraE->birthCounter < 10)
{ {
if (nDist < 0x1a00 && nDist > 0x1400 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 0x1a00 && nDist > 0x1400 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
spawned = actSpawnDude(actor, kDudeSpiderRed, pSprite->clipdist, 0); spawned = actSpawnDude(actor, kDudeSpiderRed, actor->spr.clipdist, 0);
else if (nDist < 0x1400 && nDist > 0xc00 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) else if (nDist < 0x1400 && nDist > 0xc00 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
spawned = actSpawnDude(actor, kDudeSpiderBrown, pSprite->clipdist, 0); spawned = actSpawnDude(actor, kDudeSpiderBrown, actor->spr.clipdist, 0);
else if (nDist < 0xc00 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) else if (nDist < 0xc00 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
spawned = actSpawnDude(actor, kDudeSpiderBrown, pSprite->clipdist, 0); spawned = actSpawnDude(actor, kDudeSpiderBrown, actor->spr.clipdist, 0);
if (spawned) if (spawned)
{ {
@ -177,14 +177,14 @@ static void spidThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &spidSearch); aiNewState(actor, &spidSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -197,12 +197,12 @@ static void spidThinkChase(DBloodActor* actor)
aiNewState(actor, &spidGoto); aiNewState(actor, &spidGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -216,14 +216,14 @@ static void spidThinkChase(DBloodActor* actor)
} }
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) { if (nDist <= pDudeInfo->seeDist) {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) { if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector())) {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
switch (pSprite->type) { switch (actor->spr.type) {
case kDudeSpiderRed: case kDudeSpiderRed:
if (nDist < 0x399 && abs(nDeltaAngle) < 85) if (nDist < 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &spidBite); aiNewState(actor, &spidBite);

View file

@ -59,16 +59,16 @@ void sub_71A90(int, DBloodActor* actor)
void sub_71BD4(int, DBloodActor* actor) void sub_71BD4(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int height = pSprite->yrepeat * pDudeInfo->eyeHeight; int height = actor->spr.yrepeat * pDudeInfo->eyeHeight;
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
int x = pSprite->pos.X; int x = actor->spr.pos.X;
int y = pSprite->pos.Y; int y = actor->spr.pos.Y;
int z = height; int z = height;
TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x100000 }; TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x100000 };
Aim aim; Aim aim;
aim.dx = bcos(pSprite->ang); aim.dx = bcos(actor->spr.ang);
aim.dy = bsin(pSprite->ang); aim.dy = bsin(actor->spr.ang);
aim.dz = actor->dudeSlope; aim.dz = actor->dudeSlope;
int nClosest = 0x7fffffff; int nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
@ -89,8 +89,8 @@ void sub_71BD4(int, DBloodActor* actor)
y2 += (actor->yvel * t) >> 12; y2 += (actor->yvel * t) >> 12;
z2 += (actor->zvel * t) >> 8; z2 += (actor->zvel * t) >> 8;
} }
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30); int tx = x + MulScale(Cos(actor->spr.ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30); int ty = y + MulScale(Sin(actor->spr.ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10); int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10); int tsr = MulScale(9460, nDist, 10);
int top, bottom; int top, bottom;
@ -104,11 +104,11 @@ void sub_71BD4(int, DBloodActor* actor)
if (nDist2 < nClosest) if (nDist2 < nClosest)
{ {
int nAngle = getangle(x2 - x, y2 - y); int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024; int nDeltaAngle = ((nAngle - actor->spr.ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt.at8) if (abs(nDeltaAngle) <= tt.at8)
{ {
int tz = actor2->spr.pos.Z - pSprite->pos.Z; int tz = actor2->spr.pos.Z - actor->spr.pos.Z;
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, actor2->spr.sector())) if (cansee(x, y, z, actor->spr.sector(), x2, y2, z2, actor2->spr.sector()))
{ {
nClosest = nDist2; nClosest = nDist2;
aim.dx = bcos(nAngle); aim.dx = bcos(nAngle);
@ -129,13 +129,13 @@ void sub_720AC(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int height = pSprite->yrepeat * pDudeInfo->eyeHeight; int height = actor->spr.yrepeat * pDudeInfo->eyeHeight;
int ax, ay, az; int ax, ay, az;
ax = bcos(pSprite->ang); ax = bcos(actor->spr.ang);
ay = bsin(pSprite->ang); ay = bsin(actor->spr.ang);
int x = pSprite->pos.X; int x = actor->spr.pos.X;
int y = pSprite->pos.Y; int y = actor->spr.pos.Y;
int z = height; int z = height;
TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x100000 }; TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x100000 };
Aim aim; Aim aim;
@ -162,8 +162,8 @@ void sub_720AC(int, DBloodActor* actor)
y2 += (actor->yvel * t) >> 12; y2 += (actor->yvel * t) >> 12;
z2 += (actor->zvel * t) >> 8; z2 += (actor->zvel * t) >> 8;
} }
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30); int tx = x + MulScale(Cos(actor->spr.ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30); int ty = y + MulScale(Sin(actor->spr.ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10); int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10); int tsr = MulScale(9460, nDist, 10);
int top, bottom; int top, bottom;
@ -177,11 +177,11 @@ void sub_720AC(int, DBloodActor* actor)
if (nDist2 < nClosest) if (nDist2 < nClosest)
{ {
int nAngle = getangle(x2 - x, y2 - y); int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024; int nDeltaAngle = ((nAngle - actor->spr.ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt.at8) if (abs(nDeltaAngle) <= tt.at8)
{ {
int tz = actor2->spr.pos.Z - pSprite->pos.Z; int tz = actor2->spr.pos.Z - actor->spr.pos.Z;
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, actor2->spr.sector())) if (cansee(x, y, z, actor->spr.sector(), x2, y2, z2, actor2->spr.sector()))
{ {
nClosest = nDist2; nClosest = nDist2;
aim.dx = bcos(nAngle); aim.dx = bcos(nAngle);
@ -208,12 +208,12 @@ static void sub_725A4(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++; pDudeExtraE->thinkTime++;
@ -232,18 +232,18 @@ static void sub_725A4(DBloodActor* actor)
PLAYER* pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->pos.X; int x = pPlayer->actor->spr.pos.X;
int y = pPlayer->pSprite->pos.Y; int y = pPlayer->actor->spr.pos.Y;
int z = pPlayer->pSprite->pos.Z; int z = pPlayer->actor->spr.pos.Z;
auto pSector = pPlayer->pSprite->sector(); auto pSector = pPlayer->actor->spr.sector();
int dx = x - pSprite->pos.X; int dx = x - actor->spr.pos.X;
int dy = y - pSprite->pos.Y; int dy = y - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
if (!cansee(x, y, z, pSector, pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) if (!cansee(x, y, z, pSector, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - ((pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2), actor->spr.sector()))
continue; continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->thinkTime = 0; pDudeExtraE->thinkTime = 0;
@ -267,18 +267,18 @@ static void sub_72850(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tchernobogSearch); aiNewState(actor, &tchernobogSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -291,17 +291,17 @@ static void sub_72934(DBloodActor* actor)
aiNewState(actor, &tcherno13A9B8); aiNewState(actor, &tcherno13A9B8);
return; return;
} }
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
return; return;
} }
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -316,9 +316,9 @@ static void sub_72934(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {

View file

@ -64,12 +64,12 @@ void HackSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type); DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type);
int tx = pXSprite->targetX - pSprite->pos.X; int tx = pXSprite->targetX - actor->spr.pos.X;
int ty = pXSprite->targetY - pSprite->pos.Y; int ty = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(tx, ty); int nAngle = getangle(tx, ty);
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2; int height = (actor->spr.yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2; int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2;
int dz = height - height2; int dz = height - height2;
int dx = bcos(nAngle); int dx = bcos(nAngle);
@ -94,14 +94,14 @@ static void zombaThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 921 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 921 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -114,13 +114,13 @@ static void zombaThinkChase(DBloodActor* actor)
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -133,15 +133,15 @@ static void zombaThinkChase(DBloodActor* actor)
return; return;
} }
// If the zombie gets whacked while rising from the grave it never executes this change and if it isn't done here at the very latest, will just aimlessly run around. // If the zombie gets whacked while rising from the grave it never executes this change and if it isn't done here at the very latest, will just aimlessly run around.
if (!VanillaMode() && pSprite->type == kDudeZombieAxeBuried) if (!VanillaMode() && actor->spr.type == kDudeZombieAxeBuried)
pSprite->type = kDudeZombieAxeNormal; actor->spr.type = kDudeZombieAxeNormal;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (abs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
@ -165,13 +165,13 @@ static void zombaThinkPonder(DBloodActor* actor)
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -186,9 +186,9 @@ static void zombaThinkPonder(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (abs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
@ -212,26 +212,26 @@ static void zombaThinkPonder(DBloodActor* actor)
static void myThinkTarget(DBloodActor* actor) static void myThinkTarget(DBloodActor* actor)
{ {
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
{ {
PLAYER* pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
auto owneractor = actor->GetOwner(); auto owneractor = actor->GetOwner();
if (owneractor == nullptr || owneractor == pPlayer->actor || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (owneractor == nullptr || owneractor == pPlayer->actor || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->pos.X; int x = pPlayer->actor->spr.pos.X;
int y = pPlayer->pSprite->pos.Y; int y = pPlayer->actor->spr.pos.Y;
int z = pPlayer->pSprite->pos.Z; int z = pPlayer->actor->spr.pos.Z;
auto pSector = pPlayer->pSprite->sector(); auto pSector = pPlayer->actor->spr.sector();
int dx = x - pSprite->pos.X; int dx = x - actor->spr.pos.X;
int dy = y - pSprite->pos.Y; int dy = y - actor->spr.pos.Y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
if (!cansee(x, y, z, pSector, pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) if (!cansee(x, y, z, pSector, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - ((pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2), actor->spr.sector()))
continue; continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, pPlayer->actor); aiSetTarget(actor, pPlayer->actor);
@ -264,8 +264,8 @@ static void myThinkSearch(DBloodActor* actor)
static void entryEZombie(DBloodActor* actor) static void entryEZombie(DBloodActor* actor)
{ {
auto pSprite = &actor->s(); auto pSprite = &actor->s();
pSprite->type = kDudeZombieAxeNormal; actor->spr.type = kDudeZombieAxeNormal;
pSprite->flags |= 1; actor->spr.flags |= 1;
} }
static void entryAIdle(DBloodActor* actor) static void entryAIdle(DBloodActor* actor)
@ -278,7 +278,7 @@ static void entryEStand(DBloodActor* actor)
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
sfxPlay3DSound(actor, 1100, -1, 0); sfxPlay3DSound(actor, 1100, -1, 0);
pSprite->ang = getangle(pXSprite->targetX - pSprite->pos.X, pXSprite->targetY - pSprite->pos.Y); actor->spr.ang = getangle(pXSprite->targetX - actor->spr.pos.X, pXSprite->targetY - actor->spr.pos.Y);
} }
END_BLD_NS END_BLD_NS

View file

@ -48,15 +48,15 @@ AISTATE zombieFTeslaRecoil = { kAiStateRecoil, 4, -1, 0, NULL, NULL, NULL, &zomb
void zombfHackSeqCallback(int, DBloodActor* actor) void zombfHackSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (pSprite->type != kDudeZombieButcher) if (actor->spr.type != kDudeZombieButcher)
return; return;
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat); int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat);
DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type); DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type);
int height2 = (pDudeInfoT->eyeHeight * target->spr.yrepeat); int height2 = (pDudeInfoT->eyeHeight * target->spr.yrepeat);
actFireVector(actor, 0, 0, bcos(pSprite->ang), bsin(pSprite->ang), height - height2, kVectorCleaver); actFireVector(actor, 0, 0, bcos(actor->spr.ang), bsin(actor->spr.ang), height - height2, kVectorCleaver);
} }
void PukeSeqCallback(int, DBloodActor* actor) void PukeSeqCallback(int, DBloodActor* actor)
@ -65,12 +65,12 @@ void PukeSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type); DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type);
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat); int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat);
int height2 = (pDudeInfoT->eyeHeight * target->spr.yrepeat); int height2 = (pDudeInfoT->eyeHeight * target->spr.yrepeat);
int tx = pXSprite->targetX - pSprite->pos.X; int tx = pXSprite->targetX - actor->spr.pos.X;
int ty = pXSprite->targetY - pSprite->pos.Y; int ty = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(tx, ty); int nAngle = getangle(tx, ty);
int dx = bcos(nAngle); int dx = bcos(nAngle);
int dy = bsin(nAngle); int dy = bsin(nAngle);
@ -81,7 +81,7 @@ void PukeSeqCallback(int, DBloodActor* actor)
void ThrowSeqCallback(int, DBloodActor* actor) void ThrowSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
actFireMissile(actor, 0, -getDudeInfo(pSprite->type)->eyeHeight, bcos(pSprite->ang), bsin(pSprite->ang), 0, kMissileButcherKnife); actFireMissile(actor, 0, -getDudeInfo(actor->spr.type)->eyeHeight, bcos(actor->spr.ang), bsin(actor->spr.ang), 0, kMissileButcherKnife);
} }
static void zombfThinkSearch(DBloodActor* actor) static void zombfThinkSearch(DBloodActor* actor)
@ -95,14 +95,14 @@ static void zombfThinkGoto(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = pXSprite->targetX - pSprite->pos.X; int dx = pXSprite->targetX - actor->spr.pos.X;
int dy = pXSprite->targetY - pSprite->pos.Y; int dy = pXSprite->targetY - actor->spr.pos.Y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieFSearch); aiNewState(actor, &zombieFSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -115,13 +115,13 @@ static void zombfThinkChase(DBloodActor* actor)
aiNewState(actor, &zombieFGoto); aiNewState(actor, &zombieFGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x(); XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - pSprite->pos.X; int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - pSprite->pos.Y; int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
@ -136,23 +136,23 @@ static void zombfThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->seeDist)
{ {
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector())) if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
{ {
if (abs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
if (nDist < 0x1400 && nDist > 0xe00 && abs(nDeltaAngle) < 85) if (nDist < 0x1400 && nDist > 0xe00 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
aiNewState(actor, &zombieFThrow); aiNewState(actor, &zombieFThrow);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type) if (actor->spr.type != gHitInfo.actor()->spr.type)
aiNewState(actor, &zombieFThrow); aiNewState(actor, &zombieFThrow);
else else
aiNewState(actor, &zombieFDodge); aiNewState(actor, &zombieFDodge);
@ -164,14 +164,14 @@ static void zombfThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x1400 && nDist > 0x600 && abs(nDeltaAngle) < 85) else if (nDist < 0x1400 && nDist > 0x600 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
aiNewState(actor, &zombieFPuke); aiNewState(actor, &zombieFPuke);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type) if (actor->spr.type != gHitInfo.actor()->spr.type)
aiNewState(actor, &zombieFPuke); aiNewState(actor, &zombieFPuke);
else else
aiNewState(actor, &zombieFDodge); aiNewState(actor, &zombieFDodge);
@ -183,14 +183,14 @@ static void zombfThinkChase(DBloodActor* actor)
} }
else if (nDist < 0x400 && abs(nDeltaAngle) < 85) else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1:
aiNewState(actor, &zombieFHack); aiNewState(actor, &zombieFHack);
break; break;
case 3: case 3:
if (pSprite->type != gHitInfo.actor()->spr.type) if (actor->spr.type != gHitInfo.actor()->spr.type)
aiNewState(actor, &zombieFHack); aiNewState(actor, &zombieFHack);
else else
aiNewState(actor, &zombieFDodge); aiNewState(actor, &zombieFDodge);