@ -77,10 +77,8 @@ namespace MWMechanics
void CastSpell : : inflict ( const MWWorld : : Ptr & target , const MWWorld : : Ptr & caster ,
const ESM : : EffectList & effects , ESM : : RangeType range , bool reflected , bool exploded )
{
if ( target . isEmpty ( ) )
return ;
if ( target . getClass ( ) . isActor ( ) )
const bool targetIsActor = ! target . isEmpty ( ) & & target . getClass ( ) . isActor ( ) ;
if ( targetIsActor )
{
// Early-out for characters that have departed.
const auto & stats = target . getClass ( ) . getCreatureStats ( target ) ;
@ -102,7 +100,7 @@ namespace MWMechanics
return ;
const ESM : : Spell * spell = MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : Spell > ( ) . search ( mId ) ;
if ( spell & & target . getClass ( ) . isActor ( ) & & ( spell - > mData . mType = = ESM : : Spell : : ST_Disease | | spell - > mData . mType = = ESM : : Spell : : ST_Blight ) )
if ( spell & & target IsActor & & ( spell - > mData . mType = = ESM : : Spell : : ST_Disease | | spell - > mData . mType = = ESM : : Spell : : ST_Blight ) )
{
int requiredResistance = ( spell - > mData . mType = = ESM : : Spell : : ST_Disease ) ?
ESM : : MagicEffect : : ResistCommonDisease
@ -125,13 +123,13 @@ namespace MWMechanics
// This is required for Weakness effects in a spell to apply to any subsequent effects in the spell.
// Otherwise, they'd only apply after the whole spell was added.
MagicEffects targetEffects ;
if ( target . getClass ( ) . isActor ( ) )
if ( target IsActor )
targetEffects + = target . getClass ( ) . getCreatureStats ( target ) . getMagicEffects ( ) ;
bool castByPlayer = ( ! caster . isEmpty ( ) & & caster = = getPlayer ( ) ) ;
ActiveSpells targetSpells ;
if ( target . getClass ( ) . isActor ( ) )
if ( target IsActor )
targetSpells = target . getClass ( ) . getCreatureStats ( target ) . getActiveSpells ( ) ;
bool canCastAnEffect = false ; // For bound equipment.If this remains false
@ -143,7 +141,7 @@ namespace MWMechanics
int currentEffectIndex = 0 ;
for ( std : : vector < ESM : : ENAMstruct > : : const_iterator effectIt ( effects . mList . begin ( ) ) ;
effectIt ! = effects . mList . end ( ) ; + + effectIt , + + currentEffectIndex )
! target . isEmpty ( ) & & effectIt ! = effects . mList . end ( ) ; + + effectIt , + + currentEffectIndex )
{
if ( effectIt - > mRange ! = range )
continue ;
@ -329,7 +327,7 @@ namespace MWMechanics
}
// Re-casting a summon effect will remove the creature from previous castings of that effect.
if ( isSummoningEffect ( effectIt - > mEffectID ) & & target . getClass ( ) . isActor ( ) )
if ( isSummoningEffect ( effectIt - > mEffectID ) & & target IsActor )
{
CreatureStats & targetStats = target . getClass ( ) . getCreatureStats ( target ) ;
ESM : : SummonKey key ( effectIt - > mEffectID , mId , currentEffectIndex ) ;
@ -385,16 +383,19 @@ namespace MWMechanics
if ( ! exploded )
MWBase : : Environment : : get ( ) . getWorld ( ) - > explodeSpell ( mHitPosition , effects , caster , target , range , mId , mSourceName , mFromProjectile ) ;
if ( ! reflectedEffects . mList . empty ( ) )
inflict ( caster , target , reflectedEffects , range , true , exploded ) ;
if ( ! appliedLastingEffects . empty ( ) )
if ( ! target . isEmpty ( ) )
{
int casterActorId = - 1 ;
if ( ! caster . isEmpty ( ) & & caster . getClass ( ) . isActor ( ) )
casterActorId = caster . getClass ( ) . getCreatureStats ( caster ) . getActorId ( ) ;
target . getClass ( ) . getCreatureStats ( target ) . getActiveSpells ( ) . addSpell ( mId , mStack , appliedLastingEffects ,
mSourceName , casterActorId ) ;
if ( ! reflectedEffects . mList . empty ( ) )
inflict ( caster , target , reflectedEffects , range , true , exploded ) ;
if ( ! appliedLastingEffects . empty ( ) )
{
int casterActorId = - 1 ;
if ( ! caster . isEmpty ( ) & & caster . getClass ( ) . isActor ( ) )
casterActorId = caster . getClass ( ) . getCreatureStats ( caster ) . getActorId ( ) ;
target . getClass ( ) . getCreatureStats ( target ) . getActiveSpells ( ) . addSpell ( mId , mStack , appliedLastingEffects ,
mSourceName , casterActorId ) ;
}
}
}