- reformatted the actor and ai sources.

This commit is contained in:
Christoph Oelckers 2021-09-16 21:59:39 +02:00
parent 0ee81b2bb8
commit c485fce958
21 changed files with 7350 additions and 7349 deletions

View file

@ -6625,15 +6625,15 @@ DBloodActor* actFireThing(DBloodActor* actor, int a2, int a3, int a4, int thingT
{
auto pSprite = &actor->s();
assert(thingType >= kThingBase && thingType < kThingMax);
int x = pSprite->x+MulScale(a2, Cos(pSprite->ang+512), 30);
int y = pSprite->y+MulScale(a2, Sin(pSprite->ang+512), 30);
int z = pSprite->z+a3;
int x = pSprite->x + MulScale(a2, Cos(pSprite->ang + 512), 30);
int y = pSprite->y + MulScale(a2, Sin(pSprite->ang + 512), 30);
int z = pSprite->z + a3;
x += MulScale(pSprite->clipdist, Cos(pSprite->ang), 28);
y += MulScale(pSprite->clipdist, Sin(pSprite->ang), 28);
if (HitScan(pSprite, z, x - pSprite->x, y - pSprite->y, 0, CLIPMASK0, pSprite->clipdist) != -1)
{
x = gHitInfo.hitx-MulScale(pSprite->clipdist<<1, Cos(pSprite->ang), 28);
y = gHitInfo.hity-MulScale(pSprite->clipdist<<1, Sin(pSprite->ang), 28);
x = gHitInfo.hitx - MulScale(pSprite->clipdist << 1, Cos(pSprite->ang), 28);
y = gHitInfo.hity - MulScale(pSprite->clipdist << 1, Sin(pSprite->ang), 28);
}
auto fired = actSpawnThing(pSprite->sectnum, x, y, z, thingType);
spritetype* pThing = &fired->s();
@ -6654,32 +6654,32 @@ DBloodActor* actFireThing(DBloodActor* actor, int a2, int a3, int a4, int thingT
//
//---------------------------------------------------------------------------
spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5, int a6, int nType)
spritetype* actFireMissile(spritetype* pSprite, int a2, int a3, int a4, int a5, int a6, int nType)
{
assert(nType >= kMissileBase && nType < kMissileMax);
char v4 = 0;
int nSprite = pSprite->index;
const MissileType *pMissileInfo = &missileInfo[nType-kMissileBase];
int x = pSprite->x+MulScale(a2, Cos(pSprite->ang+512), 30);
int y = pSprite->y+MulScale(a2, Sin(pSprite->ang+512), 30);
int z = pSprite->z+a3;
int clipdist = pMissileInfo->clipDist+pSprite->clipdist;
const MissileType* pMissileInfo = &missileInfo[nType - kMissileBase];
int x = pSprite->x + MulScale(a2, Cos(pSprite->ang + 512), 30);
int y = pSprite->y + MulScale(a2, Sin(pSprite->ang + 512), 30);
int z = pSprite->z + a3;
int clipdist = pMissileInfo->clipDist + pSprite->clipdist;
x += MulScale(clipdist, Cos(pSprite->ang), 28);
y += MulScale(clipdist, Sin(pSprite->ang), 28);
int hit = HitScan(pSprite, z, x-pSprite->x, y-pSprite->y, 0, CLIPMASK0, clipdist);
int hit = HitScan(pSprite, z, x - pSprite->x, y - pSprite->y, 0, CLIPMASK0, clipdist);
if (hit != -1)
{
if (hit == 3 || hit == 0)
{
v4 = 1;
x = gHitInfo.hitx-MulScale(Cos(pSprite->ang), 16, 30);
y = gHitInfo.hity-MulScale(Sin(pSprite->ang), 16, 30);
x = gHitInfo.hitx - MulScale(Cos(pSprite->ang), 16, 30);
y = gHitInfo.hity - MulScale(Sin(pSprite->ang), 16, 30);
}
else
{
x = gHitInfo.hitx-MulScale(pMissileInfo->clipDist<<1, Cos(pSprite->ang), 28);
y = gHitInfo.hity-MulScale(pMissileInfo->clipDist<<1, Sin(pSprite->ang), 28);
x = gHitInfo.hitx - MulScale(pMissileInfo->clipDist << 1, Cos(pSprite->ang), 28);
y = gHitInfo.hity - MulScale(pMissileInfo->clipDist << 1, Sin(pSprite->ang), 28);
}
}
auto actor = actSpawnSprite(pSprite->sectnum, x, y, z, 5, 1);
@ -6694,7 +6694,7 @@ spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5,
pMissile->xrepeat = pMissileInfo->xrepeat;
pMissile->yrepeat = pMissileInfo->yrepeat;
pMissile->picnum = pMissileInfo->picnum;
pMissile->ang = (pSprite->ang+pMissileInfo->angleOfs)&2047;
pMissile->ang = (pSprite->ang + pMissileInfo->angleOfs) & 2047;
xvel[nMissile] = MulScale(pMissileInfo->velocity, a4, 14);
yvel[nMissile] = MulScale(pMissileInfo->velocity, a5, 14);
zvel[nMissile] = MulScale(pMissileInfo->velocity, a6, 14);
@ -7132,7 +7132,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
}
#endif
#endif
break;
}
}

View file

@ -32,10 +32,10 @@ BEGIN_BLD_NS
void RecoilDude(DBloodActor* actor);
AISTATE genIdle = {kAiStateGenIdle, 0, -1, 0, NULL, NULL, NULL, NULL };
AISTATE genRecoil = {kAiStateRecoil, 5, -1, 20, NULL, NULL, NULL, &genIdle };
AISTATE genIdle = { kAiStateGenIdle, 0, -1, 0, NULL, NULL, NULL, NULL };
AISTATE genRecoil = { kAiStateRecoil, 5, -1, 20, NULL, NULL, NULL, &genIdle };
const int dword_138BB0[5] = {0x2000, 0x4000, 0x8000, 0xa000, 0xe000};
const int dword_138BB0[5] = { 0x2000, 0x4000, 0x8000, 0xa000, 0xe000 };
//---------------------------------------------------------------------------
//
@ -43,12 +43,12 @@ const int dword_138BB0[5] = {0x2000, 0x4000, 0x8000, 0xa000, 0xe000};
//
//---------------------------------------------------------------------------
bool dudeIsPlayingSeq(DBloodActor *actor, int nSeq)
bool dudeIsPlayingSeq(DBloodActor* actor, int nSeq)
{
auto pSprite = &actor->s();
if (pSprite->statnum == kStatDude && pSprite->type >= kDudeBase && pSprite->type < kDudeMax)
{
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (seqGetID(3, pSprite->extra) == pDudeInfo->seqStartID + nSeq && seqGetStatus(3, pSprite->extra) >= 0)
return true;
}
@ -61,9 +61,9 @@ bool dudeIsPlayingSeq(DBloodActor *actor, int nSeq)
//
//---------------------------------------------------------------------------
void aiPlay3DSound(DBloodActor *actor, int a2, AI_SFX_PRIORITY a3, int a4)
void aiPlay3DSound(DBloodActor* actor, int a2, AI_SFX_PRIORITY a3, int a4)
{
DUDEEXTRA *pDudeExtra = &actor->dudeExtra;
DUDEEXTRA* pDudeExtra = &actor->dudeExtra;
if (a3 == AI_SFX_PRIORITY_0)
sfxPlay3DSound(actor, a2, a4, 2);
else if (a3 > pDudeExtra->prio || pDudeExtra->time <= PlayClock)
@ -71,7 +71,7 @@ void aiPlay3DSound(DBloodActor *actor, int a2, AI_SFX_PRIORITY a3, int a4)
sfxKill3DSound(actor, -1, -1);
sfxPlay3DSound(actor, a2, a4, 0);
pDudeExtra->prio = a3;
pDudeExtra->time = PlayClock+120;
pDudeExtra->time = PlayClock + 120;
}
}
@ -81,11 +81,11 @@ void aiPlay3DSound(DBloodActor *actor, int a2, AI_SFX_PRIORITY a3, int a4)
//
//---------------------------------------------------------------------------
void aiNewState(DBloodActor* actor, AISTATE *pAIState)
void aiNewState(DBloodActor* actor, AISTATE* pAIState)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
pXSprite->stateTimer = pAIState->stateTicks;
pXSprite->aiState = pAIState;
int seqStartId = pDudeInfo->seqStartID;
@ -130,7 +130,7 @@ static bool isImmune(DBloodActor* actor, int dmgType, int minScale)
//
//---------------------------------------------------------------------------
bool CanMove(DBloodActor *actor, DBloodActor* target, int nAngle, int nRange)
bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange)
{
auto pSprite = &actor->s();
int top, bottom;
@ -139,7 +139,7 @@ bool CanMove(DBloodActor *actor, DBloodActor* target, int nAngle, int nRange)
int y = pSprite->y;
int z = pSprite->z;
HitScan(pSprite, z, CosScale16(nAngle), SinScale16(nAngle), 0, CLIPMASK0, nRange);
int nDist = approxDist(x-gHitInfo.hitx, y-gHitInfo.hity);
int nDist = approxDist(x - gHitInfo.hitx, y - gHitInfo.hity);
if (nDist - (pSprite->clipdist << 2) < nRange)
{
if (gHitInfo.hitactor == nullptr || target == nullptr || target != gHitInfo.hitactor)
@ -224,13 +224,13 @@ bool CanMove(DBloodActor *actor, DBloodActor* target, int nAngle, int nRange)
if (floorZ - bottom > 0x2000)
return false;
break;
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
case kDudeModernCustom:
case kDudeModernCustomBurning:
if ((Crusher && !nnExtIsImmune(pSprite, pXSector->damageType)) || ((Water || Underwater) && !canSwim(pSprite))) return false;
return true;
[[fallthrough]];
#endif
#endif
case kDudeZombieAxeNormal:
case kDudePhantasm:
case kDudeGillBeast:
@ -256,40 +256,40 @@ void aiChooseDirection(DBloodActor* actor, int a3)
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
int vc = ((a3+1024-pSprite->ang)&2047)-1024;
int vc = ((a3 + 1024 - pSprite->ang) & 2047) - 1024;
int nCos = Cos(pSprite->ang);
int nSin = Sin(pSprite->ang);
int dx = actor->xvel();
int dy = actor->yvel();
int t1 = DMulScale(dx, nCos, dy, nSin, 30);
int vsi = ((t1*15)>>12) / 2;
int vsi = ((t1 * 15) >> 12) / 2;
int v8 = 341;
if (vc < 0)
v8 = -341;
if (CanMove(actor, actor->GetTarget(), pSprite->ang+vc, vsi))
pXSprite->goalAng = pSprite->ang+vc;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang+vc/2, vsi))
pXSprite->goalAng = pSprite->ang+vc/2;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang-vc/2, vsi))
pXSprite->goalAng = pSprite->ang-vc/2;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang+v8, vsi))
pXSprite->goalAng = pSprite->ang+v8;
if (CanMove(actor, actor->GetTarget(), pSprite->ang + vc, vsi))
pXSprite->goalAng = pSprite->ang + vc;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang + vc / 2, vsi))
pXSprite->goalAng = pSprite->ang + vc / 2;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang - vc / 2, vsi))
pXSprite->goalAng = pSprite->ang - vc / 2;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang + v8, vsi))
pXSprite->goalAng = pSprite->ang + v8;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang, vsi))
pXSprite->goalAng = pSprite->ang;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang-v8, vsi))
pXSprite->goalAng = pSprite->ang-v8;
else if (CanMove(actor, actor->GetTarget(), pSprite->ang - v8, vsi))
pXSprite->goalAng = pSprite->ang - v8;
//else if (pSprite->flags&2)
//pXSprite->goalAng = pSprite->ang+341;
else // Weird..
pXSprite->goalAng = pSprite->ang+341;
pXSprite->goalAng = pSprite->ang + 341;
if (Chance(0x8000))
pXSprite->dodgeDir = 1;
else
pXSprite->dodgeDir = -1;
if (!CanMove(actor, actor->GetTarget(), pSprite->ang+pXSprite->dodgeDir*512, 512))
if (!CanMove(actor, actor->GetTarget(), pSprite->ang + pXSprite->dodgeDir * 512, 512))
{
pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!CanMove(actor, actor->GetTarget(), pSprite->ang+pXSprite->dodgeDir*512, 512))
if (!CanMove(actor, actor->GetTarget(), pSprite->ang + pXSprite->dodgeDir * 512, 512))
pXSprite->dodgeDir = 0;
}
}
@ -305,10 +305,10 @@ void aiMoveForward(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (abs(nAng) > 341)
return;
actor->xvel() += MulScale(pDudeInfo->frontSpeed, Cos(pSprite->ang), 30);
@ -326,10 +326,10 @@ void aiMoveTurn(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
}
//---------------------------------------------------------------------------
@ -343,10 +343,10 @@ void aiMoveDodge(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (pXSprite->dodgeDir)
{
int nCos = Cos(pSprite->ang);
@ -378,14 +378,14 @@ void aiActivateDude(DBloodActor* actor)
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!pXSprite->state)
{
aiChooseDirection(actor, getangle(pXSprite->targetX-pSprite->x, pXSprite->targetY-pSprite->y));
aiChooseDirection(actor, getangle(pXSprite->targetX - pSprite->x, pXSprite->targetY - pSprite->y));
pXSprite->state = 1;
}
switch (pSprite->type)
{
case kDudePhantasm:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 0;
pDudeExtraE->active = 1;
if (actor->GetTarget() == nullptr)
@ -403,7 +403,7 @@ void aiActivateDude(DBloodActor* actor)
case kDudeCultistTNT:
case kDudeCultistBeast:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 1;
if (actor->GetTarget() == nullptr)
{
@ -413,8 +413,8 @@ void aiActivateDude(DBloodActor* actor)
aiNewState(actor, &cultistSearch);
if (Chance(0x8000))
{
if (pSprite->type == kDudeCultistTommy) aiPlay3DSound(actor, 4008+Random(5), AI_SFX_PRIORITY_1, -1);
else aiPlay3DSound(actor, 1008+Random(5), AI_SFX_PRIORITY_1, -1);
if (pSprite->type == kDudeCultistTommy) aiPlay3DSound(actor, 4008 + Random(5), AI_SFX_PRIORITY_1, -1);
else aiPlay3DSound(actor, 1008 + Random(5), AI_SFX_PRIORITY_1, -1);
}
break;
case kMediumWater:
@ -427,8 +427,8 @@ void aiActivateDude(DBloodActor* actor)
{
if (Chance(0x8000))
{
if (pSprite->type == kDudeCultistTommy) aiPlay3DSound(actor, 4003+Random(4), AI_SFX_PRIORITY_1, -1);
else aiPlay3DSound(actor, 1003+Random(4), AI_SFX_PRIORITY_1, -1);
if (pSprite->type == kDudeCultistTommy) aiPlay3DSound(actor, 4003 + Random(4), AI_SFX_PRIORITY_1, -1);
else aiPlay3DSound(actor, 1003 + Random(4), AI_SFX_PRIORITY_1, -1);
}
switch (pXSprite->medium)
{
@ -469,7 +469,7 @@ void aiActivateDude(DBloodActor* actor)
#endif
case kDudeCultistTommyProne:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 1;
pSprite->type = kDudeCultistTommy;
if (actor->GetTarget() == nullptr)
@ -478,7 +478,7 @@ void aiActivateDude(DBloodActor* actor)
{
case 0:
aiNewState(actor, &cultistSearch);
if (Chance(0x8000)) aiPlay3DSound(actor, 4008+Random(5), AI_SFX_PRIORITY_1, -1);
if (Chance(0x8000)) aiPlay3DSound(actor, 4008 + Random(5), AI_SFX_PRIORITY_1, -1);
break;
case kMediumWater:
case kMediumGoo:
@ -489,7 +489,7 @@ void aiActivateDude(DBloodActor* actor)
else
{
if (Chance(0x8000))
aiPlay3DSound(actor, 4008+Random(5), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 4008 + Random(5), AI_SFX_PRIORITY_1, -1);
switch (pXSprite->medium)
{
@ -506,7 +506,7 @@ void aiActivateDude(DBloodActor* actor)
}
case kDudeCultistShotgunProne:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 1;
pSprite->type = kDudeCultistShotgun;
if (actor->GetTarget() == nullptr)
@ -516,7 +516,7 @@ void aiActivateDude(DBloodActor* actor)
case kMediumNormal:
aiNewState(actor, &cultistSearch);
if (Chance(0x8000))
aiPlay3DSound(actor, 1008+Random(5), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 1008 + Random(5), AI_SFX_PRIORITY_1, -1);
break;
case kMediumWater:
case kMediumGoo:
@ -527,7 +527,7 @@ void aiActivateDude(DBloodActor* actor)
else
{
if (Chance(0x8000))
aiPlay3DSound(actor, 1003+Random(4), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 1003 + Random(4), AI_SFX_PRIORITY_1, -1);
switch (pXSprite->medium)
{
case kMediumNormal:
@ -549,7 +549,7 @@ void aiActivateDude(DBloodActor* actor)
break;
case kDudeBat:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 0;
pDudeExtraE->active = 1;
if (!pSprite->flags)
@ -566,7 +566,7 @@ void aiActivateDude(DBloodActor* actor)
}
case kDudeBoneEel:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 0;
pDudeExtraE->active = 1;
if (actor->GetTarget() == nullptr)
@ -583,8 +583,8 @@ void aiActivateDude(DBloodActor* actor)
}
case kDudeGillBeast:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
XSECTOR *pXSector = NULL;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
XSECTOR* pXSector = NULL;
if (sector[pSprite->sectnum].extra > 0)
pXSector = &xsector[sector[pSprite->sectnum].extra];
pDudeExtraE->thinkTime = 0;
@ -611,7 +611,7 @@ void aiActivateDude(DBloodActor* actor)
}
case kDudeZombieAxeNormal:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 1;
if (actor->GetTarget() == nullptr)
aiNewState(actor, &zombieASearch);
@ -640,21 +640,21 @@ void aiActivateDude(DBloodActor* actor)
}
case kDudeZombieAxeBuried:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 1;
if (pXSprite->aiState == &zombieEIdle) aiNewState(actor, &zombieEUp);
break;
}
case kDudeZombieAxeLaying:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 1;
if (pXSprite->aiState == &zombieSIdle) aiNewState(actor, &zombie13AC2C);
break;
}
case kDudeZombieButcher:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 1;
if (actor->GetTarget() == nullptr)
aiNewState(actor, &zombieFSearch);
@ -681,7 +681,7 @@ void aiActivateDude(DBloodActor* actor)
aiNewState(actor, &zombieFBurnChase);
break;
case kDudeGargoyleFlesh: {
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 0;
pDudeExtraE->active = 1;
if (actor->GetTarget() == nullptr)
@ -698,7 +698,7 @@ void aiActivateDude(DBloodActor* actor)
}
case kDudeGargoyleStone:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 0;
pDudeExtraE->active = 1;
if (actor->GetTarget() == nullptr)
@ -716,7 +716,7 @@ void aiActivateDude(DBloodActor* actor)
case kDudeGargoyleStatueFlesh:
case kDudeGargoyleStatueStone:
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
// play gargoyle statue breaking animation if data1 = 1.
if (gModernMap && pXSprite->data1 == 1)
{
@ -731,13 +731,13 @@ void aiActivateDude(DBloodActor* actor)
if (pSprite->type == kDudeGargoyleStatueFlesh) aiNewState(actor, &gargoyleFMorph);
else aiNewState(actor, &gargoyleSMorph);
}
#else
#else
if (Chance(0x4000)) aiPlay3DSound(actor, 1401, AI_SFX_PRIORITY_1, -1);
else aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1);
if (pSprite->type == kDudeGargoyleStatueFlesh) aiNewState(actor, &gargoyleFMorph);
else aiNewState(actor, &gargoyleSMorph);
#endif
#endif
break;
case kDudeCerberusTwoHead:
if (actor->GetTarget() == nullptr)
@ -790,7 +790,7 @@ void aiActivateDude(DBloodActor* actor)
else
{
if (pXSprite->health > 0)
aiPlay3DSound(actor, 7000+Random(6), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 7000 + Random(6), AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &innocentChase);
}
break;
@ -799,7 +799,7 @@ void aiActivateDude(DBloodActor* actor)
aiNewState(actor, &tchernobogSearch);
else
{
aiPlay3DSound(actor, 2350+Random(7), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 2350 + Random(7), AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &tchernobogChase);
}
break;
@ -818,7 +818,7 @@ void aiActivateDude(DBloodActor* actor)
break;
case kDudeSpiderMother:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 1;
pSprite->flags |= 2;
pSprite->cstat &= ~8;
@ -826,14 +826,14 @@ void aiActivateDude(DBloodActor* actor)
aiNewState(actor, &spidSearch);
else
{
aiPlay3DSound(actor, 1853+Random(1), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 1853 + Random(1), AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &spidChase);
}
break;
}
case kDudeTinyCaleb:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 1;
if (actor->GetTarget() == nullptr)
{
@ -865,7 +865,7 @@ void aiActivateDude(DBloodActor* actor)
}
case kDudeBeast:
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 1;
if (actor->GetTarget() == nullptr)
{
@ -882,7 +882,7 @@ void aiActivateDude(DBloodActor* actor)
}
else
{
aiPlay3DSound(actor, 9009+Random(2), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 9009 + Random(2), AI_SFX_PRIORITY_1, -1);
switch (pXSprite->medium)
{
case kMediumNormal:
@ -928,7 +928,7 @@ void aiActivateDude(DBloodActor* actor)
//
//---------------------------------------------------------------------------
void aiSetTarget(DBloodActor*actor, int x, int y, int z)
void aiSetTarget(DBloodActor* actor, int x, int y, int z)
{
auto pXSprite = &actor->x();
actor->SetTarget(nullptr);
@ -974,11 +974,11 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
return 0;
pXSprite->health = ClipLow(pXSprite->health - nDamage, 0);
actor->cumulDamage += nDamage;
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (source)
{
spritetype *pSource = &source->s();
spritetype* pSource = &source->s();
int nSource = pSource->index;
if (pSprite == pSource) return 0;
else if (actor->GetTarget() == nullptr) // if no target, give the dude a target
@ -1000,7 +1000,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
}
}
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
if (gModernMap) {
// for enemies in patrol mode
@ -1122,16 +1122,16 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
return nDamage;
}
}
#endif
#endif
if (nDmgType == kDamageTesla)
{
DUDEEXTRA *pDudeExtra = &actor->dudeExtra;
DUDEEXTRA* pDudeExtra = &actor->dudeExtra;
pDudeExtra->teslaHit = 1;
}
else if (!VanillaMode()) // reset tesla hit state if received different type of damage
{
DUDEEXTRA *pDudeExtra = &actor->dudeExtra;
DUDEEXTRA* pDudeExtra = &actor->dudeExtra;
pDudeExtra->teslaHit = 0;
}
const bool fixRandomCultist = !cl_bloodvanillaenemies && (pSprite->inittype >= kDudeBase) && (pSprite->inittype < kDudeMax) && !VanillaMode(); // fix burning cultists randomly switching types underwater
@ -1155,8 +1155,8 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
pSprite->type = kDudeBurningCultist;
aiNewState(actor, &cultistBurnGoto);
aiPlay3DSound(actor, 361, AI_SFX_PRIORITY_0, -1);
aiPlay3DSound(actor, 1031+Random(2), AI_SFX_PRIORITY_2, -1);
actor->dudeExtra.time = PlayClock+360;
aiPlay3DSound(actor, 1031 + Random(2), AI_SFX_PRIORITY_2, -1);
actor->dudeExtra.time = PlayClock + 360;
actHealDude(actor, dudeInfo[40].startHealth, dudeInfo[40].startHealth);
evKill(actor, kCallbackFXFlameLick);
}
@ -1167,7 +1167,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
pSprite->type = kDudeBurningInnocent;
aiNewState(actor, &cultistBurnGoto);
aiPlay3DSound(actor, 361, AI_SFX_PRIORITY_0, -1);
actor->dudeExtra.time = PlayClock+360;
actor->dudeExtra.time = PlayClock + 360;
actHealDude(actor, dudeInfo[39].startHealth, dudeInfo[39].startHealth);
evKill(actor, kCallbackFXFlameLick);
}
@ -1175,8 +1175,8 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
case kDudeBurningCultist:
if (Chance(0x4000) && actor->dudeExtra.time < PlayClock)
{
aiPlay3DSound(actor, 1031+Random(2), AI_SFX_PRIORITY_2, -1);
actor->dudeExtra.time = PlayClock+360;
aiPlay3DSound(actor, 1031 + Random(2), AI_SFX_PRIORITY_2, -1);
actor->dudeExtra.time = PlayClock + 360;
}
if (Chance(0x600) && (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo))
{
@ -1222,7 +1222,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
aiNewState(actor, &cultistBurnGoto);
}
aiPlay3DSound(actor, 361, AI_SFX_PRIORITY_0, -1);
actor->dudeExtra.time = PlayClock+360;
actor->dudeExtra.time = PlayClock + 360;
actHealDude(actor, dudeInfo[39].startHealth, dudeInfo[39].startHealth);
evKill(actor, kCallbackFXFlameLick);
}
@ -1371,7 +1371,7 @@ void RecoilDude(DBloodActor* actor)
case kDudeZombieAxeNormal:
case kDudeZombieAxeBuried:
aiPlay3DSound(actor, 1106, AI_SFX_PRIORITY_2, -1);
if (pDudeExtra->teslaHit && pXSprite->data3 > pDudeInfo->startHealth/3)
if (pDudeExtra->teslaHit && pXSprite->data3 > pDudeInfo->startHealth / 3)
aiNewState(actor, &zombieATeslaRecoil);
else if (pXSprite->data3 > pDudeInfo->startHealth / 3)
aiNewState(actor, &zombieARecoil2);
@ -1392,8 +1392,8 @@ void RecoilDude(DBloodActor* actor)
aiNewState(actor, &gargoyleFRecoil);
break;
case kDudeCerberusTwoHead:
aiPlay3DSound(actor, 2302+Random(2), AI_SFX_PRIORITY_2, -1);
if (pDudeExtra->teslaHit && pXSprite->data3 > pDudeInfo->startHealth/3)
aiPlay3DSound(actor, 2302 + Random(2), AI_SFX_PRIORITY_2, -1);
if (pDudeExtra->teslaHit && pXSprite->data3 > pDudeInfo->startHealth / 3)
aiNewState(actor, &cerberusTeslaRecoil);
else
aiNewState(actor, &cerberusRecoil);
@ -1611,7 +1611,7 @@ void aiLookForTarget(DBloodActor* actor)
}
if (pXSprite->state)
{
uint8_t sectmap[(kMaxSectors+7)>>3];
uint8_t sectmap[(kMaxSectors + 7) >> 3];
const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic
GetClosestSpriteSectors(pSprite->sectnum, pSprite->x, pSprite->y, 400, sectmap, nullptr, newSectCheckMethod);
@ -1723,13 +1723,13 @@ void aiInitSprite(DBloodActor* actor)
if (nXSector > 0)
pXSector = &xsector[nXSector];
DUDEEXTRA* pDudeExtra = &actor->dudeExtra;
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtra->teslaHit = 0;
pDudeExtra->time = 0;
pDudeExtraE->thinkTime = 0;
pDudeExtraE->active = 0;
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
int stateTimer = -1;
int targetX = 0, targetY = 0, targetZ = 0;
DBloodActor* pTargetMarker = nullptr;

View file

@ -43,39 +43,39 @@ static void batMoveFly(DBloodActor*);
static void batMoveToCeil(DBloodActor*);
AISTATE batIdle = {kAiStateIdle, 0, -1, 0, NULL, NULL, batThinkTarget, NULL };
AISTATE batFlyIdle = {kAiStateIdle, 6, -1, 0, NULL, NULL, batThinkTarget, NULL };
AISTATE batChase = {kAiStateChase, 6, -1, 0, NULL, batMoveForward, batThinkChase, &batFlyIdle };
AISTATE batPonder = {kAiStateOther, 6, -1, 0, NULL, NULL, batThinkPonder, NULL };
AISTATE batGoto = {kAiStateMove, 6, -1, 600, NULL, batMoveForward, batThinkGoto, &batFlyIdle };
AISTATE batBite = {kAiStateChase, 7, nBatBiteClient, 60, NULL, NULL, NULL, &batPonder };
AISTATE batRecoil = {kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &batChase };
AISTATE batSearch = {kAiStateSearch, 6, -1, 120, NULL, batMoveForward, batThinkSearch, &batFlyIdle };
AISTATE batSwoop = {kAiStateOther, 6, -1, 60, NULL, batMoveSwoop, batThinkChase, &batChase };
AISTATE batIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, batThinkTarget, NULL };
AISTATE batFlyIdle = { kAiStateIdle, 6, -1, 0, NULL, NULL, batThinkTarget, NULL };
AISTATE batChase = { kAiStateChase, 6, -1, 0, NULL, batMoveForward, batThinkChase, &batFlyIdle };
AISTATE batPonder = { kAiStateOther, 6, -1, 0, NULL, NULL, batThinkPonder, NULL };
AISTATE batGoto = { kAiStateMove, 6, -1, 600, NULL, batMoveForward, batThinkGoto, &batFlyIdle };
AISTATE batBite = { kAiStateChase, 7, nBatBiteClient, 60, NULL, NULL, NULL, &batPonder };
AISTATE batRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &batChase };
AISTATE batSearch = { kAiStateSearch, 6, -1, 120, NULL, batMoveForward, batThinkSearch, &batFlyIdle };
AISTATE batSwoop = { kAiStateOther, 6, -1, 60, NULL, batMoveSwoop, batThinkChase, &batChase };
AISTATE batFly = { kAiStateMove, 6, -1, 0, NULL, batMoveFly, batThinkChase, &batChase };
AISTATE batTurn = {kAiStateMove, 6, -1, 60, NULL, aiMoveTurn, NULL, &batChase };
AISTATE batHide = {kAiStateOther, 6, -1, 0, NULL, batMoveToCeil, batMoveForward, NULL };
AISTATE batDodgeUp = {kAiStateMove, 6, -1, 120, NULL, batMoveDodgeUp, 0, &batChase };
AISTATE batDodgeUpRight = {kAiStateMove, 6, -1, 90, NULL, batMoveDodgeUp, 0, &batChase };
AISTATE batDodgeUpLeft = {kAiStateMove, 6, -1, 90, NULL, batMoveDodgeUp, 0, &batChase };
AISTATE batDodgeDown = {kAiStateMove, 6, -1, 120, NULL, batMoveDodgeDown, 0, &batChase };
AISTATE batDodgeDownRight = {kAiStateMove, 6, -1, 90, NULL, batMoveDodgeDown, 0, &batChase };
AISTATE batDodgeDownLeft = {kAiStateMove, 6, -1, 90, NULL, batMoveDodgeDown, 0, &batChase };
AISTATE batTurn = { kAiStateMove, 6, -1, 60, NULL, aiMoveTurn, NULL, &batChase };
AISTATE batHide = { kAiStateOther, 6, -1, 0, NULL, batMoveToCeil, batMoveForward, NULL };
AISTATE batDodgeUp = { kAiStateMove, 6, -1, 120, NULL, batMoveDodgeUp, 0, &batChase };
AISTATE batDodgeUpRight = { kAiStateMove, 6, -1, 90, NULL, batMoveDodgeUp, 0, &batChase };
AISTATE batDodgeUpLeft = { kAiStateMove, 6, -1, 90, NULL, batMoveDodgeUp, 0, &batChase };
AISTATE batDodgeDown = { kAiStateMove, 6, -1, 120, NULL, batMoveDodgeDown, 0, &batChase };
AISTATE batDodgeDownRight = { kAiStateMove, 6, -1, 90, NULL, batMoveDodgeDown, 0, &batChase };
AISTATE batDodgeDownLeft = { kAiStateMove, 6, -1, 90, NULL, batMoveDodgeDown, 0, &batChase };
void batBiteSeqCallback(int, DBloodActor* actor)
{
XSPRITE* pXSprite = &actor->x();
spritetype *pSprite = &actor->s();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
actFireVector(actor, 0, 0, dx, dy, height2-height, kVectorBatBite);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (pTarget->yrepeat * pDudeInfoT->eyeHeight) << 2;
actFireVector(actor, 0, 0, dx, dy, height2 - height, kVectorBatBite);
}
static void batThinkTarget(DBloodActor* actor)
@ -83,15 +83,15 @@ static void batThinkTarget(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++;
else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active)
{
pDudeExtraE->thinkTime = 0;
pXSprite->goalAng += 256;
POINT3D *pTarget = &actor->basePoint();
POINT3D* pTarget = &actor->basePoint();
aiSetTarget(actor, pTarget->x, pTarget->y, pTarget->z);
aiNewState(actor, &batTurn);
return;
@ -100,21 +100,21 @@ static void batThinkTarget(DBloodActor* actor)
{
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
PLAYER *pPlayer = &gPlayer[p];
PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue;
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x;
int dy = y-pSprite->y;
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget(actor, pPlayer->actor());
@ -145,9 +145,9 @@ static void batThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -166,12 +166,12 @@ static void batThinkPonder(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
XSPRITE *pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
@ -181,27 +181,27 @@ static void batThinkPonder(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int height2 = (getDudeInfo(pTarget->type)->eyeHeight*pTarget->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
int height2 = (getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
aiSetTarget(actor, actor->GetTarget());
if (height2-height < 0x3000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
if (height2 - height < 0x3000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeUp);
else if (height2-height > 0x5000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
else if (height2 - height > 0x5000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeDown);
else if (height2-height < 0x2000 && nDist < 0x200 && abs(nDeltaAngle) < 85)
else if (height2 - height < 0x2000 && nDist < 0x200 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeUp);
else if (height2-height > 0x6000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
else if (height2 - height > 0x6000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeDown);
else if (height2-height < 0x2000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
else if (height2 - height < 0x2000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeUp);
else if (height2-height < 0x2000 && abs(nDeltaAngle) < 85 && nDist > 0x1400)
else if (height2 - height < 0x2000 && abs(nDeltaAngle) < 85 && nDist > 0x1400)
aiNewState(actor, &batDodgeUp);
else if (height2-height > 0x4000)
else if (height2 - height > 0x4000)
aiNewState(actor, &batDodgeDown);
else
aiNewState(actor, &batDodgeUp);
@ -217,10 +217,10 @@ static void batMoveDodgeUp(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nCos = Cos(pSprite->ang);
int nSin = Sin(pSprite->ang);
int dx = actor->xvel();
@ -242,10 +242,10 @@ static void batMoveDodgeDown(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (pXSprite->dodgeDir == 0)
return;
int nCos = Cos(pSprite->ang);
@ -274,12 +274,12 @@ static void batThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
@ -294,10 +294,10 @@ static void batThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
// Should be dudeInfo[pTarget->type-kDudeBase]
int height2 = (pDudeInfo->eyeHeight*pTarget->yrepeat)<<2;
int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
@ -306,11 +306,11 @@ static void batThinkChase(DBloodActor* actor)
{
aiSetTarget(actor, actor->GetTarget());
int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
if (height2-height < 0x2000 && nDist < 0x200 && abs(nDeltaAngle) < 85)
if (height2 - height < 0x2000 && nDist < 0x200 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batBite);
else if ((height2-height > 0x5000 || floorZ-bottom > 0x5000) && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
else if ((height2 - height > 0x5000 || floorZ - bottom > 0x5000) && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batSwoop);
else if ((height2-height < 0x3000 || floorZ-bottom < 0x3000) && abs(nDeltaAngle) < 85)
else if ((height2 - height < 0x3000 || floorZ - bottom < 0x3000) && abs(nDeltaAngle) < 85)
aiNewState(actor, &batFly);
return;
}
@ -331,17 +331,17 @@ static void batMoveForward(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
return;
if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
pSprite->ang = (pSprite->ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x200)
return;
@ -354,7 +354,7 @@ static void batMoveForward(DBloodActor* actor)
if (actor->GetTarget() == nullptr)
t1 += nAccel;
else
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
}
@ -364,18 +364,18 @@ static void batMoveSwoop(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pXSprite->goalAng = (pSprite->ang+512)&2047;
pXSprite->goalAng = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x200)
return;
@ -385,7 +385,7 @@ static void batMoveSwoop(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
actor->zvel() = 0x44444;
@ -396,18 +396,18 @@ static void batMoveFly(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pSprite->ang = (pSprite->ang+512)&2047;
pSprite->ang = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x200)
return;
@ -417,7 +417,7 @@ static void batMoveFly(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
actor->zvel() = -0x2d555;
@ -433,7 +433,7 @@ void batMoveToCeil(DBloodActor* actor)
int nSector = pSprite->sectnum;
if (z - pXSprite->targetZ < 0x1000)
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 0;
pSprite->flags = 0;
aiNewState(actor, &batIdle);

View file

@ -30,19 +30,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void MorphToBeast(DBloodActor *);
static void beastThinkSearch(DBloodActor *);
static void beastThinkGoto(DBloodActor *);
static void beastThinkChase(DBloodActor *);
static void beastThinkSwimGoto(DBloodActor *);
static void beastThinkSwimChase(DBloodActor *);
static void beastMoveForward(DBloodActor *);
static void sub_628A0(DBloodActor *);
static void sub_62AE0(DBloodActor *);
static void sub_62D7C(DBloodActor *);
static void MorphToBeast(DBloodActor*);
static void beastThinkSearch(DBloodActor*);
static void beastThinkGoto(DBloodActor*);
static void beastThinkChase(DBloodActor*);
static void beastThinkSwimGoto(DBloodActor*);
static void beastThinkSwimChase(DBloodActor*);
static void beastMoveForward(DBloodActor*);
static void sub_628A0(DBloodActor*);
static void sub_62AE0(DBloodActor*);
static void sub_62D7C(DBloodActor*);
AISTATE beastIdle = {kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE beastChase = {kAiStateChase, 8, -1, 0, NULL, beastMoveForward, beastThinkChase, NULL };
AISTATE beastIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE beastChase = { kAiStateChase, 8, -1, 0, NULL, beastMoveForward, beastThinkChase, NULL };
AISTATE beastDodge = { kAiStateMove, 8, -1, 60, NULL, aiMoveDodge, NULL, &beastChase };
AISTATE beastGoto = { kAiStateMove, 8, -1, 600, NULL, beastMoveForward, beastThinkGoto, &beastIdle };
AISTATE beastSlash = { kAiStateChase, 6, nSlashClient, 120, NULL, NULL, NULL, &beastChase };
@ -50,7 +50,7 @@ AISTATE beastStomp = { kAiStateChase, 7, nStompClient, 120, NULL, NULL, NULL, &b
AISTATE beastSearch = { kAiStateSearch, 8, -1, 120, NULL, beastMoveForward, beastThinkSearch, &beastIdle };
AISTATE beastRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &beastDodge };
AISTATE beastTeslaRecoil = { kAiStateRecoil, 4, -1, 0, NULL, NULL, NULL, &beastDodge };
AISTATE beastSwimIdle = {kAiStateIdle, 9, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE beastSwimIdle = { kAiStateIdle, 9, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE beastSwimChase = { kAiStateChase, 9, -1, 0, NULL, sub_628A0, beastThinkSwimChase, NULL };
AISTATE beastSwimDodge = { kAiStateMove, 9, -1, 90, NULL, aiMoveDodge, NULL, &beastSwimChase };
AISTATE beastSwimGoto = { kAiStateMove, 9, -1, 600, NULL, beastMoveForward, beastThinkSwimGoto, &beastSwimIdle };
@ -66,26 +66,26 @@ AISTATE beast138FEC = { kAiStateOther, 9, -1, 120, NULL, aiMoveTurn, NULL, &beas
void SlashSeqCallback(int, DBloodActor* actor)
{
XSPRITE* pXSprite = &actor->x();
spritetype *pSprite = &actor->s();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
// Correct ?
int dz = pSprite->z-pTarget->z;
dx += Random3(4000-700*gGameOptions.nDifficulty);
dy += Random3(4000-700*gGameOptions.nDifficulty);
int dz = pSprite->z - pTarget->z;
dx += 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);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGargSlash);
sfxPlay3DSound(actor, 9012+Random(2), -1, 0);
sfxPlay3DSound(actor, 9012 + Random(2), -1, 0);
}
void StompSeqCallback(int, DBloodActor* actor1)
{
uint8_t sectmap[(kMaxSectors+7)>>3];
uint8_t sectmap[(kMaxSectors + 7) >> 3];
XSPRITE* pXSprite = &actor1->x();
spritetype *pSprite = &actor1->s();
spritetype* pSprite = &actor1->s();
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int x = pSprite->x;
@ -93,8 +93,8 @@ void StompSeqCallback(int, DBloodActor* actor1)
int z = pSprite->z;
int vc = 400;
int nSector = pSprite->sectnum;
int v1c = 5+2*gGameOptions.nDifficulty;
int v10 = 25+30*gGameOptions.nDifficulty;
int v1c = 5 + 2 * gGameOptions.nDifficulty;
int v10 = 25 + 30 * gGameOptions.nDifficulty;
const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic
GetClosestSpriteSectors(nSector, x, y, vc, sectmap, nullptr, newSectCheckMethod);
char v4 = 0;
@ -112,32 +112,32 @@ void StompSeqCallback(int, DBloodActor* actor1)
{
if (actor1 != actor2 || v4)
{
spritetype *pSprite2 = &actor2->s();
spritetype* pSprite2 = &actor2->s();
if (pSprite2->extra > 0 && pSprite2->extra < kMaxXSprites)
{
if (pSprite2->type == kDudeBeast)
continue;
if (pSprite2->flags&32)
if (pSprite2->flags & 32)
continue;
if (TestBitString(sectmap, pSprite2->sectnum) && CheckProximity(pSprite2, x, y, z, nSector, vc))
{
int top, bottom;
GetActorExtents(actor1, &top, &bottom);
if (abs(bottom-sector[nSector].floorz) == 0)
if (abs(bottom - sector[nSector].floorz) == 0)
{
int dx = abs(pSprite->x-pSprite2->x);
int dy = abs(pSprite->y-pSprite2->y);
int nDist2 = ksqrt(dx*dx + dy*dy);
int dx = abs(pSprite->x - pSprite2->x);
int dy = abs(pSprite->y - pSprite2->y);
int nDist2 = ksqrt(dx * dx + dy * dy);
if (nDist2 <= vc)
{
int nDamage;
if (!nDist2)
nDamage = v1c + v10;
else
nDamage = v1c + ((vc-nDist2)*v10)/vc;
nDamage = v1c + ((vc - nDist2) * v10) / vc;
if (IsPlayerSprite(pSprite2))
gPlayer[pSprite2->type-kDudePlayer1].quakeEffect += nDamage*4;
actDamageSprite(actor1, actor2, kDamageFall, nDamage<<4);
gPlayer[pSprite2->type - kDudePlayer1].quakeEffect += nDamage * 4;
actDamageSprite(actor1, actor2, kDamageFall, nDamage << 4);
}
}
}
@ -147,31 +147,31 @@ void StompSeqCallback(int, DBloodActor* actor1)
it1.Reset(kStatThing);
while (auto actor2 = it1.Next())
{
spritetype *pSprite2 = &actor2->s();
if (pSprite2->flags&32)
spritetype* pSprite2 = &actor2->s();
if (pSprite2->flags & 32)
continue;
if (TestBitString(sectmap, pSprite2->sectnum) && CheckProximity(pSprite2, x, y, z, nSector, vc))
{
XSPRITE *pXSprite = &actor2->x();
XSPRITE* pXSprite = &actor2->x();
if (pXSprite->locked)
continue;
int dx = abs(pSprite->x-pSprite2->x);
int dy = abs(pSprite->y-pSprite2->y);
int nDist2 = ksqrt(dx*dx + dy*dy);
int dx = abs(pSprite->x - pSprite2->x);
int dy = abs(pSprite->y - pSprite2->y);
int nDist2 = ksqrt(dx * dx + dy * dy);
if (nDist2 <= vc)
{
int nDamage;
if (!nDist2)
nDamage = v1c + v10;
else
nDamage = v1c + ((vc-nDist2)*v10)/vc;
nDamage = v1c + ((vc - nDist2) * v10) / vc;
if (IsPlayerSprite(pSprite2))
gPlayer[pSprite2->type-kDudePlayer1].quakeEffect += nDamage*4;
actDamageSprite(actor1, actor2, kDamageFall, nDamage<<4);
gPlayer[pSprite2->type - kDudePlayer1].quakeEffect += nDamage * 4;
actDamageSprite(actor1, actor2, kDamageFall, nDamage << 4);
}
}
}
sfxPlay3DSound(actor1, 9015+Random(2), -1, 0);
sfxPlay3DSound(actor1, 9015 + Random(2), -1, 0);
}
static void MorphToBeast(DBloodActor* actor)
@ -186,7 +186,7 @@ static void beastThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -195,18 +195,18 @@ static void beastThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
XSECTOR *pXSector;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
else
pXSector = NULL;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{
if (pXSector && pXSector->Underwater)
@ -223,7 +223,7 @@ static void beastThinkChase(DBloodActor* actor)
auto pSprite = &actor->s();
if (actor->GetTarget() == nullptr)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -236,16 +236,16 @@ static void beastThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -257,9 +257,9 @@ static void beastThinkChase(DBloodActor* actor)
aiNewState(actor, &beastSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -274,25 +274,25 @@ static void beastThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (pTarget->flags&2)
actor->dudeSlope = DivScale(pTarget->z - pSprite->z, nDist, 10);
if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (pTarget->flags & 2)
&& IsPlayerSprite(pTarget) && Chance(0x8000))
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
else
pXSector = NULL;
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
if (pXTarget->health > (unsigned)gPlayerTemplate[0].startHealth/2)
if (pXTarget->health > (unsigned)gPlayerTemplate[0].startHealth / 2)
{
switch (hit)
{
@ -323,7 +323,7 @@ static void beastThinkChase(DBloodActor* actor)
}
if (nDist < 921 && abs(nDeltaAngle) < 28)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -367,7 +367,7 @@ static void beastThinkChase(DBloodActor* actor)
}
}
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -385,12 +385,12 @@ static void beastThinkSwimGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &beastSwimSearch);
aiThinkTarget(actor);
@ -406,19 +406,19 @@ static void beastThinkSwimChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &beastSwimSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &beastSwimSearch);
return;
@ -426,8 +426,8 @@ static void beastThinkSwimChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = pDudeInfo->eyeHeight+pSprite->z;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = pDudeInfo->eyeHeight + pSprite->z;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
@ -439,7 +439,7 @@ static void beastThinkSwimChase(DBloodActor* actor)
aiNewState(actor, &beastSwimSlash);
else
{
aiPlay3DSound(actor, 9009+Random(2), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 9009 + Random(2), AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &beast138FD0);
}
}
@ -457,14 +457,14 @@ static void beastMoveForward(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (abs(nAng) > 341)
return;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist <= 0x400 && Random(64) < 32)
return;
@ -477,17 +477,17 @@ static void sub_628A0(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
return;
if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
pSprite->ang = (pSprite->ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400)
return;
@ -500,7 +500,7 @@ static void sub_628A0(DBloodActor* actor)
if (actor->GetTarget() == nullptr)
t1 += nAccel;
else
t1 += nAccel>>2;
t1 += nAccel >> 2;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
}
@ -510,22 +510,22 @@ static void sub_62AE0(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pXSprite->goalAng = (pSprite->ang+512)&2047;
pXSprite->goalAng = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
@ -548,23 +548,23 @@ static void sub_62D7C(DBloodActor* actor)
auto pSprite = &actor->s();
int nSprite = pSprite->index;
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pSprite->ang = (pSprite->ang+512)&2047;
pSprite->ang = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dz = (z2 - z)<<3;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;
@ -574,7 +574,7 @@ static void sub_62D7C(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
actor->zvel() = dz;

View file

@ -29,17 +29,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void eelThinkTarget(DBloodActor *);
static void eelThinkSearch(DBloodActor *);
static void eelThinkGoto(DBloodActor *);
static void eelThinkPonder(DBloodActor *);
static void eelMoveDodgeUp(DBloodActor *);
static void eelMoveDodgeDown(DBloodActor *);
static void eelThinkChase(DBloodActor *);
static void eelMoveForward(DBloodActor *);
static void eelMoveSwoop(DBloodActor *);
static void eelMoveAscend(DBloodActor *actor);
static void eelMoveToCeil(DBloodActor *);
static void eelThinkTarget(DBloodActor*);
static void eelThinkSearch(DBloodActor*);
static void eelThinkGoto(DBloodActor*);
static void eelThinkPonder(DBloodActor*);
static void eelMoveDodgeUp(DBloodActor*);
static void eelMoveDodgeDown(DBloodActor*);
static void eelThinkChase(DBloodActor*);
static void eelMoveForward(DBloodActor*);
static void eelMoveSwoop(DBloodActor*);
static void eelMoveAscend(DBloodActor* actor);
static void eelMoveToCeil(DBloodActor*);
AISTATE eelIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, eelThinkTarget, NULL };
@ -64,7 +64,7 @@ AISTATE eelDodgeDownLeft = { kAiStateMove, 0, -1, 90, NULL, eelMoveDodgeDown, NU
void eelBiteSeqCallback(int, DBloodActor* actor)
{
XSPRITE* pXSprite = &actor->x();
spritetype *pSprite = &actor->s();
spritetype* pSprite = &actor->s();
/*
* workaround for
@ -79,15 +79,15 @@ void eelBiteSeqCallback(int, DBloodActor* actor)
return;
}
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
actFireVector(actor, 0, 0, dx, dy, height2-height, kVectorBoneelBite);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (pTarget->yrepeat * pDudeInfoT->eyeHeight) << 2;
actFireVector(actor, 0, 0, dx, dy, height2 - height, kVectorBoneelBite);
}
static void eelThinkTarget(DBloodActor* actor)
@ -95,8 +95,8 @@ static void eelThinkTarget(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++;
else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active)
@ -112,21 +112,21 @@ static void eelThinkTarget(DBloodActor* actor)
{
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
PLAYER *pPlayer = &gPlayer[p];
PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue;
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x;
int dy = y-pSprite->y;
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
@ -150,7 +150,7 @@ static void eelThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
eelThinkTarget(actor);
}
@ -159,12 +159,12 @@ static void eelThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &eelSearch);
eelThinkTarget(actor);
@ -180,12 +180,12 @@ static void eelThinkPonder(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &eelSearch);
@ -194,27 +194,27 @@ static void eelThinkPonder(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int height2 = (getDudeInfo(pTarget->type)->eyeHeight*pTarget->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
int height2 = (getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
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)
aiNewState(actor, &eelDodgeUp);
else if (height2-height > 0xccc && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
else if (height2 - height > 0xccc && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeDown);
else if (height2-height < 0xccc && nDist < 0x399 && abs(nDeltaAngle) < 85)
else if (height2 - height < 0xccc && nDist < 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeUp);
else if (height2-height > 0xccc && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
else if (height2 - height > 0xccc && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeDown);
else if (height2-height < -0x2000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
else if (height2 - height < -0x2000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeUp);
else if (height2-height < -0x2000 && abs(nDeltaAngle) < 85 && nDist > 0x1400)
else if (height2 - height < -0x2000 && abs(nDeltaAngle) < 85 && nDist > 0x1400)
aiNewState(actor, &eelDodgeUp);
else if (height2-height > 0xccc)
else if (height2 - height > 0xccc)
aiNewState(actor, &eelDodgeDown);
else
aiNewState(actor, &eelDodgeUp);
@ -230,10 +230,10 @@ static void eelMoveDodgeUp(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nCos = Cos(pSprite->ang);
int nSin = Sin(pSprite->ang);
int dx = actor->xvel();
@ -255,10 +255,10 @@ static void eelMoveDodgeDown(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (pXSprite->dodgeDir == 0)
return;
int nCos = Cos(pSprite->ang);
@ -287,18 +287,18 @@ static void eelThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &eelSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &eelSearch);
return;
@ -306,8 +306,8 @@ static void eelThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
int top2, bottom2;
@ -339,17 +339,17 @@ static void eelMoveForward(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341)
return;
if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
pSprite->ang = (pSprite->ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist <= 0x399)
return;
@ -362,7 +362,7 @@ static void eelMoveForward(DBloodActor* actor)
if (actor->GetTarget() == nullptr)
t1 += nAccel;
else
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
}
@ -372,15 +372,15 @@ static void eelMoveSwoop(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341)
return;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x8000) && nDist <= 0x399)
return;
@ -390,7 +390,7 @@ static void eelMoveSwoop(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
actor->zvel() = 0x22222;
@ -401,15 +401,15 @@ static void eelMoveAscend(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341)
return;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x399)
return;
@ -419,7 +419,7 @@ static void eelMoveAscend(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
actor->zvel() = -0x8000;
@ -435,7 +435,7 @@ void eelMoveToCeil(DBloodActor* actor)
int nSector = pSprite->sectnum;
if (z - pXSprite->targetZ < 0x1000)
{
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 0;
pSprite->flags = 0;
aiNewState(actor, &eelIdle);

View file

@ -79,7 +79,7 @@ static void burnThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -88,12 +88,12 @@ static void burnThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{
switch (pSprite->type)
@ -116,11 +116,11 @@ static void burnThinkGoto(DBloodActor* actor)
case kDudeBurningTinyCaleb:
aiNewState(actor, &tinycalebBurnSearch);
break;
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
case kDudeModernCustomBurning:
aiNewState(actor, &genDudeBurnSearch);
break;
#endif
#endif
}
}
aiThinkTarget(actor);
@ -152,21 +152,21 @@ static void burnThinkChase(DBloodActor* actor)
case kDudeBurningTinyCaleb:
aiNewState(actor, &tinycalebBurnGoto);
break;
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
case kDudeModernCustomBurning:
aiNewState(actor, &genDudeBurnGoto);
break;
#endif
#endif
}
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
switch (pSprite->type)
@ -189,19 +189,19 @@ static void burnThinkChase(DBloodActor* actor)
case kDudeBurningTinyCaleb:
aiNewState(actor, &tinycalebBurnSearch);
break;
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
case kDudeModernCustomBurning:
aiNewState(actor, &genDudeBurnSearch);
break;
#endif
#endif
}
return;
}
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -229,11 +229,11 @@ static void burnThinkChase(DBloodActor* actor)
case kDudeBurningTinyCaleb:
aiNewState(actor, &tinycalebBurnAttack);
break;
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
case kDudeModernCustomBurning:
aiNewState(actor, &genDudeBurnSearch);
break;
#endif
#endif
}
}
return;
@ -261,11 +261,11 @@ static void burnThinkChase(DBloodActor* actor)
case kDudeBurningTinyCaleb:
aiNewState(actor, &tinycalebBurnGoto);
break;
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
case kDudeModernCustomBurning:
aiNewState(actor, &genDudeBurnSearch);
break;
#endif
#endif
}
actor->SetTarget(nullptr);
}

View file

@ -30,14 +30,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void calebThinkSearch(DBloodActor *);
static void calebThinkGoto(DBloodActor *);
static void calebThinkChase(DBloodActor *);
static void calebThinkSwimGoto(DBloodActor *);
static void calebThinkSwimChase(DBloodActor *);
static void sub_65D04(DBloodActor *);
static void sub_65F44(DBloodActor *);
static void sub_661E0(DBloodActor *);
static void calebThinkSearch(DBloodActor*);
static void calebThinkGoto(DBloodActor*);
static void calebThinkChase(DBloodActor*);
static void calebThinkSwimGoto(DBloodActor*);
static void calebThinkSwimChase(DBloodActor*);
static void sub_65D04(DBloodActor*);
static void sub_65F44(DBloodActor*);
static void sub_661E0(DBloodActor*);
AISTATE tinycalebIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE tinycalebChase = { kAiStateChase, 6, -1, 0, NULL, aiMoveForward, calebThinkChase, NULL };
@ -60,7 +60,7 @@ AISTATE tinycaleb139698 = { kAiStateOther, 8, -1, 120, NULL, aiMoveTurn, NULL, &
void SeqAttackCallback(int, DBloodActor* actor)
{
spritetype *pSprite = &actor->s();
spritetype* pSprite = &actor->s();
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = actor->dudeSlope;
@ -72,10 +72,10 @@ void SeqAttackCallback(int, DBloodActor* actor)
int r1 = Random3(500);
int r2 = Random3(1000);
int r3 = Random3(1000);
actFireVector(actor, 0, 0, dx+r3, dy+r2, dz+r1, kVectorShell);
actFireVector(actor, 0, 0, dx + r3, dy + r2, dz + r1, kVectorShell);
}
if (Chance(0x8000))
sfxPlay3DSound(actor, 10000+Random(5), -1, 0);
sfxPlay3DSound(actor, 10000 + Random(5), -1, 0);
if (Chance(0x8000))
sfxPlay3DSound(actor, 1001, -1, 0);
else
@ -86,7 +86,7 @@ static void calebThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -95,18 +95,18 @@ static void calebThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
XSECTOR *pXSector;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
else
pXSector = NULL;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{
if (pXSector && pXSector->Underwater)
@ -123,7 +123,7 @@ static void calebThinkChase(DBloodActor* actor)
auto pSprite = &actor->s();
if (actor->GetTarget() == nullptr)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -136,15 +136,15 @@ static void calebThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -154,14 +154,14 @@ static void calebThinkChase(DBloodActor* actor)
aiNewState(actor, &tinycalebSwimSearch);
else
{
aiPlay3DSound(actor, 11000+Random(4), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 11000 + Random(4), AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &tinycalebSearch);
}
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -176,17 +176,17 @@ static void calebThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
actor->dudeSlope = DivScale(pTarget->z - pSprite->z, nDist, 10);
if (nDist < 0x599 && abs(nDeltaAngle) < 28)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -230,7 +230,7 @@ static void calebThinkChase(DBloodActor* actor)
}
}
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -250,12 +250,12 @@ static void calebThinkSwimGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tinycalebSwimSearch);
aiThinkTarget(actor);
@ -271,18 +271,18 @@ static void calebThinkSwimChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &tinycalebSwimSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &tinycalebSwimSearch);
return;
@ -290,8 +290,8 @@ static void calebThinkSwimChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = pDudeInfo->eyeHeight+pSprite->z;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = pDudeInfo->eyeHeight + pSprite->z;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
@ -316,17 +316,17 @@ static void sub_65D04(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
return;
if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
pSprite->ang = (pSprite->ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400)
return;
@ -339,7 +339,7 @@ static void sub_65D04(DBloodActor* actor)
if (actor->GetTarget() == nullptr)
t1 += nAccel;
else
t1 += nAccel>>2;
t1 += nAccel >> 2;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
}
@ -349,23 +349,23 @@ static void sub_65F44(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pXSprite->goalAng = (pSprite->ang+512)&2047;
pXSprite->goalAng = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
@ -387,24 +387,24 @@ static void sub_661E0(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pSprite->ang = (pSprite->ang+512)&2047;
pSprite->ang = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dz = (z2 - z)<<3;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;
@ -414,7 +414,7 @@ static void sub_661E0(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
actor->zvel() = dz;

View file

@ -30,10 +30,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void cerberusThinkSearch(DBloodActor *actor);
static void cerberusThinkTarget(DBloodActor *actor);
static void cerberusThinkGoto(DBloodActor *actor);
static void cerberusThinkChase(DBloodActor *actor);
static void cerberusThinkSearch(DBloodActor* actor);
static void cerberusThinkTarget(DBloodActor* actor);
static void cerberusThinkGoto(DBloodActor* actor);
static void cerberusThinkChase(DBloodActor* actor);
AISTATE cerberusIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, cerberusThinkTarget, NULL };
@ -59,7 +59,7 @@ AISTATE cerberus1398AC = { kAiStateOther, 7, -1, 120, NULL, aiMoveTurn, NULL, &c
void cerberusBiteSeqCallback(int, DBloodActor* actor)
{
XSPRITE* pXSprite = &actor->x();
spritetype *pSprite = &actor->s();
spritetype* pSprite = &actor->s();
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
@ -68,8 +68,8 @@ void cerberusBiteSeqCallback(int, DBloodActor* actor)
return;
}
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
int dz = pTarget->z-pSprite->z;
spritetype* pTarget = &actor->GetTarget()->s();
int dz = pTarget->z - pSprite->z;
actFireVector(actor, 350, -100, dx, dy, dz, kVectorCerberusHack);
actFireVector(actor, -350, 0, dx, dy, dz, kVectorCerberusHack);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorCerberusHack);
@ -79,8 +79,8 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
{
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = pDudeInfo->eyeHeight*pSprite->yrepeat;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int height = pDudeInfo->eyeHeight * pSprite->yrepeat;
if (!actor->ValidateTarget(__FUNCTION__)) return;
int x = pSprite->x;
@ -95,13 +95,13 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
BloodStatIterator it(kStatDude);
while (auto actor2 = it.Next())
{
spritetype *pSprite2 = &actor2->s();
if (pSprite == pSprite2 || !(pSprite2->flags&8))
spritetype* pSprite2 = &actor2->s();
if (pSprite == pSprite2 || !(pSprite2->flags & 8))
continue;
int x2 = pSprite2->x;
int y2 = pSprite2->y;
int z2 = pSprite2->z;
int nDist = approxDist(x2-x, y2-y);
int nDist = approxDist(x2 - x, y2 - y);
if (nDist == 0 || nDist > 0x2800)
continue;
if (tt1.at10)
@ -111,25 +111,25 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
y2 += (actor2->yvel() * t) >> 12;
z2 += (actor2->zvel() * t) >> 8;
}
int tx = x+MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y+MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z+MulScale(actor->dudeSlope, nDist, 10);
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10);
int top, bottom;
GetSpriteExtents(pSprite2, &top, &bottom);
if (tz-tsr > bottom || tz+tsr < top)
if (tz - tsr > bottom || tz + tsr < top)
continue;
int dx = (tx-x2)>>4;
int dy = (ty-y2)>>4;
int dz = (tz-z2)>>8;
int nDist2 = ksqrt(dx*dx+dy*dy+dz*dz);
int dx = (tx - x2) >> 4;
int dy = (ty - y2) >> 4;
int dz = (tz - z2) >> 8;
int nDist2 = ksqrt(dx * dx + dy * dy + dz * dz);
if (nDist2 < nClosest)
{
int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt1.at8)
{
int tz = pSprite2->z-pSprite->z;
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
@ -158,8 +158,8 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = pDudeInfo->eyeHeight*pSprite->yrepeat;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int height = pDudeInfo->eyeHeight * pSprite->yrepeat;
int x = pSprite->x;
int y = pSprite->y;
@ -175,13 +175,13 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
BloodStatIterator it(kStatDude);
while (auto actor2 = it.Next())
{
spritetype *pSprite2 = &actor2->s();
if (pSprite == pSprite2 || !(pSprite2->flags&8))
spritetype* pSprite2 = &actor2->s();
if (pSprite == pSprite2 || !(pSprite2->flags & 8))
continue;
int x2 = pSprite2->x;
int y2 = pSprite2->y;
int z2 = pSprite2->z;
int nDist = approxDist(x2-x, y2-y);
int nDist = approxDist(x2 - x, y2 - y);
if (nDist == 0 || nDist > 0x2800)
continue;
if (tt1.at10)
@ -191,27 +191,27 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
y2 += (actor->yvel() * t) >> 12;
z2 += (actor->zvel() * t) >> 8;
}
int tx = x+MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y+MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z+MulScale(actor->dudeSlope, nDist, 10);
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10);
int top, bottom;
GetActorExtents(actor2, &top, &bottom);
if (tz-tsr > bottom || tz+tsr < top)
if (tz - tsr > bottom || tz + tsr < top)
continue;
int dx = (tx-x2)>>4;
int dy = (ty-y2)>>4;
int dz = (tz-z2)>>8;
int nDist2 = ksqrt(dx*dx+dy*dy+dz*dz);
int dx = (tx - x2) >> 4;
int dy = (ty - y2) >> 4;
int dz = (tz - z2) >> 8;
int nDist2 = ksqrt(dx * dx + dy * dy + dz * dz);
if (nDist2 < nClosest)
{
int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt1.at8)
{
DUDEINFO *pDudeInfo2 = getDudeInfo(pSprite2->type);
int height = (pDudeInfo2->aimHeight*pSprite2->yrepeat)<<2;
int tz = (z2-height)-z;
DUDEINFO* pDudeInfo2 = getDudeInfo(pSprite2->type);
int height = (pDudeInfo2->aimHeight * pSprite2->yrepeat) << 2;
int tz = (z2 - height) - z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
@ -239,7 +239,7 @@ static void cerberusThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -252,8 +252,8 @@ static void cerberusThinkTarget(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++;
else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active)
@ -271,21 +271,21 @@ static void cerberusThinkTarget(DBloodActor* actor)
{
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
PLAYER *pPlayer = &gPlayer[p];
PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue;
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x;
int dy = y-pSprite->y;
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
@ -314,12 +314,12 @@ static void cerberusThinkGoto(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{
switch (pSprite->type) {
@ -356,14 +356,14 @@ static void cerberusThinkChase(DBloodActor* actor)
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) {
switch (pSprite->type) {
@ -377,7 +377,7 @@ static void cerberusThinkChase(DBloodActor* actor)
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0) {
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0) {
switch (pSprite->type) {
case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusSearch);
@ -392,8 +392,8 @@ static void cerberusThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {

View file

@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void cultThinkSearch(DBloodActor *);
static void cultThinkGoto(DBloodActor *);
static void cultThinkChase(DBloodActor *);
static void cultThinkSearch(DBloodActor*);
static void cultThinkGoto(DBloodActor*);
static void cultThinkChase(DBloodActor*);
AISTATE cultistIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE cultistProneIdle = { kAiStateIdle, 17, -1, 0, NULL, NULL, aiThinkTarget, NULL };
@ -80,9 +80,9 @@ void TommySeqCallback(int, DBloodActor* actor)
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = actor->dudeSlope;
dx += Random3((5-gGameOptions.nDifficulty)*1000);
dy += Random3((5-gGameOptions.nDifficulty)*1000);
dz += Random3((5-gGameOptions.nDifficulty)*500);
dx += Random3((5 - gGameOptions.nDifficulty) * 1000);
dy += Random3((5 - gGameOptions.nDifficulty) * 1000);
dz += Random3((5 - gGameOptions.nDifficulty) * 500);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorBullet);
sfxPlay3DSound(actor, 4001, -1, 0);
}
@ -96,9 +96,9 @@ void TeslaSeqCallback(int, DBloodActor* actor)
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = actor->dudeSlope;
dx += Random3((5-gGameOptions.nDifficulty)*1000);
dy += Random3((5-gGameOptions.nDifficulty)*1000);
dz += Random3((5-gGameOptions.nDifficulty)*500);
dx += Random3((5 - gGameOptions.nDifficulty) * 1000);
dy += Random3((5 - gGameOptions.nDifficulty) * 1000);
dz += Random3((5 - gGameOptions.nDifficulty) * 500);
actFireMissile(pSprite, 0, 0, dx, dy, dz, kMissileTeslaRegular);
sfxPlay3DSound(actor, 470, -1, 0);
}
@ -111,15 +111,15 @@ void ShotSeqCallback(int, DBloodActor* actor)
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = actor->dudeSlope;
dx += Random2((5-gGameOptions.nDifficulty)*1000-500);
dy += Random2((5-gGameOptions.nDifficulty)*1000-500);
dz += Random2((5-gGameOptions.nDifficulty)*500);
dx += Random2((5 - gGameOptions.nDifficulty) * 1000 - 500);
dy += Random2((5 - gGameOptions.nDifficulty) * 1000 - 500);
dz += Random2((5 - gGameOptions.nDifficulty) * 500);
for (int i = 0; i < 8; i++)
{
int r1 = Random3(500);
int r2 = Random3(1000);
int r3 = Random3(1000);
actFireVector(actor, 0, 0, dx+r3, dy+r2, dz+r1, kVectorShell);
actFireVector(actor, 0, 0, dx + r3, dy + r2, dz + r1, kVectorShell);
}
if (Chance(0x8000))
sfxPlay3DSound(actor, 1001, -1, 0);
@ -137,7 +137,7 @@ void cultThrowSeqCallback(int, DBloodActor* actor)
char v4 = Chance(0x6000);
sfxPlay3DSound(actor, 455, -1, 0);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
@ -146,7 +146,7 @@ void cultThrowSeqCallback(int, DBloodActor* actor)
int nDist2 = nDist / 540;
if (nDist > 0x1e00)
v4 = 0;
auto* pMissile = actFireThing(actor, 0, 0, dz/128-14500, nMissile, (nDist2<<23)/120);
auto* pMissile = actFireThing(actor, 0, 0, dz / 128 - 14500, nMissile, (nDist2 << 23) / 120);
if (v4)
pMissile->x().Impact = 1;
else
@ -174,18 +174,18 @@ void sub_68230(int, DBloodActor* actor)
nMissile = kThingArmedTNTBundle;
sfxPlay3DSound(actor, 455, -1, 0);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
int dz = pTarget->z - pSprite->z;
int nDist = approxDist(dx, dy);
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);
pMissile->x().Impact = 1;
}
static char TargetNearExplosion(spritetype *pSprite)
static char TargetNearExplosion(spritetype* pSprite)
{
BloodSectIterator it(pSprite->sectnum);
while (auto actor = it.Next())
@ -199,7 +199,7 @@ static char TargetNearExplosion(spritetype *pSprite)
static void cultThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiLookForTarget(actor);
}
@ -208,12 +208,12 @@ static void cultThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 5120 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{
switch (pXSprite->medium)
@ -249,12 +249,12 @@ static void cultThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
switch (pXSprite->medium)
@ -262,9 +262,9 @@ static void cultThinkChase(DBloodActor* actor)
case kMediumNormal:
aiNewState(actor, &cultistSearch);
if (pSprite->type == kDudeCultistTommy)
aiPlay3DSound(actor, 4021+Random(4), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 4021 + Random(4), AI_SFX_PRIORITY_1, -1);
else
aiPlay3DSound(actor, 1021+Random(4), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 1021 + Random(4), AI_SFX_PRIORITY_1, -1);
break;
case kMediumWater:
case kMediumGoo:
@ -273,7 +273,7 @@ static void cultThinkChase(DBloodActor* actor)
}
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
switch (pXSprite->medium)
{
@ -290,18 +290,18 @@ static void cultThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
actor->dudeSlope = DivScale(pTarget->z - pSprite->z, nDist, 10);
switch (pSprite->type) {
case kDudeCultistTommy:
if (nDist < 0x1e00 && nDist > 0xe00 && abs(nDeltaAngle) < 85 && !TargetNearExplosion(pTarget)
&& (pTarget->flags&2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type-kDudePlayer1].isRunning
&& (pTarget->flags & 2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type - kDudePlayer1].isRunning
&& Chance(0x8000))
{
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
@ -369,7 +369,7 @@ static void cultThinkChase(DBloodActor* actor)
break;
case kDudeCultistShotgun:
if (nDist < 0x2c00 && nDist > 0x1400 && !TargetNearExplosion(pTarget)
&& (pTarget->flags&2) && gGameOptions.nDifficulty >= 2 && IsPlayerSprite(pTarget) && !gPlayer[pTarget->type-kDudePlayer1].isRunning
&& (pTarget->flags & 2) && gGameOptions.nDifficulty >= 2 && IsPlayerSprite(pTarget) && !gPlayer[pTarget->type - kDudePlayer1].isRunning
&& Chance(0x8000))
{
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
@ -437,7 +437,7 @@ static void cultThinkChase(DBloodActor* actor)
break;
case kDudeCultistTesla:
if (nDist < 0x1e00 && nDist > 0xe00 && !TargetNearExplosion(pTarget)
&& (pTarget->flags&2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type-kDudePlayer1].isRunning
&& (pTarget->flags & 2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type - kDudePlayer1].isRunning
&& Chance(0x8000))
{
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
@ -505,7 +505,7 @@ static void cultThinkChase(DBloodActor* actor)
break;
case kDudeCultistTNT:
if (nDist < 0x2c00 && nDist > 0x1400 && abs(nDeltaAngle) < 85
&& (pTarget->flags&2) && IsPlayerSprite(pTarget))
&& (pTarget->flags & 2) && IsPlayerSprite(pTarget))
{
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit)
@ -526,7 +526,7 @@ static void cultThinkChase(DBloodActor* actor)
}
}
else if (nDist < 0x1400 && abs(nDeltaAngle) < 85
&& (pTarget->flags&2) && IsPlayerSprite(pTarget))
&& (pTarget->flags & 2) && IsPlayerSprite(pTarget))
{
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit)
@ -549,7 +549,7 @@ static void cultThinkChase(DBloodActor* actor)
break;
case kDudeCultistBeast:
if (nDist < 0x1e00 && nDist > 0xe00 && !TargetNearExplosion(pTarget)
&& (pTarget->flags&2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type-kDudePlayer1].isRunning
&& (pTarget->flags & 2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type - kDudePlayer1].isRunning
&& Chance(0x8000))
{
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);

View file

@ -30,18 +30,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void gargThinkTarget(DBloodActor *);
static void gargThinkSearch(DBloodActor *);
static void gargThinkGoto(DBloodActor *);
static void gargMoveDodgeUp(DBloodActor *);
static void gargMoveDodgeDown(DBloodActor *);
static void gargThinkChase(DBloodActor *);
static void entryFStatue(DBloodActor *);
static void entrySStatue(DBloodActor *);
static void gargMoveForward(DBloodActor *);
static void gargMoveSlow(DBloodActor *);
static void gargMoveSwoop(DBloodActor *);
static void gargMoveFly(DBloodActor *);
static void gargThinkTarget(DBloodActor*);
static void gargThinkSearch(DBloodActor*);
static void gargThinkGoto(DBloodActor*);
static void gargMoveDodgeUp(DBloodActor*);
static void gargMoveDodgeDown(DBloodActor*);
static void gargThinkChase(DBloodActor*);
static void entryFStatue(DBloodActor*);
static void entrySStatue(DBloodActor*);
static void gargMoveForward(DBloodActor*);
static void gargMoveSlow(DBloodActor*);
static void gargMoveSwoop(DBloodActor*);
static void gargMoveFly(DBloodActor*);
static void playStatueBreakSnd(DBloodActor*);
AISTATE gargoyleFIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, gargThinkTarget, NULL };
@ -68,8 +68,8 @@ AISTATE gargoyleDodgeDown = { kAiStateMove, 0, -1, 120, NULL, gargMoveDodgeDown,
AISTATE gargoyleFDodgeDownRight = { kAiStateMove, 0, -1, 90, NULL, gargMoveDodgeDown, NULL, &gargoyleFChase };
AISTATE gargoyleFDodgeDownLeft = { kAiStateMove, 0, -1, 90, NULL, gargMoveDodgeDown, NULL, &gargoyleFChase };
AISTATE statueFBreakSEQ = { kAiStateOther, 5, -1, 0, entryFStatue, NULL, playStatueBreakSnd, &gargoyleFMorph2};
AISTATE statueSBreakSEQ = { kAiStateOther, 5, -1, 0, entrySStatue, NULL, playStatueBreakSnd, &gargoyleSMorph2};
AISTATE statueFBreakSEQ = { kAiStateOther, 5, -1, 0, entryFStatue, NULL, playStatueBreakSnd, &gargoyleFMorph2 };
AISTATE statueSBreakSEQ = { kAiStateOther, 5, -1, 0, entrySStatue, NULL, playStatueBreakSnd, &gargoyleSMorph2 };
static void playStatueBreakSnd(DBloodActor* actor) {
auto pXSprite = &actor->x();
@ -82,28 +82,28 @@ void SlashFSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
int dz = height-height2;
spritetype* pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (pTarget->yrepeat * pDudeInfoT->eyeHeight) << 2;
int dz = height - height2;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGargSlash);
int r1 = Random(50);
int r2 = Random(50);
actFireVector(actor, 0, 0, dx+r2, dy-r1, dz, kVectorGargSlash);
actFireVector(actor, 0, 0, dx + r2, dy - r1, dz, kVectorGargSlash);
r1 = Random(50);
r2 = Random(50);
actFireVector(actor, 0, 0, dx-r2, dy+r1, dz, kVectorGargSlash);
actFireVector(actor, 0, 0, dx - r2, dy + r1, dz, kVectorGargSlash);
}
void ThrowFSeqCallback(int, DBloodActor* actor)
{
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
actFireThing(actor, 0, 0, actor->dudeSlope-7500, kThingBone, 0xeeeee);
actFireThing(actor, 0, 0, actor->dudeSlope - 7500, kThingBone, 0xeeeee);
}
void BlastSSeqCallback(int, DBloodActor* actor)
@ -112,10 +112,10 @@ void BlastSSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s();
wrand(); // ???
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
int height = (pSprite->yrepeat*getDudeInfo(pSprite->type)->eyeHeight) << 2;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
spritetype* pTarget = &actor->GetTarget()->s();
int height = (pSprite->yrepeat * getDudeInfo(pSprite->type)->eyeHeight) << 2;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int x = pSprite->x;
int y = pSprite->y;
int z = height;
@ -129,12 +129,12 @@ void BlastSSeqCallback(int, DBloodActor* actor)
while (auto actor2 = it.Next())
{
spritetype* pSprite2 = &actor2->s();
if (pSprite == pSprite2 || !(pSprite2->flags&8))
if (pSprite == pSprite2 || !(pSprite2->flags & 8))
continue;
int x2 = pSprite2->x;
int y2 = pSprite2->y;
int z2 = pSprite2->z;
int nDist = approxDist(x2-x, y2-y);
int nDist = approxDist(x2 - x, y2 - y);
if (nDist == 0 || nDist > 0x2800)
continue;
if (tt.at10)
@ -144,25 +144,25 @@ void BlastSSeqCallback(int, DBloodActor* actor)
y2 += (actor->yvel() * t) >> 12;
z2 += (actor->zvel() * t) >> 8;
}
int tx = x+MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y+MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z+MulScale(actor->dudeSlope, nDist, 10);
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10);
int top, bottom;
GetActorExtents(actor2, &top, &bottom);
if (tz-tsr > bottom || tz+tsr < top)
if (tz - tsr > bottom || tz + tsr < top)
continue;
int dx = (tx-x2)>>4;
int dy = (ty-y2)>>4;
int dz = (tz-z2)>>8;
int nDist2 = ksqrt(dx*dx+dy*dy+dz*dz);
int dx = (tx - x2) >> 4;
int dy = (ty - y2) >> 4;
int dz = (tz - z2) >> 8;
int nDist2 = ksqrt(dx * dx + dy * dy + dz * dz);
if (nDist2 < nClosest)
{
int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt.at8)
{
int tz = pSprite2->z-pSprite->z;
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
@ -172,11 +172,11 @@ void BlastSSeqCallback(int, DBloodActor* actor)
if (tz > -0x333)
aim.dz = DivScale(tz, nDist, 10);
else if (tz < -0x333 && tz > -0xb33)
aim.dz = DivScale(tz, nDist, 10)+9460;
aim.dz = DivScale(tz, nDist, 10) + 9460;
else if (tz < -0xb33 && tz > -0x3000)
aim.dz = DivScale(tz, nDist, 10)+9460;
aim.dz = DivScale(tz, nDist, 10) + 9460;
else if (tz < -0x3000)
aim.dz = DivScale(tz, nDist, 10)-7500;
aim.dz = DivScale(tz, nDist, 10) - 7500;
else
aim.dz = DivScale(tz, nDist, 10);
}
@ -185,18 +185,18 @@ void BlastSSeqCallback(int, DBloodActor* actor)
}
}
}
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
// allow to fire missile in non-player targets
if (IsPlayerSprite(pTarget) || gModernMap) {
actFireMissile(pSprite, -120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
actFireMissile(pSprite, 120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
}
#else
#else
if (IsPlayerSprite(pTarget)) {
actFireMissile(pSprite, -120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
actFireMissile(pSprite, 120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
}
#endif
#endif
}
@ -214,8 +214,8 @@ static void gargThinkTarget(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++;
else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active)
@ -230,21 +230,21 @@ static void gargThinkTarget(DBloodActor* actor)
{
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
PLAYER *pPlayer = &gPlayer[p];
PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue;
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x;
int dy = y-pSprite->y;
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
@ -267,7 +267,7 @@ static void gargThinkTarget(DBloodActor* actor)
static void gargThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiLookForTarget(actor);
}
@ -280,12 +280,12 @@ static void gargThinkGoto(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gargoyleFSearch);
aiThinkTarget(actor);
@ -300,10 +300,10 @@ static void gargMoveDodgeUp(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nCos = Cos(pSprite->ang);
int nSin = Sin(pSprite->ang);
int dx = actor->xvel();
@ -329,10 +329,10 @@ static void gargMoveDodgeDown(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (pXSprite->dodgeDir == 0)
return;
int nCos = Cos(pSprite->ang);
@ -365,18 +365,18 @@ static void gargThinkChase(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &gargoyleFSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &gargoyleFSearch);
return;
@ -384,10 +384,10 @@ static void gargThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
// Should be dudeInfo[pTarget->type-kDudeBase]
int height2 = (pDudeInfo->eyeHeight*pTarget->yrepeat)<<2;
int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
@ -449,12 +449,12 @@ static void gargThinkChase(DBloodActor* actor)
break;
}
}
else if ((height2-height > 0x2000 || floorZ-bottom > 0x2000) && nDist < 0x1400 && nDist > 0xa00)
else if ((height2 - height > 0x2000 || floorZ - bottom > 0x2000) && nDist < 0x1400 && nDist > 0xa00)
{
aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &gargoyleSwoop);
}
else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && abs(nDeltaAngle) < 85)
else if ((height2 - height < 0x2000 || floorZ - bottom < 0x2000) && abs(nDeltaAngle) < 85)
aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1);
break;
case kDudeGargoyleStone:
@ -503,7 +503,7 @@ static void gargThinkChase(DBloodActor* actor)
break;
}
}
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)
aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1);
@ -511,7 +511,7 @@ static void gargThinkChase(DBloodActor* actor)
aiPlay3DSound(actor, 1450, AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &gargoyleSwoop);
}
else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && abs(nDeltaAngle) < 85)
else if ((height2 - height < 0x2000 || floorZ - bottom < 0x2000) && abs(nDeltaAngle) < 85)
aiPlay3DSound(actor, 1450, AI_SFX_PRIORITY_1, -1);
break;
}
@ -532,7 +532,7 @@ static void gargThinkChase(DBloodActor* actor)
static void entryFStatue(DBloodActor* actor)
{
auto pSprite = &actor->s();
DUDEINFO *pDudeInfo = &dudeInfo[6];
DUDEINFO* pDudeInfo = &dudeInfo[6];
actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth);
pSprite->type = kDudeGargoyleFlesh;
}
@ -540,7 +540,7 @@ static void entryFStatue(DBloodActor* actor)
static void entrySStatue(DBloodActor* actor)
{
auto pSprite = &actor->s();
DUDEINFO *pDudeInfo = &dudeInfo[7];
DUDEINFO* pDudeInfo = &dudeInfo[7];
actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth);
pSprite->type = kDudeGargoyleStone;
}
@ -554,17 +554,17 @@ static void gargMoveForward(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
return;
if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
pSprite->ang = (pSprite->ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return;
@ -577,7 +577,7 @@ static void gargMoveForward(DBloodActor* actor)
if (actor->GetTarget() == nullptr)
t1 += nAccel;
else
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
}
@ -591,18 +591,18 @@ static void gargMoveSlow(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pXSprite->goalAng = (pSprite->ang+512)&2047;
pXSprite->goalAng = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
@ -612,7 +612,7 @@ static void gargMoveSlow(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 = nAccel>>1;
t1 = nAccel >> 1;
t2 >>= 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
@ -635,18 +635,18 @@ static void gargMoveSwoop(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pXSprite->goalAng = (pSprite->ang+512)&2047;
pXSprite->goalAng = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
@ -656,7 +656,7 @@ static void gargMoveSwoop(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) {
@ -678,18 +678,18 @@ static void gargMoveFly(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pSprite->ang = (pSprite->ang+512)&2047;
pSprite->ang = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;
@ -699,7 +699,7 @@ static void gargMoveFly(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) {

View file

@ -30,16 +30,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void ghostThinkTarget(DBloodActor *);
static void ghostThinkSearch(DBloodActor *);
static void ghostThinkGoto(DBloodActor *);
static void ghostMoveDodgeUp(DBloodActor *);
static void ghostMoveDodgeDown(DBloodActor *);
static void ghostThinkChase(DBloodActor *);
static void ghostMoveForward(DBloodActor *);
static void ghostMoveSlow(DBloodActor *);
static void ghostMoveSwoop(DBloodActor *);
static void ghostMoveFly(DBloodActor *);
static void ghostThinkTarget(DBloodActor*);
static void ghostThinkSearch(DBloodActor*);
static void ghostThinkGoto(DBloodActor*);
static void ghostMoveDodgeUp(DBloodActor*);
static void ghostMoveDodgeDown(DBloodActor*);
static void ghostThinkChase(DBloodActor*);
static void ghostMoveForward(DBloodActor*);
static void ghostMoveSlow(DBloodActor*);
static void ghostMoveSwoop(DBloodActor*);
static void ghostMoveFly(DBloodActor*);
AISTATE ghostIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, ghostThinkTarget, NULL };
@ -66,22 +66,22 @@ void ghostSlashSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
int dz = height-height2;
spritetype* pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (pTarget->yrepeat * pDudeInfoT->eyeHeight) << 2;
int dz = height - height2;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
sfxPlay3DSound(actor, 1406, 0, 0);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGhost);
int r1 = Random(50);
int r2 = Random(50);
actFireVector(actor, 0, 0, dx+r2, dy-r1, dz, kVectorGhost);
actFireVector(actor, 0, 0, dx + r2, dy - r1, dz, kVectorGhost);
r1 = Random(50);
r2 = Random(50);
actFireVector(actor, 0, 0, dx-r2, dy+r1, dz, kVectorGhost);
actFireVector(actor, 0, 0, dx - r2, dy + r1, dz, kVectorGhost);
}
void ghostThrowSeqCallback(int, DBloodActor* actor)
@ -95,10 +95,10 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s();
wrand(); // ???
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
int height = (pSprite->yrepeat*getDudeInfo(pSprite->type)->eyeHeight) << 2;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
spritetype* pTarget = &actor->GetTarget()->s();
int height = (pSprite->yrepeat * getDudeInfo(pSprite->type)->eyeHeight) << 2;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int x = pSprite->x;
int y = pSprite->y;
int z = height;
@ -112,12 +112,12 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
while (auto actor2 = it.Next())
{
spritetype* pSprite2 = &actor2->s();
if (pSprite == pSprite2 || !(pSprite2->flags&8))
if (pSprite == pSprite2 || !(pSprite2->flags & 8))
continue;
int x2 = pSprite2->x;
int y2 = pSprite2->y;
int z2 = pSprite2->z;
int nDist = approxDist(x2-x, y2-y);
int nDist = approxDist(x2 - x, y2 - y);
if (nDist == 0 || nDist > 0x2800)
continue;
if (tt.at10)
@ -127,25 +127,25 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
y2 += (actor->yvel() * t) >> 12;
z2 += (actor->zvel() * t) >> 8;
}
int tx = x+MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y+MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z+MulScale(actor->dudeSlope, nDist, 10);
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10);
int top, bottom;
GetSpriteExtents(pSprite2, &top, &bottom);
if (tz-tsr > bottom || tz+tsr < top)
if (tz - tsr > bottom || tz + tsr < top)
continue;
int dx = (tx-x2)>>4;
int dy = (ty-y2)>>4;
int dz = (tz-z2)>>8;
int nDist2 = ksqrt(dx*dx+dy*dy+dz*dz);
int dx = (tx - x2) >> 4;
int dy = (ty - y2) >> 4;
int dz = (tz - z2) >> 8;
int nDist2 = ksqrt(dx * dx + dy * dy + dz * dz);
if (nDist2 < nClosest)
{
int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt.at8)
{
int tz = pSprite2->z-pSprite->z;
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
@ -155,11 +155,11 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
if (tz > -0x333)
aim.dz = DivScale(tz, nDist, 10);
else if (tz < -0x333 && tz > -0xb33)
aim.dz = DivScale(tz, nDist, 10)+9460;
aim.dz = DivScale(tz, nDist, 10) + 9460;
else if (tz < -0xb33 && tz > -0x3000)
aim.dz = DivScale(tz, nDist, 10)+9460;
aim.dz = DivScale(tz, nDist, 10) + 9460;
else if (tz < -0x3000)
aim.dz = DivScale(tz, nDist, 10)-7500;
aim.dz = DivScale(tz, nDist, 10) - 7500;
else
aim.dz = DivScale(tz, nDist, 10);
}
@ -168,18 +168,18 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
}
}
}
#ifdef NOONE_EXTENSIONS
#ifdef NOONE_EXTENSIONS
// allow fire missile in non-player targets if not a demo
if (IsPlayerSprite(pTarget) || gModernMap) {
sfxPlay3DSound(actor, 489, 0, 0);
actFireMissile(pSprite, 0, 0, aim.dx, aim.dy, aim.dz, kMissileEctoSkull);
}
#else
#else
if (IsPlayerSprite(pTarget)) {
sfxPlay3DSound(actor, 489, 0, 0);
actFireMissile(pSprite, 0, 0, aim.dx, aim.dy, aim.dz, kMissileEctoSkull);
}
#endif
#endif
}
static void ghostThinkTarget(DBloodActor* actor)
@ -191,8 +191,8 @@ static void ghostThinkTarget(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++;
else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active)
@ -207,21 +207,21 @@ static void ghostThinkTarget(DBloodActor* actor)
{
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
PLAYER *pPlayer = &gPlayer[p];
PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue;
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x;
int dy = y-pSprite->y;
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
@ -244,7 +244,7 @@ static void ghostThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -257,12 +257,12 @@ static void ghostThinkGoto(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ghostSearch);
aiThinkTarget(actor);
@ -278,10 +278,10 @@ static void ghostMoveDodgeUp(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nCos = Cos(pSprite->ang);
int nSin = Sin(pSprite->ang);
int dx = actor->xvel();
@ -308,10 +308,10 @@ static void ghostMoveDodgeDown(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
if (pXSprite->dodgeDir == 0)
return;
int nCos = Cos(pSprite->ang);
@ -344,18 +344,18 @@ static void ghostThinkChase(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &ghostSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &ghostSearch);
return;
@ -363,10 +363,10 @@ static void ghostThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
// Should be dudeInfo[pTarget->type-kDudeBase]
int height2 = (pDudeInfo->eyeHeight*pTarget->yrepeat)<<2;
int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
@ -416,12 +416,12 @@ static void ghostThinkChase(DBloodActor* actor)
break;
}
}
else if ((height2-height > 0x2000 || floorZ-bottom > 0x2000) && nDist < 0x1400 && nDist > 0x800)
else if ((height2 - height > 0x2000 || floorZ - bottom > 0x2000) && nDist < 0x1400 && nDist > 0x800)
{
aiPlay3DSound(actor, 1600, AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &ghostSwoop);
}
else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && abs(nDeltaAngle) < 85)
else if ((height2 - height < 0x2000 || floorZ - bottom < 0x2000) && abs(nDeltaAngle) < 85)
aiPlay3DSound(actor, 1600, AI_SFX_PRIORITY_1, -1);
break;
}
@ -448,17 +448,17 @@ static void ghostMoveForward(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
return;
if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
pSprite->ang = (pSprite->ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return;
@ -471,7 +471,7 @@ static void ghostMoveForward(DBloodActor* actor)
if (actor->GetTarget() == nullptr)
t1 += nAccel;
else
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
}
@ -485,18 +485,18 @@ static void ghostMoveSlow(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pXSprite->goalAng = (pSprite->ang+512)&2047;
pXSprite->goalAng = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
@ -506,7 +506,7 @@ static void ghostMoveSlow(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 = nAccel>>1;
t1 = nAccel >> 1;
t2 >>= 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
@ -526,18 +526,18 @@ static void ghostMoveSwoop(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pXSprite->goalAng = (pSprite->ang+512)&2047;
pXSprite->goalAng = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
@ -547,7 +547,7 @@ static void ghostMoveSwoop(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) {
@ -566,18 +566,18 @@ static void ghostMoveFly(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341)
{
pSprite->ang = (pSprite->ang+512)&2047;
pSprite->ang = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;
@ -587,7 +587,7 @@ static void ghostMoveFly(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
switch (pSprite->type) {

View file

@ -30,14 +30,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void gillThinkSearch(DBloodActor *);
static void gillThinkGoto(DBloodActor *);
static void gillThinkChase(DBloodActor *);
static void gillThinkSwimGoto(DBloodActor *);
static void gillThinkSwimChase(DBloodActor *);
static void sub_6CB00(DBloodActor *);
static void sub_6CD74(DBloodActor *);
static void sub_6D03C(DBloodActor *);
static void gillThinkSearch(DBloodActor*);
static void gillThinkGoto(DBloodActor*);
static void gillThinkChase(DBloodActor*);
static void gillThinkSwimGoto(DBloodActor*);
static void gillThinkSwimChase(DBloodActor*);
static void sub_6CB00(DBloodActor*);
static void sub_6CD74(DBloodActor*);
static void sub_6D03C(DBloodActor*);
AISTATE gillBeastIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
@ -63,10 +63,10 @@ void GillBiteSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = pSprite->z-pTarget->z;
int dz = pSprite->z - pTarget->z;
dx += Random3(2000);
dy += Random3(2000);
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGillBite);
@ -78,7 +78,7 @@ static void gillThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -87,18 +87,18 @@ static void gillThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
XSECTOR *pXSector;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
else
pXSector = NULL;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{
if (pXSector && pXSector->Underwater)
@ -115,7 +115,7 @@ static void gillThinkChase(DBloodActor* actor)
auto pSprite = &actor->s();
if (actor->GetTarget() == nullptr)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -128,16 +128,16 @@ static void gillThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -149,9 +149,9 @@ static void gillThinkChase(DBloodActor* actor)
aiNewState(actor, &gillBeastSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -166,17 +166,17 @@ static void gillThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
actor->dudeSlope = DivScale(pTarget->z - pSprite->z, nDist, 10);
if (nDist < 921 && abs(nDeltaAngle) < 28)
{
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -220,7 +220,7 @@ static void gillThinkChase(DBloodActor* actor)
}
}
XSECTOR *pXSector;
XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0)
pXSector = &xsector[nXSector];
@ -239,12 +239,12 @@ static void gillThinkSwimGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gillBeastSwimSearch);
aiThinkTarget(actor);
@ -260,19 +260,19 @@ static void gillThinkSwimChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &gillBeastSwimSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &gillBeastSwimSearch);
return;
@ -280,8 +280,8 @@ static void gillThinkSwimChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = pDudeInfo->eyeHeight+pSprite->z;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = pDudeInfo->eyeHeight + pSprite->z;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
@ -312,17 +312,17 @@ static void sub_6CB00(DBloodActor* actor)
auto pSprite = &actor->s();
int nSprite = pSprite->index;
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
if (abs(nAng) > 341)
return;
if (actor->GetTarget() == nullptr)
pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
pSprite->ang = (pSprite->ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400)
return;
@ -335,7 +335,7 @@ static void sub_6CB00(DBloodActor* actor)
if (actor->GetTarget() == nullptr)
t1 += nAccel;
else
t1 += nAccel>>2;
t1 += nAccel >> 2;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
}
@ -345,22 +345,22 @@ static void sub_6CD74(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
if (abs(nAng) > 341)
{
pXSprite->goalAng = (pSprite->ang+512)&2047;
pXSprite->goalAng = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
@ -382,23 +382,23 @@ static void sub_6D03C(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
if (abs(nAng) > 341)
{
pSprite->ang = (pSprite->ang+512)&2047;
pSprite->ang = (pSprite->ang + 512) & 2047;
return;
}
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
int dz = (z2 - z)<<3;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;
@ -408,7 +408,7 @@ static void sub_6D03C(DBloodActor* actor)
int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
t1 += nAccel>>1;
t1 += nAccel >> 1;
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
actor->zvel() = dz;

View file

@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void handThinkSearch(DBloodActor *);
static void handThinkGoto(DBloodActor *);
static void handThinkChase(DBloodActor *);
static void handThinkSearch(DBloodActor*);
static void handThinkGoto(DBloodActor*);
static void handThinkChase(DBloodActor*);
AISTATE handIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE hand13A3B4 = { kAiStateOther, 0, -1, 0, NULL, NULL, NULL, NULL };
@ -47,10 +47,10 @@ void HandJumpSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
if (IsPlayerSprite(pTarget))
{
PLAYER *pPlayer = &gPlayer[pTarget->type-kDudePlayer1];
PLAYER* pPlayer = &gPlayer[pTarget->type - kDudePlayer1];
if (!pPlayer->hand)
{
pPlayer->hand = 1;
@ -63,7 +63,7 @@ static void handThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -72,12 +72,12 @@ static void handThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &handSearch);
aiThinkTarget(actor);
@ -93,19 +93,19 @@ static void handThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &handSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &handSearch);
return;
@ -113,8 +113,8 @@ static void handThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)

View file

@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void houndThinkSearch(DBloodActor *);
static void houndThinkGoto(DBloodActor *);
static void houndThinkChase(DBloodActor *);
static void houndThinkSearch(DBloodActor*);
static void houndThinkGoto(DBloodActor*);
static void houndThinkChase(DBloodActor*);
AISTATE houndIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE houndSearch = { kAiStateMove, 8, -1, 1800, NULL, aiMoveForward, houndThinkSearch, &houndIdle };
@ -56,14 +56,14 @@ void houndBiteSeqCallback(int, DBloodActor* actor)
}
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
#ifdef NOONE_EXTENSIONS
spritetype* pTarget = &actor->GetTarget()->s();
#ifdef NOONE_EXTENSIONS
if (IsPlayerSprite(pTarget) || gModernMap) // allow to hit non-player targets
actFireVector(actor, 0, 0, dx, dy, pTarget->z - pSprite->z, kVectorHoundBite);
#else
#else
if (IsPlayerSprite(pTarget))
actFireVector(actor, 0, 0, dx, dy, pTarget->z - pSprite->z, kVectorHoundBite);
#endif
#endif
}
void houndBurnSeqCallback(int, DBloodActor* actor)
@ -76,7 +76,7 @@ static void houndThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -90,12 +90,12 @@ static void houndThinkGoto(DBloodActor* actor)
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &houndSearch);
aiThinkTarget(actor);
@ -115,18 +115,18 @@ static void houndThinkChase(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &houndSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &houndSearch);
return;
@ -134,8 +134,8 @@ static void houndThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -143,7 +143,7 @@ static void houndThinkChase(DBloodActor* actor)
aiSetTarget(actor, actor->GetTarget());
if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85)
aiNewState(actor, &houndBurn);
else if(nDist < 0x266 && abs(nDeltaAngle) < 85)
else if (nDist < 0x266 && abs(nDeltaAngle) < 85)
aiNewState(actor, &houndBite);
return;
}

View file

@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void innocThinkSearch(DBloodActor *);
static void innocThinkGoto(DBloodActor *);
static void innocThinkChase(DBloodActor *);
static void innocThinkSearch(DBloodActor*);
static void innocThinkGoto(DBloodActor*);
static void innocThinkChase(DBloodActor*);
AISTATE innocentIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE innocentSearch = { kAiStateSearch, 6, -1, 1800, NULL, aiMoveForward, innocThinkSearch, &innocentIdle };
@ -45,7 +45,7 @@ static void innocThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -54,12 +54,12 @@ static void innocThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &innocentSearch);
aiThinkTarget(actor);
@ -75,13 +75,13 @@ static void innocThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &innocentSearch);
@ -95,8 +95,8 @@ static void innocThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -109,7 +109,7 @@ static void innocThinkChase(DBloodActor* actor)
}
}
aiPlay3DSound(actor, 7000+Random(6), AI_SFX_PRIORITY_1, -1);
aiPlay3DSound(actor, 7000 + Random(6), AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &innocentGoto);
actor->SetTarget(nullptr);
}

View file

@ -67,12 +67,12 @@ void podAttack(int, DBloodActor* actor)
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int x = pTarget->x-pSprite->x;
int y = pTarget->y-pSprite->y;
int dz = pTarget->z-pSprite->z;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int x = pTarget->x - pSprite->x;
int y = pTarget->y - pSprite->y;
int dz = pTarget->z - pSprite->z;
x += Random2(1000);
y += Random2(1000);
int nDist = approxDist(x, y);
@ -82,23 +82,23 @@ void podAttack(int, DBloodActor* actor)
{
case kDudePodGreen:
dz += 8000;
if (pDudeInfo->seeDist*0.1 < nDist)
if (pDudeInfo->seeDist * 0.1 < nDist)
{
if (Chance(0x8000))
sfxPlay3DSound(actor, 2474, -1, 0);
else
sfxPlay3DSound(actor, 2475, -1, 0);
pMissile = actFireThing(actor, 0, -8000, dz/128-14500, kThingPodGreenBall, (nDist2<<23)/120);
pMissile = actFireThing(actor, 0, -8000, dz / 128 - 14500, kThingPodGreenBall, (nDist2 << 23) / 120);
}
if (pMissile)
seqSpawn(68, pMissile, -1);
break;
case kDudePodFire:
dz += 8000;
if (pDudeInfo->seeDist*0.1 < nDist)
if (pDudeInfo->seeDist * 0.1 < nDist)
{
sfxPlay3DSound(actor, 2454, -1, 0);
pMissile = actFireThing(actor, 0, -8000, dz/128-14500, kThingPodFireBall, (nDist2<<23)/120);
pMissile = actFireThing(actor, 0, -8000, dz / 128 - 14500, kThingPodFireBall, (nDist2 << 23) / 120);
}
if (pMissile)
seqSpawn(22, pMissile, -1);
@ -122,19 +122,19 @@ void sub_70284(int, DBloodActor* actor)
nDist = 50;
break;
case kDudeTentacleFire: // ???
nBurn = (gGameOptions.nDifficulty*120)>>2;
nBurn = (gGameOptions.nDifficulty * 120) >> 2;
dmgType = kDamageExplode;
nDist = 75;
break;
}
actRadiusDamage(actor, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, nDist, 1, 5*(1+gGameOptions.nDifficulty), dmgType, 2, nBurn);
actRadiusDamage(actor, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, nDist, 1, 5 * (1 + gGameOptions.nDifficulty), dmgType, 2, nBurn);
}
static void aiPodSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -148,12 +148,12 @@ static void aiPodMove(DBloodActor* actor)
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) {
switch (pSprite->type) {
case kDudePodGreen:
@ -191,12 +191,12 @@ static void aiPodChase(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) {
switch (pSprite->type) {
@ -214,8 +214,8 @@ static void aiPodChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)

View file

@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void ratThinkSearch(DBloodActor *);
static void ratThinkGoto(DBloodActor *);
static void ratThinkChase(DBloodActor *);
static void ratThinkSearch(DBloodActor*);
static void ratThinkGoto(DBloodActor*);
static void ratThinkChase(DBloodActor*);
AISTATE ratIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE ratSearch = { kAiStateSearch, 7, -1, 1800, NULL, aiMoveForward, ratThinkSearch, &ratIdle };
@ -50,16 +50,16 @@ void ratBiteSeqCallback(int, DBloodActor* actor)
int dy = SinScale16(pSprite->ang);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
if (IsPlayerSprite(pTarget))
actFireVector(actor, 0, 0, dx, dy, pTarget->z-pSprite->z, kVectorRatBite);
actFireVector(actor, 0, 0, dx, dy, pTarget->z - pSprite->z, kVectorRatBite);
}
static void ratThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -68,12 +68,12 @@ static void ratThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ratSearch);
aiThinkTarget(actor);
@ -89,18 +89,18 @@ static void ratThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &ratSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &ratSearch);
return;
@ -108,8 +108,8 @@ static void ratThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)

View file

@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void spidThinkSearch(DBloodActor *);
static void spidThinkGoto(DBloodActor *);
static void spidThinkChase(DBloodActor *);
static void spidThinkSearch(DBloodActor*);
static void spidThinkGoto(DBloodActor*);
static void spidThinkChase(DBloodActor*);
AISTATE spidIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
@ -46,15 +46,15 @@ AISTATE spidBirth = { kAiStateOther, 0, nSpidBirthClient, 60, NULL, NULL, NULL,
static char spidBlindEffect(DBloodActor* dudeactor, int nBlind, int max)
{
spritetype *pDude = &dudeactor->s();
spritetype* pDude = &dudeactor->s();
if (IsPlayerSprite(pDude))
{
nBlind <<= 4;
max <<= 4;
PLAYER *pPlayer = &gPlayer[pDude->type-kDudePlayer1];
PLAYER* pPlayer = &gPlayer[pDude->type - kDudePlayer1];
if (pPlayer->blindEffect < max)
{
pPlayer->blindEffect = ClipHigh(pPlayer->blindEffect+nBlind, max);
pPlayer->blindEffect = ClipHigh(pPlayer->blindEffect + nBlind, max);
return 1;
}
}
@ -74,7 +74,7 @@ void SpidBiteSeqCallback(int, DBloodActor* actor)
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto const target = actor->GetTarget();
spritetype *pTarget = &target->s();
spritetype* pTarget = &target->s();
XSPRITE* pXTarget = &target->x();
if (IsPlayerSprite(pTarget))
{
@ -82,7 +82,7 @@ void SpidBiteSeqCallback(int, DBloodActor* actor)
if (hit == 3 && gHitInfo.hitactor->IsPlayerActor())
{
dz += pTarget->z - pSprite->z;
PLAYER *pPlayer = &gPlayer[pTarget->type - kDudePlayer1];
PLAYER* pPlayer = &gPlayer[pTarget->type - kDudePlayer1];
switch (pSprite->type)
{
case kDudeSpiderBrown:
@ -124,9 +124,9 @@ void SpidJumpSeqCallback(int, DBloodActor* actor)
int dz = Random2(200);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
if (IsPlayerSprite(pTarget)) {
dz += pTarget->z-pSprite->z;
dz += pTarget->z - pSprite->z;
switch (pSprite->type) {
case kDudeSpiderBrown:
case kDudeSpiderRed:
@ -144,21 +144,21 @@ void SpidBirthSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
spritetype* pTarget = &actor->GetTarget()->s();
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
DBloodActor* spawned = nullptr;
if (IsPlayerSprite(pTarget) && pDudeExtraE->birthCounter < 10)
{
if (nDist < 0x1a00 && nDist > 0x1400 && abs(pSprite->ang-nAngle) < pDudeInfo->periphery)
if (nDist < 0x1a00 && nDist > 0x1400 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
spawned = actSpawnDude(actor, kDudeSpiderRed, pSprite->clipdist, 0);
else if (nDist < 0x1400 && nDist > 0xc00 && abs(pSprite->ang-nAngle) < pDudeInfo->periphery)
else if (nDist < 0x1400 && nDist > 0xc00 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
spawned = actSpawnDude(actor, kDudeSpiderBrown, pSprite->clipdist, 0);
else if (nDist < 0xc00 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
spawned = actSpawnDude(actor, kDudeSpiderBrown, pSprite->clipdist, 0);
@ -177,7 +177,7 @@ static void spidThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -186,12 +186,12 @@ static void spidThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &spidSearch);
aiThinkTarget(actor);
@ -207,26 +207,27 @@ static void spidThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &spidSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &spidSearch);
return;
}
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist) {
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(actor, actor->GetTarget());

View file

@ -30,10 +30,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void sub_72580(DBloodActor *);
static void sub_725A4(DBloodActor *);
static void sub_72850(DBloodActor *);
static void sub_72934(DBloodActor *);
static void sub_72580(DBloodActor*);
static void sub_725A4(DBloodActor*);
static void sub_72850(DBloodActor*);
static void sub_72934(DBloodActor*);
AISTATE tchernobogIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, sub_725A4, NULL };
@ -51,7 +51,7 @@ void sub_71A90(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int nTarget = pTarget->index;
int nOwner = pSprite->owner;
@ -66,8 +66,8 @@ void sub_71BD4(int, DBloodActor* actor)
{
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = pSprite->yrepeat*pDudeInfo->eyeHeight;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int height = pSprite->yrepeat * pDudeInfo->eyeHeight;
if (!actor->ValidateTarget(__FUNCTION__)) return;
int x = pSprite->x;
int y = pSprite->y;
@ -82,12 +82,12 @@ void sub_71BD4(int, DBloodActor* actor)
while (auto actor2 = it.Next())
{
spritetype* pSprite2 = &actor2->s();
if (pSprite == pSprite2 || !(pSprite2->flags&8))
if (pSprite == pSprite2 || !(pSprite2->flags & 8))
continue;
int x2 = pSprite2->x;
int y2 = pSprite2->y;
int z2 = pSprite2->z;
int nDist = approxDist(x2-x, y2-y);
int nDist = approxDist(x2 - x, y2 - y);
if (nDist == 0 || nDist > 0x2800)
continue;
if (tt.at10)
@ -97,25 +97,25 @@ void sub_71BD4(int, DBloodActor* actor)
y2 += (actor->yvel() * t) >> 12;
z2 += (actor->zvel() * t) >> 8;
}
int tx = x+MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y+MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z+MulScale(actor->dudeSlope, nDist, 10);
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10);
int top, bottom;
GetSpriteExtents(pSprite2, &top, &bottom);
if (tz-tsr > bottom || tz+tsr < top)
if (tz - tsr > bottom || tz + tsr < top)
continue;
int dx = (tx-x2)>>4;
int dy = (ty-y2)>>4;
int dz = (tz-z2)>>8;
int nDist2 = ksqrt(dx*dx+dy*dy+dz*dz);
int dx = (tx - x2) >> 4;
int dy = (ty - y2) >> 4;
int dz = (tz - z2) >> 8;
int nDist2 = ksqrt(dx * dx + dy * dy + dz * dz);
if (nDist2 < nClosest)
{
int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt.at8)
{
int tz = pSprite2->z-pSprite->z;
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
@ -138,8 +138,8 @@ void sub_720AC(int, DBloodActor* actor)
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = pSprite->yrepeat*pDudeInfo->eyeHeight;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int height = pSprite->yrepeat * pDudeInfo->eyeHeight;
int ax, ay, az;
ax = CosScale16(pSprite->ang);
ay = SinScale16(pSprite->ang);
@ -157,40 +157,40 @@ void sub_720AC(int, DBloodActor* actor)
while (auto actor2 = it.Next())
{
spritetype* pSprite2 = &actor2->s();
if (pSprite == pSprite2 || !(pSprite2->flags&8))
if (pSprite == pSprite2 || !(pSprite2->flags & 8))
continue;
int x2 = pSprite2->x;
int y2 = pSprite2->y;
int z2 = pSprite2->z;
int nDist = approxDist(x2-x, y2-y);
int nDist = approxDist(x2 - x, y2 - y);
if (nDist == 0 || nDist > 0x2800)
continue;
if (tt.at10)
{
int t = DivScale(nDist, tt.at10, 12);
x2 += (actor->xvel()*t)>>12;
y2 += (actor->yvel()*t)>>12;
z2 += (actor->zvel()*t)>>8;
x2 += (actor->xvel() * t) >> 12;
y2 += (actor->yvel() * t) >> 12;
z2 += (actor->zvel() * t) >> 8;
}
int tx = x+MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y+MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z+MulScale(actor->dudeSlope, nDist, 10);
int tx = x + MulScale(Cos(pSprite->ang), nDist, 30);
int ty = y + MulScale(Sin(pSprite->ang), nDist, 30);
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10);
int top, bottom;
GetSpriteExtents(pSprite2, &top, &bottom);
if (tz-tsr > bottom || tz+tsr < top)
if (tz - tsr > bottom || tz + tsr < top)
continue;
int dx = (tx-x2)>>4;
int dy = (ty-y2)>>4;
int dz = (tz-z2)>>8;
int nDist2 = ksqrt(dx*dx+dy*dy+dz*dz);
int dx = (tx - x2) >> 4;
int dy = (ty - y2) >> 4;
int dz = (tz - z2) >> 8;
int nDist2 = ksqrt(dx * dx + dy * dy + dz * dz);
if (nDist2 < nClosest)
{
int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
int nAngle = getangle(x2 - x, y2 - y);
int nDeltaAngle = ((nAngle - pSprite->ang + 1024) & 2047) - 1024;
if (abs(nDeltaAngle) <= tt.at8)
{
int tz = pSprite2->z-pSprite->z;
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
@ -211,7 +211,7 @@ static void sub_72580(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -224,8 +224,8 @@ static void sub_725A4(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
pDudeExtraE->thinkTime++;
else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active)
@ -240,21 +240,21 @@ static void sub_725A4(DBloodActor* actor)
{
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
PLAYER *pPlayer = &gPlayer[p];
PLAYER* pPlayer = &gPlayer[p];
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue;
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x;
int dy = y-pSprite->y;
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
@ -283,12 +283,12 @@ static void sub_72850(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tchernobogSearch);
aiThinkTarget(actor);
@ -308,19 +308,19 @@ static void sub_72934(DBloodActor* actor)
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return;
}
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &tchernobogSearch);
return;
}
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
{
aiNewState(actor, &tchernobogSearch);
return;
@ -328,8 +328,8 @@ static void sub_72934(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)

View file

@ -30,15 +30,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void zombaThinkSearch(DBloodActor *);
static void zombaThinkGoto(DBloodActor *);
static void zombaThinkChase(DBloodActor *);
static void zombaThinkPonder(DBloodActor *);
static void myThinkTarget(DBloodActor *);
static void myThinkSearch(DBloodActor *);
static void entryEZombie(DBloodActor *);
static void entryAIdle(DBloodActor *);
static void entryEStand(DBloodActor *);
static void zombaThinkSearch(DBloodActor*);
static void zombaThinkGoto(DBloodActor*);
static void zombaThinkChase(DBloodActor*);
static void zombaThinkPonder(DBloodActor*);
static void myThinkTarget(DBloodActor*);
static void myThinkSearch(DBloodActor*);
static void entryEZombie(DBloodActor*);
static void entryAIdle(DBloodActor*);
static void entryEStand(DBloodActor*);
AISTATE zombieAIdle = { kAiStateIdle, 0, -1, 0, entryAIdle, NULL, aiThinkTarget, NULL };
@ -64,15 +64,15 @@ void HackSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int tx = pXSprite->targetX-pSprite->x;
int ty = pXSprite->targetY-pSprite->y;
spritetype* pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfoT = getDudeInfo(pTarget->type);
int tx = pXSprite->targetX - pSprite->x;
int ty = pXSprite->targetY - pSprite->y;
int nAngle = getangle(tx, ty);
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
int dz = height-height2;
int height = (pSprite->yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (pTarget->yrepeat * pDudeInfoT->eyeHeight) << 2;
int dz = height - height2;
int dx = CosScale16(nAngle);
int dy = SinScale16(nAngle);
sfxPlay3DSound(pSprite, 1101, 1, 0);
@ -87,7 +87,7 @@ void StandSeqCallback(int, DBloodActor* actor)
static void zombaThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiLookForTarget(actor);
}
@ -96,12 +96,12 @@ static void zombaThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 921 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieASearch);
aiThinkTarget(actor);
@ -117,19 +117,19 @@ static void zombaThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &zombieASearch);
return;
}
if (IsPlayerSprite(pTarget) && (powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0 || powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpDeathMaskUseless) > 0))
if (IsPlayerSprite(pTarget) && (powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0 || powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpDeathMaskUseless) > 0))
{
aiNewState(actor, &zombieAGoto);
return;
@ -141,8 +141,8 @@ static void zombaThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -169,19 +169,19 @@ static void zombaThinkPonder(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &zombieASearch);
return;
}
if (IsPlayerSprite(pTarget) && (powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0 || powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpDeathMaskUseless) > 0))
if (IsPlayerSprite(pTarget) && (powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0 || powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpDeathMaskUseless) > 0))
{
aiNewState(actor, &zombieAGoto);
return;
@ -189,8 +189,8 @@ static void zombaThinkPonder(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -217,25 +217,25 @@ static void myThinkTarget(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
PLAYER *pPlayer = &gPlayer[p];
int nOwner = (pSprite->owner & 0x1000) ? (pSprite->owner&0xfff) : -1;
PLAYER* pPlayer = &gPlayer[p];
int nOwner = (pSprite->owner & 0x1000) ? (pSprite->owner & 0xfff) : -1;
if (nOwner == pPlayer->nSprite || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue;
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x;
int dy = y-pSprite->y;
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget(actor, pPlayer->actor());
@ -256,7 +256,7 @@ static void myThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
myThinkTarget(actor);
}
@ -278,7 +278,7 @@ static void entryEStand(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
sfxPlay3DSound(pSprite, 1100, -1, 0);
pSprite->ang = getangle(pXSprite->targetX-pSprite->x, pXSprite->targetY-pSprite->y);
pSprite->ang = getangle(pXSprite->targetX - pSprite->x, pXSprite->targetY - pSprite->y);
}
END_BLD_NS

View file

@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static void zombfThinkSearch(DBloodActor *actor);
static void zombfThinkGoto(DBloodActor *actor);
static void zombfThinkChase(DBloodActor *actor);
static void zombfThinkSearch(DBloodActor* actor);
static void zombfThinkGoto(DBloodActor* actor);
static void zombfThinkChase(DBloodActor* actor);
AISTATE zombieFIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
@ -53,12 +53,12 @@ void zombfHackSeqCallback(int, DBloodActor* actor)
if (pSprite->type != kDudeZombieButcher)
return;
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height2 = (pDudeInfoT->eyeHeight*pTarget->yrepeat);
actFireVector(actor, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), height-height2, kVectorCleaver);
spritetype* pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat);
DUDEINFO* pDudeInfoT = getDudeInfo(pTarget->type);
int height2 = (pDudeInfoT->eyeHeight * pTarget->yrepeat);
actFireVector(actor, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), height - height2, kVectorCleaver);
}
void PukeSeqCallback(int, DBloodActor* actor)
@ -66,18 +66,18 @@ void PukeSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s();
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat);
int height2 = (pDudeInfoT->eyeHeight*pTarget->yrepeat);
int tx = pXSprite->targetX-pSprite->x;
int ty = pXSprite->targetY-pSprite->y;
spritetype* pTarget = &actor->GetTarget()->s();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat);
int height2 = (pDudeInfoT->eyeHeight * pTarget->yrepeat);
int tx = pXSprite->targetX - pSprite->x;
int ty = pXSprite->targetY - pSprite->y;
int nAngle = getangle(tx, ty);
int dx = CosScale16(nAngle);
int dy = SinScale16(nAngle);
sfxPlay3DSound(pSprite, 1203, 1, 0);
actFireMissile(pSprite, 0, -(height-height2), dx, dy, 0, kMissilePukeGreen);
actFireMissile(pSprite, 0, -(height - height2), dx, dy, 0, kMissilePukeGreen);
}
void ThrowSeqCallback(int, DBloodActor* actor)
@ -90,7 +90,7 @@ static void zombfThinkSearch(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
aiChooseDirection(actor,pXSprite->goalAng);
aiChooseDirection(actor, pXSprite->goalAng);
aiThinkTarget(actor);
}
@ -99,12 +99,12 @@ static void zombfThinkGoto(DBloodActor* actor)
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y;
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor,nAngle);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieFSearch);
aiThinkTarget(actor);
@ -120,19 +120,19 @@ static void zombfThinkChase(DBloodActor* actor)
return;
}
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
spritetype *pTarget = &actor->GetTarget()->s();
spritetype* pTarget = &actor->GetTarget()->s();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y;
aiChooseDirection(actor,getangle(dx, dy));
int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
{
aiNewState(actor, &zombieFSearch);
return;
}
if (IsPlayerSprite(pTarget) && (powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0 || powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpDeathMaskUseless) > 0))
if (IsPlayerSprite(pTarget) && (powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0 || powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpDeathMaskUseless) > 0))
{
aiNewState(actor, &zombieFSearch);
return;
@ -140,8 +140,8 @@ static void zombfThinkChase(DBloodActor* actor)
int nDist = approxDist(dx, dy);
if (nDist <= pDudeInfo->seeDist)
{
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{
if (abs(nDeltaAngle) <= pDudeInfo->periphery)