Handle the OnPCHitMe script variable

This commit is contained in:
Chris Robinson 2013-07-26 07:04:36 -07:00
parent f215d2cc30
commit 5379e607cb
2 changed files with 18 additions and 2 deletions

View file

@ -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<ESM::Creature>()->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);

View file

@ -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<ESM::NPC>()->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)
{