Added IsLockInRange check when dealing with opening locks with a spell
This commit is contained in:
parent
30d105fe9f
commit
1524a1e85d
@ -4978,6 +4978,10 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
lockId = go->GetGOInfo()->GetLockId();
|
||||
if (!lockId)
|
||||
{ return SPELL_FAILED_ALREADY_OPEN; }
|
||||
|
||||
// Is the lock within the spell max range?
|
||||
if (!IsLockInRange(go))
|
||||
{ return SPELL_FAILED_OUT_OF_RANGE; }
|
||||
}
|
||||
else if (Item* item = m_targets.getItemTarget())
|
||||
{
|
||||
@ -5000,6 +5004,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
|
||||
// check lock compatibility
|
||||
SpellCastResult res = CanOpenLock(SpellEffectIndex(i), lockId, skillId, reqSkillValue, skillValue);
|
||||
|
||||
if (res != SPELL_CAST_OK)
|
||||
{ return res; }
|
||||
|
||||
@ -6513,6 +6518,19 @@ bool SpellEvent::IsDeletable() const
|
||||
return m_Spell->IsDeletable();
|
||||
}
|
||||
|
||||
bool Spell::IsLockInRange(GameObject* go)
|
||||
{
|
||||
const SpellRangeEntry* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
|
||||
|
||||
|
||||
// This check is not related to bounding radius
|
||||
float dx = m_caster->GetPositionX() - go->GetPositionX();
|
||||
float dy = m_caster->GetPositionY() - go->GetPositionY();
|
||||
float dz = m_caster->GetPositionZ() - go->GetPositionZ();
|
||||
|
||||
return (dx * dx + dy * dy + dz * dz < srange->maxRange);
|
||||
}
|
||||
|
||||
SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, SkillType& skillId, int32& reqSkillValue, int32& skillValue)
|
||||
{
|
||||
if (!lockId) // possible case for GO and maybe for items.
|
||||
|
@ -578,6 +578,7 @@ class Spell
|
||||
void DoAllEffectOnTarget(ItemTargetInfo* target);
|
||||
bool IsAliveUnitPresentInTargetList();
|
||||
SpellCastResult CanOpenLock(SpellEffectIndex effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue);
|
||||
bool IsLockInRange(GameObject* go);
|
||||
SpellCastResult CanTameUnit(bool isGM = false);
|
||||
// -------------------------------------------
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user