diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index 96f9a5955..e5b824838 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -2523,7 +2523,7 @@ namespace Game.Entities // need to add Battle pets automatically into pet journal foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values) - { + { if (entry.SummonSpellID == spellId && GetSession().GetBattlePetMgr().GetPetCount(entry.Id) == 0) { GetSession().GetBattlePetMgr().AddPet(entry.Id, entry.CreatureID, BattlePetMgr.RollPetBreed(entry.Id), BattlePetMgr.GetDefaultPetQuality(entry.Id)); diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index a5aaf59b9..568f429a3 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -567,6 +567,11 @@ namespace Game.Spells { if (focusObject != null) AddGOTarget(focusObject, effMask); + else + { + SendCastResult(SpellCastResult.BadImplicitTargets); + finish(false); + } return; } break; @@ -579,6 +584,11 @@ namespace Game.Spells CallScriptDestinationTargetSelectHandlers(ref dest, effIndex, targetType); m_targets.SetDst(dest); } + else + { + SendCastResult(SpellCastResult.BadImplicitTargets); + finish(false); + } return; } break; @@ -591,10 +601,19 @@ namespace Game.Spells if (target == null) { Log.outDebug(LogFilter.Spells, "Spell.SelectImplicitNearbyTargets: cannot find nearby target for spell ID {0}, effect {1}", m_spellInfo.Id, effIndex); + SendCastResult(SpellCastResult.BadImplicitTargets); + finish(false); return; } CallScriptObjectTargetSelectHandlers(ref target, effIndex, targetType); + if (!target) + { + Log.outDebug(LogFilter.Spells, $"Spell.SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id {m_spellInfo.Id} set NULL target, effect {effIndex}"); + SendCastResult(SpellCastResult.BadImplicitTargets); + finish(false); + return; + } switch (targetType.GetObjectType()) { @@ -602,11 +621,25 @@ namespace Game.Spells Unit unitTarget = target.ToUnit(); if (unitTarget != null) AddUnitTarget(unitTarget, effMask, true, false); + else + { + Log.outDebug(LogFilter.Spells, $"Spell.SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id {m_spellInfo.Id} set object of wrong type, expected unit, got {target.GetGUID().GetHigh()}, effect {effMask}"); + SendCastResult(SpellCastResult.BadImplicitTargets); + finish(false); + return; + } break; case SpellTargetObjectTypes.Gobj: GameObject gobjTarget = target.ToGameObject(); if (gobjTarget != null) AddGOTarget(gobjTarget, effMask); + else + { + Log.outDebug(LogFilter.Spells, $"Spell.SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id {m_spellInfo.Id} set object of wrong type, expected gameobject, got {target.GetGUID().GetHigh()}, effect {effMask}"); + SendCastResult(SpellCastResult.BadImplicitTargets); + finish(false); + return; + } break; case SpellTargetObjectTypes.Dest: SpellDestination dest = new SpellDestination(target);