mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 15:53:54 +00:00
Merge remote branch 'greye/master'
This commit is contained in:
commit
e1bb98e71f
10 changed files with 462 additions and 138 deletions
|
@ -47,24 +47,24 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
// creature stats
|
// creature stats
|
||||||
data->mCreatureStats.mAttributes[0].set (ref->base->data.strength);
|
data->mCreatureStats.getAttribute(0).set (ref->base->data.strength);
|
||||||
data->mCreatureStats.mAttributes[1].set (ref->base->data.intelligence);
|
data->mCreatureStats.getAttribute(1).set (ref->base->data.intelligence);
|
||||||
data->mCreatureStats.mAttributes[2].set (ref->base->data.willpower);
|
data->mCreatureStats.getAttribute(2).set (ref->base->data.willpower);
|
||||||
data->mCreatureStats.mAttributes[3].set (ref->base->data.agility);
|
data->mCreatureStats.getAttribute(3).set (ref->base->data.agility);
|
||||||
data->mCreatureStats.mAttributes[4].set (ref->base->data.speed);
|
data->mCreatureStats.getAttribute(4).set (ref->base->data.speed);
|
||||||
data->mCreatureStats.mAttributes[5].set (ref->base->data.endurance);
|
data->mCreatureStats.getAttribute(5).set (ref->base->data.endurance);
|
||||||
data->mCreatureStats.mAttributes[6].set (ref->base->data.personality);
|
data->mCreatureStats.getAttribute(6).set (ref->base->data.personality);
|
||||||
data->mCreatureStats.mAttributes[7].set (ref->base->data.luck);
|
data->mCreatureStats.getAttribute(7).set (ref->base->data.luck);
|
||||||
data->mCreatureStats.mDynamic[0].set (ref->base->data.health);
|
data->mCreatureStats.getHealth().set (ref->base->data.health);
|
||||||
data->mCreatureStats.mDynamic[1].set (ref->base->data.mana);
|
data->mCreatureStats.getMagicka().set (ref->base->data.mana);
|
||||||
data->mCreatureStats.mDynamic[2].set (ref->base->data.fatigue);
|
data->mCreatureStats.getFatigue().set (ref->base->data.fatigue);
|
||||||
|
|
||||||
data->mCreatureStats.mLevel = ref->base->data.level;
|
data->mCreatureStats.setLevel(ref->base->data.level);
|
||||||
|
|
||||||
data->mCreatureStats.mHello = ref->base->AI.hello;
|
data->mCreatureStats.setHello(ref->base->AI.hello);
|
||||||
data->mCreatureStats.mFight = ref->base->AI.fight;
|
data->mCreatureStats.setFight(ref->base->AI.fight);
|
||||||
data->mCreatureStats.mFlee = ref->base->AI.flee;
|
data->mCreatureStats.setFlee(ref->base->AI.flee);
|
||||||
data->mCreatureStats.mAlarm = ref->base->AI.alarm;
|
data->mCreatureStats.setAlarm(ref->base->AI.alarm);
|
||||||
|
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData (data.release());
|
ptr.getRefData().setCustomData (data.release());
|
||||||
|
@ -169,7 +169,7 @@ namespace MWClass
|
||||||
float Creature::getCapacity (const MWWorld::Ptr& ptr) const
|
float Creature::getCapacity (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
return stats.mAttributes[0].getModified()*5;
|
return stats.getAttribute(0).getModified()*5;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const
|
float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const
|
||||||
|
@ -178,9 +178,9 @@ namespace MWClass
|
||||||
|
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
|
|
||||||
weight -= stats.mMagicEffects.get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
weight -= stats.getMagicEffects().get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
||||||
|
|
||||||
weight += stats.mMagicEffects.get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
weight += stats.getMagicEffects().get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
||||||
|
|
||||||
if (weight<0)
|
if (weight<0)
|
||||||
weight = 0;
|
weight = 0;
|
||||||
|
|
|
@ -81,29 +81,29 @@ namespace MWClass
|
||||||
for (int i=0; i<27; ++i)
|
for (int i=0; i<27; ++i)
|
||||||
data->mNpcStats.getSkill (i).setBase (ref->base->npdt52.skills[i]);
|
data->mNpcStats.getSkill (i).setBase (ref->base->npdt52.skills[i]);
|
||||||
|
|
||||||
data->mCreatureStats.mAttributes[0].set (ref->base->npdt52.strength);
|
data->mCreatureStats.getAttribute(0).set (ref->base->npdt52.strength);
|
||||||
data->mCreatureStats.mAttributes[1].set (ref->base->npdt52.intelligence);
|
data->mCreatureStats.getAttribute(1).set (ref->base->npdt52.intelligence);
|
||||||
data->mCreatureStats.mAttributes[2].set (ref->base->npdt52.willpower);
|
data->mCreatureStats.getAttribute(2).set (ref->base->npdt52.willpower);
|
||||||
data->mCreatureStats.mAttributes[3].set (ref->base->npdt52.agility);
|
data->mCreatureStats.getAttribute(3).set (ref->base->npdt52.agility);
|
||||||
data->mCreatureStats.mAttributes[4].set (ref->base->npdt52.speed);
|
data->mCreatureStats.getAttribute(4).set (ref->base->npdt52.speed);
|
||||||
data->mCreatureStats.mAttributes[5].set (ref->base->npdt52.endurance);
|
data->mCreatureStats.getAttribute(5).set (ref->base->npdt52.endurance);
|
||||||
data->mCreatureStats.mAttributes[6].set (ref->base->npdt52.personality);
|
data->mCreatureStats.getAttribute(6).set (ref->base->npdt52.personality);
|
||||||
data->mCreatureStats.mAttributes[7].set (ref->base->npdt52.luck);
|
data->mCreatureStats.getAttribute(7).set (ref->base->npdt52.luck);
|
||||||
data->mCreatureStats.mDynamic[0].set (ref->base->npdt52.health);
|
data->mCreatureStats.getHealth().set (ref->base->npdt52.health);
|
||||||
data->mCreatureStats.mDynamic[1].set (ref->base->npdt52.mana);
|
data->mCreatureStats.getMagicka().set (ref->base->npdt52.mana);
|
||||||
data->mCreatureStats.mDynamic[2].set (ref->base->npdt52.fatigue);
|
data->mCreatureStats.getFatigue().set (ref->base->npdt52.fatigue);
|
||||||
|
|
||||||
data->mCreatureStats.mLevel = ref->base->npdt52.level;
|
data->mCreatureStats.setLevel(ref->base->npdt52.level);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/// \todo do something with npdt12 maybe:p
|
/// \todo do something with npdt12 maybe:p
|
||||||
}
|
}
|
||||||
|
|
||||||
data->mCreatureStats.mHello = ref->base->AI.hello;
|
data->mCreatureStats.setHello(ref->base->AI.hello);
|
||||||
data->mCreatureStats.mFight = ref->base->AI.fight;
|
data->mCreatureStats.setFight(ref->base->AI.fight);
|
||||||
data->mCreatureStats.mFlee = ref->base->AI.flee;
|
data->mCreatureStats.setFlee(ref->base->AI.flee);
|
||||||
data->mCreatureStats.mAlarm = ref->base->AI.alarm;
|
data->mCreatureStats.setAlarm(ref->base->AI.alarm);
|
||||||
|
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData (data.release());
|
ptr.getRefData().setCustomData (data.release());
|
||||||
|
@ -330,7 +330,7 @@ namespace MWClass
|
||||||
float Npc::getCapacity (const MWWorld::Ptr& ptr) const
|
float Npc::getCapacity (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
return stats.mAttributes[0].getModified()*5;
|
return stats.getAttribute(0).getModified()*5;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Npc::getEncumbrance (const MWWorld::Ptr& ptr) const
|
float Npc::getEncumbrance (const MWWorld::Ptr& ptr) const
|
||||||
|
@ -339,9 +339,9 @@ namespace MWClass
|
||||||
|
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
|
|
||||||
weight -= stats.mMagicEffects.get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
weight -= stats.getMagicEffects().get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
||||||
|
|
||||||
weight += stats.mMagicEffects.get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
weight += stats.getMagicEffects().get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
||||||
|
|
||||||
if (weight<0)
|
if (weight<0)
|
||||||
weight = 0;
|
weight = 0;
|
||||||
|
@ -356,7 +356,7 @@ namespace MWClass
|
||||||
|
|
||||||
/// \todo consider instant effects
|
/// \todo consider instant effects
|
||||||
|
|
||||||
return stats.mActiveSpells.addSpell (id);
|
return stats.getActiveSpells().addSpell (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const
|
void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace MWGui
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||||
MWMechanics::Spells& spells = stats.mSpells;
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
|
||||||
// the following code switches between selected enchanted item and selected spell (only one of these
|
// the following code switches between selected enchanted item and selected spell (only one of these
|
||||||
// can be active at a time)
|
// can be active at a time)
|
||||||
|
@ -333,7 +333,7 @@ namespace MWGui
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
||||||
MWMechanics::Spells& spells = stats.mSpells;
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>();
|
||||||
|
|
||||||
// retrieve ContainerStoreIterator to the item
|
// retrieve ContainerStoreIterator to the item
|
||||||
|
@ -397,7 +397,7 @@ namespace MWGui
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
||||||
MWMechanics::Spells& spells = stats.mSpells;
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
|
||||||
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
||||||
{
|
{
|
||||||
|
@ -451,7 +451,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||||
MWMechanics::Spells& spells = stats.mSpells;
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
|
||||||
if (spells.getSelectedSpell() == mSpellToDelete)
|
if (spells.getSelectedSpell() == mSpellToDelete)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature);
|
CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature);
|
||||||
|
|
||||||
MagicEffects now = creatureStats.mSpells.getMagicEffects();
|
MagicEffects now = creatureStats.getSpells().getMagicEffects();
|
||||||
|
|
||||||
if (creature.getTypeName()==typeid (ESM::NPC).name())
|
if (creature.getTypeName()==typeid (ESM::NPC).name())
|
||||||
{
|
{
|
||||||
|
@ -41,11 +41,11 @@ namespace MWMechanics
|
||||||
now += store.getMagicEffects();
|
now += store.getMagicEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
now += creatureStats.mActiveSpells.getMagicEffects();
|
now += creatureStats.getActiveSpells().getMagicEffects();
|
||||||
|
|
||||||
MagicEffects diff = MagicEffects::diff (creatureStats.mMagicEffects, now);
|
MagicEffects diff = MagicEffects::diff (creatureStats.getMagicEffects(), now);
|
||||||
|
|
||||||
creatureStats.mMagicEffects = now;
|
creatureStats.setMagicEffects(now);
|
||||||
|
|
||||||
// TODO apply diff to other stats
|
// TODO apply diff to other stats
|
||||||
}
|
}
|
||||||
|
@ -54,18 +54,22 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
int strength = creatureStats.mAttributes[0].getBase();
|
int strength = creatureStats.getAttribute(0).getBase();
|
||||||
int intelligence = creatureStats.mAttributes[1].getBase();
|
int intelligence = creatureStats.getAttribute(1).getBase();
|
||||||
int willpower = creatureStats.mAttributes[2].getBase();
|
int willpower = creatureStats.getAttribute(2).getBase();
|
||||||
int agility = creatureStats.mAttributes[3].getBase();
|
int agility = creatureStats.getAttribute(3).getBase();
|
||||||
int endurance = creatureStats.mAttributes[5].getBase();
|
int endurance = creatureStats.getAttribute(5).getBase();
|
||||||
|
|
||||||
double magickaFactor = creatureStats.mMagicEffects.get (EffectKey (84)).mMagnitude*0.1 + 0.5;
|
double magickaFactor =
|
||||||
|
creatureStats.getMagicEffects().get (EffectKey (84)).mMagnitude * 0.1 + 0.5;
|
||||||
|
|
||||||
creatureStats.mDynamic[0].setBase (static_cast<int> (0.5 * (strength + endurance)));
|
creatureStats.getHealth().setBase(
|
||||||
creatureStats.mDynamic[1].setBase (static_cast<int> (intelligence +
|
static_cast<int> (0.5 * (strength + endurance)));
|
||||||
magickaFactor * intelligence));
|
|
||||||
creatureStats.mDynamic[2].setBase (strength+willpower+agility+endurance);
|
creatureStats.getMagicka().setBase(
|
||||||
|
static_cast<int> (intelligence + magickaFactor * intelligence));
|
||||||
|
|
||||||
|
creatureStats.getFatigue().setBase(strength+willpower+agility+endurance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr)
|
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr)
|
||||||
|
@ -75,20 +79,24 @@ namespace MWMechanics
|
||||||
// attributes
|
// attributes
|
||||||
for (int i=0; i<5; ++i)
|
for (int i=0; i<5; ++i)
|
||||||
{
|
{
|
||||||
int modifier = creatureStats.mMagicEffects.get (EffectKey (79, i)).mMagnitude
|
int modifier =
|
||||||
- creatureStats.mMagicEffects.get (EffectKey (17, i)).mMagnitude;
|
creatureStats.getMagicEffects().get (EffectKey (79, i)).mMagnitude;
|
||||||
|
|
||||||
creatureStats.mAttributes[i].setModifier (modifier);
|
modifier -= creatureStats.getMagicEffects().get (EffectKey (17, i)).mMagnitude;
|
||||||
|
|
||||||
|
creatureStats.getAttribute(i).setModifier (modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dynamic stats
|
// dynamic stats
|
||||||
for (int i=0; i<3; ++i)
|
MagicEffects effects = creatureStats.getMagicEffects();
|
||||||
{
|
creatureStats.getHealth().setModifier(
|
||||||
int modifier = creatureStats.mMagicEffects.get (EffectKey (80+i)).mMagnitude
|
effects.get(EffectKey(80)).mMagnitude - effects.get(EffectKey(18)).mMagnitude);
|
||||||
- creatureStats.mMagicEffects.get (EffectKey (18+i)).mMagnitude;
|
|
||||||
|
|
||||||
creatureStats.mDynamic[i].setModifier (modifier);
|
creatureStats.getMagicka().setModifier(
|
||||||
}
|
effects.get(EffectKey(81)).mMagnitude - effects.get(EffectKey(19)).mMagnitude);
|
||||||
|
|
||||||
|
creatureStats.getFatigue().setModifier(
|
||||||
|
effects.get(EffectKey(82)).mMagnitude - effects.get(EffectKey(20)).mMagnitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
Actors::Actors() : mDuration (0) {}
|
Actors::Actors() : mDuration (0) {}
|
||||||
|
|
48
apps/openmw/mwmechanics/creaturestats.cpp
Normal file
48
apps/openmw/mwmechanics/creaturestats.cpp
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#include "creaturestats.hpp"
|
||||||
|
|
||||||
|
namespace MWMechanics
|
||||||
|
{
|
||||||
|
CreatureStats::CreatureStats()
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Can't use all benefits of members initialization because of
|
||||||
|
// lack of copy constructors
|
||||||
|
CreatureStats::CreatureStats(const CreatureStats &orig)
|
||||||
|
: mLevel(orig.mLevel), mHello(orig.mHello), mFight(orig.mFight),
|
||||||
|
mFlee(orig.mFlee), mAlarm(orig.mAlarm)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
mAttributes[i] = orig.mAttributes[i];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
mDynamic[i] = orig.mDynamic[i];
|
||||||
|
}
|
||||||
|
mSpells = orig.mSpells;
|
||||||
|
mActiveSpells = orig.mActiveSpells;
|
||||||
|
mMagicEffects = orig.mMagicEffects;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatureStats::~CreatureStats()
|
||||||
|
{}
|
||||||
|
|
||||||
|
const CreatureStats &
|
||||||
|
CreatureStats::operator=(const CreatureStats &orig)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
mAttributes[i] = orig.mAttributes[i];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
mDynamic[i] = orig.mDynamic[i];
|
||||||
|
}
|
||||||
|
mLevel = orig.mLevel;
|
||||||
|
mSpells = orig.mSpells;
|
||||||
|
mActiveSpells = orig.mActiveSpells;
|
||||||
|
mMagicEffects = orig.mMagicEffects;
|
||||||
|
mHello = orig.mHello;
|
||||||
|
mFight = orig.mFight;
|
||||||
|
mFlee = orig.mFlee;
|
||||||
|
mAlarm = orig.mAlarm;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "stat.hpp"
|
#include "stat.hpp"
|
||||||
#include "magiceffects.hpp"
|
#include "magiceffects.hpp"
|
||||||
|
@ -11,7 +12,10 @@
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
struct CreatureStats
|
/// \brief Common creature stats
|
||||||
|
///
|
||||||
|
///
|
||||||
|
class CreatureStats
|
||||||
{
|
{
|
||||||
Stat<int> mAttributes[8];
|
Stat<int> mAttributes[8];
|
||||||
DynamicStat<int> mDynamic[3]; // health, magicka, fatigue
|
DynamicStat<int> mDynamic[3]; // health, magicka, fatigue
|
||||||
|
@ -23,7 +27,258 @@ namespace MWMechanics
|
||||||
int mFight;
|
int mFight;
|
||||||
int mFlee;
|
int mFlee;
|
||||||
int mAlarm;
|
int mAlarm;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CreatureStats();
|
||||||
|
CreatureStats(const CreatureStats &);
|
||||||
|
virtual ~CreatureStats();
|
||||||
|
|
||||||
|
const CreatureStats & operator=(const CreatureStats &);
|
||||||
|
|
||||||
|
const Stat<int> & getAttribute(int index) const;
|
||||||
|
|
||||||
|
const DynamicStat<int> & getHealth() const;
|
||||||
|
|
||||||
|
const DynamicStat<int> & getMagicka() const;
|
||||||
|
|
||||||
|
const DynamicStat<int> & getFatigue() const;
|
||||||
|
|
||||||
|
const Spells & getSpells() const;
|
||||||
|
|
||||||
|
const ActiveSpells & getActiveSpells() const;
|
||||||
|
|
||||||
|
const MagicEffects & getMagicEffects() const;
|
||||||
|
|
||||||
|
int getLevel() const;
|
||||||
|
|
||||||
|
int getHello() const;
|
||||||
|
|
||||||
|
int getFight() const;
|
||||||
|
|
||||||
|
int getFlee() const;
|
||||||
|
|
||||||
|
int getAlarm() const;
|
||||||
|
|
||||||
|
|
||||||
|
Stat<int> & getAttribute(int index);
|
||||||
|
|
||||||
|
DynamicStat<int> & getHealth();
|
||||||
|
|
||||||
|
DynamicStat<int> & getMagicka();
|
||||||
|
|
||||||
|
DynamicStat<int> & getFatigue();
|
||||||
|
|
||||||
|
DynamicStat<int> & getDynamic(int index);
|
||||||
|
|
||||||
|
Spells & getSpells();
|
||||||
|
|
||||||
|
ActiveSpells & getActiveSpells();
|
||||||
|
|
||||||
|
MagicEffects & getMagicEffects();
|
||||||
|
|
||||||
|
|
||||||
|
void setAttribute(int index, const Stat<int> &value);
|
||||||
|
|
||||||
|
void setHealth(const DynamicStat<int> &value);
|
||||||
|
|
||||||
|
void setMagicka(const DynamicStat<int> &value);
|
||||||
|
|
||||||
|
void setFatigue(const DynamicStat<int> &value);
|
||||||
|
|
||||||
|
void setSpells(const Spells &spells);
|
||||||
|
|
||||||
|
void setActiveSpells(const ActiveSpells &active);
|
||||||
|
|
||||||
|
void setMagicEffects(const MagicEffects &effects);
|
||||||
|
|
||||||
|
void setLevel(int level);
|
||||||
|
|
||||||
|
void setHello(int value);
|
||||||
|
|
||||||
|
void setFight(int value);
|
||||||
|
|
||||||
|
void setFlee(int value);
|
||||||
|
|
||||||
|
void setAlarm(int value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Inline const getters
|
||||||
|
|
||||||
|
inline const Stat<int> &
|
||||||
|
CreatureStats::getAttribute(int index) const {
|
||||||
|
if (index < 0 || index > 7) {
|
||||||
|
throw std::runtime_error("attribute index is out of range");
|
||||||
|
}
|
||||||
|
return mAttributes[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const DynamicStat<int> &
|
||||||
|
CreatureStats::getHealth() const {
|
||||||
|
return mDynamic[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const DynamicStat<int> &
|
||||||
|
CreatureStats::getMagicka() const {
|
||||||
|
return mDynamic[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const DynamicStat<int> &
|
||||||
|
CreatureStats::getFatigue() const {
|
||||||
|
return mDynamic[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Spells &
|
||||||
|
CreatureStats::getSpells() const {
|
||||||
|
return mSpells;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ActiveSpells &
|
||||||
|
CreatureStats::getActiveSpells() const {
|
||||||
|
return mActiveSpells;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const MagicEffects &
|
||||||
|
CreatureStats::getMagicEffects() const {
|
||||||
|
return mMagicEffects;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int
|
||||||
|
CreatureStats::getLevel() const {
|
||||||
|
return mLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int
|
||||||
|
CreatureStats::getHello() const {
|
||||||
|
return mHello;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int
|
||||||
|
CreatureStats::getFight() const {
|
||||||
|
return mFight;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int
|
||||||
|
CreatureStats::getFlee() const {
|
||||||
|
return mFlee;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int
|
||||||
|
CreatureStats::getAlarm() const {
|
||||||
|
return mAlarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inline non-const getters
|
||||||
|
|
||||||
|
inline Stat<int> &
|
||||||
|
CreatureStats::getAttribute(int index) {
|
||||||
|
if (index < 0 || index > 7) {
|
||||||
|
throw std::runtime_error("attribute index is out of range");
|
||||||
|
}
|
||||||
|
return mAttributes[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DynamicStat<int> &
|
||||||
|
CreatureStats::getHealth() {
|
||||||
|
return mDynamic[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DynamicStat<int> &
|
||||||
|
CreatureStats::getMagicka() {
|
||||||
|
return mDynamic[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DynamicStat<int> &
|
||||||
|
CreatureStats::getFatigue() {
|
||||||
|
return mDynamic[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DynamicStat<int> &
|
||||||
|
CreatureStats::getDynamic(int index) {
|
||||||
|
if (index < 0 || index > 2) {
|
||||||
|
throw std::runtime_error("dynamic stat index is out of range");
|
||||||
|
}
|
||||||
|
return mDynamic[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Spells &
|
||||||
|
CreatureStats::getSpells() {
|
||||||
|
return mSpells;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setSpells(const Spells &spells) {
|
||||||
|
mSpells = spells;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ActiveSpells &
|
||||||
|
CreatureStats::getActiveSpells() {
|
||||||
|
return mActiveSpells;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MagicEffects &
|
||||||
|
CreatureStats::getMagicEffects() {
|
||||||
|
return mMagicEffects;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inline setters
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setAttribute(int index, const Stat<int> &value) {
|
||||||
|
if (index < 0 || index > 7) {
|
||||||
|
throw std::runtime_error("attribute index is out of range");
|
||||||
|
}
|
||||||
|
mAttributes[index] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setHealth(const DynamicStat<int> &value) {
|
||||||
|
mDynamic[0] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setMagicka(const DynamicStat<int> &value) {
|
||||||
|
mDynamic[1] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setFatigue(const DynamicStat<int> &value) {
|
||||||
|
mDynamic[2] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setLevel(int level) {
|
||||||
|
mLevel = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setActiveSpells(const ActiveSpells &active) {
|
||||||
|
mActiveSpells = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setMagicEffects(const MagicEffects &effects) {
|
||||||
|
mMagicEffects = effects;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setHello(int value) {
|
||||||
|
mHello = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setFight(int value) {
|
||||||
|
mFight = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setFlee(int value) {
|
||||||
|
mFlee = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CreatureStats::setAlarm(int value) {
|
||||||
|
mAlarm = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,21 +23,21 @@ namespace MWMechanics
|
||||||
const ESM::NPC *player = ptr.get<ESM::NPC>()->base;
|
const ESM::NPC *player = ptr.get<ESM::NPC>()->base;
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
creatureStats.mLevel = player->npdt52.level;
|
creatureStats.setLevel(player->npdt52.level);
|
||||||
creatureStats.mSpells.clear();
|
creatureStats.getSpells().clear();
|
||||||
creatureStats.mMagicEffects = MagicEffects();
|
creatureStats.setMagicEffects(MagicEffects());
|
||||||
|
|
||||||
for (int i=0; i<27; ++i)
|
for (int i=0; i<27; ++i)
|
||||||
npcStats.getSkill (i).setBase (player->npdt52.skills[i]);
|
npcStats.getSkill (i).setBase (player->npdt52.skills[i]);
|
||||||
|
|
||||||
creatureStats.mAttributes[0].setBase (player->npdt52.strength);
|
creatureStats.getAttribute(0).setBase (player->npdt52.strength);
|
||||||
creatureStats.mAttributes[1].setBase (player->npdt52.intelligence);
|
creatureStats.getAttribute(1).setBase (player->npdt52.intelligence);
|
||||||
creatureStats.mAttributes[2].setBase (player->npdt52.willpower);
|
creatureStats.getAttribute(2).setBase (player->npdt52.willpower);
|
||||||
creatureStats.mAttributes[3].setBase (player->npdt52.agility);
|
creatureStats.getAttribute(3).setBase (player->npdt52.agility);
|
||||||
creatureStats.mAttributes[4].setBase (player->npdt52.speed);
|
creatureStats.getAttribute(4).setBase (player->npdt52.speed);
|
||||||
creatureStats.mAttributes[5].setBase (player->npdt52.endurance);
|
creatureStats.getAttribute(5).setBase (player->npdt52.endurance);
|
||||||
creatureStats.mAttributes[6].setBase (player->npdt52.personality);
|
creatureStats.getAttribute(6).setBase (player->npdt52.personality);
|
||||||
creatureStats.mAttributes[7].setBase (player->npdt52.luck);
|
creatureStats.getAttribute(7).setBase (player->npdt52.luck);
|
||||||
|
|
||||||
// race
|
// race
|
||||||
if (mRaceSelected)
|
if (mRaceSelected)
|
||||||
|
@ -63,7 +63,7 @@ namespace MWMechanics
|
||||||
case 7: attribute = &race->data.luck; break;
|
case 7: attribute = &race->data.luck; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
creatureStats.mAttributes[i].setBase (
|
creatureStats.getAttribute(i).setBase (
|
||||||
static_cast<int> (male ? attribute->male : attribute->female));
|
static_cast<int> (male ? attribute->male : attribute->female));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ namespace MWMechanics
|
||||||
for (std::vector<std::string>::const_iterator iter (race->powers.list.begin());
|
for (std::vector<std::string>::const_iterator iter (race->powers.list.begin());
|
||||||
iter!=race->powers.list.end(); ++iter)
|
iter!=race->powers.list.end(); ++iter)
|
||||||
{
|
{
|
||||||
creatureStats.mSpells.add (*iter);
|
creatureStats.getSpells().add (*iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ namespace MWMechanics
|
||||||
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
|
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
|
||||||
iter!=sign->powers.list.end(); ++iter)
|
iter!=sign->powers.list.end(); ++iter)
|
||||||
{
|
{
|
||||||
creatureStats.mSpells.add (*iter);
|
creatureStats.getSpells().add (*iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ namespace MWMechanics
|
||||||
int attribute = class_.data.attribute[i];
|
int attribute = class_.data.attribute[i];
|
||||||
if (attribute>=0 && attribute<8)
|
if (attribute>=0 && attribute<8)
|
||||||
{
|
{
|
||||||
creatureStats.mAttributes[attribute].setBase (
|
creatureStats.getAttribute(attribute).setBase (
|
||||||
creatureStats.mAttributes[attribute].getBase() + 10);
|
creatureStats.getAttribute(attribute).getBase() + 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +151,9 @@ namespace MWMechanics
|
||||||
// forced update and current value adjustments
|
// forced update and current value adjustments
|
||||||
mActors.updateActor (ptr, 0);
|
mActors.updateActor (ptr, 0);
|
||||||
|
|
||||||
for (int i=0; i<3; ++i)
|
creatureStats.getHealth().setCurrent(creatureStats.getHealth().getModified());
|
||||||
creatureStats.mDynamic[i].setCurrent (creatureStats.mDynamic[i].getModified());
|
creatureStats.getMagicka().setCurrent(creatureStats.getMagicka().getModified());
|
||||||
|
creatureStats.getFatigue().setCurrent(creatureStats.getFatigue().getModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,22 +214,25 @@ namespace MWMechanics
|
||||||
|
|
||||||
for (int i=0; i<8; ++i)
|
for (int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
if (stats.mAttributes[i]!=mWatchedCreature.mAttributes[i])
|
if (stats.getAttribute(i)!=mWatchedCreature.getAttribute(i))
|
||||||
{
|
{
|
||||||
mWatchedCreature.mAttributes[i] = stats.mAttributes[i];
|
mWatchedCreature.setAttribute(i, stats.getAttribute(i));
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->setValue (attributeNames[i], stats.mAttributes[i]);
|
MWBase::Environment::get().getWindowManager()->setValue (attributeNames[i], stats.getAttribute(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<3; ++i)
|
if (stats.getHealth() != mWatchedCreature.getHealth()) {
|
||||||
{
|
mWatchedCreature.setHealth(stats.getHealth());
|
||||||
if (stats.mDynamic[i]!=mWatchedCreature.mDynamic[i])
|
MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[0], stats.getHealth());
|
||||||
{
|
|
||||||
mWatchedCreature.mDynamic[i] = stats.mDynamic[i];
|
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->setValue (dynamicNames[i], stats.mDynamic[i]);
|
|
||||||
}
|
}
|
||||||
|
if (stats.getMagicka() != mWatchedCreature.getMagicka()) {
|
||||||
|
mWatchedCreature.setMagicka(stats.getMagicka());
|
||||||
|
MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[1], stats.getMagicka());
|
||||||
|
}
|
||||||
|
if (stats.getFatigue() != mWatchedCreature.getFatigue()) {
|
||||||
|
mWatchedCreature.setFatigue(stats.getFatigue());
|
||||||
|
MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[2], stats.getFatigue());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update = false;
|
bool update = false;
|
||||||
|
@ -247,7 +251,7 @@ namespace MWMechanics
|
||||||
if (update)
|
if (update)
|
||||||
MWBase::Environment::get().getWindowManager()->updateSkillArea();
|
MWBase::Environment::get().getWindowManager()->updateSkillArea();
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->setValue ("level", stats.mLevel);
|
MWBase::Environment::get().getWindowManager()->setValue ("level", stats.getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mUpdatePlayer)
|
if (mUpdatePlayer)
|
||||||
|
|
|
@ -81,12 +81,12 @@ namespace MWMechanics
|
||||||
int skillLevel = stats.getSkill (getSpellSchool(spellId, actor)).getModified();
|
int skillLevel = stats.getSkill (getSpellSchool(spellId, actor)).getModified();
|
||||||
|
|
||||||
// Sound magic effect (reduces spell casting chance)
|
// Sound magic effect (reduces spell casting chance)
|
||||||
int soundMagnitude = creatureStats.mMagicEffects.get (MWMechanics::EffectKey (48)).mMagnitude;
|
int soundMagnitude = creatureStats.getMagicEffects().get (MWMechanics::EffectKey (48)).mMagnitude;
|
||||||
|
|
||||||
int willpower = creatureStats.mAttributes[ESM::Attribute::Willpower].getModified();
|
int willpower = creatureStats.getAttribute(ESM::Attribute::Willpower).getModified();
|
||||||
int luck = creatureStats.mAttributes[ESM::Attribute::Luck].getModified();
|
int luck = creatureStats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||||
int currentFatigue = creatureStats.mDynamic[2].getCurrent();
|
int currentFatigue = creatureStats.getFatigue().getCurrent();
|
||||||
int maxFatigue = creatureStats.mDynamic[2].getModified();
|
int maxFatigue = creatureStats.getFatigue().getModified();
|
||||||
int spellCost = spell->data.cost;
|
int spellCost = spell->data.cost;
|
||||||
|
|
||||||
// There we go, all needed variables are there, lets go
|
// There we go, all needed variables are there, lets go
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mHello = value;
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).setHello(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mFight = value;
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).setFight(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mFlee = value;
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).setFlee(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAlarm = value;
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAlarm(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,10 @@ namespace MWScript
|
||||||
MWWorld::Ptr ptr = R()(runtime);
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
Interpreter::Type_Integer value =
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
MWWorld::Class::get (ptr)
|
||||||
getModified();
|
.getCreatureStats (ptr)
|
||||||
|
.getAttribute(mIndex)
|
||||||
|
.getModified();
|
||||||
|
|
||||||
runtime.push (value);
|
runtime.push (value);
|
||||||
}
|
}
|
||||||
|
@ -69,8 +71,10 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
MWWorld::Class::get(ptr)
|
||||||
setModified (value, 0);
|
.getCreatureStats(ptr)
|
||||||
|
.getAttribute(mIndex)
|
||||||
|
.setModified (value, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,11 +94,16 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
value += MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
value +=
|
||||||
getModified();
|
MWWorld::Class::get(ptr)
|
||||||
|
.getCreatureStats(ptr)
|
||||||
|
.getAttribute(mIndex)
|
||||||
|
.getModified();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
MWWorld::Class::get(ptr)
|
||||||
setModified (value, 0, 100);
|
.getCreatureStats(ptr)
|
||||||
|
.getAttribute(mIndex)
|
||||||
|
.setModified (value, 0, 100);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,21 +119,19 @@ namespace MWScript
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = R()(runtime);
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
Interpreter::Type_Integer value;
|
||||||
|
|
||||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
||||||
{
|
{
|
||||||
// health is a special case
|
// health is a special case
|
||||||
Interpreter::Type_Integer value =
|
value = MWWorld::Class::get (ptr).getItemMaxHealth (ptr);
|
||||||
MWWorld::Class::get (ptr).getItemMaxHealth (ptr);
|
} else {
|
||||||
runtime.push (value);
|
value =
|
||||||
|
MWWorld::Class::get(ptr)
|
||||||
return;
|
.getCreatureStats(ptr)
|
||||||
|
.getDynamic(mIndex)
|
||||||
|
.getCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
|
||||||
getCurrent();
|
|
||||||
|
|
||||||
runtime.push (value);
|
runtime.push (value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -145,8 +152,10 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
MWWorld::Class::get(ptr)
|
||||||
setModified (value, 0);
|
.getCreatureStats(ptr)
|
||||||
|
.getDynamic(mIndex)
|
||||||
|
.setModified(value, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -168,12 +177,12 @@ namespace MWScript
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
Interpreter::Type_Integer current = stats.getDynamic(mIndex).getCurrent();
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setModified (
|
stats.getDynamic(mIndex).setModified(
|
||||||
diff + stats.mDynamic[mIndex].getModified(), 0);
|
diff + stats.getDynamic(mIndex).getModified(), 0);
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setCurrent (diff + current);
|
stats.getDynamic(mIndex).setCurrent(diff + current);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,9 +204,9 @@ namespace MWScript
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
Interpreter::Type_Integer current = stats.getDynamic(mIndex).getCurrent();
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setCurrent (diff + current);
|
stats.getDynamic(mIndex).setCurrent (diff + current);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,10 +227,10 @@ namespace MWScript
|
||||||
|
|
||||||
Interpreter::Type_Float value = 0;
|
Interpreter::Type_Float value = 0;
|
||||||
|
|
||||||
Interpreter::Type_Float max = stats.mDynamic[mIndex].getModified();
|
Interpreter::Type_Float max = stats.getDynamic(mIndex).getModified();
|
||||||
|
|
||||||
if (max>0)
|
if (max>0)
|
||||||
value = stats.mDynamic[mIndex].getCurrent() / max;
|
value = stats.getDynamic(mIndex).getCurrent() / max;
|
||||||
|
|
||||||
runtime.push (value);
|
runtime.push (value);
|
||||||
}
|
}
|
||||||
|
@ -335,7 +344,7 @@ namespace MWScript
|
||||||
// make sure a spell with this ID actually exists.
|
// make sure a spell with this ID actually exists.
|
||||||
MWBase::Environment::get().getWorld()->getStore().spells.find (id);
|
MWBase::Environment::get().getWorld()->getStore().spells.find (id);
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.add (id);
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().add (id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -351,7 +360,7 @@ namespace MWScript
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.remove (id);
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().remove (id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -371,8 +380,8 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = 0;
|
Interpreter::Type_Integer value = 0;
|
||||||
|
|
||||||
for (MWMechanics::Spells::TIterator iter (
|
for (MWMechanics::Spells::TIterator iter (
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.begin());
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().begin());
|
||||||
iter!=MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.end(); ++iter)
|
iter!=MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().end(); ++iter)
|
||||||
if (*iter==id)
|
if (*iter==id)
|
||||||
{
|
{
|
||||||
value = 1;
|
value = 1;
|
||||||
|
|
Loading…
Reference in a new issue