- target stuff in aiInitSprite

This commit is contained in:
Christoph Oelckers 2021-09-16 21:11:26 +02:00
parent b8d55feb1e
commit 39b9ddc04c

View file

@ -1730,16 +1730,20 @@ void aiInitSprite(DBloodActor* actor)
pDudeExtraE->active = 0; pDudeExtraE->active = 0;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
int stateTimer = -1, targetMarker = -1; int stateTimer = -1;
int targetX = 0, targetY = 0, targetZ = 0; int targetX = 0, targetY = 0, targetZ = 0;
DBloodActor* pTargetMarker = nullptr;
// dude patrol init // dude patrol init
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_i) && sprite[pXSprite->target_i].type == kMarkerPath) { if (pXSprite->dudeFlag4 && actor->GetTarget() && actor->GetTarget()->s().type == kMarkerPath)
stateTimer = pXSprite->stateTimer; targetMarker = pXSprite->target_i; {
targetX = pXSprite->targetX; targetY = pXSprite->targetY; stateTimer = pXSprite->stateTimer;
pTargetMarker = actor->GetTarget();
targetX = pXSprite->targetX;
targetY = pXSprite->targetY;
targetZ = pXSprite->targetZ; targetZ = pXSprite->targetZ;
} }
} }
@ -1955,9 +1959,9 @@ void aiInitSprite(DBloodActor* actor)
if (pXSprite->dudeFlag4) if (pXSprite->dudeFlag4)
{ {
// restore dude's path // restore dude's path
if (spriRangeIsFine(targetMarker)) if (pTargetMarker)
{ {
pXSprite->target_i = targetMarker; actor->SetTarget(pTargetMarker);
pXSprite->targetX = targetX; pXSprite->targetX = targetX;
pXSprite->targetY = targetY; pXSprite->targetY = targetY;
pXSprite->targetZ = targetZ; pXSprite->targetZ = targetZ;