diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index b30d052d64..2faa6332ec 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -362,6 +362,11 @@ namespace MWMechanics mLastHitAttemptObject = objectid; } + void CreatureStats::clearLastHitAttemptObject() + { + mLastHitAttemptObject.clear(); + } + const std::string &CreatureStats::getLastHitAttemptObject() const { return mLastHitAttemptObject; diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index d233d87cd0..8908ed838c 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -258,6 +258,7 @@ namespace MWMechanics void clearLastHitObject(); const std::string &getLastHitObject() const; void setLastHitAttemptObject(const std::string &objectid); + void clearLastHitAttemptObject(); const std::string &getLastHitAttemptObject() const; void setHitAttemptActorId(const int actorId); int getHitAttemptActorId() const; diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 2b557fc9b6..678e195808 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -997,9 +997,10 @@ namespace MWScript runtime.pop(); MWMechanics::CreatureStats &stats = ptr.getClass().getCreatureStats(ptr); - runtime.push(::Misc::StringUtils::ciEqual(objectID, stats.getLastHitAttemptObject())); - - stats.setLastHitAttemptObject(std::string()); + bool hit = ::Misc::StringUtils::ciEqual(objectID, stats.getLastHitAttemptObject()); + runtime.push(hit); + if(hit) + stats.clearLastHitAttemptObject(); } };