- replaced most occurences of target_i in already refactored code.

This commit is contained in:
Christoph Oelckers 2021-09-16 00:52:54 +02:00
parent 7a6629ce6a
commit 90091965ba
4 changed files with 65 additions and 55 deletions

View file

@ -2396,7 +2396,8 @@ static void actInitThings()
if (pSprite->flags & kPhysGravity) pSprite->flags |= kPhysFalling; if (pSprite->flags & kPhysGravity) pSprite->flags |= kPhysFalling;
act->xvel() = act->yvel() = act->zvel() = 0; act->xvel() = act->yvel() = act->zvel() = 0;
switch (pSprite->type) { switch (pSprite->type)
{
case kThingArmedProxBomb: case kThingArmedProxBomb:
case kTrapMachinegun: case kTrapMachinegun:
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
@ -5347,7 +5348,7 @@ int MoveMissile(DBloodActor* actor)
gHitInfo.hitsprite = -1; gHitInfo.hitsprite = -1;
if (pSprite->type == kMissileFlameSpray) actAirDrag(actor, 0x1000); if (pSprite->type == kMissileFlameSpray) actAirDrag(actor, 0x1000);
if (pXSprite->target_i != -1 && (actor->xvel() || actor->yvel() || actor->zvel())) if (actor->GetTarget() != nullptr && (actor->xvel() || actor->yvel() || actor->zvel()))
{ {
auto target = actor->GetTarget(); auto target = actor->GetTarget();
spritetype* pTarget = &target->s(); spritetype* pTarget = &target->s();
@ -5710,7 +5711,7 @@ static void actCheckProximity()
continue; continue;
#endif #endif
if (pSprite->type == kThingDroppedLifeLeech) pXSprite->target_i = -1; if (pSprite->type == kThingDroppedLifeLeech) actor->SetTarget(nullptr);
BloodStatIterator it1(kStatDude); BloodStatIterator it1(kStatDude);
while (auto dudeactor = it1.Next()) while (auto dudeactor = it1.Next())
{ {
@ -5730,7 +5731,7 @@ static void actCheckProximity()
if (pSprite->type == kModernThingEnemyLifeLeech) proxyDist = 512; if (pSprite->type == kModernThingEnemyLifeLeech) proxyDist = 512;
#endif #endif
if (pSprite->type == kThingDroppedLifeLeech && pXSprite->target_i == -1) if (pSprite->type == kThingDroppedLifeLeech && actor->GetTarget() == nullptr)
{ {
auto Owner = actor->GetOwner(); auto Owner = actor->GetOwner();
if (!Owner->IsPlayerActor()) continue; if (!Owner->IsPlayerActor()) continue;
@ -5751,7 +5752,7 @@ static void actCheckProximity()
{ {
case kThingDroppedLifeLeech: case kThingDroppedLifeLeech:
if (!Chance(0x4000) && nextdude) continue; if (!Chance(0x4000) && nextdude) continue;
if (pSprite2->cstat & CLIPMASK0) pXSprite->target_i = pSprite2->index; if (pSprite2->cstat & CLIPMASK0) actor->SetTarget(dudeactor);
else continue; else continue;
break; break;
@ -5762,7 +5763,7 @@ static void actCheckProximity()
break; break;
case kModernThingEnemyLifeLeech: case kModernThingEnemyLifeLeech:
if (pXSprite->target_i != pSprite2->index) continue; if (actor->GetTarget() != dudeactor) continue;
break; break;
#endif #endif
@ -6196,7 +6197,7 @@ static void actCheckDudes()
{ {
pXSprite->health = dudeInfo[28].startHealth << 4; pXSprite->health = dudeInfo[28].startHealth << 4;
pSprite->type = kDudeCerberusOneHead; pSprite->type = kDudeCerberusOneHead;
if (pXSprite->target_i != -1) aiSetTarget(pXSprite, pXSprite->target_i); if (actor->GetTarget() != nullptr) aiSetTarget(actor, actor->GetTarget());
aiActivateDude(actor); aiActivateDude(actor);
} }
} }

View file

@ -132,7 +132,7 @@ static bool isImmune(DBloodActor* actor, int dmgType, int minScale)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool CanMove(DBloodActor *actor, int a2, int nAngle, int nRange) bool CanMove(DBloodActor *actor, DBloodActor* target, int nAngle, int nRange)
{ {
auto pSprite = &actor->s(); auto pSprite = &actor->s();
int top, bottom; int top, bottom;
@ -144,7 +144,7 @@ bool CanMove(DBloodActor *actor, int a2, int nAngle, int 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 (nDist - (pSprite->clipdist << 2) < nRange)
{ {
if (gHitInfo.hitsprite < 0 || a2 != gHitInfo.hitsprite) if (gHitInfo.hitsprite < 0 || target == nullptr || target->s().index != gHitInfo.hitsprite)
return false; return false;
return true; return true;
} }
@ -269,17 +269,17 @@ void aiChooseDirection(DBloodActor* actor, int a3)
int v8 = 341; int v8 = 341;
if (vc < 0) if (vc < 0)
v8 = -341; v8 = -341;
if (CanMove(actor, pXSprite->target_i, pSprite->ang+vc, vsi)) if (CanMove(actor, actor->GetTarget(), pSprite->ang+vc, vsi))
pXSprite->goalAng = pSprite->ang+vc; pXSprite->goalAng = pSprite->ang+vc;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang+vc/2, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang+vc/2, vsi))
pXSprite->goalAng = pSprite->ang+vc/2; pXSprite->goalAng = pSprite->ang+vc/2;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang-vc/2, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang-vc/2, vsi))
pXSprite->goalAng = pSprite->ang-vc/2; pXSprite->goalAng = pSprite->ang-vc/2;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang+v8, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang+v8, vsi))
pXSprite->goalAng = pSprite->ang+v8; pXSprite->goalAng = pSprite->ang+v8;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang, vsi))
pXSprite->goalAng = pSprite->ang; pXSprite->goalAng = pSprite->ang;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang-v8, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang-v8, vsi))
pXSprite->goalAng = pSprite->ang-v8; pXSprite->goalAng = pSprite->ang-v8;
//else if (pSprite->flags&2) //else if (pSprite->flags&2)
//pXSprite->goalAng = pSprite->ang+341; //pXSprite->goalAng = pSprite->ang+341;
@ -289,10 +289,10 @@ void aiChooseDirection(DBloodActor* actor, int a3)
pXSprite->dodgeDir = 1; pXSprite->dodgeDir = 1;
else else
pXSprite->dodgeDir = -1; pXSprite->dodgeDir = -1;
if (!CanMove(actor, pXSprite->target_i, pSprite->ang+pXSprite->dodgeDir*512, 512)) if (!CanMove(actor, actor->GetTarget(), pSprite->ang+pXSprite->dodgeDir*512, 512))
{ {
pXSprite->dodgeDir = -pXSprite->dodgeDir; pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!CanMove(actor, pXSprite->target_i, pSprite->ang+pXSprite->dodgeDir*512, 512)) if (!CanMove(actor, actor->GetTarget(), pSprite->ang+pXSprite->dodgeDir*512, 512))
pXSprite->dodgeDir = 0; pXSprite->dodgeDir = 0;
} }
} }
@ -392,7 +392,7 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->xval2 = 0; pDudeExtraE->xval2 = 0;
pDudeExtraE->xval3 = 1; pDudeExtraE->xval3 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &ghostSearch); aiNewState(actor, &ghostSearch);
else else
{ {
@ -410,7 +410,7 @@ void aiActivateDude(DBloodActor* actor)
DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1;
pDudeExtraE->xval3 = 1; pDudeExtraE->xval3 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -455,10 +455,13 @@ void aiActivateDude(DBloodActor* actor)
DUDEEXTRA_at6_u1* pDudeExtraE = &actor->dudeExtra.at6.u1; DUDEEXTRA_at6_u1* pDudeExtraE = &actor->dudeExtra.at6.u1;
pDudeExtraE->xval3 = 1; pDudeExtraE->xval3 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) { if (actor->GetTarget() == nullptr)
{
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW); if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW);
else aiGenDudeNewState(pSprite, &genDudeSearchL); else aiGenDudeNewState(pSprite, &genDudeSearchL);
} else { }
else
{
if (Chance(0x4000)) playGenDudeSound(pSprite, kGenDudeSndTargetSpot); if (Chance(0x4000)) playGenDudeSound(pSprite, kGenDudeSndTargetSpot);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeChaseW); if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL); else aiGenDudeNewState(pSprite, &genDudeChaseL);
@ -466,7 +469,7 @@ void aiActivateDude(DBloodActor* actor)
break; break;
} }
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
if (pXSprite->target_i == -1) aiGenDudeNewState(pSprite, &genDudeBurnSearch); if (actor->GetTarget() == nullptr) aiGenDudeNewState(pSprite, &genDudeBurnSearch);
else aiGenDudeNewState(pSprite, &genDudeBurnChase); else aiGenDudeNewState(pSprite, &genDudeBurnChase);
break; break;
#endif #endif
@ -475,7 +478,7 @@ void aiActivateDude(DBloodActor* actor)
DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1;
pDudeExtraE->xval3 = 1; pDudeExtraE->xval1 = 0; pDudeExtraE->xval3 = 1; pDudeExtraE->xval1 = 0;
pSprite->type = kDudeCultistTommy; pSprite->type = kDudeCultistTommy;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -513,7 +516,7 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->xval3 = 1; pDudeExtraE->xval3 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
pSprite->type = kDudeCultistShotgun; pSprite->type = kDudeCultistShotgun;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -546,7 +549,7 @@ void aiActivateDude(DBloodActor* actor)
break; break;
} }
case kDudeBurningCultist: case kDudeBurningCultist:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &cultistBurnSearch); aiNewState(actor, &cultistBurnSearch);
else else
aiNewState(actor, &cultistBurnChase); aiNewState(actor, &cultistBurnChase);
@ -559,7 +562,7 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (!pSprite->flags) if (!pSprite->flags)
pSprite->flags = 9; pSprite->flags = 9;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &batSearch); aiNewState(actor, &batSearch);
else else
{ {
@ -575,7 +578,7 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->xval2 = 0; pDudeExtraE->xval2 = 0;
pDudeExtraE->xval3 = 1; pDudeExtraE->xval3 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
else else
{ {
@ -596,7 +599,7 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
pDudeExtraE->xval2 = 0; pDudeExtraE->xval2 = 0;
pDudeExtraE->xval3 = 1; pDudeExtraE->xval3 = 1;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
@ -621,7 +624,7 @@ void aiActivateDude(DBloodActor* actor)
DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2;
pDudeExtraE->xval2 = 1; pDudeExtraE->xval2 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
else else
{ {
@ -667,7 +670,7 @@ void aiActivateDude(DBloodActor* actor)
DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2;
pDudeExtraE->xval2 = 1; pDudeExtraE->xval2 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &zombieFSearch); aiNewState(actor, &zombieFSearch);
else else
{ {
@ -680,13 +683,13 @@ void aiActivateDude(DBloodActor* actor)
break; break;
} }
case kDudeBurningZombieAxe: case kDudeBurningZombieAxe:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &zombieABurnSearch); aiNewState(actor, &zombieABurnSearch);
else else
aiNewState(actor, &zombieABurnChase); aiNewState(actor, &zombieABurnChase);
break; break;
case kDudeBurningZombieButcher: case kDudeBurningZombieButcher:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &zombieFBurnSearch); aiNewState(actor, &zombieFBurnSearch);
else else
aiNewState(actor, &zombieFBurnChase); aiNewState(actor, &zombieFBurnChase);
@ -696,7 +699,7 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->xval2 = 0; pDudeExtraE->xval2 = 0;
pDudeExtraE->xval3 = 1; pDudeExtraE->xval3 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &gargoyleFSearch); aiNewState(actor, &gargoyleFSearch);
else else
{ {
@ -714,7 +717,7 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->xval2 = 0; pDudeExtraE->xval2 = 0;
pDudeExtraE->xval3 = 1; pDudeExtraE->xval3 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &gargoyleFSearch); aiNewState(actor, &gargoyleFSearch);
else else
{ {
@ -753,7 +756,7 @@ void aiActivateDude(DBloodActor* actor)
#endif #endif
break; break;
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &cerberusSearch); aiNewState(actor, &cerberusSearch);
else else
{ {
@ -762,7 +765,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeCerberusOneHead: case kDudeCerberusOneHead:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &cerberus2Search); aiNewState(actor, &cerberus2Search);
else else
{ {
@ -771,7 +774,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeHellHound: case kDudeHellHound:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &houndSearch); aiNewState(actor, &houndSearch);
else else
{ {
@ -780,7 +783,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeHand: case kDudeHand:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &handSearch); aiNewState(actor, &handSearch);
else else
{ {
@ -789,7 +792,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeRat: case kDudeRat:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &ratSearch); aiNewState(actor, &ratSearch);
else else
{ {
@ -798,7 +801,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeInnocent: case kDudeInnocent:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &innocentSearch); aiNewState(actor, &innocentSearch);
else else
{ {
@ -808,7 +811,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeTchernobog: case kDudeTchernobog:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &tchernobogSearch); aiNewState(actor, &tchernobogSearch);
else else
{ {
@ -821,7 +824,7 @@ void aiActivateDude(DBloodActor* actor)
case kDudeSpiderBlack: case kDudeSpiderBlack:
pSprite->flags |= 2; pSprite->flags |= 2;
pSprite->cstat &= ~8; pSprite->cstat &= ~8;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &spidSearch); aiNewState(actor, &spidSearch);
else else
{ {
@ -836,7 +839,7 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
pSprite->flags |= 2; pSprite->flags |= 2;
pSprite->cstat &= ~8; pSprite->cstat &= ~8;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &spidSearch); aiNewState(actor, &spidSearch);
else else
{ {
@ -850,7 +853,7 @@ void aiActivateDude(DBloodActor* actor)
DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2;
pDudeExtraE->xval2 = 1; pDudeExtraE->xval2 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -883,7 +886,7 @@ void aiActivateDude(DBloodActor* actor)
DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2;
pDudeExtraE->xval2 = 1; pDudeExtraE->xval2 = 1;
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -914,7 +917,7 @@ void aiActivateDude(DBloodActor* actor)
} }
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &podSearch); aiNewState(actor, &podSearch);
else else
{ {
@ -927,7 +930,7 @@ void aiActivateDude(DBloodActor* actor)
break; break;
case kDudeTentacleGreen: case kDudeTentacleGreen:
case kDudeTentacleFire: case kDudeTentacleFire:
if (pXSprite->target_i == -1) if (actor->GetTarget() == nullptr)
aiNewState(actor, &tentacleSearch); aiNewState(actor, &tentacleSearch);
else else
{ {
@ -969,6 +972,11 @@ void aiSetTarget(XSPRITE *pXSprite, int nTarget)
} }
} }
void aiSetTarget(DBloodActor* actor, DBloodActor* target)
{
aiSetTarget(&actor->x(), target ? target->x().reference : -1);
}
int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType, int nDamage) int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType, int nDamage)
{ {

View file

@ -98,6 +98,7 @@ void aiMoveDodge(DBloodActor *actor);
void aiActivateDude(DBloodActor *actor); void aiActivateDude(DBloodActor *actor);
void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z); void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z);
void aiSetTarget(XSPRITE *pXSprite, int nTarget); void aiSetTarget(XSPRITE *pXSprite, int nTarget);
void aiSetTarget(DBloodActor* actor, DBloodActor* target);
int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType, int nDamage); int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType, int nDamage);
void aiThinkTarget(DBloodActor* actor); void aiThinkTarget(DBloodActor* actor);
void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite); void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite);

View file

@ -1048,26 +1048,26 @@ void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, in
int t1 = DMulScale(xvel, Cos(pSprite->ang), yvel, Sin(pSprite->ang), 30); int t1 = DMulScale(xvel, Cos(pSprite->ang), yvel, Sin(pSprite->ang), 30);
int vsi = ((t1 * 15) >> 12) / 2; int v8 = (vc >= 0) ? 341 : -341; int vsi = ((t1 * 15) >> 12) / 2; int v8 = (vc >= 0) ? 341 : -341;
if (CanMove(actor, pXSprite->target_i, pSprite->ang + vc, vsi)) if (CanMove(actor, actor->GetTarget(), pSprite->ang + vc, vsi))
pXSprite->goalAng = pSprite->ang + vc; pXSprite->goalAng = pSprite->ang + vc;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang + vc / 2, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang + vc / 2, vsi))
pXSprite->goalAng = pSprite->ang + vc / 2; pXSprite->goalAng = pSprite->ang + vc / 2;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang - vc / 2, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang - vc / 2, vsi))
pXSprite->goalAng = pSprite->ang - vc / 2; pXSprite->goalAng = pSprite->ang - vc / 2;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang + v8, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang + v8, vsi))
pXSprite->goalAng = pSprite->ang + v8; pXSprite->goalAng = pSprite->ang + v8;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang, vsi))
pXSprite->goalAng = pSprite->ang; pXSprite->goalAng = pSprite->ang;
else if (CanMove(actor, pXSprite->target_i, pSprite->ang - v8, vsi)) else if (CanMove(actor, actor->GetTarget(), pSprite->ang - v8, vsi))
pXSprite->goalAng = pSprite->ang - v8; pXSprite->goalAng = pSprite->ang - v8;
else else
pXSprite->goalAng = pSprite->ang + 341; pXSprite->goalAng = pSprite->ang + 341;
pXSprite->dodgeDir = (Chance(0x8000)) ? 1 : -1; pXSprite->dodgeDir = (Chance(0x8000)) ? 1 : -1;
if (!CanMove(actor, pXSprite->target_i, pSprite->ang + pXSprite->dodgeDir * 512, 512)) { if (!CanMove(actor, actor->GetTarget(), pSprite->ang + pXSprite->dodgeDir * 512, 512)) {
pXSprite->dodgeDir = -pXSprite->dodgeDir; pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!CanMove(actor, pXSprite->target_i, pSprite->ang + pXSprite->dodgeDir * 512, 512)) if (!CanMove(actor, actor->GetTarget(), pSprite->ang + pXSprite->dodgeDir * 512, 512))
pXSprite->dodgeDir = 0; pXSprite->dodgeDir = 0;
} }
} }