|
|
|
@ -7,6 +7,7 @@
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
|
|
|
|
#include "../mwbase/dialoguemanager.hpp"
|
|
|
|
|
|
|
|
|
|
#include "creaturestats.hpp"
|
|
|
|
|
#include <OgreVector3.h>
|
|
|
|
|
|
|
|
|
@ -31,6 +32,7 @@ namespace MWMechanics
|
|
|
|
|
, mX(0)
|
|
|
|
|
, mY(0)
|
|
|
|
|
, mZ(0)
|
|
|
|
|
, mSaidGreeting(false)
|
|
|
|
|
{
|
|
|
|
|
for(unsigned short counter = 0; counter < mIdle.size(); counter++)
|
|
|
|
|
{
|
|
|
|
@ -197,6 +199,38 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
if(mIdleNow)
|
|
|
|
|
{
|
|
|
|
|
// Play a random voice greeting if the player gets too close
|
|
|
|
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
|
|
|
|
|
|
float hello = actor.getClass().getCreatureStats(actor).getAiSetting(CreatureStats::AI_Hello).getModified();
|
|
|
|
|
float helloDistance = hello;
|
|
|
|
|
int iGreetDistanceMultiplier = store.get<ESM::GameSetting>().find("iGreetDistanceMultiplier")->getInt();
|
|
|
|
|
helloDistance *= iGreetDistanceMultiplier;
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|
|
float playerDist = Ogre::Vector3(player.getRefData().getPosition().pos).distance(
|
|
|
|
|
Ogre::Vector3(actor.getRefData().getPosition().pos));
|
|
|
|
|
|
|
|
|
|
if (!mSaidGreeting)
|
|
|
|
|
{
|
|
|
|
|
// TODO: check if actor is aware / has line of sight
|
|
|
|
|
if (playerDist <= helloDistance
|
|
|
|
|
// Only play a greeting if the player is not moving
|
|
|
|
|
&& Ogre::Vector3(player.getClass().getMovementSettings(player).mPosition).squaredLength() == 0)
|
|
|
|
|
{
|
|
|
|
|
mSaidGreeting = true;
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->say(actor, "hello");
|
|
|
|
|
// TODO: turn to face player and interrupt the idle animation?
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
float fGreetDistanceReset = store.get<ESM::GameSetting>().find("fGreetDistanceReset")->getFloat();
|
|
|
|
|
if (playerDist >= fGreetDistanceReset * iGreetDistanceMultiplier)
|
|
|
|
|
mSaidGreeting = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if idle animation finished
|
|
|
|
|
if(!checkIdle(actor, mPlayedIdle))
|
|
|
|
|
{
|
|
|
|
|
mPlayedIdle = 0;
|
|
|
|
|