From 04010b8a1aee77a69fbd654ecaf1be2238c7a8a8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 18 Jun 2015 15:00:04 +0200 Subject: [PATCH] Set OnPcHitMe even for missed hits --- apps/openmw/mwclass/creature.cpp | 16 ++++++++-------- apps/openmw/mwclass/npc.cpp | 15 ++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index c88691515..5b5a3a0cb 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -345,6 +345,14 @@ namespace MWClass if(!object.isEmpty()) getCreatureStats(ptr).setLastHitAttemptObject(object.getClass().getId(object)); + if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) + { + const std::string &script = ptr.get()->mBase->mScript; + /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ + if(!script.empty()) + ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); + } + if(!successful) { // Missed @@ -355,14 +363,6 @@ namespace MWClass if(!object.isEmpty()) getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); - if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) - { - const std::string &script = ptr.get()->mBase->mScript; - /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ - if(!script.empty()) - ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); - } - if (damage > 0.0f && !object.isEmpty()) MWMechanics::resistNormalWeapon(ptr, attacker, object, damage); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c9de1f6ff..b9ca69c63 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -610,6 +610,14 @@ namespace MWClass if(!object.isEmpty()) getCreatureStats(ptr).setLastHitAttemptObject(object.getClass().getId(object)); + if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) + { + const std::string &script = ptr.getClass().getScript(ptr); + /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ + if(!script.empty()) + ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); + } + if(!successful) { // Missed @@ -620,13 +628,6 @@ namespace MWClass if(!object.isEmpty()) getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); - if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) - { - const std::string &script = ptr.getClass().getScript(ptr); - /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ - if(!script.empty()) - ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); - } if (damage > 0.0f && !object.isEmpty()) MWMechanics::resistNormalWeapon(ptr, attacker, object, damage);