From 9d6e658e052b045adff765f2851ecee53d3bb8ec Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 3 Aug 2010 13:03:08 +0200 Subject: [PATCH] previous commit was missing some files --- apps/openmw/mwclass/activator.cpp | 14 ++++++++++ apps/openmw/mwworld/creature.cpp | 45 +++++++++++++++++++++++++++++++ apps/openmw/mwworld/creature.hpp | 19 +++++++++++++ apps/openmw/mwworld/npc.cpp | 43 +++++++++++++++++++++++++++++ apps/openmw/mwworld/npc.hpp | 19 +++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 apps/openmw/mwclass/activator.cpp create mode 100644 apps/openmw/mwworld/creature.cpp create mode 100644 apps/openmw/mwworld/creature.hpp create mode 100644 apps/openmw/mwworld/npc.cpp create mode 100644 apps/openmw/mwworld/npc.hpp diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp new file mode 100644 index 000000000..27bf00e10 --- /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 000000000..dff1cb1c9 --- /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 000000000..7ab2b5af0 --- /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 000000000..e98e532da --- /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 000000000..7b10ccb32 --- /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