1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 20:53:50 +00:00

ObstacleCheck: fix evasion issue

The check if (samePosition... would not work as intended because actors do not move in every frame when the framerate is higher than the physics framerate. In that case the actor would change its evasion direction almost every frame.
This commit is contained in:
scrawl 2015-11-09 20:26:18 +01:00
parent caa523a959
commit d233bc483d
2 changed files with 6 additions and 9 deletions

View file

@ -163,13 +163,13 @@ namespace MWMechanics
{ {
mStuckDuration = 0; mStuckDuration = 0;
mWalkState = State_Evade; mWalkState = State_Evade;
chooseEvasionDirection();
} }
} }
} }
/* FALL THROUGH */ /* FALL THROUGH */
case State_Evade: case State_Evade:
{ {
chooseEvasionDirection(samePosition);
mEvadeDuration += duration; mEvadeDuration += duration;
if(mEvadeDuration < DURATION_TO_EVADE) if(mEvadeDuration < DURATION_TO_EVADE)
return true; return true;
@ -191,16 +191,13 @@ namespace MWMechanics
actorMovement.mPosition[1] = evadeDirections[mEvadeDirectionIndex][1]; actorMovement.mPosition[1] = evadeDirections[mEvadeDirectionIndex][1];
} }
void ObstacleCheck::chooseEvasionDirection(bool samePosition) void ObstacleCheck::chooseEvasionDirection()
{ {
// change direction if attempt didn't work // change direction if attempt didn't work
if (samePosition && (0 < mEvadeDuration)) ++mEvadeDirectionIndex;
if (mEvadeDirectionIndex == NUM_EVADE_DIRECTIONS)
{ {
++mEvadeDirectionIndex; mEvadeDirectionIndex = 0;
if (mEvadeDirectionIndex == NUM_EVADE_DIRECTIONS)
{
mEvadeDirectionIndex = 0;
}
} }
} }

View file

@ -65,7 +65,7 @@ namespace MWMechanics
float mDistSameSpot; // take account of actor's speed float mDistSameSpot; // take account of actor's speed
int mEvadeDirectionIndex; int mEvadeDirectionIndex;
void chooseEvasionDirection(bool samePosition); void chooseEvasionDirection();
}; };
} }