From 5379e607cbd6d800d5d2cedc6356e1f5a5d3a687 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 26 Jul 2013 07:04:36 -0700 Subject: [PATCH] Handle the OnPCHitMe script variable --- apps/openmw/mwclass/creature.cpp | 10 +++++++++- apps/openmw/mwclass/npc.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 0f719b332..36d1ae4f4 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -167,7 +167,15 @@ namespace MWClass return; } - // TODO: Handle HitOnMe script function and OnPCHitMe script variable. + // TODO: Handle HitOnMe script function + + if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player") + { + 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); + } float health = getCreatureStats(ptr).getHealth().getCurrent() - damage; setActorHealth(ptr, health, attacker); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index bc6d2b056..12144bedb 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -392,7 +392,15 @@ namespace MWClass return; } - // TODO: Handle HitOnMe script function and OnPCHitMe script variable. + // TODO: Handle HitOnMe script function + + if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player") + { + 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) {