- renamed XSPRITE::target to target_i.

This is to make searching for it easier as 'target' is a very common word in the source.
This commit is contained in:
Christoph Oelckers 2021-09-16 00:40:09 +02:00
parent 774a015e6b
commit 7a6629ce6a
32 changed files with 390 additions and 390 deletions

View file

@ -5347,7 +5347,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 != -1 && (actor->xvel() || actor->yvel() || actor->zvel())) if (pXSprite->target_i != -1 && (actor->xvel() || actor->yvel() || actor->zvel()))
{ {
auto target = actor->GetTarget(); auto target = actor->GetTarget();
spritetype* pTarget = &target->s(); spritetype* pTarget = &target->s();
@ -5637,7 +5637,7 @@ void actExplodeSprite(DBloodActor* actor)
pSprite->flags &= ~3; pSprite->flags &= ~3;
pSprite->type = nType; pSprite->type = nType;
const EXPLOSION* pExplodeInfo = &explodeInfo[nType]; const EXPLOSION* pExplodeInfo = &explodeInfo[nType];
pXSprite->target = 0; pXSprite->target_i = 0;
pXSprite->data1 = pExplodeInfo->ticks; pXSprite->data1 = pExplodeInfo->ticks;
pXSprite->data2 = pExplodeInfo->quakeEffect; pXSprite->data2 = pExplodeInfo->quakeEffect;
pXSprite->data3 = pExplodeInfo->flashEffect; pXSprite->data3 = pExplodeInfo->flashEffect;
@ -5710,7 +5710,7 @@ static void actCheckProximity()
continue; continue;
#endif #endif
if (pSprite->type == kThingDroppedLifeLeech) pXSprite->target = -1; if (pSprite->type == kThingDroppedLifeLeech) pXSprite->target_i = -1;
BloodStatIterator it1(kStatDude); BloodStatIterator it1(kStatDude);
while (auto dudeactor = it1.Next()) while (auto dudeactor = it1.Next())
{ {
@ -5730,7 +5730,7 @@ static void actCheckProximity()
if (pSprite->type == kModernThingEnemyLifeLeech) proxyDist = 512; if (pSprite->type == kModernThingEnemyLifeLeech) proxyDist = 512;
#endif #endif
if (pSprite->type == kThingDroppedLifeLeech && pXSprite->target == -1) if (pSprite->type == kThingDroppedLifeLeech && pXSprite->target_i == -1)
{ {
auto Owner = actor->GetOwner(); auto Owner = actor->GetOwner();
if (!Owner->IsPlayerActor()) continue; if (!Owner->IsPlayerActor()) continue;
@ -5751,7 +5751,7 @@ static void actCheckProximity()
{ {
case kThingDroppedLifeLeech: case kThingDroppedLifeLeech:
if (!Chance(0x4000) && nextdude) continue; if (!Chance(0x4000) && nextdude) continue;
if (pSprite2->cstat & CLIPMASK0) pXSprite->target = pSprite2->index; if (pSprite2->cstat & CLIPMASK0) pXSprite->target_i = pSprite2->index;
else continue; else continue;
break; break;
@ -5762,7 +5762,7 @@ static void actCheckProximity()
break; break;
case kModernThingEnemyLifeLeech: case kModernThingEnemyLifeLeech:
if (pXSprite->target != pSprite2->index) continue; if (pXSprite->target_i != pSprite2->index) continue;
break; break;
#endif #endif
@ -5981,9 +5981,9 @@ static void actCheckExplosion()
{ {
if (pXSprite->data1 && CheckProximity(pDude, x, y, z, nSector, radius)) if (pXSprite->data1 && CheckProximity(pDude, x, y, z, nSector, radius))
{ {
if (pExplodeInfo->dmg && pXSprite->target == 0) if (pExplodeInfo->dmg && pXSprite->target_i == 0)
{ {
pXSprite->target = 1; pXSprite->target_i = 1;
actDamageSprite(Owner, dudeactor, kDamageFall, (pExplodeInfo->dmg + Random(pExplodeInfo->dmgRng)) << 4); actDamageSprite(Owner, dudeactor, kDamageFall, (pExplodeInfo->dmg + Random(pExplodeInfo->dmgRng)) << 4);
} }
if (pExplodeInfo->dmgType) ConcussSprite(actor, dudeactor, x, y, z, pExplodeInfo->dmgType); if (pExplodeInfo->dmgType) ConcussSprite(actor, dudeactor, x, y, z, pExplodeInfo->dmgType);
@ -6196,7 +6196,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 != -1) aiSetTarget(pXSprite, pXSprite->target); if (pXSprite->target_i != -1) aiSetTarget(pXSprite, pXSprite->target_i);
aiActivateDude(actor); aiActivateDude(actor);
} }
} }
@ -6704,7 +6704,7 @@ spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5,
pMissile->cstat |= 1; pMissile->cstat |= 1;
int nXSprite = pMissile->extra; int nXSprite = pMissile->extra;
assert(nXSprite > 0 && nXSprite < kMaxXSprites); assert(nXSprite > 0 && nXSprite < kMaxXSprites);
xsprite[nXSprite].target = -1; xsprite[nXSprite].target_i = -1;
evPost(nMissile, 3, 600, kCallbackRemove); evPost(nMissile, 3, 600, kCallbackRemove);
actBuildMissile(pMissile, nXSprite, nSprite); actBuildMissile(pMissile, nXSprite, nSprite);

View file

@ -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, pSprite->ang+vc, vsi)) if (CanMove(actor, pXSprite->target_i, pSprite->ang+vc, vsi))
pXSprite->goalAng = pSprite->ang+vc; pXSprite->goalAng = pSprite->ang+vc;
else if (CanMove(actor, pXSprite->target, pSprite->ang+vc/2, vsi)) else if (CanMove(actor, pXSprite->target_i, pSprite->ang+vc/2, vsi))
pXSprite->goalAng = pSprite->ang+vc/2; pXSprite->goalAng = pSprite->ang+vc/2;
else if (CanMove(actor, pXSprite->target, pSprite->ang-vc/2, vsi)) else if (CanMove(actor, pXSprite->target_i, pSprite->ang-vc/2, vsi))
pXSprite->goalAng = pSprite->ang-vc/2; pXSprite->goalAng = pSprite->ang-vc/2;
else if (CanMove(actor, pXSprite->target, pSprite->ang+v8, vsi)) else if (CanMove(actor, pXSprite->target_i, pSprite->ang+v8, vsi))
pXSprite->goalAng = pSprite->ang+v8; pXSprite->goalAng = pSprite->ang+v8;
else if (CanMove(actor, pXSprite->target, pSprite->ang, vsi)) else if (CanMove(actor, pXSprite->target_i, pSprite->ang, vsi))
pXSprite->goalAng = pSprite->ang; pXSprite->goalAng = pSprite->ang;
else if (CanMove(actor, pXSprite->target, pSprite->ang-v8, vsi)) else if (CanMove(actor, pXSprite->target_i, 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, pSprite->ang+pXSprite->dodgeDir*512, 512)) if (!CanMove(actor, pXSprite->target_i, pSprite->ang+pXSprite->dodgeDir*512, 512))
{ {
pXSprite->dodgeDir = -pXSprite->dodgeDir; pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!CanMove(actor, pXSprite->target, pSprite->ang+pXSprite->dodgeDir*512, 512)) if (!CanMove(actor, pXSprite->target_i, 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 == -1) if (pXSprite->target_i == -1)
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 == -1) if (pXSprite->target_i == -1)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -455,7 +455,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 == -1) { if (pXSprite->target_i == -1) {
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW); if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW);
else aiGenDudeNewState(pSprite, &genDudeSearchL); else aiGenDudeNewState(pSprite, &genDudeSearchL);
} else { } else {
@ -466,7 +466,7 @@ void aiActivateDude(DBloodActor* actor)
break; break;
} }
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
if (pXSprite->target == -1) aiGenDudeNewState(pSprite, &genDudeBurnSearch); if (pXSprite->target_i == -1) aiGenDudeNewState(pSprite, &genDudeBurnSearch);
else aiGenDudeNewState(pSprite, &genDudeBurnChase); else aiGenDudeNewState(pSprite, &genDudeBurnChase);
break; break;
#endif #endif
@ -475,7 +475,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 == -1) if (pXSprite->target_i == -1)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -513,7 +513,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 == -1) if (pXSprite->target_i == -1)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -546,7 +546,7 @@ void aiActivateDude(DBloodActor* actor)
break; break;
} }
case kDudeBurningCultist: case kDudeBurningCultist:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &cultistBurnSearch); aiNewState(actor, &cultistBurnSearch);
else else
aiNewState(actor, &cultistBurnChase); aiNewState(actor, &cultistBurnChase);
@ -559,7 +559,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 == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &batSearch); aiNewState(actor, &batSearch);
else else
{ {
@ -575,7 +575,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 == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
else else
{ {
@ -596,7 +596,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 == -1) if (pXSprite->target_i == -1)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
@ -621,7 +621,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 == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
else else
{ {
@ -667,7 +667,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 == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &zombieFSearch); aiNewState(actor, &zombieFSearch);
else else
{ {
@ -680,13 +680,13 @@ void aiActivateDude(DBloodActor* actor)
break; break;
} }
case kDudeBurningZombieAxe: case kDudeBurningZombieAxe:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &zombieABurnSearch); aiNewState(actor, &zombieABurnSearch);
else else
aiNewState(actor, &zombieABurnChase); aiNewState(actor, &zombieABurnChase);
break; break;
case kDudeBurningZombieButcher: case kDudeBurningZombieButcher:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &zombieFBurnSearch); aiNewState(actor, &zombieFBurnSearch);
else else
aiNewState(actor, &zombieFBurnChase); aiNewState(actor, &zombieFBurnChase);
@ -696,7 +696,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 == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &gargoyleFSearch); aiNewState(actor, &gargoyleFSearch);
else else
{ {
@ -714,7 +714,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 == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &gargoyleFSearch); aiNewState(actor, &gargoyleFSearch);
else else
{ {
@ -753,7 +753,7 @@ void aiActivateDude(DBloodActor* actor)
#endif #endif
break; break;
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &cerberusSearch); aiNewState(actor, &cerberusSearch);
else else
{ {
@ -762,7 +762,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeCerberusOneHead: case kDudeCerberusOneHead:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &cerberus2Search); aiNewState(actor, &cerberus2Search);
else else
{ {
@ -771,7 +771,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeHellHound: case kDudeHellHound:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &houndSearch); aiNewState(actor, &houndSearch);
else else
{ {
@ -780,7 +780,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeHand: case kDudeHand:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &handSearch); aiNewState(actor, &handSearch);
else else
{ {
@ -789,7 +789,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeRat: case kDudeRat:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &ratSearch); aiNewState(actor, &ratSearch);
else else
{ {
@ -798,7 +798,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeInnocent: case kDudeInnocent:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &innocentSearch); aiNewState(actor, &innocentSearch);
else else
{ {
@ -808,7 +808,7 @@ void aiActivateDude(DBloodActor* actor)
} }
break; break;
case kDudeTchernobog: case kDudeTchernobog:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &tchernobogSearch); aiNewState(actor, &tchernobogSearch);
else else
{ {
@ -821,7 +821,7 @@ void aiActivateDude(DBloodActor* actor)
case kDudeSpiderBlack: case kDudeSpiderBlack:
pSprite->flags |= 2; pSprite->flags |= 2;
pSprite->cstat &= ~8; pSprite->cstat &= ~8;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &spidSearch); aiNewState(actor, &spidSearch);
else else
{ {
@ -836,7 +836,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 == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &spidSearch); aiNewState(actor, &spidSearch);
else else
{ {
@ -850,7 +850,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 == -1) if (pXSprite->target_i == -1)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -883,7 +883,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 == -1) if (pXSprite->target_i == -1)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -914,7 +914,7 @@ void aiActivateDude(DBloodActor* actor)
} }
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &podSearch); aiNewState(actor, &podSearch);
else else
{ {
@ -927,7 +927,7 @@ void aiActivateDude(DBloodActor* actor)
break; break;
case kDudeTentacleGreen: case kDudeTentacleGreen:
case kDudeTentacleFire: case kDudeTentacleFire:
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
aiNewState(actor, &tentacleSearch); aiNewState(actor, &tentacleSearch);
else else
{ {
@ -946,7 +946,7 @@ void aiActivateDude(DBloodActor* actor)
void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z) void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z)
{ {
pXSprite->target = -1; pXSprite->target_i = -1;
pXSprite->targetX = x; pXSprite->targetX = x;
pXSprite->targetY = y; pXSprite->targetY = y;
pXSprite->targetZ = z; pXSprite->targetZ = z;
@ -960,7 +960,7 @@ void aiSetTarget(XSPRITE *pXSprite, int nTarget)
{ {
if (sprite[pXSprite->reference].owner != nTarget) if (sprite[pXSprite->reference].owner != nTarget)
{ {
pXSprite->target = nTarget; pXSprite->target_i = nTarget;
DUDEINFO *pDudeInfo = getDudeInfo(pTarget->type); DUDEINFO *pDudeInfo = getDudeInfo(pTarget->type);
pXSprite->targetX = pTarget->x; pXSprite->targetX = pTarget->x;
pXSprite->targetY = pTarget->y; pXSprite->targetY = pTarget->y;
@ -986,12 +986,12 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
spritetype *pSource = &source->s(); spritetype *pSource = &source->s();
int nSource = pSource->index; int nSource = pSource->index;
if (pSprite == pSource) return 0; if (pSprite == pSource) return 0;
else if (pXSprite->target == -1) // if no target, give the dude a target else if (pXSprite->target_i == -1) // if no target, give the dude a target
{ {
aiSetTarget(pXSprite, nSource); aiSetTarget(pXSprite, nSource);
aiActivateDude(&bloodActors[pXSprite->reference]); aiActivateDude(&bloodActors[pXSprite->reference]);
} }
else if (nSource != pXSprite->target) // if found a new target, retarget else if (nSource != pXSprite->target_i) // if found a new target, retarget
{ {
int nThresh = nDamage; int nThresh = nDamage;
if (pSprite->type == pSource->type) if (pSprite->type == pSource->type)
@ -1683,8 +1683,8 @@ void aiInitSprite(spritetype *pSprite)
if (gModernMap) { if (gModernMap) {
// must keep it in case of loading save // must keep it in case of loading save
if (pXSprite->dudeFlag4 && spriRangeIsFine(pXSprite->target) && sprite[pXSprite->target].type == kMarkerPath) { if (pXSprite->dudeFlag4 && spriRangeIsFine(pXSprite->target_i) && sprite[pXSprite->target_i].type == kMarkerPath) {
stateTimer = pXSprite->stateTimer; targetMarker = pXSprite->target; stateTimer = pXSprite->stateTimer; targetMarker = pXSprite->target_i;
targetX = pXSprite->targetX; targetY = pXSprite->targetY; targetX = pXSprite->targetX; targetY = pXSprite->targetY;
targetZ = pXSprite->targetZ; targetZ = pXSprite->targetZ;
} }
@ -1919,7 +1919,7 @@ void aiInitSprite(spritetype *pSprite)
// restore dude's path // restore dude's path
if (spriRangeIsFine(targetMarker)) { if (spriRangeIsFine(targetMarker)) {
pXSprite->target = targetMarker; pXSprite->target_i = targetMarker;
pXSprite->targetX = targetX; pXSprite->targetX = targetX;
pXSprite->targetY = targetY; pXSprite->targetY = targetY;
pXSprite->targetZ = targetZ; pXSprite->targetZ = targetZ;
@ -1930,8 +1930,8 @@ void aiInitSprite(spritetype *pSprite)
// make dude follow the markers // make dude follow the markers
bool uwater = spriteIsUnderwater(pSprite); bool uwater = spriteIsUnderwater(pSprite);
if (pXSprite->target <= 0 || sprite[pXSprite->target].type != kMarkerPath) { if (pXSprite->target_i <= 0 || sprite[pXSprite->target_i].type != kMarkerPath) {
pXSprite->target = -1; aiPatrolSetMarker(pSprite, pXSprite); pXSprite->target_i = -1; aiPatrolSetMarker(pSprite, pXSprite);
} }
if (stateTimer > 0) { if (stateTimer > 0) {

View file

@ -66,7 +66,7 @@ void batBiteSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype *pSprite = &actor->s(); spritetype *pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int dx = CosScale16(pSprite->ang); int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang); int dy = SinScale16(pSprite->ang);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
@ -74,7 +74,7 @@ void batBiteSeqCallback(int, DBloodActor* actor)
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type); DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2; int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2; int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
actFireVector(actor, 0, 0, dx, dy, height2-height, kVectorBatBite); actFireVector(actor, 0, 0, dx, dy, height2-height, kVectorBatBite);
} }
@ -160,15 +160,15 @@ static void batThinkPonder(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &batSearch); aiNewState(actor, &batSearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -188,7 +188,7 @@ static void batThinkPonder(DBloodActor* actor)
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
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); 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)
@ -209,7 +209,7 @@ static void batThinkPonder(DBloodActor* actor)
} }
} }
aiNewState(actor, &batGoto); aiNewState(actor, &batGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void batMoveDodgeUp(DBloodActor* actor) static void batMoveDodgeUp(DBloodActor* actor)
@ -268,15 +268,15 @@ static void batThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &batGoto); aiNewState(actor, &batGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -304,7 +304,7 @@ static void batThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); 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); aiNewState(actor, &batBite);
@ -322,7 +322,7 @@ static void batThinkChase(DBloodActor* actor)
} }
} }
pXSprite->target = -1; pXSprite->target_i = -1;
aiNewState(actor, &batHide); aiNewState(actor, &batHide);
} }
@ -338,7 +338,7 @@ static void batMoveForward(DBloodActor* actor)
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -351,7 +351,7 @@ static void batMoveForward(DBloodActor* actor)
int vy = actor->yvel(); int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
t1 += nAccel; t1 += nAccel;
else else
t1 += nAccel>>1; t1 += nAccel>>1;

View file

@ -67,7 +67,7 @@ void SlashSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype *pSprite = &actor->s(); spritetype *pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int dx = CosScale16(pSprite->ang); int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang); int dy = SinScale16(pSprite->ang);
// Correct ? // Correct ?
@ -222,7 +222,7 @@ static void beastThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
int nXSector = sector[pSprite->sectnum].extra; int nXSector = sector[pSprite->sectnum].extra;
@ -238,8 +238,8 @@ static void beastThinkChase(DBloodActor* actor)
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -281,7 +281,7 @@ static void beastThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (pTarget->flags&2) if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (pTarget->flags&2)
&& IsPlayerSprite(pTarget) && Chance(0x8000)) && IsPlayerSprite(pTarget) && Chance(0x8000))
@ -378,7 +378,7 @@ static void beastThinkChase(DBloodActor* actor)
aiNewState(actor, &beastSwimGoto); aiNewState(actor, &beastSwimGoto);
else else
aiNewState(actor, &beastGoto); aiNewState(actor, &beastGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void beastThinkSwimGoto(DBloodActor* actor) static void beastThinkSwimGoto(DBloodActor* actor)
@ -401,15 +401,15 @@ static void beastThinkSwimChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &beastSwimGoto); aiNewState(actor, &beastSwimGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -435,7 +435,7 @@ static void beastThinkSwimChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x400 && abs(nDeltaAngle) < 85) if (nDist < 0x400 && abs(nDeltaAngle) < 85)
aiNewState(actor, &beastSwimSlash); aiNewState(actor, &beastSwimSlash);
else else
@ -450,7 +450,7 @@ static void beastThinkSwimChase(DBloodActor* actor)
return; return;
} }
aiNewState(actor, &beastSwimGoto); aiNewState(actor, &beastSwimGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void beastMoveForward(DBloodActor* actor) static void beastMoveForward(DBloodActor* actor)
@ -485,7 +485,7 @@ static void sub_628A0(DBloodActor* actor)
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -498,7 +498,7 @@ static void sub_628A0(DBloodActor* actor)
int vy = actor->yvel(); int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
t1 += nAccel; t1 += nAccel;
else else
t1 += nAccel>>2; t1 += nAccel>>2;
@ -512,7 +512,7 @@ static void sub_62AE0(DBloodActor* actor)
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight; int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight; int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
@ -549,7 +549,7 @@ static void sub_62D7C(DBloodActor* actor)
int nSprite = pSprite->index; int nSprite = pSprite->index;
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight; int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight; int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;

View file

@ -65,7 +65,7 @@ void eelBiteSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype *pSprite = &actor->s(); spritetype *pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int dx = CosScale16(pSprite->ang); int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang); int dy = SinScale16(pSprite->ang);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
@ -80,12 +80,12 @@ void eelBiteSeqCallback(int, DBloodActor* actor)
* copied from lines 177:181 * copied from lines 177:181
* resolves this case, but may cause other issues? * resolves this case, but may cause other issues?
*/ */
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
return; return;
} }
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
actFireVector(actor, 0, 0, dx, dy, height2-height, kVectorBoneelBite); actFireVector(actor, 0, 0, dx, dy, height2-height, kVectorBoneelBite);
} }
@ -173,15 +173,15 @@ static void eelThinkPonder(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -201,7 +201,7 @@ static void eelThinkPonder(DBloodActor* actor)
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
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); 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)
@ -222,7 +222,7 @@ static void eelThinkPonder(DBloodActor* actor)
} }
} }
aiNewState(actor, &eelGoto); aiNewState(actor, &eelGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void eelMoveDodgeUp(DBloodActor* actor) static void eelMoveDodgeUp(DBloodActor* actor)
@ -281,15 +281,15 @@ static void eelThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &eelGoto); aiNewState(actor, &eelGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -317,7 +317,7 @@ static void eelThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x399 && top2 > top && abs(nDeltaAngle) < 85) if (nDist < 0x399 && top2 > top && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelSwoop); aiNewState(actor, &eelSwoop);
else if (nDist <= 0x399 && abs(nDeltaAngle) < 85) else if (nDist <= 0x399 && abs(nDeltaAngle) < 85)
@ -331,7 +331,7 @@ static void eelThinkChase(DBloodActor* actor)
return; return;
} }
pXSprite->target = -1; pXSprite->target_i = -1;
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
} }
@ -347,7 +347,7 @@ static void eelMoveForward(DBloodActor* actor)
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2; int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -360,7 +360,7 @@ static void eelMoveForward(DBloodActor* actor)
int vy = actor->yvel(); int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
t1 += nAccel; t1 += nAccel;
else else
t1 += nAccel>>1; t1 += nAccel>>1;

View file

@ -130,7 +130,7 @@ static void burnThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
switch (pSprite->type) switch (pSprite->type)
{ {
@ -162,8 +162,8 @@ static void burnThinkChase(DBloodActor* actor)
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -207,7 +207,7 @@ static void burnThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x333 && abs(nDeltaAngle) < 85) if (nDist < 0x333 && abs(nDeltaAngle) < 85)
{ {
switch (pSprite->type) switch (pSprite->type)
@ -268,7 +268,7 @@ static void burnThinkChase(DBloodActor* actor)
break; break;
#endif #endif
} }
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -121,7 +121,7 @@ static void calebThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
int nXSector = sector[pSprite->sectnum].extra; int nXSector = sector[pSprite->sectnum].extra;
@ -137,8 +137,8 @@ static void calebThinkChase(DBloodActor* actor)
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -183,7 +183,7 @@ static void calebThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 0x599 && abs(nDeltaAngle) < 28) if (nDist < 0x599 && abs(nDeltaAngle) < 28)
{ {
@ -243,7 +243,7 @@ static void calebThinkChase(DBloodActor* actor)
aiNewState(actor, &tinycalebGoto); aiNewState(actor, &tinycalebGoto);
if (Chance(0x2000)) if (Chance(0x2000))
sfxPlay3DSound(pSprite, 10000 + Random(5), -1, 0); sfxPlay3DSound(pSprite, 10000 + Random(5), -1, 0);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void calebThinkSwimGoto(DBloodActor* actor) static void calebThinkSwimGoto(DBloodActor* actor)
@ -266,15 +266,15 @@ static void calebThinkSwimChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &tinycalebSwimGoto); aiNewState(actor, &tinycalebSwimGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -300,7 +300,7 @@ static void calebThinkSwimChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x400 && abs(nDeltaAngle) < 85) if (nDist < 0x400 && abs(nDeltaAngle) < 85)
aiNewState(actor, &tinycalebSwimAttack); aiNewState(actor, &tinycalebSwimAttack);
else else
@ -310,7 +310,7 @@ static void calebThinkSwimChase(DBloodActor* actor)
return; return;
} }
aiNewState(actor, &tinycalebSwimGoto); aiNewState(actor, &tinycalebSwimGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void sub_65D04(DBloodActor* actor) static void sub_65D04(DBloodActor* actor)
@ -326,7 +326,7 @@ static void sub_65D04(DBloodActor* actor)
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -339,7 +339,7 @@ static void sub_65D04(DBloodActor* actor)
int vy = yvel[nSprite]; int vy = yvel[nSprite];
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
t1 += nAccel; t1 += nAccel;
else else
t1 += nAccel>>2; t1 += nAccel>>2;
@ -354,7 +354,7 @@ static void sub_65F44(DBloodActor* actor)
int nSprite = pSprite->index; int nSprite = pSprite->index;
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight; int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight; int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
@ -391,7 +391,7 @@ static void sub_661E0(DBloodActor* actor)
int nSprite = pSprite->index; int nSprite = pSprite->index;
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight; int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight; int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;

View file

@ -68,11 +68,11 @@ void cerberusBiteSeqCallback(int, DBloodActor* actor)
return; return;
} }
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int dz = pTarget->z-pSprite->z; int dz = pTarget->z-pSprite->z;
actFireVector(actor, 350, -100, dx, dy, dz, kVectorCerberusHack); actFireVector(actor, 350, -100, dx, dy, dz, kVectorCerberusHack);
actFireVector(actor, -350, 0, dx, dy, dz, kVectorCerberusHack); actFireVector(actor, -350, 0, dx, dy, dz, kVectorCerberusHack);
@ -86,7 +86,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = pDudeInfo->eyeHeight*pSprite->yrepeat; int height = pDudeInfo->eyeHeight*pSprite->yrepeat;
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
return; return;
} }
@ -166,7 +166,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
return; return;
} }
@ -351,7 +351,7 @@ static void cerberusThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) { if (pXSprite->target_i == -1) {
switch (pSprite->type) { switch (pSprite->type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusGoto); aiNewState(actor, &cerberusGoto);
@ -372,11 +372,11 @@ static void cerberusThinkChase(DBloodActor* actor)
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -414,7 +414,7 @@ static void cerberusThinkChase(DBloodActor* actor)
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) 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) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x1b00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) { if (nDist < 0x1b00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) {
switch (pSprite->type) { switch (pSprite->type) {
@ -490,7 +490,7 @@ static void cerberusThinkChase(DBloodActor* actor)
aiNewState(actor, &cerberus2Goto); aiNewState(actor, &cerberus2Goto);
break; break;
} }
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -136,8 +136,8 @@ void cultThrowSeqCallback(int, DBloodActor* actor)
nMissile = kThingArmedTNTBundle; nMissile = kThingArmedTNTBundle;
char v4 = Chance(0x6000); char v4 = Chance(0x6000);
sfxPlay3DSound(pSprite, 455, -1, 0); sfxPlay3DSound(pSprite, 455, -1, 0);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
int dx = pTarget->x - pSprite->x; int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y; int dy = pTarget->y - pSprite->y;
@ -173,8 +173,8 @@ void sub_68230(int, DBloodActor* actor)
if (gGameOptions.nDifficulty > 2) if (gGameOptions.nDifficulty > 2)
nMissile = kThingArmedTNTBundle; nMissile = kThingArmedTNTBundle;
sfxPlay3DSound(pSprite, 455, -1, 0); sfxPlay3DSound(pSprite, 455, -1, 0);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
int dx = pTarget->x - pSprite->x; int dx = pTarget->x - pSprite->x;
int dy = pTarget->y - pSprite->y; int dy = pTarget->y - pSprite->y;
@ -236,7 +236,7 @@ static void cultThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -252,8 +252,8 @@ static void cultThinkChase(DBloodActor* actor)
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -299,7 +299,7 @@ static void cultThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
switch (pSprite->type) { switch (pSprite->type) {
case kDudeCultistTommy: case kDudeCultistTommy:
@ -633,7 +633,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistSwimGoto); aiNewState(actor, &cultistSwimGoto);
break; break;
} }
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -81,7 +81,7 @@ void SlashFSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type); DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2; int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
@ -110,7 +110,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
wrand(); // ??? wrand(); // ???
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int height = (pSprite->yrepeat*getDudeInfo(pSprite->type)->eyeHeight) << 2; int height = (pSprite->yrepeat*getDudeInfo(pSprite->type)->eyeHeight) << 2;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -355,7 +355,7 @@ static void gargThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &gargoyleFGoto); aiNewState(actor, &gargoyleFGoto);
return; return;
@ -367,11 +367,11 @@ static void gargThinkChase(DBloodActor* actor)
} }
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -399,7 +399,7 @@ static void gargThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
switch (pSprite->type) { switch (pSprite->type) {
case kDudeGargoyleFlesh: case kDudeGargoyleFlesh:
@ -530,7 +530,7 @@ static void gargThinkChase(DBloodActor* actor)
} }
aiNewState(actor, &gargoyleFGoto); aiNewState(actor, &gargoyleFGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void entryFStatue(DBloodActor* actor) static void entryFStatue(DBloodActor* actor)
@ -565,7 +565,7 @@ static void gargMoveForward(DBloodActor* actor)
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -578,7 +578,7 @@ static void gargMoveForward(DBloodActor* actor)
int vy = actor->yvel(); int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
t1 += nAccel; t1 += nAccel;
else else
t1 += nAccel>>1; t1 += nAccel>>1;

View file

@ -65,7 +65,7 @@ void ghostSlashSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type); DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2; int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
@ -93,7 +93,7 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
wrand(); // ??? wrand(); // ???
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int height = (pSprite->yrepeat*getDudeInfo(pSprite->type)->eyeHeight) << 2; int height = (pSprite->yrepeat*getDudeInfo(pSprite->type)->eyeHeight) << 2;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -333,7 +333,7 @@ static void ghostThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &ghostGoto); aiNewState(actor, &ghostGoto);
return; return;
@ -344,12 +344,12 @@ static void ghostThinkChase(DBloodActor* actor)
return; return;
} }
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -377,7 +377,7 @@ static void ghostThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
switch (pSprite->type) { switch (pSprite->type) {
case kDudePhantasm: case kDudePhantasm:
@ -440,7 +440,7 @@ static void ghostThinkChase(DBloodActor* actor)
} }
aiNewState(actor, &ghostGoto); aiNewState(actor, &ghostGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void ghostMoveForward(DBloodActor* actor) static void ghostMoveForward(DBloodActor* actor)
@ -459,7 +459,7 @@ static void ghostMoveForward(DBloodActor* actor)
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -472,7 +472,7 @@ static void ghostMoveForward(DBloodActor* actor)
int vy = actor->yvel(); int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
t1 += nAccel; t1 += nAccel;
else else
t1 += nAccel>>1; t1 += nAccel>>1;

View file

@ -62,7 +62,7 @@ void GillBiteSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int dx = CosScale16(pSprite->ang); int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang); int dy = SinScale16(pSprite->ang);
int dz = pSprite->z-pTarget->z; int dz = pSprite->z-pTarget->z;
@ -112,7 +112,7 @@ static void gillThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
int nXSector = sector[pSprite->sectnum].extra; int nXSector = sector[pSprite->sectnum].extra;
@ -128,8 +128,8 @@ static void gillThinkChase(DBloodActor* actor)
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -171,7 +171,7 @@ static void gillThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 921 && abs(nDeltaAngle) < 28) if (nDist < 921 && abs(nDeltaAngle) < 28)
{ {
@ -230,7 +230,7 @@ static void gillThinkChase(DBloodActor* actor)
else else
aiNewState(actor, &gillBeastGoto); aiNewState(actor, &gillBeastGoto);
sfxPlay3DSound(pSprite, 1701, -1, 0); sfxPlay3DSound(pSprite, 1701, -1, 0);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void gillThinkSwimGoto(DBloodActor* actor) static void gillThinkSwimGoto(DBloodActor* actor)
@ -253,15 +253,15 @@ static void gillThinkSwimChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -287,7 +287,7 @@ static void gillThinkSwimChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x400 && abs(nDeltaAngle) < 85) if (nDist < 0x400 && abs(nDeltaAngle) < 85)
aiNewState(actor, &gillBeastSwimBite); aiNewState(actor, &gillBeastSwimBite);
else else
@ -302,7 +302,7 @@ static void gillThinkSwimChase(DBloodActor* actor)
return; return;
} }
aiNewState(actor, &gillBeastSwimGoto); aiNewState(actor, &gillBeastSwimGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void sub_6CB00(DBloodActor* actor) static void sub_6CB00(DBloodActor* actor)
@ -318,7 +318,7 @@ static void sub_6CB00(DBloodActor* actor)
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2; int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -331,7 +331,7 @@ static void sub_6CB00(DBloodActor* actor)
int vy = actor->yvel(); int vy = actor->yvel();
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
t1 += nAccel; t1 += nAccel;
else else
t1 += nAccel>>2; t1 += nAccel>>2;
@ -345,7 +345,7 @@ static void sub_6CD74(DBloodActor* actor)
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight; int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight; int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
@ -381,7 +381,7 @@ static void sub_6D03C(DBloodActor* actor)
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight; int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight; int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;

View file

@ -46,7 +46,7 @@ void HandJumpSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
if (IsPlayerSprite(pTarget)) if (IsPlayerSprite(pTarget))
{ {
PLAYER *pPlayer = &gPlayer[pTarget->type-kDudePlayer1]; PLAYER *pPlayer = &gPlayer[pTarget->type-kDudePlayer1];
@ -86,15 +86,15 @@ static void handThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &handGoto); aiNewState(actor, &handGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -118,7 +118,7 @@ static void handThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x233 && abs(nDeltaAngle) < 85 && gGameOptions.nGameType == 0) if (nDist < 0x233 && abs(nDeltaAngle) < 85 && gGameOptions.nGameType == 0)
aiNewState(actor, &handJump); aiNewState(actor, &handJump);
return; return;
@ -127,7 +127,7 @@ static void handThinkChase(DBloodActor* actor)
} }
aiNewState(actor, &handGoto); aiNewState(actor, &handGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -55,12 +55,12 @@ void houndBiteSeqCallback(int, DBloodActor* actor)
return; return;
} }
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
if (IsPlayerSprite(pTarget) || gModernMap) // allow to hit non-player targets if (IsPlayerSprite(pTarget) || gModernMap) // allow to hit non-player targets
actFireVector(actor, 0, 0, dx, dy, pTarget->z - pSprite->z, kVectorHoundBite); actFireVector(actor, 0, 0, dx, dy, pTarget->z - pSprite->z, kVectorHoundBite);
@ -109,7 +109,7 @@ static void houndThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &houndGoto); aiNewState(actor, &houndGoto);
return; return;
@ -120,12 +120,12 @@ static void houndThinkChase(DBloodActor* actor)
return; return;
} }
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -149,7 +149,7 @@ static void houndThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85) if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85)
aiNewState(actor, &houndBurn); aiNewState(actor, &houndBurn);
else if(nDist < 0x266 && abs(nDeltaAngle) < 85) else if(nDist < 0x266 && abs(nDeltaAngle) < 85)
@ -160,7 +160,7 @@ static void houndThinkChase(DBloodActor* actor)
} }
aiNewState(actor, &houndGoto); aiNewState(actor, &houndGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -69,15 +69,15 @@ static void innocThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &innocentGoto); aiNewState(actor, &innocentGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -101,7 +101,7 @@ static void innocThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x666 && abs(nDeltaAngle) < 85) if (nDist < 0x666 && abs(nDeltaAngle) < 85)
aiNewState(actor, &innocentIdle); aiNewState(actor, &innocentIdle);
return; return;
@ -111,7 +111,7 @@ static void innocThinkChase(DBloodActor* actor)
aiPlay3DSound(pSprite, 7000+Random(6), AI_SFX_PRIORITY_1, -1); aiPlay3DSound(pSprite, 7000+Random(6), AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &innocentGoto); aiNewState(actor, &innocentGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }

View file

@ -65,13 +65,13 @@ void podAttack(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
@ -182,7 +182,7 @@ static void aiPodChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) { if (pXSprite->target_i == -1) {
switch (pSprite->type) { switch (pSprite->type) {
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
@ -201,12 +201,12 @@ static void aiPodChase(DBloodActor* actor)
return; return;
} }
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -234,7 +234,7 @@ static void aiPodChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (abs(nDeltaAngle) < 85 && pTarget->type != kDudePodGreen && pTarget->type != kDudePodFire) { if (abs(nDeltaAngle) < 85 && pTarget->type != kDudePodGreen && pTarget->type != kDudePodFire) {
switch (pSprite->type) { switch (pSprite->type) {
case kDudePodGreen: case kDudePodGreen:
@ -262,7 +262,7 @@ static void aiPodChase(DBloodActor* actor)
aiNewState(actor, &tentacleMove); aiNewState(actor, &tentacleMove);
break; break;
} }
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -49,8 +49,8 @@ void ratBiteSeqCallback(int, DBloodActor* actor)
int dx = CosScale16(pSprite->ang); int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang); int dy = SinScale16(pSprite->ang);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
if (IsPlayerSprite(pTarget)) 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);
} }
@ -83,15 +83,15 @@ static void ratThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &ratGoto); aiNewState(actor, &ratGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -115,7 +115,7 @@ static void ratThinkChase(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x399 && abs(nDeltaAngle) < 85) if (nDist < 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &ratBite); aiNewState(actor, &ratBite);
return; return;
@ -124,7 +124,7 @@ static void ratThinkChase(DBloodActor* actor)
} }
aiNewState(actor, &ratGoto); aiNewState(actor, &ratGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -73,8 +73,8 @@ void SpidBiteSeqCallback(int, DBloodActor* actor)
dy += Random2(2000); dy += Random2(2000);
int dz = Random2(2000); int dz = Random2(2000);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
if (IsPlayerSprite(pTarget)) { if (IsPlayerSprite(pTarget)) {
@ -122,8 +122,8 @@ void SpidJumpSeqCallback(int, DBloodActor* actor)
dy += Random2(200); dy += Random2(200);
int dz = Random2(200); int dz = Random2(200);
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
if (IsPlayerSprite(pTarget)) { if (IsPlayerSprite(pTarget)) {
dz += pTarget->z-pSprite->z; dz += pTarget->z-pSprite->z;
switch (pSprite->type) { switch (pSprite->type) {
@ -144,8 +144,8 @@ void SpidBirthSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -200,15 +200,15 @@ static void spidThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &spidGoto); aiNewState(actor, &spidGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -229,7 +229,7 @@ static void spidThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; 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 (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) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
switch (pSprite->type) { switch (pSprite->type) {
case kDudeSpiderRed: case kDudeSpiderRed:
@ -257,7 +257,7 @@ static void spidThinkChase(DBloodActor* actor)
} }
aiNewState(actor, &spidGoto); aiNewState(actor, &spidGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -50,7 +50,7 @@ void sub_71A90(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int nTarget = pTarget->index; int nTarget = pTarget->index;
int nOwner = pSprite->owner; int nOwner = pSprite->owner;
@ -67,9 +67,9 @@ void sub_71BD4(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = pSprite->yrepeat*pDudeInfo->eyeHeight; int height = pSprite->yrepeat*pDudeInfo->eyeHeight;
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites");
return; return;
} }
int x = pSprite->x; int x = pSprite->x;
@ -140,9 +140,9 @@ void sub_720AC(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites");
return; return;
} }
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
@ -306,7 +306,7 @@ static void sub_72934(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &tcherno13A9B8); aiNewState(actor, &tcherno13A9B8);
return; return;
@ -317,12 +317,12 @@ static void sub_72934(DBloodActor* actor)
return; return;
} }
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); ///assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) { if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites)) {
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites"); Printf(PRINT_HIGH, "pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites");
return; return;
} }
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -346,7 +346,7 @@ static void sub_72934(DBloodActor* actor)
{ {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x1f00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) if (nDist < 0x1f00 && nDist > 0xd00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &tcherno13AA0C); aiNewState(actor, &tcherno13AA0C);
else if (nDist < 0xd00 && nDist > 0xb00 && abs(nDeltaAngle) < 85) else if (nDist < 0xd00 && nDist > 0xb00 && abs(nDeltaAngle) < 85)
@ -359,7 +359,7 @@ static void sub_72934(DBloodActor* actor)
} }
aiNewState(actor, &tcherno13A9B8); aiNewState(actor, &tcherno13A9B8);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -130,7 +130,7 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int
{ {
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
if (spriRangeIsFine(pXSprite->target)) if (spriRangeIsFine(pXSprite->target_i))
{ {
int fStart = 0; int fStart = 0;
int fEnd = 0; int fEnd = 0;
@ -140,8 +140,8 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int
for (int i = -8191; i < 8192; i += by) for (int i = -8191; i < 8192; i += by)
{ {
HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), i, clipMask, dist); HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), i, clipMask, dist);
if (!fStart && pXSprite->target == gHitInfo.hitsprite) fStart = i; if (!fStart && pXSprite->target_i == gHitInfo.hitsprite) fStart = i;
else if (fStart && pXSprite->target != gHitInfo.hitsprite) else if (fStart && pXSprite->target_i != gHitInfo.hitsprite)
{ {
fEnd = i; fEnd = i;
break; break;
@ -183,12 +183,12 @@ void punchCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (pXSprite->target != -1) if (pXSprite->target_i != -1)
{ {
int nZOffset1 = getDudeInfo(pSprite->type)->eyeHeight * pSprite->yrepeat << 2; int nZOffset1 = getDudeInfo(pSprite->type)->eyeHeight * pSprite->yrepeat << 2;
int nZOffset2 = 0; int nZOffset2 = 0;
spritetype* pTarget = &sprite[pXSprite->target]; spritetype* pTarget = &sprite[pXSprite->target_i];
if(IsDudeSprite(pTarget)) if(IsDudeSprite(pTarget))
nZOffset2 = getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat << 2; nZOffset2 = getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat << 2;
@ -208,7 +208,7 @@ void genDudeAttack1(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (pXSprite->target < 0) return; if (pXSprite->target_i < 0) return;
int dx, dy, dz; int dx, dy, dz;
xvel[pSprite->index] = yvel[pSprite->index] = 0; xvel[pSprite->index] = yvel[pSprite->index] = 0;
@ -241,8 +241,8 @@ void genDudeAttack1(int, DBloodActor* actor)
pSpawned->owner = pSprite->index; pSpawned->owner = pSprite->index;
if (xspriRangeIsFine(pSpawned->extra)) { if (xspriRangeIsFine(pSpawned->extra)) {
xsprite[pSpawned->extra].target = pXSprite->target; xsprite[pSpawned->extra].target_i = pXSprite->target_i;
if (pXSprite->target > -1) if (pXSprite->target_i > -1)
aiActivateDude(&bloodActors[pSpawned->index]); aiActivateDude(&bloodActors[pSpawned->index]);
} }
@ -281,10 +281,10 @@ static void ThrowThing(DBloodActor* actor, bool impact)
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) if (!(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites))
return; return;
spritetype * pTarget = &sprite[pXSprite->target]; spritetype * pTarget = &sprite[pXSprite->target_i];
if (!(pTarget->type >= kDudeBase && pTarget->type < kDudeMax)) if (!(pTarget->type >= kDudeBase && pTarget->type < kDudeMax))
return; return;
@ -363,7 +363,7 @@ static void ThrowThing(DBloodActor* actor, bool impact)
pThing->cstat &= ~CSTAT_SPRITE_BLOCK; pThing->cstat &= ~CSTAT_SPRITE_BLOCK;
pThing->pal = 6; pThing->pal = 6;
pThing->clipdist = 0; pThing->clipdist = 0;
pXThing->target = pTarget->index; pXThing->target_i = pTarget->index;
pXThing->Proximity = true; pXThing->Proximity = true;
pXThing->stateTimer = 1; pXThing->stateTimer = 1;
@ -418,7 +418,7 @@ static void unicultThinkChase(DBloodActor* actor)
auto const pXSprite = &actor->x(); auto const pXSprite = &actor->x();
auto const pSprite = &actor->s(); auto const pSprite = &actor->s();
if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) return; if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) return;
else if (pXSprite->target < 0 || pXSprite->target >= kMaxSprites) { else if (pXSprite->target_i < 0 || pXSprite->target_i >= kMaxSprites) {
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeGotoW); if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
else aiGenDudeNewState(pSprite, &genDudeGotoL); else aiGenDudeNewState(pSprite, &genDudeGotoL);
return; return;
@ -428,13 +428,13 @@ static void unicultThinkChase(DBloodActor* actor)
} }
spritetype* pTarget = &sprite[pXSprite->target]; spritetype* pTarget = &sprite[pXSprite->target_i];
XSPRITE* pXTarget = (!IsDudeSprite(pTarget) || !xspriRangeIsFine(pTarget->extra)) ? NULL : &xsprite[pTarget->extra]; XSPRITE* pXTarget = (!IsDudeSprite(pTarget) || !xspriRangeIsFine(pTarget->extra)) ? NULL : &xsprite[pTarget->extra];
if (pXTarget == NULL) { // target lost if (pXTarget == NULL) { // target lost
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW); if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW);
else aiGenDudeNewState(pSprite, &genDudeSearchShortL); else aiGenDudeNewState(pSprite, &genDudeSearchShortL);
pXSprite->target = -1; pXSprite->target_i = -1;
return; return;
} else if (pXTarget->health <= 0) { // target is dead } else if (pXTarget->health <= 0) { // target is dead
@ -446,7 +446,7 @@ static void unicultThinkChase(DBloodActor* actor)
} }
else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeGotoW); else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
else aiGenDudeNewState(pSprite, &genDudeGotoL); else aiGenDudeNewState(pSprite, &genDudeGotoL);
pXSprite->target = -1; pXSprite->target_i = -1;
return; return;
} }
@ -475,7 +475,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (powerupCheck(pPlayer, kPwUpShadowCloak) > 0) { if (powerupCheck(pPlayer, kPwUpShadowCloak) > 0) {
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW); if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW);
else aiGenDudeNewState(pSprite, &genDudeSearchShortL); else aiGenDudeNewState(pSprite, &genDudeSearchShortL);
pXSprite->target = -1; pXSprite->target_i = -1;
return; return;
} }
} }
@ -489,7 +489,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW); if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW);
else aiGenDudeNewState(pSprite, &genDudeSearchL); else aiGenDudeNewState(pSprite, &genDudeSearchL);
pXSprite->target = -1; pXSprite->target_i = -1;
return; return;
} }
@ -533,7 +533,7 @@ static void unicultThinkChase(DBloodActor* actor)
XSPRITE* pXLeech = &xsprite[pLeech->extra]; XSPRITE* pXLeech = &xsprite[pLeech->extra];
int ldist = aiFightGetTargetDist(pTarget, pDudeInfo, pLeech); int ldist = aiFightGetTargetDist(pTarget, pDudeInfo, pLeech);
if (ldist > 3 || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, if (ldist > 3 || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum,
pLeech->x, pLeech->y, pLeech->z, pLeech->sectnum) || pXLeech->target == -1) { pLeech->x, pLeech->y, pLeech->z, pLeech->sectnum) || pXLeech->target_i == -1) {
aiGenDudeNewState(pSprite, &genDudeThrow2); aiGenDudeNewState(pSprite, &genDudeThrow2);
genDudeThrow2.nextState = &genDudeDodgeShortL; genDudeThrow2.nextState = &genDudeDodgeShortL;
@ -595,7 +595,7 @@ static void unicultThinkChase(DBloodActor* actor)
} else if (weaponType == kGenDudeWeaponSummon) { } else if (weaponType == kGenDudeWeaponSummon) {
// don't attack slaves // don't attack slaves
if (pXSprite->target >= 0 && sprite[pXSprite->target].owner == pSprite->index) { if (pXSprite->target_i >= 0 && sprite[pXSprite->target_i].owner == pSprite->index) {
aiSetTarget(pXSprite, pSprite->x, pSprite->y, pSprite->z); aiSetTarget(pXSprite, pSprite->x, pSprite->y, pSprite->z);
return; return;
} else if (gGenDudeExtra[pSprite->index].slaveCount > gGameOptions.nDifficulty || dist < meleeVector->maxDist) { } else if (gGenDudeExtra[pSprite->index].slaveCount > gGameOptions.nDifficulty || dist < meleeVector->maxDist) {
@ -677,7 +677,7 @@ static void unicultThinkChase(DBloodActor* actor)
objDist = approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y); objDist = approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y);
} }
if (pXSprite->target != gHitInfo.hitsprite && targetDist > objDist) { if (pXSprite->target_i != gHitInfo.hitsprite && targetDist > objDist) {
walltype* pHWall = NULL; XWALL* pXHWall = NULL; walltype* pHWall = NULL; XWALL* pXHWall = NULL;
spritetype* pHSprite = NULL; XSPRITE* pXHSprite = NULL; spritetype* pHSprite = NULL; XSPRITE* pXHSprite = NULL;
bool hscn = false; bool blck = false; bool failed = false; bool hscn = false; bool blck = false; bool failed = false;
@ -716,7 +716,7 @@ static void unicultThinkChase(DBloodActor* actor)
break; break;
if (IsDudeSprite(pHSprite) && (weaponType != kGenDudeWeaponHitscan || hscn)) { if (IsDudeSprite(pHSprite) && (weaponType != kGenDudeWeaponHitscan || hscn)) {
// dodge a bit in sides // dodge a bit in sides
if (pXHSprite->target != pSprite->index) { if (pXHSprite->target_i != pSprite->index) {
if (pExtra->baseDispersion < 1024 && weaponType != kGenDudeWeaponMissile) { if (pExtra->baseDispersion < 1024 && weaponType != kGenDudeWeaponMissile) {
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeDodgeShorterW); if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeDodgeShorterW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(pSprite, &genDudeDodgeShorterD); else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(pSprite, &genDudeDodgeShorterD);
@ -774,7 +774,7 @@ static void unicultThinkChase(DBloodActor* actor)
{ {
if (genDudeAdjustSlope(actor, dist, weaponType)) break; if (genDudeAdjustSlope(actor, dist, weaponType)) break;
VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope, dist, 1); VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope, dist, 1);
if (pXSprite->target == gHitInfo.hitsprite) break; if (pXSprite->target_i == gHitInfo.hitsprite) break;
bool immune = nnExtIsImmune(pHSprite, gVectorData[curWeapon].dmgType); bool immune = nnExtIsImmune(pHSprite, gVectorData[curWeapon].dmgType);
if (!(pXHSprite != NULL && (!immune || (immune && pHSprite->statnum == kStatThing && pXHSprite->Vector)) && !pXHSprite->locked)) if (!(pXHSprite != NULL && (!immune || (immune && pHSprite->statnum == kStatThing && pXHSprite->Vector)) && !pXHSprite->locked))
@ -828,7 +828,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (masked) VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope, dist, 1); if (masked) VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope, dist, 1);
//viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall); //viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall);
if ((pXSprite->target != gHitInfo.hitsprite) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) { if ((pXSprite->target_i != gHitInfo.hitsprite) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) {
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW); if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL); else aiGenDudeNewState(pSprite, &genDudeChaseL);
return; return;
@ -880,7 +880,7 @@ static void unicultThinkChase(DBloodActor* actor)
} }
} }
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
switch (state) { switch (state) {
case 1: case 1:
aiGenDudeNewState(pSprite, &genDudeFireW); aiGenDudeNewState(pSprite, &genDudeFireW);
@ -999,7 +999,7 @@ void aiGenDudeMoveForward(DBloodActor* actor)
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (abs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
pSprite->ang = (pSprite->ang + 256) & 2047; pSprite->ang = (pSprite->ang + 256) & 2047;
int dx = pXSprite->targetX - pSprite->x; int dx = pXSprite->targetX - pSprite->x;
int dy = pXSprite->targetY - pSprite->y; int dy = pXSprite->targetY - pSprite->y;
@ -1012,7 +1012,7 @@ void aiGenDudeMoveForward(DBloodActor* actor)
int vy = yvel[pSprite->index]; int vy = yvel[pSprite->index];
int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t1 = DMulScale(vx, nCos, vy, nSin, 30);
int t2 = DMulScale(vx, nSin, -vy, nCos, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
t1 += nAccel; t1 += nAccel;
else else
t1 += nAccel >> 1; t1 += nAccel >> 1;
@ -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, pSprite->ang + vc, vsi)) if (CanMove(actor, pXSprite->target_i, pSprite->ang + vc, vsi))
pXSprite->goalAng = pSprite->ang + vc; pXSprite->goalAng = pSprite->ang + vc;
else if (CanMove(actor, pXSprite->target, pSprite->ang + vc / 2, vsi)) else if (CanMove(actor, pXSprite->target_i, pSprite->ang + vc / 2, vsi))
pXSprite->goalAng = pSprite->ang + vc / 2; pXSprite->goalAng = pSprite->ang + vc / 2;
else if (CanMove(actor, pXSprite->target, pSprite->ang - vc / 2, vsi)) else if (CanMove(actor, pXSprite->target_i, pSprite->ang - vc / 2, vsi))
pXSprite->goalAng = pSprite->ang - vc / 2; pXSprite->goalAng = pSprite->ang - vc / 2;
else if (CanMove(actor, pXSprite->target, pSprite->ang + v8, vsi)) else if (CanMove(actor, pXSprite->target_i, pSprite->ang + v8, vsi))
pXSprite->goalAng = pSprite->ang + v8; pXSprite->goalAng = pSprite->ang + v8;
else if (CanMove(actor, pXSprite->target, pSprite->ang, vsi)) else if (CanMove(actor, pXSprite->target_i, pSprite->ang, vsi))
pXSprite->goalAng = pSprite->ang; pXSprite->goalAng = pSprite->ang;
else if (CanMove(actor, pXSprite->target, pSprite->ang - v8, vsi)) else if (CanMove(actor, pXSprite->target_i, 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, pSprite->ang + pXSprite->dodgeDir * 512, 512)) { if (!CanMove(actor, pXSprite->target_i, pSprite->ang + pXSprite->dodgeDir * 512, 512)) {
pXSprite->dodgeDir = -pXSprite->dodgeDir; pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!CanMove(actor, pXSprite->target, pSprite->ang + pXSprite->dodgeDir * 512, 512)) if (!CanMove(actor, pXSprite->target_i, pSprite->ang + pXSprite->dodgeDir * 512, 512))
pXSprite->dodgeDir = 0; pXSprite->dodgeDir = 0;
} }
} }
@ -1551,7 +1551,7 @@ void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT event)
return; return;
} }
int nTarget = pXSprite->target; int nTarget = pXSprite->target_i;
if (spriRangeIsFine(nTarget) && nTarget != pSprite->owner) { if (spriRangeIsFine(nTarget) && nTarget != pSprite->owner) {
spritetype* pTarget = &sprite[nTarget]; spritetype* pTarget = &sprite[nTarget];
if (pTarget->statnum == kStatDude && !(pTarget->flags & 32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites && !pXSprite->stateTimer) { if (pTarget->statnum == kStatDude && !(pTarget->flags & 32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites && !pXSprite->stateTimer) {
@ -1810,7 +1810,7 @@ void genDudeTransform(spritetype* pSprite) {
seqSpawn(seqId, 3, pSprite->extra, -1); seqSpawn(seqId, 3, pSprite->extra, -1);
// save target // save target
int target = pXSprite->target; int target = pXSprite->target_i;
// re-init sprite // re-init sprite
aiInitSprite(pSprite); aiInitSprite(pSprite);
@ -1848,14 +1848,14 @@ void updateTargetOfLeech(spritetype* pSprite) {
spritetype* pLeech = leechIsDropped(pSprite); spritetype* pLeech = leechIsDropped(pSprite);
if (pLeech == NULL || pLeech->extra < 0) gGenDudeExtra[pSprite->index].nLifeLeech = -1; if (pLeech == NULL || pLeech->extra < 0) gGenDudeExtra[pSprite->index].nLifeLeech = -1;
else if (xsprite[pSprite->extra].target != xsprite[pLeech->extra].target) { else if (xsprite[pSprite->extra].target_i != xsprite[pLeech->extra].target_i) {
XSPRITE* pXDude = &xsprite[pSprite->extra]; XSPRITE* pXLeech = &xsprite[pLeech->extra]; XSPRITE* pXDude = &xsprite[pSprite->extra]; XSPRITE* pXLeech = &xsprite[pLeech->extra];
if (pXDude->target < 0 && spriRangeIsFine(pXLeech->target)) { if (pXDude->target_i < 0 && spriRangeIsFine(pXLeech->target_i)) {
aiSetTarget(pXDude, pXLeech->target); aiSetTarget(pXDude, pXLeech->target_i);
if (inIdle(pXDude->aiState)) if (inIdle(pXDude->aiState))
aiActivateDude(&bloodActors[pXDude->reference]); aiActivateDude(&bloodActors[pXDude->reference]);
} else { } else {
pXLeech->target = pXDude->target; pXLeech->target_i = pXDude->target_i;
} }
} }
} }
@ -1868,7 +1868,7 @@ void updateTargetOfSlaves(spritetype* pSprite) {
XSPRITE* pXSprite = &xsprite[pSprite->extra]; XSPRITE* pXSprite = &xsprite[pSprite->extra];
GENDUDEEXTRA* pExtra = genDudeExtra(pSprite); short* slave = pExtra->slave; GENDUDEEXTRA* pExtra = genDudeExtra(pSprite); short* slave = pExtra->slave;
spritetype* pTarget = (pXSprite->target >= 0 && IsDudeSprite(&sprite[pXSprite->target])) ? &sprite[pXSprite->target] : NULL; spritetype* pTarget = (pXSprite->target_i >= 0 && IsDudeSprite(&sprite[pXSprite->target_i])) ? &sprite[pXSprite->target_i] : NULL;
XSPRITE* pXTarget = (pTarget != NULL && xspriRangeIsFine(pTarget->extra) && xsprite[pTarget->extra].health > 0) ? &xsprite[pTarget->extra] : NULL; XSPRITE* pXTarget = (pTarget != NULL && xspriRangeIsFine(pTarget->extra) && xsprite[pTarget->extra].health > 0) ? &xsprite[pTarget->extra] : NULL;
int newCnt = pExtra->slaveCount; int newCnt = pExtra->slaveCount;
@ -1882,9 +1882,9 @@ void updateTargetOfSlaves(spritetype* pSprite) {
XSPRITE* pXSlave = &xsprite[pSlave->index]; XSPRITE* pXSlave = &xsprite[pSlave->index];
if (pXTarget != NULL) { if (pXTarget != NULL) {
if (pXSprite->target != pXSlave->target) aiSetTarget(pXSlave, pXSprite->target); if (pXSprite->target_i != pXSlave->target_i) aiSetTarget(pXSlave, pXSprite->target_i);
// check if slave have proper target // check if slave have proper target
if (!spriRangeIsFine(pXSlave->target) || sprite[pXSlave->target].owner == pSprite->index) if (!spriRangeIsFine(pXSlave->target_i) || sprite[pXSlave->target_i].owner == pSprite->index)
aiSetTarget(pXSlave, pSprite->x, pSprite->y, pSprite->z); aiSetTarget(pXSlave, pSprite->x, pSprite->y, pSprite->z);
} else { } else {
aiSetTarget(pXSlave, pSprite->x, pSprite->y, pSprite->z); // try return to master aiSetTarget(pXSlave, pSprite->x, pSprite->y, pSprite->z); // try return to master
@ -2098,7 +2098,7 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
bool oldStatus = pExtra->canWalk; bool oldStatus = pExtra->canWalk;
pExtra->canWalk = !!getSequence(i); pExtra->canWalk = !!getSequence(i);
if (oldStatus != pExtra->canWalk) { if (oldStatus != pExtra->canWalk) {
if (!spriRangeIsFine(pXSprite->target)) if (!spriRangeIsFine(pXSprite->target_i))
{ {
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeIdleW); if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeIdleW);
else aiGenDudeNewState(pSprite, &genDudeIdleL); else aiGenDudeNewState(pSprite, &genDudeIdleL);

View file

@ -63,7 +63,7 @@ void HackSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type); DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int tx = pXSprite->targetX-pSprite->x; int tx = pXSprite->targetX-pSprite->x;
@ -111,15 +111,15 @@ static void zombaThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -147,7 +147,7 @@ static void zombaThinkChase(DBloodActor* actor)
{ {
if (abs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x400 && abs(nDeltaAngle) < 85) if (nDist < 0x400 && abs(nDeltaAngle) < 85)
aiNewState(actor, &zombieAHack); aiNewState(actor, &zombieAHack);
return; return;
@ -156,22 +156,22 @@ static void zombaThinkChase(DBloodActor* actor)
} }
aiNewState(actor, &zombieAGoto); aiNewState(actor, &zombieAGoto);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void zombaThinkPonder(DBloodActor* actor) static void zombaThinkPonder(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -195,7 +195,7 @@ static void zombaThinkPonder(DBloodActor* actor)
{ {
if (abs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x400) if (nDist < 0x400)
{ {
if (abs(nDeltaAngle) < 85) if (abs(nDeltaAngle) < 85)
@ -271,7 +271,7 @@ static void entryEZombie(DBloodActor* actor)
static void entryAIdle(DBloodActor* actor) static void entryAIdle(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
pXSprite->target = -1; pXSprite->target_i = -1;
} }
static void entryEStand(DBloodActor* actor) static void entryEStand(DBloodActor* actor)

View file

@ -52,7 +52,7 @@ void zombfHackSeqCallback(int, DBloodActor* actor)
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
if (pSprite->type != kDudeZombieButcher) if (pSprite->type != kDudeZombieButcher)
return; return;
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat); int height = (pDudeInfo->eyeHeight*pSprite->yrepeat);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type); DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
@ -64,7 +64,7 @@ void PukeSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type); DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat); int height = (pDudeInfo->eyeHeight*pSprite->yrepeat);
@ -112,15 +112,15 @@ static void zombfThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (pXSprite->target == -1) if (pXSprite->target_i == -1)
{ {
aiNewState(actor, &zombieFGoto); aiNewState(actor, &zombieFGoto);
return; return;
} }
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target]; spritetype *pTarget = &sprite[pXSprite->target_i];
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
@ -144,7 +144,7 @@ static void zombfThinkChase(DBloodActor* actor)
{ {
if (abs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target_i);
if (nDist < 0x1400 && nDist > 0xe00 && abs(nDeltaAngle) < 85) if (nDist < 0x1400 && nDist > 0xe00 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
@ -208,7 +208,7 @@ static void zombfThinkChase(DBloodActor* actor)
} }
aiNewState(actor, &zombieFSearch); aiNewState(actor, &zombieFSearch);
pXSprite->target = -1; pXSprite->target_i = -1;
} }
END_BLD_NS END_BLD_NS

View file

@ -806,7 +806,7 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int
case kMissileFlareAlt: case kMissileFlareAlt:
if (pTSprite->statnum == kStatFlare) { if (pTSprite->statnum == kStatFlare) {
assert(pTXSprite != NULL); assert(pTXSprite != NULL);
if (pTXSprite->target == gView->nSprite) { if (pTXSprite->target_i == gView->nSprite) {
pTSprite->xrepeat = 0; pTSprite->xrepeat = 0;
break; break;
} }
@ -833,7 +833,7 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int
{ {
if (pTSprite->type == kDudeHand && pTXSprite->aiState == &hand13A3B4) if (pTSprite->type == kDudeHand && pTXSprite->aiState == &hand13A3B4)
{ {
spritetype *pTTarget = &sprite[pTXSprite->target]; spritetype *pTTarget = &sprite[pTXSprite->target_i];
assert(pTXSprite != NULL && pTTarget != NULL); assert(pTXSprite != NULL && pTTarget != NULL);
if (IsPlayerSprite(pTTarget)) if (IsPlayerSprite(pTTarget))
{ {

View file

@ -55,13 +55,13 @@ public:
void SetTarget(DBloodActor* own) void SetTarget(DBloodActor* own)
{ {
x().target = own ? own->s().index : -1; x().target_i = own ? own->s().index : -1;
} }
DBloodActor* GetTarget() DBloodActor* GetTarget()
{ {
if (x().target == -1 || x().target == kMaxSprites - 1) return nullptr; if (x().target_i == -1 || x().target_i == kMaxSprites - 1) return nullptr;
return base() + x().target; return base() + x().target_i;
} }
void SetBurnSource(DBloodActor* own) void SetBurnSource(DBloodActor* own)

View file

@ -269,7 +269,7 @@ void Respawn(int nSprite) // 9
// return dude to the patrol state // return dude to the patrol state
if (gModernMap && pXSprite->dudeFlag4) { if (gModernMap && pXSprite->dudeFlag4) {
pXSprite->data3 = 0; pXSprite->data3 = 0;
pXSprite->target = -1; pXSprite->target_i = -1;
} }
#else #else
pSprite->clipdist = getDudeInfo(nType + kDudeBase)->clipdist; pSprite->clipdist = getDudeInfo(nType + kDudeBase)->clipdist;
@ -377,7 +377,7 @@ void FinishHim(int nSprite) // 13
spritetype* pSprite = &sprite[nSprite]; spritetype* pSprite = &sprite[nSprite];
int nXSprite = pSprite->extra; int nXSprite = pSprite->extra;
XSPRITE* pXSprite = &xsprite[nXSprite]; XSPRITE* pXSprite = &xsprite[nXSprite];
if (IsPlayerSprite(pSprite) && playerSeqPlaying(&gPlayer[pSprite->type - kDudePlayer1], 16) && pXSprite->target == gMe->nSprite) if (IsPlayerSprite(pSprite) && playerSeqPlaying(&gPlayer[pSprite->type - kDudePlayer1], 16) && pXSprite->target_i == gMe->nSprite)
sndStartSample(3313, -1, 1, 0); sndStartSample(3313, -1, 1, 0);
} }

View file

@ -957,7 +957,7 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
pXSprite->dudeAmbush = bitReader.readUnsigned(1); pXSprite->dudeAmbush = bitReader.readUnsigned(1);
pXSprite->dudeGuard = bitReader.readUnsigned(1); pXSprite->dudeGuard = bitReader.readUnsigned(1);
pXSprite->dudeFlag4 = bitReader.readUnsigned(1); pXSprite->dudeFlag4 = bitReader.readUnsigned(1);
pXSprite->target = bitReader.readSigned(16); pXSprite->target_i = bitReader.readSigned(16);
pXSprite->targetX = bitReader.readSigned(32); pXSprite->targetX = bitReader.readSigned(32);
pXSprite->targetY = bitReader.readSigned(32); pXSprite->targetY = bitReader.readSigned(32);
pXSprite->targetZ = bitReader.readSigned(32); pXSprite->targetZ = bitReader.readSigned(32);

View file

@ -112,7 +112,7 @@ struct XSPRITE {
int16_t data1; // Data 1 int16_t data1; // Data 1
int16_t data2; // Data 2 int16_t data2; // Data 2
int16_t data3; // Data 3 int16_t data3; // Data 3
int16_t target; // target sprite int16_t target_i; // target sprite
int16_t burnSource; int16_t burnSource;
uint16_t txID; // TX ID uint16_t txID; // TX ID
uint16_t rxID; // RX ID uint16_t rxID; // RX ID

View file

@ -575,7 +575,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, XSPRITE& w, XSPRIT
("targetX", w.targetX, def->targetX) ("targetX", w.targetX, def->targetX)
("targetY", w.targetY, def->targetY) ("targetY", w.targetY, def->targetY)
("targetZ", w.targetZ, def->targetZ) ("targetZ", w.targetZ, def->targetZ)
("target", w.target, def->target) ("target", w.target_i, def->target_i)
("sysdata1", w.sysData1, def->sysData1) ("sysdata1", w.sysData1, def->sysData1)
("sysdata2", w.sysData2, def->sysData2) ("sysdata2", w.sysData2, def->sysData2)
("scale", w.scale, def->scale) ("scale", w.scale, def->scale)

View file

@ -338,7 +338,7 @@ spritetype* nnExtSpawnDude(XSPRITE* pXSource, spritetype* pSprite, short nType,
bool burning = IsBurningDude(pDude); bool burning = IsBurningDude(pDude);
if (burning) { if (burning) {
pXDude->burnTime = 10; pXDude->burnTime = 10;
pXDude->target = -1; pXDude->target_i = -1;
} }
if ((burning || (pSource->flags & kModernTypeFlag3)) && !pXDude->dudeFlag4) if ((burning || (pSource->flags & kModernTypeFlag3)) && !pXDude->dudeFlag4)
@ -711,7 +711,7 @@ void nnExtInitModernStuff(bool bSaveLoad) {
pXSprite->Proximity = pXSprite->Push = pXSprite->Vector = pXSprite->triggerOn = false; pXSprite->Proximity = pXSprite->Push = pXSprite->Vector = pXSprite->triggerOn = false;
pXSprite->state = pXSprite->restState = 0; pXSprite->state = pXSprite->restState = 0;
pXSprite->targetX = pXSprite->targetY = pXSprite->targetZ = pXSprite->target = pXSprite->sysData2 = -1; pXSprite->targetX = pXSprite->targetY = pXSprite->targetZ = pXSprite->target_i = pXSprite->sysData2 = -1;
changespritestat(pSprite->index, kStatModernCondition); changespritestat(pSprite->index, kStatModernCondition);
int oldStat = pSprite->cstat; pSprite->cstat = 0x30; int oldStat = pSprite->cstat; pSprite->cstat = 0x30;
@ -2731,13 +2731,13 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
if (pSprite->statnum == kStatDude && IsDudeSprite(pSprite) && !IsPlayerSprite(pSprite)) { if (pSprite->statnum == kStatDude && IsDudeSprite(pSprite) && !IsPlayerSprite(pSprite)) {
XSPRITE* pXDude = &xsprite[pSprite->extra]; XSPRITE* pXDude = &xsprite[pSprite->extra];
int x = pXDude->targetX; int y = pXDude->targetY; int z = pXDude->targetZ; int x = pXDude->targetX; int y = pXDude->targetY; int z = pXDude->targetZ;
int target = pXDude->target; int target = pXDude->target_i;
aiInitSprite(pSprite); aiInitSprite(pSprite);
if (target >= 0) { if (target >= 0) {
pXDude->targetX = x; pXDude->targetY = y; pXDude->targetZ = z; pXDude->targetX = x; pXDude->targetY = y; pXDude->targetZ = z;
pXDude->target = target; aiActivateDude(&bloodActors[pXDude->reference]); pXDude->target_i = target; aiActivateDude(&bloodActors[pXDude->reference]);
} }
} }
@ -3765,9 +3765,9 @@ bool condCheckDude(XSPRITE* pXCond, int cmpOp, bool PUSH) {
switch (cond) { switch (cond) {
default: break; default: break;
case 0: // dude have any targets? case 0: // dude have any targets?
if (!spriRangeIsFine(pXSpr->target)) return false; if (!spriRangeIsFine(pXSpr->target_i)) return false;
else if (!IsDudeSprite(&sprite[pXSpr->target]) && sprite[pXSpr->target].type != kMarkerPath) return false; else if (!IsDudeSprite(&sprite[pXSpr->target_i]) && sprite[pXSpr->target_i].type != kMarkerPath) return false;
else if (PUSH) condPush(pXCond, OBJ_SPRITE, pXSpr->target); else if (PUSH) condPush(pXCond, OBJ_SPRITE, pXSpr->target_i);
return true; return true;
case 1: return aiFightDudeIsAffected(pXSpr); // dude affected by ai fight? case 1: return aiFightDudeIsAffected(pXSpr); // dude affected by ai fight?
case 2: // distance to the target in a range? case 2: // distance to the target in a range?
@ -3775,10 +3775,10 @@ bool condCheckDude(XSPRITE* pXCond, int cmpOp, bool PUSH) {
case 4: // is the target visible with periphery? case 4: // is the target visible with periphery?
{ {
if (!spriRangeIsFine(pXSpr->target)) if (!spriRangeIsFine(pXSpr->target_i))
condError(pXCond, "Dude #%d have no target!", objIndex); condError(pXCond, "Dude #%d have no target!", objIndex);
spritetype* pTrgt = &sprite[pXSpr->target]; spritetype* pTrgt = &sprite[pXSpr->target_i];
DUDEINFO* pInfo = getDudeInfo(pSpr->type); DUDEINFO* pInfo = getDudeInfo(pSpr->type);
int eyeAboveZ = pInfo->eyeHeight * pSpr->yrepeat << 2; int eyeAboveZ = pInfo->eyeHeight * pSpr->yrepeat << 2;
int dx = pTrgt->x - pSpr->x; int dy = pTrgt->y - pSpr->y; int dx = pTrgt->x - pSpr->x; int dy = pTrgt->y - pSpr->y;
@ -3798,7 +3798,7 @@ bool condCheckDude(XSPRITE* pXCond, int cmpOp, bool PUSH) {
} }
if (var <= 0) return false; if (var <= 0) return false;
else if (PUSH) condPush(pXCond, OBJ_SPRITE, pXSpr->target); else if (PUSH) condPush(pXCond, OBJ_SPRITE, pXSpr->target_i);
return true; return true;
} }
@ -3809,21 +3809,21 @@ bool condCheckDude(XSPRITE* pXCond, int cmpOp, bool PUSH) {
case 9: return (pXSpr->unused1 & kDudeFlagStealth); case 9: return (pXSpr->unused1 & kDudeFlagStealth);
case 10: // check if the marker is busy with another dude case 10: // check if the marker is busy with another dude
case 11: // check if the marker is reached case 11: // check if the marker is reached
if (!pXSpr->dudeFlag4 || !spriRangeIsFine(pXSpr->target) || sprite[pXSpr->target].type != kMarkerPath) return false; if (!pXSpr->dudeFlag4 || !spriRangeIsFine(pXSpr->target_i) || sprite[pXSpr->target_i].type != kMarkerPath) return false;
switch (cond) { switch (cond) {
case 10: case 10:
var = aiPatrolMarkerBusy(pSpr->index, pXSpr->target); var = aiPatrolMarkerBusy(pSpr->index, pXSpr->target_i);
if (!spriRangeIsFine(var)) return false; if (!spriRangeIsFine(var)) return false;
else if (PUSH) condPush(pXCond, OBJ_SPRITE, var); else if (PUSH) condPush(pXCond, OBJ_SPRITE, var);
break; break;
case 11: case 11:
if (!aiPatrolMarkerReached(pSpr, pXSpr)) return false; if (!aiPatrolMarkerReached(pSpr, pXSpr)) return false;
else if (PUSH) condPush(pXCond, OBJ_SPRITE, pXSpr->target); else if (PUSH) condPush(pXCond, OBJ_SPRITE, pXSpr->target_i);
break; break;
} }
return true; return true;
case 12: // compare spot progress value in % case 12: // compare spot progress value in %
if (!pXSpr->dudeFlag4 || !spriRangeIsFine(pXSpr->target) || sprite[pXSpr->target].type != kMarkerPath) var = 0; if (!pXSpr->dudeFlag4 || !spriRangeIsFine(pXSpr->target_i) || sprite[pXSpr->target_i].type != kMarkerPath) var = 0;
else if (!(pXSpr->unused1 & kDudeFlagStealth) || pXSpr->data3 < 0 || pXSpr->data3 > kMaxPatrolSpotValue) var = 0; else if (!(pXSpr->unused1 & kDudeFlagStealth) || pXSpr->data3 < 0 || pXSpr->data3 > kMaxPatrolSpotValue) var = 0;
else var = (kPercFull * pXSpr->data3) / kMaxPatrolSpotValue; else var = (kPercFull * pXSpr->data3) / kMaxPatrolSpotValue;
return condCmp(var, arg1, arg2, cmpOp); return condCmp(var, arg1, arg2, cmpOp);
@ -3986,7 +3986,7 @@ bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) {
spritetype* pDude = &sprite[nSprite]; spritetype* pDude = &sprite[nSprite];
if (IsDudeSprite(pDude) && xspriRangeIsFine(pDude->extra)) { if (IsDudeSprite(pDude) && xspriRangeIsFine(pDude->extra)) {
XSPRITE* pXDude = &xsprite[pDude->extra]; XSPRITE* pXDude = &xsprite[pDude->extra];
if (pXDude->health <= 0 || pXDude->target != pSpr->index) continue; if (pXDude->health <= 0 || pXDude->target_i != pSpr->index) continue;
else if (PUSH) condPush(pXCond, OBJ_SPRITE, nSprite); else if (PUSH) condPush(pXCond, OBJ_SPRITE, nSprite);
return true; return true;
} }
@ -4066,7 +4066,7 @@ bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) {
continue; continue;
XSPRITE* pXFlare = &xsprite[pFlare->extra]; XSPRITE* pXFlare = &xsprite[pFlare->extra];
if (!spriRangeIsFine(pXFlare->target) || pXFlare->target != objIndex) continue; if (!spriRangeIsFine(pXFlare->target_i) || pXFlare->target_i != objIndex) continue;
else if (PUSH) condPush(pXCond, OBJ_SPRITE, nSprite); else if (PUSH) condPush(pXCond, OBJ_SPRITE, nSprite);
return true; return true;
} }
@ -4312,14 +4312,14 @@ spritetype* aiFightGetTargetInRange(spritetype* pSprite, int minDist, int maxDis
int dist = aiFightGetTargetDist(pSprite, pDudeInfo, pTarget); int dist = aiFightGetTargetDist(pSprite, pDudeInfo, pTarget);
if (dist < minDist || dist > maxDist) continue; if (dist < minDist || dist > maxDist) continue;
else if (pXSprite->target == pTarget->index) return pTarget; else if (pXSprite->target_i == pTarget->index) return pTarget;
else if (!IsDudeSprite(pTarget) || pTarget->index == pSprite->index || IsPlayerSprite(pTarget)) continue; else if (!IsDudeSprite(pTarget) || pTarget->index == pSprite->index || IsPlayerSprite(pTarget)) continue;
else if (IsBurningDude(pTarget) || !IsKillableDude(pTarget) || pTarget->owner == pSprite->index) continue; else if (IsBurningDude(pTarget) || !IsKillableDude(pTarget) || pTarget->owner == pSprite->index) continue;
else if ((teamMode == 1 && aiFightIsMateOf(pXSprite, pXTarget)) || aiFightMatesHaveSameTarget(pXSprite, pTarget, 1)) continue; else if ((teamMode == 1 && aiFightIsMateOf(pXSprite, pXTarget)) || aiFightMatesHaveSameTarget(pXSprite, pTarget, 1)) continue;
else if (data == 666 || pXTarget->data1 == data) { else if (data == 666 || pXTarget->data1 == data) {
if (pXSprite->target > 0) { if (pXSprite->target_i > 0) {
cTarget = &sprite[pXSprite->target]; cTarget = &sprite[pXSprite->target_i];
int fineDist1 = aiFightGetFineTargetDist(pSprite, cTarget); int fineDist1 = aiFightGetFineTargetDist(pSprite, cTarget);
int fineDist2 = aiFightGetFineTargetDist(pSprite, pTarget); int fineDist2 = aiFightGetFineTargetDist(pSprite, pTarget);
if (fineDist1 < fineDist2) if (fineDist1 < fineDist2)
@ -4334,9 +4334,9 @@ spritetype* aiFightGetTargetInRange(spritetype* pSprite, int minDist, int maxDis
spritetype* aiFightTargetIsPlayer(XSPRITE* pXSprite) { spritetype* aiFightTargetIsPlayer(XSPRITE* pXSprite) {
if (pXSprite->target >= 0) { if (pXSprite->target_i >= 0) {
if (IsPlayerSprite(&sprite[pXSprite->target])) if (IsPlayerSprite(&sprite[pXSprite->target_i]))
return &sprite[pXSprite->target]; return &sprite[pXSprite->target_i];
} }
return NULL; return NULL;
@ -4351,9 +4351,9 @@ spritetype* aiFightGetMateTargets(XSPRITE* pXSprite) {
continue; continue;
pXMate = &xsprite[pMate->extra]; pXMate = &xsprite[pMate->extra];
if (pXMate->target > -1) { if (pXMate->target_i > -1) {
if (!IsPlayerSprite(&sprite[pXMate->target])) if (!IsPlayerSprite(&sprite[pXMate->target_i]))
return &sprite[pXMate->target]; return &sprite[pXMate->target_i];
} }
} }
@ -4375,7 +4375,7 @@ bool aiFightMatesHaveSameTarget(XSPRITE* pXLeader, spritetype* pTarget, int allo
continue; continue;
pXMate = &xsprite[pMate->extra]; pXMate = &xsprite[pMate->extra];
if (pXMate->target == pTarget->index && allow-- <= 0) if (pXMate->target_i == pTarget->index && allow-- <= 0)
return true; return true;
} }
@ -4426,7 +4426,7 @@ void aiFightFreeTargets(int nSprite) {
while ((nTarget = it.NextIndex()) >= 0) while ((nTarget = it.NextIndex()) >= 0)
{ {
if (!IsDudeSprite(&sprite[nTarget]) || sprite[nTarget].extra < 0) continue; if (!IsDudeSprite(&sprite[nTarget]) || sprite[nTarget].extra < 0) continue;
else if (xsprite[sprite[nTarget].extra].target == nSprite) else if (xsprite[sprite[nTarget].extra].target_i == nSprite)
aiSetTarget(&xsprite[sprite[nTarget].extra], sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z); aiSetTarget(&xsprite[sprite[nTarget].extra], sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z);
} }
@ -4502,7 +4502,7 @@ void aiFightAlarmDudesInSight(spritetype* pSprite, int max) {
continue; continue;
pXDude = &xsprite[pDude->extra]; pXDude = &xsprite[pDude->extra];
if (aiFightDudeCanSeeTarget(pXSprite, pDudeInfo, pDude)) { if (aiFightDudeCanSeeTarget(pXSprite, pDudeInfo, pDude)) {
if (pXDude->target != -1 || pXDude->rxID > 0) if (pXDude->target_i != -1 || pXDude->rxID > 0)
continue; continue;
aiSetTarget(pXDude, pDude->x, pDude->y, pDude->z); aiSetTarget(pXDude, pDude->x, pDude->y, pDude->z);
@ -5904,8 +5904,8 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
} }
int maxAlarmDudes = 8 + Random(8); int maxAlarmDudes = 8 + Random(8);
if (pXSprite->target > -1 && sprite[pXSprite->target].extra > -1 && pPlayer == NULL) { if (pXSprite->target_i > -1 && sprite[pXSprite->target_i].extra > -1 && pPlayer == NULL) {
pTarget = &sprite[pXSprite->target]; pXTarget = &xsprite[pTarget->extra]; pTarget = &sprite[pXSprite->target_i]; pXTarget = &xsprite[pTarget->extra];
if (aiFightUnitCanFly(pSprite) && aiFightIsMeleeUnit(pTarget) && !aiFightUnitCanFly(pTarget)) if (aiFightUnitCanFly(pSprite) && aiFightIsMeleeUnit(pTarget) && !aiFightUnitCanFly(pTarget))
pSprite->flags |= 0x0002; pSprite->flags |= 0x0002;
@ -5946,10 +5946,10 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
startHp = (pXMate->sysData2 > 0) ? ClipRange(pXMate->sysData2 << 4, 1, 65535) : getDudeInfo(pMate->type)->startHealth << 4; startHp = (pXMate->sysData2 > 0) ? ClipRange(pXMate->sysData2 << 4, 1, 65535) : getDudeInfo(pMate->type)->startHealth << 4;
if (pXMate->health < (unsigned)startHp) actHealDude(&bloodActors[pXMate->reference], receiveHp, startHp); if (pXMate->health < (unsigned)startHp) actHealDude(&bloodActors[pXMate->reference], receiveHp, startHp);
if (pXMate->target > -1 && sprite[pXMate->target].extra >= 0) { if (pXMate->target_i > -1 && sprite[pXMate->target_i].extra >= 0) {
pTarget = &sprite[pXMate->target]; pTarget = &sprite[pXMate->target_i];
// force mate stop attack dude, if he does // force mate stop attack dude, if he does
if (pXMate->target == pSprite->index) { if (pXMate->target_i == pSprite->index) {
aiSetTarget(pXMate, pMate->x, pMate->y, pMate->z); aiSetTarget(pXMate, pMate->x, pMate->y, pMate->z);
} else if (!aiFightIsMateOf(pXSprite, &xsprite[pTarget->extra])) { } else if (!aiFightIsMateOf(pXSprite, &xsprite[pTarget->extra])) {
// force dude to attack same target that mate have // force dude to attack same target that mate have
@ -5963,7 +5963,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
} }
// force dude stop attack mate, if target was not changed previously // force dude stop attack mate, if target was not changed previously
if (pXSprite->target == pMate->index) if (pXSprite->target_i == pMate->index)
aiSetTarget(pXSprite, pSprite->x, pSprite->y, pSprite->z); aiSetTarget(pXSprite, pSprite->x, pSprite->y, pSprite->z);
@ -5974,19 +5974,19 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
} }
int mDist = 3; if (aiFightIsMeleeUnit(pSprite)) mDist = 2; int mDist = 3; if (aiFightIsMeleeUnit(pSprite)) mDist = 2;
if (pXSprite->target >= 0 && aiFightGetTargetDist(pSprite, pDudeInfo, &sprite[pXSprite->target]) < mDist) { if (pXSprite->target_i >= 0 && aiFightGetTargetDist(pSprite, pDudeInfo, &sprite[pXSprite->target_i]) < mDist) {
if (!isActive(pSprite->index)) aiActivateDude(&bloodActors[pXSprite->reference]); if (!isActive(pSprite->index)) aiActivateDude(&bloodActors[pXSprite->reference]);
return; return;
} }
// lets try to look for target that fits better by distance // lets try to look for target that fits better by distance
else if ((PlayClock & 256) != 0 && (pXSprite->target < 0 || aiFightGetTargetDist(pSprite, pDudeInfo, pTarget) >= mDist)) { else if ((PlayClock & 256) != 0 && (pXSprite->target_i < 0 || aiFightGetTargetDist(pSprite, pDudeInfo, pTarget) >= mDist)) {
pTarget = aiFightGetTargetInRange(pSprite, 0, mDist, pXSource->data1, pXSource->data2); pTarget = aiFightGetTargetInRange(pSprite, 0, mDist, pXSource->data1, pXSource->data2);
if (pTarget != NULL) { if (pTarget != NULL) {
pXTarget = &xsprite[pTarget->extra]; pXTarget = &xsprite[pTarget->extra];
// Make prev target not aim in dude // Make prev target not aim in dude
if (pXSprite->target > -1) { if (pXSprite->target_i > -1) {
spritetype* prvTarget = &sprite[pXSprite->target]; spritetype* prvTarget = &sprite[pXSprite->target_i];
aiSetTarget(&xsprite[prvTarget->extra], prvTarget->x, prvTarget->y, prvTarget->z); aiSetTarget(&xsprite[prvTarget->extra], prvTarget->x, prvTarget->y, prvTarget->z);
if (!isActive(pTarget->index)) if (!isActive(pTarget->index))
aiActivateDude(&bloodActors[pXTarget->reference]); aiActivateDude(&bloodActors[pXTarget->reference]);
@ -5998,7 +5998,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
aiActivateDude(&bloodActors[pXSprite->reference]); aiActivateDude(&bloodActors[pXSprite->reference]);
// ...and change target of target to dude to force it fight // ...and change target of target to dude to force it fight
if (pXSource->data3 > 0 && pXTarget->target != pSprite->index) { if (pXSource->data3 > 0 && pXTarget->target_i != pSprite->index) {
aiSetTarget(pXTarget, pSprite->index); aiSetTarget(pXTarget, pSprite->index);
if (!isActive(pTarget->index)) if (!isActive(pTarget->index))
aiActivateDude(&bloodActors[pXTarget->reference]); aiActivateDude(&bloodActors[pXTarget->reference]);
@ -6009,7 +6009,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
} }
} }
if ((pXSprite->target < 0 || pPlayer != NULL) && (PlayClock & 32) != 0) { if ((pXSprite->target_i < 0 || pPlayer != NULL) && (PlayClock & 32) != 0) {
// try find first target that dude can see // try find first target that dude can see
int nSprite; int nSprite;
StatIterator it(kStatDude); StatIterator it(kStatDude);
@ -6017,7 +6017,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
{ {
pTarget = &sprite[nSprite]; pXTarget = &xsprite[pTarget->extra]; pTarget = &sprite[nSprite]; pXTarget = &xsprite[pTarget->extra];
if (pXTarget->target == pSprite->index) { if (pXTarget->target_i == pSprite->index) {
aiSetTarget(pXSprite, pTarget->index); aiSetTarget(pXSprite, pTarget->index);
return; return;
} }
@ -6040,7 +6040,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
aiActivateDude(&bloodActors[pXSprite->reference]); aiActivateDude(&bloodActors[pXSprite->reference]);
// ...and change target of target to dude to force it fight // ...and change target of target to dude to force it fight
if (pXSource->data3 > 0 && pXTarget->target != pSprite->index) { if (pXSource->data3 > 0 && pXTarget->target_i != pSprite->index) {
aiSetTarget(pXTarget, pSprite->index); aiSetTarget(pXTarget, pSprite->index);
if (pPlayer == NULL && !isActive(pTarget->index)) if (pPlayer == NULL && !isActive(pTarget->index))
aiActivateDude(&bloodActors[pXTarget->reference]); aiActivateDude(&bloodActors[pXTarget->reference]);
@ -6057,12 +6057,12 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
} }
// got no target - let's ask mates if they have targets // got no target - let's ask mates if they have targets
if ((pXSprite->target < 0 || pPlayer != NULL) && pXSource->data2 == 1 && (PlayClock & 64) != 0) { if ((pXSprite->target_i < 0 || pPlayer != NULL) && pXSource->data2 == 1 && (PlayClock & 64) != 0) {
spritetype* pMateTarget = NULL; spritetype* pMateTarget = NULL;
if ((pMateTarget = aiFightGetMateTargets(pXSprite)) != NULL && pMateTarget->extra > 0) { if ((pMateTarget = aiFightGetMateTargets(pXSprite)) != NULL && pMateTarget->extra > 0) {
XSPRITE* pXMateTarget = &xsprite[pMateTarget->extra]; XSPRITE* pXMateTarget = &xsprite[pMateTarget->extra];
if (aiFightDudeCanSeeTarget(pXSprite, pDudeInfo, pMateTarget)) { if (aiFightDudeCanSeeTarget(pXSprite, pDudeInfo, pMateTarget)) {
if (pXMateTarget->target < 0) { if (pXMateTarget->target_i < 0) {
aiSetTarget(pXMateTarget, pSprite->index); aiSetTarget(pXMateTarget, pSprite->index);
if (IsDudeSprite(pMateTarget) && !isActive(pMateTarget->index)) if (IsDudeSprite(pMateTarget) && !isActive(pMateTarget->index))
aiActivateDude(&bloodActors[pXMateTarget->reference]); aiActivateDude(&bloodActors[pXMateTarget->reference]);
@ -6074,9 +6074,9 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
return; return;
// try walk in mate direction in case if not see the target // try walk in mate direction in case if not see the target
} else if (pXMateTarget->target >= 0 && aiFightDudeCanSeeTarget(pXSprite, pDudeInfo, &sprite[pXMateTarget->target])) { } else if (pXMateTarget->target_i >= 0 && aiFightDudeCanSeeTarget(pXSprite, pDudeInfo, &sprite[pXMateTarget->target_i])) {
spritetype* pMate = &sprite[pXMateTarget->target]; spritetype* pMate = &sprite[pXMateTarget->target_i];
pXSprite->target = pMateTarget->index; pXSprite->target_i = pMateTarget->index;
pXSprite->targetX = pMate->x; pXSprite->targetX = pMate->x;
pXSprite->targetY = pMate->y; pXSprite->targetY = pMate->y;
pXSprite->targetZ = pMate->z; pXSprite->targetZ = pMate->z;
@ -6483,27 +6483,27 @@ void nnExtAiSetDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3) {
if (vc < 0) if (vc < 0)
v8 = -341; v8 = -341;
if (nnExtCanMove(pSprite, pXSprite->target, pSprite->ang + vc, vsi)) if (nnExtCanMove(pSprite, pXSprite->target_i, pSprite->ang + vc, vsi))
pXSprite->goalAng = pSprite->ang + vc; pXSprite->goalAng = pSprite->ang + vc;
else if (nnExtCanMove(pSprite, pXSprite->target, pSprite->ang + vc / 2, vsi)) else if (nnExtCanMove(pSprite, pXSprite->target_i, pSprite->ang + vc / 2, vsi))
pXSprite->goalAng = pSprite->ang + vc / 2; pXSprite->goalAng = pSprite->ang + vc / 2;
else if (nnExtCanMove(pSprite, pXSprite->target, pSprite->ang - vc / 2, vsi)) else if (nnExtCanMove(pSprite, pXSprite->target_i, pSprite->ang - vc / 2, vsi))
pXSprite->goalAng = pSprite->ang - vc / 2; pXSprite->goalAng = pSprite->ang - vc / 2;
else if (nnExtCanMove(pSprite, pXSprite->target, pSprite->ang + v8, vsi)) else if (nnExtCanMove(pSprite, pXSprite->target_i, pSprite->ang + v8, vsi))
pXSprite->goalAng = pSprite->ang + v8; pXSprite->goalAng = pSprite->ang + v8;
else if (nnExtCanMove(pSprite, pXSprite->target, pSprite->ang, vsi)) else if (nnExtCanMove(pSprite, pXSprite->target_i, pSprite->ang, vsi))
pXSprite->goalAng = pSprite->ang; pXSprite->goalAng = pSprite->ang;
else if (nnExtCanMove(pSprite, pXSprite->target, pSprite->ang - v8, vsi)) else if (nnExtCanMove(pSprite, pXSprite->target_i, 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;
if (pXSprite->dodgeDir) { if (pXSprite->dodgeDir) {
if (!nnExtCanMove(pSprite, pXSprite->target, pSprite->ang + pXSprite->dodgeDir * 512, 512)) if (!nnExtCanMove(pSprite, pXSprite->target_i, pSprite->ang + pXSprite->dodgeDir * 512, 512))
{ {
pXSprite->dodgeDir = -pXSprite->dodgeDir; pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!nnExtCanMove(pSprite, pXSprite->target, pSprite->ang + pXSprite->dodgeDir * 512, 512)) if (!nnExtCanMove(pSprite, pXSprite->target_i, pSprite->ang + pXSprite->dodgeDir * 512, 512))
pXSprite->dodgeDir = 0; pXSprite->dodgeDir = 0;
} }
@ -6519,9 +6519,9 @@ void aiPatrolState(spritetype* pSprite, int state) {
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
XSPRITE* pXSprite = &xsprite[pSprite->extra]; XSPRITE* pXSprite = &xsprite[pSprite->extra];
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites); assert(pXSprite->target_i >= 0 && pXSprite->target_i < kMaxSprites);
spritetype* pMarker = &sprite[pXSprite->target]; spritetype* pMarker = &sprite[pXSprite->target_i];
XSPRITE* pXMarker = &xsprite[pMarker->extra]; XSPRITE* pXMarker = &xsprite[pMarker->extra];
assert(pMarker->type == kMarkerPath); assert(pMarker->type == kMarkerPath);
@ -6612,7 +6612,7 @@ int aiPatrolMarkerBusy(int nExcept, int nMarker) {
continue; continue;
XSPRITE* pXDude = &xsprite[sprite[i].extra]; XSPRITE* pXDude = &xsprite[sprite[i].extra];
if (pXDude->health > 0 && pXDude->target >= 0 && sprite[pXDude->target].type == kMarkerPath && pXDude->target == nMarker) if (pXDude->health > 0 && pXDude->target_i >= 0 && sprite[pXDude->target_i].type == kMarkerPath && pXDude->target_i == nMarker)
return sprite[i].index; return sprite[i].index;
} }
@ -6625,9 +6625,9 @@ bool aiPatrolMarkerReached(spritetype* pSprite, XSPRITE* pXSprite) {
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO_EXTRA* pExtra = &gDudeInfoExtra[pSprite->type - kDudeBase]; DUDEINFO_EXTRA* pExtra = &gDudeInfoExtra[pSprite->type - kDudeBase];
if (spriRangeIsFine(pXSprite->target) && sprite[pXSprite->target].type == kMarkerPath) { if (spriRangeIsFine(pXSprite->target_i) && sprite[pXSprite->target_i].type == kMarkerPath) {
spritetype* pMarker = &sprite[pXSprite->target]; spritetype* pMarker = &sprite[pXSprite->target_i];
short okDist = ClipLow(pMarker->clipdist << 1, 4); short okDist = ClipLow(pMarker->clipdist << 1, 4);
int oX = abs(pMarker->x - pSprite->x) >> 4; int oX = abs(pMarker->x - pSprite->x) >> 4;
int oY = abs(pMarker->y - pSprite->y) >> 4; int oY = abs(pMarker->y - pSprite->y) >> 4;
@ -6705,7 +6705,7 @@ void aiPatrolSetMarker(spritetype* pSprite, XSPRITE* pXSprite) {
int path = -1; int firstFinePath = -1; int prev = -1, next, i, dist, zt1, zb1, zt2, zb2, closest = 200000; int path = -1; int firstFinePath = -1; int prev = -1, next, i, dist, zt1, zb1, zt2, zb2, closest = 200000;
// select closest marker that dude can see // select closest marker that dude can see
if (pXSprite->target <= 0) { if (pXSprite->target_i <= 0) {
for (i = headspritestat[kStatPathMarker]; i != -1; i = nextspritestat[i]) { for (i = headspritestat[kStatPathMarker]; i != -1; i = nextspritestat[i]) {
@ -6725,7 +6725,7 @@ void aiPatrolSetMarker(spritetype* pSprite, XSPRITE* pXSprite) {
} }
// set next marker // set next marker
} else if (sprite[pXSprite->target].type == kMarkerPath && xspriRangeIsFine(sprite[pXSprite->target].extra)) { } else if (sprite[pXSprite->target_i].type == kMarkerPath && xspriRangeIsFine(sprite[pXSprite->target_i].extra)) {
// idea: which one of next (allowed) markers are closer to the potential target? // idea: which one of next (allowed) markers are closer to the potential target?
// idea: -3 select random next marker that dude can see in radius of reached marker // idea: -3 select random next marker that dude can see in radius of reached marker
@ -6734,7 +6734,7 @@ void aiPatrolSetMarker(spritetype* pSprite, XSPRITE* pXSprite) {
// another marker which belongs that node? // another marker which belongs that node?
int breakChance = 0; int breakChance = 0;
pCur = &sprite[pXSprite->target]; pCur = &sprite[pXSprite->target_i];
pXCur = &xsprite[pCur->extra]; pXCur = &xsprite[pCur->extra];
if (pXSprite->targetX >= 0) if (pXSprite->targetX >= 0)
{ {
@ -6751,7 +6751,7 @@ void aiPatrolSetMarker(spritetype* pSprite, XSPRITE* pXSprite) {
back = (pXSprite->unused2 == kPatrolMoveBackward); next = (back) ? pXCur->data1 : pXCur->data2; back = (pXSprite->unused2 == kPatrolMoveBackward); next = (back) ? pXCur->data1 : pXCur->data2;
for (i = headspritestat[kStatPathMarker]; i != -1; i = nextspritestat[i]) { for (i = headspritestat[kStatPathMarker]; i != -1; i = nextspritestat[i]) {
if (sprite[i].index == pXSprite->target || !xspriRangeIsFine(sprite[i].extra)) continue; if (sprite[i].index == pXSprite->target_i || !xspriRangeIsFine(sprite[i].extra)) continue;
else if (pXSprite->targetX >= 0 && sprite[i].index == pPrev->index && node) { else if (pXSprite->targetX >= 0 && sprite[i].index == pPrev->index && node) {
if (pXCur->data2 == pXPrev->data1) if (pXCur->data2 == pXPrev->data1)
continue; continue;
@ -6786,7 +6786,7 @@ void aiPatrolSetMarker(spritetype* pSprite, XSPRITE* pXSprite) {
if (!spriRangeIsFine(path)) if (!spriRangeIsFine(path))
return; return;
pXSprite->target = path; pXSprite->target_i = path;
pXSprite->targetX = prev; // keep previous marker index here, use actual sprite coords when selecting direction pXSprite->targetX = prev; // keep previous marker index here, use actual sprite coords when selecting direction
sprite[path].owner = pSprite->index; sprite[path].owner = pSprite->index;
@ -6803,9 +6803,9 @@ void aiPatrolStop(spritetype* pSprite, int target, bool alarm) {
if (pXSprite->health <= 0) if (pXSprite->health <= 0)
return; return;
if (pXSprite->target >= 0 && sprite[pXSprite->target].type == kMarkerPath) { if (pXSprite->target_i >= 0 && sprite[pXSprite->target_i].type == kMarkerPath) {
if (target < 0) pSprite->ang = sprite[pXSprite->target].ang & 2047; if (target < 0) pSprite->ang = sprite[pXSprite->target_i].ang & 2047;
pXSprite->target = -1; pXSprite->target_i = -1;
} }
bool patrol = pXSprite->dudeFlag4; pXSprite->dudeFlag4 = 0; bool patrol = pXSprite->dudeFlag4; pXSprite->dudeFlag4 = 0;
@ -6868,7 +6868,7 @@ void aiPatrolMove(DBloodActor* actor) {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax) || !spriRangeIsFine(pXSprite->target)) if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax) || !spriRangeIsFine(pXSprite->target_i))
return; return;
@ -6878,7 +6878,7 @@ void aiPatrolMove(DBloodActor* actor) {
case kDudeCultistTommyProne: dudeIdx = kDudeCultistTommy - kDudeBase; break; case kDudeCultistTommyProne: dudeIdx = kDudeCultistTommy - kDudeBase; break;
} }
spritetype* pTarget = &sprite[pXSprite->target]; spritetype* pTarget = &sprite[pXSprite->target_i];
XSPRITE* pXTarget = &xsprite[pTarget->extra]; XSPRITE* pXTarget = &xsprite[pTarget->extra];
DUDEINFO* pDudeInfo = &dudeInfo[dudeIdx]; DUDEINFO* pDudeInfo = &dudeInfo[dudeIdx];
DUDEINFO_EXTRA* pExtra = &gDudeInfoExtra[dudeIdx]; DUDEINFO_EXTRA* pExtra = &gDudeInfoExtra[dudeIdx];
@ -6975,8 +6975,8 @@ void aiPatrolAlarmLite(spritetype* pSprite, XSPRITE* pXTarget) {
} }
if (aiInPatrolState(pXDude->aiState)) aiPatrolStop(pDude, pXDude->target); if (aiInPatrolState(pXDude->aiState)) aiPatrolStop(pDude, pXDude->target_i);
if (pXDude->target >= 0 || pXDude->target == pXSprite->target) if (pXDude->target_i >= 0 || pXDude->target_i == pXSprite->target_i)
continue; continue;
aiSetTarget(pXDude, pXTarget->reference); aiSetTarget(pXDude, pXTarget->reference);
@ -7026,11 +7026,11 @@ void aiPatrolAlarmFull(spritetype* pSprite, XSPRITE* pXTarget, bool chain) {
if (//(nDist1 < hdist || nDist2 < hdist) || if (//(nDist1 < hdist || nDist2 < hdist) ||
((nDist1 < sdist && cansee(x1, y1, z1, sect1, x2, y2, z2, sect2)) || (nDist2 < sdist && cansee(x1, y1, z1, sect1, x3, y3, z3, sect3)))) { ((nDist1 < sdist && cansee(x1, y1, z1, sect1, x2, y2, z2, sect2)) || (nDist2 < sdist && cansee(x1, y1, z1, sect1, x3, y3, z3, sect3)))) {
if (aiInPatrolState(pXDude->aiState)) aiPatrolStop(pDude, pXDude->target); if (aiInPatrolState(pXDude->aiState)) aiPatrolStop(pDude, pXDude->target_i);
if (pXDude->target >= 0 || pXDude->target == pXSprite->target) if (pXDude->target_i >= 0 || pXDude->target_i == pXSprite->target_i)
continue; continue;
if (spriRangeIsFine(pXSprite->target)) aiSetTarget(pXDude, pXSprite->target); if (spriRangeIsFine(pXSprite->target_i)) aiSetTarget(pXDude, pXSprite->target_i);
else aiSetTarget(pXDude, pSprite->x, pSprite->y, pSprite->z); else aiSetTarget(pXDude, pSprite->x, pSprite->y, pSprite->z);
aiActivateDude(&bloodActors[pXDude->reference]); aiActivateDude(&bloodActors[pXDude->reference]);
@ -7422,7 +7422,7 @@ void aiPatrolFlagsMgr(spritetype* pSource, XSPRITE* pXSource, spritetype* pDest,
if (aiInPatrolState(pXDest->aiState)) if (aiInPatrolState(pXDest->aiState))
return; return;
pXDest->target = -1; // reset the target pXDest->target_i = -1; // reset the target
pXDest->stateTimer = 0; pXDest->stateTimer = 0;
@ -7452,7 +7452,7 @@ void aiPatrolThink(DBloodActor* actor) {
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
int nTarget, stateTimer, nMarker = pXSprite->target; int nTarget, stateTimer, nMarker = pXSprite->target_i;
if ((nTarget = aiPatrolSearchTargets(pSprite, pXSprite)) != -1) { if ((nTarget = aiPatrolSearchTargets(pSprite, pXSprite)) != -1) {
aiPatrolStop(pSprite, nTarget, pXSprite->dudeAmbush); aiPatrolStop(pSprite, nTarget, pXSprite->dudeAmbush);
return; return;

View file

@ -2040,7 +2040,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage
nDeathSeqID = 16; nDeathSeqID = 16;
nKneelingPlayer = nPlayerKneelClient; nKneelingPlayer = nPlayerKneelClient;
powerupActivate(pPlayer, kPwUpDeliriumShroom); powerupActivate(pPlayer, kPwUpDeliriumShroom);
pXSprite->target = nSource; pXSprite->target_i = nSource;
evPost(pSprite->index, 3, 15, kCallbackFinishHim); evPost(pSprite->index, 3, 15, kCallbackFinishHim);
} }
else else

View file

@ -223,7 +223,7 @@ void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event)
} }
case kCmdSpriteProximity: case kCmdSpriteProximity:
{ {
int nTarget = pXSprite->target; int nTarget = pXSprite->target_i;
if (nTarget >= 0 && nTarget < kMaxSprites) if (nTarget >= 0 && nTarget < kMaxSprites)
{ {
if (!pXSprite->stateTimer) if (!pXSprite->stateTimer)
@ -471,7 +471,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
case kDudeBurningBeast: { case kDudeBurningBeast: {
pXSpawn->health = getDudeInfo(pXSprite->data1)->startHealth << 4; pXSpawn->health = getDudeInfo(pXSprite->data1)->startHealth << 4;
pXSpawn->burnTime = 10; pXSpawn->burnTime = 10;
pXSpawn->target = -1; pXSpawn->target_i = -1;
aiActivateDude(&bloodActors[pXSpawn->reference]); aiActivateDude(&bloodActors[pXSpawn->reference]);
break; break;
default: default:

View file

@ -1693,7 +1693,7 @@ void FireLifeLeech(int nTrigger, PLAYER *pPlayer)
if (pMissile) if (pMissile)
{ {
XSPRITE *pXSprite = &xsprite[pMissile->extra]; XSPRITE *pXSprite = &xsprite[pMissile->extra];
pXSprite->target = pPlayer->aimTarget; pXSprite->target_i = pPlayer->aimTarget;
pMissile->ang = (nTrigger==2) ? 1024 : 0; pMissile->ang = (nTrigger==2) ? 1024 : 0;
} }
if (checkAmmo2(pPlayer, 8, 1)) if (checkAmmo2(pPlayer, 8, 1))