diff --git a/zone/bot.cpp b/zone/bot.cpp index 76363ab7c..8d84899f3 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -9128,7 +9128,7 @@ void Bot::DoBuffTic(uint16 spell_id, int slot, uint32 ticsremaining, uint8 caste bool Bot::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot, int32 cast_time, int32 mana_cost, uint32* oSpellWillFinish, uint32 item_slot, int16 *resist_adjust) { bool Result = false; - if(zone && !zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())) { + if(zone && !zone->IsSpellBlocked(spell_id, GetPosition())) { mlog(SPELLS__CASTING, "CastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item slot %d", spells[spell_id].name, spell_id, target_id, slot, cast_time, mana_cost, (item_slot==0xFFFFFFFF)?999:item_slot); diff --git a/zone/spells.cpp b/zone/spells.cpp index da6e4f40c..223a584f3 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -521,7 +521,7 @@ bool Mob::DoCastingChecks() return false; } - if (zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())) { + if (zone->IsSpellBlocked(spell_id, GetPosition())) { const char *msg = zone->GetSpellBlockedMessage(spell_id, GetPosition()); if (msg) { Message(13, msg); @@ -1893,7 +1893,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 if(IsClient() && !CastToClient()->GetGM()){ - if(zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())){ + if(zone->IsSpellBlocked(spell_id, GetPosition())){ const char *msg = zone->GetSpellBlockedMessage(spell_id, GetPosition()); if(msg){ Message(13, msg); diff --git a/zone/zone.cpp b/zone/zone.cpp index 8ed12673e..292d4fc79 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1869,7 +1869,7 @@ void Zone::ClearBlockedSpells() } } -bool Zone::IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz) +bool Zone::IsSpellBlocked(uint32 spell_id, const xyz_location& location) { if (blocked_spells) { @@ -1919,12 +1919,8 @@ bool Zone::IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz) } case 2: { - if ((( nx >= (blocked_spells[x].m_Location.m_X-blocked_spells[x].m_Difference.m_X)) && (nx <= (blocked_spells[x].m_Location.m_X+blocked_spells[x].m_Difference.m_X))) && - (( ny >= (blocked_spells[x].m_Location.m_Y-blocked_spells[x].m_Difference.m_Y)) && (ny <= (blocked_spells[x].m_Location.m_Y+blocked_spells[x].m_Difference.m_Y))) && - (( nz >= (blocked_spells[x].m_Location.m_Z-blocked_spells[x].m_Difference.m_Z)) && (nz <= (blocked_spells[x].m_Location.m_Z+blocked_spells[x].m_Difference.m_Z)))) - { + if (!IsWithinAxisAlignedBox(location, blocked_spells[x].m_Location - blocked_spells[x].m_Difference, blocked_spells[x].m_Location + blocked_spells[x].m_Difference)) return true; - } break; } default: diff --git a/zone/zone.h b/zone/zone.h index 48557ccad..e0a89ac50 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -245,7 +245,7 @@ public: void LoadBlockedSpells(uint32 zoneid); void ClearBlockedSpells(); - bool IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz); + bool IsSpellBlocked(uint32 spell_id, const xyz_location& location); const char *GetSpellBlockedMessage(uint32 spell_id, const xyz_location& location); int GetTotalBlockedSpells() { return totalBS; } inline bool HasMap() { return zonemap != nullptr; }