|
|
@ -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()
|
|
|
|