mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 16:37:00 +00:00
[8551] code cleanup
moved arena/battleground check from spell::checkcast to SpellMgr::GetSpellAllowedInLocationError also i adjusted some spell_fail-codes related to battleground cause a spell_fail_wrong_area always requires the areaid, else it would output "not in area %s" then we don't need to check for map->isarena() when player is already in an arena ---- in Spell.h i moved "isTargetableForAttack()" to the top - cause it was anyway used in every case of that switch and isTargetableForAttack for attack also checks for isAlive and isInFlight so this could get simplified
This commit is contained in:
parent
9143f19bef
commit
5385b385bc
4 changed files with 39 additions and 56 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue