diff --git a/zone/spells.cpp b/zone/spells.cpp index 96d2b74ce..fdd1f286e 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -180,22 +180,27 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, } //Goal of Spells:UseSpellImpliedTargeting is to replicate the EQ2 feature where spells will 'pass through' invalid targets to target's target to try to find a valid target. - if (RuleB(Spells,UseSpellImpliedTargeting) && IsClient()) { - Mob* spell_target = entity_list.GetMobID(target_id); - if (spell_target && spell_target->GetTarget()) { - // If either this is beneficial and the target is not a player or player's pet or vis versa - if ((IsBeneficialSpell(spell_id) && (!(spell_target->IsClient() || (spell_target->HasOwner() && spell_target->GetOwner()->IsClient())))) - || (IsDetrimentalSpell(spell_id) && (spell_target->IsClient() || (spell_target->HasOwner() && spell_target->GetOwner()->IsClient())))) { - //Check if the target's target is a valid target; we can use DoCastingChecksOnTarget() here because we can let it handle the failure as vanilla would - if (DoCastingChecksOnTarget(true, spell_id, spell_target->GetTarget())) { - target_id = spell_target->GetTarget()->GetID(); - } else { - //Just return false here because we are going to fail the next check block anyway if we reach this point. - return false; - } - } - } - } + if (RuleB(Spells,UseSpellImpliedTargeting) && IsClient()) { + Mob* spell_target = entity_list.GetMobID(target_id); + if (spell_target) { + Mob* targets_target = spell_target->GetTarget(); + if (targets_target) { + // If either this is beneficial and the target is not a player or player's pet or vis versa + if ((IsBeneficialSpell(spell_id) && (!(spell_target->IsClient() || (spell_target->HasOwner() && spell_target->GetOwner()->IsClient())))) + || (IsDetrimentalSpell(spell_id) && (spell_target->IsClient() || (spell_target->HasOwner() && spell_target->GetOwner()->IsClient())))) { + //Check if the target's target is a valid target; we can use DoCastingChecksOnTarget() here because we can let it handle the failure as vanilla would + if (DoCastingChecksOnTarget(true, spell_id, targets_target)) { + target_id = targets_target->GetID(); + } + else { + //Just return false here because we are going to fail the next check block anyway if we reach this point. + StopCastSpell(spell_id, send_spellbar_enable); + return false; + } + } + } + } + } if (!DoCastingChecksOnCaster(spell_id, slot) || !DoCastingChecksZoneRestrictions(true, spell_id) ||