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); }