mirror of https://github.com/OpenMW/openmw.git
previous commit was missing some files
parent
ca842d1b4d
commit
9d6e658e05
@ -0,0 +1,14 @@
|
||||
|
||||
#include "activator.hpp"
|
||||
|
||||
#include <components/esm/loadacti.hpp>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
void Activator::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Activator);
|
||||
|
||||
registerClass (typeid (ESM::Activator).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
|
||||
#include "creature.hpp"
|
||||
|
||||
#include <components/esm/loadcrea.hpp>
|
||||
|
||||
#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<MWMechanics::CreatureStats> stats (
|
||||
new MWMechanics::CreatureStats);
|
||||
|
||||
ESMS::LiveCellRef<ESM::Creature, RefData> *ref = ptr.get<ESM::Creature>();
|
||||
|
||||
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<Class> instance (new Creature);
|
||||
|
||||
registerClass (typeid (ESM::Creature).name(), instance);
|
||||
}
|
||||
}
|
@ -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
|
@ -0,0 +1,43 @@
|
||||
|
||||
#include "npc.hpp"
|
||||
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
|
||||
#include "ptr.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
MWMechanics::CreatureStats& Npc::getCreatureStats (const Ptr& ptr) const
|
||||
{
|
||||
if (!ptr.getRefData().getCreatureStats().get())
|
||||
{
|
||||
boost::shared_ptr<MWMechanics::CreatureStats> stats (
|
||||
new MWMechanics::CreatureStats);
|
||||
|
||||
ESMS::LiveCellRef<ESM::NPC, RefData> *ref = ptr.get<ESM::NPC>();
|
||||
|
||||
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<Class> instance (new Npc);
|
||||
|
||||
registerClass (typeid (ESM::NPC).name(), instance);
|
||||
}
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue