2010-08-03 11:14:57 +02:00
|
|
|
#include "class.hpp"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
2012-07-25 17:18:17 +04:00
|
|
|
#include <components/esm/defs.hpp>
|
|
|
|
|
2013-08-08 22:34:53 -07:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2013-08-11 00:35:19 -07:00
|
|
|
#include "../mwbase/world.hpp"
|
2014-12-19 11:26:54 +01:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2013-08-08 22:34:53 -07:00
|
|
|
|
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"
|
2013-08-08 22:34:53 -07:00
|
|
|
#include "failedaction.hpp"
|
|
|
|
#include "actiontake.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-08-08 22:34:53 -07:00
|
|
|
|
2013-07-25 08:15:42 -07:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
2013-08-08 22:34:53 -07:00
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
2013-07-25 08:15:42 -07:00
|
|
|
#include "../mwmechanics/magiceffects.hpp"
|
2012-07-03 13:15:20 +02:00
|
|
|
|
2010-08-03 11:14:57 +02:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
2017-05-05 21:21:11 +02:00
|
|
|
std::map<std::string, std::shared_ptr<Class> > Class::sClasses;
|
2010-08-03 11:14:57 +02:00
|
|
|
|
|
|
|
Class::Class() {}
|
|
|
|
|
|
|
|
Class::~Class() {}
|
|
|
|
|
2015-01-12 11:29:56 +01:00
|
|
|
void Class::insertObjectRendering (const Ptr& ptr, const std::string& mesh, 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
|
|
|
|
2015-05-10 01:09:00 +02:00
|
|
|
void Class::insertObject(const Ptr& ptr, const std::string& mesh, MWPhysics::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;
|
|
|
|
}
|
|
|
|
|
2014-09-25 12:25:57 +02:00
|
|
|
void Class::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor) const
|
2012-07-13 09:03:17 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not represent an actor");
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:58:23 +01:00
|
|
|
bool Class::canSell (const MWWorld::ConstPtr& item, int npcServices) const
|
2013-04-07 21:38:53 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:44:35 +01:00
|
|
|
int Class::getServices(const ConstPtr &actor) const
|
2013-05-11 18:38:27 +02:00
|
|
|
{
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:06:31 +01:00
|
|
|
bool Class::hasItemHealth (const ConstPtr& ptr) const
|
2010-08-03 14:14:04 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:27:06 +01:00
|
|
|
int Class::getItemHealth(const ConstPtr &ptr) const
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
|
|
|
if (ptr.getCellRef().getCharge() == -1)
|
|
|
|
return getItemMaxHealth(ptr);
|
|
|
|
else
|
|
|
|
return ptr.getCellRef().getCharge();
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:45:31 +03:00
|
|
|
float Class::getItemNormalizedHealth (const ConstPtr& ptr) const
|
|
|
|
{
|
|
|
|
if (getItemMaxHealth(ptr) == 0)
|
|
|
|
{
|
|
|
|
return 0.f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return getItemHealth(ptr) / static_cast<float>(getItemMaxHealth(ptr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:27:06 +01:00
|
|
|
int Class::getItemMaxHealth (const ConstPtr& ptr) const
|
2010-08-03 14:14:04 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have item health");
|
|
|
|
}
|
|
|
|
|
2015-06-26 05:15:07 +02:00
|
|
|
void Class::hit(const Ptr& ptr, float attackStrength, 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
|
|
|
}
|
|
|
|
|
2014-01-21 01:01:21 +01:00
|
|
|
void Class::block(const Ptr &ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("class cannot block");
|
|
|
|
}
|
|
|
|
|
2016-09-15 16:47:50 +02:00
|
|
|
bool Class::canBeActivated(const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return !getName(ptr).empty();
|
|
|
|
}
|
|
|
|
|
2016-09-13 00:49:31 +09:00
|
|
|
void Class::onHit(const Ptr& ptr, float damage, bool ishealth, const Ptr& object, const Ptr& attacker, const osg::Vec3f& hitPosition, bool successful) const
|
2013-07-26 03:21:54 -07:00
|
|
|
{
|
|
|
|
throw std::runtime_error("class cannot be hit");
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:21:11 +02:00
|
|
|
std::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const
|
2010-08-03 18:20:15 +02:00
|
|
|
{
|
2017-05-05 21:21:11 +02:00
|
|
|
return std::shared_ptr<Action> (new NullAction);
|
2010-08-03 18:20:15 +02:00
|
|
|
}
|
|
|
|
|
2018-07-09 19:31:40 +04:00
|
|
|
std::shared_ptr<Action> Class::use (const Ptr& ptr, bool force) const
|
2010-08-03 18:20:15 +02:00
|
|
|
{
|
2017-05-05 21:21:11 +02:00
|
|
|
return std::shared_ptr<Action> (new NullAction);
|
2010-08-03 18:20:15 +02:00
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2014-01-19 11:42:58 +01:00
|
|
|
bool Class::hasInventoryStore(const Ptr &ptr) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:50:32 +01:00
|
|
|
bool Class::canLock(const ConstPtr &ptr) const
|
2015-08-04 17:33:34 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-15 15:23:42 -04:00
|
|
|
void Class::setRemainingUsageTime (const Ptr& ptr, float duration) const
|
|
|
|
{
|
2013-10-16 15:14:35 -04:00
|
|
|
throw std::runtime_error ("class does not support time-based uses");
|
2013-10-15 15:23:42 -04:00
|
|
|
}
|
|
|
|
|
2015-12-18 15:27:06 +01:00
|
|
|
float Class::getRemainingUsageTime (const ConstPtr& ptr) const
|
2013-10-15 15:23:42 -04:00
|
|
|
{
|
2013-12-16 13:31:03 +01:00
|
|
|
return -1;
|
2013-10-15 15:23:42 -04:00
|
|
|
}
|
|
|
|
|
2015-12-18 00:12:03 +01:00
|
|
|
std::string Class::getScript (const ConstPtr& ptr) const
|
2010-08-05 15:40:03 +02:00
|
|
|
{
|
|
|
|
return "";
|
2010-08-04 14:37:23 +02:00
|
|
|
}
|
|
|
|
|
2011-01-18 10:45:29 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:48:19 +01:00
|
|
|
int Class::getEnchantmentPoints (const MWWorld::ConstPtr& 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");
|
|
|
|
}
|
|
|
|
|
2015-06-03 19:41:19 +02:00
|
|
|
osg::Vec3f Class::getRotationVector (const Ptr& ptr) const
|
2013-03-31 01:29:24 -07:00
|
|
|
{
|
2015-06-03 19:41:19 +02:00
|
|
|
return osg::Vec3f (0, 0, 0);
|
2013-03-31 01:29:24 -07:00
|
|
|
}
|
|
|
|
|
2015-12-18 16:06:31 +01:00
|
|
|
std::pair<std::vector<int>, bool> Class::getEquipmentSlots (const ConstPtr& ptr) const
|
2012-03-13 13:45:50 +01:00
|
|
|
{
|
|
|
|
return std::make_pair (std::vector<int>(), false);
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:27:06 +01:00
|
|
|
int Class::getEquipmentSkill (const ConstPtr& ptr) const
|
2012-03-13 14:12:07 +01:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:27:06 +01:00
|
|
|
int Class::getValue (const ConstPtr& ptr) const
|
2012-04-07 19:53:49 +02:00
|
|
|
{
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:00:50 +01:00
|
|
|
float Class::getWeight(const ConstPtr &ptr) const
|
2013-05-11 18:38:27 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-12-18 16:39:35 +01:00
|
|
|
bool Class::isEssential (const MWWorld::ConstPtr& ptr) const
|
2012-10-27 13:33:54 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
|
2017-05-05 21:21:11 +02:00
|
|
|
std::map<std::string, std::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
2010-08-03 11:14:57 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:41:37 +01:00
|
|
|
bool Class::isPersistent(const ConstPtr &ptr) const
|
2013-05-16 18:50:26 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support persistence");
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:21:11 +02:00
|
|
|
void Class::registerClass(const std::string& key, std::shared_ptr<Class> instance)
|
2010-08-03 11:14:57 +02:00
|
|
|
{
|
2013-08-16 04:18:48 -07:00
|
|
|
instance->mTypeName = key;
|
|
|
|
sClasses.insert(std::make_pair(key, instance));
|
2010-08-03 11:14:57 +02:00
|
|
|
}
|
2012-03-13 18:05:38 +02:00
|
|
|
|
2015-12-18 16:09:08 +01:00
|
|
|
std::string Class::getUpSoundId (const ConstPtr& ptr) const
|
2012-03-13 18:05:38 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have an up sound");
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:09:08 +01:00
|
|
|
std::string Class::getDownSoundId (const ConstPtr& 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
|
|
|
|
2015-12-18 15:53:47 +01:00
|
|
|
std::string Class::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
2012-04-15 20:56:45 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have any inventory icon");
|
|
|
|
}
|
2012-05-11 10:40:40 +02:00
|
|
|
|
2015-12-19 16:29:07 +01:00
|
|
|
MWGui::ToolTipInfo Class::getToolTipInfo (const ConstPtr& ptr, int count) const
|
2012-04-16 19:30:52 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have a tool tip");
|
|
|
|
}
|
|
|
|
|
2016-09-24 18:01:31 +02:00
|
|
|
bool Class::showsInInventory (const ConstPtr& ptr) const
|
|
|
|
{
|
|
|
|
// NOTE: Don't show WerewolfRobe objects in the inventory, or allow them to be taken.
|
|
|
|
// Vanilla likely uses a hack like this since there's no other way to prevent it from
|
|
|
|
// being shown or taken.
|
|
|
|
return (ptr.getCellRef().getRefId() != "werewolfrobe");
|
|
|
|
}
|
|
|
|
|
2015-12-19 16:13:00 +01:00
|
|
|
bool Class::hasToolTip (const ConstPtr& ptr) const
|
2012-04-16 19:30:52 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-12 16:17:03 +02:00
|
|
|
|
2015-12-18 15:56:45 +01:00
|
|
|
std::string Class::getEnchantment (const ConstPtr& ptr) const
|
2012-05-12 16:17:03 +02:00
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2012-05-21 10:58:04 +02:00
|
|
|
|
2015-12-18 16:46:02 +01:00
|
|
|
void Class::adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const
|
2012-05-21 10:58:04 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:51:05 +01:00
|
|
|
std::string Class::getModel(const MWWorld::ConstPtr &ptr) const
|
2012-07-24 18:52:08 +04:00
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2012-07-25 17:18:17 +04:00
|
|
|
|
2017-02-20 19:04:02 +01:00
|
|
|
bool Class::useAnim() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-08 20:52:32 +01:00
|
|
|
void Class::getModelsToPreload(const Ptr &ptr, std::vector<std::string> &models) const
|
|
|
|
{
|
|
|
|
std::string model = getModel(ptr);
|
|
|
|
if (!model.empty())
|
|
|
|
models.push_back(model);
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:43:11 +01:00
|
|
|
std::string Class::applyEnchantment(const MWWorld::ConstPtr &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");
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:06:31 +01:00
|
|
|
std::pair<int, std::string> Class::canBeEquipped(const MWWorld::ConstPtr &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
|
|
|
}
|
|
|
|
|
2014-07-31 04:24:45 +02:00
|
|
|
void Class::adjustPosition(const MWWorld::Ptr& ptr, bool force) const
|
2013-04-03 23:55:57 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:21:11 +02:00
|
|
|
std::shared_ptr<Action> Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const
|
2013-08-08 22:34:53 -07:00
|
|
|
{
|
|
|
|
if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
2017-05-05 21:21:11 +02:00
|
|
|
return std::shared_ptr<Action>(new NullAction());
|
2013-08-08 22:34:53 -07:00
|
|
|
|
2014-05-22 20:37:22 +02:00
|
|
|
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
2013-08-08 22:34:53 -07:00
|
|
|
{
|
2013-08-11 00:35:19 -07:00
|
|
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfItem");
|
|
|
|
|
2017-05-05 21:21:11 +02:00
|
|
|
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
|
2013-08-11 00:35:19 -07:00
|
|
|
if(sound) action->setSound(sound->mId);
|
|
|
|
|
2013-08-08 22:34:53 -07:00
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:21:11 +02:00
|
|
|
std::shared_ptr<MWWorld::Action> action(new ActionTake(ptr));
|
2013-08-08 22:34:53 -07:00
|
|
|
action->setSound(getUpSoundId(ptr));
|
|
|
|
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2012-07-25 17:18:17 +04:00
|
|
|
MWWorld::Ptr
|
2015-12-18 16:24:24 +01:00
|
|
|
Class::copyToCellImpl(const ConstPtr &ptr, CellStore &cell) const
|
2012-07-25 17:18:17 +04:00
|
|
|
{
|
2015-12-18 16:24:24 +01:00
|
|
|
throw std::runtime_error("unable to copy class to cell");
|
2012-07-25 17:18:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::Ptr
|
2015-12-19 16:47:55 +01:00
|
|
|
Class::copyToCell(const ConstPtr &ptr, CellStore &cell, int count) const
|
2012-07-25 17:18:17 +04:00
|
|
|
{
|
2012-07-26 16:14:11 +04:00
|
|
|
Ptr newPtr = copyToCellImpl(ptr, cell);
|
2014-08-30 18:25:13 +02:00
|
|
|
newPtr.getCellRef().unsetRefNum(); // This RefNum is only valid within the original cell of the reference
|
2015-12-19 16:47:55 +01:00
|
|
|
newPtr.getRefData().setCount(count);
|
2012-07-25 17:18:17 +04:00
|
|
|
return newPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::Ptr
|
2015-12-19 16:47:55 +01:00
|
|
|
Class::copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos, int count) const
|
2012-07-25 17:18:17 +04:00
|
|
|
{
|
2015-12-19 16:47:55 +01:00
|
|
|
Ptr newPtr = copyToCell(ptr, cell, count);
|
2014-06-14 17:56:41 +02:00
|
|
|
newPtr.getRefData().setPosition(pos);
|
2012-07-25 17:18:17 +04:00
|
|
|
|
|
|
|
return newPtr;
|
|
|
|
}
|
2014-01-05 15:38:12 +01:00
|
|
|
|
2015-12-18 16:15:40 +01:00
|
|
|
bool Class::isBipedal(const ConstPtr &ptr) const
|
2014-03-16 08:09:14 +11:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:16:45 +01:00
|
|
|
bool Class::canFly(const ConstPtr &ptr) const
|
2014-03-16 08:09:14 +11:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:16:45 +01:00
|
|
|
bool Class::canSwim(const ConstPtr &ptr) const
|
2014-03-16 08:09:14 +11:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:16:45 +01:00
|
|
|
bool Class::canWalk(const ConstPtr &ptr) const
|
2014-01-05 15:38:12 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-09 21:40:53 +13:00
|
|
|
bool Class::isPureWaterCreature(const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
2016-11-16 20:15:25 +01:00
|
|
|
return canSwim(ptr)
|
|
|
|
&& !isBipedal(ptr)
|
|
|
|
&& !canFly(ptr)
|
|
|
|
&& !canWalk(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Class::isPureFlyingCreature(const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return canFly(ptr)
|
|
|
|
&& !isBipedal(ptr)
|
|
|
|
&& !canSwim(ptr)
|
|
|
|
&& !canWalk(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Class::isPureLandCreature(const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return canWalk(ptr)
|
|
|
|
&& !isBipedal(ptr)
|
|
|
|
&& !canFly(ptr)
|
|
|
|
&& !canSwim(ptr);
|
2015-01-09 21:40:53 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Class::isMobile(const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return canSwim(ptr) || canWalk(ptr) || canFly(ptr);
|
|
|
|
}
|
|
|
|
|
2014-01-15 15:50:45 +01:00
|
|
|
int Class::getSkill(const MWWorld::Ptr& ptr, int skill) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("class does not support skills");
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:38:14 +01:00
|
|
|
int Class::getBloodTexture (const MWWorld::ConstPtr& ptr) const
|
2014-01-17 10:52:44 +01:00
|
|
|
{
|
|
|
|
throw std::runtime_error("class does not support gore");
|
|
|
|
}
|
2014-01-30 11:50:13 +01:00
|
|
|
|
|
|
|
void Class::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const {}
|
|
|
|
|
2015-12-18 00:18:06 +01:00
|
|
|
void Class::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const {}
|
2014-03-28 14:21:38 -04:00
|
|
|
|
2015-12-18 16:28:20 +01:00
|
|
|
int Class::getBaseGold(const MWWorld::ConstPtr& ptr) const
|
2014-03-28 17:27:23 -04:00
|
|
|
{
|
|
|
|
throw std::runtime_error("class does not support base gold");
|
|
|
|
}
|
2014-04-01 14:15:55 -04:00
|
|
|
|
2015-12-18 16:29:30 +01:00
|
|
|
bool Class::isClass(const MWWorld::ConstPtr& ptr, const std::string &className) const
|
2014-04-01 14:15:55 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-05-15 01:58:44 +02:00
|
|
|
|
2015-12-19 15:57:37 +01:00
|
|
|
int Class::getDoorState (const MWWorld::ConstPtr &ptr) const
|
2014-05-15 01:58:44 +02:00
|
|
|
{
|
|
|
|
throw std::runtime_error("this is not a door");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Class::setDoorState (const MWWorld::Ptr &ptr, int state) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("this is not a door");
|
|
|
|
}
|
2014-10-05 15:50:01 +02:00
|
|
|
|
|
|
|
float Class::getNormalizedEncumbrance(const Ptr &ptr) const
|
|
|
|
{
|
|
|
|
float capacity = getCapacity(ptr);
|
2018-05-12 20:50:18 +03:00
|
|
|
float encumbrance = getEncumbrance(ptr);
|
|
|
|
|
|
|
|
if (encumbrance == 0)
|
|
|
|
return 0.f;
|
|
|
|
|
2014-10-05 15:50:01 +02:00
|
|
|
if (capacity == 0)
|
|
|
|
return 1.f;
|
|
|
|
|
2018-05-12 20:50:18 +03:00
|
|
|
return encumbrance / capacity;
|
2014-10-05 15:50:01 +02:00
|
|
|
}
|
2014-10-12 14:06:08 +02:00
|
|
|
|
2015-12-18 16:11:03 +01:00
|
|
|
std::string Class::getSound(const MWWorld::ConstPtr&) const
|
2014-10-12 11:40:14 +02:00
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
2014-12-14 19:35:34 +01:00
|
|
|
|
2015-12-18 16:12:35 +01:00
|
|
|
int Class::getBaseFightRating(const ConstPtr &ptr) const
|
2014-12-14 19:35:34 +01:00
|
|
|
{
|
|
|
|
throw std::runtime_error("class does not support fight rating");
|
|
|
|
}
|
2015-01-27 17:32:21 +01:00
|
|
|
|
2015-12-18 16:33:54 +01:00
|
|
|
std::string Class::getPrimaryFaction (const MWWorld::ConstPtr& ptr) const
|
2015-01-27 17:32:21 +01:00
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
2015-12-18 16:33:54 +01:00
|
|
|
int Class::getPrimaryFactionRank (const MWWorld::ConstPtr& ptr) const
|
2015-01-27 17:32:21 +01:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
2015-03-01 19:28:20 +01:00
|
|
|
|
2017-02-17 03:11:37 +01:00
|
|
|
float Class::getEffectiveArmorRating(const ConstPtr &armor, const Ptr &actor) const
|
2015-03-01 19:28:20 +01:00
|
|
|
{
|
|
|
|
throw std::runtime_error("class does not support armor ratings");
|
|
|
|
}
|
2010-08-03 11:14:57 +02:00
|
|
|
}
|