diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index d5f20904d..2c96a659b 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1282,14 +1282,16 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap) else radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); - if(m_originalCaster) - if(Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius, this); - uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[effIndex]; + if(m_originalCaster) + { if(Player* modOwner = m_originalCaster->GetSpellModOwner()) + { + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius, this); modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this); + } + } // Get spell max affected targets uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets; @@ -4098,27 +4100,12 @@ SpellCastResult Spell::CheckCast(bool strict) if (non_caster_target && (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat()) return SPELL_FAILED_TARGET_AFFECTING_COMBAT; } - - // Spell casted only on battleground - if ((m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId() == TYPEID_PLAYER) - if(!((Player*)m_caster)->InBattleGround()) - return SPELL_FAILED_ONLY_BATTLEGROUNDS; - - // do not allow spells to be cast in arenas - // - with greater than 15 min CD without SPELL_ATTR_EX4_USABLE_IN_ARENA flag - // - with SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA flag - if ((m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || - GetSpellRecoveryTime(m_spellInfo) > 15 * MINUTE * IN_MILISECONDS && !(m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA)) - if(MapEntry const* mapEntry = sMapStore.LookupEntry(m_caster->GetMapId())) - if(mapEntry->IsBattleArena()) - return SPELL_FAILED_NOT_IN_ARENA; - // zone check uint32 zone, area; m_caster->GetZoneAndAreaId(zone, area); SpellCastResult locRes= spellmgr.GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),zone,area, - m_caster->GetTypeId() == TYPEID_PLAYER ? ((Player*)m_caster) : NULL); + m_caster->GetCharmerOrOwnerPlayerOrPlayerItself()); if (locRes != SPELL_CAST_OK) return locRes; diff --git a/src/game/Spell.h b/src/game/Spell.h index 25d34c098..d345aef13 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -657,37 +657,33 @@ namespace MaNGOS for(typename GridRefManager::iterator itr = m.begin(); itr != m.end(); ++itr) { - if( !itr->getSource()->isAlive() || (itr->getSource()->GetTypeId() == TYPEID_PLAYER && ((Player*)itr->getSource())->isInFlight())) - continue; - - // mostly phase check - if(!itr->getSource()->IsInMap(i_originalCaster)) + if ( !itr->getSource()->isTargetableForAttack() + // mostly phase check + || !itr->getSource()->IsInMap(i_originalCaster)) continue; switch (i_TargetType) { case SPELL_TARGETS_HOSTILE: - if (!itr->getSource()->isTargetableForAttack() || !i_originalCaster->IsHostileTo( itr->getSource() )) + if (!i_originalCaster->IsHostileTo( itr->getSource() )) continue; break; case SPELL_TARGETS_NOT_FRIENDLY: - if (!itr->getSource()->isTargetableForAttack() || i_originalCaster->IsFriendlyTo( itr->getSource() )) + if (i_originalCaster->IsFriendlyTo( itr->getSource() )) continue; break; case SPELL_TARGETS_NOT_HOSTILE: - if (!itr->getSource()->isTargetableForAttack() || i_originalCaster->IsHostileTo( itr->getSource() )) + if (i_originalCaster->IsHostileTo( itr->getSource() )) continue; break; case SPELL_TARGETS_FRIENDLY: - if (!itr->getSource()->isTargetableForAttack() || !i_originalCaster->IsFriendlyTo( itr->getSource() )) + if (!i_originalCaster->IsFriendlyTo( itr->getSource() )) continue; break; case SPELL_TARGETS_AOE_DAMAGE: { if(itr->getSource()->GetTypeId()==TYPEID_UNIT && ((Creature*)itr->getSource())->isTotem()) continue; - if(!itr->getSource()->isTargetableForAttack()) - continue; Unit* check = i_originalCaster->GetCharmerOrOwnerOrSelf(); diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 7e7bb7de8..051404404 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2803,6 +2803,20 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spell } // bg spell checks + + // do not allow spells to be cast in arenas + // - with SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA flag + // - with greater than 15 min CD + if ((spellInfo->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || + (GetSpellRecoveryTime(spellInfo) > 15 * MINUTE * IN_MILISECONDS && !(spellInfo->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA))) + if (!player || !player->InArena()) + return SPELL_FAILED_NOT_IN_ARENA; + + // Spell casted only on battleground + if ((spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND)) + if (!player || !player->InBattleGround()) + return SPELL_FAILED_ONLY_BATTLEGROUNDS; + switch(spellInfo->Id) { case 23333: // Warsong Flag @@ -2811,59 +2825,45 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spell case 34976: // Netherstorm Flag return map_id == 566 && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; case 2584: // Waiting to Resurrect + case 42792: // Recently Dropped Flag + case 43681: // Inactive + { + return player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; + } case 22011: // Spirit Heal Channel case 22012: // Spirit Heal case 24171: // Resurrection Impact Visual - case 42792: // Recently Dropped Flag - case 43681: // Inactive case 44535: // Spirit Heal (mana) { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry) return SPELL_FAILED_INCORRECT_AREA; - - return mapEntry->IsBattleGround() && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; + return mapEntry->IsBattleGround()? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } case 44521: // Preparation { if (!player) return SPELL_FAILED_REQUIRES_AREA; - MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); - if (!mapEntry) - return SPELL_FAILED_INCORRECT_AREA; - - if (!mapEntry->IsBattleGround()) - return SPELL_FAILED_REQUIRES_AREA; - BattleGround* bg = player->GetBattleGround(); - return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; + return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } case 32724: // Gold Team (Alliance) case 32725: // Green Team (Alliance) case 35774: // Gold Team (Horde) case 35775: // Green Team (Horde) { - MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); - if (!mapEntry) - return SPELL_FAILED_INCORRECT_AREA; - - return mapEntry->IsBattleArena() && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; + return player && player->InArena() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; } case 32727: // Arena Preparation { if (!player) return SPELL_FAILED_REQUIRES_AREA; - - MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); - if (!mapEntry) - return SPELL_FAILED_INCORRECT_AREA; - - if (!mapEntry->IsBattleArena()) + if (!player->InArena()) return SPELL_FAILED_REQUIRES_AREA; BattleGround* bg = player->GetBattleGround(); - return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; + return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; } } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2deeecb64..492bca4fe 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8550" + #define REVISION_NR "8551" #endif // __REVISION_NR_H__