mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Merge pull request #1571
This commit is contained in:
commit
59bfd670c0
2 changed files with 45 additions and 19 deletions
|
@ -1148,6 +1148,46 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Actors::updateCombatMusic ()
|
||||||
|
{
|
||||||
|
MWWorld::Ptr player = getPlayer();
|
||||||
|
int hostilesCount = 0; // need to know this to play Battle music
|
||||||
|
|
||||||
|
for(PtrActorMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (!iter->first.getClass().getCreatureStats(iter->first).isDead())
|
||||||
|
{
|
||||||
|
bool inProcessingRange = (player.getRefData().getPosition().asVec3() - iter->first.getRefData().getPosition().asVec3()).length2()
|
||||||
|
<= sqrAiProcessingDistance;
|
||||||
|
|
||||||
|
if (MWBase::Environment::get().getMechanicsManager()->isAIActive() && inProcessingRange)
|
||||||
|
{
|
||||||
|
if (iter->first != player)
|
||||||
|
{
|
||||||
|
MWMechanics::CreatureStats& stats = iter->first.getClass().getCreatureStats(iter->first);
|
||||||
|
if (stats.getAiSequence().isInCombat() && !stats.isDead()) hostilesCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if we still have any player enemies to switch music
|
||||||
|
static int currentMusic = 0;
|
||||||
|
|
||||||
|
if (currentMusic != 1 && hostilesCount == 0 && !(player.getClass().getCreatureStats(player).isDead() &&
|
||||||
|
MWBase::Environment::get().getSoundManager()->isMusicPlaying()))
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore"));
|
||||||
|
currentMusic = 1;
|
||||||
|
}
|
||||||
|
else if (currentMusic != 2 && hostilesCount > 0)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Battle"));
|
||||||
|
currentMusic = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Actors::update (float duration, bool paused)
|
void Actors::update (float duration, bool paused)
|
||||||
{
|
{
|
||||||
if(!paused)
|
if(!paused)
|
||||||
|
@ -1165,8 +1205,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
MWWorld::Ptr player = getPlayer();
|
MWWorld::Ptr player = getPlayer();
|
||||||
|
|
||||||
int hostilesCount = 0; // need to know this to play Battle music
|
|
||||||
|
|
||||||
/// \todo move update logic to Actor class where appropriate
|
/// \todo move update logic to Actor class where appropriate
|
||||||
|
|
||||||
std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr> > cachedAllies; // will be filled as engageCombat iterates
|
std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr> > cachedAllies; // will be filled as engageCombat iterates
|
||||||
|
@ -1257,8 +1295,6 @@ namespace MWMechanics
|
||||||
CreatureStats &stats = iter->first.getClass().getCreatureStats(iter->first);
|
CreatureStats &stats = iter->first.getClass().getCreatureStats(iter->first);
|
||||||
if (isConscious(iter->first))
|
if (isConscious(iter->first))
|
||||||
stats.getAiSequence().execute(iter->first, *iter->second->getCharacterController(), iter->second->getAiState(), duration);
|
stats.getAiSequence().execute(iter->first, *iter->second->getCharacterController(), iter->second->getAiState(), duration);
|
||||||
|
|
||||||
if (stats.getAiSequence().isInCombat() && !stats.isDead()) hostilesCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1331,21 +1367,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
killDeadActors();
|
killDeadActors();
|
||||||
|
|
||||||
// check if we still have any player enemies to switch music
|
|
||||||
static int currentMusic = 0;
|
|
||||||
|
|
||||||
if (currentMusic != 1 && hostilesCount == 0 && !(player.getClass().getCreatureStats(player).isDead() &&
|
|
||||||
MWBase::Environment::get().getSoundManager()->isMusicPlaying()))
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore"));
|
|
||||||
currentMusic = 1;
|
|
||||||
}
|
|
||||||
else if (currentMusic != 2 && hostilesCount > 0)
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Battle"));
|
|
||||||
currentMusic = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static float sneakTimer = 0.f; // times update of sneak icon
|
static float sneakTimer = 0.f; // times update of sneak icon
|
||||||
|
|
||||||
// if player is in sneak state see if anyone detects him
|
// if player is in sneak state see if anyone detects him
|
||||||
|
@ -1412,6 +1433,8 @@ namespace MWMechanics
|
||||||
MWBase::Environment::get().getWindowManager()->setSneakVisibility(false);
|
MWBase::Environment::get().getWindowManager()->setSneakVisibility(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCombatMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::killDeadActors()
|
void Actors::killDeadActors()
|
||||||
|
|
|
@ -81,6 +81,9 @@ namespace MWMechanics
|
||||||
void dropActors (const MWWorld::CellStore *cellStore, const MWWorld::Ptr& ignore);
|
void dropActors (const MWWorld::CellStore *cellStore, const MWWorld::Ptr& ignore);
|
||||||
///< Deregister all actors (except for \a ignore) in the given cell.
|
///< Deregister all actors (except for \a ignore) in the given cell.
|
||||||
|
|
||||||
|
void updateCombatMusic();
|
||||||
|
///< Update combat music state
|
||||||
|
|
||||||
void update (float duration, bool paused);
|
void update (float duration, bool paused);
|
||||||
///< Update actor stats and store desired velocity vectors in \a movement
|
///< Update actor stats and store desired velocity vectors in \a movement
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue