forked from teamnwah/openmw-tes3coop
extracted function playIdleDialogueRandomly()
This commit is contained in:
parent
22059d68f6
commit
e294cd95cd
2 changed files with 32 additions and 26 deletions
|
@ -285,32 +285,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play idle voiced dialogue entries randomly
|
playIdleDialogueRandomly(actor);
|
||||||
int hello = cStats.getAiSetting(CreatureStats::AI_Hello).getModified();
|
|
||||||
if (hello > 0 && !MWBase::Environment::get().getWorld()->isSwimming(actor)
|
|
||||||
&& MWBase::Environment::get().getSoundManager()->sayDone(actor))
|
|
||||||
{
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
||||||
|
|
||||||
static float fVoiceIdleOdds = MWBase::Environment::get().getWorld()->getStore()
|
|
||||||
.get<ESM::GameSetting>().find("fVoiceIdleOdds")->getFloat();
|
|
||||||
|
|
||||||
float roll = Misc::Rng::rollProbability() * 10000.0f;
|
|
||||||
|
|
||||||
// In vanilla MW the chance was FPS dependent, and did not allow proper changing of fVoiceIdleOdds
|
|
||||||
// due to the roll being an integer.
|
|
||||||
// Our implementation does not have these issues, so needs to be recalibrated. We chose to
|
|
||||||
// use the chance MW would have when run at 60 FPS with the default value of the GMST for calibration.
|
|
||||||
float x = fVoiceIdleOdds * 0.6f * (MWBase::Environment::get().getFrameDuration() / 0.1f);
|
|
||||||
|
|
||||||
// Only say Idle voices when player is in LOS
|
|
||||||
// A bit counterintuitive, likely vanilla did this to reduce the appearance of
|
|
||||||
// voices going through walls?
|
|
||||||
if (roll < x && (player.getRefData().getPosition().asVec3() - pos.asVec3()).length2()
|
|
||||||
< 3000*3000 // maybe should be fAudioVoiceDefaultMaxDistance*fAudioMaxDistanceMult instead
|
|
||||||
&& MWBase::Environment::get().getWorld()->getLOS(player, actor))
|
|
||||||
MWBase::Environment::get().getDialogueManager()->say(actor, "idle");
|
|
||||||
}
|
|
||||||
|
|
||||||
float& lastReaction = storage.mReaction;
|
float& lastReaction = storage.mReaction;
|
||||||
lastReaction += duration;
|
lastReaction += duration;
|
||||||
|
@ -442,6 +417,36 @@ namespace MWMechanics
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiWander::playIdleDialogueRandomly(const MWWorld::Ptr& actor)
|
||||||
|
{
|
||||||
|
int hello = actor.getClass().getCreatureStats(actor).getAiSetting(CreatureStats::AI_Hello).getModified();
|
||||||
|
if (hello > 0 && !MWBase::Environment::get().getWorld()->isSwimming(actor)
|
||||||
|
&& MWBase::Environment::get().getSoundManager()->sayDone(actor))
|
||||||
|
{
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
|
|
||||||
|
static float fVoiceIdleOdds = MWBase::Environment::get().getWorld()->getStore()
|
||||||
|
.get<ESM::GameSetting>().find("fVoiceIdleOdds")->getFloat();
|
||||||
|
|
||||||
|
float roll = Misc::Rng::rollProbability() * 10000.0f;
|
||||||
|
|
||||||
|
// In vanilla MW the chance was FPS dependent, and did not allow proper changing of fVoiceIdleOdds
|
||||||
|
// due to the roll being an integer.
|
||||||
|
// Our implementation does not have these issues, so needs to be recalibrated. We chose to
|
||||||
|
// use the chance MW would have when run at 60 FPS with the default value of the GMST for calibration.
|
||||||
|
float x = fVoiceIdleOdds * 0.6f * (MWBase::Environment::get().getFrameDuration() / 0.1f);
|
||||||
|
|
||||||
|
// Only say Idle voices when player is in LOS
|
||||||
|
// A bit counterintuitive, likely vanilla did this to reduce the appearance of
|
||||||
|
// voices going through walls?
|
||||||
|
const ESM::Position& pos = actor.getRefData().getPosition();
|
||||||
|
if (roll < x && (player.getRefData().getPosition().asVec3() - pos.asVec3()).length2()
|
||||||
|
< 3000 * 3000 // maybe should be fAudioVoiceDefaultMaxDistance*fAudioMaxDistanceMult instead
|
||||||
|
&& MWBase::Environment::get().getWorld()->getLOS(player, actor))
|
||||||
|
MWBase::Environment::get().getDialogueManager()->say(actor, "idle");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AiWander::playGreetingIfPlayerGetsTooClose(const MWWorld::Ptr& actor, AiWanderStorage& storage)
|
void AiWander::playGreetingIfPlayerGetsTooClose(const MWWorld::Ptr& actor, AiWanderStorage& storage)
|
||||||
{
|
{
|
||||||
// Play a random voice greeting if the player gets too close
|
// Play a random voice greeting if the player gets too close
|
||||||
|
|
|
@ -74,6 +74,7 @@ namespace MWMechanics
|
||||||
void setPathToAnAllowedNode(const MWWorld::Ptr& actor, AiWanderStorage& storage, const ESM::Position& actorPos);
|
void setPathToAnAllowedNode(const MWWorld::Ptr& actor, AiWanderStorage& storage, const ESM::Position& actorPos);
|
||||||
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);
|
||||||
|
|
||||||
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