forked from mirror/openmw-tes3mp
Issue #68: check for essential actors
This commit is contained in:
parent
453f347ee8
commit
ed3641b214
7 changed files with 36 additions and 0 deletions
|
@ -149,6 +149,14 @@ namespace MWClass
|
|||
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()
|
||||
{
|
||||
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
|
||||
/// 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();
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
|
|
@ -315,7 +315,15 @@ namespace MWClass
|
|||
|
||||
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()
|
||||
{
|
||||
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 bool isEssential (const MWWorld::Ptr& ptr) const;
|
||||
///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable)
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
|
|
@ -238,6 +238,10 @@ namespace MWMechanics
|
|||
|
||||
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++);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -157,6 +157,11 @@ namespace MWWorld
|
|||
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)
|
||||
{
|
||||
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)
|
||||
|
||||
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);
|
||||
///< If there is no class for this \a key, an exception is thrown.
|
||||
|
||||
|
|
Loading…
Reference in a new issue