mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 07:09:40 +00:00
Merge branch 'poly'
Conflicts: apps/openmw/mwworld/world.cpp
This commit is contained in:
commit
69ea00455f
57 changed files with 1494 additions and 155 deletions
|
@ -2,33 +2,33 @@ project(OpenMW)
|
|||
|
||||
# local files
|
||||
|
||||
set(GAME
|
||||
set(GAME
|
||||
main.cpp
|
||||
engine.cpp)
|
||||
set(GAME_HEADER
|
||||
set(GAME_HEADER
|
||||
engine.hpp)
|
||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||
|
||||
set(GAMEREND
|
||||
set(GAMEREND
|
||||
mwrender/mwscene.cpp
|
||||
mwrender/cellimp.cpp
|
||||
mwrender/interior.cpp
|
||||
mwrender/sky.cpp)
|
||||
set(GAMEREND_HEADER
|
||||
set(GAMEREND_HEADER
|
||||
mwrender/cell.hpp
|
||||
mwrender/cellimp.hpp
|
||||
mwrender/mwscene.hpp
|
||||
mwrender/interior.hpp
|
||||
mwrender/playerpos.hpp
|
||||
mwrender/sky.hpp)
|
||||
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
||||
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
||||
|
||||
set(GAMEINPUT
|
||||
mwinput/inputmanager.cpp
|
||||
)
|
||||
set(GAMEINPUT_HEADER
|
||||
set(GAMEINPUT_HEADER
|
||||
mwinput/inputmanager.hpp)
|
||||
source_group(apps\\openmw\\mwinput FILES ${GAMEINPUT} ${GAMEINPUT_HEADER})
|
||||
source_group(apps\\openmw\\mwinput FILES ${GAMEINPUT} ${GAMEINPUT_HEADER})
|
||||
|
||||
set(GAMEGUI_HEADER
|
||||
mwgui/mw_layouts.hpp
|
||||
|
@ -54,7 +54,7 @@ set(GAMESCRIPT
|
|||
mwscript/extensions.cpp
|
||||
mwscript/globalscripts.cpp
|
||||
)
|
||||
set(GAMESCRIPT_HEADER
|
||||
set(GAMESCRIPT_HEADER
|
||||
mwscript/locals.hpp
|
||||
mwscript/scriptmanager.hpp
|
||||
mwscript/compilercontext.hpp
|
||||
|
@ -68,41 +68,96 @@ set(GAMESCRIPT_HEADER
|
|||
mwscript/extensions.hpp
|
||||
mwscript/globalscripts.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
||||
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
||||
|
||||
set(GAMESOUND
|
||||
mwsound/soundmanager.cpp)
|
||||
set(GAMESOUND_HEADER
|
||||
set(GAMESOUND_HEADER
|
||||
mwsound/soundmanager.hpp)
|
||||
source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER})
|
||||
source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER})
|
||||
|
||||
set(GAMEWORLD
|
||||
mwworld/world.cpp
|
||||
mwworld/globals.cpp
|
||||
mwworld/class.cpp
|
||||
mwworld/actionteleport.cpp
|
||||
)
|
||||
set(GAMEWORLD_HEADER
|
||||
set(GAMEWORLD_HEADER
|
||||
mwworld/refdata.hpp
|
||||
mwworld/world.hpp
|
||||
mwworld/ptr.hpp
|
||||
mwworld/environment.hpp
|
||||
mwworld/globals.hpp
|
||||
mwworld/class.hpp
|
||||
mwworld/action.hpp
|
||||
mwworld/nullaction.hpp
|
||||
mwworld/actionteleport.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
||||
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
||||
|
||||
set(GAMECLASS
|
||||
mwclass/classes.cpp
|
||||
mwclass/activator.cpp
|
||||
mwclass/creature.cpp
|
||||
mwclass/npc.cpp
|
||||
mwclass/weapon.cpp
|
||||
mwclass/armor.cpp
|
||||
mwclass/potion.cpp
|
||||
mwclass/apparatus.cpp
|
||||
mwclass/book.cpp
|
||||
mwclass/clothing.cpp
|
||||
mwclass/container.cpp
|
||||
mwclass/door.cpp
|
||||
mwclass/ingredient.cpp
|
||||
mwclass/creaturelevlist.cpp
|
||||
mwclass/itemlevlist.cpp
|
||||
mwclass/light.cpp
|
||||
mwclass/lockpick.cpp
|
||||
mwclass/misc.cpp
|
||||
mwclass/probe.cpp
|
||||
mwclass/repair.cpp
|
||||
mwclass/static.cpp
|
||||
)
|
||||
set(GAMECLASS_HEADER
|
||||
mwclass/classes.hpp
|
||||
mwclass/activator.hpp
|
||||
mwclass/creature.hpp
|
||||
mwclass/npc.hpp
|
||||
mwclass/weapon.hpp
|
||||
mwclass/armor.hpp
|
||||
mwclass/potion.hpp
|
||||
mwclass/apparatus.hpp
|
||||
mwclass/book.hpp
|
||||
mwclass/clothing.hpp
|
||||
mwclass/container.hpp
|
||||
mwclass/door.hpp
|
||||
mwclass/ingredient.hpp
|
||||
mwclass/creaturelevlist.hpp
|
||||
mwclass/itemlevlist.hpp
|
||||
mwclass/light.hpp
|
||||
mwclass/lockpick.hpp
|
||||
mwclass/misc.hpp
|
||||
mwclass/probe.hpp
|
||||
mwclass/repair.hpp
|
||||
mwclass/static.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwclass FILES ${GAMECLASS} ${GAMECLASS_HEADER})
|
||||
|
||||
set(GAMEMECHANICS
|
||||
mwmechanics/mechanicsmanager.cpp)
|
||||
set(GAMEMECHANICS_HEADER
|
||||
set(GAMEMECHANICS_HEADER
|
||||
mwmechanics/mechanicsmanager.hpp
|
||||
mwmechanics/stat.hpp
|
||||
mwmechanics/creaturestats.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
||||
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
||||
|
||||
set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD}
|
||||
${GAMEMECHANICS}
|
||||
${GAMECLASS} ${GAMEMECHANICS}
|
||||
)
|
||||
set(OPENMW_HEADER ${GAME_HEADER} ${GAMEREND_HEADER} ${GAMEINPUT_HEADER} ${GAMESCRIPT_HEADER}
|
||||
${GAMESOUND_HEADER} ${GAMEGUI_HEADER} ${GAMEWORLD_HEADER} ${GAMEMECHANICS_HEADER}
|
||||
${GAMESOUND_HEADER} ${GAMEGUI_HEADER} ${GAMEWORLD_HEADER} ${GAMECLASS_HEADER}
|
||||
${GAMEMECHANICS_HEADER}
|
||||
)
|
||||
|
||||
# Main executable
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "mwworld/ptr.hpp"
|
||||
#include "mwworld/environment.hpp"
|
||||
|
||||
#include "mwclass/classes.hpp"
|
||||
|
||||
#include "mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
#include <OgreRoot.h>
|
||||
|
@ -78,6 +80,7 @@ OMW::Engine::Engine()
|
|||
, mScriptManager (0)
|
||||
, mScriptContext (0)
|
||||
{
|
||||
MWClass::registerClasses();
|
||||
}
|
||||
|
||||
OMW::Engine::~Engine()
|
||||
|
|
26
apps/openmw/mwclass/activator.cpp
Normal file
26
apps/openmw/mwclass/activator.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "activator.hpp"
|
||||
|
||||
#include <components/esm/loadacti.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Activator::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Activator>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Activator::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Activator);
|
||||
|
||||
registerClass (typeid (ESM::Activator).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/activator.hpp
Normal file
20
apps/openmw/mwclass/activator.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_ACTIVATOR_H
|
||||
#define GAME_MWCLASS_ACTIVATOR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Activator : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/apparatus.cpp
Normal file
26
apps/openmw/mwclass/apparatus.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "apparatus.hpp"
|
||||
|
||||
#include <components/esm/loadappa.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Apparatus::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Apparatus>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Apparatus::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Apparatus);
|
||||
|
||||
registerClass (typeid (ESM::Apparatus).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/apparatus.hpp
Normal file
20
apps/openmw/mwclass/apparatus.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_APPARATUS_H
|
||||
#define GAME_MWCLASS_APPARATUS_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Apparatus : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
39
apps/openmw/mwclass/armor.cpp
Normal file
39
apps/openmw/mwclass/armor.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
#include "armor.hpp"
|
||||
|
||||
#include <components/esm/loadarmo.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Armor::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Armor::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
||||
return ref->base->data.health;
|
||||
}
|
||||
|
||||
void Armor::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Armor);
|
||||
|
||||
registerClass (typeid (ESM::Armor).name(), instance);
|
||||
}
|
||||
}
|
26
apps/openmw/mwclass/armor.hpp
Normal file
26
apps/openmw/mwclass/armor.hpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef GAME_MWCLASS_ARMOR_H
|
||||
#define GAME_MWCLASS_ARMOR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Armor : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< \return Item health data available?
|
||||
|
||||
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/book.cpp
Normal file
26
apps/openmw/mwclass/book.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "book.hpp"
|
||||
|
||||
#include <components/esm/loadbook.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Book::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Book>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Book::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Book);
|
||||
|
||||
registerClass (typeid (ESM::Book).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/book.hpp
Normal file
20
apps/openmw/mwclass/book.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_BOOK_H
|
||||
#define GAME_MWCLASS_BOOK_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Book : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
50
apps/openmw/mwclass/classes.cpp
Normal file
50
apps/openmw/mwclass/classes.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
|
||||
#include "classes.hpp"
|
||||
|
||||
#include "activator.hpp"
|
||||
#include "creature.hpp"
|
||||
#include "npc.hpp"
|
||||
#include "weapon.hpp"
|
||||
#include "armor.hpp"
|
||||
#include "potion.hpp"
|
||||
#include "apparatus.hpp"
|
||||
#include "book.hpp"
|
||||
#include "clothing.hpp"
|
||||
#include "container.hpp"
|
||||
#include "door.hpp"
|
||||
#include "ingredient.hpp"
|
||||
#include "creaturelevlist.hpp"
|
||||
#include "itemlevlist.hpp"
|
||||
#include "light.hpp"
|
||||
#include "lockpick.hpp"
|
||||
#include "misc.hpp"
|
||||
#include "probe.hpp"
|
||||
#include "repair.hpp"
|
||||
#include "static.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void registerClasses()
|
||||
{
|
||||
Activator::registerSelf();
|
||||
Creature::registerSelf();
|
||||
Npc::registerSelf();
|
||||
Weapon::registerSelf();
|
||||
Armor::registerSelf();
|
||||
Potion::registerSelf();
|
||||
Apparatus::registerSelf();
|
||||
Book::registerSelf();
|
||||
Clothing::registerSelf();
|
||||
Container::registerSelf();
|
||||
Door::registerSelf();
|
||||
Ingredient::registerSelf();
|
||||
CreatureLevList::registerSelf();
|
||||
ItemLevList::registerSelf();
|
||||
Light::registerSelf();
|
||||
Lockpick::registerSelf();
|
||||
Misc::registerSelf();
|
||||
Probe::registerSelf();
|
||||
Repair::registerSelf();
|
||||
Static::registerSelf();
|
||||
}
|
||||
}
|
10
apps/openmw/mwclass/classes.hpp
Normal file
10
apps/openmw/mwclass/classes.hpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef GAME_MWCLASS_CLASSES_H
|
||||
#define GAME_MWCLASS_CLASSES_H
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void registerClasses();
|
||||
///< register all known classes
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/clothing.cpp
Normal file
26
apps/openmw/mwclass/clothing.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "clothing.hpp"
|
||||
|
||||
#include <components/esm/loadclot.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Clothing::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Clothing>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Clothing::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Clothing);
|
||||
|
||||
registerClass (typeid (ESM::Clothing).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/clothing.hpp
Normal file
20
apps/openmw/mwclass/clothing.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_CLOTHING_H
|
||||
#define GAME_MWCLASS_CLOTHING_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Clothing : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/container.cpp
Normal file
26
apps/openmw/mwclass/container.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "container.hpp"
|
||||
|
||||
#include <components/esm/loadcont.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Container::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Container>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Container::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Container);
|
||||
|
||||
registerClass (typeid (ESM::Container).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/container.hpp
Normal file
20
apps/openmw/mwclass/container.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_CONTAINER_H
|
||||
#define GAME_MWCLASS_CONTAINER_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Container : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
53
apps/openmw/mwclass/creature.cpp
Normal file
53
apps/openmw/mwclass/creature.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
#include "creature.hpp"
|
||||
|
||||
#include <components/esm/loadcrea.hpp>
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Creature::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Creature>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
if (!ptr.getRefData().getCreatureStats().get())
|
||||
{
|
||||
boost::shared_ptr<MWMechanics::CreatureStats> stats (
|
||||
new MWMechanics::CreatureStats);
|
||||
|
||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::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);
|
||||
}
|
||||
}
|
23
apps/openmw/mwclass/creature.hpp
Normal file
23
apps/openmw/mwclass/creature.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef GAME_MWCLASS_CREATURE_H
|
||||
#define GAME_MWCLASS_CREATURE_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Creature : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
|
||||
///< Return creature stats
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
19
apps/openmw/mwclass/creaturelevlist.cpp
Normal file
19
apps/openmw/mwclass/creaturelevlist.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
#include "creaturelevlist.hpp"
|
||||
|
||||
#include <components/esm/loadlevlist.hpp>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string CreatureLevList::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void CreatureLevList::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new CreatureLevList);
|
||||
|
||||
registerClass (typeid (ESM::CreatureLevList).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/creaturelevlist.hpp
Normal file
20
apps/openmw/mwclass/creaturelevlist.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_CREATURELEVLIST_H
|
||||
#define GAME_MWCLASS_CREATURELEVLIST_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class CreatureLevList : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
62
apps/openmw/mwclass/door.cpp
Normal file
62
apps/openmw/mwclass/door.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
|
||||
#include "door.hpp"
|
||||
|
||||
#include <components/esm/loaddoor.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwrender/playerpos.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/nullaction.hpp"
|
||||
#include "../mwworld/actionteleport.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Door::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Door>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Door>();
|
||||
|
||||
if (ref->ref.teleport)
|
||||
{
|
||||
// teleport door
|
||||
if (environment.mWorld->getPlayerPos().getPlayer()==actor)
|
||||
{
|
||||
// the player is using the door
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest));
|
||||
}
|
||||
else
|
||||
{
|
||||
// another NPC or a create is using the door
|
||||
// TODO return action for teleporting other NPC/creature
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// animated door
|
||||
// TODO return action for rotating the door
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
}
|
||||
}
|
||||
|
||||
void Door::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Door);
|
||||
|
||||
registerClass (typeid (ESM::Door).name(), instance);
|
||||
}
|
||||
}
|
24
apps/openmw/mwclass/door.hpp
Normal file
24
apps/openmw/mwclass/door.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef GAME_MWCLASS_DOOR_H
|
||||
#define GAME_MWCLASS_DOOR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Door : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
|
||||
///< Generate action for activation
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/ingredient.cpp
Normal file
26
apps/openmw/mwclass/ingredient.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "ingredient.hpp"
|
||||
|
||||
#include <components/esm/loadingr.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Ingredient::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Ingredient>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Ingredient::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Ingredient);
|
||||
|
||||
registerClass (typeid (ESM::Ingredient).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/ingredient.hpp
Normal file
20
apps/openmw/mwclass/ingredient.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_INGREDIENT_H
|
||||
#define GAME_MWCLASS_INGREDIENT_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Ingredient : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
19
apps/openmw/mwclass/itemlevlist.cpp
Normal file
19
apps/openmw/mwclass/itemlevlist.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
#include "itemlevlist.hpp"
|
||||
|
||||
#include <components/esm/loadlevlist.hpp>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string ItemLevList::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void ItemLevList::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new ItemLevList);
|
||||
|
||||
registerClass (typeid (ESM::ItemLevList).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/itemlevlist.hpp
Normal file
20
apps/openmw/mwclass/itemlevlist.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_ITEMLEVLIST_H
|
||||
#define GAME_MWCLASS_ITEMLEVLIST_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class ItemLevList : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
29
apps/openmw/mwclass/light.cpp
Normal file
29
apps/openmw/mwclass/light.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
#include "light.hpp"
|
||||
|
||||
#include <components/esm/loadligh.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Light::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Light>();
|
||||
|
||||
if (ref->base->model.empty())
|
||||
return "";
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Light::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Light);
|
||||
|
||||
registerClass (typeid (ESM::Light).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/light.hpp
Normal file
20
apps/openmw/mwclass/light.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_LIGHT_H
|
||||
#define GAME_MWCLASS_LIGHT_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Light : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/lockpick.cpp
Normal file
26
apps/openmw/mwclass/lockpick.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "lockpick.hpp"
|
||||
|
||||
#include <components/esm/loadlocks.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Lockpick::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Tool>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Lockpick::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Lockpick);
|
||||
|
||||
registerClass (typeid (ESM::Tool).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/lockpick.hpp
Normal file
20
apps/openmw/mwclass/lockpick.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_LOCKPICK_H
|
||||
#define GAME_MWCLASS_LOCKPICK_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Lockpick : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/misc.cpp
Normal file
26
apps/openmw/mwclass/misc.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "misc.hpp"
|
||||
|
||||
#include <components/esm/loadmisc.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Misc::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Misc>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Misc::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Misc);
|
||||
|
||||
registerClass (typeid (ESM::Misc).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/misc.hpp
Normal file
20
apps/openmw/mwclass/misc.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_MISC_H
|
||||
#define GAME_MWCLASS_MISC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Misc : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
53
apps/openmw/mwclass/npc.cpp
Normal file
53
apps/openmw/mwclass/npc.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
#include "npc.hpp"
|
||||
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Npc::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::NPC>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
if (!ptr.getRefData().getCreatureStats().get())
|
||||
{
|
||||
boost::shared_ptr<MWMechanics::CreatureStats> stats (
|
||||
new MWMechanics::CreatureStats);
|
||||
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::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);
|
||||
}
|
||||
}
|
23
apps/openmw/mwclass/npc.hpp
Normal file
23
apps/openmw/mwclass/npc.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef GAME_MWCLASS_NPC_H
|
||||
#define GAME_MWCLASS_NPC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Npc : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
|
||||
///< Return creature stats
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/potion.cpp
Normal file
26
apps/openmw/mwclass/potion.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "potion.hpp"
|
||||
|
||||
#include <components/esm/loadalch.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Potion::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Potion>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Potion::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Potion);
|
||||
|
||||
registerClass (typeid (ESM::Potion).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/potion.hpp
Normal file
20
apps/openmw/mwclass/potion.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_POTION_H
|
||||
#define GAME_MWCLASS_POTION_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Potion : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/probe.cpp
Normal file
26
apps/openmw/mwclass/probe.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "probe.hpp"
|
||||
|
||||
#include <components/esm/loadlocks.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Probe::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Probe>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Probe::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Probe);
|
||||
|
||||
registerClass (typeid (ESM::Probe).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/probe.hpp
Normal file
20
apps/openmw/mwclass/probe.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_PROBE_H
|
||||
#define GAME_MWCLASS_PROBE_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Probe : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
26
apps/openmw/mwclass/repair.cpp
Normal file
26
apps/openmw/mwclass/repair.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "repair.hpp"
|
||||
|
||||
#include <components/esm/loadlocks.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Repair::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Repair>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Repair::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Repair);
|
||||
|
||||
registerClass (typeid (ESM::Repair).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/repair.hpp
Normal file
20
apps/openmw/mwclass/repair.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_REPAIR_H
|
||||
#define GAME_MWCLASS_REPAIR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Repair : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
19
apps/openmw/mwclass/static.cpp
Normal file
19
apps/openmw/mwclass/static.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
#include "static.hpp"
|
||||
|
||||
#include <components/esm/loadstat.hpp>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Static::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void Static::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Static);
|
||||
|
||||
registerClass (typeid (ESM::Static).name(), instance);
|
||||
}
|
||||
}
|
20
apps/openmw/mwclass/static.hpp
Normal file
20
apps/openmw/mwclass/static.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAME_MWCLASS_STATIC_H
|
||||
#define GAME_MWCLASS_STATIC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Static : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
39
apps/openmw/mwclass/weapon.cpp
Normal file
39
apps/openmw/mwclass/weapon.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
#include "weapon.hpp"
|
||||
|
||||
#include <components/esm/loadweap.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Weapon::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Weapon::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
return ref->base->data.health;
|
||||
}
|
||||
|
||||
void Weapon::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Weapon);
|
||||
|
||||
registerClass (typeid (ESM::Weapon).name(), instance);
|
||||
}
|
||||
}
|
26
apps/openmw/mwclass/weapon.hpp
Normal file
26
apps/openmw/mwclass/weapon.hpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef GAME_MWCLASS_WEAPON_H
|
||||
#define GAME_MWCLASS_WEAPON_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Weapon : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< \return Item health data available?
|
||||
|
||||
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "../mwgui/window_manager.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
MechanicsManager::MechanicsManager (const ESMS::ESMStore& store,
|
||||
|
@ -46,7 +48,8 @@ namespace MWMechanics
|
|||
{
|
||||
if (!mWatched.isEmpty())
|
||||
{
|
||||
MWMechanics::CreatureStats& stats = mWatched.getCreatureStats();
|
||||
MWMechanics::CreatureStats& stats =
|
||||
MWWorld::Class::get (mWatched).getCreatureStats (mWatched);
|
||||
|
||||
static const char *attributeNames[8] =
|
||||
{
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
#include <components/interpreter/runtime.hpp>
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
namespace MWScript
|
||||
|
@ -26,8 +30,10 @@ namespace MWScript
|
|||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
context.getReference().getCreatureStats().mAttributes[mIndex].
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
getModified();
|
||||
|
||||
runtime.push (value);
|
||||
|
@ -50,8 +56,10 @@ namespace MWScript
|
|||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
context.getWorld().getPtr (id, false).getCreatureStats().mAttributes[mIndex].
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
getModified();
|
||||
|
||||
runtime.push (value);
|
||||
|
@ -74,7 +82,9 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
context.getReference().getCreatureStats().mAttributes[mIndex].
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
@ -98,7 +108,9 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
context.getWorld().getPtr (id, false).getCreatureStats().mAttributes[mIndex].
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
@ -119,10 +131,12 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
value += context.getReference().getCreatureStats().mAttributes[mIndex].
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
value += MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
getModified();
|
||||
|
||||
context.getReference().getCreatureStats().mAttributes[mIndex].
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
setModified (value, 0, 100);
|
||||
}
|
||||
};
|
||||
|
@ -146,11 +160,13 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
value +=
|
||||
context.getWorld().getPtr (id, false).getCreatureStats().mAttributes[mIndex].
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
getModified();
|
||||
|
||||
context.getWorld().getPtr (id, false).getCreatureStats().mAttributes[mIndex].
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
setModified (value, 0, 100);
|
||||
}
|
||||
};
|
||||
|
@ -168,35 +184,20 @@ namespace MWScript
|
|||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
if (mIndex==0)
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
||||
{
|
||||
// health is a special case
|
||||
if (context.getReference().getType()==
|
||||
typeid (ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *))
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
context.getReference().get<ESM::Weapon>();
|
||||
Interpreter::Type_Integer value =
|
||||
MWWorld::Class::get (ptr).getItemMaxHealth (ptr);
|
||||
runtime.push (value);
|
||||
|
||||
Interpreter::Type_Integer value = ref->base->data.health;
|
||||
runtime.push (value);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (context.getReference().getType()==
|
||||
typeid (ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *))
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
context.getReference().get<ESM::Armor>();
|
||||
|
||||
Interpreter::Type_Integer value = ref->base->data.health;
|
||||
runtime.push (value);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
context.getReference().getCreatureStats().mDynamic[mIndex].
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||
getCurrent();
|
||||
|
||||
runtime.push (value);
|
||||
|
@ -219,35 +220,20 @@ namespace MWScript
|
|||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
if (mIndex==0)
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
||||
{
|
||||
// health is a special case
|
||||
if (context.getWorld().getPtr (id, false).getType()==
|
||||
typeid (ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *))
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
context.getWorld().getPtr (id, false).get<ESM::Weapon>();
|
||||
Interpreter::Type_Integer value =
|
||||
MWWorld::Class::get (ptr).getItemMaxHealth (ptr);
|
||||
runtime.push (value);
|
||||
|
||||
Interpreter::Type_Integer value = ref->base->data.health;
|
||||
runtime.push (value);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (context.getWorld().getPtr (id, false).getType()==
|
||||
typeid (ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *))
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
context.getWorld().getPtr (id, false).get<ESM::Armor>();
|
||||
|
||||
Interpreter::Type_Integer value = ref->base->data.health;
|
||||
runtime.push (value);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
context.getWorld().getPtr (id, false).getCreatureStats().mDynamic[mIndex].
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||
getCurrent();
|
||||
|
||||
runtime.push (value);
|
||||
|
@ -270,7 +256,9 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
context.getReference().getCreatureStats().mDynamic[mIndex].
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
@ -294,7 +282,9 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
context.getWorld().getPtr (id, false).getCreatureStats().mDynamic[mIndex].
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
@ -315,7 +305,9 @@ namespace MWScript
|
|||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWMechanics::CreatureStats& stats = context.getReference().getCreatureStats();
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||
|
||||
|
@ -345,8 +337,10 @@ namespace MWScript
|
|||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWMechanics::CreatureStats& stats =
|
||||
context.getWorld().getPtr (id, false).getCreatureStats();
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||
|
||||
|
@ -374,7 +368,9 @@ namespace MWScript
|
|||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWMechanics::CreatureStats& stats = context.getReference().getCreatureStats();
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||
|
||||
|
@ -401,8 +397,10 @@ namespace MWScript
|
|||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWMechanics::CreatureStats& stats =
|
||||
context.getWorld().getPtr (id, false).getCreatureStats();
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||
|
||||
|
@ -423,7 +421,9 @@ namespace MWScript
|
|||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWMechanics::CreatureStats& stats = context.getReference().getCreatureStats();
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Float value = 0;
|
||||
|
||||
|
@ -452,8 +452,10 @@ namespace MWScript
|
|||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWMechanics::CreatureStats& stats =
|
||||
context.getWorld().getPtr (id, false).getCreatureStats();
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Float value = 0;
|
||||
|
||||
|
|
25
apps/openmw/mwworld/action.hpp
Normal file
25
apps/openmw/mwworld/action.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef GAME_MWWORLD_ACTION_H
|
||||
#define GAME_MWWORLD_ACTION_H
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Environment;
|
||||
|
||||
/// \brief Abstract base for actions
|
||||
class Action
|
||||
{
|
||||
// not implemented
|
||||
Action (const Action& action);
|
||||
Action& operator= (const Action& action);
|
||||
|
||||
public:
|
||||
|
||||
Action() {}
|
||||
|
||||
virtual ~Action() {}
|
||||
|
||||
virtual void execute (Environment& environment) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
18
apps/openmw/mwworld/actionteleport.cpp
Normal file
18
apps/openmw/mwworld/actionteleport.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
#include "actionteleport.hpp"
|
||||
|
||||
#include "environment.hpp"
|
||||
#include "world.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
ActionTeleportPlayer::ActionTeleportPlayer (const std::string& cellName,
|
||||
const ESM::Position& position)
|
||||
: mCellName (cellName), mPosition (position)
|
||||
{}
|
||||
|
||||
void ActionTeleportPlayer::ActionTeleportPlayer::execute (Environment& environment)
|
||||
{
|
||||
environment.mWorld->changeCell (mCellName, mPosition);
|
||||
}
|
||||
}
|
25
apps/openmw/mwworld/actionteleport.hpp
Normal file
25
apps/openmw/mwworld/actionteleport.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef GAME_MWWORLD_ACTIONTELEPORT_H
|
||||
#define GAME_MWWORLD_ACTIONTELEPORT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
|
||||
#include "action.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class ActionTeleportPlayer : public Action
|
||||
{
|
||||
std::string mCellName;
|
||||
ESM::Position mPosition;
|
||||
|
||||
public:
|
||||
|
||||
ActionTeleportPlayer (const std::string& cellName, const ESM::Position& position);
|
||||
|
||||
virtual void execute (Environment& environment);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
63
apps/openmw/mwworld/class.cpp
Normal file
63
apps/openmw/mwworld/class.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
|
||||
#include "class.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "ptr.hpp"
|
||||
#include "nullaction.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
std::map<std::string, boost::shared_ptr<Class> > Class::sClasses;
|
||||
|
||||
Class::Class() {}
|
||||
|
||||
Class::~Class() {}
|
||||
|
||||
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have creature stats");
|
||||
}
|
||||
|
||||
bool Class::hasItemHealth (const Ptr& ptr) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int Class::getItemMaxHealth (const Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have item health");
|
||||
}
|
||||
|
||||
boost::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor,
|
||||
const Environment& environment) const
|
||||
{
|
||||
return boost::shared_ptr<Action> (new NullAction);
|
||||
}
|
||||
|
||||
boost::shared_ptr<Action> Class::use (const Ptr& ptr,
|
||||
const Environment& environment) const
|
||||
{
|
||||
return boost::shared_ptr<Action> (new NullAction);
|
||||
}
|
||||
|
||||
const Class& Class::get (const std::string& key)
|
||||
{
|
||||
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||
|
||||
if (iter==sClasses.end())
|
||||
throw std::logic_error ("unknown class key: " + key);
|
||||
|
||||
return *iter->second;
|
||||
}
|
||||
|
||||
const Class& Class::get (const Ptr& ptr)
|
||||
{
|
||||
return get (ptr.getTypeName());
|
||||
}
|
||||
|
||||
void Class::registerClass (const std::string& key, boost::shared_ptr<Class> instance)
|
||||
{
|
||||
sClasses.insert (std::make_pair (key, instance));
|
||||
}
|
||||
}
|
71
apps/openmw/mwworld/class.hpp
Normal file
71
apps/openmw/mwworld/class.hpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef GAME_MWWORLD_CLASS_H
|
||||
#define GAME_MWWORLD_CLASS_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "action.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
struct CreatureStats;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
|
||||
/// \brief Base class for referenceable esm records
|
||||
class Class
|
||||
{
|
||||
static std::map<std::string, boost::shared_ptr<Class> > sClasses;
|
||||
|
||||
// not implemented
|
||||
Class (const Class&);
|
||||
Class& operator= (const Class&);
|
||||
|
||||
protected:
|
||||
|
||||
Class();
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Class();
|
||||
|
||||
virtual std::string getName (const Ptr& ptr) const = 0;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual MWMechanics::CreatureStats& getCreatureStats (const Ptr& ptr) const;
|
||||
///< Return creature stats or throw an exception, if class does not have creature stats
|
||||
/// (default implementation: throw an exceoption)
|
||||
|
||||
virtual bool hasItemHealth (const Ptr& ptr) const;
|
||||
///< \return Item health data available? (default implementation: false)
|
||||
|
||||
virtual int getItemMaxHealth (const Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
/// (default implementation: throw an exceoption)
|
||||
|
||||
virtual boost::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor,
|
||||
const Environment& environment) const;
|
||||
///< Generate action for activation (default implementation: return a null action).
|
||||
|
||||
virtual boost::shared_ptr<Action> use (const Ptr& ptr, const Environment& environment)
|
||||
const;
|
||||
///< Generate action for using via inventory menu (default implementation: return a
|
||||
/// null action).
|
||||
|
||||
static const Class& get (const std::string& key);
|
||||
///< If there is no class for this \a key, an exception is thrown.
|
||||
|
||||
static const Class& get (const Ptr& ptr);
|
||||
///< If there is no class for this pointer, an exception is thrown.
|
||||
|
||||
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
17
apps/openmw/mwworld/nullaction.hpp
Normal file
17
apps/openmw/mwworld/nullaction.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef GAME_MWWORLD_NULLACTION_H
|
||||
#define GAME_MWWORLD_NULLACTION_H
|
||||
|
||||
#include "action.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
/// \brief Action: do nothing
|
||||
class NullAction : public Action
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Environment& environment) {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -5,12 +5,8 @@
|
|||
|
||||
#include <boost/any.hpp>
|
||||
|
||||
#include <components/esm/loadcrea.hpp>
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "refdata.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -27,6 +23,7 @@ namespace MWWorld
|
|||
ESM::CellRef *mCellRef;
|
||||
RefData *mRefData;
|
||||
CellStore *mCell;
|
||||
std::string mTypeName;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -43,6 +40,11 @@ namespace MWWorld
|
|||
return mPtr.type();
|
||||
}
|
||||
|
||||
const std::string& getTypeName() const
|
||||
{
|
||||
return mTypeName;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell)
|
||||
{
|
||||
|
@ -50,6 +52,7 @@ namespace MWWorld
|
|||
mCellRef = &liveCellRef->ref;
|
||||
mRefData = &liveCellRef->mData;
|
||||
mCell = cell;
|
||||
mTypeName = typeid (T).name();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -75,63 +78,6 @@ namespace MWWorld
|
|||
assert (mCell);
|
||||
return mCell;
|
||||
}
|
||||
|
||||
/// Throws an exception, if the ID type does not support creature stats.
|
||||
MWMechanics::CreatureStats& getCreatureStats() const
|
||||
{
|
||||
RefData& data = getRefData();
|
||||
|
||||
if (!data.getCreatureStats().get())
|
||||
{
|
||||
if (mPtr.type()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData> *))
|
||||
{
|
||||
boost::shared_ptr<MWMechanics::CreatureStats> stats (
|
||||
new MWMechanics::CreatureStats);
|
||||
|
||||
ESMS::LiveCellRef<ESM::Creature, RefData> *ref = 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);
|
||||
|
||||
data.getCreatureStats() = stats;
|
||||
}
|
||||
else if (mPtr.type()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData> *))
|
||||
{
|
||||
boost::shared_ptr<MWMechanics::CreatureStats> stats (
|
||||
new MWMechanics::CreatureStats);
|
||||
|
||||
ESMS::LiveCellRef<ESM::NPC, RefData> *ref = 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);
|
||||
|
||||
data.getCreatureStats() = stats;
|
||||
}
|
||||
else
|
||||
throw std::runtime_error (
|
||||
"CreatureStats not available for this ID type");
|
||||
}
|
||||
|
||||
return *data.getCreatureStats();
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator== (const Ptr& left, const Ptr& right)
|
||||
|
|
|
@ -120,10 +120,10 @@ namespace MWWorld
|
|||
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = cell.npcs.find (name))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.probes.find (name))
|
||||
if (ESMS::LiveCellRef<ESM::Probe, RefData> *ref = cell.probes.find (name))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.repairs.find (name))
|
||||
if (ESMS::LiveCellRef<ESM::Repair, RefData> *ref = cell.repairs.find (name))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Static, RefData> *ref = cell.statics.find (name))
|
||||
|
@ -183,10 +183,10 @@ namespace MWWorld
|
|||
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = searchViaHandle (handle, cell.npcs))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = searchViaHandle (handle, cell.probes))
|
||||
if (ESMS::LiveCellRef<ESM::Probe, RefData> *ref = searchViaHandle (handle, cell.probes))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = searchViaHandle (handle, cell.repairs))
|
||||
if (ESMS::LiveCellRef<ESM::Repair, RefData> *ref = searchViaHandle (handle, cell.repairs))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Static, RefData> *ref = searchViaHandle (handle, cell.statics))
|
||||
|
|
|
@ -50,5 +50,16 @@ struct Tool
|
|||
icon = esm.getHNOString("ITEX");
|
||||
}
|
||||
};
|
||||
|
||||
struct Probe : Tool
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
struct Repair : Tool
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace ESMS
|
|||
|
||||
list.push_back(lr);
|
||||
}
|
||||
|
||||
|
||||
LiveRef *find (const std::string& name)
|
||||
{
|
||||
for (typename std::list<LiveRef>::iterator iter (list.begin()); iter!=list.end(); ++iter)
|
||||
|
@ -71,9 +71,9 @@ namespace ESMS
|
|||
if (iter->ref.refID==name)
|
||||
return &*iter;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// A storage struct for one single cell reference.
|
||||
|
@ -102,8 +102,8 @@ namespace ESMS
|
|||
CellRefList<Tool, D> lockpicks;
|
||||
CellRefList<Misc, D> miscItems;
|
||||
CellRefList<NPC, D> npcs;
|
||||
CellRefList<Tool, D> probes;
|
||||
CellRefList<Tool, D> repairs;
|
||||
CellRefList<Probe, D> probes;
|
||||
CellRefList<Repair, D> repairs;
|
||||
CellRefList<Static, D> statics;
|
||||
CellRefList<Weapon, D> weapons;
|
||||
|
||||
|
@ -119,12 +119,12 @@ namespace ESMS
|
|||
throw str_exception("Cell not found - " + name);
|
||||
|
||||
loadRefs(store, esm);
|
||||
}
|
||||
}
|
||||
|
||||
/** Ditto for exterior cell. */
|
||||
void loadExt(int X, int Y, const ESMStore &store, ESMReader &esm)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -176,7 +176,7 @@ namespace ESMS
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -55,10 +55,10 @@ namespace ESMS
|
|||
RecListT<Misc> miscItems;
|
||||
RecListT<NPC> npcs;
|
||||
RecListT<LoadNPCC> npcChange;
|
||||
RecListT<Tool> probes;
|
||||
RecListT<Probe> probes;
|
||||
RecListT<Race> races;
|
||||
RecListT<Region> regions;
|
||||
RecListT<Tool> repairs;
|
||||
RecListT<Repair> repairs;
|
||||
RecListT<SoundGenerator> soundGens;
|
||||
RecListT<Sound> sounds;
|
||||
RecListT<Spell> spells;
|
||||
|
|
Loading…
Reference in a new issue