2012-03-30 14:18:58 +00:00
|
|
|
|
|
|
|
#include "actors.hpp"
|
|
|
|
|
2012-03-30 15:01:55 +00:00
|
|
|
#include <typeinfo>
|
|
|
|
|
2012-07-03 13:32:38 +00:00
|
|
|
#include <OgreVector3.h>
|
|
|
|
|
2012-03-30 15:01:55 +00:00
|
|
|
#include <components/esm/loadnpc.hpp>
|
|
|
|
|
2012-10-01 15:17:04 +00:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-09-21 15:53:16 +00:00
|
|
|
|
2012-03-30 14:18:58 +00:00
|
|
|
#include "../mwworld/class.hpp"
|
2012-03-31 15:26:15 +00:00
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2013-08-28 00:08:23 +00:00
|
|
|
#include "../mwworld/player.hpp"
|
2013-11-21 02:39:55 +00:00
|
|
|
#include "../mwworld/manualref.hpp"
|
|
|
|
#include "../mwworld/actionequip.hpp"
|
2012-03-30 14:18:58 +00:00
|
|
|
|
2012-09-21 15:53:16 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2013-08-28 00:08:23 +00:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
2012-09-21 15:53:16 +00:00
|
|
|
|
2013-08-07 13:34:11 +00:00
|
|
|
#include "npcstats.hpp"
|
2012-05-17 11:15:31 +00:00
|
|
|
#include "creaturestats.hpp"
|
2013-03-31 07:13:56 +00:00
|
|
|
#include "movement.hpp"
|
2012-05-17 11:15:31 +00:00
|
|
|
|
2013-11-18 11:33:09 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
|
|
|
|
|
|
|
#include "aicombat.hpp"
|
|
|
|
|
2013-11-21 02:39:55 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2013-11-21 03:11:06 +00:00
|
|
|
void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& actor)
|
2013-11-21 02:39:55 +00:00
|
|
|
{
|
|
|
|
if (bound)
|
|
|
|
{
|
2013-11-21 03:11:06 +00:00
|
|
|
MWWorld::Ptr newPtr = *actor.getClass().getContainerStore(actor).add(item, 1, actor);
|
|
|
|
MWWorld::ActionEquip action(newPtr);
|
|
|
|
action.execute(actor);
|
2013-11-21 02:39:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-21 03:11:06 +00:00
|
|
|
actor.getClass().getContainerStore(actor).remove(item, 1, actor);
|
2013-11-21 02:39:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-30 14:18:58 +00:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
2012-03-30 15:01:55 +00:00
|
|
|
void Actors::updateActor (const MWWorld::Ptr& ptr, float duration)
|
|
|
|
{
|
2012-05-17 11:21:49 +00:00
|
|
|
// magic effects
|
|
|
|
adjustMagicEffects (ptr);
|
2013-12-28 16:19:35 +00:00
|
|
|
if (ptr.getClass().getCreatureStats(ptr).needToRecalcDynamicStats())
|
|
|
|
calculateDynamicStats (ptr);
|
2013-11-16 02:16:21 +00:00
|
|
|
calculateCreatureStatModifiers (ptr, duration);
|
2012-09-21 15:53:16 +00:00
|
|
|
|
2013-05-27 02:33:45 +00:00
|
|
|
if(!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
2013-05-27 02:54:59 +00:00
|
|
|
{
|
2013-10-12 22:32:28 +00:00
|
|
|
// AI
|
2013-11-19 17:43:32 +00:00
|
|
|
if(MWBase::Environment::get().getMechanicsManager()->isAIActive())
|
2013-11-18 11:33:09 +00:00
|
|
|
{
|
2013-11-19 17:43:32 +00:00
|
|
|
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
|
|
//engage combat or not?
|
|
|
|
if(ptr != MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && !creatureStats.isHostile())
|
2013-11-18 11:33:09 +00:00
|
|
|
{
|
2013-11-19 17:43:32 +00:00
|
|
|
ESM::Position playerpos = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getRefData().getPosition();
|
|
|
|
ESM::Position actorpos = ptr.getRefData().getPosition();
|
|
|
|
float d = sqrt((actorpos.pos[0] - playerpos.pos[0])*(actorpos.pos[0] - playerpos.pos[0])
|
|
|
|
+(actorpos.pos[1] - playerpos.pos[1])*(actorpos.pos[1] - playerpos.pos[1])
|
|
|
|
+(actorpos.pos[2] - playerpos.pos[2])*(actorpos.pos[2] - playerpos.pos[2]));
|
|
|
|
float fight = ptr.getClass().getCreatureStats(ptr).getAiSetting(1);
|
|
|
|
float disp = 100; //creatures don't have disposition, so set it to 100 by default
|
|
|
|
if(ptr.getTypeName() == typeid(ESM::NPC).name())
|
2013-11-18 22:03:44 +00:00
|
|
|
{
|
2013-11-19 17:43:32 +00:00
|
|
|
disp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(ptr);
|
|
|
|
}
|
|
|
|
bool LOS = MWBase::Environment::get().getWorld()->getLOS(ptr,MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
|
|
|
if( ( (fight == 100 )
|
|
|
|
|| (fight >= 95 && d <= 3000)
|
|
|
|
|| (fight >= 90 && d <= 2000)
|
|
|
|
|| (fight >= 80 && d <= 1000)
|
|
|
|
|| (fight >= 80 && disp <= 40)
|
|
|
|
|| (fight >= 70 && disp <= 35 && d <= 1000)
|
|
|
|
|| (fight >= 60 && disp <= 30 && d <= 1000)
|
|
|
|
|| (fight >= 50 && disp == 0)
|
|
|
|
|| (fight >= 40 && disp <= 10 && d <= 500) )
|
|
|
|
&& LOS
|
|
|
|
)
|
|
|
|
{
|
|
|
|
creatureStats.getAiSequence().stack(AiCombat("player"));
|
|
|
|
creatureStats.setHostile(true);
|
2013-11-18 22:03:44 +00:00
|
|
|
}
|
2013-11-18 11:33:09 +00:00
|
|
|
}
|
2013-11-19 17:43:32 +00:00
|
|
|
|
|
|
|
creatureStats.getAiSequence().execute (ptr,duration);
|
2013-11-18 11:33:09 +00:00
|
|
|
}
|
2013-10-12 22:32:28 +00:00
|
|
|
|
|
|
|
// fatigue restoration
|
|
|
|
calculateRestoration(ptr, duration);
|
2013-05-27 02:54:59 +00:00
|
|
|
}
|
2012-03-30 15:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
|
|
|
{
|
2013-08-07 13:34:11 +00:00
|
|
|
if(!paused)
|
2013-10-15 19:23:42 +00:00
|
|
|
{
|
2013-08-08 07:09:29 +00:00
|
|
|
updateDrowning(ptr, duration);
|
2013-11-09 09:49:00 +00:00
|
|
|
calculateNpcStatModifiers(ptr);
|
2013-10-16 00:56:42 +00:00
|
|
|
updateEquippedLight(ptr, duration);
|
2013-10-15 19:23:42 +00:00
|
|
|
}
|
2012-03-30 15:01:55 +00:00
|
|
|
}
|
|
|
|
|
2012-05-17 11:21:49 +00:00
|
|
|
void Actors::adjustMagicEffects (const MWWorld::Ptr& creature)
|
|
|
|
{
|
|
|
|
CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature);
|
|
|
|
|
2012-07-22 14:29:54 +00:00
|
|
|
MagicEffects now = creatureStats.getSpells().getMagicEffects();
|
2012-05-17 11:21:49 +00:00
|
|
|
|
2012-05-18 13:48:55 +00:00
|
|
|
if (creature.getTypeName()==typeid (ESM::NPC).name())
|
|
|
|
{
|
|
|
|
MWWorld::InventoryStore& store = MWWorld::Class::get (creature).getInventoryStore (creature);
|
|
|
|
now += store.getMagicEffects();
|
|
|
|
}
|
|
|
|
|
2012-07-22 14:29:54 +00:00
|
|
|
now += creatureStats.getActiveSpells().getMagicEffects();
|
2012-05-17 11:21:49 +00:00
|
|
|
|
2012-07-22 14:29:54 +00:00
|
|
|
MagicEffects diff = MagicEffects::diff (creatureStats.getMagicEffects(), now);
|
2012-05-17 11:21:49 +00:00
|
|
|
|
2012-07-22 14:29:54 +00:00
|
|
|
creatureStats.setMagicEffects(now);
|
2012-05-17 11:21:49 +00:00
|
|
|
|
|
|
|
// TODO apply diff to other stats
|
|
|
|
}
|
|
|
|
|
2012-07-17 10:18:43 +00:00
|
|
|
void Actors::calculateDynamicStats (const MWWorld::Ptr& ptr)
|
|
|
|
{
|
|
|
|
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
|
|
|
2013-08-28 05:44:52 +00:00
|
|
|
int strength = creatureStats.getAttribute(ESM::Attribute::Strength).getBase();
|
|
|
|
int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getBase();
|
|
|
|
int willpower = creatureStats.getAttribute(ESM::Attribute::Willpower).getBase();
|
|
|
|
int agility = creatureStats.getAttribute(ESM::Attribute::Agility).getBase();
|
|
|
|
int endurance = creatureStats.getAttribute(ESM::Attribute::Endurance).getBase();
|
2012-07-17 10:18:43 +00:00
|
|
|
|
2012-07-22 14:29:54 +00:00
|
|
|
double magickaFactor =
|
2013-03-16 22:28:26 +00:00
|
|
|
creatureStats.getMagicEffects().get (EffectKey (ESM::MagicEffect::FortifyMaximumMagicka)).mMagnitude * 0.1 + 0.5;
|
2012-07-17 10:18:43 +00:00
|
|
|
|
2012-10-19 11:10:06 +00:00
|
|
|
DynamicStat<float> magicka = creatureStats.getMagicka();
|
2013-08-28 05:44:52 +00:00
|
|
|
float diff = (static_cast<int>(intelligence + magickaFactor*intelligence)) - magicka.getBase();
|
|
|
|
magicka.modify(diff);
|
|
|
|
creatureStats.setMagicka(magicka);
|
2013-03-18 09:54:47 +00:00
|
|
|
|
2012-10-19 11:10:06 +00:00
|
|
|
DynamicStat<float> fatigue = creatureStats.getFatigue();
|
2013-08-28 05:44:52 +00:00
|
|
|
diff = (strength+willpower+agility+endurance) - fatigue.getBase();
|
|
|
|
fatigue.modify(diff);
|
|
|
|
creatureStats.setFatigue(fatigue);
|
2012-07-17 10:18:43 +00:00
|
|
|
}
|
|
|
|
|
2012-09-21 15:53:16 +00:00
|
|
|
void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration)
|
|
|
|
{
|
2013-11-29 19:21:57 +00:00
|
|
|
if (ptr.getClass().getCreatureStats(ptr).isDead())
|
|
|
|
return;
|
2012-09-21 15:53:16 +00:00
|
|
|
CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
2013-10-12 22:32:28 +00:00
|
|
|
const MWWorld::Store<ESM::GameSetting>& settings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
|
|
|
|
int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified ();
|
|
|
|
|
|
|
|
float capacity = MWWorld::Class::get(ptr).getCapacity(ptr);
|
|
|
|
float encumbrance = MWWorld::Class::get(ptr).getEncumbrance(ptr);
|
|
|
|
float normalizedEncumbrance = (capacity == 0 ? 1 : encumbrance/capacity);
|
|
|
|
if (normalizedEncumbrance > 1)
|
|
|
|
normalizedEncumbrance = 1;
|
2012-09-21 15:53:16 +00:00
|
|
|
|
|
|
|
if (duration == 3600)
|
|
|
|
{
|
2013-10-12 22:32:28 +00:00
|
|
|
// the actor is sleeping, restore health and magicka
|
2012-09-21 15:53:16 +00:00
|
|
|
|
2013-10-12 22:32:28 +00:00
|
|
|
bool stunted = stats.getMagicEffects ().get(MWMechanics::EffectKey(ESM::MagicEffect::StuntedMagicka)).mMagnitude > 0;
|
2013-03-18 09:54:47 +00:00
|
|
|
|
2012-10-19 11:10:06 +00:00
|
|
|
DynamicStat<float> health = stats.getHealth();
|
|
|
|
health.setCurrent (health.getCurrent() + 0.1 * endurance);
|
|
|
|
stats.setHealth (health);
|
2012-09-21 15:53:16 +00:00
|
|
|
|
|
|
|
if (!stunted)
|
|
|
|
{
|
2013-10-12 22:32:28 +00:00
|
|
|
float fRestMagicMult = settings.find("fRestMagicMult")->getFloat ();
|
2013-03-18 09:54:47 +00:00
|
|
|
|
2012-10-19 11:10:06 +00:00
|
|
|
DynamicStat<float> magicka = stats.getMagicka();
|
|
|
|
magicka.setCurrent (magicka.getCurrent()
|
|
|
|
+ fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified());
|
|
|
|
stats.setMagicka (magicka);
|
2012-09-21 15:53:16 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-12 22:32:28 +00:00
|
|
|
|
|
|
|
// restore fatigue
|
|
|
|
|
|
|
|
float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
|
|
|
|
float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
|
|
|
float fEndFatigueMult = settings.find("fEndFatigueMult")->getFloat ();
|
|
|
|
|
|
|
|
float x = fFatigueReturnBase + fFatigueReturnMult * (1 - normalizedEncumbrance);
|
|
|
|
x *= fEndFatigueMult * endurance;
|
|
|
|
|
|
|
|
DynamicStat<float> fatigue = stats.getFatigue();
|
|
|
|
fatigue.setCurrent (fatigue.getCurrent() + duration * x);
|
|
|
|
stats.setFatigue (fatigue);
|
2012-09-21 15:53:16 +00:00
|
|
|
}
|
|
|
|
|
2013-11-16 02:16:21 +00:00
|
|
|
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration)
|
2012-07-17 13:49:37 +00:00
|
|
|
{
|
2013-08-28 04:40:31 +00:00
|
|
|
CreatureStats &creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
|
|
|
|
const MagicEffects &effects = creatureStats.getMagicEffects();
|
2012-07-17 13:49:37 +00:00
|
|
|
|
|
|
|
// attributes
|
2013-08-28 04:40:31 +00:00
|
|
|
for(int i = 0;i < ESM::Attribute::Length;++i)
|
2012-07-17 13:49:37 +00:00
|
|
|
{
|
2013-08-28 04:40:31 +00:00
|
|
|
Stat<int> stat = creatureStats.getAttribute(i);
|
|
|
|
stat.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifyAttribute, i)).mMagnitude -
|
2013-11-18 03:57:54 +00:00
|
|
|
effects.get(EffectKey(ESM::MagicEffect::DrainAttribute, i)).mMagnitude -
|
|
|
|
effects.get(EffectKey(ESM::MagicEffect::AbsorbAttribute, i)).mMagnitude);
|
2012-07-17 13:49:37 +00:00
|
|
|
|
2013-08-28 04:40:31 +00:00
|
|
|
creatureStats.setAttribute(i, stat);
|
2012-07-17 13:49:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// dynamic stats
|
2013-08-28 04:40:31 +00:00
|
|
|
for(int i = 0;i < 3;++i)
|
2012-10-19 11:10:06 +00:00
|
|
|
{
|
2013-08-28 04:40:31 +00:00
|
|
|
DynamicStat<float> stat = creatureStats.getDynamic(i);
|
2013-11-10 14:28:26 +00:00
|
|
|
stat.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifyHealth+i)).mMagnitude -
|
|
|
|
effects.get(EffectKey(ESM::MagicEffect::DrainHealth+i)).mMagnitude);
|
2013-03-18 09:54:47 +00:00
|
|
|
|
2013-11-19 17:43:32 +00:00
|
|
|
|
2013-11-16 04:06:54 +00:00
|
|
|
float currentDiff = creatureStats.getMagicEffects().get(EffectKey(ESM::MagicEffect::RestoreHealth+i)).mMagnitude
|
2013-11-18 03:57:54 +00:00
|
|
|
- creatureStats.getMagicEffects().get(EffectKey(ESM::MagicEffect::DamageHealth+i)).mMagnitude
|
2013-11-20 23:27:22 +00:00
|
|
|
- creatureStats.getMagicEffects().get(EffectKey(ESM::MagicEffect::AbsorbHealth+i)).mMagnitude;
|
2013-11-16 04:06:54 +00:00
|
|
|
stat.setCurrent(stat.getCurrent() + currentDiff * duration);
|
2013-11-16 02:16:21 +00:00
|
|
|
|
2013-08-28 04:40:31 +00:00
|
|
|
creatureStats.setDynamic(i, stat);
|
2013-03-18 09:54:47 +00:00
|
|
|
}
|
2013-11-10 14:28:26 +00:00
|
|
|
|
2013-11-16 02:16:21 +00:00
|
|
|
// Apply damage ticks
|
|
|
|
int damageEffects[] = {
|
2013-11-20 23:27:22 +00:00
|
|
|
ESM::MagicEffect::FireDamage, ESM::MagicEffect::ShockDamage, ESM::MagicEffect::FrostDamage, ESM::MagicEffect::Poison,
|
|
|
|
ESM::MagicEffect::SunDamage
|
2013-11-16 02:16:21 +00:00
|
|
|
};
|
2013-11-10 14:28:26 +00:00
|
|
|
|
2013-11-20 23:27:22 +00:00
|
|
|
DynamicStat<float> health = creatureStats.getHealth();
|
2013-11-16 02:16:21 +00:00
|
|
|
for (unsigned int i=0; i<sizeof(damageEffects)/sizeof(int); ++i)
|
|
|
|
{
|
|
|
|
float magnitude = creatureStats.getMagicEffects().get(EffectKey(damageEffects[i])).mMagnitude;
|
2013-11-20 23:27:22 +00:00
|
|
|
|
|
|
|
if (damageEffects[i] == ESM::MagicEffect::SunDamage)
|
|
|
|
{
|
|
|
|
// isInCell shouldn't be needed, but updateActor called during game start
|
|
|
|
if (!ptr.isInCell() || !ptr.getCell()->isExterior())
|
|
|
|
continue;
|
|
|
|
float time = MWBase::Environment::get().getWorld()->getTimeStamp().getHour();
|
|
|
|
float timeDiff = std::min(7.f, std::max(0.f, std::abs(time - 13)));
|
|
|
|
float damageScale = 1.f - timeDiff / 7.f;
|
|
|
|
// When cloudy, the sun damage effect is halved
|
2013-11-26 14:01:22 +00:00
|
|
|
static float fMagicSunBlockedMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
|
|
|
"fMagicSunBlockedMult")->getFloat();
|
|
|
|
|
2013-11-20 23:27:22 +00:00
|
|
|
int weather = MWBase::Environment::get().getWorld()->getCurrentWeather();
|
|
|
|
if (weather > 1)
|
2013-11-26 14:01:22 +00:00
|
|
|
damageScale *= fMagicSunBlockedMult;
|
2013-11-20 23:27:22 +00:00
|
|
|
health.setCurrent(health.getCurrent() - magnitude * duration * damageScale);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
health.setCurrent(health.getCurrent() - magnitude * duration);
|
|
|
|
|
2013-11-16 02:16:21 +00:00
|
|
|
}
|
2013-11-20 23:27:22 +00:00
|
|
|
creatureStats.setHealth(health);
|
2013-11-21 02:39:55 +00:00
|
|
|
|
|
|
|
// TODO: dirty flag for magic effects to avoid some unnecessary work below?
|
|
|
|
|
|
|
|
// Update bound effects
|
|
|
|
static std::map<int, std::string> boundItemsMap;
|
|
|
|
if (boundItemsMap.empty())
|
|
|
|
{
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundBattleAxe] = "battle_axe";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundBoots] = "boots";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundCuirass] = "cuirass";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundDagger] = "dagger";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundGloves] = "gauntlet"; // Note: needs both _left and _right variants, see below
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundHelm] = "helm";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundLongbow] = "longbow";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundLongsword] = "longsword";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundMace] = "mace";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundShield] = "shield";
|
|
|
|
boundItemsMap[ESM::MagicEffect::BoundSpear] = "spear";
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::map<int, std::string>::iterator it = boundItemsMap.begin(); it != boundItemsMap.end(); ++it)
|
|
|
|
{
|
|
|
|
bool found = creatureStats.mBoundItems.find(it->first) != creatureStats.mBoundItems.end();
|
|
|
|
int magnitude = creatureStats.getMagicEffects().get(EffectKey(it->first)).mMagnitude;
|
|
|
|
if (found != (magnitude > 0))
|
|
|
|
{
|
|
|
|
std::string item = "bound_" + it->second;
|
|
|
|
if (it->first == ESM::MagicEffect::BoundGloves)
|
|
|
|
{
|
|
|
|
adjustBoundItem(item + "_left", magnitude > 0, ptr);
|
|
|
|
adjustBoundItem(item + "_right", magnitude > 0, ptr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustBoundItem(item, magnitude > 0, ptr);
|
|
|
|
|
|
|
|
if (magnitude > 0)
|
|
|
|
creatureStats.mBoundItems.insert(it->first);
|
|
|
|
else
|
|
|
|
creatureStats.mBoundItems.erase(it->first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update summon effects
|
|
|
|
static std::map<int, std::string> summonMap;
|
|
|
|
if (summonMap.empty())
|
|
|
|
{
|
|
|
|
summonMap[ESM::MagicEffect::SummonAncestralGhost] = "ancestor_ghost_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonBear] = "BM_bear_black_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonBonelord] = "bonelord_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonBonewalker] = "bonewalker_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonBonewolf] = "BM_wolf_bone_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonCenturionSphere] = "centurion_sphere_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonClannfear] = "clannfear_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonDaedroth] = "daedroth_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonDremora] = "dremora_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonFabricant] = "fabricant_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonFlameAtronach] = "atronach_flame_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonFrostAtronach] = "atronach_frost_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonGoldenSaint] = "golden saint_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonGreaterBonewalker] = "bonewalker_greater_summ";
|
|
|
|
summonMap[ESM::MagicEffect::SummonHunger] = "hunger_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonScamp] = "scamp_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonSkeletalMinion] = "skeleton_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonStormAtronach] = "atronach_storm_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonWingedTwilight] = "winged twilight_summon";
|
|
|
|
summonMap[ESM::MagicEffect::SummonWolf] = "BM_wolf_grey_summon";
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::map<int, std::string>::iterator it = summonMap.begin(); it != summonMap.end(); ++it)
|
|
|
|
{
|
|
|
|
bool found = creatureStats.mSummonedCreatures.find(it->first) != creatureStats.mSummonedCreatures.end();
|
|
|
|
int magnitude = creatureStats.getMagicEffects().get(EffectKey(it->first)).mMagnitude;
|
|
|
|
if (found != (magnitude > 0))
|
|
|
|
{
|
|
|
|
if (magnitude > 0)
|
|
|
|
{
|
|
|
|
ESM::Position ipos = ptr.getRefData().getPosition();
|
|
|
|
Ogre::Vector3 pos(ipos.pos[0],ipos.pos[1],ipos.pos[2]);
|
|
|
|
Ogre::Quaternion rot(Ogre::Radian(-ipos.rot[2]), Ogre::Vector3::UNIT_Z);
|
|
|
|
const float distance = 50;
|
|
|
|
pos = pos + distance*rot.yAxis();
|
|
|
|
ipos.pos[0] = pos.x;
|
|
|
|
ipos.pos[1] = pos.y;
|
|
|
|
ipos.pos[2] = pos.z;
|
|
|
|
ipos.rot[0] = 0;
|
|
|
|
ipos.rot[1] = 0;
|
|
|
|
ipos.rot[2] = 0;
|
|
|
|
|
|
|
|
MWWorld::CellStore* store = ptr.getCell();
|
|
|
|
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), it->second, 1);
|
|
|
|
ref.getPtr().getCellRef().mPos = ipos;
|
|
|
|
|
|
|
|
// TODO: Add AI to follow player and fight for him
|
|
|
|
|
|
|
|
creatureStats.mSummonedCreatures.insert(std::make_pair(it->first,
|
|
|
|
MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),*store,ipos).getRefData().getHandle()));
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string handle = creatureStats.mSummonedCreatures[it->first];
|
|
|
|
// TODO: Show death animation before deleting? We shouldn't allow looting the corpse while the animation
|
|
|
|
// plays though, which is a rather lame exploit in vanilla.
|
|
|
|
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle);
|
|
|
|
if (!ptr.isEmpty())
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWorld()->deleteObject(ptr);
|
|
|
|
creatureStats.mSummonedCreatures.erase(it->first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-17 13:49:37 +00:00
|
|
|
}
|
|
|
|
|
2013-11-09 09:49:00 +00:00
|
|
|
void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr)
|
|
|
|
{
|
|
|
|
NpcStats &npcStats = MWWorld::Class::get(ptr).getNpcStats(ptr);
|
|
|
|
const MagicEffects &effects = npcStats.getMagicEffects();
|
|
|
|
|
|
|
|
// skills
|
|
|
|
for(int i = 0;i < ESM::Skill::Length;++i)
|
|
|
|
{
|
|
|
|
Stat<float>& skill = npcStats.getSkill(i);
|
|
|
|
skill.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifySkill, i)).mMagnitude -
|
2013-11-18 03:57:54 +00:00
|
|
|
effects.get(EffectKey(ESM::MagicEffect::DrainSkill, i)).mMagnitude -
|
|
|
|
effects.get(EffectKey(ESM::MagicEffect::AbsorbSkill, i)).mMagnitude);
|
2013-11-09 09:49:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-07 13:34:11 +00:00
|
|
|
void Actors::updateDrowning(const MWWorld::Ptr& ptr, float duration)
|
|
|
|
{
|
2013-08-28 00:08:23 +00:00
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
NpcStats &stats = ptr.getClass().getNpcStats(ptr);
|
|
|
|
if(world->isSubmerged(ptr) &&
|
2013-08-09 08:14:08 +00:00
|
|
|
stats.getMagicEffects().get(ESM::MagicEffect::WaterBreathing).mMagnitude == 0)
|
2013-08-07 13:34:11 +00:00
|
|
|
{
|
2013-08-28 00:08:23 +00:00
|
|
|
float timeLeft = 0.0f;
|
2013-08-09 08:14:08 +00:00
|
|
|
if(stats.getFatigue().getCurrent() == 0)
|
2013-08-07 13:34:11 +00:00
|
|
|
stats.setTimeToStartDrowning(0);
|
2013-08-28 00:08:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
timeLeft = stats.getTimeToStartDrowning() - duration;
|
|
|
|
if(timeLeft < 0.0f)
|
|
|
|
timeLeft = 0.0f;
|
|
|
|
stats.setTimeToStartDrowning(timeLeft);
|
|
|
|
}
|
2013-08-09 08:14:08 +00:00
|
|
|
if(timeLeft == 0.0f)
|
2013-08-28 00:08:23 +00:00
|
|
|
{
|
|
|
|
// If drowning, apply 3 points of damage per second
|
|
|
|
ptr.getClass().setActorHealth(ptr, stats.getHealth().getCurrent() - 3.0f*duration);
|
|
|
|
|
|
|
|
// Play a drowning sound as necessary for the player
|
|
|
|
if(ptr == world->getPlayer().getPlayer())
|
|
|
|
{
|
|
|
|
MWBase::SoundManager *sndmgr = MWBase::Environment::get().getSoundManager();
|
|
|
|
if(!sndmgr->getSoundPlaying(MWWorld::Ptr(), "drown"))
|
|
|
|
sndmgr->playSound("drown", 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
}
|
2013-08-07 13:34:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
stats.setTimeToStartDrowning(20);
|
|
|
|
}
|
|
|
|
|
2013-10-15 19:23:42 +00:00
|
|
|
void Actors::updateEquippedLight (const MWWorld::Ptr& ptr, float duration)
|
|
|
|
{
|
2013-12-20 21:38:23 +00:00
|
|
|
bool isPlayer = ptr.getRefData().getHandle()=="player";
|
|
|
|
|
2013-10-15 19:23:42 +00:00
|
|
|
MWWorld::InventoryStore &inventoryStore = MWWorld::Class::get(ptr).getInventoryStore(ptr);
|
|
|
|
MWWorld::ContainerStoreIterator heldIter =
|
|
|
|
inventoryStore.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
2013-12-20 21:38:23 +00:00
|
|
|
/**
|
|
|
|
* Automatically equip NPCs torches at night and unequip them at day
|
|
|
|
*/
|
2013-12-30 16:53:02 +00:00
|
|
|
if (!isPlayer)
|
2013-12-20 21:38:23 +00:00
|
|
|
{
|
2013-12-30 16:53:02 +00:00
|
|
|
MWWorld::ContainerStoreIterator torch = inventoryStore.end();
|
|
|
|
for (MWWorld::ContainerStoreIterator it = inventoryStore.begin(); it != inventoryStore.end(); ++it)
|
2013-12-20 21:38:23 +00:00
|
|
|
{
|
2013-12-30 16:53:02 +00:00
|
|
|
if (it->getTypeName() == typeid(ESM::Light).name())
|
|
|
|
{
|
|
|
|
torch = it;
|
|
|
|
break;
|
|
|
|
}
|
2013-12-20 21:38:23 +00:00
|
|
|
}
|
2013-12-30 16:53:02 +00:00
|
|
|
|
|
|
|
if (MWBase::Environment::get().getWorld()->isDark())
|
2013-12-20 21:38:23 +00:00
|
|
|
{
|
2013-12-30 16:53:02 +00:00
|
|
|
if (torch != inventoryStore.end())
|
|
|
|
{
|
|
|
|
if (!MWWorld::Class::get (ptr).getCreatureStats (ptr).isHostile())
|
|
|
|
{
|
|
|
|
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
|
|
|
|
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
|
|
|
|
inventoryStore.unequipItem(*heldIter, ptr);
|
|
|
|
|
|
|
|
// Also unequip twohanded weapons which conflict with anything in CarriedLeft
|
|
|
|
if (torch->getClass().canBeEquipped(*torch, ptr).first == 3)
|
|
|
|
inventoryStore.unequipSlot(MWWorld::InventoryStore::Slot_CarriedRight, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
heldIter = inventoryStore.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
|
|
|
|
|
|
|
// If we have a torch and can equip it (left slot free, no
|
|
|
|
// twohanded weapon in right slot), then equip it now.
|
|
|
|
if (heldIter == inventoryStore.end()
|
|
|
|
&& torch->getClass().canBeEquipped(*torch, ptr).first == 1)
|
|
|
|
{
|
|
|
|
inventoryStore.equip(MWWorld::InventoryStore::Slot_CarriedLeft, torch, ptr);
|
|
|
|
}
|
|
|
|
}
|
2013-12-20 21:38:23 +00:00
|
|
|
}
|
2013-12-30 16:53:02 +00:00
|
|
|
else
|
2013-12-20 21:38:23 +00:00
|
|
|
{
|
2013-12-30 16:53:02 +00:00
|
|
|
if (heldIter != inventoryStore.end() && heldIter->getTypeName() == typeid(ESM::Light).name())
|
|
|
|
{
|
|
|
|
// At day, unequip lights and auto equip shields or other suitable items
|
|
|
|
// (Note: autoEquip will ignore lights)
|
|
|
|
inventoryStore.autoEquip(ptr);
|
|
|
|
}
|
2013-12-20 21:38:23 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-15 19:23:42 +00:00
|
|
|
|
2013-12-30 16:53:02 +00:00
|
|
|
heldIter = inventoryStore.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
|
|
|
|
2013-12-20 21:38:23 +00:00
|
|
|
//If holding a light...
|
2013-10-15 19:23:42 +00:00
|
|
|
if(heldIter.getType() == MWWorld::ContainerStore::Type_Light)
|
|
|
|
{
|
2013-10-16 00:56:42 +00:00
|
|
|
// Use time from the player's light
|
|
|
|
if(isPlayer)
|
|
|
|
{
|
|
|
|
float timeRemaining = heldIter->getClass().getRemainingUsageTime(*heldIter);
|
|
|
|
|
|
|
|
// -1 is infinite light source. Other negative values are treated as 0.
|
|
|
|
if(timeRemaining != -1.0f)
|
|
|
|
{
|
|
|
|
timeRemaining -= duration;
|
|
|
|
|
|
|
|
if(timeRemaining > 0.0f)
|
|
|
|
heldIter->getClass().setRemainingUsageTime(*heldIter, timeRemaining);
|
|
|
|
else
|
|
|
|
{
|
2013-08-12 23:19:33 +00:00
|
|
|
inventoryStore.remove(*heldIter, 1, ptr); // remove it
|
2013-10-16 00:56:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-10-15 19:23:42 +00:00
|
|
|
|
2013-10-16 00:56:42 +00:00
|
|
|
// Both NPC and player lights extinguish in water.
|
|
|
|
if(MWBase::Environment::get().getWorld()->isSwimming(ptr))
|
2013-10-15 19:23:42 +00:00
|
|
|
{
|
2013-08-12 23:19:33 +00:00
|
|
|
inventoryStore.remove(*heldIter, 1, ptr); // remove it
|
2013-10-15 19:23:42 +00:00
|
|
|
|
2013-10-16 00:56:42 +00:00
|
|
|
// ...But, only the player makes a sound.
|
|
|
|
if(isPlayer)
|
|
|
|
MWBase::Environment::get().getSoundManager()->playSound("torch out",
|
|
|
|
1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoEnv);
|
2013-10-15 19:23:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-20 23:27:22 +00:00
|
|
|
Actors::Actors() {}
|
2012-03-30 14:18:58 +00:00
|
|
|
|
|
|
|
void Actors::addActor (const MWWorld::Ptr& ptr)
|
|
|
|
{
|
2013-03-18 09:54:47 +00:00
|
|
|
// erase previous death events since we are currently only tracking them while in an active cell
|
2013-07-16 06:43:33 +00:00
|
|
|
MWWorld::Class::get(ptr).getCreatureStats(ptr).clearHasDied();
|
2013-03-18 09:54:47 +00:00
|
|
|
|
2013-07-18 04:39:21 +00:00
|
|
|
removeActor(ptr);
|
|
|
|
|
2013-01-16 18:16:37 +00:00
|
|
|
MWRender::Animation *anim = MWBase::Environment::get().getWorld()->getAnimation(ptr);
|
2013-07-16 06:43:33 +00:00
|
|
|
mActors.insert(std::make_pair(ptr, new CharacterController(ptr, anim)));
|
2012-03-30 14:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
|
|
|
{
|
2013-01-12 15:12:12 +00:00
|
|
|
PtrControllerMap::iterator iter = mActors.find(ptr);
|
|
|
|
if(iter != mActors.end())
|
2013-07-08 21:05:53 +00:00
|
|
|
{
|
|
|
|
delete iter->second;
|
2013-01-12 15:12:12 +00:00
|
|
|
mActors.erase(iter);
|
2013-07-08 21:05:53 +00:00
|
|
|
}
|
2012-03-30 14:18:58 +00:00
|
|
|
}
|
|
|
|
|
2013-02-25 17:57:34 +00:00
|
|
|
void Actors::updateActor(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr)
|
2013-01-29 08:19:24 +00:00
|
|
|
{
|
2013-02-25 17:57:34 +00:00
|
|
|
PtrControllerMap::iterator iter = mActors.find(old);
|
2013-01-29 08:19:24 +00:00
|
|
|
if(iter != mActors.end())
|
|
|
|
{
|
2013-07-08 21:05:53 +00:00
|
|
|
CharacterController *ctrl = iter->second;
|
2013-01-29 08:19:24 +00:00
|
|
|
mActors.erase(iter);
|
2013-02-25 17:57:34 +00:00
|
|
|
|
2013-07-08 21:05:53 +00:00
|
|
|
ctrl->updatePtr(ptr);
|
2013-01-29 08:19:24 +00:00
|
|
|
mActors.insert(std::make_pair(ptr, ctrl));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-30 09:50:02 +00:00
|
|
|
void Actors::dropActors (const MWWorld::Ptr::CellStore *cellStore, const MWWorld::Ptr& ignore)
|
2012-03-30 14:18:58 +00:00
|
|
|
{
|
2013-01-12 15:12:12 +00:00
|
|
|
PtrControllerMap::iterator iter = mActors.begin();
|
|
|
|
while(iter != mActors.end())
|
|
|
|
{
|
2013-11-30 09:50:02 +00:00
|
|
|
if(iter->first.getCell()==cellStore && iter->first != ignore)
|
2013-07-08 21:05:53 +00:00
|
|
|
{
|
|
|
|
delete iter->second;
|
2013-01-12 15:12:12 +00:00
|
|
|
mActors.erase(iter++);
|
2013-07-08 21:05:53 +00:00
|
|
|
}
|
2012-03-30 14:18:58 +00:00
|
|
|
else
|
|
|
|
++iter;
|
2013-01-12 15:12:12 +00:00
|
|
|
}
|
2012-03-30 14:18:58 +00:00
|
|
|
}
|
|
|
|
|
2013-01-16 16:22:38 +00:00
|
|
|
void Actors::update (float duration, bool paused)
|
2012-03-30 14:18:58 +00:00
|
|
|
{
|
2013-11-17 13:09:42 +00:00
|
|
|
if (!paused)
|
2012-03-30 15:01:55 +00:00
|
|
|
{
|
2013-02-03 07:39:43 +00:00
|
|
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++)
|
2012-03-30 15:01:55 +00:00
|
|
|
{
|
2013-07-26 15:08:52 +00:00
|
|
|
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
|
|
|
|
CreatureStats &stats = cls.getCreatureStats(iter->first);
|
|
|
|
|
|
|
|
stats.setLastHitObject(std::string());
|
|
|
|
if(!stats.isDead())
|
2012-10-20 08:54:51 +00:00
|
|
|
{
|
2013-07-16 06:43:33 +00:00
|
|
|
if(iter->second->isDead())
|
|
|
|
iter->second->resurrect();
|
2013-01-12 18:10:27 +00:00
|
|
|
|
2013-11-20 23:27:22 +00:00
|
|
|
updateActor(iter->first, duration);
|
2013-01-12 15:12:12 +00:00
|
|
|
if(iter->first.getTypeName() == typeid(ESM::NPC).name())
|
2013-11-20 23:27:22 +00:00
|
|
|
updateNpc(iter->first, duration, paused);
|
2012-10-20 08:54:51 +00:00
|
|
|
|
2013-07-26 15:08:52 +00:00
|
|
|
if(!stats.isDead())
|
2013-01-12 15:12:12 +00:00
|
|
|
continue;
|
2012-10-20 08:54:51 +00:00
|
|
|
}
|
|
|
|
|
2013-09-15 20:12:59 +00:00
|
|
|
// If it's the player and God Mode is turned on, keep it alive
|
2013-10-02 17:46:33 +00:00
|
|
|
if(iter->first.getRefData().getHandle()=="player" &&
|
|
|
|
MWBase::Environment::get().getWorld()->getGodModeState())
|
2012-10-25 10:28:45 +00:00
|
|
|
{
|
2013-07-26 15:08:52 +00:00
|
|
|
MWMechanics::DynamicStat<float> stat(stats.getHealth());
|
2013-01-12 15:12:12 +00:00
|
|
|
|
2013-07-26 15:08:52 +00:00
|
|
|
if(stat.getModified()<1)
|
2012-10-25 10:28:45 +00:00
|
|
|
{
|
2013-07-26 15:08:52 +00:00
|
|
|
stat.setModified(1, 0);
|
|
|
|
stats.setHealth(stat);
|
2012-10-25 10:28:45 +00:00
|
|
|
}
|
2012-10-27 08:36:42 +00:00
|
|
|
|
2013-07-26 15:08:52 +00:00
|
|
|
stats.resurrect();
|
2013-01-12 15:12:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-16 06:43:33 +00:00
|
|
|
if(iter->second->isDead())
|
2013-01-12 18:10:27 +00:00
|
|
|
continue;
|
2012-10-27 09:15:52 +00:00
|
|
|
|
2013-07-16 06:43:33 +00:00
|
|
|
iter->second->kill();
|
2012-10-27 08:36:42 +00:00
|
|
|
|
2013-07-26 15:08:52 +00:00
|
|
|
++mDeathCount[cls.getId(iter->first)];
|
2013-01-12 18:10:27 +00:00
|
|
|
|
2013-07-26 15:08:52 +00:00
|
|
|
if(cls.isEssential(iter->first))
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sKilledEssential}");
|
2012-03-30 15:01:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-17 02:03:39 +00:00
|
|
|
if(!paused)
|
2012-03-30 14:18:58 +00:00
|
|
|
{
|
2013-11-14 12:30:48 +00:00
|
|
|
// Note: we need to do this before any of the animations are updated.
|
|
|
|
// Reaching the text keys may trigger Hit / Spellcast (and as such, particles),
|
|
|
|
// so updating VFX immediately after that would just remove the particle effects instantly.
|
|
|
|
// There needs to be a magic effect update in between.
|
|
|
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
|
|
|
iter->second->updateContinuousVfx();
|
|
|
|
|
2013-01-17 02:03:39 +00:00
|
|
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
2013-08-18 05:34:38 +00:00
|
|
|
iter->second->update(duration);
|
2013-01-17 02:03:39 +00:00
|
|
|
}
|
2012-03-30 14:18:58 +00:00
|
|
|
}
|
2012-09-21 15:53:16 +00:00
|
|
|
void Actors::restoreDynamicStats()
|
|
|
|
{
|
2013-01-12 15:12:12 +00:00
|
|
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
2013-01-29 07:39:11 +00:00
|
|
|
calculateRestoration(iter->first, 3600);
|
2012-09-21 15:53:16 +00:00
|
|
|
}
|
2013-03-18 09:54:47 +00:00
|
|
|
|
2012-10-27 09:33:18 +00:00
|
|
|
int Actors::countDeaths (const std::string& id) const
|
|
|
|
{
|
2013-01-12 15:12:12 +00:00
|
|
|
std::map<std::string, int>::const_iterator iter = mDeathCount.find(id);
|
|
|
|
if(iter != mDeathCount.end())
|
2012-10-27 09:33:18 +00:00
|
|
|
return iter->second;
|
|
|
|
return 0;
|
|
|
|
}
|
2013-01-17 01:53:18 +00:00
|
|
|
|
2013-04-25 14:08:11 +00:00
|
|
|
void Actors::forceStateUpdate(const MWWorld::Ptr & ptr)
|
|
|
|
{
|
|
|
|
PtrControllerMap::iterator iter = mActors.find(ptr);
|
|
|
|
if(iter != mActors.end())
|
2013-07-08 21:05:53 +00:00
|
|
|
iter->second->forceStateUpdate();
|
2013-04-25 14:08:11 +00:00
|
|
|
}
|
|
|
|
|
2013-01-17 01:53:18 +00:00
|
|
|
void Actors::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number)
|
|
|
|
{
|
|
|
|
PtrControllerMap::iterator iter = mActors.find(ptr);
|
|
|
|
if(iter != mActors.end())
|
2013-07-08 21:05:53 +00:00
|
|
|
iter->second->playGroup(groupName, mode, number);
|
2013-01-17 01:53:18 +00:00
|
|
|
}
|
|
|
|
void Actors::skipAnimation(const MWWorld::Ptr& ptr)
|
|
|
|
{
|
|
|
|
PtrControllerMap::iterator iter = mActors.find(ptr);
|
|
|
|
if(iter != mActors.end())
|
2013-07-08 21:05:53 +00:00
|
|
|
iter->second->skipAnim();
|
2013-01-17 01:53:18 +00:00
|
|
|
}
|
2013-05-25 03:10:07 +00:00
|
|
|
|
|
|
|
bool Actors::checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName)
|
|
|
|
{
|
|
|
|
PtrControllerMap::iterator iter = mActors.find(ptr);
|
|
|
|
if(iter != mActors.end())
|
2013-07-08 21:05:53 +00:00
|
|
|
return iter->second->isAnimPlaying(groupName);
|
2013-05-25 03:10:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-03-30 14:18:58 +00:00
|
|
|
}
|