mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[7466] Use SpellCastResult in SpellMgr.* functions
This commit is contained in:
parent
78879cc634
commit
c1b0e7d57a
5 changed files with 27 additions and 32 deletions
|
|
@ -7022,7 +7022,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
|
|||
if(apply)
|
||||
{
|
||||
// Cannot be used in this stance/form
|
||||
if(GetErrorAtShapeshiftedCast(spellInfo, m_form)!=0)
|
||||
if(GetErrorAtShapeshiftedCast(spellInfo, m_form) != SPELL_CAST_OK)
|
||||
return;
|
||||
|
||||
if(form_change) // check aura active state from other form
|
||||
|
|
@ -7056,7 +7056,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
|
|||
if(form_change) // check aura compatibility
|
||||
{
|
||||
// Cannot be used in this stance/form
|
||||
if(GetErrorAtShapeshiftedCast(spellInfo, m_form)==0)
|
||||
if(GetErrorAtShapeshiftedCast(spellInfo, m_form)==SPELL_CAST_OK)
|
||||
return; // and remove only not compatible at form change
|
||||
}
|
||||
|
||||
|
|
@ -19255,7 +19255,7 @@ void Player::UpdateAreaDependentAuras( uint32 newArea )
|
|||
for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();)
|
||||
{
|
||||
// use m_zoneUpdateId for speed: UpdateArea called from UpdateZone or instead UpdateZone in both cases m_zoneUpdateId up-to-date
|
||||
if(spellmgr.GetSpellAllowedInLocationError(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea,this)!=0)
|
||||
if(spellmgr.GetSpellAllowedInLocationError(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea,this) != SPELL_CAST_OK)
|
||||
RemoveAura(iter);
|
||||
else
|
||||
++iter;
|
||||
|
|
|
|||
|
|
@ -3616,7 +3616,8 @@ uint8 Spell::CanCast(bool strict)
|
|||
if (checkForm)
|
||||
{
|
||||
// Cannot be used in this stance/form
|
||||
if(uint8 shapeError = GetErrorAtShapeshiftedCast(m_spellInfo, m_caster->m_form))
|
||||
SpellCastResult shapeError = GetErrorAtShapeshiftedCast(m_spellInfo, m_caster->m_form);
|
||||
if(shapeError != SPELL_CAST_OK)
|
||||
return shapeError;
|
||||
|
||||
if ((m_spellInfo->Attributes & SPELL_ATTR_ONLY_STEALTHED) && !(m_caster->HasStealthAura()))
|
||||
|
|
@ -3676,15 +3677,11 @@ uint8 Spell::CanCast(bool strict)
|
|||
// auto selection spell rank implemented in WorldSession::HandleCastSpellOpcode
|
||||
// this case can be triggered if rank not found (too low-level target for first rank)
|
||||
if(m_caster->GetTypeId() == TYPEID_PLAYER && !IsPassiveSpell(m_spellInfo->Id) && !m_CastItem)
|
||||
{
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
if(IsPositiveEffect(m_spellInfo->Id, i) && m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA)
|
||||
if(target->getLevel() + 10 < m_spellInfo->spellLevel)
|
||||
return SPELL_FAILED_LOWLEVEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_caster->GetTypeId()==TYPEID_PLAYER) // Target - is player caster
|
||||
{
|
||||
// Additional check for some spells
|
||||
|
|
@ -3748,10 +3745,8 @@ uint8 Spell::CanCast(bool strict)
|
|||
}
|
||||
|
||||
if(IsPositiveSpell(m_spellInfo->Id))
|
||||
{
|
||||
if(target->IsImmunedToSpell(m_spellInfo))
|
||||
return SPELL_FAILED_TARGET_AURASTATE;
|
||||
}
|
||||
|
||||
//Must be behind the target.
|
||||
if( m_spellInfo->AttributesEx2 == 0x100000 && (m_spellInfo->AttributesEx & 0x200) == 0x200 && target->HasInArc(M_PI, m_caster) )
|
||||
|
|
@ -3773,10 +3768,9 @@ uint8 Spell::CanCast(bool strict)
|
|||
|
||||
// check if target is in combat
|
||||
if (target != m_caster && (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())
|
||||
|
|
@ -3795,9 +3789,10 @@ uint8 Spell::CanCast(bool strict)
|
|||
uint32 zone, area;
|
||||
m_caster->GetZoneAndAreaId(zone,area);
|
||||
|
||||
if (uint8 res= spellmgr.GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),zone,area,
|
||||
m_caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)m_caster) : NULL))
|
||||
return res;
|
||||
SpellCastResult locRes= spellmgr.GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),zone,area,
|
||||
m_caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)m_caster) : NULL);
|
||||
if(locRes != SPELL_CAST_OK)
|
||||
return locRes;
|
||||
|
||||
// not let players cast spells at mount (and let do it to creatures)
|
||||
if( m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell &&
|
||||
|
|
|
|||
|
|
@ -535,13 +535,13 @@ bool IsAuraAddedBySpell(uint32 auraType, uint32 spellId)
|
|||
return false;
|
||||
}
|
||||
|
||||
uint8 GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form)
|
||||
SpellCastResult GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form)
|
||||
{
|
||||
// talents that learn spells can have stance requirements that need ignore
|
||||
// (this requirement only for client-side stance show in talent description)
|
||||
if( GetTalentSpellCost(spellInfo->Id) > 0 &&
|
||||
(spellInfo->Effect[0]==SPELL_EFFECT_LEARN_SPELL || spellInfo->Effect[1]==SPELL_EFFECT_LEARN_SPELL || spellInfo->Effect[2]==SPELL_EFFECT_LEARN_SPELL) )
|
||||
return 0;
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
uint32 stanceMask = (form ? 1 << (form - 1) : 0);
|
||||
|
||||
|
|
@ -549,7 +549,7 @@ uint8 GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form)
|
|||
return SPELL_FAILED_NOT_SHAPESHIFT;
|
||||
|
||||
if (stanceMask & spellInfo->Stances) // can explicitly be casted in this stance
|
||||
return 0;
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
bool actAsShifted = false;
|
||||
if (form > 0)
|
||||
|
|
@ -558,7 +558,7 @@ uint8 GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form)
|
|||
if (!shapeInfo)
|
||||
{
|
||||
sLog.outError("GetErrorAtShapeshiftedCast: unknown shapeshift %u", form);
|
||||
return 0;
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
actAsShifted = !(shapeInfo->flags1 & 1); // shapeshift acts as normal form for spells
|
||||
}
|
||||
|
|
@ -577,7 +577,7 @@ uint8 GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form)
|
|||
return SPELL_FAILED_ONLY_SHAPESHIFT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
|
||||
void SpellMgr::LoadSpellTargetPositions()
|
||||
|
|
@ -2559,7 +2559,7 @@ void SpellMgr::LoadSpellAreas()
|
|||
sLog.outString( ">> Loaded %u spell area requirements", count );
|
||||
}
|
||||
|
||||
uint8 SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player)
|
||||
SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player)
|
||||
{
|
||||
// normal case
|
||||
if( spellInfo->AreaGroupId > 0)
|
||||
|
|
@ -2585,7 +2585,7 @@ uint8 SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint
|
|||
for(SpellAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
|
||||
{
|
||||
if(itr->second.IsFitToRequirements(player,zone_id,area_id))
|
||||
return 0;
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
return SPELL_FAILED_INCORRECT_AREA;
|
||||
}
|
||||
|
|
@ -2595,9 +2595,9 @@ uint8 SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint
|
|||
{
|
||||
case 23333: // Warsong Flag
|
||||
case 23335: // Silverwing Flag
|
||||
return map_id == 489 && player && player->InBattleGround() ? 0 : SPELL_FAILED_REQUIRES_AREA;
|
||||
return map_id == 489 && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA;
|
||||
case 34976: // Netherstorm Flag
|
||||
return map_id == 566 && player && player->InBattleGround() ? 0 : SPELL_FAILED_REQUIRES_AREA;
|
||||
return map_id == 566 && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA;
|
||||
case 2584: // Waiting to Resurrect
|
||||
case 22011: // Spirit Heal Channel
|
||||
case 22012: // Spirit Heal
|
||||
|
|
@ -2610,7 +2610,7 @@ uint8 SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint
|
|||
if(!mapEntry)
|
||||
return SPELL_FAILED_INCORRECT_AREA;
|
||||
|
||||
return mapEntry->IsBattleGround() && player && player->InBattleGround() ? 0 : SPELL_FAILED_REQUIRES_AREA;
|
||||
return mapEntry->IsBattleGround() && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA;
|
||||
}
|
||||
case 44521: // Preparation
|
||||
{
|
||||
|
|
@ -2625,7 +2625,7 @@ uint8 SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint
|
|||
return SPELL_FAILED_REQUIRES_AREA;
|
||||
|
||||
BattleGround* bg = player->GetBattleGround();
|
||||
return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? 0 : SPELL_FAILED_REQUIRES_AREA;
|
||||
return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA;
|
||||
}
|
||||
case 32724: // Gold Team (Alliance)
|
||||
case 32725: // Green Team (Alliance)
|
||||
|
|
@ -2636,7 +2636,7 @@ uint8 SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint
|
|||
if(!mapEntry)
|
||||
return SPELL_FAILED_INCORRECT_AREA;
|
||||
|
||||
return mapEntry->IsBattleArena() && player && player->InBattleGround() ? 0 : SPELL_FAILED_REQUIRES_AREA;
|
||||
return mapEntry->IsBattleArena() && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA;
|
||||
}
|
||||
case 32727: // Arena Preparation
|
||||
{
|
||||
|
|
@ -2651,11 +2651,11 @@ uint8 SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint
|
|||
return SPELL_FAILED_REQUIRES_AREA;
|
||||
|
||||
BattleGround* bg = player->GetBattleGround();
|
||||
return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? 0 : SPELL_FAILED_REQUIRES_AREA;
|
||||
return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
|
||||
void SpellMgr::LoadSkillLineAbilityMap()
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ inline bool IsAutoRepeatRangedSpell(SpellEntry const* spellInfo)
|
|||
return (spellInfo->Attributes & SPELL_ATTR_RANGED) && (spellInfo->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG);
|
||||
}
|
||||
|
||||
uint8 GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form);
|
||||
SpellCastResult GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form);
|
||||
|
||||
inline bool IsChanneledSpell(SpellEntry const* spellInfo)
|
||||
{
|
||||
|
|
@ -810,7 +810,7 @@ class SpellMgr
|
|||
return NULL;
|
||||
}
|
||||
|
||||
uint8 GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL);
|
||||
SpellCastResult GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL);
|
||||
|
||||
SpellAreaMapBounds GetSpellAreaMapBounds(uint32 spell_id) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7465"
|
||||
#define REVISION_NR "7466"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue