|
|
|
@ -8,7 +8,6 @@
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
|
#include "../mwbase/dialoguemanager.hpp"
|
|
|
|
|
#include "../mwbase/soundmanager.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
|
#include "../mwworld/player.hpp"
|
|
|
|
@ -189,6 +188,9 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
void MechanicsManager::updateCell(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr)
|
|
|
|
|
{
|
|
|
|
|
if(old == mWatched)
|
|
|
|
|
mWatched = ptr;
|
|
|
|
|
|
|
|
|
|
if(MWWorld::Class::get(ptr).isActor())
|
|
|
|
|
mActors.updateActor(old, ptr);
|
|
|
|
|
else
|
|
|
|
@ -213,98 +215,76 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
void MechanicsManager::update(float duration, bool paused)
|
|
|
|
|
{
|
|
|
|
|
if (!mWatched.isEmpty())
|
|
|
|
|
if(!mWatched.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
MWMechanics::CreatureStats& stats =
|
|
|
|
|
MWWorld::Class::get (mWatched).getCreatureStats (mWatched);
|
|
|
|
|
|
|
|
|
|
MWMechanics::NpcStats& npcStats =
|
|
|
|
|
MWWorld::Class::get (mWatched).getNpcStats (mWatched);
|
|
|
|
|
|
|
|
|
|
static const char *attributeNames[8] =
|
|
|
|
|
{
|
|
|
|
|
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5",
|
|
|
|
|
"AttribVal6", "AttribVal7", "AttribVal8"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char *dynamicNames[3] =
|
|
|
|
|
MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager();
|
|
|
|
|
const MWMechanics::NpcStats &stats = mWatched.getClass().getNpcStats(mWatched);
|
|
|
|
|
for(int i = 0;i < ESM::Attribute::Length;++i)
|
|
|
|
|
{
|
|
|
|
|
"HBar", "MBar", "FBar"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<8; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (stats.getAttribute(i)!=mWatchedCreature.getAttribute(i))
|
|
|
|
|
if(stats.getAttribute(i) != mWatchedStats.getAttribute(i))
|
|
|
|
|
{
|
|
|
|
|
mWatchedCreature.setAttribute(i, stats.getAttribute(i));
|
|
|
|
|
std::stringstream attrname;
|
|
|
|
|
attrname << "AttribVal"<<(i+1);
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setValue (attributeNames[i], stats.getAttribute(i));
|
|
|
|
|
mWatchedStats.setAttribute(i, stats.getAttribute(i));
|
|
|
|
|
winMgr->setValue(attrname.str(), stats.getAttribute(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stats.getHealth() != mWatchedCreature.getHealth()) {
|
|
|
|
|
mWatchedCreature.setHealth(stats.getHealth());
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[0], stats.getHealth());
|
|
|
|
|
if(stats.getHealth() != mWatchedStats.getHealth())
|
|
|
|
|
{
|
|
|
|
|
static const std::string hbar("HBar");
|
|
|
|
|
mWatchedStats.setHealth(stats.getHealth());
|
|
|
|
|
winMgr->setValue(hbar, stats.getHealth());
|
|
|
|
|
}
|
|
|
|
|
if (stats.getMagicka() != mWatchedCreature.getMagicka()) {
|
|
|
|
|
mWatchedCreature.setMagicka(stats.getMagicka());
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[1], stats.getMagicka());
|
|
|
|
|
if(stats.getMagicka() != mWatchedStats.getMagicka())
|
|
|
|
|
{
|
|
|
|
|
static const std::string mbar("MBar");
|
|
|
|
|
mWatchedStats.setMagicka(stats.getMagicka());
|
|
|
|
|
winMgr->setValue(mbar, stats.getMagicka());
|
|
|
|
|
}
|
|
|
|
|
if (stats.getFatigue() != mWatchedCreature.getFatigue()) {
|
|
|
|
|
mWatchedCreature.setFatigue(stats.getFatigue());
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[2], stats.getFatigue());
|
|
|
|
|
if(stats.getFatigue() != mWatchedStats.getFatigue())
|
|
|
|
|
{
|
|
|
|
|
static const std::string fbar("FBar");
|
|
|
|
|
mWatchedStats.setFatigue(stats.getFatigue());
|
|
|
|
|
winMgr->setValue(fbar, stats.getFatigue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(npcStats.getTimeToStartDrowning() != mWatchedNpc.getTimeToStartDrowning())
|
|
|
|
|
if(stats.getTimeToStartDrowning() != mWatchedStats.getTimeToStartDrowning())
|
|
|
|
|
{
|
|
|
|
|
mWatchedNpc.setTimeToStartDrowning(npcStats.getTimeToStartDrowning());
|
|
|
|
|
if(npcStats.getTimeToStartDrowning()>=20.0)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setDrowningBarVisibility(false);
|
|
|
|
|
}
|
|
|
|
|
mWatchedStats.setTimeToStartDrowning(stats.getTimeToStartDrowning());
|
|
|
|
|
if(stats.getTimeToStartDrowning() >= 20.0f)
|
|
|
|
|
winMgr->setDrowningBarVisibility(false);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setDrowningBarVisibility(true);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setDrowningTimeLeft(npcStats.getTimeToStartDrowning());
|
|
|
|
|
winMgr->setDrowningBarVisibility(true);
|
|
|
|
|
winMgr->setDrowningTimeLeft(stats.getTimeToStartDrowning());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool update = false;
|
|
|
|
|
|
|
|
|
|
//Loop over ESM::Skill::SkillEnum
|
|
|
|
|
for(int i = 0; i < 27; ++i)
|
|
|
|
|
for(int i = 0; i < ESM::Skill::Length; ++i)
|
|
|
|
|
{
|
|
|
|
|
if(npcStats.getSkill (i) != mWatchedNpc.getSkill (i))
|
|
|
|
|
if(stats.getSkill(i) != mWatchedStats.getSkill(i))
|
|
|
|
|
{
|
|
|
|
|
update = true;
|
|
|
|
|
mWatchedNpc.getSkill (i) = npcStats.getSkill (i);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.getSkill (i));
|
|
|
|
|
mWatchedStats.getSkill(i) = stats.getSkill(i);
|
|
|
|
|
winMgr->setValue((ESM::Skill::SkillEnum)i, stats.getSkill(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->updateSkillArea();
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setValue ("level", stats.getLevel());
|
|
|
|
|
}
|
|
|
|
|
if(update)
|
|
|
|
|
winMgr->updateSkillArea();
|
|
|
|
|
|
|
|
|
|
//update drowning sound
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
MWBase::SoundManager * sndmgr = MWBase::Environment::get().getSoundManager();
|
|
|
|
|
MWWorld::Ptr playerPtr = world->getPlayer().getPlayer();
|
|
|
|
|
NpcStats& playerStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
|
|
|
|
|
if(!sndmgr->getSoundPlaying(MWWorld::Ptr(), "drown") && playerStats.getTimeToStartDrowning()==0.0)
|
|
|
|
|
{
|
|
|
|
|
sndmgr->playSound("drown",1.0,1.0,MWBase::SoundManager::Play_TypeSfx,MWBase::SoundManager::Play_Loop);
|
|
|
|
|
}
|
|
|
|
|
if(playerStats.getTimeToStartDrowning()>0.0)
|
|
|
|
|
{
|
|
|
|
|
//no need to check if it's playing, stop sound does nothing in that case
|
|
|
|
|
sndmgr->stopSound("drown");
|
|
|
|
|
winMgr->setValue("level", stats.getLevel());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mUpdatePlayer)
|
|
|
|
|
{
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
|
|
// basic player profile; should not change anymore after the creation phase is finished.
|
|
|
|
|
MWBase::WindowManager *winMgr =
|
|
|
|
|
MWBase::Environment::get().getWindowManager();
|
|
|
|
|