1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

Allow activating actors without a name (Fixes #3551)

This commit is contained in:
MiroslavR 2016-09-15 16:47:50 +02:00
parent 322a0ba8bb
commit f323f231db
7 changed files with 29 additions and 18 deletions

View File

@ -83,4 +83,19 @@ namespace MWClass
bool Actor::allowTelekinesis(const MWWorld::ConstPtr &ptr) const {
return false;
}
bool Actor::isActor() const
{
return true;
}
bool Actor::canBeActivated(const MWWorld::Ptr& ptr) const
{
MWMechanics::CreatureStats &stats = getCreatureStats(ptr);
if (stats.getAiSequence().isInCombat() && !stats.isDead())
return false;
return true;
}
}

View File

@ -38,6 +38,10 @@ namespace MWClass
virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const;
///< Return whether this class of object can be activated with telekinesis
virtual bool isActor() const;
virtual bool canBeActivated(const MWWorld::Ptr& ptr) const;
// not implemented
Actor(const Actor&);
Actor& operator= (const Actor&);

View File

@ -104,11 +104,6 @@ namespace MWClass
virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const;
///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel().
virtual bool
isActor() const {
return true;
}
virtual bool isBipedal (const MWWorld::ConstPtr &ptr) const;
virtual bool canFly (const MWWorld::ConstPtr &ptr) const;
virtual bool canSwim (const MWWorld::ConstPtr &ptr) const;

View File

@ -135,10 +135,6 @@ namespace MWClass
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
virtual int getBloodTexture (const MWWorld::ConstPtr& ptr) const;
virtual bool isActor() const {
return true;
}
virtual bool isNpc() const {
return true;
}

View File

@ -98,6 +98,11 @@ namespace MWWorld
throw std::runtime_error("class cannot block");
}
bool Class::canBeActivated(const Ptr& ptr) const
{
return !getName(ptr).empty();
}
void Class::onHit(const Ptr& ptr, float damage, bool ishealth, const Ptr& object, const Ptr& attacker, const osg::Vec3f& hitPosition, bool successful) const
{
throw std::runtime_error("class cannot be hit");

View File

@ -130,6 +130,10 @@ namespace MWWorld
///< Play the appropriate sound for a blocked attack, depending on the currently equipped shield
/// (default implementation: throw an exception)
virtual bool canBeActivated(const Ptr& ptr) const;
///< \return Can the player activate this object?
/// (default implementation: true if object's user-readable name is not empty, false otherwise)
virtual boost::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor) const;
///< Generate action for activation (default implementation: return a null action).

View File

@ -220,17 +220,9 @@ namespace MWWorld
if (toActivate.isEmpty())
return;
if (toActivate.getClass().getName(toActivate) == "") // objects without name presented to user can never be activated
if (!toActivate.getClass().canBeActivated(toActivate))
return;
if (toActivate.getClass().isActor())
{
MWMechanics::CreatureStats &stats = toActivate.getClass().getCreatureStats(toActivate);
if (stats.getAiSequence().isInCombat() && !stats.isDead())
return;
}
MWBase::Environment::get().getWorld()->activate(toActivate, player);
}