IsSpellBlocked converted to use xyz_location

This commit is contained in:
Arthur Ice 2014-12-01 16:00:48 -08:00
parent b06647b763
commit f5a94ed07b
4 changed files with 6 additions and 10 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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:

View File

@ -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; }