2010-08-03 11:14:57 +02:00
|
|
|
|
|
|
|
#include "class.hpp"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
2011-02-03 11:37:17 +01:00
|
|
|
#include <OgreVector3.h>
|
|
|
|
|
2012-07-25 17:18:17 +04:00
|
|
|
#include <components/esm/defs.hpp>
|
|
|
|
|
2010-08-03 11:49:12 +02:00
|
|
|
#include "ptr.hpp"
|
2012-07-25 17:18:17 +04:00
|
|
|
#include "refdata.hpp"
|
2010-08-03 18:20:15 +02:00
|
|
|
#include "nullaction.hpp"
|
2012-02-20 12:44:17 +01:00
|
|
|
#include "containerstore.hpp"
|
2010-08-03 11:49:12 +02:00
|
|
|
|
2012-07-03 13:15:20 +02:00
|
|
|
#include "../mwgui/tooltips.hpp"
|
2013-07-25 08:15:42 -07:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
#include "../mwmechanics/magiceffects.hpp"
|
2012-07-03 13:15:20 +02:00
|
|
|
|
2010-08-03 11:14:57 +02:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
std::map<std::string, boost::shared_ptr<Class> > Class::sClasses;
|
|
|
|
|
|
|
|
Class::Class() {}
|
|
|
|
|
|
|
|
Class::~Class() {}
|
|
|
|
|
2010-08-08 14:28:35 +02:00
|
|
|
std::string Class::getId (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support ID retrieval");
|
|
|
|
}
|
|
|
|
|
2011-11-09 15:47:06 -05:00
|
|
|
void Class::insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
2010-08-14 09:20:47 +02:00
|
|
|
{
|
|
|
|
|
2011-11-09 18:06:55 -05:00
|
|
|
}
|
2012-04-08 19:44:11 +02:00
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
2012-04-08 19:44:11 +02:00
|
|
|
{
|
2011-11-09 18:06:55 -05:00
|
|
|
|
2010-08-14 09:20:47 +02:00
|
|
|
}
|
|
|
|
|
2012-07-13 08:50:46 +02:00
|
|
|
bool Class::apply (const MWWorld::Ptr& ptr, const std::string& id, const MWWorld::Ptr& actor) const
|
2012-06-24 16:23:43 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-13 09:03:17 +02:00
|
|
|
void Class::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not represent an actor");
|
|
|
|
}
|
|
|
|
|
2013-04-07 21:38:53 +02:00
|
|
|
bool Class::canSell (const MWWorld::Ptr& item, int npcServices) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
int Class::getServices(const Ptr &actor) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have services");
|
|
|
|
}
|
|
|
|
|
2010-08-03 11:49:12 +02:00
|
|
|
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have creature stats");
|
|
|
|
}
|
|
|
|
|
2010-08-19 12:49:13 +02:00
|
|
|
MWMechanics::NpcStats& Class::getNpcStats (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have NPC stats");
|
|
|
|
}
|
|
|
|
|
2010-08-03 14:14:04 +02:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2013-07-25 08:15:42 -07:00
|
|
|
float Class::getEvasion(const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
MWMechanics::CreatureStats &crstats = getCreatureStats(ptr);
|
|
|
|
const MWMechanics::MagicEffects &mageffects = crstats.getMagicEffects();
|
|
|
|
float evasion = (crstats.getAttribute(ESM::Attribute::Agility).getModified() / 5.0f) +
|
|
|
|
(crstats.getAttribute(ESM::Attribute::Luck).getModified() / 10.0f);
|
|
|
|
evasion *= crstats.getFatigueTerm();
|
|
|
|
evasion += mageffects.get(MWMechanics::EffectKey(ESM::MagicEffect::Sanctuary)).mMagnitude;
|
|
|
|
|
|
|
|
return evasion;
|
|
|
|
}
|
|
|
|
|
2013-07-25 00:30:01 -07:00
|
|
|
void Class::hit(const Ptr& ptr, int type) const
|
2013-07-24 02:51:42 -07:00
|
|
|
{
|
2013-07-25 00:30:01 -07:00
|
|
|
throw std::runtime_error("class cannot hit");
|
2013-07-24 02:51:42 -07:00
|
|
|
}
|
|
|
|
|
2013-07-26 03:21:54 -07:00
|
|
|
void Class::onHit(const Ptr& ptr, float damage, const Ptr& object, const Ptr& attacker, bool successful) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("class cannot be hit");
|
|
|
|
}
|
|
|
|
|
2013-07-24 02:51:42 -07:00
|
|
|
void Class::setActorHealth(const Ptr& ptr, float health, const Ptr& attacker) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("class does not have actor health");
|
|
|
|
}
|
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
boost::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const
|
2010-08-03 18:20:15 +02:00
|
|
|
{
|
|
|
|
return boost::shared_ptr<Action> (new NullAction);
|
|
|
|
}
|
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
boost::shared_ptr<Action> Class::use (const Ptr& ptr) const
|
2010-08-03 18:20:15 +02:00
|
|
|
{
|
|
|
|
return boost::shared_ptr<Action> (new NullAction);
|
|
|
|
}
|
|
|
|
|
2012-01-28 11:45:55 +01:00
|
|
|
ContainerStore& Class::getContainerStore (const Ptr& ptr) const
|
2010-08-04 14:37:23 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have a container store");
|
2010-08-06 22:20:20 +02:00
|
|
|
}
|
|
|
|
|
2012-03-10 12:49:54 +01:00
|
|
|
InventoryStore& Class::getInventoryStore (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have an inventory store");
|
|
|
|
}
|
|
|
|
|
2010-08-30 11:56:55 +02:00
|
|
|
void Class::lock (const Ptr& ptr, int lockLevel) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support locking");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Class::unlock (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support unlocking");
|
|
|
|
}
|
|
|
|
|
2010-08-05 15:40:03 +02:00
|
|
|
std::string Class::getScript (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return "";
|
2010-08-04 14:37:23 +02:00
|
|
|
}
|
|
|
|
|
2011-01-18 10:45:29 +01:00
|
|
|
void Class::setForceStance (const Ptr& ptr, Stance stance, bool force) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("stance not supported by class");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Class::setStance (const Ptr& ptr, Stance stance, bool set) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("stance not supported by class");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Class::getStance (const Ptr& ptr, Stance stance, bool ignoreForce) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
float Class::getSpeed (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-24 03:30:33 -08:00
|
|
|
float Class::getJump (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-29 10:19:09 +02:00
|
|
|
float Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
|
2013-03-16 19:00:14 +01:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support enchanting");
|
|
|
|
}
|
|
|
|
|
2011-02-03 11:37:17 +01:00
|
|
|
MWMechanics::Movement& Class::getMovementSettings (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("movement settings not supported by class");
|
|
|
|
}
|
|
|
|
|
|
|
|
Ogre::Vector3 Class::getMovementVector (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return Ogre::Vector3 (0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2013-03-31 01:29:24 -07:00
|
|
|
Ogre::Vector3 Class::getRotationVector (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return Ogre::Vector3 (0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2012-03-13 14:12:07 +01:00
|
|
|
std::pair<std::vector<int>, bool> Class::getEquipmentSlots (const Ptr& ptr) const
|
2012-03-13 13:45:50 +01:00
|
|
|
{
|
|
|
|
return std::make_pair (std::vector<int>(), false);
|
|
|
|
}
|
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
int Class::getEquipmentSkill (const Ptr& ptr) const
|
2012-03-13 14:12:07 +01:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-04-07 19:53:49 +02:00
|
|
|
int Class::getValue (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::logic_error ("value not supported by this class");
|
|
|
|
}
|
|
|
|
|
2012-05-15 22:31:52 +02:00
|
|
|
float Class::getCapacity (const MWWorld::Ptr& ptr) const
|
2012-05-15 21:17:00 +02:00
|
|
|
{
|
2012-05-15 21:34:00 +02:00
|
|
|
throw std::runtime_error ("capacity not supported by this class");
|
|
|
|
}
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
float Class::getWeight(const Ptr &ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("weight not supported by this class");
|
|
|
|
}
|
|
|
|
|
2012-05-15 21:34:00 +02:00
|
|
|
float Class::getEncumbrance (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("encumbrance not supported by class");
|
2012-05-15 21:17:00 +02:00
|
|
|
}
|
|
|
|
|
2012-10-27 13:33:54 +02:00
|
|
|
bool Class::isEssential (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-17 22:29:12 +01:00
|
|
|
bool Class::hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const
|
2012-11-15 20:00:27 +01:00
|
|
|
{
|
2013-03-17 03:17:05 +01:00
|
|
|
return true;
|
2012-11-15 20:00:27 +01:00
|
|
|
}
|
|
|
|
|
2013-03-17 22:29:12 +01:00
|
|
|
float Class::getArmorRating (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Class does not support armor rating");
|
|
|
|
}
|
|
|
|
|
2010-08-03 11:14:57 +02:00
|
|
|
const Class& Class::get (const std::string& key)
|
|
|
|
{
|
2013-03-31 10:16:02 +02:00
|
|
|
if (key.empty())
|
|
|
|
throw std::logic_error ("Class::get(): attempting to get an empty key");
|
|
|
|
|
2010-08-03 11:14:57 +02:00
|
|
|
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
|
|
|
|
|
|
|
if (iter==sClasses.end())
|
2013-03-31 10:16:02 +02:00
|
|
|
throw std::logic_error ("Class::get(): unknown class key: " + key);
|
2010-08-03 11:14:57 +02:00
|
|
|
|
|
|
|
return *iter->second;
|
|
|
|
}
|
|
|
|
|
2010-08-03 11:49:12 +02:00
|
|
|
const Class& Class::get (const Ptr& ptr)
|
|
|
|
{
|
|
|
|
return get (ptr.getTypeName());
|
|
|
|
}
|
|
|
|
|
2013-05-16 18:50:26 +02:00
|
|
|
bool Class::isPersistent(const Ptr &ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support persistence");
|
|
|
|
}
|
|
|
|
|
2010-08-03 11:14:57 +02:00
|
|
|
void Class::registerClass (const std::string& key, boost::shared_ptr<Class> instance)
|
|
|
|
{
|
|
|
|
sClasses.insert (std::make_pair (key, instance));
|
|
|
|
}
|
2012-03-13 18:05:38 +02:00
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
std::string Class::getUpSoundId (const Ptr& ptr) const
|
2012-03-13 18:05:38 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have an up sound");
|
|
|
|
}
|
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
std::string Class::getDownSoundId (const Ptr& ptr) const
|
2012-03-13 18:05:38 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have an down sound");
|
|
|
|
}
|
2012-04-15 20:56:45 +02:00
|
|
|
|
2013-07-17 23:58:21 -07:00
|
|
|
std::string Class::getSoundIdFromSndGen(const Ptr &ptr, const std::string &type) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("class does not support soundgen look up");
|
|
|
|
}
|
2012-05-11 10:40:40 +02:00
|
|
|
|
2012-04-15 20:56:45 +02:00
|
|
|
std::string Class::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have any inventory icon");
|
|
|
|
}
|
2012-05-11 10:40:40 +02:00
|
|
|
|
2012-04-24 02:02:03 +02:00
|
|
|
MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr) const
|
2012-04-16 19:30:52 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have a tool tip");
|
|
|
|
}
|
|
|
|
|
2012-04-16 19:34:46 +02:00
|
|
|
bool Class::hasToolTip (const Ptr& ptr) const
|
2012-04-16 19:30:52 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-12 16:17:03 +02:00
|
|
|
|
|
|
|
std::string Class::getEnchantment (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2012-05-21 10:58:04 +02:00
|
|
|
|
2012-05-25 18:23:06 +02:00
|
|
|
void Class::adjustScale(const MWWorld::Ptr& ptr,float& scale) const
|
2012-05-21 10:58:04 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-25 18:23:06 +02:00
|
|
|
void Class::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
|
|
|
|
{
|
|
|
|
}
|
2012-07-24 18:52:08 +04:00
|
|
|
|
2012-07-24 20:22:11 +04:00
|
|
|
std::string Class::getModel(const MWWorld::Ptr &ptr) const
|
2012-07-24 18:52:08 +04:00
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2012-07-25 17:18:17 +04:00
|
|
|
|
2013-03-31 23:18:23 +02:00
|
|
|
void Class::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
2013-03-28 17:41:00 +01:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class can't be enchanted");
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:23 +02:00
|
|
|
std::pair<int, std::string> Class::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
2013-04-05 15:42:05 +02:00
|
|
|
{
|
2013-04-15 02:56:23 +02:00
|
|
|
return std::make_pair (1, "");
|
2013-04-05 15:42:05 +02:00
|
|
|
}
|
|
|
|
|
2013-04-03 23:55:57 +02:00
|
|
|
void Class::adjustPosition(const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-07-25 17:18:17 +04:00
|
|
|
MWWorld::Ptr
|
2012-07-26 16:14:11 +04:00
|
|
|
Class::copyToCellImpl(const Ptr &ptr, CellStore &cell) const
|
2012-07-25 17:18:17 +04:00
|
|
|
{
|
|
|
|
throw std::runtime_error("unable to move class to cell");
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::Ptr
|
2012-07-26 16:14:11 +04:00
|
|
|
Class::copyToCell(const Ptr &ptr, CellStore &cell) const
|
2012-07-25 17:18:17 +04:00
|
|
|
{
|
2012-07-26 16:14:11 +04:00
|
|
|
Ptr newPtr = copyToCellImpl(ptr, cell);
|
2012-07-25 17:18:17 +04:00
|
|
|
|
|
|
|
return newPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::Ptr
|
2012-07-26 16:14:11 +04:00
|
|
|
Class::copyToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const
|
2012-07-25 17:18:17 +04:00
|
|
|
{
|
2012-07-26 16:14:11 +04:00
|
|
|
Ptr newPtr = copyToCell(ptr, cell);
|
2012-07-25 17:18:17 +04:00
|
|
|
newPtr.getRefData().getPosition() = pos;
|
|
|
|
|
|
|
|
return newPtr;
|
|
|
|
}
|
2010-08-03 11:14:57 +02:00
|
|
|
}
|