From 8ce225b1cc1fd17476f05c7d28d9e63b4752475c Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 2 Jul 2018 00:42:32 +0300 Subject: [PATCH] [Client] Use the casters of damage-dealing spells as death reasons --- apps/openmw/mwmechanics/spellcasting.cpp | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index c985cfffc..ffb9c34ce 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -20,6 +20,7 @@ #include "../mwmp/PlayerList.hpp" #include "../mwmp/LocalPlayer.hpp" #include "../mwmp/ObjectList.hpp" +#include "../mwmp/CellController.hpp" #include "../mwmp/MechanicsHelper.hpp" /* End of tes3mp addition @@ -532,6 +533,30 @@ namespace MWMechanics effectTick(target.getClass().getCreatureStats(target), target, EffectKey(*effectIt), magnitude); bool isDead = target.getClass().getCreatureStats(target).isDead(); + /* + Start of tes3mp addition + + If the victim was a LocalPlayer or LocalActor who died, record their attacker as the deathReason + */ + if (!wasDead && isDead) + { + bool isSuicide = target == caster || caster.isEmpty(); + + if (target == MWMechanics::getPlayer()) + { + mwmp::Main::get().getLocalPlayer()->deathReason = isSuicide ? + "suicide" : caster.getClass().getName(caster); + } + else if (mwmp::Main::get().getCellController()->isLocalActor(target)) + { + mwmp::Main::get().getCellController()->getLocalActor(target)->deathReason = isSuicide ? + "suicide" : caster.getClass().getName(caster); + } + } + /* + End of tes3mp addition + */ + if (!wasDead && isDead) MWBase::Environment::get().getMechanicsManager()->actorKilled(target, caster); }