mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-15 18:39:51 +00:00
Issue #68: check for essential actors
This commit is contained in:
parent
453f347ee8
commit
ed3641b214
@ -149,6 +149,14 @@ namespace MWClass
|
|||||||
return ref->base->mScript;
|
return ref->base->mScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Creature::isEssential (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Creature> *ref =
|
||||||
|
ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
|
return ref->base->mFlags & ESM::Creature::Essential;
|
||||||
|
}
|
||||||
|
|
||||||
void Creature::registerSelf()
|
void Creature::registerSelf()
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Class> instance (new Creature);
|
boost::shared_ptr<Class> instance (new Creature);
|
||||||
|
@ -56,6 +56,9 @@ namespace MWClass
|
|||||||
///< Returns total weight of objects inside this object (including modifications from magic
|
///< Returns total weight of objects inside this object (including modifications from magic
|
||||||
/// effects). Throws an exception, if the object can't hold other objects.
|
/// effects). Throws an exception, if the object can't hold other objects.
|
||||||
|
|
||||||
|
virtual bool isEssential (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable)
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
|
@ -315,7 +315,15 @@ namespace MWClass
|
|||||||
|
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Npc::isEssential (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
|
ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
|
return ref->base->mFlags & ESM::NPC::Essential;
|
||||||
|
}
|
||||||
|
|
||||||
void Npc::registerSelf()
|
void Npc::registerSelf()
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Class> instance (new Npc);
|
boost::shared_ptr<Class> instance (new Npc);
|
||||||
|
@ -90,6 +90,9 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
|
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
|
||||||
|
|
||||||
|
virtual bool isEssential (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable)
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
|
@ -238,6 +238,10 @@ namespace MWMechanics
|
|||||||
|
|
||||||
MWBase::Environment::get().getWorld()->playAnimationGroup (*iter, "death1", 0);
|
MWBase::Environment::get().getWorld()->playAnimationGroup (*iter, "death1", 0);
|
||||||
|
|
||||||
|
if (MWWorld::Class::get (*iter).isEssential (*iter))
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox (
|
||||||
|
"#{sKilledEssential}", std::vector<std::string>());
|
||||||
|
|
||||||
mActors.erase (iter++);
|
mActors.erase (iter++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -157,6 +157,11 @@ namespace MWWorld
|
|||||||
throw std::runtime_error ("encumbrance not supported by class");
|
throw std::runtime_error ("encumbrance not supported by class");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Class::isEssential (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const Class& Class::get (const std::string& key)
|
const Class& Class::get (const std::string& key)
|
||||||
{
|
{
|
||||||
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||||
|
@ -186,6 +186,11 @@ namespace MWWorld
|
|||||||
///
|
///
|
||||||
/// (default implementations: throws an exception)
|
/// (default implementations: throws an exception)
|
||||||
|
|
||||||
|
virtual bool isEssential (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable)
|
||||||
|
///
|
||||||
|
/// (default implementation: return false)
|
||||||
|
|
||||||
static const Class& get (const std::string& key);
|
static const Class& get (const std::string& key);
|
||||||
///< If there is no class for this \a key, an exception is thrown.
|
///< If there is no class for this \a key, an exception is thrown.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user