Core/Spells: Spells with TARGET_SELECT_CATEGORY_NEARBY requires a valid target
This commit is contained in:
@@ -2523,7 +2523,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
// need to add Battle pets automatically into pet journal
|
// need to add Battle pets automatically into pet journal
|
||||||
foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values)
|
foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values)
|
||||||
{
|
{
|
||||||
if (entry.SummonSpellID == spellId && GetSession().GetBattlePetMgr().GetPetCount(entry.Id) == 0)
|
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));
|
GetSession().GetBattlePetMgr().AddPet(entry.Id, entry.CreatureID, BattlePetMgr.RollPetBreed(entry.Id), BattlePetMgr.GetDefaultPetQuality(entry.Id));
|
||||||
|
|||||||
@@ -567,6 +567,11 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
if (focusObject != null)
|
if (focusObject != null)
|
||||||
AddGOTarget(focusObject, effMask);
|
AddGOTarget(focusObject, effMask);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendCastResult(SpellCastResult.BadImplicitTargets);
|
||||||
|
finish(false);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -579,6 +584,11 @@ namespace Game.Spells
|
|||||||
CallScriptDestinationTargetSelectHandlers(ref dest, effIndex, targetType);
|
CallScriptDestinationTargetSelectHandlers(ref dest, effIndex, targetType);
|
||||||
m_targets.SetDst(dest);
|
m_targets.SetDst(dest);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendCastResult(SpellCastResult.BadImplicitTargets);
|
||||||
|
finish(false);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -591,10 +601,19 @@ namespace Game.Spells
|
|||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.Spells, "Spell.SelectImplicitNearbyTargets: cannot find nearby target for spell ID {0}, effect {1}", m_spellInfo.Id, effIndex);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CallScriptObjectTargetSelectHandlers(ref target, effIndex, targetType);
|
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())
|
switch (targetType.GetObjectType())
|
||||||
{
|
{
|
||||||
@@ -602,11 +621,25 @@ namespace Game.Spells
|
|||||||
Unit unitTarget = target.ToUnit();
|
Unit unitTarget = target.ToUnit();
|
||||||
if (unitTarget != null)
|
if (unitTarget != null)
|
||||||
AddUnitTarget(unitTarget, effMask, true, false);
|
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;
|
break;
|
||||||
case SpellTargetObjectTypes.Gobj:
|
case SpellTargetObjectTypes.Gobj:
|
||||||
GameObject gobjTarget = target.ToGameObject();
|
GameObject gobjTarget = target.ToGameObject();
|
||||||
if (gobjTarget != null)
|
if (gobjTarget != null)
|
||||||
AddGOTarget(gobjTarget, effMask);
|
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;
|
break;
|
||||||
case SpellTargetObjectTypes.Dest:
|
case SpellTargetObjectTypes.Dest:
|
||||||
SpellDestination dest = new SpellDestination(target);
|
SpellDestination dest = new SpellDestination(target);
|
||||||
|
|||||||
Reference in New Issue
Block a user