From a609dc56749831b2011f80c56cd8a0d319b89207 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 15 May 2014 02:03:42 +0200 Subject: [PATCH] Fix exception when getting hit by a trap --- apps/openmw/mwmechanics/spellcasting.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 553674dd3..3f6cc4103 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -410,11 +410,16 @@ namespace MWMechanics inflict(caster, target, reflectedEffects, range, true); if (!appliedLastingEffects.empty()) + { + int casterActorId = -1; + if (caster.getClass().isActor()) + casterActorId = caster.getClass().getCreatureStats(caster).getActorId(); target.getClass().getCreatureStats(target).getActiveSpells().addSpell(mId, mStack, appliedLastingEffects, - mSourceName, caster.getClass().getCreatureStats(caster).getActorId()); + mSourceName, casterActorId); + } // Notify the target actor they've been hit - if (anyHarmfulEffect && target.getClass().isActor() && target != caster) + if (anyHarmfulEffect && target.getClass().isActor() && target != caster && caster.getClass().isActor()) target.getClass().onHit(target, 0.f, true, MWWorld::Ptr(), caster, true); }