- aiSetTarget calls

This commit is contained in:
Christoph Oelckers 2022-08-22 18:41:41 +02:00
parent 97223af592
commit a0c0894e41
4 changed files with 21 additions and 27 deletions

View file

@ -401,10 +401,7 @@ static void batMoveFly(DBloodActor* actor)
void batMoveToCeil(DBloodActor* actor) void batMoveToCeil(DBloodActor* actor)
{ {
int x = actor->int_pos().X; if (actor->spr.pos.Z - actor->xspr.TargetPos.Z < 0x10)
int y = actor->int_pos().Y;
int z = actor->int_pos().Z;
if (z - actor->xspr.int_TargetPos().Z < 0x1000)
{ {
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 0; pDudeExtraE->thinkTime = 0;
@ -412,7 +409,7 @@ void batMoveToCeil(DBloodActor* actor)
aiNewState(actor, &batIdle); aiNewState(actor, &batIdle);
} }
else else
aiSetTarget(actor, x, y, actor->sector()->int_ceilingz()); aiSetTarget(actor, DVector3(actor->spr.pos.XY(), actor->sector()->ceilingz));
} }
END_BLD_NS END_BLD_NS

View file

@ -405,10 +405,7 @@ static void eelMoveAscend(DBloodActor* actor)
void eelMoveToCeil(DBloodActor* actor) void eelMoveToCeil(DBloodActor* actor)
{ {
int x = actor->int_pos().X; if (actor->spr.pos.Z - actor->xspr.TargetPos.Z < 0x10)
int y = actor->int_pos().Y;
int z = actor->int_pos().Z;
if (z - actor->xspr.int_TargetPos().Z < 0x1000)
{ {
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 0; pDudeExtraE->active = 0;
@ -416,7 +413,7 @@ void eelMoveToCeil(DBloodActor* actor)
aiNewState(actor, &eelIdle); aiNewState(actor, &eelIdle);
} }
else else
aiSetTarget(actor, x, y, actor->sector()->int_ceilingz()); aiSetTarget(actor, DVector3(actor->spr.pos.XY(), actor->sector()->ceilingz));
} }
END_BLD_NS END_BLD_NS

View file

@ -655,7 +655,7 @@ static void unicultThinkChase(DBloodActor* actor)
// don't attack slaves // don't attack slaves
if (actor->GetTarget() != nullptr && actor->GetTarget()->GetOwner() == actor) if (actor->GetTarget() != nullptr && actor->GetTarget()->GetOwner() == actor)
{ {
aiSetTarget(actor, actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); aiSetTarget(actor, actor->spr.pos);
return; return;
} }
else if (actor->genDudeExtra.slaveCount > gGameOptions.nDifficulty || dist < meleeVector->maxDist) else if (actor->genDudeExtra.slaveCount > gGameOptions.nDifficulty || dist < meleeVector->maxDist)
@ -2057,7 +2057,7 @@ void genDudeTransform(DBloodActor* actor)
aiInitSprite(actor); aiInitSprite(actor);
// try to restore target // try to restore target
if (target == nullptr) aiSetTarget(actor, actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); if (target == nullptr) aiSetTarget(actor, actor->spr.pos);
else aiSetTarget(actor, target); else aiSetTarget(actor, target);
// finally activate it // finally activate it
@ -2140,11 +2140,11 @@ void updateTargetOfSlaves(DBloodActor* actor)
if (actTarget != slave[i]->GetTarget()) aiSetTarget(slave[i], actTarget); if (actTarget != slave[i]->GetTarget()) aiSetTarget(slave[i], actTarget);
// check if slave have proper target // check if slave have proper target
if (slave[i]->GetTarget() == nullptr || slave[i]->GetTarget()->GetOwner() == actor) if (slave[i]->GetTarget() == nullptr || slave[i]->GetTarget()->GetOwner() == actor)
aiSetTarget(slave[i], actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); aiSetTarget(slave[i], actor->spr.pos);
} }
else else
{ {
aiSetTarget(slave[i], actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); // try return to master aiSetTarget(slave[i], actor->spr.pos); // try return to master
} }
} }
} }

View file

@ -5227,7 +5227,7 @@ void aiFightFreeTargets(DBloodActor* actor)
{ {
if (!targetactor->IsDudeActor() || !targetactor->hasX()) continue; if (!targetactor->IsDudeActor() || !targetactor->hasX()) continue;
else if (targetactor->GetTarget() == actor) else if (targetactor->GetTarget() == actor)
aiSetTarget(targetactor, targetactor->int_pos().X, targetactor->int_pos().Y, targetactor->int_pos().Z); aiSetTarget(targetactor, targetactor->spr.pos);
} }
} }
@ -5331,7 +5331,7 @@ void aiFightAlarmDudesInSight(DBloodActor* actor, int max)
if (dudeactor->GetTarget() != nullptr || dudeactor->xspr.rxID > 0) if (dudeactor->GetTarget() != nullptr || dudeactor->xspr.rxID > 0)
continue; continue;
aiSetTarget(dudeactor, dudeactor->int_pos().X, dudeactor->int_pos().Y, dudeactor->int_pos().Z); aiSetTarget(dudeactor, dudeactor->spr.pos);
aiActivateDude(dudeactor); aiActivateDude(dudeactor);
if (max-- < 1) if (max-- < 1)
break; break;
@ -7011,14 +7011,14 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
auto actLeech = leechIsDropped(actor); auto actLeech = leechIsDropped(actor);
if (sourceactor->xspr.data4 == 3) if (sourceactor->xspr.data4 == 3)
{ {
aiSetTarget(actor, actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); aiSetTarget(actor, actor->spr.pos);
aiSetGenIdleState(actor); aiSetGenIdleState(actor);
if (actor->spr.type == kDudeModernCustom && actLeech) if (actor->spr.type == kDudeModernCustom && actLeech)
removeLeech(actLeech); removeLeech(actLeech);
} }
else if (sourceactor->xspr.data4 == 4) else if (sourceactor->xspr.data4 == 4)
{ {
aiSetTarget(actor, playeractor->int_pos().X, playeractor->int_pos().Y, playeractor->int_pos().Z); aiSetTarget(actor, playeractor->spr.pos);
if (actor->spr.type == kDudeModernCustom && actLeech) if (actor->spr.type == kDudeModernCustom && actLeech)
removeLeech(actLeech); removeLeech(actLeech);
} }
@ -7035,7 +7035,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
if (!targetactor->IsDudeActor() || targetactor->xspr.health < 1 || !aiFightDudeCanSeeTarget(actor, pDudeInfo, targetactor)) if (!targetactor->IsDudeActor() || targetactor->xspr.health < 1 || !aiFightDudeCanSeeTarget(actor, pDudeInfo, targetactor))
{ {
aiSetTarget(actor, actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); aiSetTarget(actor, actor->spr.pos);
} }
// dude attack or attacked by target that does not fit by data id? // dude attack or attacked by target that does not fit by data id?
else if (sourceactor->xspr.data1 != 666 && targetactor->xspr.data1 != sourceactor->xspr.data1) else if (sourceactor->xspr.data1 != 666 && targetactor->xspr.data1 != sourceactor->xspr.data1)
@ -7043,7 +7043,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
if (aiFightDudeIsAffected(targetactor)) if (aiFightDudeIsAffected(targetactor))
{ {
// force stop attack target // force stop attack target
aiSetTarget(actor, actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); aiSetTarget(actor, actor->spr.pos);
if (actor->GetBurnSource() == targetactor) if (actor->GetBurnSource() == targetactor)
{ {
actor->xspr.burnTime = 0; actor->xspr.burnTime = 0;
@ -7051,7 +7051,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
} }
// force stop attack dude // force stop attack dude
aiSetTarget(targetactor, targetactor->int_pos().X, targetactor->int_pos().Y, targetactor->int_pos().Z); aiSetTarget(targetactor, targetactor->spr.pos);
if (targetactor->GetBurnSource() == actor) if (targetactor->GetBurnSource() == actor)
{ {
targetactor->xspr.burnTime = 0; targetactor->xspr.burnTime = 0;
@ -7077,7 +7077,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
// force mate stop attack dude, if he does // force mate stop attack dude, if he does
if (matetarget == actor) if (matetarget == actor)
{ {
aiSetTarget(mateactor, mateactor->int_pos().X, mateactor->int_pos().Y, mateactor->int_pos().Z); aiSetTarget(mateactor, mateactor->spr.pos);
} }
else if (actor->xspr.rxID != matetarget->xspr.rxID) else if (actor->xspr.rxID != matetarget->xspr.rxID)
{ {
@ -7088,13 +7088,13 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
else else
{ {
// force mate to stop attack another mate // force mate to stop attack another mate
aiSetTarget(mateactor, mateactor->int_pos().X, mateactor->int_pos().Y, mateactor->int_pos().Z); aiSetTarget(mateactor, mateactor->spr.pos);
} }
} }
// force dude stop attack mate, if target was not changed previously // force dude stop attack mate, if target was not changed previously
if (actor == mateactor) if (actor == mateactor)
aiSetTarget(actor, actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); aiSetTarget(actor, actor->spr.pos);
} }
@ -7121,7 +7121,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
// Make prev target not aim in dude // Make prev target not aim in dude
if (targetactor) if (targetactor)
{ {
aiSetTarget(targetactor, targetactor->int_pos().X, targetactor->int_pos().Y, targetactor->int_pos().Z); aiSetTarget(targetactor, targetactor->spr.pos);
if (!isActive(newtargactor)) if (!isActive(newtargactor))
aiActivateDude(newtargactor); aiActivateDude(newtargactor);
} }
@ -8111,7 +8111,7 @@ void aiPatrolStop(DBloodActor* actor, DBloodActor* targetactor, bool alarm)
else else
{ {
aiInitSprite(actor); aiInitSprite(actor);
aiSetTarget(actor, actor->xspr.int_TargetPos().X, actor->xspr.int_TargetPos().Y, actor->xspr.int_TargetPos().Z); aiSetTarget(actor, actor->xspr.TargetPos);
} }
actor->xspr.dudeFlag4 = patrol; // this must be kept so enemy can patrol after respawn again actor->xspr.dudeFlag4 = patrol; // this must be kept so enemy can patrol after respawn again
@ -8339,7 +8339,7 @@ void aiPatrolAlarmFull(DBloodActor* actor, DBloodActor* targetactor, bool chain)
continue; continue;
if (actor->GetTarget()) aiSetTarget(dudeactor, actor->GetTarget()); if (actor->GetTarget()) aiSetTarget(dudeactor, actor->GetTarget());
else aiSetTarget(dudeactor, actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z); else aiSetTarget(dudeactor, actor->spr.pos);
aiActivateDude(dudeactor); aiActivateDude(dudeactor);
if (chain) if (chain)