diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp new file mode 100644 index 0000000000..27bf00e10b --- /dev/null +++ b/apps/openmw/mwclass/activator.cpp @@ -0,0 +1,14 @@ + +#include "activator.hpp" + +#include + +namespace MWWorld +{ + void Activator::registerSelf() + { + boost::shared_ptr instance (new Activator); + + registerClass (typeid (ESM::Activator).name(), instance); + } +} diff --git a/apps/openmw/mwworld/creature.cpp b/apps/openmw/mwworld/creature.cpp new file mode 100644 index 0000000000..dff1cb1c96 --- /dev/null +++ b/apps/openmw/mwworld/creature.cpp @@ -0,0 +1,45 @@ + +#include "creature.hpp" + +#include + +#include "../mwmechanics/creaturestats.hpp" + +#include "ptr.hpp" + +namespace MWWorld +{ + MWMechanics::CreatureStats& Creature::getCreatureStats (const Ptr& ptr) const + { + if (!ptr.getRefData().getCreatureStats().get()) + { + boost::shared_ptr stats ( + new MWMechanics::CreatureStats); + + ESMS::LiveCellRef *ref = ptr.get(); + + stats->mAttributes[0].set (ref->base->data.strength); + stats->mAttributes[1].set (ref->base->data.intelligence); + stats->mAttributes[2].set (ref->base->data.willpower); + stats->mAttributes[3].set (ref->base->data.agility); + stats->mAttributes[4].set (ref->base->data.speed); + stats->mAttributes[5].set (ref->base->data.endurance); + stats->mAttributes[6].set (ref->base->data.personality); + stats->mAttributes[7].set (ref->base->data.luck); + stats->mDynamic[0].set (ref->base->data.health); + stats->mDynamic[1].set (ref->base->data.mana); + stats->mDynamic[2].set (ref->base->data.fatigue); + + ptr.getRefData().getCreatureStats() = stats; + } + + return *ptr.getRefData().getCreatureStats(); + } + + void Creature::registerSelf() + { + boost::shared_ptr instance (new Creature); + + registerClass (typeid (ESM::Creature).name(), instance); + } +} diff --git a/apps/openmw/mwworld/creature.hpp b/apps/openmw/mwworld/creature.hpp new file mode 100644 index 0000000000..7ab2b5af0a --- /dev/null +++ b/apps/openmw/mwworld/creature.hpp @@ -0,0 +1,19 @@ +#ifndef GAME_MWWORLD_CREATURE_H +#define GAME_MWWORLD_CREATURE_H + +#include "class.hpp" + +namespace MWWorld +{ + class Creature : public Class + { + public: + + virtual MWMechanics::CreatureStats& getCreatureStats (const Ptr& ptr) const; + ///< Return creature stats + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/mwworld/npc.cpp b/apps/openmw/mwworld/npc.cpp new file mode 100644 index 0000000000..e98e532da3 --- /dev/null +++ b/apps/openmw/mwworld/npc.cpp @@ -0,0 +1,43 @@ + +#include "npc.hpp" + +#include + +#include "ptr.hpp" + +namespace MWWorld +{ + MWMechanics::CreatureStats& Npc::getCreatureStats (const Ptr& ptr) const + { + if (!ptr.getRefData().getCreatureStats().get()) + { + boost::shared_ptr stats ( + new MWMechanics::CreatureStats); + + ESMS::LiveCellRef *ref = ptr.get(); + + stats->mAttributes[0].set (ref->base->npdt52.strength); + stats->mAttributes[1].set (ref->base->npdt52.intelligence); + stats->mAttributes[2].set (ref->base->npdt52.willpower); + stats->mAttributes[3].set (ref->base->npdt52.agility); + stats->mAttributes[4].set (ref->base->npdt52.speed); + stats->mAttributes[5].set (ref->base->npdt52.endurance); + stats->mAttributes[6].set (ref->base->npdt52.personality); + stats->mAttributes[7].set (ref->base->npdt52.luck); + stats->mDynamic[0].set (ref->base->npdt52.health); + stats->mDynamic[1].set (ref->base->npdt52.mana); + stats->mDynamic[2].set (ref->base->npdt52.fatigue); + + ptr.getRefData().getCreatureStats() = stats; + } + + return *ptr.getRefData().getCreatureStats(); + } + + void Npc::registerSelf() + { + boost::shared_ptr instance (new Npc); + + registerClass (typeid (ESM::NPC).name(), instance); + } +} diff --git a/apps/openmw/mwworld/npc.hpp b/apps/openmw/mwworld/npc.hpp new file mode 100644 index 0000000000..7b10ccb328 --- /dev/null +++ b/apps/openmw/mwworld/npc.hpp @@ -0,0 +1,19 @@ +#ifndef GAME_MWWORLD_NPC_H +#define GAME_MWWORLD_NPC_H + +#include "class.hpp" + +namespace MWWorld +{ + class Npc : public Class + { + public: + + virtual MWMechanics::CreatureStats& getCreatureStats (const Ptr& ptr) const; + ///< Return creature stats + + static void registerSelf(); + }; +} + +#endif