forked from teamnwah/openmw-tes3coop
added getEncumbrance function
This commit is contained in:
parent
c6493fb133
commit
7e00fea18b
8 changed files with 65 additions and 5 deletions
|
@ -184,4 +184,9 @@ namespace MWClass
|
|||
|
||||
return ref->base->weight;
|
||||
}
|
||||
|
||||
float Container::getEncumbrance (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return getContainerStore (ptr).getWeight();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,11 @@ namespace MWClass
|
|||
///< Return name of the script attached to ptr
|
||||
|
||||
virtual float getCapactiy (const MWWorld::Ptr& ptr) const;
|
||||
///< Return total weight that fits into the object (including modifications from magic
|
||||
///< Return total weight that fits into the object. Throws an exception, if the object can't
|
||||
/// hold other objects.
|
||||
|
||||
virtual float getEncumbrance (const MWWorld::Ptr& ptr) const;
|
||||
///< Returns total weight of objects inside this object (including modifications from magic
|
||||
/// effects). Throws an exception, if the object can't hold other objects.
|
||||
|
||||
static void registerSelf();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
#include "../mwmechanics/magiceffects.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
|
@ -172,4 +173,20 @@ namespace MWClass
|
|||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||
return stats.mAttributes[0].getModified()*5;
|
||||
}
|
||||
|
||||
float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
float weight = getContainerStore (ptr).getWeight();
|
||||
|
||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||
|
||||
weight -= stats.mMagicEffects.get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
||||
|
||||
weight += stats.mMagicEffects.get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
||||
|
||||
if (weight<0)
|
||||
weight = 0;
|
||||
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,11 @@ namespace MWClass
|
|||
///< Return name of the script attached to ptr
|
||||
|
||||
virtual float getCapactiy (const MWWorld::Ptr& ptr) const;
|
||||
///< Return total weight that fits into the object (including modifications from magic
|
||||
///< Return total weight that fits into the object. Throws an exception, if the object can't
|
||||
/// hold other objects.
|
||||
|
||||
virtual float getEncumbrance (const MWWorld::Ptr& ptr) const;
|
||||
///< Returns total weight of objects inside this object (including modifications from magic
|
||||
/// effects). Throws an exception, if the object can't hold other objects.
|
||||
|
||||
static void registerSelf();
|
||||
|
|
|
@ -331,4 +331,20 @@ namespace MWClass
|
|||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||
return stats.mAttributes[0].getModified()*5;
|
||||
}
|
||||
|
||||
float Npc::getEncumbrance (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
float weight = getContainerStore (ptr).getWeight();
|
||||
|
||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||
|
||||
weight -= stats.mMagicEffects.get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
||||
|
||||
weight += stats.mMagicEffects.get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
||||
|
||||
if (weight<0)
|
||||
weight = 0;
|
||||
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,11 @@ namespace MWClass
|
|||
/// stance and stats).
|
||||
|
||||
virtual float getCapactiy (const MWWorld::Ptr& ptr) const;
|
||||
///< Return total weight that fits into the object (including modifications from magic
|
||||
///< Return total weight that fits into the object. Throws an exception, if the object can't
|
||||
/// hold other objects.
|
||||
|
||||
virtual float getEncumbrance (const MWWorld::Ptr& ptr) const;
|
||||
///< Returns total weight of objects inside this object (including modifications from magic
|
||||
/// effects). Throws an exception, if the object can't hold other objects.
|
||||
|
||||
static void registerSelf();
|
||||
|
|
|
@ -144,7 +144,12 @@ namespace MWWorld
|
|||
|
||||
float Class::getCapactiy (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("capacity not supported by class");
|
||||
throw std::runtime_error ("capacity not supported by this class");
|
||||
}
|
||||
|
||||
float Class::getEncumbrance (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("encumbrance not supported by class");
|
||||
}
|
||||
|
||||
const Class& Class::get (const std::string& key)
|
||||
|
|
|
@ -165,7 +165,12 @@ namespace MWWorld
|
|||
/// (default implementation: throws an exception)
|
||||
|
||||
virtual float getCapactiy (const MWWorld::Ptr& ptr) const;
|
||||
///< Return total weight that fits into the object (including modifications from magic
|
||||
///< Return total weight that fits into the object. Throws an exception, if the object can't
|
||||
/// hold other objects.
|
||||
/// (default implementation: throws an exception)
|
||||
|
||||
virtual float getEncumbrance (const MWWorld::Ptr& ptr) const;
|
||||
///< Returns total weight of objects inside this object (including modifications from magic
|
||||
/// effects). Throws an exception, if the object can't hold other objects.
|
||||
/// (default implementation: throws an exception)
|
||||
|
||||
|
|
Loading…
Reference in a new issue