mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-07 01:45:32 +00:00
renamed mRotate to mTurnActorGivingGreetingToFacePlayer
This commit is contained in:
parent
833ad5a2b4
commit
3ebe9fb34f
2 changed files with 17 additions and 16 deletions
|
@ -51,10 +51,10 @@ namespace MWMechanics
|
||||||
/// \brief This class holds the variables AiWander needs which are deleted if the package becomes inactive.
|
/// \brief This class holds the variables AiWander needs which are deleted if the package becomes inactive.
|
||||||
struct AiWanderStorage : AiTemporaryBase
|
struct AiWanderStorage : AiTemporaryBase
|
||||||
{
|
{
|
||||||
// the z rotation angle (degrees) we want to reach
|
// the z rotation angle to reach
|
||||||
// used every frame when mRotate is true
|
// when mTurnActorGivingGreetingToFacePlayer is true
|
||||||
float mTargetAngleRadians;
|
float mTargetAngleRadians;
|
||||||
bool mRotate;
|
bool mTurnActorGivingGreetingToFacePlayer;
|
||||||
float mReaction; // update some actions infrequently
|
float mReaction; // update some actions infrequently
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
AiWanderStorage():
|
AiWanderStorage():
|
||||||
mTargetAngleRadians(0),
|
mTargetAngleRadians(0),
|
||||||
mRotate(false),
|
mTurnActorGivingGreetingToFacePlayer(false),
|
||||||
mReaction(0),
|
mReaction(0),
|
||||||
mSaidGreeting(AiWander::Greet_None),
|
mSaidGreeting(AiWander::Greet_None),
|
||||||
mGreetingTimer(0),
|
mGreetingTimer(0),
|
||||||
|
@ -240,15 +240,13 @@ namespace MWMechanics
|
||||||
evadeObstacles(actor, storage, duration);
|
evadeObstacles(actor, storage, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool& rotate = storage.mTurnActorGivingGreetingToFacePlayer;
|
||||||
float& targetAngleRadians = storage.mTargetAngleRadians;
|
|
||||||
bool& rotate = storage.mRotate;
|
|
||||||
if (rotate)
|
if (rotate)
|
||||||
{
|
{
|
||||||
// Reduce the turning animation glitch by using a *HUGE* value of
|
// Reduce the turning animation glitch by using a *HUGE* value of
|
||||||
// epsilon... TODO: a proper fix might be in either the physics or the
|
// epsilon... TODO: a proper fix might be in either the physics or the
|
||||||
// animation subsystem
|
// animation subsystem
|
||||||
if (zTurn(actor, targetAngleRadians, osg::DegreesToRadians(5.f)))
|
if (zTurn(actor, storage.mTargetAngleRadians, osg::DegreesToRadians(5.f)))
|
||||||
rotate = false;
|
rotate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,14 +489,7 @@ namespace MWMechanics
|
||||||
getRandomIdle(storage.mPlayedIdle);
|
getRandomIdle(storage.mPlayedIdle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storage.mRotate)
|
turnActorToFacePlayer(actorPos, playerPos, storage);
|
||||||
{
|
|
||||||
osg::Vec3f dir = playerPos - actorPos;
|
|
||||||
|
|
||||||
float faceAngleRadians = std::atan2(dir.x(), dir.y());
|
|
||||||
storage.mTargetAngleRadians = faceAngleRadians;
|
|
||||||
storage.mRotate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (greetingTimer >= GREETING_SHOULD_END)
|
if (greetingTimer >= GREETING_SHOULD_END)
|
||||||
{
|
{
|
||||||
|
@ -515,6 +506,15 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiWander::turnActorToFacePlayer(const osg::Vec3f& actorPosition, const osg::Vec3f& playerPosition, AiWanderStorage& storage)
|
||||||
|
{
|
||||||
|
osg::Vec3f dir = playerPosition - actorPosition;
|
||||||
|
|
||||||
|
float faceAngleRadians = std::atan2(dir.x(), dir.y());
|
||||||
|
storage.mTargetAngleRadians = faceAngleRadians;
|
||||||
|
storage.mTurnActorGivingGreetingToFacePlayer = true;
|
||||||
|
}
|
||||||
|
|
||||||
void AiWander::setPathToAnAllowedNode(const MWWorld::Ptr& actor, AiWanderStorage& storage, const ESM::Position& actorPos)
|
void AiWander::setPathToAnAllowedNode(const MWWorld::Ptr& actor, AiWanderStorage& storage, const ESM::Position& actorPos)
|
||||||
{
|
{
|
||||||
unsigned int randNode = Misc::Rng::rollDice(mAllowedNodes.size());
|
unsigned int randNode = Misc::Rng::rollDice(mAllowedNodes.size());
|
||||||
|
|
|
@ -75,6 +75,7 @@ namespace MWMechanics
|
||||||
void playGreetingIfPlayerGetsTooClose(const MWWorld::Ptr& actor, AiWanderStorage& storage);
|
void playGreetingIfPlayerGetsTooClose(const MWWorld::Ptr& actor, AiWanderStorage& storage);
|
||||||
void evadeObstacles(const MWWorld::Ptr& actor, AiWanderStorage& storage, float duration);
|
void evadeObstacles(const MWWorld::Ptr& actor, AiWanderStorage& storage, float duration);
|
||||||
void playIdleDialogueRandomly(const MWWorld::Ptr& actor);
|
void playIdleDialogueRandomly(const MWWorld::Ptr& actor);
|
||||||
|
void turnActorToFacePlayer(const osg::Vec3f& actorPosition, const osg::Vec3f& playerPosition, AiWanderStorage& storage);
|
||||||
|
|
||||||
int mDistance; // how far the actor can wander from the spawn point
|
int mDistance; // how far the actor can wander from the spawn point
|
||||||
int mDuration;
|
int mDuration;
|
||||||
|
|
Loading…
Reference in a new issue