2010-10-07 15:35:36 +02:00
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
2008-11-17 22:07:21 -06:00
*/
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
#include "SpellMgr.h"
#include "ObjectMgr.h"
#include "SpellAuraDefines.h"
#include "ProgressBar.h"
2009-03-27 09:58:20 -06:00
#include "DBCStores.h"
2008-11-17 22:07:21 -06:00
#include "World.h"
#include "Chat.h"
#include "Spell.h"
2010-08-08 04:37:24 +02:00
#include "BattlegroundMgr.h"
2009-05-10 22:48:22 -05:00
#include "CreatureAI.h"
2010-04-18 23:20:07 +02:00
#include "MapManager.h"
2009-10-17 15:51:44 -07:00
2009-01-30 01:11:51 -06:00
bool IsAreaEffectTarget [ TOTAL_SPELL_TARGETS ];
2009-08-17 15:54:39 -05:00
SpellEffectTargetTypes EffectTargetType [ TOTAL_SPELL_EFFECTS ];
SpellSelectTargetTypes SpellTargetType [ TOTAL_SPELL_TARGETS ];
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
SpellMgr :: SpellMgr ()
{
2009-10-17 16:20:24 -07:00
for ( int i = 0 ; i < TOTAL_SPELL_EFFECTS ; ++ i )
2008-12-21 14:01:26 -06:00
{
switch ( i )
{
2008-12-23 14:58:55 -06:00
case SPELL_EFFECT_PERSISTENT_AREA_AURA : //27
case SPELL_EFFECT_SUMMON : //28
case SPELL_EFFECT_TRIGGER_MISSILE : //32
case SPELL_EFFECT_TRANS_DOOR : //50 summon object
case SPELL_EFFECT_SUMMON_PET : //56
case SPELL_EFFECT_ADD_FARSIGHT : //72
case SPELL_EFFECT_SUMMON_OBJECT_WILD : //76
2009-01-06 13:45:49 -06:00
//case SPELL_EFFECT_SUMMON_CRITTER: //97 not 303
2008-12-23 14:58:55 -06:00
case SPELL_EFFECT_SUMMON_OBJECT_SLOT1 : //104
case SPELL_EFFECT_SUMMON_OBJECT_SLOT2 : //105
case SPELL_EFFECT_SUMMON_OBJECT_SLOT3 : //106
case SPELL_EFFECT_SUMMON_OBJECT_SLOT4 : //107
case SPELL_EFFECT_SUMMON_DEAD_PET : //109
case SPELL_EFFECT_TRIGGER_SPELL_2 : //151 ritual of summon
2008-12-21 14:01:26 -06:00
EffectTargetType [ i ] = SPELL_REQUIRE_DEST ;
break ;
case SPELL_EFFECT_PARRY : // 0
case SPELL_EFFECT_BLOCK : // 0
case SPELL_EFFECT_SKILL : // always with dummy 3 as A
2008-12-24 15:06:06 -06:00
//case SPELL_EFFECT_LEARN_SPELL: // 0 may be 5 pet
2008-12-21 14:01:26 -06:00
case SPELL_EFFECT_TRADE_SKILL : // 0 or 1
case SPELL_EFFECT_PROFICIENCY : // 0
EffectTargetType [ i ] = SPELL_REQUIRE_NONE ;
break ;
2008-12-24 18:45:06 -06:00
case SPELL_EFFECT_ENCHANT_ITEM :
case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY :
case SPELL_EFFECT_DISENCHANT :
2009-05-03 16:29:33 -05:00
//in 243 this is 0, in 309 it is 1
//so both item target and unit target is pushed, and cause crash
//case SPELL_EFFECT_FEED_PET:
2008-12-24 18:45:06 -06:00
case SPELL_EFFECT_PROSPECTING :
2009-03-18 21:04:46 +01:00
case SPELL_EFFECT_MILLING :
2009-04-10 15:18:41 +02:00
case SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC :
2008-12-24 18:45:06 -06:00
EffectTargetType [ i ] = SPELL_REQUIRE_ITEM ;
break ;
2008-12-26 16:15:44 -06:00
//caster must be pushed otherwise no sound
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY :
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND :
case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY :
case SPELL_EFFECT_APPLY_AREA_AURA_PET :
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER :
2009-05-24 14:58:54 +02:00
case SPELL_EFFECT_APPLY_AREA_AURA_RAID :
2009-05-03 16:29:33 -05:00
case SPELL_EFFECT_CHARGE :
2010-07-19 19:22:05 +02:00
case SPELL_EFFECT_CHARGE_DEST :
2009-05-03 16:29:33 -05:00
case SPELL_EFFECT_JUMP :
2010-07-19 21:24:09 +02:00
case SPELL_EFFECT_JUMP_DEST :
2009-08-27 20:14:50 -05:00
case SPELL_EFFECT_LEAP_BACK :
2008-12-26 16:15:44 -06:00
EffectTargetType [ i ] = SPELL_REQUIRE_CASTER ;
break ;
2009-05-21 10:01:03 -05:00
//case SPELL_EFFECT_WMO_DAMAGE:
//case SPELL_EFFECT_WMO_REPAIR:
//case SPELL_EFFECT_WMO_CHANGE:
// EffectTargetType[i] = SPELL_REQUIRE_GOBJECT;
// break;
2008-12-21 14:01:26 -06:00
default :
EffectTargetType [ i ] = SPELL_REQUIRE_UNIT ;
break ;
}
}
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for ( int i = 0 ; i < TOTAL_SPELL_TARGETS ; ++ i )
2008-12-21 14:01:26 -06:00
{
switch ( i )
{
case TARGET_UNIT_CASTER :
case TARGET_UNIT_CASTER_FISHING :
case TARGET_UNIT_MASTER :
case TARGET_UNIT_PET :
2008-12-23 20:19:40 -06:00
case TARGET_UNIT_PARTY_CASTER :
2009-05-02 11:28:11 -05:00
case TARGET_UNIT_RAID_CASTER :
2009-06-14 09:57:57 -05:00
case TARGET_UNIT_VEHICLE :
2010-01-25 12:40:03 +01:00
case TARGET_UNIT_PASSENGER_0 :
case TARGET_UNIT_PASSENGER_1 :
case TARGET_UNIT_PASSENGER_2 :
case TARGET_UNIT_PASSENGER_3 :
case TARGET_UNIT_PASSENGER_4 :
case TARGET_UNIT_PASSENGER_5 :
case TARGET_UNIT_PASSENGER_6 :
case TARGET_UNIT_PASSENGER_7 :
2010-08-17 20:19:06 +02:00
case TARGET_UNIT_SUMMONER :
2008-12-21 14:01:26 -06:00
SpellTargetType [ i ] = TARGET_TYPE_UNIT_CASTER ;
break ;
2010-08-17 20:19:06 +02:00
case TARGET_UNIT_TARGET_PUPPET :
2008-12-21 14:01:26 -06:00
case TARGET_UNIT_TARGET_ALLY :
case TARGET_UNIT_TARGET_RAID :
case TARGET_UNIT_TARGET_ANY :
case TARGET_UNIT_TARGET_ENEMY :
2008-12-23 20:01:05 -06:00
case TARGET_UNIT_TARGET_PARTY :
case TARGET_UNIT_PARTY_TARGET :
2009-05-02 11:28:11 -05:00
case TARGET_UNIT_CLASS_TARGET :
2009-01-27 14:34:42 -06:00
case TARGET_UNIT_CHAINHEAL :
2008-12-21 14:01:26 -06:00
SpellTargetType [ i ] = TARGET_TYPE_UNIT_TARGET ;
break ;
2009-05-02 11:28:11 -05:00
case TARGET_UNIT_NEARBY_ENEMY :
case TARGET_UNIT_NEARBY_ALLY :
case TARGET_UNIT_NEARBY_ALLY_UNK :
case TARGET_UNIT_NEARBY_ENTRY :
case TARGET_UNIT_NEARBY_RAID :
2010-02-04 00:36:40 +01:00
case TARGET_GAMEOBJECT_NEARBY_ENTRY :
2009-05-02 11:28:11 -05:00
SpellTargetType [ i ] = TARGET_TYPE_UNIT_NEARBY ;
2008-12-21 14:01:26 -06:00
break ;
2009-05-02 11:28:11 -05:00
case TARGET_UNIT_AREA_ENEMY_SRC :
case TARGET_UNIT_AREA_ALLY_SRC :
case TARGET_UNIT_AREA_ENTRY_SRC :
case TARGET_UNIT_AREA_PARTY_SRC :
2010-07-30 01:51:33 +02:00
case TARGET_GAMEOBJECT_AREA_SRC :
2009-05-02 11:28:11 -05:00
SpellTargetType [ i ] = TARGET_TYPE_AREA_SRC ;
2008-12-21 14:01:26 -06:00
break ;
2009-05-02 11:28:11 -05:00
case TARGET_UNIT_AREA_ENEMY_DST :
case TARGET_UNIT_AREA_ALLY_DST :
case TARGET_UNIT_AREA_ENTRY_DST :
case TARGET_UNIT_AREA_PARTY_DST :
2010-07-30 01:51:33 +02:00
case TARGET_GAMEOBJECT_AREA_DST :
2009-05-02 11:28:11 -05:00
SpellTargetType [ i ] = TARGET_TYPE_AREA_DST ;
break ;
case TARGET_UNIT_CONE_ENEMY :
case TARGET_UNIT_CONE_ALLY :
case TARGET_UNIT_CONE_ENTRY :
case TARGET_UNIT_CONE_ENEMY_UNKNOWN :
2009-07-31 11:12:04 +08:00
case TARGET_UNIT_AREA_PATH :
2010-08-18 15:04:00 +02:00
case TARGET_GAMEOBJECT_AREA_PATH :
2009-05-02 11:28:11 -05:00
SpellTargetType [ i ] = TARGET_TYPE_AREA_CONE ;
break ;
case TARGET_DST_CASTER :
case TARGET_SRC_CASTER :
case TARGET_MINION :
case TARGET_DEST_CASTER_FRONT_LEAP :
case TARGET_DEST_CASTER_FRONT :
case TARGET_DEST_CASTER_BACK :
case TARGET_DEST_CASTER_RIGHT :
case TARGET_DEST_CASTER_LEFT :
case TARGET_DEST_CASTER_FRONT_LEFT :
case TARGET_DEST_CASTER_BACK_LEFT :
case TARGET_DEST_CASTER_BACK_RIGHT :
case TARGET_DEST_CASTER_FRONT_RIGHT :
case TARGET_DEST_CASTER_RANDOM :
case TARGET_DEST_CASTER_RADIUS :
SpellTargetType [ i ] = TARGET_TYPE_DEST_CASTER ;
break ;
case TARGET_DST_TARGET_ENEMY :
2009-03-12 09:15:30 -06:00
case TARGET_DEST_TARGET_ANY :
2008-12-21 14:01:26 -06:00
case TARGET_DEST_TARGET_FRONT :
case TARGET_DEST_TARGET_BACK :
case TARGET_DEST_TARGET_RIGHT :
case TARGET_DEST_TARGET_LEFT :
2009-01-08 14:22:15 -06:00
case TARGET_DEST_TARGET_FRONT_LEFT :
case TARGET_DEST_TARGET_BACK_LEFT :
case TARGET_DEST_TARGET_BACK_RIGHT :
case TARGET_DEST_TARGET_FRONT_RIGHT :
2008-12-21 14:01:26 -06:00
case TARGET_DEST_TARGET_RANDOM :
case TARGET_DEST_TARGET_RADIUS :
SpellTargetType [ i ] = TARGET_TYPE_DEST_TARGET ;
break ;
2009-04-30 22:04:15 -05:00
case TARGET_DEST_DYNOBJ_ENEMY :
case TARGET_DEST_DYNOBJ_ALLY :
2009-05-02 11:28:11 -05:00
case TARGET_DEST_DYNOBJ_NONE :
2008-12-21 14:01:26 -06:00
case TARGET_DEST_DEST :
2009-05-02 11:28:11 -05:00
case TARGET_DEST_TRAJ :
2009-01-08 14:22:15 -06:00
case TARGET_DEST_DEST_FRONT_LEFT :
case TARGET_DEST_DEST_BACK_LEFT :
case TARGET_DEST_DEST_BACK_RIGHT :
case TARGET_DEST_DEST_FRONT_RIGHT :
case TARGET_DEST_DEST_FRONT :
case TARGET_DEST_DEST_BACK :
case TARGET_DEST_DEST_RIGHT :
case TARGET_DEST_DEST_LEFT :
case TARGET_DEST_DEST_RANDOM :
2010-01-25 12:40:03 +01:00
case TARGET_DEST_DEST_RANDOM_DIR_DIST :
2008-12-21 14:01:26 -06:00
SpellTargetType [ i ] = TARGET_TYPE_DEST_DEST ;
break ;
2009-05-02 11:28:11 -05:00
case TARGET_DST_DB :
case TARGET_DST_HOME :
case TARGET_DST_NEARBY_ENTRY :
SpellTargetType [ i ] = TARGET_TYPE_DEST_SPECIAL ;
break ;
2010-08-18 15:04:00 +02:00
case TARGET_UNIT_CHANNEL_TARGET :
case TARGET_DEST_CHANNEL_TARGET :
case TARGET_DEST_CHANNEL_CASTER :
2009-05-02 11:28:11 -05:00
SpellTargetType [ i ] = TARGET_TYPE_CHANNEL ;
break ;
2008-12-21 14:01:26 -06:00
default :
SpellTargetType [ i ] = TARGET_TYPE_DEFAULT ;
}
}
2009-10-17 15:51:44 -07:00
2010-08-18 15:04:00 +02:00
for ( int32 i = 0 ; i < TOTAL_SPELL_TARGETS ; ++ i )
2008-12-26 15:55:12 -06:00
{
switch ( i )
{
2009-05-02 11:28:11 -05:00
case TARGET_UNIT_AREA_ENEMY_DST :
case TARGET_UNIT_AREA_ENEMY_SRC :
case TARGET_UNIT_AREA_ALLY_DST :
case TARGET_UNIT_AREA_ALLY_SRC :
case TARGET_UNIT_AREA_ENTRY_DST :
case TARGET_UNIT_AREA_ENTRY_SRC :
case TARGET_UNIT_AREA_PARTY_DST :
case TARGET_UNIT_AREA_PARTY_SRC :
2008-12-26 15:55:12 -06:00
case TARGET_UNIT_PARTY_TARGET :
case TARGET_UNIT_PARTY_CASTER :
case TARGET_UNIT_CONE_ENEMY :
case TARGET_UNIT_CONE_ALLY :
case TARGET_UNIT_CONE_ENEMY_UNKNOWN :
2009-07-31 11:12:04 +08:00
case TARGET_UNIT_AREA_PATH :
2010-08-18 15:04:00 +02:00
case TARGET_GAMEOBJECT_AREA_PATH :
2009-05-02 11:28:11 -05:00
case TARGET_UNIT_RAID_CASTER :
2008-12-26 15:55:12 -06:00
IsAreaEffectTarget [ i ] = true ;
break ;
default :
IsAreaEffectTarget [ i ] = false ;
break ;
}
}
2008-11-17 22:07:21 -06:00
}
SpellMgr ::~ SpellMgr ()
{
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
SpellMgr & SpellMgr :: Instance ()
{
static SpellMgr spellMgr ;
return spellMgr ;
}
2009-10-17 15:51:44 -07:00
2009-07-05 16:58:42 +02:00
bool SpellMgr :: IsSrcTargetSpell ( SpellEntry const * spellInfo ) const
{
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
{
2010-04-07 19:14:10 +02:00
if ( SpellTargetType [ spellInfo -> EffectImplicitTargetA [ i ]] == TARGET_TYPE_AREA_SRC || SpellTargetType [ spellInfo -> EffectImplicitTargetB [ i ]] == TARGET_TYPE_AREA_SRC )
2009-07-05 16:58:42 +02:00
return true ;
}
return false ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
int32 GetSpellDuration ( SpellEntry const * spellInfo )
{
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-11-17 22:07:21 -06:00
return 0 ;
SpellDurationEntry const * du = sSpellDurationStore . LookupEntry ( spellInfo -> DurationIndex );
2010-04-07 19:14:10 +02:00
if ( ! du )
2008-11-17 22:07:21 -06:00
return 0 ;
return ( du -> Duration [ 0 ] == - 1 ) ? - 1 : abs ( du -> Duration [ 0 ]);
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
int32 GetSpellMaxDuration ( SpellEntry const * spellInfo )
{
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-11-17 22:07:21 -06:00
return 0 ;
SpellDurationEntry const * du = sSpellDurationStore . LookupEntry ( spellInfo -> DurationIndex );
2010-04-07 19:14:10 +02:00
if ( ! du )
2008-11-17 22:07:21 -06:00
return 0 ;
return ( du -> Duration [ 2 ] == - 1 ) ? - 1 : abs ( du -> Duration [ 2 ]);
}
2009-10-17 15:51:44 -07:00
2010-06-27 04:03:30 +02:00
uint32 GetDispelChance ( Unit * auraCaster , Unit * target , uint32 spellId , bool offensive , bool * result )
2009-03-23 01:54:50 +01:00
{
// we assume that aura dispel chance is 100% on start
// need formula for level difference based chance
2010-05-25 10:36:33 +02:00
int32 resist_chance = 0 ;
2009-03-23 01:54:50 +01:00
// Apply dispel mod from aura caster
2010-05-25 10:36:33 +02:00
if ( auraCaster )
if ( Player * modOwner = auraCaster -> GetSpellModOwner ())
modOwner -> ApplySpellMod ( spellId , SPELLMOD_RESIST_DISPEL_CHANCE , resist_chance );
// Dispel resistance from target SPELL_AURA_MOD_DISPEL_RESIST
// Only affects offensive dispels
if ( offensive && target )
resist_chance += target -> GetTotalAuraModifier ( SPELL_AURA_MOD_DISPEL_RESIST );
2009-03-23 01:54:50 +01:00
// Try dispel
2010-05-25 10:36:33 +02:00
if ( result )
* result = ! roll_chance_i ( resist_chance );
2010-06-27 04:03:30 +02:00
resist_chance = resist_chance < 0 ? 0 : resist_chance ;
resist_chance = resist_chance > 100 ? 100 : resist_chance ;
return 100 - resist_chance ;
2009-03-23 01:54:50 +01:00
}
2009-10-17 15:51:44 -07:00
2009-06-06 08:27:36 +02:00
uint32 GetSpellCastTime ( SpellEntry const * spellInfo , Spell * spell )
2008-11-17 22:07:21 -06:00
{
SpellCastTimesEntry const * spellCastTimeEntry = sSpellCastTimesStore . LookupEntry ( spellInfo -> CastingTimeIndex );
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// not all spells have cast time index and this is all is pasiive abilities
2010-04-07 19:14:10 +02:00
if ( ! spellCastTimeEntry )
2008-11-17 22:07:21 -06:00
return 0 ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
int32 castTime = spellCastTimeEntry -> CastTime ;
2009-10-17 15:51:44 -07:00
2009-02-11 20:10:00 +01:00
if ( spell && spell -> GetCaster ())
2009-03-02 23:37:24 +01:00
spell -> GetCaster () -> ModSpellCastTime ( spellInfo , castTime , spell );
2009-10-17 15:51:44 -07:00
2009-05-08 00:49:02 -05:00
if ( spellInfo -> Attributes & SPELL_ATTR_REQ_AMMO && ( ! spell || ! ( spell -> IsAutoRepeat ())))
2008-11-17 22:07:21 -06:00
castTime += 500 ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
return ( castTime > 0 ) ? uint32 ( castTime ) : 0 ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool IsPassiveSpell ( uint32 spellId )
{
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( spellId );
if ( ! spellInfo )
return false ;
2010-01-10 01:23:15 +01:00
return IsPassiveSpell ( spellInfo );
}
bool IsPassiveSpell ( SpellEntry const * spellInfo )
{
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Attributes & SPELL_ATTR_PASSIVE )
2009-05-26 15:32:11 -05:00
return true ;
return false ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-03-21 18:05:43 -06:00
bool IsAutocastableSpell ( uint32 spellId )
{
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( spellId );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2009-03-21 18:05:43 -06:00
return false ;
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Attributes & SPELL_ATTR_PASSIVE )
2009-03-21 18:05:43 -06:00
return false ;
2010-04-07 19:14:10 +02:00
if ( spellInfo -> AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET )
2009-03-21 18:05:43 -06:00
return false ;
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-06 13:31:14 +02:00
bool IsHigherHankOfSpell ( uint32 spellId_1 , uint32 spellId_2 )
2008-11-17 22:07:21 -06:00
{
2010-08-08 05:25:45 +02:00
return sSpellMgr . GetSpellRank ( spellId_1 ) < sSpellMgr . GetSpellRank ( spellId_2 );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-07-23 18:32:32 +02:00
uint32 CalculatePowerCost ( SpellEntry const * spellInfo , Unit const * caster , SpellSchoolMask schoolMask )
{
// Spell drain all exist power on cast (Only paladin lay of Hands)
if ( spellInfo -> AttributesEx & SPELL_ATTR_EX_DRAIN_ALL_POWER )
{
// If power type - health drain all
if ( spellInfo -> powerType == POWER_HEALTH )
return caster -> GetHealth ();
// Else drain all power
if ( spellInfo -> powerType < MAX_POWERS )
return caster -> GetPower ( Powers ( spellInfo -> powerType ));
sLog . outError ( "CalculateManaCost: Unknown power type '%d' in spell %d" , spellInfo -> powerType , spellInfo -> Id );
return 0 ;
}
2009-10-17 15:51:44 -07:00
2009-07-23 18:32:32 +02:00
// Base powerCost
int32 powerCost = spellInfo -> manaCost ;
// PCT cost from total amount
if ( spellInfo -> ManaCostPercentage )
{
switch ( spellInfo -> powerType )
{
// health as power used
case POWER_HEALTH :
powerCost += spellInfo -> ManaCostPercentage * caster -> GetCreateHealth () / 100 ;
break ;
case POWER_MANA :
powerCost += spellInfo -> ManaCostPercentage * caster -> GetCreateMana () / 100 ;
break ;
case POWER_RAGE :
case POWER_FOCUS :
case POWER_ENERGY :
case POWER_HAPPINESS :
powerCost += spellInfo -> ManaCostPercentage * caster -> GetMaxPower ( Powers ( spellInfo -> powerType )) / 100 ;
break ;
case POWER_RUNE :
case POWER_RUNIC_POWER :
sLog . outDebug ( "CalculateManaCost: Not implemented yet!" );
break ;
default :
sLog . outError ( "CalculateManaCost: Unknown power type '%d' in spell %d" , spellInfo -> powerType , spellInfo -> Id );
return 0 ;
}
}
SpellSchools school = GetFirstSchoolInMask ( schoolMask );
// Flat mod from caster auras by spell school
powerCost += caster -> GetInt32Value ( UNIT_FIELD_POWER_COST_MODIFIER + school );
// Shiv - costs 20 + weaponSpeed*10 energy (apply only to non-triggered spell with energy cost)
2010-04-07 22:59:46 +02:00
if ( spellInfo -> AttributesEx4 & SPELL_ATTR_EX4_SPELL_VS_EXTEND_COST )
2009-07-23 18:32:32 +02:00
powerCost += caster -> GetAttackTime ( OFF_ATTACK ) / 100 ;
// Apply cost mod by spell
2010-04-07 19:14:10 +02:00
if ( Player * modOwner = caster -> GetSpellModOwner ())
2009-07-23 18:32:32 +02:00
modOwner -> ApplySpellMod ( spellInfo -> Id , SPELLMOD_COST , powerCost );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION )
2009-07-23 18:32:32 +02:00
powerCost = int32 ( powerCost / ( 1.117f * spellInfo -> spellLevel / caster -> getLevel () - 0.1327f ));
2009-10-17 15:51:44 -07:00
2009-07-23 18:32:32 +02:00
// PCT mod from user auras by school
powerCost = int32 ( powerCost * ( 1.0f + caster -> GetFloatValue ( UNIT_FIELD_POWER_COST_MULTIPLIER + school )));
if ( powerCost < 0 )
powerCost = 0 ;
return powerCost ;
}
2009-10-17 15:51:44 -07:00
2010-02-20 23:57:54 +01:00
Unit * GetTriggeredSpellCaster ( SpellEntry const * spellInfo , Unit * caster , Unit * target )
{
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
{
if ( SpellTargetType [ spellInfo -> EffectImplicitTargetA [ i ]] == TARGET_TYPE_UNIT_TARGET
|| SpellTargetType [ spellInfo -> EffectImplicitTargetB [ i ]] == TARGET_TYPE_UNIT_TARGET
|| SpellTargetType [ spellInfo -> EffectImplicitTargetA [ i ]] == TARGET_TYPE_CHANNEL
|| SpellTargetType [ spellInfo -> EffectImplicitTargetB [ i ]] == TARGET_TYPE_CHANNEL
|| SpellTargetType [ spellInfo -> EffectImplicitTargetA [ i ]] == TARGET_TYPE_DEST_TARGET
|| SpellTargetType [ spellInfo -> EffectImplicitTargetB [ i ]] == TARGET_TYPE_DEST_TARGET )
return caster ;
}
return target ;
}
2009-07-30 17:16:56 +02:00
AuraState GetSpellAuraState ( SpellEntry const * spellInfo )
{
// Seals
if ( IsSealSpell ( spellInfo ))
2009-08-11 19:57:27 +02:00
return AURA_STATE_JUDGEMENT ;
2009-10-17 15:51:44 -07:00
2009-07-30 17:16:56 +02:00
// Conflagrate aura state on Immolate and Shadowflame
if ( spellInfo -> SpellFamilyName == SPELLFAMILY_WARLOCK &&
// Immolate
(( spellInfo -> SpellFamilyFlags [ 0 ] & 4 ) ||
// Shadowflame
( spellInfo -> SpellFamilyFlags [ 2 ] & 2 )))
2009-08-11 19:57:27 +02:00
return AURA_STATE_CONFLAGRATE ;
2009-10-17 15:51:44 -07:00
2009-07-30 17:16:56 +02:00
// Faerie Fire (druid versions)
if ( spellInfo -> SpellFamilyName == SPELLFAMILY_DRUID && spellInfo -> SpellFamilyFlags [ 0 ] & 0x400 )
2009-08-11 19:57:27 +02:00
return AURA_STATE_FAERIE_FIRE ;
2009-10-17 15:51:44 -07:00
2009-07-30 17:16:56 +02:00
// Sting (hunter's pet ability)
if ( spellInfo -> Category == 1133 )
2009-08-11 19:57:27 +02:00
return AURA_STATE_FAERIE_FIRE ;
2009-10-17 15:51:44 -07:00
2009-07-30 17:16:56 +02:00
// Victorious
if ( spellInfo -> SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo -> SpellFamilyFlags [ 1 ] & 0x00040000 )
2009-08-11 19:57:27 +02:00
return AURA_STATE_WARRIOR_VICTORY_RUSH ;
2009-10-17 15:51:44 -07:00
2009-07-30 17:16:56 +02:00
// Swiftmend state on Regrowth & Rejuvenation
2010-04-07 22:59:46 +02:00
if ( spellInfo -> SpellFamilyName == SPELLFAMILY_DRUID && spellInfo -> SpellFamilyFlags [ 0 ] & 0x50 )
2009-08-11 19:57:27 +02:00
return AURA_STATE_SWIFTMEND ;
2009-10-17 15:51:44 -07:00
2009-07-30 17:16:56 +02:00
// Deadly poison aura state
2010-04-07 19:14:10 +02:00
if ( spellInfo -> SpellFamilyName == SPELLFAMILY_ROGUE && spellInfo -> SpellFamilyFlags [ 0 ] & 0x10000 )
2009-08-11 19:57:27 +02:00
return AURA_STATE_DEADLY_POISON ;
2009-10-17 15:51:44 -07:00
2009-07-30 17:16:56 +02:00
// Enrage aura state
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Dispel == DISPEL_ENRAGE )
2009-08-11 19:57:27 +02:00
return AURA_STATE_ENRAGE ;
2009-10-17 15:51:44 -07:00
2009-07-30 17:16:56 +02:00
// Bleeding aura state
if ( GetAllSpellMechanicMask ( spellInfo ) & 1 << MECHANIC_BLEED )
2009-08-11 19:57:27 +02:00
return AURA_STATE_BLEEDING ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( GetSpellSchoolMask ( spellInfo ) & SPELL_SCHOOL_MASK_FROST )
2009-07-30 17:16:56 +02:00
{
2009-10-17 16:20:24 -07:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-07-30 17:16:56 +02:00
{
2010-04-07 23:25:02 +02:00
if ( spellInfo -> EffectApplyAuraName [ i ] == SPELL_AURA_MOD_STUN
|| spellInfo -> EffectApplyAuraName [ i ] == SPELL_AURA_MOD_ROOT )
2009-08-11 19:57:27 +02:00
return AURA_STATE_FROZEN ;
2009-07-30 17:16:56 +02:00
}
}
return AURA_STATE_NONE ;
}
2009-10-17 15:51:44 -07:00
2010-01-20 20:54:32 +01:00
SpellSpecific GetSpellSpecific ( SpellEntry const * spellInfo )
2008-11-17 22:07:21 -06:00
{
switch ( spellInfo -> SpellFamilyName )
{
2008-11-28 20:19:37 +01:00
case SPELLFAMILY_GENERIC :
{
2009-08-24 20:17:33 -05:00
// Food / Drinks (mostly)
2010-04-07 19:14:10 +02:00
if ( spellInfo -> AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED )
2008-12-13 14:35:56 -06:00
{
2009-08-24 20:17:33 -05:00
bool food = false ;
bool drink = false ;
2010-09-28 08:21:51 +03:00
for ( int i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-08-24 20:17:33 -05:00
{
switch ( spellInfo -> EffectApplyAuraName [ i ])
{
// Food
case SPELL_AURA_MOD_REGEN :
case SPELL_AURA_OBS_MOD_HEALTH :
food = true ;
break ;
// Drink
case SPELL_AURA_MOD_POWER_REGEN :
case SPELL_AURA_OBS_MOD_POWER :
drink = true ;
break ;
default :
break ;
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( food && drink )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_FOOD_AND_DRINK ;
2010-04-07 19:14:10 +02:00
else if ( food )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_FOOD ;
2010-04-07 19:14:10 +02:00
else if ( drink )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_DRINK ;
2008-12-13 14:35:56 -06:00
}
2009-03-10 16:44:03 +01:00
// scrolls effects
else
{
2010-08-08 05:25:45 +02:00
uint32 firstSpell = sSpellMgr . GetFirstSpellInChain ( spellInfo -> Id );
2009-03-10 16:44:03 +01:00
switch ( firstSpell )
{
2009-05-25 11:08:52 -05:00
case 8118 : // Strength
case 8099 : // Stamina
case 8112 : // Spirit
case 8096 : // Intellect
case 8115 : // Agility
case 8091 : // Armor
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_SCROLL ;
2009-05-25 11:19:13 -05:00
case 12880 : // Enrage (Enrage)
case 57518 : // Enrage (Wrecking Crew)
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_WARRIOR_ENRAGE ;
2009-03-10 16:44:03 +01:00
}
}
2008-11-28 20:19:37 +01:00
break ;
}
2008-11-17 22:07:21 -06:00
case SPELLFAMILY_MAGE :
{
// family flags 18(Molten), 25(Frost/Ice), 28(Mage)
2009-02-02 17:01:56 +01:00
if ( spellInfo -> SpellFamilyFlags [ 0 ] & 0x12040000 )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_MAGE_ARMOR ;
2009-10-17 15:51:44 -07:00
2009-05-03 16:55:09 +02:00
// Arcane brillance and Arcane intelect (normal check fails because of flags difference)
if ( spellInfo -> SpellFamilyFlags [ 0 ] & 0x400 )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_MAGE_ARCANE_BRILLANCE ;
2009-10-17 15:51:44 -07:00
2010-04-07 23:25:02 +02:00
if (( spellInfo -> SpellFamilyFlags [ 0 ] & 0x1000000 ) && spellInfo -> EffectApplyAuraName [ 0 ] == SPELL_AURA_MOD_CONFUSE )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_MAGE_POLYMORPH ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
break ;
}
case SPELLFAMILY_WARRIOR :
{
2009-08-12 18:51:19 +02:00
if ( spellInfo -> Id == 12292 ) // Death Wish
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_WARRIOR_ENRAGE ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
break ;
}
case SPELLFAMILY_WARLOCK :
{
// only warlock curses have this
if ( spellInfo -> Dispel == DISPEL_CURSE )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_CURSE ;
2009-10-17 15:51:44 -07:00
2009-01-30 19:26:53 -06:00
// Warlock (Demon Armor | Demon Skin | Fel Armor)
2009-02-02 17:01:56 +01:00
if ( spellInfo -> SpellFamilyFlags [ 1 ] & 0x20000020 || spellInfo -> SpellFamilyFlags [ 2 ] & 0x00000010 )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_WARLOCK_ARMOR ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
//seed of corruption and corruption
2009-02-02 17:01:56 +01:00
if ( spellInfo -> SpellFamilyFlags [ 1 ] & 0x10 || spellInfo -> SpellFamilyFlags [ 0 ] & 0x2 )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_WARLOCK_CORRUPTION ;
2008-11-17 22:07:21 -06:00
break ;
}
2009-08-24 19:12:22 -05:00
case SPELLFAMILY_PRIEST :
{
// Divine Spirit and Prayer of Spirit
if ( spellInfo -> SpellFamilyFlags [ 0 ] & 0x20 )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_PRIEST_DIVINE_SPIRIT ;
2009-10-17 15:51:44 -07:00
2009-08-24 19:12:22 -05:00
break ;
}
2008-11-17 22:07:21 -06:00
case SPELLFAMILY_HUNTER :
{
// only hunter stings have this
if ( spellInfo -> Dispel == DISPEL_POISON )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_STING ;
2009-10-17 15:51:44 -07:00
2009-08-02 09:51:11 +08:00
// only hunter aspects have this (but not all aspects in hunter family)
2010-04-07 22:59:46 +02:00
if ( spellInfo -> SpellFamilyFlags . HasFlag ( 0x00380000 , 0x00440000 , 0x00001010 ))
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_ASPECT ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
break ;
}
case SPELLFAMILY_PALADIN :
{
if ( IsSealSpell ( spellInfo ))
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_SEAL ;
2009-10-17 15:51:44 -07:00
2009-08-05 16:11:12 -05:00
if ( spellInfo -> SpellFamilyFlags [ 0 ] & 0x00002190 )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_HAND ;
2009-10-17 15:51:44 -07:00
2009-07-19 14:02:52 +02:00
// Judgement of Wisdom, Judgement of Light, Judgement of Justice
if ( spellInfo -> Id == 20184 || spellInfo -> Id == 20185 || spellInfo -> Id == 20186 )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_JUDGEMENT ;
2009-10-17 15:51:44 -07:00
2009-08-02 09:51:11 +08:00
// only paladin auras have this (for palaldin class family)
2010-04-07 22:59:46 +02:00
if ( spellInfo -> SpellFamilyFlags [ 2 ] & 0x00000020 )
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_AURA ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
break ;
}
case SPELLFAMILY_SHAMAN :
{
if ( IsElementalShield ( spellInfo ))
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_ELEMENTAL_SHIELD ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
break ;
}
2009-10-17 15:51:44 -07:00
2008-12-29 12:22:49 -06:00
case SPELLFAMILY_DEATHKNIGHT :
2010-02-15 18:23:39 +01:00
if ( spellInfo -> Id == 48266 || spellInfo -> Id == 48263 || spellInfo -> Id == 48265 )
2009-08-02 09:51:11 +08:00
//if (spellInfo->Category == 47)
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_PRESENCE ;
2008-12-29 12:22:49 -06:00
break ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2010-09-28 08:21:51 +03:00
for ( int i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-02-18 16:26:02 -06:00
{
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Effect [ i ] == SPELL_EFFECT_APPLY_AURA )
2009-02-18 16:26:02 -06:00
{
switch ( spellInfo -> EffectApplyAuraName [ i ])
{
case SPELL_AURA_MOD_CHARM :
case SPELL_AURA_MOD_POSSESS_PET :
case SPELL_AURA_MOD_POSSESS :
2009-06-07 23:32:35 -05:00
case SPELL_AURA_AOE_CHARM :
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_CHARM ;
2009-04-06 13:31:14 +02:00
case SPELL_AURA_TRACK_CREATURES :
case SPELL_AURA_TRACK_RESOURCES :
case SPELL_AURA_TRACK_STEALTHED :
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_TRACKER ;
2009-08-13 00:52:05 +02:00
case SPELL_AURA_PHASE :
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_PHASE ;
2009-02-18 16:26:02 -06:00
}
}
}
2009-10-17 15:51:44 -07:00
2010-01-10 01:23:15 +01:00
return SPELL_SPECIFIC_NORMAL ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-08-24 20:17:33 -05:00
// target not allow have more one spell specific from same caster
bool IsSingleFromSpellSpecificPerCaster ( SpellSpecific spellSpec1 , SpellSpecific spellSpec2 )
2008-11-17 22:07:21 -06:00
{
switch ( spellSpec1 )
{
2010-01-10 01:23:15 +01:00
case SPELL_SPECIFIC_SEAL :
case SPELL_SPECIFIC_HAND :
case SPELL_SPECIFIC_AURA :
case SPELL_SPECIFIC_STING :
case SPELL_SPECIFIC_CURSE :
case SPELL_SPECIFIC_ASPECT :
case SPELL_SPECIFIC_JUDGEMENT :
case SPELL_SPECIFIC_WARLOCK_CORRUPTION :
2010-04-07 23:25:02 +02:00
return spellSpec1 == spellSpec2 ;
2008-11-20 18:13:10 -06:00
default :
return false ;
}
}
2009-10-17 15:51:44 -07:00
2009-08-24 20:17:33 -05:00
bool IsSingleFromSpellSpecificPerTarget ( SpellSpecific spellSpec1 , SpellSpecific spellSpec2 )
2008-11-20 18:13:10 -06:00
{
switch ( spellSpec1 )
{
2010-01-10 01:23:15 +01:00
case SPELL_SPECIFIC_PHASE :
case SPELL_SPECIFIC_TRACKER :
case SPELL_SPECIFIC_WARLOCK_ARMOR :
case SPELL_SPECIFIC_MAGE_ARMOR :
case SPELL_SPECIFIC_ELEMENTAL_SHIELD :
case SPELL_SPECIFIC_MAGE_POLYMORPH :
case SPELL_SPECIFIC_PRESENCE :
case SPELL_SPECIFIC_CHARM :
case SPELL_SPECIFIC_SCROLL :
case SPELL_SPECIFIC_WARRIOR_ENRAGE :
case SPELL_SPECIFIC_MAGE_ARCANE_BRILLANCE :
case SPELL_SPECIFIC_PRIEST_DIVINE_SPIRIT :
2010-04-07 23:25:02 +02:00
return spellSpec1 == spellSpec2 ;
2010-01-10 01:23:15 +01:00
case SPELL_SPECIFIC_FOOD :
2010-04-07 23:25:02 +02:00
return spellSpec2 == SPELL_SPECIFIC_FOOD
|| spellSpec2 == SPELL_SPECIFIC_FOOD_AND_DRINK ;
2010-01-10 01:23:15 +01:00
case SPELL_SPECIFIC_DRINK :
2010-04-07 23:25:02 +02:00
return spellSpec2 == SPELL_SPECIFIC_DRINK
|| spellSpec2 == SPELL_SPECIFIC_FOOD_AND_DRINK ;
2010-01-10 01:23:15 +01:00
case SPELL_SPECIFIC_FOOD_AND_DRINK :
2010-04-07 23:25:02 +02:00
return spellSpec2 == SPELL_SPECIFIC_FOOD
|| spellSpec2 == SPELL_SPECIFIC_DRINK
|| spellSpec2 == SPELL_SPECIFIC_FOOD_AND_DRINK ;
2008-11-17 22:07:21 -06:00
default :
return false ;
}
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool IsPositiveTarget ( uint32 targetA , uint32 targetB )
{
// non-positive targets
switch ( targetA )
{
2010-01-10 13:48:57 +01:00
case TARGET_UNIT_NEARBY_ENEMY :
2009-05-02 11:28:11 -05:00
case TARGET_UNIT_TARGET_ENEMY :
case TARGET_UNIT_AREA_ENEMY_SRC :
case TARGET_UNIT_AREA_ENEMY_DST :
case TARGET_UNIT_CONE_ENEMY :
2009-04-30 22:04:15 -05:00
case TARGET_DEST_DYNOBJ_ENEMY :
2009-05-02 11:28:11 -05:00
case TARGET_DST_TARGET_ENEMY :
2008-11-17 22:07:21 -06:00
return false ;
default :
break ;
}
if ( targetB )
return IsPositiveTarget ( targetB , 0 );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-08-06 11:24:14 -05:00
bool SpellMgr :: _isPositiveEffect ( uint32 spellId , uint32 effIndex , bool deep ) const
2008-11-17 22:07:21 -06:00
{
SpellEntry const * spellproto = sSpellStore . LookupEntry ( spellId );
if ( ! spellproto ) return false ;
2009-10-17 15:51:44 -07:00
2010-01-10 13:48:57 +01:00
// not found a single positive spell with this attribute
if ( spellproto -> Attributes & SPELL_ATTR_NEGATIVE_1 )
return false ;
2010-06-23 03:45:44 +02:00
switch ( spellproto -> SpellFamilyName )
2008-11-17 22:07:21 -06:00
{
2010-06-23 03:45:44 +02:00
case SPELLFAMILY_GENERIC :
switch ( spellId )
{
case 34700 : // Allergic Reaction
case 61987 : // Avenging Wrath Marker
case 61988 : // Divine Shield exclude aura
return false ;
case 30877 : // Tag Murloc
return true ;
default :
break ;
}
break ;
case SPELLFAMILY_MAGE :
// Amplify Magic, Dampen Magic
if ( spellproto -> SpellFamilyFlags [ 0 ] == 0x00002000 )
return true ;
break ;
case SPELLFAMILY_PRIEST :
switch ( spellId )
{
case 64844 : // Divine Hymn
case 64904 : // Hymn of Hope
case 47585 : // Dispersion
return true ;
default :
break ;
}
break ;
2010-06-28 20:34:11 +02:00
case SPELLFAMILY_HUNTER :
// Aspect of the Viper
if ( spellId == 34074 )
return true ;
break ;
2010-09-05 14:34:48 -07:00
case SPELLFAMILY_SHAMAN :
if ( spellId == 30708 )
return false ;
break ;
2010-06-23 03:45:44 +02:00
default :
break ;
2009-03-18 21:04:46 +01:00
}
2009-10-17 15:51:44 -07:00
2010-06-23 03:45:44 +02:00
switch ( spellproto -> Mechanic )
2009-03-18 21:04:46 +01:00
{
2009-03-20 19:53:26 +01:00
case MECHANIC_IMMUNE_SHIELD :
2009-03-18 21:04:46 +01:00
return true ;
default :
break ;
}
2009-10-17 15:51:44 -07:00
2009-06-17 01:12:40 +02:00
// Special case: effects which determine positivity of whole spell
2009-10-17 16:20:24 -07:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-06-17 01:12:40 +02:00
{
if ( spellproto -> EffectApplyAuraName [ i ] == SPELL_AURA_MOD_STEALTH )
return true ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
switch ( spellproto -> Effect [ effIndex ])
{
2009-08-12 20:42:07 -05:00
case SPELL_EFFECT_DUMMY :
// some explicitly required dummy effect sets
switch ( spellId )
{
case 28441 : return false ; // AB Effect 000
default :
break ;
}
break ;
2008-11-17 22:07:21 -06:00
// always positive effects (check before target checks that provided non-positive result in some case for positive effects)
case SPELL_EFFECT_HEAL :
case SPELL_EFFECT_LEARN_SPELL :
case SPELL_EFFECT_SKILL_STEP :
case SPELL_EFFECT_HEAL_PCT :
case SPELL_EFFECT_ENERGIZE_PCT :
return true ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// non-positive aura use
case SPELL_EFFECT_APPLY_AURA :
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND :
{
switch ( spellproto -> EffectApplyAuraName [ effIndex ])
{
case SPELL_AURA_MOD_DAMAGE_DONE : // dependent from bas point sign (negative -> negative)
2009-08-12 20:42:07 -05:00
case SPELL_AURA_MOD_STAT :
case SPELL_AURA_MOD_SKILL :
case SPELL_AURA_MOD_HEALING_PCT :
2008-11-17 22:07:21 -06:00
case SPELL_AURA_MOD_HEALING_DONE :
2009-03-13 22:48:04 +01:00
case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE :
2010-07-14 16:57:13 +02:00
if ( SpellMgr :: CalculateSpellEffectAmount ( spellproto , effIndex ) < 0 )
2008-11-17 22:07:21 -06:00
return false ;
break ;
2009-08-12 20:42:07 -05:00
case SPELL_AURA_MOD_DAMAGE_TAKEN : // dependent from bas point sign (positive -> negative)
2010-07-14 16:57:13 +02:00
if ( SpellMgr :: CalculateSpellEffectAmount ( spellproto , effIndex ) > 0 )
2009-08-12 20:42:07 -05:00
return false ;
break ;
2009-08-17 16:30:14 +02:00
case SPELL_AURA_MOD_CRIT_PCT :
2009-05-31 16:01:19 -05:00
case SPELL_AURA_MOD_SPELL_CRIT_CHANCE :
2010-07-14 16:57:13 +02:00
if ( SpellMgr :: CalculateSpellEffectAmount ( spellproto , effIndex ) > 0 )
2009-08-12 20:42:07 -05:00
return true ; // some expected positive spells have SPELL_ATTR_EX_NEGATIVE
2009-05-31 16:01:19 -05:00
break ;
2008-11-17 22:07:21 -06:00
case SPELL_AURA_ADD_TARGET_TRIGGER :
return true ;
2009-04-23 20:57:17 +02:00
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE :
2008-11-17 22:07:21 -06:00
case SPELL_AURA_PERIODIC_TRIGGER_SPELL :
2010-04-07 19:14:10 +02:00
if ( ! deep )
2009-04-09 17:32:22 +02:00
{
uint32 spellTriggeredId = spellproto -> EffectTriggerSpell [ effIndex ];
SpellEntry const * spellTriggeredProto = sSpellStore . LookupEntry ( spellTriggeredId );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( spellTriggeredProto )
2009-04-09 17:32:22 +02:00
{
// non-positive targets of main spell return early
2010-09-28 08:21:51 +03:00
for ( int i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-04-09 17:32:22 +02:00
{
2009-04-10 16:59:34 +02:00
if ( ! spellTriggeredProto -> Effect [ i ])
continue ;
2009-04-09 17:32:22 +02:00
// if non-positive trigger cast targeted to positive target this main cast is non-positive
// this will place this spell auras as debuffs
2010-04-07 19:14:10 +02:00
if ( IsPositiveTarget ( spellTriggeredProto -> EffectImplicitTargetA [ effIndex ], spellTriggeredProto -> EffectImplicitTargetB [ effIndex ]) && ! _isPositiveEffect ( spellTriggeredId , i , true ))
2009-04-09 17:32:22 +02:00
return false ;
}
}
}
2008-11-17 22:07:21 -06:00
case SPELL_AURA_PROC_TRIGGER_SPELL :
// many positive auras have negative triggered spells at damage for example and this not make it negative (it can be canceled for example)
break ;
case SPELL_AURA_MOD_STUN : //have positive and negative spells, we can't sort its correctly at this moment.
2010-04-07 23:25:02 +02:00
if ( effIndex == 0 && spellproto -> Effect [ 1 ] == 0 && spellproto -> Effect [ 2 ] == 0 )
2008-11-17 22:07:21 -06:00
return false ; // but all single stun aura spells is negative
break ;
2009-08-12 20:58:58 -05:00
case SPELL_AURA_MOD_PACIFY_SILENCE :
2010-04-07 19:14:10 +02:00
if ( spellproto -> Id == 24740 ) // Wisp Costume
2009-08-12 20:58:58 -05:00
return true ;
return false ;
2008-11-17 22:07:21 -06:00
case SPELL_AURA_MOD_ROOT :
case SPELL_AURA_MOD_SILENCE :
case SPELL_AURA_GHOST :
case SPELL_AURA_PERIODIC_LEECH :
case SPELL_AURA_MOD_STALKED :
case SPELL_AURA_PERIODIC_DAMAGE_PERCENT :
2010-07-16 13:20:50 +02:00
case SPELL_AURA_PREVENT_RESSURECTION :
2008-11-17 22:07:21 -06:00
return false ;
case SPELL_AURA_PERIODIC_DAMAGE : // used in positive spells also.
// part of negative spell if casted at self (prevent cancel)
2010-04-07 19:14:10 +02:00
if ( spellproto -> EffectImplicitTargetA [ effIndex ] == TARGET_UNIT_CASTER )
2008-11-17 22:07:21 -06:00
return false ;
break ;
case SPELL_AURA_MOD_DECREASE_SPEED : // used in positive spells also
// part of positive spell if casted at self
2010-04-07 19:14:10 +02:00
if ( spellproto -> EffectImplicitTargetA [ effIndex ] != TARGET_UNIT_CASTER )
2008-11-17 22:07:21 -06:00
return false ;
2010-01-18 20:15:23 +01:00
// but not this if this first effect (didn't find better check)
2010-09-28 08:21:51 +03:00
if ( spellproto -> Attributes & SPELL_ATTR_NEGATIVE_1 && effIndex == 0 )
2008-11-17 22:07:21 -06:00
return false ;
break ;
case SPELL_AURA_MECHANIC_IMMUNITY :
{
// non-positive immunities
switch ( spellproto -> EffectMiscValue [ effIndex ])
{
case MECHANIC_BANDAGE :
case MECHANIC_SHIELD :
case MECHANIC_MOUNT :
case MECHANIC_INVULNERABILITY :
return false ;
default :
break ;
}
} break ;
case SPELL_AURA_ADD_FLAT_MODIFIER : // mods
case SPELL_AURA_ADD_PCT_MODIFIER :
{
// non-positive mods
switch ( spellproto -> EffectMiscValue [ effIndex ])
{
case SPELLMOD_COST : // dependent from bas point sign (negative -> positive)
2010-07-14 16:57:13 +02:00
if ( SpellMgr :: CalculateSpellEffectAmount ( spellproto , effIndex ) > 0 )
2009-04-14 19:09:08 +02:00
{
if ( ! deep )
{
bool negative = true ;
2009-10-17 16:20:24 -07:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-04-14 19:09:08 +02:00
{
if ( i != effIndex )
2009-08-06 11:24:14 -05:00
if ( _isPositiveEffect ( spellId , i , true ))
2009-04-14 19:09:08 +02:00
{
negative = false ;
break ;
}
}
if ( negative )
return false ;
}
}
2008-11-17 22:07:21 -06:00
break ;
default :
break ;
}
} break ;
default :
break ;
}
break ;
}
default :
break ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// non-positive targets
2010-04-07 19:14:10 +02:00
if ( ! IsPositiveTarget ( spellproto -> EffectImplicitTargetA [ effIndex ], spellproto -> EffectImplicitTargetB [ effIndex ]))
2008-11-17 22:07:21 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// AttributesEx check
2010-04-07 19:14:10 +02:00
if ( spellproto -> AttributesEx & SPELL_ATTR_EX_NEGATIVE )
2008-11-17 22:07:21 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2009-03-14 13:34:05 +01:00
if ( ! deep && spellproto -> EffectTriggerSpell [ effIndex ]
2009-04-10 16:59:34 +02:00
&& ! spellproto -> EffectApplyAuraName [ effIndex ]
2009-03-14 13:34:05 +01:00
&& IsPositiveTarget ( spellproto -> EffectImplicitTargetA [ effIndex ], spellproto -> EffectImplicitTargetB [ effIndex ])
2009-08-06 11:24:14 -05:00
&& ! _isPositiveSpell ( spellproto -> EffectTriggerSpell [ effIndex ], true ))
2009-03-11 22:27:07 +01:00
return false ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// ok, positive
return true ;
}
2009-10-17 15:51:44 -07:00
2009-08-06 11:24:14 -05:00
bool IsPositiveSpell ( uint32 spellId )
{
2010-04-07 19:14:10 +02:00
if ( ! sSpellStore . LookupEntry ( spellId )) // non-existing spells
2009-08-11 11:32:32 -05:00
return false ;
2010-08-08 05:25:45 +02:00
return ! ( sSpellMgr . GetSpellCustomAttr ( spellId ) & SPELL_ATTR_CU_NEGATIVE );
2009-08-06 11:24:14 -05:00
}
2009-10-17 15:51:44 -07:00
2009-08-06 11:24:14 -05:00
bool IsPositiveEffect ( uint32 spellId , uint32 effIndex )
{
2010-04-07 19:14:10 +02:00
if ( ! sSpellStore . LookupEntry ( spellId ))
2009-08-11 11:32:32 -05:00
return false ;
2009-08-06 11:24:14 -05:00
switch ( effIndex )
{
default :
2010-08-08 05:25:45 +02:00
case 0 : return ! ( sSpellMgr . GetSpellCustomAttr ( spellId ) & SPELL_ATTR_CU_NEGATIVE_EFF0 );
case 1 : return ! ( sSpellMgr . GetSpellCustomAttr ( spellId ) & SPELL_ATTR_CU_NEGATIVE_EFF1 );
case 2 : return ! ( sSpellMgr . GetSpellCustomAttr ( spellId ) & SPELL_ATTR_CU_NEGATIVE_EFF2 );
2009-08-06 11:24:14 -05:00
}
}
2009-10-17 15:51:44 -07:00
2009-08-06 11:24:14 -05:00
bool SpellMgr :: _isPositiveSpell ( uint32 spellId , bool deep ) const
2008-11-17 22:07:21 -06:00
{
SpellEntry const * spellproto = sSpellStore . LookupEntry ( spellId );
if ( ! spellproto ) return false ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// spells with at least one negative effect are considered negative
// some self-applied spells have negative effects but in self casting case negative check ignored.
2010-09-28 08:21:51 +03:00
for ( int i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-08-06 11:24:14 -05:00
if ( ! _isPositiveEffect ( spellId , i , deep ))
2008-11-17 22:07:21 -06:00
return false ;
return true ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool IsSingleTargetSpell ( SpellEntry const * spellInfo )
{
// all other single target spells have if it has AttributesEx5
2010-04-07 22:59:46 +02:00
if ( spellInfo -> AttributesEx5 & SPELL_ATTR_EX5_SINGLE_TARGET_SPELL )
2008-11-17 22:07:21 -06:00
return true ;
2009-10-17 15:51:44 -07:00
2010-01-20 20:54:32 +01:00
switch ( GetSpellSpecific ( spellInfo ))
2008-11-17 22:07:21 -06:00
{
2010-01-10 01:23:15 +01:00
case SPELL_SPECIFIC_JUDGEMENT :
2008-11-17 22:07:21 -06:00
return true ;
2009-05-03 22:21:46 -05:00
default :
break ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
return false ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool IsSingleTargetSpells ( SpellEntry const * spellInfo1 , SpellEntry const * spellInfo2 )
{
// TODO - need better check
// Equal icon and spellfamily
2010-04-07 22:59:46 +02:00
if ( spellInfo1 -> SpellFamilyName == spellInfo2 -> SpellFamilyName &&
spellInfo1 -> SpellIconID == spellInfo2 -> SpellIconID )
2008-11-17 22:07:21 -06:00
return true ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// TODO - need found Judgements rule
2010-01-20 20:54:32 +01:00
SpellSpecific spec1 = GetSpellSpecific ( spellInfo1 );
2008-11-17 22:07:21 -06:00
// spell with single target specific types
switch ( spec1 )
{
2010-01-10 01:23:15 +01:00
case SPELL_SPECIFIC_JUDGEMENT :
case SPELL_SPECIFIC_MAGE_POLYMORPH :
2010-04-07 19:14:10 +02:00
if ( GetSpellSpecific ( spellInfo2 ) == spec1 )
2008-11-17 22:07:21 -06:00
return true ;
break ;
2009-05-03 22:21:46 -05:00
default :
break ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
return false ;
}
2009-10-17 15:51:44 -07:00
2009-03-16 12:00:14 -06:00
SpellCastResult GetErrorAtShapeshiftedCast ( SpellEntry const * spellInfo , uint32 form )
2008-11-17 22:07:21 -06:00
{
// talents that learn spells can have stance requirements that need ignore
// (this requirement only for client-side stance show in talent description)
2010-04-07 22:59:46 +02:00
if ( GetTalentSpellCost ( spellInfo -> Id ) > 0 &&
2010-04-07 23:25:02 +02:00
( spellInfo -> Effect [ 0 ] == SPELL_EFFECT_LEARN_SPELL || spellInfo -> Effect [ 1 ] == SPELL_EFFECT_LEARN_SPELL || spellInfo -> Effect [ 2 ] == SPELL_EFFECT_LEARN_SPELL ))
2009-03-16 12:00:14 -06:00
return SPELL_CAST_OK ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
uint32 stanceMask = ( form ? 1 << ( form - 1 ) : 0 );
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
if ( stanceMask & spellInfo -> StancesNot ) // can explicitly not be casted in this stance
return SPELL_FAILED_NOT_SHAPESHIFT ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
if ( stanceMask & spellInfo -> Stances ) // can explicitly be casted in this stance
2009-03-16 12:00:14 -06:00
return SPELL_CAST_OK ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool actAsShifted = false ;
2009-06-07 22:13:17 +02:00
SpellShapeshiftEntry const * shapeInfo = NULL ;
2008-11-17 22:07:21 -06:00
if ( form > 0 )
{
2009-06-07 22:13:17 +02:00
shapeInfo = sSpellShapeshiftStore . LookupEntry ( form );
2008-11-17 22:07:21 -06:00
if ( ! shapeInfo )
{
sLog . outError ( "GetErrorAtShapeshiftedCast: unknown shapeshift %u" , form );
2009-03-16 12:00:14 -06:00
return SPELL_CAST_OK ;
2008-11-17 22:07:21 -06:00
}
actAsShifted = ! ( shapeInfo -> flags1 & 1 ); // shapeshift acts as normal form for spells
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( actAsShifted )
2008-11-17 22:07:21 -06:00
{
if ( spellInfo -> Attributes & SPELL_ATTR_NOT_SHAPESHIFT ) // not while shapeshifted
return SPELL_FAILED_NOT_SHAPESHIFT ;
else if ( spellInfo -> Stances != 0 ) // needs other shapeshift
return SPELL_FAILED_ONLY_SHAPESHIFT ;
}
else
{
// needs shapeshift
2010-04-07 19:14:10 +02:00
if ( ! ( spellInfo -> AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT ) && spellInfo -> Stances != 0 )
2008-11-17 22:07:21 -06:00
return SPELL_FAILED_ONLY_SHAPESHIFT ;
2009-06-07 22:13:17 +02:00
}
2009-10-17 15:51:44 -07:00
2009-06-07 22:13:17 +02:00
// Check if stance disables cast of not-stance spells
// Example: cannot cast any other spells in zombie or ghoul form
// TODO: Find a way to disable use of these spells clientside
if ( shapeInfo && shapeInfo -> flags1 & 0x400 )
{
2010-04-07 19:14:10 +02:00
if ( ! ( stanceMask & spellInfo -> Stances ))
2009-06-07 22:13:17 +02:00
return SPELL_FAILED_ONLY_SHAPESHIFT ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-03-16 12:00:14 -06:00
return SPELL_CAST_OK ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
void SpellMgr :: LoadSpellTargetPositions ()
{
mSpellTargetPositions . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// 0 1 2 3 4 5
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM spell_target_position" );
2010-04-07 22:59:46 +02:00
if ( ! result )
2008-11-17 22:07:21 -06:00
{
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
barGoLink bar ( 1 );
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell target coordinates" , count );
2008-11-17 22:07:21 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
barGoLink bar ( result -> GetRowCount ());
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
do
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bar . step ();
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
uint32 Spell_ID = fields [ 0 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
SpellTargetPosition st ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
st . target_mapId = fields [ 1 ]. GetUInt32 ();
st . target_X = fields [ 2 ]. GetFloat ();
st . target_Y = fields [ 3 ]. GetFloat ();
st . target_Z = fields [ 4 ]. GetFloat ();
st . target_Orientation = fields [ 5 ]. GetFloat ();
2009-10-17 15:51:44 -07:00
2010-04-18 23:20:07 +02:00
MapEntry const * mapEntry = sMapStore . LookupEntry ( st . target_mapId );
if ( ! mapEntry )
{
sLog . outErrorDb ( "Spell (ID:%u) target map (ID: %u) does not exist in `Map.dbc`." , Spell_ID , st . target_mapId );
continue ;
}
if ( st . target_X == 0 && st . target_Y == 0 && st . target_Z == 0 )
{
sLog . outErrorDb ( "Spell (ID:%u) target coordinates not provided." , Spell_ID );
continue ;
}
2008-11-17 22:07:21 -06:00
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( Spell_ID );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-11-17 22:07:21 -06:00
{
sLog . outErrorDb ( "Spell (ID:%u) listed in `spell_target_position` does not exist." , Spell_ID );
continue ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool found = false ;
2010-09-28 08:21:51 +03:00
for ( int i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2008-11-17 22:07:21 -06:00
{
2010-04-07 23:25:02 +02:00
if ( spellInfo -> EffectImplicitTargetA [ i ] == TARGET_DST_DB || spellInfo -> EffectImplicitTargetB [ i ] == TARGET_DST_DB )
2008-11-17 22:07:21 -06:00
{
2010-04-18 23:20:07 +02:00
// additional requirements
if ( spellInfo -> Effect [ i ] == SPELL_EFFECT_BIND && spellInfo -> EffectMiscValue [ i ])
{
2010-06-25 00:18:01 +02:00
uint32 area_id = sMapMgr . GetAreaId ( st . target_mapId , st . target_X , st . target_Y , st . target_Z );
2010-05-01 22:25:14 +02:00
if ( area_id != uint32 ( spellInfo -> EffectMiscValue [ i ]))
2010-04-18 23:20:07 +02:00
{
sLog . outErrorDb ( "Spell (Id: %u) listed in `spell_target_position` expected point to zone %u bit point to zone %u." , Spell_ID , spellInfo -> EffectMiscValue [ i ], area_id );
break ;
}
}
2008-11-17 22:07:21 -06:00
found = true ;
break ;
}
}
2010-04-07 19:14:10 +02:00
if ( ! found )
2008-11-17 22:07:21 -06:00
{
2009-05-02 11:28:11 -05:00
sLog . outErrorDb ( "Spell (Id: %u) listed in `spell_target_position` does not have target TARGET_DST_DB (17)." , Spell_ID );
2008-11-17 22:07:21 -06:00
continue ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
mSpellTargetPositions [ Spell_ID ] = st ;
2009-09-02 18:11:11 -05:00
++ count ;
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-05-25 16:50:01 -05:00
// Check all spells
2009-10-17 16:20:24 -07:00
for ( uint32 i = 1 ; i < sSpellStore . GetNumRows (); ++ i )
2009-05-25 16:50:01 -05:00
{
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( i );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2009-05-25 16:50:01 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-25 16:50:01 -05:00
bool found = false ;
2010-09-28 08:21:51 +03:00
for ( int j = 0 ; j < MAX_SPELL_EFFECTS ; ++ j )
2009-05-25 16:50:01 -05:00
{
switch ( spellInfo -> EffectImplicitTargetA [ j ])
{
case TARGET_DST_DB :
found = true ;
break ;
}
2010-04-07 19:14:10 +02:00
if ( found )
2009-05-25 16:50:01 -05:00
break ;
switch ( spellInfo -> EffectImplicitTargetB [ j ])
{
case TARGET_DST_DB :
found = true ;
break ;
}
2010-04-07 19:14:10 +02:00
if ( found )
2009-05-25 16:50:01 -05:00
break ;
}
2010-04-07 19:14:10 +02:00
if ( found )
2009-05-25 16:50:01 -05:00
{
2010-08-08 05:25:45 +02:00
// if (!sSpellMgr.GetSpellTargetPosition(i))
2009-12-21 16:28:57 -07:00
// sLog.outDebug("Spell (ID: %u) does not have record in `spell_target_position`", i);
2009-05-25 16:50:01 -05:00
}
}
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell teleport coordinates" , count );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
bool SpellMgr :: IsAffectedByMod ( SpellEntry const * spellInfo , SpellModifier * mod ) const
2008-11-17 22:07:21 -06:00
{
// false for spellInfo == NULL
2008-12-24 09:58:26 -06:00
if ( ! spellInfo || ! mod )
2008-11-17 22:07:21 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
SpellEntry const * affect_spell = sSpellStore . LookupEntry ( mod -> spellId );
// False if affect_spell == NULL or spellFamily not equal
if ( ! affect_spell || affect_spell -> SpellFamilyName != spellInfo -> SpellFamilyName )
2008-11-17 22:07:21 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// true
2009-02-02 17:01:56 +01:00
if ( mod -> mask & spellInfo -> SpellFamilyFlags )
2008-11-17 22:07:21 -06:00
return true ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
return false ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
void SpellMgr :: LoadSpellProcEvents ()
{
mSpellProcEventMap . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2009-01-06 13:45:49 -06:00
// 0 1 2 3 4 5 6 7 8 9 10
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT entry, SchoolMask, SpellFamilyName, SpellFamilyMask0, SpellFamilyMask1, SpellFamilyMask2, procFlags, procEx, ppmRate, CustomChance, Cooldown FROM spell_proc_event" );
2010-04-07 22:59:46 +02:00
if ( ! result )
2008-11-17 22:07:21 -06:00
{
2010-04-07 22:59:46 +02:00
barGoLink bar ( 1 );
2008-11-17 22:07:21 -06:00
bar . step ();
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell proc event conditions" , count );
2008-11-17 22:07:21 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
barGoLink bar ( result -> GetRowCount ());
2008-11-26 15:14:03 -06:00
uint32 customProc = 0 ;
2008-11-17 22:07:21 -06:00
do
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-01-29 19:33:39 -06:00
uint32 entry = fields [ 0 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
const SpellEntry * spell = sSpellStore . LookupEntry ( entry );
if ( ! spell )
2008-11-17 22:07:21 -06:00
{
sLog . outErrorDb ( "Spell %u listed in `spell_proc_event` does not exist" , entry );
continue ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
SpellProcEventEntry spe ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
spe . schoolMask = fields [ 1 ]. GetUInt32 ();
2008-11-26 15:14:03 -06:00
spe . spellFamilyName = fields [ 2 ]. GetUInt32 ();
2009-02-25 21:15:38 +01:00
spe . spellFamilyMask [ 0 ] = fields [ 3 ]. GetUInt32 ();
spe . spellFamilyMask [ 1 ] = fields [ 4 ]. GetUInt32 ();
spe . spellFamilyMask [ 2 ] = fields [ 5 ]. GetUInt32 ();
2009-01-06 13:45:49 -06:00
spe . procFlags = fields [ 6 ]. GetUInt32 ();
spe . procEx = fields [ 7 ]. GetUInt32 ();
spe . ppmRate = fields [ 8 ]. GetFloat ();
spe . customChance = fields [ 9 ]. GetFloat ();
spe . cooldown = fields [ 10 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
mSpellProcEventMap [ entry ] = spe ;
2009-10-17 15:51:44 -07:00
2010-04-07 23:25:02 +02:00
if ( spell -> procFlags == 0 )
2008-11-26 15:14:03 -06:00
{
if ( spe . procFlags == 0 )
{
sLog . outErrorDb ( "Spell %u listed in `spell_proc_event` probally not triggered spell" , entry );
continue ;
}
customProc ++ ;
}
2008-11-17 22:07:21 -06:00
++ count ;
2010-04-07 22:59:46 +02:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2008-11-26 15:14:03 -06:00
if ( customProc )
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u extra spell proc event conditions + %u custom" , count , customProc );
2008-11-26 15:14:03 -06:00
else
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u extra spell proc event conditions" , count );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-01-29 19:33:39 -06:00
void SpellMgr :: LoadSpellBonusess ()
{
mSpellBonusMap . clear (); // need for reload case
uint32 count = 0 ;
2009-07-18 22:18:47 +02:00
// 0 1 2 3 4
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT entry, direct_bonus, dot_bonus, ap_bonus, ap_dot_bonus FROM spell_bonus_data" );
2010-04-07 22:59:46 +02:00
if ( ! result )
2009-01-29 19:33:39 -06:00
{
2010-04-07 22:59:46 +02:00
barGoLink bar ( 1 );
2009-01-29 19:33:39 -06:00
bar . step ();
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell bonus data" , count );
2009-01-29 19:33:39 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
barGoLink bar ( result -> GetRowCount ());
2009-01-29 19:33:39 -06:00
do
{
Field * fields = result -> Fetch ();
bar . step ();
uint32 entry = fields [ 0 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
const SpellEntry * spell = sSpellStore . LookupEntry ( entry );
2009-01-29 19:33:39 -06:00
if ( ! spell )
{
sLog . outErrorDb ( "Spell %u listed in `spell_bonus_data` does not exist" , entry );
continue ;
}
2009-10-17 15:51:44 -07:00
2009-01-29 19:33:39 -06:00
SpellBonusEntry sbe ;
2009-10-17 15:51:44 -07:00
2009-01-29 19:33:39 -06:00
sbe . direct_damage = fields [ 1 ]. GetFloat ();
sbe . dot_damage = fields [ 2 ]. GetFloat ();
sbe . ap_bonus = fields [ 3 ]. GetFloat ();
2009-07-18 22:18:47 +02:00
sbe . ap_dot_bonus = fields [ 4 ]. GetFloat ();
2009-10-17 15:51:44 -07:00
2009-01-29 19:33:39 -06:00
mSpellBonusMap [ entry ] = sbe ;
2009-07-18 22:18:47 +02:00
++ count ;
2010-04-07 22:59:46 +02:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u extra spell bonus data" , count );
2009-01-29 19:33:39 -06:00
}
2009-10-17 15:51:44 -07:00
2009-07-02 14:13:30 +02:00
bool SpellMgr :: IsSpellProcEventCanTriggeredBy ( SpellProcEventEntry const * spellProcEvent , uint32 EventProcFlag , SpellEntry const * procSpell , uint32 procFlags , uint32 procExtra , bool active )
2008-11-26 15:14:03 -06:00
{
// No extra req need
uint32 procEvent_procEx = PROC_EX_NONE ;
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
// check prockFlags for condition
2010-04-07 19:14:10 +02:00
if (( procFlags & EventProcFlag ) == 0 )
2008-11-26 15:14:03 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2009-05-17 18:00:33 +02:00
bool hasFamilyMask = false ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:59:27 +02:00
/* Check Periodic Auras
2009-10-17 15:51:44 -07:00
2009-07-18 22:18:47 +02:00
*Dots can trigger if spell has no PROC_FLAG_SUCCESSFUL_NEGATIVE_MAGIC_SPELL
nor PROC_FLAG_TAKEN_POSITIVE_MAGIC_SPELL
2009-10-17 15:51:44 -07:00
2009-07-18 22:18:47 +02:00
*Only Hots can trigger if spell has PROC_FLAG_TAKEN_POSITIVE_MAGIC_SPELL
2009-10-17 15:51:44 -07:00
2009-07-18 22:18:47 +02:00
*Only dots can trigger if spell has both positivity flags or PROC_FLAG_SUCCESSFUL_NEGATIVE_MAGIC_SPELL
2009-10-17 15:51:44 -07:00
2009-07-18 22:18:47 +02:00
*Aura has to have PROC_FLAG_TAKEN_POSITIVE_MAGIC_SPELL or spellfamily specified to trigger from Hot
2009-10-17 15:51:44 -07:00
2009-05-15 16:59:27 +02:00
*/
2009-10-17 15:51:44 -07:00
2010-10-08 19:17:49 +02:00
if ( procFlags & PROC_FLAG_DONE_PERIODIC )
2009-05-15 16:59:27 +02:00
{
2010-10-08 19:17:49 +02:00
if ( EventProcFlag & PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG )
2009-05-15 16:59:27 +02:00
{
2009-06-15 18:27:41 +02:00
if ( ! ( procExtra & PROC_EX_INTERNAL_DOT ))
2009-05-15 16:59:27 +02:00
return false ;
}
2009-07-18 22:18:47 +02:00
else if ( procExtra & PROC_EX_INTERNAL_HOT )
procExtra |= PROC_EX_INTERNAL_REQ_FAMILY ;
2010-10-08 19:17:49 +02:00
else if ( EventProcFlag & PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS )
2009-08-23 11:33:00 -05:00
return false ;
2009-05-15 16:59:27 +02:00
}
2009-10-17 15:51:44 -07:00
2010-10-08 19:17:49 +02:00
if ( procFlags & PROC_FLAG_TAKEN_PERIODIC )
2009-05-15 16:59:27 +02:00
{
2010-10-08 19:17:49 +02:00
if ( EventProcFlag & PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS )
2009-05-15 16:59:27 +02:00
{
2009-06-15 18:27:41 +02:00
if ( ! ( procExtra & PROC_EX_INTERNAL_DOT ))
2009-05-15 16:59:27 +02:00
return false ;
}
2009-07-18 22:18:47 +02:00
else if ( procExtra & PROC_EX_INTERNAL_HOT )
procExtra |= PROC_EX_INTERNAL_REQ_FAMILY ;
2010-10-08 19:17:49 +02:00
else if ( EventProcFlag & PROC_FLAG_TAKEN_SPELL_NONE_DMG_CLASS_POS )
2009-08-23 11:33:00 -05:00
return false ;
2009-05-15 16:59:27 +02:00
}
2009-07-11 20:06:02 +02:00
// Trap casts are active by default
2010-10-08 19:17:49 +02:00
if ( procFlags & PROC_FLAG_DONE_TRAP_ACTIVATION )
2009-07-11 20:06:02 +02:00
active = true ;
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
// Always trigger for this
2009-07-11 20:06:02 +02:00
if ( procFlags & ( PROC_FLAG_KILLED | PROC_FLAG_KILL | PROC_FLAG_DEATH ))
2008-11-26 15:14:03 -06:00
return true ;
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
if ( spellProcEvent ) // Exist event data
{
// Store extra req
procEvent_procEx = spellProcEvent -> procEx ;
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
// For melee triggers
if ( procSpell == NULL )
{
// Check (if set) for school (melee attack have Normal school)
2010-04-07 19:14:10 +02:00
if ( spellProcEvent -> schoolMask && ( spellProcEvent -> schoolMask & SPELL_SCHOOL_MASK_NORMAL ) == 0 )
2008-11-26 15:14:03 -06:00
return false ;
}
else // For spells need check school/spell family/family mask
{
// Check (if set) for school
2010-04-07 19:14:10 +02:00
if ( spellProcEvent -> schoolMask && ( spellProcEvent -> schoolMask & procSpell -> SchoolMask ) == 0 )
2008-11-26 15:14:03 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
// Check (if set) for spellFamilyName
2010-04-07 19:14:10 +02:00
if ( spellProcEvent -> spellFamilyName && ( spellProcEvent -> spellFamilyName != procSpell -> SpellFamilyName ))
2008-11-26 15:14:03 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
// spellFamilyName is Ok need check for spellFamilyMask if present
2010-04-07 19:14:10 +02:00
if ( spellProcEvent -> spellFamilyMask )
2008-11-26 15:14:03 -06:00
{
2010-04-07 22:59:46 +02:00
if (( spellProcEvent -> spellFamilyMask & procSpell -> SpellFamilyFlags ) == 0 )
2008-11-26 15:14:03 -06:00
return false ;
2009-05-17 18:00:33 +02:00
hasFamilyMask = true ;
2009-07-09 23:49:46 +02:00
// Some spells are not considered as active even with have spellfamilyflags
if ( ! ( procEvent_procEx & PROC_EX_ONLY_ACTIVE_SPELL ))
active = true ;
2008-11-26 15:14:03 -06:00
}
}
}
2009-10-17 15:51:44 -07:00
2009-07-18 22:18:47 +02:00
if ( procExtra & ( PROC_EX_INTERNAL_REQ_FAMILY ))
2009-05-17 18:00:33 +02:00
{
if ( ! hasFamilyMask )
return false ;
}
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
// Check for extra req (if none) and hit/crit
if ( procEvent_procEx == PROC_EX_NONE )
{
2009-07-02 21:32:19 +02:00
// No extra req, so can trigger only for hit/crit - spell has to be active
2010-04-07 19:14:10 +02:00
if (( procExtra & ( PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT )) && active )
2008-11-26 15:14:03 -06:00
return true ;
}
else // Passive spells hits here only if resist/reflect/immune/evade
{
2009-07-02 21:32:19 +02:00
if ( procExtra & AURA_SPELL_PROC_EX_MASK )
{
2009-07-09 23:49:46 +02:00
// if spell marked as procing only from not active spells
if ( active && procEvent_procEx & PROC_EX_NOT_ACTIVE_SPELL )
return false ;
// if spell marked as procing only from active spells
if ( ! active && procEvent_procEx & PROC_EX_ONLY_ACTIVE_SPELL )
return false ;
2009-07-02 21:32:19 +02:00
// Exist req for PROC_EX_EX_TRIGGER_ALWAYS
if ( procEvent_procEx & PROC_EX_EX_TRIGGER_ALWAYS )
return true ;
2009-07-09 23:49:46 +02:00
// PROC_EX_NOT_ACTIVE_SPELL and PROC_EX_ONLY_ACTIVE_SPELL flags handle: if passed checks before
2010-01-10 01:23:15 +01:00
if (( procExtra & ( PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT )) && (( procEvent_procEx & ( AURA_SPELL_PROC_EX_MASK )) == 0 ))
2009-07-09 23:49:46 +02:00
return true ;
2009-07-02 21:32:19 +02:00
}
2009-07-13 18:05:53 +02:00
// Check Extra Requirement like (hit/crit/miss/resist/parry/dodge/block/immune/reflect/absorb and other)
if ( procEvent_procEx & procExtra )
return true ;
2008-11-26 15:14:03 -06:00
}
return false ;
}
2009-10-17 15:51:44 -07:00
2010-02-01 19:22:32 +01:00
void SpellMgr :: LoadSpellGroups ()
2008-11-17 22:07:21 -06:00
{
2010-02-01 19:22:32 +01:00
mSpellSpellGroup . clear (); // need for reload case
mSpellGroupSpell . clear ();
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2010-02-01 19:22:32 +01:00
// 0 1
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT id, spell_id FROM spell_group" );
2010-04-07 22:59:46 +02:00
if ( ! result )
2008-11-17 22:07:21 -06:00
{
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
barGoLink bar ( 1 );
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell group definitions" , count );
2008-11-17 22:07:21 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
barGoLink bar ( result -> GetRowCount ());
2009-10-17 15:51:44 -07:00
2010-02-02 22:35:01 +01:00
std :: set < uint32 > groups ;
2008-11-17 22:07:21 -06:00
do
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bar . step ();
2009-10-17 15:51:44 -07:00
2010-02-01 19:22:32 +01:00
uint32 group_id = fields [ 0 ]. GetUInt32 ();
2010-02-02 22:35:01 +01:00
if ( group_id <= SPELL_GROUP_DB_RANGE_MIN && group_id >= SPELL_GROUP_CORE_RANGE_MAX )
2008-11-17 22:07:21 -06:00
{
2010-02-02 22:35:01 +01:00
sLog . outErrorDb ( "SpellGroup id %u listed in `spell_groups` is in core range, but is not defined in core!" , group_id );
2010-02-01 19:22:32 +01:00
continue ;
}
2010-02-02 22:35:01 +01:00
int32 spell_id = fields [ 1 ]. GetInt32 ();
groups . insert ( std :: set < uint32 >:: value_type ( group_id ));
mSpellGroupSpell . insert ( SpellGroupSpellMap :: value_type (( SpellGroup ) group_id , spell_id ));
2010-02-01 19:22:32 +01:00
2010-04-07 22:59:46 +02:00
} while ( result -> NextRow ());
2010-02-02 22:35:01 +01:00
2010-04-07 22:59:46 +02:00
for ( SpellGroupSpellMap :: iterator itr = mSpellGroupSpell . begin (); itr != mSpellGroupSpell . end () ;)
2010-02-02 22:35:01 +01:00
{
if ( itr -> second < 0 )
2010-02-01 19:22:32 +01:00
{
2010-02-02 22:35:01 +01:00
if ( groups . find ( abs ( itr -> second )) == groups . end ())
{
sLog . outErrorDb ( "SpellGroup id %u listed in `spell_groups` does not exist" , abs ( itr -> second ));
mSpellGroupSpell . erase ( itr ++ );
}
else
++ itr ;
2008-11-17 22:07:21 -06:00
}
2010-02-02 22:35:01 +01:00
else
2010-02-01 19:22:32 +01:00
{
2010-02-02 22:35:01 +01:00
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( itr -> second );
if ( ! spellInfo )
{
sLog . outErrorDb ( "Spell %u listed in `spell_group` does not exist" , itr -> second );
mSpellGroupSpell . erase ( itr ++ );
}
else if ( GetSpellRank ( itr -> second ) > 1 )
{
sLog . outErrorDb ( "Spell %u listed in `spell_group` is not first rank of spell" , itr -> second );
mSpellGroupSpell . erase ( itr ++ );
}
else
++ itr ;
2010-02-01 19:22:32 +01:00
}
2010-02-02 22:35:01 +01:00
}
2009-10-17 15:51:44 -07:00
2010-02-02 22:35:01 +01:00
for ( std :: set < uint32 >:: iterator groupItr = groups . begin () ; groupItr != groups . end () ; ++ groupItr )
{
std :: set < uint32 > spells ;
GetSetOfSpellsInSpellGroup ( SpellGroup ( * groupItr ), spells );
for ( std :: set < uint32 >:: iterator spellItr = spells . begin () ; spellItr != spells . end () ; ++ spellItr )
{
++ count ;
mSpellSpellGroup . insert ( SpellSpellGroupMap :: value_type ( * spellItr , SpellGroup ( * groupItr )));
}
}
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell group definitions" , count );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2010-02-02 22:35:01 +01:00
void SpellMgr :: LoadSpellGroupStackRules ()
2010-01-23 17:05:20 +01:00
{
2010-02-02 22:35:01 +01:00
mSpellGroupStack . clear (); // need for reload case
2010-01-23 17:05:20 +01:00
uint32 count = 0 ;
2010-02-02 22:35:01 +01:00
// 0 1
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT group_id, stack_rule FROM spell_group_stack_rules" );
2010-04-07 22:59:46 +02:00
if ( ! result )
2010-01-23 17:05:20 +01:00
{
2010-04-07 22:59:46 +02:00
barGoLink bar ( 1 );
2010-01-23 17:05:20 +01:00
bar . step ();
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell group stack rules" , count );
2010-01-23 17:05:20 +01:00
return ;
}
2010-04-07 22:59:46 +02:00
barGoLink bar ( result -> GetRowCount ());
2010-01-23 17:05:20 +01:00
do
{
Field * fields = result -> Fetch ();
bar . step ();
2010-02-02 22:35:01 +01:00
uint32 group_id = fields [ 0 ]. GetUInt32 ();
uint8 stack_rule = fields [ 1 ]. GetUInt32 ();
if ( stack_rule >= SPELL_GROUP_STACK_RULE_MAX )
{
sLog . outErrorDb ( "SpellGroupStackRule %u listed in `spell_group_stack_rules` does not exist" , stack_rule );
continue ;
}
2010-01-23 17:05:20 +01:00
2010-02-02 22:35:01 +01:00
SpellGroupSpellMapBounds spellGroup = GetSpellGroupSpellMapBounds (( SpellGroup ) group_id );
2010-01-23 17:05:20 +01:00
2010-02-02 22:35:01 +01:00
if ( spellGroup . first == spellGroup . second )
2010-01-23 17:05:20 +01:00
{
2010-02-02 22:35:01 +01:00
sLog . outErrorDb ( "SpellGroup id %u listed in `spell_group_stack_rules` does not exist" , group_id );
2010-01-23 17:05:20 +01:00
continue ;
}
2010-02-02 22:35:01 +01:00
mSpellGroupStack [( SpellGroup ) group_id ] = ( SpellGroupStackRule ) stack_rule ;
2010-01-23 17:05:20 +01:00
++ count ;
2010-04-07 22:59:46 +02:00
} while ( result -> NextRow ());
2010-01-23 17:05:20 +01:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell group stack rules" , count );
2010-01-23 17:05:20 +01:00
}
2008-11-17 22:07:21 -06:00
void SpellMgr :: LoadSpellThreats ()
{
2009-07-30 11:37:08 +08:00
mSpellThreatMap . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
// 0 1
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT entry, Threat FROM spell_threat" );
2010-01-01 14:19:29 -06:00
if ( ! result )
2009-07-30 11:37:08 +08:00
{
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( 1 );
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u aggro generating spells" , count );
2009-07-30 11:37:08 +08:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( result -> GetRowCount ());
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
do
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
uint32 entry = fields [ 0 ]. GetUInt32 ();
uint16 Threat = fields [ 1 ]. GetUInt16 ();
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
if ( ! sSpellStore . LookupEntry ( entry ))
{
sLog . outErrorDb ( "Spell %u listed in `spell_threat` does not exist" , entry );
continue ;
}
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
mSpellThreatMap [ entry ] = Threat ;
2009-10-17 15:51:44 -07:00
2009-07-30 11:37:08 +08:00
++ count ;
2010-01-01 14:19:29 -06:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u aggro generating spells" , count );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool SpellMgr :: IsRankSpellDueToSpell ( SpellEntry const * spellInfo_1 , uint32 spellId_2 ) const
{
SpellEntry const * spellInfo_2 = sSpellStore . LookupEntry ( spellId_2 );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo_1 || ! spellInfo_2 ) return false ;
if ( spellInfo_1 -> Id == spellId_2 ) return false ;
2009-10-17 15:51:44 -07:00
2010-04-07 23:25:02 +02:00
return GetFirstSpellInChain ( spellInfo_1 -> Id ) == GetFirstSpellInChain ( spellId_2 );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool SpellMgr :: canStackSpellRanks ( SpellEntry const * spellInfo )
{
2010-04-07 19:14:10 +02:00
if ( IsPassiveSpell ( spellInfo -> Id )) // ranked passive spell
2009-01-25 16:35:14 -06:00
return false ;
2010-04-07 19:14:10 +02:00
if ( spellInfo -> powerType != POWER_MANA && spellInfo -> powerType != POWER_HEALTH )
2008-11-17 22:07:21 -06:00
return false ;
2010-04-07 19:14:10 +02:00
if ( IsProfessionOrRidingSpell ( spellInfo -> Id ))
2008-11-17 22:07:21 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2010-08-08 05:25:45 +02:00
if ( sSpellMgr . IsSkillBonusSpell ( spellInfo -> Id ))
2009-01-25 16:35:14 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// All stance spells. if any better way, change it.
2010-09-28 08:21:51 +03:00
for ( int i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2008-11-17 22:07:21 -06:00
{
2009-01-25 16:35:14 -06:00
switch ( spellInfo -> SpellFamilyName )
{
case SPELLFAMILY_PALADIN :
// Paladin aura Spell
2010-04-07 23:25:02 +02:00
if ( spellInfo -> Effect [ i ] == SPELL_EFFECT_APPLY_AREA_AURA_RAID )
2009-01-25 16:35:14 -06:00
return false ;
break ;
case SPELLFAMILY_DRUID :
// Druid form Spell
2010-04-07 23:25:02 +02:00
if ( spellInfo -> Effect [ i ] == SPELL_EFFECT_APPLY_AURA &&
2009-01-25 16:35:14 -06:00
spellInfo -> EffectApplyAuraName [ i ] == SPELL_AURA_MOD_SHAPESHIFT )
return false ;
break ;
case SPELLFAMILY_ROGUE :
// Rogue Stealth
2010-04-07 23:25:02 +02:00
if ( spellInfo -> Effect [ i ] == SPELL_EFFECT_APPLY_AURA &&
2009-01-25 16:35:14 -06:00
spellInfo -> EffectApplyAuraName [ i ] == SPELL_AURA_MOD_SHAPESHIFT )
return false ;
}
2008-11-17 22:07:21 -06:00
}
return true ;
}
2009-01-14 00:35:13 -06:00
bool SpellMgr :: IsProfessionOrRidingSpell ( uint32 spellId )
2008-11-17 22:07:21 -06:00
{
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( spellId );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-11-17 22:07:21 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2010-01-31 17:24:13 +01:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
{
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Effect [ i ] == SPELL_EFFECT_SKILL )
2010-01-31 17:24:13 +01:00
{
uint32 skill = spellInfo -> EffectMiscValue [ i ];
2009-10-17 15:51:44 -07:00
2010-01-31 17:24:13 +01:00
bool found = IsProfessionOrRidingSkill ( skill );
if ( found )
return true ;
}
}
return false ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-01-16 15:53:34 -06:00
bool SpellMgr :: IsProfessionSpell ( uint32 spellId )
{
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( spellId );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2009-01-16 15:53:34 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2010-01-31 17:24:13 +01:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
{
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Effect [ i ] == SPELL_EFFECT_SKILL )
2010-01-31 17:24:13 +01:00
{
uint32 skill = spellInfo -> EffectMiscValue [ i ];
2009-10-17 15:51:44 -07:00
2010-01-31 17:24:13 +01:00
bool found = IsProfessionSkill ( skill );
if ( found )
return true ;
}
}
return false ;
2009-01-16 15:53:34 -06:00
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool SpellMgr :: IsPrimaryProfessionSpell ( uint32 spellId )
{
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( spellId );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-11-17 22:07:21 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2010-01-31 17:24:13 +01:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
{
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Effect [ i ] == SPELL_EFFECT_SKILL )
2010-01-31 17:24:13 +01:00
{
uint32 skill = spellInfo -> EffectMiscValue [ i ];
2009-10-17 15:51:44 -07:00
2010-01-31 17:24:13 +01:00
bool found = IsPrimaryProfessionSkill ( skill );
if ( found )
return true ;
}
}
return false ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool SpellMgr :: IsPrimaryProfessionFirstRankSpell ( uint32 spellId ) const
{
2010-04-07 23:25:02 +02:00
return IsPrimaryProfessionSpell ( spellId ) && GetSpellRank ( spellId ) == 1 ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-01-25 16:35:14 -06:00
bool SpellMgr :: IsSkillBonusSpell ( uint32 spellId ) const
{
2009-08-27 20:27:55 -05:00
SkillLineAbilityMapBounds bounds = GetSkillLineAbilityMapBounds ( spellId );
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for ( SkillLineAbilityMap :: const_iterator _spell_idx = bounds . first ; _spell_idx != bounds . second ; ++ _spell_idx )
2009-01-25 16:35:14 -06:00
{
SkillLineAbilityEntry const * pAbility = _spell_idx -> second ;
if ( ! pAbility || pAbility -> learnOnGetSkill != ABILITY_LEARNED_ON_GET_PROFESSION_SKILL )
continue ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( pAbility -> req_skill_value > 0 )
2009-01-25 16:35:14 -06:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-01-25 16:35:14 -06:00
return false ;
}
2009-10-17 15:51:44 -07:00
2010-07-14 16:57:13 +02:00
bool SpellMgr :: IsSkillTypeSpell ( uint32 spellId , SkillType type ) const
{
SkillLineAbilityMapBounds bounds = GetSkillLineAbilityMapBounds ( spellId );
for ( SkillLineAbilityMap :: const_iterator _spell_idx = bounds . first ; _spell_idx != bounds . second ; ++ _spell_idx )
if ( _spell_idx -> second -> skillId == uint32 ( type ))
return true ;
return false ;
}
// basepoints provided here have to be valid basepoints (use SpellMgr::CalculateSpellEffectBaseAmount)
2010-08-21 23:08:54 +02:00
int32 SpellMgr :: CalculateSpellEffectAmount ( SpellEntry const * spellEntry , uint8 effIndex , Unit const * caster , int32 const * effBasePoints , Unit const * /*target*/ )
2010-07-14 16:57:13 +02:00
{
float basePointsPerLevel = spellEntry -> EffectRealPointsPerLevel [ effIndex ];
int32 basePoints = effBasePoints ? * effBasePoints : spellEntry -> EffectBasePoints [ effIndex ];
int32 randomPoints = int32 ( spellEntry -> EffectDieSides [ effIndex ]);
// base amount modification based on spell lvl vs caster lvl
if ( caster )
{
int32 level = int32 ( caster -> getLevel ());
if ( level > int32 ( spellEntry -> maxLevel ) && spellEntry -> maxLevel > 0 )
level = int32 ( spellEntry -> maxLevel );
else if ( level < int32 ( spellEntry -> baseLevel ))
level = int32 ( spellEntry -> baseLevel );
level -= int32 ( spellEntry -> spellLevel );
basePoints += int32 ( level * basePointsPerLevel );
}
// roll in a range <1;EffectDieSides> as of patch 3.3.3
switch ( randomPoints )
{
2010-07-22 12:21:11 +02:00
case 0 : break ;
2010-07-14 16:57:13 +02:00
case 1 : basePoints += 1 ; break ; // range 1..1
default :
// range can have positive (1..rand) and negative (rand..1) values, so order its for irand
int32 randvalue = ( randomPoints >= 1 )
? irand ( 1 , randomPoints )
: irand ( randomPoints , 1 );
basePoints += randvalue ;
break ;
}
int32 value = basePoints ;
// random damage
if ( caster )
{
// bonus amount from combo points
if ( caster -> m_movedPlayer )
if ( uint8 comboPoints = caster -> m_movedPlayer -> GetComboPoints ())
if ( float comboDamage = spellEntry -> EffectPointsPerComboPoint [ effIndex ])
value += int32 ( comboDamage * comboPoints );
value = caster -> ApplyEffectModifiers ( spellEntry , effIndex , value );
// amount multiplication based on caster's level
if ( ! basePointsPerLevel && ( spellEntry -> Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellEntry -> spellLevel ) &&
spellEntry -> Effect [ effIndex ] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE &&
spellEntry -> Effect [ effIndex ] != SPELL_EFFECT_KNOCK_BACK &&
spellEntry -> EffectApplyAuraName [ effIndex ] != SPELL_AURA_MOD_SPEED_ALWAYS &&
spellEntry -> EffectApplyAuraName [ effIndex ] != SPELL_AURA_MOD_SPEED_NOT_STACK &&
spellEntry -> EffectApplyAuraName [ effIndex ] != SPELL_AURA_MOD_INCREASE_SPEED &&
spellEntry -> EffectApplyAuraName [ effIndex ] != SPELL_AURA_MOD_DECREASE_SPEED )
//there are many more: slow speed, -healing pct
value = int32 ( value * 0.25f * exp ( caster -> getLevel () * ( 70 - spellEntry -> spellLevel ) / 1000.0f ));
//value = int32(value * (int32)getLevel() / (int32)(spellProto->spellLevel ? spellProto->spellLevel : 1));
}
return value ;
}
2010-07-22 12:21:11 +02:00
int32 SpellMgr :: CalculateSpellEffectBaseAmount ( int32 value , SpellEntry const * spellEntry , uint8 effIndex )
{
if ( spellEntry -> EffectDieSides [ effIndex ] == 0 )
return value ;
else
return value - 1 ;
}
2010-08-27 21:07:33 +02:00
float SpellMgr :: CalculateSpellEffectValueMultiplier ( SpellEntry const * spellEntry , uint8 effIndex , Unit * caster , Spell * spell )
2010-08-26 19:07:55 +02:00
{
float multiplier = spellEntry -> EffectValueMultiplier [ effIndex ];
if ( caster )
if ( Player * modOwner = caster -> GetSpellModOwner ())
2010-08-27 20:51:29 +02:00
modOwner -> ApplySpellMod ( spellEntry -> Id , SPELLMOD_VALUE_MULTIPLIER , multiplier , spell );
2010-08-26 19:07:55 +02:00
return multiplier ;
}
2010-08-27 21:07:33 +02:00
float SpellMgr :: CalculateSpellEffectDamageMultiplier ( SpellEntry const * spellEntry , uint8 effIndex , Unit * caster , Spell * spell )
2010-08-26 19:07:55 +02:00
{
float multiplier = spellEntry -> EffectDamageMultiplier [ effIndex ];
if ( caster )
if ( Player * modOwner = caster -> GetSpellModOwner ())
2010-08-27 20:51:29 +02:00
modOwner -> ApplySpellMod ( spellEntry -> Id , SPELLMOD_DAMAGE_MULTIPLIER , multiplier , spell );
2010-08-26 19:07:55 +02:00
return multiplier ;
}
2008-11-17 22:07:21 -06:00
SpellEntry const * SpellMgr :: SelectAuraRankForPlayerLevel ( SpellEntry const * spellInfo , uint32 playerLevel ) const
{
// ignore passive spells
2010-04-07 19:14:10 +02:00
if ( IsPassiveSpell ( spellInfo -> Id ))
2008-11-17 22:07:21 -06:00
return spellInfo ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bool needRankSelection = false ;
2010-09-28 08:21:51 +03:00
for ( int i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2008-11-17 22:07:21 -06:00
{
2010-04-07 22:59:46 +02:00
if ( IsPositiveEffect ( spellInfo -> Id , i ) && (
2008-11-17 22:07:21 -06:00
spellInfo -> Effect [ i ] == SPELL_EFFECT_APPLY_AURA ||
2008-12-24 09:58:26 -06:00
spellInfo -> Effect [ i ] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY ||
spellInfo -> Effect [ i ] == SPELL_EFFECT_APPLY_AREA_AURA_RAID
2010-04-07 22:59:46 +02:00
))
2008-11-17 22:07:21 -06:00
{
needRankSelection = true ;
break ;
}
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// not required
2010-04-07 19:14:10 +02:00
if ( ! needRankSelection )
2008-11-17 22:07:21 -06:00
return spellInfo ;
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for ( uint32 nextSpellId = spellInfo -> Id ; nextSpellId != 0 ; nextSpellId = GetPrevSpellInChain ( nextSpellId ))
2008-11-17 22:07:21 -06:00
{
SpellEntry const * nextSpellInfo = sSpellStore . LookupEntry ( nextSpellId );
2010-04-07 19:14:10 +02:00
if ( ! nextSpellInfo )
2008-11-17 22:07:21 -06:00
break ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// if found appropriate level
2010-04-07 19:14:10 +02:00
if ( playerLevel + 10 >= nextSpellInfo -> spellLevel )
2008-11-17 22:07:21 -06:00
return nextSpellInfo ;
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// one rank less then
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
// not found
return NULL ;
}
2009-05-15 16:26:00 -05:00
void SpellMgr :: LoadSpellLearnSkills ()
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
mSpellLearnSkills . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// search auto-learned skills and add its to map also for use in unlearn spells/talents
uint32 dbc_count = 0 ;
2010-01-01 14:19:29 -06:00
barGoLink bar ( sSpellStore . GetNumRows ());
2009-10-17 16:20:24 -07:00
for ( uint32 spell = 0 ; spell < sSpellStore . GetNumRows (); ++ spell )
2009-05-15 16:26:00 -05:00
{
bar . step ();
SpellEntry const * entry = sSpellStore . LookupEntry ( spell );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! entry )
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-05-15 16:26:00 -05:00
{
2010-04-07 23:25:02 +02:00
if ( entry -> Effect [ i ] == SPELL_EFFECT_SKILL )
2009-05-15 16:26:00 -05:00
{
SpellLearnSkillNode dbc_node ;
2010-01-01 14:19:29 -06:00
dbc_node . skill = entry -> EffectMiscValue [ i ];
2010-07-14 16:57:13 +02:00
dbc_node . step = SpellMgr :: CalculateSpellEffectAmount ( entry , i );
2010-01-01 14:19:29 -06:00
if ( dbc_node . skill != SKILL_RIDING )
2009-05-15 16:26:00 -05:00
dbc_node . value = 1 ;
else
2010-04-11 11:16:42 +04:00
dbc_node . value = dbc_node . step * 75 ;
dbc_node . maxvalue = dbc_node . step * 75 ;
2009-05-15 16:26:00 -05:00
mSpellLearnSkills [ spell ] = dbc_node ;
++ dbc_count ;
break ;
}
}
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u Spell Learn Skills from DBC" , dbc_count );
2009-05-15 16:26:00 -05:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
void SpellMgr :: LoadSpellLearnSpells ()
{
mSpellLearnSpells . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
// 0 1 2
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT entry, SpellID, Active FROM spell_learn_spell" );
2010-01-01 14:19:29 -06:00
if ( ! result )
2008-11-17 22:07:21 -06:00
{
2010-01-01 14:19:29 -06:00
barGoLink bar ( 1 );
2008-11-17 22:07:21 -06:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded 0 spell learn spells" );
2009-05-15 16:26:00 -05:00
sLog . outErrorDb ( "`spell_learn_spell` table is empty!" );
2008-11-17 22:07:21 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( result -> GetRowCount ());
2008-11-17 22:07:21 -06:00
do
{
bar . step ();
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
uint32 spell_id = fields [ 0 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
SpellLearnSpellNode node ;
node . spell = fields [ 1 ]. GetUInt32 ();
node . active = fields [ 2 ]. GetBool ();
node . autoLearned = false ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
if ( ! sSpellStore . LookupEntry ( spell_id ))
2009-05-15 16:26:00 -05:00
{
2010-01-01 14:19:29 -06:00
sLog . outErrorDb ( "Spell %u listed in `spell_learn_spell` does not exist" , spell_id );
2009-05-15 16:26:00 -05:00
continue ;
}
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
if ( ! sSpellStore . LookupEntry ( node . spell ))
2009-05-15 16:26:00 -05:00
{
2010-01-01 14:19:29 -06:00
sLog . outErrorDb ( "Spell %u listed in `spell_learn_spell` learning not existed spell %u" , spell_id , node . spell );
2009-07-01 18:07:57 -05:00
continue ;
}
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
if ( GetTalentSpellCost ( node . spell ))
2009-07-01 18:07:57 -05:00
{
2010-01-01 14:19:29 -06:00
sLog . outErrorDb ( "Spell %u listed in `spell_learn_spell` attempt learning talent spell %u, skipped" , spell_id , node . spell );
2009-05-15 16:26:00 -05:00
continue ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
mSpellLearnSpells . insert ( SpellLearnSpellMap :: value_type ( spell_id , node ));
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
++ count ;
2010-01-01 14:19:29 -06:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// search auto-learned spells and add its to map also for use in unlearn spells/talents
uint32 dbc_count = 0 ;
2009-10-17 16:20:24 -07:00
for ( uint32 spell = 0 ; spell < sSpellStore . GetNumRows (); ++ spell )
2009-05-15 16:26:00 -05:00
{
SpellEntry const * entry = sSpellStore . LookupEntry ( spell );
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
if ( ! entry )
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-05-15 16:26:00 -05:00
{
2010-04-07 23:25:02 +02:00
if ( entry -> Effect [ i ] == SPELL_EFFECT_LEARN_SPELL )
2009-05-15 16:26:00 -05:00
{
SpellLearnSpellNode dbc_node ;
2010-01-01 14:19:29 -06:00
dbc_node . spell = entry -> EffectTriggerSpell [ i ];
dbc_node . active = true ; // all dbc based learned spells is active (show in spell book or hide by client itself)
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// ignore learning not existed spells (broken/outdated/or generic learnig spell 483
2010-01-01 14:19:29 -06:00
if ( ! sSpellStore . LookupEntry ( dbc_node . spell ))
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// talent or passive spells or skill-step spells auto-casted and not need dependent learning,
// pet teaching spells don't must be dependent learning (casted)
// other required explicit dependent learning
dbc_node . autoLearned = entry -> EffectImplicitTargetA [ i ] == TARGET_UNIT_PET || GetTalentSpellCost ( spell ) > 0 || IsPassiveSpell ( spell ) || IsSpellHaveEffect ( entry , SPELL_EFFECT_SKILL_STEP );
2009-10-17 15:51:44 -07:00
2009-08-27 20:27:55 -05:00
SpellLearnSpellMapBounds db_node_bounds = GetSpellLearnSpellMapBounds ( spell );
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
bool found = false ;
2009-10-17 16:20:24 -07:00
for ( SpellLearnSpellMap :: const_iterator itr = db_node_bounds . first ; itr != db_node_bounds . second ; ++ itr )
2009-05-15 16:26:00 -05:00
{
2010-01-01 14:19:29 -06:00
if ( itr -> second . spell == dbc_node . spell )
2009-05-15 16:26:00 -05:00
{
sLog . outErrorDb ( "Spell %u auto-learn spell %u in spell.dbc then the record in `spell_learn_spell` is redundant, please fix DB." ,
spell , dbc_node . spell );
found = true ;
break ;
}
}
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
if ( ! found ) // add new spell-spell pair if not found
2009-05-15 16:26:00 -05:00
{
mSpellLearnSpells . insert ( SpellLearnSpellMap :: value_type ( spell , dbc_node ));
++ dbc_count ;
}
}
}
2008-12-22 02:11:11 +01:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell learn spells + %u found in DBC" , count , dbc_count );
2009-05-15 16:26:00 -05:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
void SpellMgr :: LoadSpellPetAuras ()
{
mSpellPetAuraMap . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
// 0 1 2 3
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT spell, effectId, pet, aura FROM spell_pet_auras" );
2009-11-19 03:53:49 -08:00
if ( ! result )
2009-05-15 16:26:00 -05:00
{
2009-11-19 03:53:49 -08:00
barGoLink bar ( 1 );
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell pet auras" , count );
2009-05-15 16:26:00 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
barGoLink bar ( result -> GetRowCount ());
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
do
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-07-01 18:07:20 -05:00
uint32 spell = fields [ 0 ]. GetUInt32 ();
2009-06-23 14:05:37 +02:00
uint8 eff = fields [ 1 ]. GetUInt8 ();
2009-07-01 18:07:20 -05:00
uint32 pet = fields [ 2 ]. GetUInt32 ();
uint32 aura = fields [ 3 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2009-06-23 14:05:37 +02:00
SpellPetAuraMap :: iterator itr = mSpellPetAuraMap . find (( spell << 8 ) + eff );
2009-11-19 03:53:49 -08:00
if ( itr != mSpellPetAuraMap . end ())
2009-05-15 16:26:00 -05:00
itr -> second . AddAura ( pet , aura );
else
2008-12-22 02:11:11 +01:00
{
2009-05-15 16:26:00 -05:00
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( spell );
if ( ! spellInfo )
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
sLog . outErrorDb ( "Spell %u listed in `spell_pet_auras` does not exist" , spell );
continue ;
2008-11-17 22:07:21 -06:00
}
2009-06-23 14:05:37 +02:00
if ( spellInfo -> Effect [ eff ] != SPELL_EFFECT_DUMMY &&
( spellInfo -> Effect [ eff ] != SPELL_EFFECT_APPLY_AURA ||
spellInfo -> EffectApplyAuraName [ eff ] != SPELL_AURA_DUMMY ))
2009-05-15 16:26:00 -05:00
{
sLog . outError ( "Spell %u listed in `spell_pet_auras` does not have dummy aura or dummy effect" , spell );
continue ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
SpellEntry const * spellInfo2 = sSpellStore . LookupEntry ( aura );
if ( ! spellInfo2 )
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
sLog . outErrorDb ( "Aura %u listed in `spell_pet_auras` does not exist" , aura );
continue ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2010-07-14 16:57:13 +02:00
PetAura pa ( pet , aura , spellInfo -> EffectImplicitTargetA [ eff ] == TARGET_UNIT_PET , SpellMgr :: CalculateSpellEffectAmount ( spellInfo , eff ));
2009-06-23 14:05:37 +02:00
mSpellPetAuraMap [( spell << 8 ) + eff ] = pa ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
++ count ;
2009-11-19 03:53:49 -08:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell pet auras" , count );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
void SpellMgr :: LoadPetLevelupSpellMap ()
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
mPetLevelupSpellMap . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2009-05-15 16:36:59 -05:00
uint32 count = 0 ;
2009-05-17 10:57:55 -05:00
uint32 family_count = 0 ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( sCreatureFamilyStore . GetNumRows ());
2009-05-15 16:26:00 -05:00
for ( uint32 i = 0 ; i < sCreatureFamilyStore . GetNumRows (); ++ i )
2008-11-17 22:07:21 -06:00
{
2010-01-01 14:19:29 -06:00
bar . step ();
2009-05-15 16:36:59 -05:00
CreatureFamilyEntry const * creatureFamily = sCreatureFamilyStore . LookupEntry ( i );
2010-01-01 14:19:29 -06:00
if ( ! creatureFamily ) // not exist
2008-11-17 22:07:21 -06:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
for ( uint8 j = 0 ; j < 2 ; ++ j )
2008-11-17 22:07:21 -06:00
{
2009-05-16 14:49:58 -05:00
if ( ! creatureFamily -> skillLine [ j ])
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:36:59 -05:00
for ( uint32 k = 0 ; k < sSkillLineAbilityStore . GetNumRows (); ++ k )
2009-05-15 16:26:00 -05:00
{
SkillLineAbilityEntry const * skillLine = sSkillLineAbilityStore . LookupEntry ( k );
2009-11-19 03:53:49 -08:00
if ( ! skillLine )
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2010-04-08 08:20:08 +02:00
//if (skillLine->skillId != creatureFamily->skillLine[0] &&
// (!creatureFamily->skillLine[1] || skillLine->skillId != creatureFamily->skillLine[1]))
2009-05-26 16:10:42 -05:00
// continue;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
if ( skillLine -> skillId != creatureFamily -> skillLine [ j ])
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( skillLine -> learnOnGetSkill != ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL )
2009-05-15 16:36:59 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
SpellEntry const * spell = sSpellStore . LookupEntry ( skillLine -> spellId );
2009-11-19 03:53:49 -08:00
if ( ! spell ) // not exist or triggered or talent
2009-05-17 10:57:55 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( ! spell -> spellLevel )
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
PetLevelupSpellSet & spellSet = mPetLevelupSpellMap [ creatureFamily -> ID ];
if ( spellSet . empty ())
++ family_count ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
spellSet . insert ( PetLevelupSpellSet :: value_type ( spell -> spellLevel , spell -> Id ));
++ count ;
2008-11-17 22:07:21 -06:00
}
}
}
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u pet levelup and default spells for %u families" , count , family_count );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
bool LoadPetDefaultSpells_helper ( CreatureInfo const * cInfo , PetDefaultSpellsEntry & petDefSpells )
{
// skip empty list;
bool have_spell = false ;
2009-11-19 03:53:49 -08:00
for ( uint8 j = 0 ; j < MAX_CREATURE_SPELL_DATA_SLOT ; ++ j )
2009-05-24 12:16:12 -05:00
{
2009-11-19 03:53:49 -08:00
if ( petDefSpells . spellid [ j ])
2009-05-24 12:16:12 -05:00
{
have_spell = true ;
break ;
}
}
2009-11-19 03:53:49 -08:00
if ( ! have_spell )
2009-05-24 12:16:12 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
// remove duplicates with levelupSpells if any
2010-08-08 05:25:45 +02:00
if ( PetLevelupSpellSet const * levelupSpells = cInfo -> family ? sSpellMgr . GetPetLevelupSpellList ( cInfo -> family ) : NULL )
2009-05-24 12:16:12 -05:00
{
2009-11-19 03:53:49 -08:00
for ( uint8 j = 0 ; j < MAX_CREATURE_SPELL_DATA_SLOT ; ++ j )
2009-05-24 12:16:12 -05:00
{
2010-04-07 19:14:10 +02:00
if ( ! petDefSpells . spellid [ j ])
2009-05-24 12:16:12 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for ( PetLevelupSpellSet :: const_iterator itr = levelupSpells -> begin (); itr != levelupSpells -> end (); ++ itr )
2009-05-24 12:16:12 -05:00
{
if ( itr -> second == petDefSpells . spellid [ j ])
{
petDefSpells . spellid [ j ] = 0 ;
break ;
}
}
}
}
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
// skip empty list;
have_spell = false ;
2009-11-19 03:53:49 -08:00
for ( uint8 j = 0 ; j < MAX_CREATURE_SPELL_DATA_SLOT ; ++ j )
2009-05-24 12:16:12 -05:00
{
2009-11-19 03:53:49 -08:00
if ( petDefSpells . spellid [ j ])
2009-05-24 12:16:12 -05:00
{
have_spell = true ;
break ;
}
}
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
return have_spell ;
}
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
void SpellMgr :: LoadPetDefaultSpells ()
{
mPetDefaultSpellsMap . clear ();
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
uint32 countCreature = 0 ;
uint32 countData = 0 ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( sCreatureStorage . MaxEntry + sSpellStore . GetNumRows ());
2009-11-19 03:53:49 -08:00
for ( uint32 i = 0 ; i < sCreatureStorage . MaxEntry ; ++ i )
2009-05-24 12:16:12 -05:00
{
2010-01-01 14:19:29 -06:00
bar . step ();
2009-05-24 12:16:12 -05:00
CreatureInfo const * cInfo = sCreatureStorage . LookupEntry < CreatureInfo > ( i );
2009-11-19 03:53:49 -08:00
if ( ! cInfo )
2009-05-24 12:16:12 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( ! cInfo -> PetSpellDataId )
2009-05-24 12:16:12 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
// for creature with PetSpellDataId get default pet spells from dbc
CreatureSpellDataEntry const * spellDataEntry = sCreatureSpellDataStore . LookupEntry ( cInfo -> PetSpellDataId );
2009-11-19 03:53:49 -08:00
if ( ! spellDataEntry )
2009-05-24 12:16:12 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
int32 petSpellsId = - int32 ( cInfo -> PetSpellDataId );
2009-05-24 12:16:12 -05:00
PetDefaultSpellsEntry petDefSpells ;
2009-11-19 03:53:49 -08:00
for ( uint8 j = 0 ; j < MAX_CREATURE_SPELL_DATA_SLOT ; ++ j )
2009-05-24 12:16:12 -05:00
petDefSpells . spellid [ j ] = spellDataEntry -> spellId [ j ];
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( LoadPetDefaultSpells_helper ( cInfo , petDefSpells ))
2009-05-24 12:16:12 -05:00
{
mPetDefaultSpellsMap [ petSpellsId ] = petDefSpells ;
++ countData ;
}
}
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
// different summon spells
2009-11-19 03:53:49 -08:00
for ( uint32 i = 0 ; i < sSpellStore . GetNumRows (); ++ i )
2009-05-24 12:16:12 -05:00
{
2010-01-01 14:19:29 -06:00
bar . step ();
2009-05-24 12:16:12 -05:00
SpellEntry const * spellEntry = sSpellStore . LookupEntry ( i );
2009-11-19 03:53:49 -08:00
if ( ! spellEntry )
2009-05-24 12:16:12 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
for ( uint8 k = 0 ; k < MAX_SPELL_EFFECTS ; ++ k )
2009-05-24 12:16:12 -05:00
{
2009-11-19 03:53:49 -08:00
if ( spellEntry -> Effect [ k ] == SPELL_EFFECT_SUMMON || spellEntry -> Effect [ k ] == SPELL_EFFECT_SUMMON_PET )
2009-05-24 12:16:12 -05:00
{
uint32 creature_id = spellEntry -> EffectMiscValue [ k ];
2009-11-19 03:53:49 -08:00
CreatureInfo const * cInfo = sCreatureStorage . LookupEntry < CreatureInfo > ( creature_id );
if ( ! cInfo )
2009-05-24 12:16:12 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
// already loaded
2009-11-19 03:53:49 -08:00
if ( cInfo -> PetSpellDataId )
2009-05-24 12:16:12 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
// for creature without PetSpellDataId get default pet spells from creature_template
int32 petSpellsId = cInfo -> Entry ;
2009-11-19 03:53:49 -08:00
if ( mPetDefaultSpellsMap . find ( cInfo -> Entry ) != mPetDefaultSpellsMap . end ())
2009-05-24 12:16:12 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
PetDefaultSpellsEntry petDefSpells ;
2009-11-19 03:53:49 -08:00
for ( uint8 j = 0 ; j < MAX_CREATURE_SPELL_DATA_SLOT ; ++ j )
2009-05-24 12:16:12 -05:00
petDefSpells . spellid [ j ] = cInfo -> spells [ j ];
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( LoadPetDefaultSpells_helper ( cInfo , petDefSpells ))
2009-05-24 12:16:12 -05:00
{
mPetDefaultSpellsMap [ petSpellsId ] = petDefSpells ;
++ countCreature ;
}
}
}
}
2009-10-17 15:51:44 -07:00
2009-05-24 12:16:12 -05:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded addition spells for %u pet spell data entries." , countData );
sLog . outString ( ">> Loaded %u summonable creature templates." , countCreature );
2009-05-24 12:16:12 -05:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
/// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
2009-11-19 03:53:49 -08:00
bool SpellMgr :: IsSpellValid ( SpellEntry const * spellInfo , Player * pl , bool msg )
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
// not exist
2009-11-19 03:53:49 -08:00
if ( ! spellInfo )
2009-05-15 16:26:00 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
bool need_check_reagents = false ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// check effects
2010-09-28 08:21:51 +03:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2008-11-17 22:07:21 -06:00
{
2009-11-19 03:53:49 -08:00
switch ( spellInfo -> Effect [ i ])
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
case 0 :
continue ;
2009-10-17 15:51:44 -07:00
2009-06-23 14:44:16 +02:00
// craft spell for crafting non-existed item (break client recipes list show)
2009-05-15 16:26:00 -05:00
case SPELL_EFFECT_CREATE_ITEM :
2009-06-23 14:44:16 +02:00
case SPELL_EFFECT_CREATE_ITEM_2 :
2008-11-17 22:07:21 -06:00
{
2010-02-14 19:13:14 -07:00
if ( spellInfo -> EffectItemType [ i ] == 0 )
{
// skip auto-loot crafting spells, its not need explicit item info (but have special fake items sometime)
if ( ! IsLootCraftingSpell ( spellInfo ))
{
2010-04-07 19:14:10 +02:00
if ( msg )
2010-02-14 19:13:14 -07:00
{
2010-04-07 19:14:10 +02:00
if ( pl )
2010-02-14 19:13:14 -07:00
ChatHandler ( pl ). PSendSysMessage ( "Craft spell %u not have create item entry." , spellInfo -> Id );
else
sLog . outErrorDb ( "Craft spell %u not have create item entry." , spellInfo -> Id );
}
return false ;
}
}
// also possible IsLootCraftingSpell case but fake item must exist anyway
else if ( ! ObjectMgr :: GetItemPrototype ( spellInfo -> EffectItemType [ i ]))
2009-05-15 16:26:00 -05:00
{
2009-11-19 03:53:49 -08:00
if ( msg )
2009-05-15 16:26:00 -05:00
{
2009-11-19 03:53:49 -08:00
if ( pl )
2009-05-15 16:26:00 -05:00
ChatHandler ( pl ). PSendSysMessage ( "Craft spell %u create not-exist in DB item (Entry: %u) and then..." , spellInfo -> Id , spellInfo -> EffectItemType [ i ]);
else
sLog . outErrorDb ( "Craft spell %u create not-exist in DB item (Entry: %u) and then..." , spellInfo -> Id , spellInfo -> EffectItemType [ i ]);
}
return false ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
need_check_reagents = true ;
break ;
}
case SPELL_EFFECT_LEARN_SPELL :
{
2009-11-19 03:53:49 -08:00
SpellEntry const * spellInfo2 = sSpellStore . LookupEntry ( spellInfo -> EffectTriggerSpell [ i ]);
if ( ! IsSpellValid ( spellInfo2 , pl , msg ))
2008-11-17 22:07:21 -06:00
{
2009-11-19 03:53:49 -08:00
if ( msg )
2008-11-17 22:07:21 -06:00
{
2009-11-19 03:53:49 -08:00
if ( pl )
2009-05-15 16:26:00 -05:00
ChatHandler ( pl ). PSendSysMessage ( "Spell %u learn to broken spell %u, and then..." , spellInfo -> Id , spellInfo -> EffectTriggerSpell [ i ]);
else
sLog . outErrorDb ( "Spell %u learn to invalid spell %u, and then..." , spellInfo -> Id , spellInfo -> EffectTriggerSpell [ i ]);
2008-11-17 22:07:21 -06:00
}
2009-05-15 16:26:00 -05:00
return false ;
2008-11-17 22:07:21 -06:00
}
2009-05-15 16:26:00 -05:00
break ;
}
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( need_check_reagents )
2009-05-15 16:26:00 -05:00
{
2010-09-28 08:21:51 +03:00
for ( uint8 j = 0 ; j < MAX_SPELL_REAGENTS ; ++ j )
2009-05-15 16:26:00 -05:00
{
2009-11-19 03:53:49 -08:00
if ( spellInfo -> Reagent [ j ] > 0 && ! ObjectMgr :: GetItemPrototype ( spellInfo -> Reagent [ j ]))
2009-05-15 16:26:00 -05:00
{
2009-11-19 03:53:49 -08:00
if ( msg )
2008-11-17 22:07:21 -06:00
{
2009-11-19 03:53:49 -08:00
if ( pl )
2009-05-15 16:26:00 -05:00
ChatHandler ( pl ). PSendSysMessage ( "Craft spell %u have not-exist reagent in DB item (Entry: %u) and then..." , spellInfo -> Id , spellInfo -> Reagent [ j ]);
else
sLog . outErrorDb ( "Craft spell %u have not-exist reagent in DB item (Entry: %u) and then..." , spellInfo -> Id , spellInfo -> Reagent [ j ]);
2008-11-17 22:07:21 -06:00
}
2009-05-15 16:26:00 -05:00
return false ;
2008-11-17 22:07:21 -06:00
}
}
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
return true ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
void SpellMgr :: LoadSpellAreas ()
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
mSpellAreaMap . clear (); // need for reload case
mSpellAreaForQuestMap . clear ();
mSpellAreaForActiveQuestMap . clear ();
mSpellAreaForQuestEndMap . clear ();
mSpellAreaForAuraMap . clear ();
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
// 0 1 2 3 4 5 6 7 8
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT spell, area, quest_start, quest_start_active, quest_end, aura_spell, racemask, gender, autocast FROM spell_area" );
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( ! result )
2008-11-17 22:07:21 -06:00
{
2009-11-19 03:53:49 -08:00
barGoLink bar ( 1 );
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2009-11-19 03:53:49 -08:00
sLog . outString ( ">> Loaded %u spell area requirements" , count );
2008-11-17 22:07:21 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
barGoLink bar ( result -> GetRowCount ());
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
do
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
uint32 spell = fields [ 0 ]. GetUInt32 ();
SpellArea spellArea ;
spellArea . spellId = spell ;
spellArea . areaId = fields [ 1 ]. GetUInt32 ();
spellArea . questStart = fields [ 2 ]. GetUInt32 ();
spellArea . questStartCanActive = fields [ 3 ]. GetBool ();
spellArea . questEnd = fields [ 4 ]. GetUInt32 ();
spellArea . auraSpell = fields [ 5 ]. GetInt32 ();
spellArea . raceMask = fields [ 6 ]. GetUInt32 ();
spellArea . gender = Gender ( fields [ 7 ]. GetUInt8 ());
spellArea . autocast = fields [ 8 ]. GetBool ();
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
if ( const SpellEntry * spellInfo = sSpellStore . LookupEntry ( spell ))
2009-06-17 13:34:05 -05:00
{
2010-04-07 19:14:10 +02:00
if ( spellArea . autocast )
2009-06-17 13:34:05 -05:00
const_cast < SpellEntry *> ( spellInfo ) -> Attributes |= SPELL_ATTR_CANT_CANCEL ;
}
2009-06-17 00:58:06 -05:00
else
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
sLog . outErrorDb ( "Spell %u listed in `spell_area` does not exist" , spell );
2008-11-17 22:07:21 -06:00
continue ;
}
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
bool ok = true ;
SpellAreaMapBounds sa_bounds = GetSpellAreaMapBounds ( spellArea . spellId );
2009-10-17 16:20:24 -07:00
for ( SpellAreaMap :: const_iterator itr = sa_bounds . first ; itr != sa_bounds . second ; ++ itr )
2008-11-17 22:07:21 -06:00
{
2009-08-12 20:38:24 -05:00
if ( spellArea . spellId != itr -> second . spellId )
2009-05-15 16:26:00 -05:00
continue ;
2009-08-12 20:38:24 -05:00
if ( spellArea . areaId != itr -> second . areaId )
2009-05-15 16:26:00 -05:00
continue ;
2009-08-12 20:38:24 -05:00
if ( spellArea . questStart != itr -> second . questStart )
2009-05-15 16:26:00 -05:00
continue ;
2009-08-12 20:38:24 -05:00
if ( spellArea . auraSpell != itr -> second . auraSpell )
2009-05-15 16:26:00 -05:00
continue ;
2009-08-12 20:38:24 -05:00
if (( spellArea . raceMask & itr -> second . raceMask ) == 0 )
2009-05-15 16:26:00 -05:00
continue ;
2009-08-12 20:38:24 -05:00
if ( spellArea . gender != itr -> second . gender )
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// duplicate by requirements
ok = false ;
2008-11-17 22:07:21 -06:00
break ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! ok )
2009-05-15 16:26:00 -05:00
{
sLog . outErrorDb ( "Spell %u listed in `spell_area` already listed with similar requirements." , spell );
continue ;
}
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( spellArea . areaId && ! GetAreaEntryByAreaID ( spellArea . areaId ))
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
sLog . outErrorDb ( "Spell %u listed in `spell_area` have wrong area (%u) requirement" , spell , spellArea . areaId );
2008-11-17 22:07:21 -06:00
continue ;
2009-05-15 16:26:00 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-08 05:25:45 +02:00
if ( spellArea . questStart && ! sObjectMgr . GetQuestTemplate ( spellArea . questStart ))
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
sLog . outErrorDb ( "Spell %u listed in `spell_area` have wrong start quest (%u) requirement" , spell , spellArea . questStart );
2008-11-17 22:07:21 -06:00
continue ;
}
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( spellArea . questEnd )
2008-11-17 22:07:21 -06:00
{
2010-08-08 05:25:45 +02:00
if ( ! sObjectMgr . GetQuestTemplate ( spellArea . questEnd ))
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
sLog . outErrorDb ( "Spell %u listed in `spell_area` have wrong end quest (%u) requirement" , spell , spellArea . questEnd );
continue ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 23:25:02 +02:00
if ( spellArea . questEnd == spellArea . questStart && ! spellArea . questStartCanActive )
2009-05-15 16:26:00 -05:00
{
sLog . outErrorDb ( "Spell %u listed in `spell_area` have quest (%u) requirement for start and end in same time" , spell , spellArea . questEnd );
continue ;
2008-11-17 22:07:21 -06:00
}
}
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( spellArea . auraSpell )
2009-05-15 16:26:00 -05:00
{
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( abs ( spellArea . auraSpell ));
2009-11-19 03:53:49 -08:00
if ( ! spellInfo )
2009-05-15 16:26:00 -05:00
{
sLog . outErrorDb ( "Spell %u listed in `spell_area` have wrong aura spell (%u) requirement" , spell , abs ( spellArea . auraSpell ));
continue ;
}
2009-10-17 15:51:44 -07:00
2010-05-01 22:25:14 +02:00
if ( uint32 ( abs ( spellArea . auraSpell )) == spellArea . spellId )
2009-05-15 16:26:00 -05:00
{
sLog . outErrorDb ( "Spell %u listed in `spell_area` have aura spell (%u) requirement for itself" , spell , abs ( spellArea . auraSpell ));
continue ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// not allow autocast chains by auraSpell field (but allow use as alternative if not present)
2009-11-19 03:53:49 -08:00
if ( spellArea . autocast && spellArea . auraSpell > 0 )
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
bool chain = false ;
SpellAreaForAuraMapBounds saBound = GetSpellAreaForAuraMapBounds ( spellArea . spellId );
2009-10-17 16:20:24 -07:00
for ( SpellAreaForAuraMap :: const_iterator itr = saBound . first ; itr != saBound . second ; ++ itr )
2008-11-17 22:07:21 -06:00
{
2009-11-19 03:53:49 -08:00
if ( itr -> second -> autocast && itr -> second -> auraSpell > 0 )
2009-05-15 16:26:00 -05:00
{
chain = true ;
break ;
}
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( chain )
2009-05-15 16:26:00 -05:00
{
sLog . outErrorDb ( "Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura" , spell , spellArea . auraSpell );
continue ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
SpellAreaMapBounds saBound2 = GetSpellAreaMapBounds ( spellArea . auraSpell );
2009-10-17 16:20:24 -07:00
for ( SpellAreaMap :: const_iterator itr2 = saBound2 . first ; itr2 != saBound2 . second ; ++ itr2 )
2009-05-15 16:26:00 -05:00
{
2009-11-19 03:53:49 -08:00
if ( itr2 -> second . autocast && itr2 -> second . auraSpell > 0 )
2009-05-15 16:26:00 -05:00
{
chain = true ;
break ;
}
}
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( chain )
2009-05-15 16:26:00 -05:00
{
sLog . outErrorDb ( "Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura" , spell , spellArea . auraSpell );
continue ;
}
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 23:25:02 +02:00
if ( spellArea . raceMask && ( spellArea . raceMask & RACEMASK_ALL_PLAYABLE ) == 0 )
2009-05-15 16:26:00 -05:00
{
sLog . outErrorDb ( "Spell %u listed in `spell_area` have wrong race mask (%u) requirement" , spell , spellArea . raceMask );
continue ;
}
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( spellArea . gender != GENDER_NONE && spellArea . gender != GENDER_FEMALE && spellArea . gender != GENDER_MALE )
2009-05-15 16:26:00 -05:00
{
2009-11-19 03:53:49 -08:00
sLog . outErrorDb ( "Spell %u listed in `spell_area` have wrong gender (%u) requirement" , spell , spellArea . gender );
2009-05-15 16:26:00 -05:00
continue ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
SpellArea const * sa = & mSpellAreaMap . insert ( SpellAreaMap :: value_type ( spell , spellArea )) -> second ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// for search by current zone/subzone at zone/subzone change
2009-11-19 03:53:49 -08:00
if ( spellArea . areaId )
2009-05-15 16:26:00 -05:00
mSpellAreaForAreaMap . insert ( SpellAreaForAreaMap :: value_type ( spellArea . areaId , sa ));
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// for search at quest start/reward
2009-11-19 03:53:49 -08:00
if ( spellArea . questStart )
2008-11-17 22:07:21 -06:00
{
2009-11-19 03:53:49 -08:00
if ( spellArea . questStartCanActive )
2009-05-15 16:26:00 -05:00
mSpellAreaForActiveQuestMap . insert ( SpellAreaForQuestMap :: value_type ( spellArea . questStart , sa ));
else
mSpellAreaForQuestMap . insert ( SpellAreaForQuestMap :: value_type ( spellArea . questStart , sa ));
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// for search at quest start/reward
2009-11-19 03:53:49 -08:00
if ( spellArea . questEnd )
2009-05-15 16:26:00 -05:00
mSpellAreaForQuestEndMap . insert ( SpellAreaForQuestMap :: value_type ( spellArea . questEnd , sa ));
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// for search at aura apply
2009-11-19 03:53:49 -08:00
if ( spellArea . auraSpell )
2009-05-15 16:26:00 -05:00
mSpellAreaForAuraMap . insert ( SpellAreaForAuraMap :: value_type ( abs ( spellArea . auraSpell ), sa ));
2009-10-17 15:51:44 -07:00
2008-11-17 22:07:21 -06:00
++ count ;
2010-04-07 19:13:19 +02:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell area requirements" , count );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
SpellCastResult SpellMgr :: GetSpellAllowedInLocationError ( SpellEntry const * spellInfo , uint32 map_id , uint32 zone_id , uint32 area_id , Player const * player )
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
// normal case
2009-08-05 16:33:34 -05:00
if ( spellInfo -> AreaGroupId > 0 )
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
bool found = false ;
AreaGroupEntry const * groupEntry = sAreaGroupStore . LookupEntry ( spellInfo -> AreaGroupId );
while ( groupEntry )
{
2010-09-28 08:21:51 +03:00
for ( uint8 i = 0 ; i < MAX_GROUP_AREA_IDS ; ++ i )
2009-09-11 12:57:21 -07:00
if ( groupEntry -> AreaId [ i ] == zone_id || groupEntry -> AreaId [ i ] == area_id )
2009-05-15 16:26:00 -05:00
found = true ;
if ( found || ! groupEntry -> nextGroup )
break ;
// Try search in next group
groupEntry = sAreaGroupStore . LookupEntry ( groupEntry -> nextGroup );
}
2009-10-17 16:20:24 -07:00
2009-09-11 12:57:21 -07:00
if ( ! found )
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_INCORRECT_AREA ;
}
2009-10-17 15:51:44 -07:00
2009-08-05 16:33:34 -05:00
// continent limitation (virtual continent)
if ( spellInfo -> AttributesEx4 & SPELL_ATTR_EX4_CAST_ONLY_IN_OUTLAND )
{
uint32 v_map = GetVirtualMapForMapAndZone ( map_id , zone_id );
2009-11-19 03:53:49 -08:00
MapEntry const * mapEntry = sMapStore . LookupEntry ( v_map );
2009-09-11 12:57:21 -07:00
if ( ! mapEntry || mapEntry -> addon < 1 || ! mapEntry -> IsContinent ())
2009-08-05 16:33:34 -05:00
return SPELL_FAILED_INCORRECT_AREA ;
}
2009-10-17 15:51:44 -07:00
2009-09-11 12:57:21 -07:00
// raid instance limitation
if ( spellInfo -> AttributesEx6 & SPELL_ATTR_EX6_NOT_IN_RAID_INSTANCE )
{
2009-11-19 03:53:49 -08:00
MapEntry const * mapEntry = sMapStore . LookupEntry ( map_id );
2009-09-11 12:57:21 -07:00
if ( ! mapEntry || mapEntry -> IsRaid ())
return SPELL_FAILED_NOT_IN_RAID_INSTANCE ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// DB base check (if non empty then must fit at least single for allow)
2010-08-08 05:25:45 +02:00
SpellAreaMapBounds saBounds = sSpellMgr . GetSpellAreaMapBounds ( spellInfo -> Id );
2009-08-05 16:33:34 -05:00
if ( saBounds . first != saBounds . second )
2009-05-15 16:26:00 -05:00
{
2009-10-17 16:20:24 -07:00
for ( SpellAreaMap :: const_iterator itr = saBounds . first ; itr != saBounds . second ; ++ itr )
2008-11-17 22:07:21 -06:00
{
2010-04-07 19:14:10 +02:00
if ( itr -> second . IsFitToRequirements ( player , zone_id , area_id ))
2009-05-15 16:26:00 -05:00
return SPELL_CAST_OK ;
2008-12-22 11:36:13 -06:00
}
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_INCORRECT_AREA ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// bg spell checks
switch ( spellInfo -> Id )
{
case 23333 : // Warsong Flag
case 23335 : // Silverwing Flag
2010-08-08 04:37:24 +02:00
return map_id == 489 && player && player -> InBattleground () ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA ;
2009-05-15 16:26:00 -05:00
case 34976 : // Netherstorm Flag
2010-08-08 04:37:24 +02:00
return map_id == 566 && player && player -> InBattleground () ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA ;
2009-05-15 16:26:00 -05:00
case 2584 : // Waiting to Resurrect
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)
2008-12-22 11:36:13 -06:00
{
2009-05-15 16:26:00 -05:00
MapEntry const * mapEntry = sMapStore . LookupEntry ( map_id );
2009-08-05 16:33:34 -05:00
if ( ! mapEntry )
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_INCORRECT_AREA ;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
return zone_id == 4197 || ( mapEntry -> IsBattleground () && player && player -> InBattleground ()) ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA ;
2008-11-17 22:07:21 -06:00
}
2009-05-15 16:26:00 -05:00
case 44521 : // Preparation
2009-05-01 15:36:32 -05:00
{
2009-08-05 16:33:34 -05:00
if ( ! player )
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_REQUIRES_AREA ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
MapEntry const * mapEntry = sMapStore . LookupEntry ( map_id );
2009-08-05 16:33:34 -05:00
if ( ! mapEntry )
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_INCORRECT_AREA ;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
if ( ! mapEntry -> IsBattleground ())
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_REQUIRES_AREA ;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
Battleground * bg = player -> GetBattleground ();
2009-11-19 03:53:49 -08:00
return bg && bg -> GetStatus () == STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA ;
2008-11-17 22:07:21 -06:00
}
2009-05-15 16:26:00 -05:00
case 32724 : // Gold Team (Alliance)
case 32725 : // Green Team (Alliance)
case 35774 : // Gold Team (Horde)
case 35775 : // Green Team (Horde)
{
2009-11-19 03:53:49 -08:00
MapEntry const * mapEntry = sMapStore . LookupEntry ( map_id );
2009-08-05 16:33:34 -05:00
if ( ! mapEntry )
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_INCORRECT_AREA ;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
return mapEntry -> IsBattleArena () && player && player -> InBattleground () ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA ;
2009-05-15 16:26:00 -05:00
}
case 32727 : // Arena Preparation
2009-03-21 23:01:36 -06:00
{
2009-08-05 16:33:34 -05:00
if ( ! player )
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_REQUIRES_AREA ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
MapEntry const * mapEntry = sMapStore . LookupEntry ( map_id );
if ( ! mapEntry )
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_INCORRECT_AREA ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
if ( ! mapEntry -> IsBattleArena ())
2009-05-15 16:26:00 -05:00
return SPELL_FAILED_REQUIRES_AREA ;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
Battleground * bg = player -> GetBattleground ();
2009-11-19 03:53:49 -08:00
return bg && bg -> GetStatus () == STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA ;
2009-03-21 23:01:36 -06:00
}
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-09-23 00:45:47 -07:00
// aura limitations
2009-11-19 03:53:49 -08:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-09-23 00:45:47 -07:00
{
2009-11-19 03:53:49 -08:00
switch ( spellInfo -> EffectApplyAuraName [ i ])
2009-09-23 00:45:47 -07:00
{
case SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED :
case SPELL_AURA_FLY :
{
if ( player && ! player -> IsKnowHowFlyIn ( map_id , zone_id ))
return SPELL_FAILED_INCORRECT_AREA ;
}
}
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
return SPELL_CAST_OK ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
void SpellMgr :: LoadSkillLineAbilityMap ()
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
mSkillLineAbilityMap . clear ();
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
barGoLink bar ( sSkillLineAbilityStore . GetNumRows ());
2008-11-17 22:07:21 -06:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
for ( uint32 i = 0 ; i < sSkillLineAbilityStore . GetNumRows (); ++ i )
2008-11-17 22:07:21 -06:00
{
bar . step ();
2009-05-15 16:26:00 -05:00
SkillLineAbilityEntry const * SkillInfo = sSkillLineAbilityStore . LookupEntry ( i );
2009-11-19 03:53:49 -08:00
if ( ! SkillInfo )
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
mSkillLineAbilityMap . insert ( SkillLineAbilityMap :: value_type ( SkillInfo -> spellId , SkillInfo ));
++ count ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
sLog . outString ();
sLog . outString ( ">> Loaded %u SkillLineAbility MultiMap Data" , count );
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
DiminishingGroup GetDiminishingReturnsGroupForSpell ( SpellEntry const * spellproto , bool triggered )
{
// Explicit Diminishing Groups
2009-11-19 03:53:49 -08:00
switch ( spellproto -> SpellFamilyName )
2008-11-17 22:07:21 -06:00
{
2009-07-30 11:06:31 +08:00
case SPELLFAMILY_GENERIC :
// some generic arena related spells have by some strange reason MECHANIC_TURN
if ( spellproto -> Mechanic == MECHANIC_TURN )
return DIMINISHING_NONE ;
break ;
2009-07-07 07:04:01 +08:00
case SPELLFAMILY_MAGE :
{
2009-08-12 18:51:19 +02:00
// Frostbite
2009-07-07 07:04:01 +08:00
if ( spellproto -> SpellFamilyFlags [ 1 ] & 0x80000000 )
return DIMINISHING_TRIGGER_ROOT ;
2010-05-25 10:36:33 +02:00
//Shattered Barrier: only flag SpellFamilyFlags[0] = 0x00080000 shared
//by most frost spells, using id instead
if ( spellproto -> Id == 55080 )
return DIMINISHING_TRIGGER_ROOT ;
// Frost Nova / Freeze (Water Elemental)
if ( spellproto -> SpellIconID == 193 )
return DIMINISHING_CONTROL_ROOT ;
2009-07-07 07:04:01 +08:00
break ;
}
2009-05-15 16:26:00 -05:00
case SPELLFAMILY_ROGUE :
2008-11-17 22:07:21 -06:00
{
2009-06-27 18:24:40 -05:00
// Sap 0x80 Gouge 0x8
if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x88 )
2009-05-15 16:26:00 -05:00
return DIMINISHING_POLYMORPH ;
// Blind
2009-06-01 14:55:51 -05:00
else if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x1000000 )
2009-06-16 02:26:40 +02:00
return DIMINISHING_FEAR_BLIND ;
// Cheap Shot
else if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x400 )
return DIMINISHING_CHEAPSHOT_POUNCE ;
2009-07-07 06:08:15 +08:00
// Crippling poison - Limit to 10 seconds in PvP (No SpellFamilyFlags)
else if ( spellproto -> SpellIconID == 163 )
return DIMINISHING_LIMITONLY ;
2009-06-01 14:55:51 -05:00
break ;
}
2009-05-15 16:26:00 -05:00
case SPELLFAMILY_WARLOCK :
2009-02-05 22:49:07 -06:00
{
2009-05-15 16:26:00 -05:00
// Death Coil
2009-06-01 14:55:51 -05:00
if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x80000 )
2009-05-15 16:26:00 -05:00
return DIMINISHING_DEATHCOIL ;
// Curses/etc
else if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x80000000 )
return DIMINISHING_LIMITONLY ;
2009-06-16 02:26:40 +02:00
// Howl of Terror
else if ( spellproto -> SpellFamilyFlags [ 1 ] & 0x8 )
return DIMINISHING_FEAR_BLIND ;
2009-08-23 11:37:06 -05:00
// Seduction
else if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x40000000 )
return DIMINISHING_FEAR_BLIND ;
2009-05-15 16:26:00 -05:00
break ;
2009-02-05 22:49:07 -06:00
}
2009-05-15 16:26:00 -05:00
case SPELLFAMILY_DRUID :
2009-02-05 22:49:07 -06:00
{
2009-06-16 02:26:40 +02:00
// Pounce
if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x20000 )
return DIMINISHING_CHEAPSHOT_POUNCE ;
2009-06-27 18:24:40 -05:00
// Cyclone
else if ( spellproto -> SpellFamilyFlags [ 1 ] & 0x20 )
return DIMINISHING_CYCLONE ;
2009-08-12 18:51:19 +02:00
// Entangling Roots: to force natures grasp proc to be control root
2009-06-16 02:26:40 +02:00
else if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x00000200 )
return DIMINISHING_CONTROL_ROOT ;
2009-07-07 06:08:15 +08:00
// Faerie Fire
else if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x400 )
return DIMINISHING_LIMITONLY ;
2009-06-16 02:26:40 +02:00
break ;
}
2009-05-15 16:26:00 -05:00
case SPELLFAMILY_WARRIOR :
2009-02-06 15:07:56 -06:00
{
2009-05-15 16:26:00 -05:00
// Hamstring - limit duration to 10s in PvP
2009-06-01 14:55:51 -05:00
if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x2 )
2009-05-15 16:26:00 -05:00
return DIMINISHING_LIMITONLY ;
2009-06-16 02:26:40 +02:00
// Intimidating Shout
else if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x40000 )
return DIMINISHING_FEAR_BLIND ;
2009-07-19 14:56:18 +02:00
// Charge Stun
else if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x01000000 )
2009-06-16 02:26:40 +02:00
return DIMINISHING_NONE ;
break ;
}
case SPELLFAMILY_PALADIN :
{
// Repentance
if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x4 )
return DIMINISHING_POLYMORPH ;
break ;
}
case SPELLFAMILY_DEATHKNIGHT :
{
2009-06-27 18:24:40 -05:00
// Hungering Cold (no flags)
2009-06-16 02:26:40 +02:00
if ( spellproto -> SpellIconID == 2797 )
return DIMINISHING_POLYMORPH ;
2010-04-21 18:53:51 +02:00
// Mark of Blood
else if (( spellproto -> SpellFamilyFlags [ 0 ] & 0x10000000 )
&& spellproto -> SpellIconID == 2285 )
return DIMINISHING_LIMITONLY ;
2009-05-15 16:26:00 -05:00
break ;
2009-02-06 15:07:56 -06:00
}
2010-04-11 11:00:51 +02:00
case SPELLFAMILY_HUNTER :
{
// Hunter's mark
if (( spellproto -> SpellFamilyFlags [ 0 ] & 0x400 ) && spellproto -> SpellIconID == 538 )
return DIMINISHING_LIMITONLY ;
2010-07-24 07:19:59 +02:00
// Scatter Shot
if (( spellproto -> SpellFamilyFlags [ 0 ] & 0x40000 ) && spellproto -> SpellIconID == 132 )
return DIMINISHING_NONE ;
2010-04-11 11:00:51 +02:00
break ;
}
2009-05-15 16:26:00 -05:00
default :
break ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// Get by mechanic
uint32 mechanic = GetAllSpellMechanicMask ( spellproto );
if ( mechanic == MECHANIC_NONE ) return DIMINISHING_NONE ;
2009-07-23 09:34:10 +08:00
if ( mechanic & (( 1 << MECHANIC_STUN ) |
( 1 << MECHANIC_SHACKLE ))) return triggered ? DIMINISHING_TRIGGER_STUN : DIMINISHING_CONTROL_STUN ;
if ( mechanic & (( 1 << MECHANIC_SLEEP ) |
( 1 << MECHANIC_FREEZE ))) return DIMINISHING_FREEZE_SLEEP ;
2009-05-15 16:26:00 -05:00
if ( mechanic & ( 1 << MECHANIC_POLYMORPH )) return DIMINISHING_POLYMORPH ;
if ( mechanic & ( 1 << MECHANIC_ROOT )) return triggered ? DIMINISHING_TRIGGER_ROOT : DIMINISHING_CONTROL_ROOT ;
2009-07-23 09:34:10 +08:00
if ( mechanic & (( 1 << MECHANIC_FEAR ) |
( 1 << MECHANIC_TURN ))) return DIMINISHING_FEAR_BLIND ;
2009-05-15 16:26:00 -05:00
if ( mechanic & ( 1 << MECHANIC_CHARM )) return DIMINISHING_CHARM ;
if ( mechanic & ( 1 << MECHANIC_SILENCE )) return DIMINISHING_SILENCE ;
if ( mechanic & ( 1 << MECHANIC_DISARM )) return DIMINISHING_DISARM ;
2009-07-23 09:34:10 +08:00
if ( mechanic & ( 1 << MECHANIC_FREEZE )) return DIMINISHING_FREEZE_SLEEP ;
if ( mechanic & (( 1 << MECHANIC_KNOCKOUT ) |
( 1 << MECHANIC_SAPPED ))) return DIMINISHING_KNOCKOUT ;
2009-05-15 16:26:00 -05:00
if ( mechanic & ( 1 << MECHANIC_BANISH )) return DIMINISHING_BANISH ;
if ( mechanic & ( 1 << MECHANIC_HORROR )) return DIMINISHING_DEATHCOIL ;
2009-10-17 15:51:44 -07:00
2009-06-16 02:26:40 +02:00
// Get by effect
2009-11-19 03:53:49 -08:00
for ( uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-06-16 02:26:40 +02:00
{
if ( spellproto -> EffectApplyAuraName [ i ] == SPELL_AURA_MOD_TAUNT )
return DIMINISHING_TAUNT ;
}
2009-05-15 16:26:00 -05:00
return DIMINISHING_NONE ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-06-27 18:24:40 -05:00
int32 GetDiminishingReturnsLimitDuration ( DiminishingGroup group , SpellEntry const * spellproto )
{
2010-04-07 19:14:10 +02:00
if ( ! IsDiminishingReturnsGroupDurationLimited ( group ))
2009-06-27 18:24:40 -05:00
return 0 ;
2009-10-17 15:51:44 -07:00
2009-06-27 18:24:40 -05:00
// Explicit diminishing duration
switch ( spellproto -> SpellFamilyName )
{
case SPELLFAMILY_HUNTER :
{
// Wyvern Sting
if ( spellproto -> SpellFamilyFlags [ 1 ] & 0x1000 )
2010-07-12 00:30:17 +02:00
return 6 * IN_MILLISECONDS ;
2010-04-11 11:00:51 +02:00
// Hunter's Mark
if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x400 )
2010-07-12 00:30:17 +02:00
return 120 * IN_MILLISECONDS ;
2009-06-27 18:24:40 -05:00
break ;
}
case SPELLFAMILY_PALADIN :
{
// Repentance - limit to 6 seconds in PvP
if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x4 )
2010-07-12 00:30:17 +02:00
return 6 * IN_MILLISECONDS ;
2009-06-27 18:24:40 -05:00
break ;
}
2009-07-07 06:08:15 +08:00
case SPELLFAMILY_DRUID :
{
// Faerie Fire - limit to 40 seconds in PvP (3.1)
if ( spellproto -> SpellFamilyFlags [ 0 ] & 0x400 )
2010-07-12 00:30:17 +02:00
return 40 * IN_MILLISECONDS ;
2009-07-07 06:08:15 +08:00
break ;
}
2009-06-27 18:24:40 -05:00
default :
break ;
}
2009-10-17 15:51:44 -07:00
2010-07-12 00:30:17 +02:00
return 10 * IN_MILLISECONDS ;
2009-06-27 18:24:40 -05:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
bool IsDiminishingReturnsGroupDurationLimited ( DiminishingGroup group )
2008-12-24 09:58:26 -06:00
{
2009-05-15 16:26:00 -05:00
switch ( group )
2008-12-24 09:58:26 -06:00
{
2009-05-15 16:26:00 -05:00
case DIMINISHING_CONTROL_STUN :
case DIMINISHING_TRIGGER_STUN :
2009-06-27 18:24:40 -05:00
case DIMINISHING_FREEZE_SLEEP :
2009-05-15 16:26:00 -05:00
case DIMINISHING_CONTROL_ROOT :
case DIMINISHING_TRIGGER_ROOT :
2009-06-16 02:26:40 +02:00
case DIMINISHING_FEAR_BLIND :
2009-05-15 16:26:00 -05:00
case DIMINISHING_CHARM :
case DIMINISHING_POLYMORPH :
case DIMINISHING_KNOCKOUT :
2009-06-27 18:24:40 -05:00
case DIMINISHING_CYCLONE :
2009-05-15 16:26:00 -05:00
case DIMINISHING_BANISH :
case DIMINISHING_LIMITONLY :
2009-06-16 02:26:40 +02:00
case DIMINISHING_CHEAPSHOT_POUNCE :
2009-05-15 16:26:00 -05:00
return true ;
default :
return false ;
}
}
2009-10-17 15:51:44 -07:00
2010-02-14 19:13:14 -07:00
DiminishingLevels GetDiminishingReturnsMaxLevel ( DiminishingGroup group )
{
switch ( group )
{
case DIMINISHING_TAUNT :
return DIMINISHING_LEVEL_TAUNT_IMMUNE ;
default :
return DIMINISHING_LEVEL_IMMUNE ;
}
}
2009-05-15 16:26:00 -05:00
DiminishingReturnsType GetDiminishingReturnsGroupType ( DiminishingGroup group )
{
switch ( group )
{
2009-06-16 02:26:40 +02:00
case DIMINISHING_TAUNT :
2009-05-15 16:26:00 -05:00
case DIMINISHING_CONTROL_STUN :
case DIMINISHING_TRIGGER_STUN :
2009-06-16 02:26:40 +02:00
case DIMINISHING_CHEAPSHOT_POUNCE :
2009-06-27 18:24:40 -05:00
case DIMINISHING_CYCLONE :
2009-05-15 16:26:00 -05:00
return DRTYPE_ALL ;
2009-07-07 16:40:44 +02:00
case DIMINISHING_FEAR_BLIND :
2009-05-15 16:26:00 -05:00
case DIMINISHING_CONTROL_ROOT :
case DIMINISHING_TRIGGER_ROOT :
case DIMINISHING_CHARM :
case DIMINISHING_POLYMORPH :
case DIMINISHING_SILENCE :
case DIMINISHING_DISARM :
case DIMINISHING_DEATHCOIL :
2009-06-27 18:24:40 -05:00
case DIMINISHING_FREEZE_SLEEP :
case DIMINISHING_BANISH :
2009-05-15 16:26:00 -05:00
case DIMINISHING_KNOCKOUT :
return DRTYPE_PLAYER ;
default :
break ;
2008-12-24 09:58:26 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
return DRTYPE_NONE ;
2008-12-24 09:58:26 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
bool SpellArea :: IsFitToRequirements ( Player const * player , uint32 newZone , uint32 newArea ) const
2008-11-17 22:07:21 -06:00
{
2010-01-07 07:36:49 +01:00
if ( gender != GENDER_NONE ) // not in expected gender
if ( ! player || gender != player -> getGender ())
2009-05-15 16:26:00 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2010-01-07 07:36:49 +01:00
if ( raceMask ) // not in expected race
if ( ! player || ! ( raceMask & player -> getRaceMask ()))
2009-05-15 16:26:00 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2010-01-07 07:36:49 +01:00
if ( areaId ) // not in expected zone
if ( newZone != areaId && newArea != areaId )
2009-05-15 16:26:00 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2010-01-07 07:36:49 +01:00
if ( questStart ) // not in expected required quest state
2010-08-21 21:54:41 +02:00
if ( ! player || (( ! questStartCanActive || ! player -> IsActiveQuest ( questStart )) && ! player -> GetQuestRewardStatus ( questStart )))
2009-05-15 16:26:00 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2010-01-07 07:36:49 +01:00
if ( questEnd ) // not in expected forbidden quest state
if ( ! player || player -> GetQuestRewardStatus ( questEnd ))
2009-05-15 16:26:00 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2010-01-07 07:36:49 +01:00
if ( auraSpell ) // not have expected aura
2010-08-21 21:54:41 +02:00
if ( ! player || ( auraSpell > 0 && ! player -> HasAura ( auraSpell )) || ( auraSpell < 0 && player -> HasAura ( - auraSpell )))
2009-05-15 16:26:00 -05:00
return false ;
2010-02-14 19:13:14 -07:00
2010-01-20 15:04:47 -07:00
// Extra conditions -- leaving the possibility add extra conditions...
switch ( spellId )
{
2010-08-06 20:09:23 +02:00
case 58600 : // No fly Zone - Dalaran
2010-06-16 19:36:50 +02:00
if ( ! player )
return false ;
2010-06-16 19:58:40 +02:00
AreaTableEntry const * pArea = GetAreaEntryByAreaID ( player -> GetAreaId ());
2010-06-16 19:36:50 +02:00
if ( ! ( pArea && pArea -> flags & AREA_FLAG_NO_FLY_ZONE ))
return false ;
2010-08-06 20:09:23 +02:00
if ( ! player -> HasAuraType ( SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED ) && ! player -> HasAuraType ( SPELL_AURA_FLY ))
2010-01-20 15:04:47 -07:00
return false ;
break ;
}
2010-01-21 01:28:18 +01:00
return true ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
//-----------TRINITY-------------
2009-10-17 15:51:44 -07:00
2009-08-23 10:22:58 -05:00
bool SpellMgr :: CanAurasStack ( SpellEntry const * spellInfo_1 , SpellEntry const * spellInfo_2 , bool sameCaster ) const
2009-05-15 16:26:00 -05:00
{
2010-01-20 20:54:32 +01:00
SpellSpecific spellSpec_1 = GetSpellSpecific ( spellInfo_1 );
SpellSpecific spellSpec_2 = GetSpellSpecific ( spellInfo_2 );
2009-08-23 10:22:58 -05:00
if ( spellSpec_1 && spellSpec_2 )
if ( IsSingleFromSpellSpecificPerTarget ( spellSpec_1 , spellSpec_2 )
2010-08-21 21:54:41 +02:00
|| ( sameCaster && IsSingleFromSpellSpecificPerCaster ( spellSpec_1 , spellSpec_2 )))
2009-08-23 10:22:58 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2010-02-02 22:35:01 +01:00
SpellGroupStackRule stackRule = CheckSpellGroupStackRules ( spellInfo_1 -> Id , spellInfo_2 -> Id );
if ( stackRule )
{
if ( stackRule == SPELL_GROUP_STACK_RULE_EXCLUSIVE )
2010-01-23 17:05:20 +01:00
return false ;
2010-02-02 22:35:01 +01:00
if ( sameCaster && stackRule == SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER )
return false ;
}
2010-01-23 17:05:20 +01:00
2010-04-07 19:14:10 +02:00
if ( spellInfo_1 -> SpellFamilyName != spellInfo_2 -> SpellFamilyName )
2009-08-23 10:22:58 -05:00
return true ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! sameCaster )
2009-05-15 16:26:00 -05:00
{
2010-04-07 19:14:10 +02:00
if ( spellInfo_1 -> AttributesEx & SPELL_ATTR_EX_STACK_FOR_DIFF_CASTERS
2009-08-23 10:22:58 -05:00
|| spellInfo_1 -> AttributesEx3 & SPELL_ATTR_EX3_STACK_FOR_DIFF_CASTERS )
return true ;
2009-10-17 16:20:24 -07:00
2009-08-23 10:22:58 -05:00
// check same periodic auras
2010-02-02 22:35:01 +01:00
for ( uint32 i = 0 ; i < MAX_SPELL_EFFECTS ; ++ i )
2009-08-23 10:22:58 -05:00
{
switch ( spellInfo_1 -> EffectApplyAuraName [ i ])
2009-06-28 15:13:56 +02:00
{
2009-08-23 10:22:58 -05:00
// DOT or HOT from different casters will stack
case SPELL_AURA_PERIODIC_DAMAGE :
2010-07-19 13:57:28 +02:00
case SPELL_AURA_PERIODIC_DUMMY :
2009-08-23 10:22:58 -05:00
case SPELL_AURA_PERIODIC_HEAL :
case SPELL_AURA_PERIODIC_TRIGGER_SPELL :
case SPELL_AURA_PERIODIC_ENERGIZE :
case SPELL_AURA_PERIODIC_MANA_LEECH :
case SPELL_AURA_PERIODIC_LEECH :
case SPELL_AURA_POWER_BURN_MANA :
2009-08-24 20:17:33 -05:00
case SPELL_AURA_OBS_MOD_POWER :
2009-08-23 10:22:58 -05:00
case SPELL_AURA_OBS_MOD_HEALTH :
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE :
return true ;
default :
break ;
2009-06-28 15:13:56 +02:00
}
2009-08-23 10:22:58 -05:00
}
2009-05-15 16:26:00 -05:00
}
2009-10-17 15:51:44 -07:00
2009-08-23 10:22:58 -05:00
uint32 spellId_1 = GetLastSpellInChain ( spellInfo_1 -> Id );
uint32 spellId_2 = GetLastSpellInChain ( spellInfo_2 -> Id );
2009-10-17 15:51:44 -07:00
2009-08-23 10:22:58 -05:00
// same spell
2009-05-15 16:26:00 -05:00
if ( spellId_1 == spellId_2 )
2009-08-23 10:22:58 -05:00
{
// Hack for Incanter's Absorption
2010-04-07 19:14:10 +02:00
if ( spellId_1 == 44413 )
2009-08-23 10:22:58 -05:00
return true ;
// same spell with same caster should not stack
return false ;
}
2009-10-17 15:51:44 -07:00
2010-08-24 14:38:00 +03:00
return true ;
2009-05-15 16:26:00 -05:00
}
2009-10-17 15:51:44 -07:00
2010-07-26 19:27:28 +02:00
bool CanSpellDispelAura ( SpellEntry const * dispelSpell , SpellEntry const * aura )
2009-05-15 16:26:00 -05:00
{
2010-07-26 19:27:28 +02:00
// These auras (like ressurection sickness) can't be dispelled
if ( aura -> Attributes & SPELL_ATTR_NEGATIVE_1 )
2009-05-16 20:23:56 +02:00
return false ;
2009-10-17 15:51:44 -07:00
2010-07-26 19:27:28 +02:00
// These spells (like Mass Dispel) can dispell all auras
2010-04-07 19:14:10 +02:00
if ( dispelSpell -> Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY )
2009-05-15 16:26:00 -05:00
return true ;
2009-10-17 15:51:44 -07:00
2010-07-26 19:27:28 +02:00
// These auras (like Divine Shield) can't be dispelled
if ( aura -> Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY )
return false ;
// These auras (Cyclone for example) are not dispelable
if ( aura -> AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE )
return false ;
return true ;
}
bool CanSpellPierceImmuneAura ( SpellEntry const * pierceSpell , SpellEntry const * aura )
{
// these spells pierce all avalible spells (Resurrection Sickness for example)
if ( pierceSpell -> Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY )
return true ;
// these spells (Cyclone for example) can pierce all...
if (( pierceSpell -> AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE )
// ...but not these (Divine shield for example)
2010-09-18 12:42:17 +02:00
&& ! ( aura && ( aura -> Mechanic == MECHANIC_IMMUNE_SHIELD || aura -> Mechanic == MECHANIC_INVULNERABILITY )))
2010-07-26 19:27:28 +02:00
return true ;
return false ;
2009-05-15 16:26:00 -05:00
}
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
void SpellMgr :: LoadSpellEnchantProcData ()
{
mSpellEnchantProcEventMap . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
// 0 1 2 3
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data" );
2010-01-01 14:19:29 -06:00
if ( ! result )
2009-07-31 13:21:01 +02:00
{
2010-01-01 14:19:29 -06:00
barGoLink bar ( 1 );
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell enchant proc event conditions" , count );
2009-07-31 13:21:01 +02:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( result -> GetRowCount ());
2009-07-31 13:21:01 +02:00
do
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
uint32 enchantId = fields [ 0 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
SpellItemEnchantmentEntry const * ench = sSpellItemEnchantmentStore . LookupEntry ( enchantId );
if ( ! ench )
{
sLog . outErrorDb ( "Enchancment %u listed in `spell_enchant_proc_data` does not exist" , enchantId );
continue ;
}
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
SpellEnchantProcEntry spe ;
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
spe . customChance = fields [ 1 ]. GetUInt32 ();
spe . PPMChance = fields [ 2 ]. GetFloat ();
spe . procEx = fields [ 3 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
mSpellEnchantProcEventMap [ enchantId ] = spe ;
2009-10-17 15:51:44 -07:00
2009-07-31 13:21:01 +02:00
++ count ;
2010-04-07 19:13:19 +02:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u enchant proc data definitions" , count );
2009-07-31 13:21:01 +02:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
void SpellMgr :: LoadSpellRequired ()
{
mSpellsReqSpell . clear (); // need for reload case
mSpellReq . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT spell_id, req_spell from spell_required" );
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
if ( ! result )
2009-05-15 16:26:00 -05:00
{
2009-11-20 19:11:28 -08:00
barGoLink bar ( 1 );
2009-05-15 16:26:00 -05:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
sLog . outString ();
2009-11-20 19:11:28 -08:00
sLog . outString ( ">> Loaded 0 spell required records" );
2009-05-15 16:26:00 -05:00
sLog . outErrorDb ( "`spell_required` table is empty!" );
return ;
}
uint32 rows = 0 ;
2009-10-17 15:51:44 -07:00
2009-11-20 19:11:28 -08:00
barGoLink bar ( result -> GetRowCount ());
2009-05-15 16:26:00 -05:00
do
{
bar . step ();
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
uint32 spell_id = fields [ 0 ]. GetUInt32 ();
2009-05-15 16:26:00 -05:00
uint32 spell_req = fields [ 1 ]. GetUInt32 ();
2010-02-14 19:13:14 -07:00
// check if chain is made with valid first spell
2010-01-30 19:25:04 +01:00
SpellEntry const * spell = sSpellStore . LookupEntry ( spell_id );
if ( ! spell )
{
sLog . outErrorDb ( "spell_id %u in `spell_required` table is not found in dbcs, skipped" , spell_id );
continue ;
}
SpellEntry const * req_spell = sSpellStore . LookupEntry ( spell_req );
if ( ! req_spell )
{
sLog . outErrorDb ( "req_spell %u in `spell_required` table is not found in dbcs, skipped" , spell_req );
continue ;
}
if ( GetFirstSpellInChain ( spell_id ) == GetFirstSpellInChain ( spell_req ))
{
sLog . outErrorDb ( "req_spell %u and spell_id %u in `spell_required` table are ranks of the same spell, entry not needed, skipped" , spell_req , spell_id );
continue ;
}
if ( IsSpellRequiringSpell ( spell_id , spell_req ))
{
sLog . outErrorDb ( "duplicated entry of req_spell %u and spell_id %u in `spell_required`, skipped" , spell_req , spell_id );
continue ;
}
2009-10-17 15:51:44 -07:00
2010-01-30 19:25:04 +01:00
mSpellReq . insert ( std :: pair < uint32 , uint32 > ( spell_id , spell_req ));
2009-05-15 16:26:00 -05:00
mSpellsReqSpell . insert ( std :: pair < uint32 , uint32 > ( spell_req , spell_id ));
++ rows ;
2009-11-20 19:11:28 -08:00
} while ( result -> NextRow ());
2010-01-01 14:19:29 -06:00
2009-05-15 16:26:00 -05:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell required records" , rows );
2009-05-15 16:26:00 -05:00
}
2009-10-17 15:51:44 -07:00
2010-01-29 17:54:29 +01:00
void SpellMgr :: LoadSpellRanks ()
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
mSpellChains . clear (); // need for reload case
2009-10-17 15:51:44 -07:00
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT first_spell_id, spell_id, rank from spell_ranks ORDER BY first_spell_id , rank" );
2009-10-17 15:51:44 -07:00
2010-01-29 17:54:29 +01:00
if ( ! result )
2009-05-15 16:26:00 -05:00
{
2010-01-29 17:54:29 +01:00
barGoLink bar ( 1 );
bar . step ();
2009-10-17 15:51:44 -07:00
2010-01-29 17:54:29 +01:00
sLog . outString ();
sLog . outString ( ">> Loaded 0 spell rank records" );
sLog . outErrorDb ( "`spell_ranks` table is empty!" );
return ;
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2010-01-29 17:54:29 +01:00
barGoLink bar ( result -> GetRowCount ());
2009-10-17 15:51:44 -07:00
2010-01-29 17:54:29 +01:00
uint32 rows = 0 ;
bool finished = false ;
2009-10-17 15:51:44 -07:00
2010-01-29 17:54:29 +01:00
do
2008-11-17 22:07:21 -06:00
{
2010-01-29 17:54:29 +01:00
// spellid, rank
2010-01-29 19:08:42 +01:00
std :: list < std :: pair < int32 , int32 > > rankChain ;
2010-01-29 17:54:29 +01:00
int32 currentSpell = - 1 ;
int32 lastSpell = - 1 ;
2010-02-14 19:13:14 -07:00
2010-01-29 17:54:29 +01:00
// fill one chain
2010-04-07 19:13:19 +02:00
while ( currentSpell == lastSpell && ! finished )
2009-05-15 16:26:00 -05:00
{
2010-01-29 17:54:29 +01:00
Field * fields = result -> Fetch ();
currentSpell = fields [ 0 ]. GetUInt32 ();
if ( lastSpell == - 1 )
lastSpell = currentSpell ;
uint32 spell_id = fields [ 1 ]. GetUInt32 ();
uint32 rank = fields [ 2 ]. GetUInt32 ();
// don't drop the row if we're moving to the next rank
if ( currentSpell == lastSpell )
2009-05-15 16:26:00 -05:00
{
2010-02-01 19:22:32 +01:00
bar . step ();
2010-01-29 17:54:29 +01:00
rankChain . push_back ( std :: make_pair ( spell_id , rank ));
if ( ! result -> NextRow ())
finished = true ;
2009-05-15 16:26:00 -05:00
}
2010-01-29 17:54:29 +01:00
else
break ;
}
// check if chain is made with valid first spell
SpellEntry const * first = sSpellStore . LookupEntry ( lastSpell );
if ( ! first )
2009-05-15 16:26:00 -05:00
{
2010-01-29 17:54:29 +01:00
sLog . outErrorDb ( "Spell rank identifier(first_spell_id) %u listed in `spell_ranks` does not exist!" , lastSpell );
2009-05-15 16:26:00 -05:00
continue ;
}
2010-01-29 17:54:29 +01:00
// check if chain is long enough
if ( rankChain . size () < 2 )
2009-05-15 16:26:00 -05:00
{
2010-01-29 17:54:29 +01:00
sLog . outErrorDb ( "There is only 1 spell rank for identifier(first_spell_id) %u in `spell_ranks`, entry is not needed!" , lastSpell );
continue ;
2009-05-15 16:26:00 -05:00
}
2010-01-29 17:54:29 +01:00
int32 curRank = 0 ;
bool valid = true ;
// check spells in chain
2010-01-29 19:08:42 +01:00
for ( std :: list < std :: pair < int32 , int32 > >:: iterator itr = rankChain . begin () ; itr != rankChain . end (); ++ itr )
2009-05-15 16:26:00 -05:00
{
2010-01-29 17:54:29 +01:00
SpellEntry const * spell = sSpellStore . LookupEntry ( itr -> first );
if ( ! spell )
2009-05-15 16:26:00 -05:00
{
2010-01-29 17:54:29 +01:00
sLog . outErrorDb ( "Spell %u (rank %u) listed in `spell_ranks` for chain %u does not exist!" , itr -> first , itr -> second , lastSpell );
valid = false ;
break ;
}
++ curRank ;
if ( itr -> second != curRank )
{
sLog . outErrorDb ( "Spell %u (rank %u) listed in `spell_ranks` for chain %u does not have proper rank value(should be %u)!" , itr -> first , itr -> second , lastSpell , curRank );
valid = false ;
2010-01-29 18:16:46 +01:00
break ;
2009-05-15 16:26:00 -05:00
}
}
2010-01-29 17:54:29 +01:00
if ( ! valid )
2009-05-15 16:26:00 -05:00
continue ;
2010-01-29 17:54:29 +01:00
int32 prevRank = 0 ;
// insert the chain
2010-01-29 19:08:42 +01:00
std :: list < std :: pair < int32 , int32 > >:: iterator itr = rankChain . begin ();
2010-01-29 17:54:29 +01:00
do
{
2010-02-01 19:22:32 +01:00
++ rows ;
2010-01-29 17:54:29 +01:00
int32 addedSpell = itr -> first ;
mSpellChains [ addedSpell ]. first = lastSpell ;
mSpellChains [ addedSpell ]. last = rankChain . back (). first ;
mSpellChains [ addedSpell ]. rank = itr -> second ;
mSpellChains [ addedSpell ]. prev = prevRank ;
prevRank = addedSpell ;
++ itr ;
if ( itr == rankChain . end ())
2009-05-15 16:26:00 -05:00
{
2010-01-29 17:54:29 +01:00
mSpellChains [ addedSpell ]. next = 0 ;
break ;
2009-05-15 16:26:00 -05:00
}
2010-01-29 17:54:29 +01:00
else
mSpellChains [ addedSpell ]. next = itr -> first ;
2009-05-15 16:26:00 -05:00
}
2010-01-29 17:54:29 +01:00
while ( true );
} while ( ! finished );
2009-10-17 15:51:44 -07:00
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u spell rank records" , rows );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// set data in core for now
void SpellMgr :: LoadSpellCustomAttr ()
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
mSpellCustomAttr . resize ( GetSpellStore () -> GetNumRows ());
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( GetSpellStore () -> GetNumRows ());
uint32 count = 0 ;
2009-05-15 16:26:00 -05:00
SpellEntry * spellInfo ;
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < GetSpellStore () -> GetNumRows (); ++ i )
2008-11-17 22:07:21 -06:00
{
2010-01-01 14:19:29 -06:00
bar . step ();
2009-05-15 16:26:00 -05:00
mSpellCustomAttr [ i ] = 0 ;
spellInfo = ( SpellEntry * ) GetSpellStore () -> LookupEntry ( i );
2009-11-20 19:11:28 -08:00
if ( ! spellInfo )
2009-05-15 16:26:00 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
for ( uint8 j = 0 ; j < MAX_SPELL_EFFECTS ; ++ j )
2009-05-15 16:26:00 -05:00
{
2009-11-20 19:11:28 -08:00
switch ( spellInfo -> Effect [ j ])
2009-05-15 16:26:00 -05:00
{
case SPELL_EFFECT_SCHOOL_DAMAGE :
case SPELL_EFFECT_WEAPON_DAMAGE :
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL :
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG :
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE :
case SPELL_EFFECT_HEAL :
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_DIRECT_DAMAGE ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
case SPELL_EFFECT_CHARGE :
2010-07-19 19:22:05 +02:00
case SPELL_EFFECT_CHARGE_DEST :
2009-05-15 16:26:00 -05:00
case SPELL_EFFECT_JUMP :
2010-07-19 21:24:09 +02:00
case SPELL_EFFECT_JUMP_DEST :
2009-08-27 20:14:50 -05:00
case SPELL_EFFECT_LEAP_BACK :
2010-04-07 19:14:10 +02:00
if ( ! spellInfo -> speed && ! spellInfo -> SpellFamilyName )
2009-05-15 16:26:00 -05:00
spellInfo -> speed = SPEED_CHARGE ;
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_CHARGE ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
2010-01-13 18:22:31 +01:00
case SPELL_EFFECT_PICKPOCKET :
2010-01-19 11:36:05 +01:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_PICKPOCKET ;
break ;
2009-05-15 16:26:00 -05:00
case SPELL_EFFECT_TRIGGER_SPELL :
2009-08-23 00:46:21 -05:00
if ( IsPositionTarget ( spellInfo -> EffectImplicitTargetA [ j ]) ||
2009-05-15 16:26:00 -05:00
spellInfo -> Targets & ( TARGET_FLAG_SOURCE_LOCATION | TARGET_FLAG_DEST_LOCATION ))
spellInfo -> Effect [ j ] = SPELL_EFFECT_TRIGGER_MISSILE ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
}
2009-10-17 15:51:44 -07:00
2009-11-20 19:11:28 -08:00
switch ( SpellTargetType [ spellInfo -> EffectImplicitTargetA [ j ]])
2009-05-15 16:26:00 -05:00
{
case TARGET_TYPE_UNIT_TARGET :
case TARGET_TYPE_DEST_TARGET :
spellInfo -> Targets |= TARGET_FLAG_UNIT ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
2010-08-21 20:55:31 +02:00
default :
break ;
2009-05-15 16:26:00 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
for ( uint8 j = 0 ; j < MAX_SPELL_EFFECTS ; ++ j )
2009-05-15 16:26:00 -05:00
{
2009-11-20 19:11:28 -08:00
switch ( spellInfo -> EffectApplyAuraName [ j ])
2009-05-15 16:26:00 -05:00
{
case SPELL_AURA_MOD_POSSESS :
case SPELL_AURA_MOD_CONFUSE :
case SPELL_AURA_MOD_CHARM :
2009-06-07 23:32:35 -05:00
case SPELL_AURA_AOE_CHARM :
2009-05-15 16:26:00 -05:00
case SPELL_AURA_MOD_FEAR :
case SPELL_AURA_MOD_STUN :
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_AURA_CC ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
}
2009-08-06 11:24:14 -05:00
}
2009-10-17 15:51:44 -07:00
2009-11-20 19:11:28 -08:00
if ( ! _isPositiveEffect ( i , 0 , false ))
2010-01-01 14:19:29 -06:00
{
2009-08-06 11:24:14 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_NEGATIVE_EFF0 ;
2010-01-01 14:19:29 -06:00
count ++ ;
}
2009-11-20 19:11:28 -08:00
if ( ! _isPositiveEffect ( i , 1 , false ))
2010-01-01 14:19:29 -06:00
{
2009-08-06 11:24:14 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_NEGATIVE_EFF1 ;
2010-01-01 14:19:29 -06:00
count ++ ;
}
2009-11-20 19:11:28 -08:00
if ( ! _isPositiveEffect ( i , 2 , false ))
2010-01-01 14:19:29 -06:00
{
2009-08-06 11:24:14 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_NEGATIVE_EFF2 ;
2010-01-01 14:19:29 -06:00
count ++ ;
}
2009-10-17 15:51:44 -07:00
2009-11-20 19:11:28 -08:00
if ( spellInfo -> SpellVisual [ 0 ] == 3879 )
2010-01-01 14:19:29 -06:00
{
2009-05-15 16:26:00 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_CONE_BACK ;
2010-01-01 14:19:29 -06:00
count ++ ;
}
2009-10-17 15:51:44 -07:00
2009-11-20 19:11:28 -08:00
if ( spellInfo -> activeIconID == 2158 ) // flight
2010-01-01 14:19:29 -06:00
{
2009-08-06 11:24:14 -05:00
spellInfo -> Attributes |= SPELL_ATTR_PASSIVE ;
2010-01-01 14:19:29 -06:00
count ++ ;
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
switch ( i )
{
2010-04-18 23:20:07 +02:00
// Bind
case 3286 :
spellInfo -> EffectImplicitTargetA [ 0 ] = TARGET_UNIT_TARGET_ENEMY ;
spellInfo -> EffectImplicitTargetA [ 1 ] = TARGET_UNIT_TARGET_ENEMY ;
count ++ ;
break ;
2009-10-22 20:35:32 +02:00
// Heroism
case 32182 :
spellInfo -> excludeCasterAuraSpell = 57723 ; // Exhaustion
2010-01-01 14:19:29 -06:00
count ++ ;
2009-10-22 20:35:32 +02:00
break ;
2010-05-31 18:55:02 -06:00
// Blazing Harpoon
case 61588 :
spellInfo -> MaxAffectedTargets = 1 ;
count ++ ;
break ;
2009-12-17 12:23:01 +01:00
// Bloodlust
case 2825 :
spellInfo -> excludeCasterAuraSpell = 57724 ; // Sated
2010-01-01 14:19:29 -06:00
count ++ ;
2009-12-17 12:23:01 +01:00
break ;
2009-06-24 19:56:13 +02:00
// Heart of the Crusader
case 20335 :
case 20336 :
case 20337 :
2010-05-14 18:02:31 +02:00
// Glyph of Life Tap
case 63320 :
2009-11-17 19:28:36 -08:00
// Entries were not updated after spell effect change, we have to do that manually :/
2009-06-24 19:56:13 +02:00
spellInfo -> AttributesEx3 |= SPELL_ATTR_EX3_CAN_PROC_TRIGGERED ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-06-24 19:56:13 +02:00
break ;
2009-06-11 11:35:31 -05:00
case 16007 : // Draco-Incarcinatrix 900
// was 46, but effect is aura effect
spellInfo -> EffectImplicitTargetA [ 0 ] = TARGET_UNIT_NEARBY_ENTRY ;
spellInfo -> EffectImplicitTargetB [ 0 ] = TARGET_DST_NEARBY_ENTRY ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-06-11 11:35:31 -05:00
break ;
2009-05-15 16:26:00 -05:00
case 26029 : // dark glare
case 37433 : // spout
case 43140 : case 43215 : // flame breath
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_CONE_LINE ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
case 24340 : case 26558 : case 28884 : // Meteor
case 36837 : case 38903 : case 41276 : // Meteor
2009-05-20 11:44:38 -05:00
case 57467 : // Meteor
2009-05-15 16:26:00 -05:00
case 26789 : // Shard of the Fallen Star
case 31436 : // Malevolent Cleave
case 35181 : // Dive Bomb
case 40810 : case 43267 : case 43268 : // Saber Lash
case 42384 : // Brutal Swipe
case 45150 : // Meteor Slash
2009-07-31 11:06:35 +08:00
case 64422 : case 64688 : // Sonic Screech
2010-05-20 20:09:18 +02:00
case 72373 : // Shared Suffering
2010-09-28 17:35:59 +02:00
case 71904 : // Chaos Bane
2010-10-16 16:34:21 +02:00
case 70492 : case 72505 : // Ooze Eruption
case 72624 : case 72625 : // Ooze Eruption
2009-08-11 19:57:27 +02:00
// ONLY SPELLS WITH SPELLFAMILY_GENERIC and EFFECT_SCHOOL_DAMAGE
2009-05-15 16:26:00 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_SHARE_DAMAGE ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
2009-06-10 23:44:30 +02:00
case 59725 : // Improved Spell Reflection - aoe aura
// Target entry seems to be wrong for this spell :/
spellInfo -> EffectImplicitTargetA [ 0 ] = TARGET_UNIT_PARTY_CASTER ;
spellInfo -> EffectRadiusIndex [ 0 ] = 45 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-06-15 01:10:09 +02:00
break ;
2009-05-18 15:04:05 -05:00
case 27820 : // Mana Detonation
2009-05-20 11:44:38 -05:00
//case 28062: case 39090: // Positive/Negative Charge
//case 28085: case 39093:
2010-10-09 16:50:03 +02:00
case 69782 : case 69796 : // Ooze Flood
case 69798 : case 69801 : // Ooze Flood
case 69538 : case 69553 : case 69610 : // Ooze Combine
2009-05-15 16:26:00 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_EXCLUDE_SELF ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
case 44978 : case 45001 : case 45002 : // Wild Magic
case 45004 : case 45006 : case 45010 : // Wild Magic
case 31347 : // Doom
case 41635 : // Prayer of Mending
case 44869 : // Spectral Blast
case 45027 : // Revitalize
case 45976 : // Muru Portal Channel
case 39365 : // Thundering Storm
case 41071 : // Raise Dead (HACK)
2009-05-27 23:33:21 -05:00
case 52124 : // Sky Darkener Assault
2010-07-16 14:42:24 +02:00
case 42442 : // Vengeance Landing Cannonfire
case 45863 : // Cosmetic - Incinerate to Random Target
case 25425 : // Shoot
case 45761 : // Shoot
case 42611 : // Shoot
case 62374 : // Pursued
2009-08-14 21:45:54 -05:00
spellInfo -> MaxAffectedTargets = 1 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-08-14 21:45:54 -05:00
break ;
2009-06-03 23:24:57 -05:00
case 52479 : // Gift of the Harvester
2009-05-15 16:26:00 -05:00
spellInfo -> MaxAffectedTargets = 1 ;
2009-08-14 21:45:54 -05:00
// a trap always has dst = src?
spellInfo -> EffectImplicitTargetA [ 0 ] = TARGET_DST_CASTER ;
spellInfo -> EffectImplicitTargetA [ 1 ] = TARGET_DST_CASTER ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
case 41376 : // Spite
case 39992 : // Needle Spine
case 29576 : // Multi-Shot
case 40816 : // Saber Lash
case 37790 : // Spread Shot
case 46771 : // Flame Sear
case 45248 : // Shadow Blades
case 41303 : // Soul Drain
case 54172 : // Divine Storm (heal)
case 29213 : // Curse of the Plaguebringer - Noth
case 28542 : // Life Drain - Sapphiron
2010-07-16 14:42:24 +02:00
case 66588 : // Flaming Spear
case 54171 : // Divine Storm
2009-05-15 16:26:00 -05:00
spellInfo -> MaxAffectedTargets = 3 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
2009-11-17 19:28:36 -08:00
case 38310 : // Multi-Shot
case 53385 : // Divine Storm (Damage)
2009-05-15 16:26:00 -05:00
spellInfo -> MaxAffectedTargets = 4 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
case 42005 : // Bloodboil
case 38296 : // Spitfire Totem
case 37676 : // Insidious Whisper
2009-05-25 13:03:11 -05:00
case 46008 : // Negative Energy
2009-05-15 16:26:00 -05:00
case 45641 : // Fire Bloom
case 55665 : // Life Drain - Sapphiron (H)
case 28796 : // Poison Bolt Volly - Faerlina
spellInfo -> MaxAffectedTargets = 5 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2008-11-17 22:07:21 -06:00
break ;
2009-05-15 16:26:00 -05:00
case 40827 : // Sinful Beam
case 40859 : // Sinister Beam
case 40860 : // Vile Beam
case 40861 : // Wicked Beam
case 54835 : // Curse of the Plaguebringer - Noth (H)
case 54098 : // Poison Bolt Volly - Faerlina (H)
spellInfo -> MaxAffectedTargets = 10 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2008-11-17 22:07:21 -06:00
break ;
2010-09-14 01:27:05 +03:00
case 50312 : // Unholy Frenzy
spellInfo -> MaxAffectedTargets = 15 ;
count ++ ;
break ;
2009-05-15 16:26:00 -05:00
case 38794 : case 33711 : //Murmur's Touch
spellInfo -> MaxAffectedTargets = 1 ;
spellInfo -> EffectTriggerSpell [ 0 ] = 33760 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
case 17941 : // Shadow Trance
case 22008 : // Netherwind Focus
case 31834 : // Light's Grace
case 34754 : // Clearcasting
case 34936 : // Backlash
case 48108 : // Hot Streak
case 51124 : // Killing Machine
case 54741 : // Firestarter
case 57761 : // Fireball!
case 39805 : // Lightning Overload
2009-07-19 00:27:03 +02:00
case 64823 : // Item - Druid T8 Balance 4P Bonus
2010-02-15 18:23:39 +01:00
case 44401 :
2009-11-20 19:11:28 -08:00
spellInfo -> procCharges = 1 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
2010-02-15 18:23:39 +01:00
case 53390 : // Tidal Wave
2009-12-28 21:09:16 -06:00
spellInfo -> procCharges = 2 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-12-28 21:09:16 -06:00
break ;
2009-05-15 16:26:00 -05:00
case 44544 : // Fingers of Frost
2010-09-27 20:30:47 +02:00
spellInfo -> EffectSpellClassMask [ 0 ] = flag96 ( 685904631 , 1151048 , 0 );
count ++ ;
break ;
case 74396 : // Fingers of Frost visual buff
2009-11-20 19:11:28 -08:00
spellInfo -> procCharges = 2 ;
2010-09-27 20:30:47 +02:00
spellInfo -> StackAmount = 0 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
case 28200 : // Ascendance (Talisman of Ascendance trinket)
2009-11-20 19:11:28 -08:00
spellInfo -> procCharges = 6 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2008-11-17 22:07:21 -06:00
break ;
2010-07-16 17:25:14 +02:00
case 47201 : // Everlasting Affliction
case 47202 :
case 47203 :
case 47204 :
case 47205 :
// add corruption to affected spells
spellInfo -> EffectSpellClassMask [ 1 ][ 0 ] |= 2 ;
count ++ ;
break ;
2009-05-26 22:13:36 -05:00
case 51852 : // The Eye of Acherus (no spawn in phase 2 in db)
spellInfo -> EffectMiscValue [ 0 ] |= 1 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-26 22:13:36 -05:00
break ;
2009-09-10 09:25:32 -07:00
case 52025 : // Cleansing Totem Effect
spellInfo -> EffectDieSides [ 1 ] = 1 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-09-10 09:25:32 -07:00
break ;
2009-05-26 22:13:36 -05:00
case 51904 : // Summon Ghouls On Scarlet Crusade (core does not know the triggered spell is summon spell)
spellInfo -> EffectImplicitTargetA [ 0 ] = TARGET_UNIT_CASTER ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-26 22:13:36 -05:00
break ;
2009-07-11 13:03:06 +02:00
case 29809 : // Desecration Arm - 36 instead of 37 - typo? :/
spellInfo -> EffectRadiusIndex [ 0 ] = 37 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-07-17 19:09:08 +02:00
break ;
// Master Shapeshifter: missing stance data for forms other than bear - bear version has correct data
// To prevent aura staying on target after talent unlearned
case 48420 :
spellInfo -> Stances = 1 << ( FORM_CAT - 1 );
2010-01-01 14:19:29 -06:00
count ++ ;
2009-07-17 19:09:08 +02:00
break ;
case 48421 :
spellInfo -> Stances = 1 << ( FORM_MOONKIN - 1 );
2010-01-01 14:19:29 -06:00
count ++ ;
2009-07-17 19:09:08 +02:00
break ;
case 48422 :
spellInfo -> Stances = 1 << ( FORM_TREE - 1 );
2010-01-01 14:19:29 -06:00
count ++ ;
2009-07-17 19:09:08 +02:00
break ;
2009-08-14 18:34:16 -05:00
case 30421 : // Nether Portal - Perseverence
spellInfo -> EffectBasePoints [ 2 ] += 30000 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-08-14 18:34:16 -05:00
break ;
2009-08-23 01:08:09 -05:00
// some dummy spell only has dest, should push caster in this case
case 62324 : // Throw Passenger
2010-08-04 19:16:44 +02:00
spellInfo -> Targets |= TARGET_FLAG_UNIT_CASTER ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-08-23 01:08:09 -05:00
break ;
2009-12-26 14:05:55 +01:00
case 51735 : // Ebon Plague
case 51734 :
case 51726 :
2010-09-19 04:10:35 +03:00
spellInfo -> AttributesEx3 |= SPELL_ATTR_EX3_STACK_FOR_DIFF_CASTERS ;
2009-12-26 14:05:55 +01:00
spellInfo -> SpellFamilyFlags [ 2 ] = 0x10 ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-12-26 14:05:55 +01:00
break ;
2010-01-24 11:45:50 +01:00
case 41013 : // Parasitic Shadowfiend Passive
spellInfo -> EffectApplyAuraName [ 0 ] = 4 ; // proc debuff, and summon infinite fiends
count ++ ;
break ;
case 27892 : // To Anchor 1
case 27928 : // To Anchor 1
case 27935 : // To Anchor 1
case 27915 : // Anchor to Skulls
case 27931 : // Anchor to Skulls
case 27937 : // Anchor to Skulls
spellInfo -> rangeIndex = 13 ;
count ++ ;
break ;
2010-04-30 09:47:06 +02:00
case 48743 : // Death Pact
spellInfo -> AttributesEx &= ~ SPELL_ATTR_EX_CANT_TARGET_SELF ;
count ++ ;
break ;
2010-02-04 18:34:46 +01:00
// target allys instead of enemies, target A is src_caster, spells with effect like that have ally target
// this is the only known exception, probably just wrong data
2010-02-15 18:23:39 +01:00
case 29214 : // Wrath of the Plaguebringer
case 54836 : // Wrath of the Plaguebringer
2010-02-04 18:34:46 +01:00
spellInfo -> EffectImplicitTargetB [ 0 ] = TARGET_UNIT_AREA_ALLY_SRC ;
spellInfo -> EffectImplicitTargetB [ 1 ] = TARGET_UNIT_AREA_ALLY_SRC ;
2010-01-24 23:10:15 +01:00
count ++ ;
break ;
2010-02-15 20:59:05 +01:00
case 31687 : // Summon Water Elemental
// 322-330 switch - effect changed to dummy, target entry not changed in client:(
spellInfo -> EffectImplicitTargetA [ 0 ] = TARGET_UNIT_CASTER ;
count ++ ;
break ;
2010-03-24 20:35:04 +01:00
case 25771 : // Forbearance - wrong mechanic immunity in DBC since 3.0.x
spellInfo -> EffectMiscValue [ 0 ] = MECHANIC_IMMUNE_SHIELD ;
count ++ ;
break ;
2010-07-27 02:36:27 +02:00
case 64321 : // Potent Pheromones
// spell should dispel area aura, but doesn't have the attribute
// may be db data bug, or blizz may keep reapplying area auras every update with checking immunity
// that will be clear if we get more spells with problem like this
spellInfo -> AttributesEx |= SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY ;
2010-05-11 18:43:47 +02:00
count ++ ;
2010-04-21 22:33:20 +02:00
break ;
2010-08-18 17:19:47 +02:00
case 69055 : // Saber Lash
case 70814 : // Saber Lash
spellInfo -> EffectRadiusIndex [ 0 ] = 8 ;
count ++ ;
break ;
case 69075 : // Bone Storm
case 70834 : // Bone Storm
case 70835 : // Bone Storm
case 70836 : // Bone Storm
spellInfo -> EffectRadiusIndex [ 0 ] = 12 ;
count ++ ;
break ;
2010-08-18 19:26:07 +02:00
case 18500 : // Wing Buffet
case 33086 : // Wild Bite
case 49749 : // Piercing Blow
2010-08-19 14:31:31 +02:00
case 52890 : // Penetrating Strike
2010-08-18 19:26:07 +02:00
case 53454 : // Impale
case 59446 : // Impale
case 62383 : // Shatter
case 64777 : // Machine Gun
case 65239 : // Machine Gun
2010-08-19 14:31:31 +02:00
case 65919 : // Impale
case 67858 : // Impale
case 67859 : // Impale
case 67860 : // Impale
2010-08-18 19:26:07 +02:00
case 69293 : // Wing Buffet
case 74439 : // Machine Gun
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_IGNORE_ARMOR ;
count ++ ;
break ;
2010-08-27 18:11:21 +02:00
// THESE SPELLS ARE WORKING CORRECTLY EVEN WITHOUT THIS HACK
// THE ONLY REASON ITS HERE IS THAT CURRENT GRID SYSTEM
// DOES NOT ALLOW FAR OBJECT SELECTION (dist > 333)
case 70781 : // Light's Hammer Teleport
case 70856 : // Oratory of the Damned Teleport
case 70857 : // Rampart of Skulls Teleport
case 70858 : // Deathbringer's Rise Teleport
case 70859 : // Upper Spire Teleport
case 70860 : // Frozen Throne Teleport
case 70861 : // Sindragosa's Lair Teleport
spellInfo -> EffectImplicitTargetA [ 0 ] = TARGET_DST_DB ;
count ++ ;
break ;
2010-09-06 10:53:02 -07:00
case 63675 : // Improved Devouring Plague
spellInfo -> AttributesEx3 |= SPELL_ATTR_EX3_NO_DONE_BONUS ;
count ++ ;
break ;
2010-10-10 11:09:16 +02:00
case 53241 : // Marked for Death (Rank 1)
case 53243 : // Marked for Death (Rank 2)
case 53244 : // Marked for Death (Rank 3)
case 53245 : // Marked for Death (Rank 4)
case 53246 : // Marked for Death (Rank 5)
spellInfo -> EffectSpellClassMask [ 0 ] = flag96 ( 423937 , 276955137 , 2049 );
2010-10-10 01:22:47 +02:00
count ++ ;
break ;
2010-10-16 16:34:21 +02:00
// this is here until targetAuraSpell and alike support SpellDifficulty.dbc
case 70459 : // Ooze Eruption Search Effect
spellInfo -> targetAuraSpell = 0 ;
count ++ ;
break ;
2010-10-21 21:05:29 +02:00
case 70728 : // Exploit Weakness
spellInfo -> EffectImplicitTargetB [ 0 ] = TARGET_UNIT_PET ;
count ++ ;
break ;
2010-10-16 16:34:21 +02:00
case 71413 : // Green Ooze Summon
case 71414 : // Orange Ooze Summon
spellInfo -> EffectImplicitTargetA [ 0 ] = TARGET_DEST_DEST ;
count ++ ;
break ;
// THIS IS HERE BECAUSE COOLDOWN ON CREATURE PROCS IS NOT IMPLEMENTED
case 71604 : // Mutated Strength
case 72673 : // Mutated Strength
case 72674 : // Mutated Strength
case 72675 : // Mutated Strength
spellInfo -> Effect [ 1 ] = 0 ;
count ++ ;
break ;
case 70447 : // Volatile Ooze Adhesive
case 72836 : // Volatile Ooze Adhesive
case 72837 : // Volatile Ooze Adhesive
case 72838 : // Volatile Ooze Adhesive
case 70672 : // Gaseous Bloat
case 72455 : // Gaseous Bloat
case 72832 : // Gaseous Bloat
case 72833 : // Gaseous Bloat
spellInfo -> EffectImplicitTargetB [ 0 ] = TARGET_UNIT_TARGET_ENEMY ;
spellInfo -> EffectImplicitTargetB [ 1 ] = TARGET_UNIT_TARGET_ENEMY ;
spellInfo -> EffectImplicitTargetB [ 2 ] = TARGET_UNIT_TARGET_ENEMY ;
count ++ ;
break ;
case 70911 : // Unbound Plague
case 72854 : // Unbound Plague
case 72855 : // Unbound Plague
case 72856 : // Unbound Plague
spellInfo -> EffectImplicitTargetB [ 0 ] = TARGET_UNIT_TARGET_ENEMY ;
count ++ ;
break ;
2008-11-17 22:07:21 -06:00
default :
break ;
2009-05-15 16:26:00 -05:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
switch ( spellInfo -> SpellFamilyName )
{
2009-05-29 16:09:55 -05:00
case SPELLFAMILY_WARRIOR :
// Shout
2010-04-07 19:14:10 +02:00
if ( spellInfo -> SpellFamilyFlags [ 0 ] & 0x20000 || spellInfo -> SpellFamilyFlags [ 1 ] & 0x20 )
2009-05-29 16:09:55 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_AURA_CC ;
2010-01-01 14:19:29 -06:00
else
break ;
count ++ ;
2009-05-29 16:09:55 -05:00
break ;
2009-05-15 16:26:00 -05:00
case SPELLFAMILY_DRUID :
2009-05-18 10:22:43 -05:00
// Starfall Target Selection
2010-04-07 19:14:10 +02:00
if ( spellInfo -> SpellFamilyFlags [ 2 ] & 0x100 )
2009-05-15 16:26:00 -05:00
spellInfo -> MaxAffectedTargets = 2 ;
2009-05-18 10:22:43 -05:00
// Starfall AOE Damage
2010-04-07 19:14:10 +02:00
else if ( spellInfo -> SpellFamilyFlags [ 2 ] & 0x800000 )
2009-05-18 10:22:43 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_EXCLUDE_SELF ;
2009-05-29 16:09:55 -05:00
// Roar
2010-04-07 19:14:10 +02:00
else if ( spellInfo -> SpellFamilyFlags [ 0 ] & 0x8 )
2009-05-29 16:09:55 -05:00
mSpellCustomAttr [ i ] |= SPELL_ATTR_CU_AURA_CC ;
2010-01-01 14:19:29 -06:00
else
break ;
count ++ ;
2009-05-15 16:26:00 -05:00
break ;
2009-06-08 21:08:27 +02:00
// Do not allow Deadly throw and Slice and Dice to proc twice
case SPELLFAMILY_ROGUE :
2010-04-07 19:14:10 +02:00
if ( spellInfo -> SpellFamilyFlags [ 1 ] & 0x1 || spellInfo -> SpellFamilyFlags [ 0 ] & 0x40000 )
2009-06-08 21:08:27 +02:00
spellInfo -> AttributesEx4 |= SPELL_ATTR_EX4_CANT_PROC_FROM_SELFCAST ;
2010-01-01 14:19:29 -06:00
else
break ;
count ++ ;
2009-06-08 21:08:27 +02:00
break ;
2009-05-15 16:26:00 -05:00
}
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
SummonPropertiesEntry * properties = const_cast < SummonPropertiesEntry *> ( sSummonPropertiesStore . LookupEntry ( 121 ));
properties -> Type = SUMMON_TYPE_TOTEM ;
2009-08-17 23:09:17 -05:00
properties = const_cast < SummonPropertiesEntry *> ( sSummonPropertiesStore . LookupEntry ( 647 )); // 52893
properties -> Type = SUMMON_TYPE_TOTEM ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
CreatureAI :: FillAISpellInfo ();
2010-01-01 14:19:29 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u custom spell attributes" , count );
2008-11-17 22:07:21 -06:00
}
2009-10-17 15:51:44 -07:00
2009-05-24 22:54:13 +02:00
// Fill custom data about enchancments
void SpellMgr :: LoadEnchantCustomAttr ()
{
uint32 size = sSpellItemEnchantmentStore . GetNumRows ();
mEnchantCustomAttr . resize ( size );
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( GetSpellStore () -> GetNumRows ());
uint32 count = 0 ;
for ( uint32 i = 0 ; i < size ; ++ i )
2009-05-24 22:54:13 +02:00
mEnchantCustomAttr [ i ] = 0 ;
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < GetSpellStore () -> GetNumRows (); ++ i )
2009-05-24 22:54:13 +02:00
{
2010-01-01 14:19:29 -06:00
bar . step ();
2009-05-24 22:54:13 +02:00
SpellEntry * spellInfo = ( SpellEntry * ) GetSpellStore () -> LookupEntry ( i );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2009-05-24 22:54:13 +02:00
continue ;
2009-10-17 15:51:44 -07:00
2009-05-24 22:54:13 +02:00
// TODO: find a better check
if ( ! ( spellInfo -> AttributesEx2 & SPELL_ATTR_EX2_UNK13 ) || ! ( spellInfo -> Attributes & SPELL_ATTR_NOT_SHAPESHIFT ))
continue ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
for ( uint32 j = 0 ; j < MAX_SPELL_EFFECTS ; ++ j )
2009-05-24 22:54:13 +02:00
{
2010-04-07 19:14:10 +02:00
if ( spellInfo -> Effect [ j ] == SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY )
2009-05-24 22:54:13 +02:00
{
uint32 enchId = spellInfo -> EffectMiscValue [ j ];
SpellItemEnchantmentEntry const * ench = sSpellItemEnchantmentStore . LookupEntry ( enchId );
2010-04-19 16:59:30 +02:00
if ( ! ench )
2009-05-24 22:54:13 +02:00
continue ;
mEnchantCustomAttr [ enchId ] = true ;
2010-01-01 14:19:29 -06:00
count ++ ;
2009-05-24 22:54:13 +02:00
break ;
}
}
}
2010-01-01 14:19:29 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u custom enchant attributes" , count );
2009-05-24 22:54:13 +02:00
}
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
void SpellMgr :: LoadSpellLinked ()
2008-11-17 22:07:21 -06:00
{
2009-05-15 16:26:00 -05:00
mSpellLinkedMap . clear (); // need for reload case
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
// 0 1 2
2010-09-11 21:10:54 +02:00
QueryResult result = WorldDatabase . Query ( "SELECT spell_trigger, spell_effect, type FROM spell_linked_spell" );
2010-01-01 14:19:29 -06:00
if ( ! result )
2009-02-27 12:53:27 -06:00
{
2010-01-01 14:19:29 -06:00
barGoLink bar ( 1 );
2009-05-15 16:26:00 -05:00
bar . step ();
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u linked spells" , count );
2009-05-15 16:26:00 -05:00
return ;
2009-02-27 12:53:27 -06:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
barGoLink bar ( result -> GetRowCount ());
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
do
2009-02-27 12:53:27 -06:00
{
2009-05-15 16:26:00 -05:00
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
bar . step ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
int32 trigger = fields [ 0 ]. GetInt32 ();
2010-01-01 14:19:29 -06:00
int32 effect = fields [ 1 ]. GetInt32 ();
int32 type = fields [ 2 ]. GetInt32 ();
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( abs ( trigger ));
if ( ! spellInfo )
{
sLog . outErrorDb ( "Spell %u listed in `spell_linked_spell` does not exist" , abs ( trigger ));
continue ;
}
spellInfo = sSpellStore . LookupEntry ( abs ( effect ));
if ( ! spellInfo )
{
sLog . outErrorDb ( "Spell %u listed in `spell_linked_spell` does not exist" , abs ( effect ));
continue ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( trigger > 0 )
2009-05-15 16:26:00 -05:00
{
switch ( type )
{
case 0 : mSpellCustomAttr [ trigger ] |= SPELL_ATTR_CU_LINK_CAST ; break ;
case 1 : mSpellCustomAttr [ trigger ] |= SPELL_ATTR_CU_LINK_HIT ; break ;
case 2 : mSpellCustomAttr [ trigger ] |= SPELL_ATTR_CU_LINK_AURA ; break ;
}
}
2009-03-03 18:41:11 -06:00
else
2009-05-15 16:26:00 -05:00
{
mSpellCustomAttr [ - trigger ] |= SPELL_ATTR_CU_LINK_REMOVE ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( type ) //we will find a better way when more types are needed
2009-05-15 16:26:00 -05:00
{
2010-04-07 19:14:10 +02:00
if ( trigger > 0 )
2009-05-15 16:26:00 -05:00
trigger += SPELL_LINKED_MAX_SPELLS * type ;
else
trigger -= SPELL_LINKED_MAX_SPELLS * type ;
}
mSpellLinkedMap [ trigger ]. push_back ( effect );
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
++ count ;
2010-04-07 22:59:46 +02:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-05-15 16:26:00 -05:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u linked spells" , count );
2009-02-27 12:53:27 -06:00
}