mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
Play 'hello' voiced dialogue entries in AIWander
This commit is contained in:
parent
0adc0f56ed
commit
bea161331c
@ -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;
|
||||
|
@ -32,6 +32,8 @@ namespace MWMechanics
|
||||
std::vector<int> mIdle;
|
||||
bool mRepeat;
|
||||
|
||||
bool mSaidGreeting;
|
||||
|
||||
float mX;
|
||||
float mY;
|
||||
float mZ;
|
||||
|
Loading…
Reference in New Issue
Block a user