2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
24 #include "UpdateMask.h"
26 #include "ObjectMgr.h"
29 #include "SkillExtraItems.h"
32 #include "DynamicObject.h"
33 #include "SpellAuras.h"
35 #include "UpdateData.h"
36 #include "MapManager.h"
37 #include "ObjectAccessor.h"
38 #include "SharedDefines.h"
40 #include "GameObject.h"
41 #include "GossipDef.h"
44 #include "CreatureAI.h"
45 #include "BattleGroundMgr.h"
46 #include "BattleGround.h"
47 #include "BattleGroundEY.h"
48 #include "BattleGroundWS.h"
49 #include "VMapFactory.h"
51 #include "SocialMgr.h"
53 #include "TemporarySummon.h"
54 #include "ScriptCalls.h"
55 #include "SkillDiscovery.h"
58 pEffect SpellEffects
[TOTAL_SPELL_EFFECTS
]=
60 &Spell::EffectNULL
, // 0
61 &Spell::EffectInstaKill
, // 1 SPELL_EFFECT_INSTAKILL
62 &Spell::EffectSchoolDMG
, // 2 SPELL_EFFECT_SCHOOL_DAMAGE
63 &Spell::EffectDummy
, // 3 SPELL_EFFECT_DUMMY
64 &Spell::EffectUnused
, // 4 SPELL_EFFECT_PORTAL_TELEPORT unused
65 &Spell::EffectTeleportUnits
, // 5 SPELL_EFFECT_TELEPORT_UNITS
66 &Spell::EffectApplyAura
, // 6 SPELL_EFFECT_APPLY_AURA
67 &Spell::EffectEnvirinmentalDMG
, // 7 SPELL_EFFECT_ENVIRONMENTAL_DAMAGE
68 &Spell::EffectPowerDrain
, // 8 SPELL_EFFECT_POWER_DRAIN
69 &Spell::EffectHealthLeech
, // 9 SPELL_EFFECT_HEALTH_LEECH
70 &Spell::EffectHeal
, // 10 SPELL_EFFECT_HEAL
71 &Spell::EffectUnused
, // 11 SPELL_EFFECT_BIND
72 &Spell::EffectNULL
, // 12 SPELL_EFFECT_PORTAL
73 &Spell::EffectUnused
, // 13 SPELL_EFFECT_RITUAL_BASE unused
74 &Spell::EffectUnused
, // 14 SPELL_EFFECT_RITUAL_SPECIALIZE unused
75 &Spell::EffectUnused
, // 15 SPELL_EFFECT_RITUAL_ACTIVATE_PORTAL unused
76 &Spell::EffectQuestComplete
, // 16 SPELL_EFFECT_QUEST_COMPLETE
77 &Spell::EffectWeaponDmg
, // 17 SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
78 &Spell::EffectResurrect
, // 18 SPELL_EFFECT_RESURRECT
79 &Spell::EffectAddExtraAttacks
, // 19 SPELL_EFFECT_ADD_EXTRA_ATTACKS
80 &Spell::EffectUnused
, // 20 SPELL_EFFECT_DODGE one spell: Dodge
81 &Spell::EffectUnused
, // 21 SPELL_EFFECT_EVADE one spell: Evade (DND)
82 &Spell::EffectParry
, // 22 SPELL_EFFECT_PARRY
83 &Spell::EffectBlock
, // 23 SPELL_EFFECT_BLOCK one spell: Block
84 &Spell::EffectCreateItem
, // 24 SPELL_EFFECT_CREATE_ITEM
85 &Spell::EffectUnused
, // 25 SPELL_EFFECT_WEAPON
86 &Spell::EffectUnused
, // 26 SPELL_EFFECT_DEFENSE one spell: Defense
87 &Spell::EffectPersistentAA
, // 27 SPELL_EFFECT_PERSISTENT_AREA_AURA
88 &Spell::EffectSummonType
, // 28 SPELL_EFFECT_SUMMON
89 &Spell::EffectMomentMove
, // 29 SPELL_EFFECT_LEAP
90 &Spell::EffectEnergize
, // 30 SPELL_EFFECT_ENERGIZE
91 &Spell::EffectWeaponDmg
, // 31 SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
92 &Spell::EffectTriggerMissileSpell
, // 32 SPELL_EFFECT_TRIGGER_MISSILE
93 &Spell::EffectOpenLock
, // 33 SPELL_EFFECT_OPEN_LOCK
94 &Spell::EffectSummonChangeItem
, // 34 SPELL_EFFECT_SUMMON_CHANGE_ITEM
95 &Spell::EffectApplyAreaAura
, // 35 SPELL_EFFECT_APPLY_AREA_AURA_PARTY
96 &Spell::EffectLearnSpell
, // 36 SPELL_EFFECT_LEARN_SPELL
97 &Spell::EffectUnused
, // 37 SPELL_EFFECT_SPELL_DEFENSE one spell: SPELLDEFENSE (DND)
98 &Spell::EffectDispel
, // 38 SPELL_EFFECT_DISPEL
99 &Spell::EffectUnused
, // 39 SPELL_EFFECT_LANGUAGE
100 &Spell::EffectDualWield
, // 40 SPELL_EFFECT_DUAL_WIELD
101 &Spell::EffectUnused
, // 41 SPELL_EFFECT_JUMP
102 &Spell::EffectJump
, // 42 SPELL_EFFECT_JUMP2
103 &Spell::EffectTeleUnitsFaceCaster
, // 43 SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER
104 &Spell::EffectLearnSkill
, // 44 SPELL_EFFECT_SKILL_STEP
105 &Spell::EffectAddHonor
, // 45 SPELL_EFFECT_ADD_HONOR honor/pvp related
106 &Spell::EffectNULL
, // 46 SPELL_EFFECT_SPAWN we must spawn pet there
107 &Spell::EffectTradeSkill
, // 47 SPELL_EFFECT_TRADE_SKILL
108 &Spell::EffectUnused
, // 48 SPELL_EFFECT_STEALTH one spell: Base Stealth
109 &Spell::EffectUnused
, // 49 SPELL_EFFECT_DETECT one spell: Detect
110 &Spell::EffectTransmitted
, // 50 SPELL_EFFECT_TRANS_DOOR
111 &Spell::EffectUnused
, // 51 SPELL_EFFECT_FORCE_CRITICAL_HIT unused
112 &Spell::EffectUnused
, // 52 SPELL_EFFECT_GUARANTEE_HIT one spell: zzOLDCritical Shot
113 &Spell::EffectEnchantItemPerm
, // 53 SPELL_EFFECT_ENCHANT_ITEM
114 &Spell::EffectEnchantItemTmp
, // 54 SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY
115 &Spell::EffectTameCreature
, // 55 SPELL_EFFECT_TAMECREATURE
116 &Spell::EffectSummonPet
, // 56 SPELL_EFFECT_SUMMON_PET
117 &Spell::EffectLearnPetSpell
, // 57 SPELL_EFFECT_LEARN_PET_SPELL
118 &Spell::EffectWeaponDmg
, // 58 SPELL_EFFECT_WEAPON_DAMAGE
119 &Spell::EffectOpenSecretSafe
, // 59 SPELL_EFFECT_OPEN_LOCK_ITEM
120 &Spell::EffectProficiency
, // 60 SPELL_EFFECT_PROFICIENCY
121 &Spell::EffectSendEvent
, // 61 SPELL_EFFECT_SEND_EVENT
122 &Spell::EffectPowerBurn
, // 62 SPELL_EFFECT_POWER_BURN
123 &Spell::EffectThreat
, // 63 SPELL_EFFECT_THREAT
124 &Spell::EffectTriggerSpell
, // 64 SPELL_EFFECT_TRIGGER_SPELL
125 &Spell::EffectApplyAreaAura
, // 65 SPELL_EFFECT_APPLY_AREA_AURA_RAID
126 &Spell::EffectUnused
, // 66 SPELL_EFFECT_CREATE_MANA_GEM (possibly recharge it, misc - is item ID)
127 &Spell::EffectHealMaxHealth
, // 67 SPELL_EFFECT_HEAL_MAX_HEALTH
128 &Spell::EffectInterruptCast
, // 68 SPELL_EFFECT_INTERRUPT_CAST
129 &Spell::EffectDistract
, // 69 SPELL_EFFECT_DISTRACT
130 &Spell::EffectPull
, // 70 SPELL_EFFECT_PULL one spell: Distract Move
131 &Spell::EffectPickPocket
, // 71 SPELL_EFFECT_PICKPOCKET
132 &Spell::EffectAddFarsight
, // 72 SPELL_EFFECT_ADD_FARSIGHT
133 &Spell::EffectUnused
, // 73 SPELL_EFFECT_UNTRAIN_TALENTS
134 &Spell::EffectApplyGlyph
, // 74 SPELL_EFFECT_APPLY_GLYPH
135 &Spell::EffectHealMechanical
, // 75 SPELL_EFFECT_HEAL_MECHANICAL one spell: Mechanical Patch Kit
136 &Spell::EffectSummonObjectWild
, // 76 SPELL_EFFECT_SUMMON_OBJECT_WILD
137 &Spell::EffectScriptEffect
, // 77 SPELL_EFFECT_SCRIPT_EFFECT
138 &Spell::EffectUnused
, // 78 SPELL_EFFECT_ATTACK
139 &Spell::EffectSanctuary
, // 79 SPELL_EFFECT_SANCTUARY
140 &Spell::EffectAddComboPoints
, // 80 SPELL_EFFECT_ADD_COMBO_POINTS
141 &Spell::EffectUnused
, // 81 SPELL_EFFECT_CREATE_HOUSE one spell: Create House (TEST)
142 &Spell::EffectNULL
, // 82 SPELL_EFFECT_BIND_SIGHT
143 &Spell::EffectDuel
, // 83 SPELL_EFFECT_DUEL
144 &Spell::EffectStuck
, // 84 SPELL_EFFECT_STUCK
145 &Spell::EffectSummonPlayer
, // 85 SPELL_EFFECT_SUMMON_PLAYER
146 &Spell::EffectActivateObject
, // 86 SPELL_EFFECT_ACTIVATE_OBJECT
147 &Spell::EffectUnused
, // 87 SPELL_EFFECT_WMO_DAMAGE
148 &Spell::EffectUnused
, // 88 SPELL_EFFECT_WMO_REPAIR
149 &Spell::EffectUnused
, // 89 SPELL_EFFECT_WMO_CHANGE
150 &Spell::EffectUnused
, // 90 SPELL_EFFECT_KILL_CREDIT
151 &Spell::EffectUnused
, // 91 SPELL_EFFECT_THREAT_ALL one spell: zzOLDBrainwash
152 &Spell::EffectEnchantHeldItem
, // 92 SPELL_EFFECT_ENCHANT_HELD_ITEM
153 &Spell::EffectUnused
, // 93 SPELL_EFFECT_SUMMON_PHANTASM
154 &Spell::EffectSelfResurrect
, // 94 SPELL_EFFECT_SELF_RESURRECT
155 &Spell::EffectSkinning
, // 95 SPELL_EFFECT_SKINNING
156 &Spell::EffectCharge
, // 96 SPELL_EFFECT_CHARGE
157 &Spell::EffectUnused
, // 97 SPELL_EFFECT_97
158 &Spell::EffectKnockBack
, // 98 SPELL_EFFECT_KNOCK_BACK
159 &Spell::EffectDisEnchant
, // 99 SPELL_EFFECT_DISENCHANT
160 &Spell::EffectInebriate
, //100 SPELL_EFFECT_INEBRIATE
161 &Spell::EffectFeedPet
, //101 SPELL_EFFECT_FEED_PET
162 &Spell::EffectDismissPet
, //102 SPELL_EFFECT_DISMISS_PET
163 &Spell::EffectReputation
, //103 SPELL_EFFECT_REPUTATION
164 &Spell::EffectSummonObject
, //104 SPELL_EFFECT_SUMMON_OBJECT_SLOT1
165 &Spell::EffectSummonObject
, //105 SPELL_EFFECT_SUMMON_OBJECT_SLOT2
166 &Spell::EffectSummonObject
, //106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3
167 &Spell::EffectSummonObject
, //107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4
168 &Spell::EffectDispelMechanic
, //108 SPELL_EFFECT_DISPEL_MECHANIC
169 &Spell::EffectSummonDeadPet
, //109 SPELL_EFFECT_SUMMON_DEAD_PET
170 &Spell::EffectDestroyAllTotems
, //110 SPELL_EFFECT_DESTROY_ALL_TOTEMS
171 &Spell::EffectDurabilityDamage
, //111 SPELL_EFFECT_DURABILITY_DAMAGE
172 &Spell::EffectUnused
, //112 SPELL_EFFECT_112
173 &Spell::EffectResurrectNew
, //113 SPELL_EFFECT_RESURRECT_NEW
174 &Spell::EffectTaunt
, //114 SPELL_EFFECT_ATTACK_ME
175 &Spell::EffectDurabilityDamagePCT
, //115 SPELL_EFFECT_DURABILITY_DAMAGE_PCT
176 &Spell::EffectSkinPlayerCorpse
, //116 SPELL_EFFECT_SKIN_PLAYER_CORPSE one spell: Remove Insignia, bg usage, required special corpse flags...
177 &Spell::EffectSpiritHeal
, //117 SPELL_EFFECT_SPIRIT_HEAL one spell: Spirit Heal
178 &Spell::EffectSkill
, //118 SPELL_EFFECT_SKILL professions and more
179 &Spell::EffectApplyAreaAura
, //119 SPELL_EFFECT_APPLY_AREA_AURA_PET
180 &Spell::EffectUnused
, //120 SPELL_EFFECT_TELEPORT_GRAVEYARD one spell: Graveyard Teleport Test
181 &Spell::EffectWeaponDmg
, //121 SPELL_EFFECT_NORMALIZED_WEAPON_DMG
182 &Spell::EffectUnused
, //122 SPELL_EFFECT_122 unused
183 &Spell::EffectSendTaxi
, //123 SPELL_EFFECT_SEND_TAXI taxi/flight related (misc value is taxi path id)
184 &Spell::EffectPlayerPull
, //124 SPELL_EFFECT_PLAYER_PULL opposite of knockback effect (pulls player twoard caster)
185 &Spell::EffectModifyThreatPercent
, //125 SPELL_EFFECT_MODIFY_THREAT_PERCENT
186 &Spell::EffectStealBeneficialBuff
, //126 SPELL_EFFECT_STEAL_BENEFICIAL_BUFF spell steal effect?
187 &Spell::EffectProspecting
, //127 SPELL_EFFECT_PROSPECTING Prospecting spell
188 &Spell::EffectApplyAreaAura
, //128 SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
189 &Spell::EffectApplyAreaAura
, //129 SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
190 &Spell::EffectNULL
, //130 SPELL_EFFECT_REDIRECT_THREAT
191 &Spell::EffectUnused
, //131 SPELL_EFFECT_131 used in some test spells
192 &Spell::EffectNULL
, //132 SPELL_EFFECT_PLAY_MUSIC sound id in misc value (SoundEntries.dbc)
193 &Spell::EffectUnlearnSpecialization
, //133 SPELL_EFFECT_UNLEARN_SPECIALIZATION unlearn profession specialization
194 &Spell::EffectKillCredit
, //134 SPELL_EFFECT_KILL_CREDIT misc value is creature entry
195 &Spell::EffectNULL
, //135 SPELL_EFFECT_CALL_PET
196 &Spell::EffectHealPct
, //136 SPELL_EFFECT_HEAL_PCT
197 &Spell::EffectEnergisePct
, //137 SPELL_EFFECT_ENERGIZE_PCT
198 &Spell::EffectNULL
, //138 SPELL_EFFECT_138 Leap
199 &Spell::EffectUnused
, //139 SPELL_EFFECT_CLEAR_QUEST (misc - is quest ID)
200 &Spell::EffectForceCast
, //140 SPELL_EFFECT_FORCE_CAST
201 &Spell::EffectNULL
, //141 SPELL_EFFECT_141 damage and reduce speed?
202 &Spell::EffectTriggerSpellWithValue
, //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE
203 &Spell::EffectApplyAreaAura
, //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER
204 &Spell::EffectNULL
, //144 SPELL_EFFECT_144 Spectral Blast
205 &Spell::EffectNULL
, //145 SPELL_EFFECT_145 Black Hole Effect
206 &Spell::EffectActivateRune
, //146 SPELL_EFFECT_ACTIVATE_RUNE
207 &Spell::EffectQuestFail
, //147 SPELL_EFFECT_QUEST_FAIL quest fail
208 &Spell::EffectUnused
, //148 SPELL_EFFECT_148 unused
209 &Spell::EffectNULL
, //149 SPELL_EFFECT_149 swoop
210 &Spell::EffectUnused
, //150 SPELL_EFFECT_150 unused
211 &Spell::EffectTriggerRitualOfSummoning
, //151 SPELL_EFFECT_TRIGGER_SPELL_2
212 &Spell::EffectNULL
, //152 SPELL_EFFECT_152 summon Refer-a-Friend
213 &Spell::EffectNULL
, //153 SPELL_EFFECT_CREATE_PET misc value is creature entry
214 &Spell::EffectNULL
, //154 unused
215 &Spell::EffectTitanGrip
, //155 SPELL_EFFECT_TITAN_GRIP Allows you to equip two-handed axes, maces and swords in one hand, but you attack $49152s1% slower than normal.
216 &Spell::EffectEnchantItemPrismatic
, //156 SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC
217 &Spell::EffectCreateItem2
, //157 SPELL_EFFECT_CREATE_ITEM_2 create/learn item/spell for profession
218 &Spell::EffectMilling
, //158 SPELL_EFFECT_MILLING milling
219 &Spell::EffectRenamePet
//159 SPELL_EFFECT_ALLOW_RENAME_PET allow rename pet once again
222 void Spell::EffectNULL(uint32
/*i*/)
224 sLog
.outDebug("WORLD: Spell Effect DUMMY");
227 void Spell::EffectUnused(uint32
/*i*/)
229 // NOT USED BY ANY SPELL OR USELESS OR IMPLEMENTED IN DIFFERENT WAY IN MANGOS
232 void Spell::EffectResurrectNew(uint32 i
)
234 if(!unitTarget
|| unitTarget
->isAlive())
237 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
240 if(!unitTarget
->IsInWorld())
243 Player
* pTarget
= ((Player
*)unitTarget
);
245 if(pTarget
->isRessurectRequested()) // already have one active request
248 uint32 health
= damage
;
249 uint32 mana
= m_spellInfo
->EffectMiscValue
[i
];
250 pTarget
->setResurrectRequestData(m_caster
->GetGUID(), m_caster
->GetMapId(), m_caster
->GetPositionX(), m_caster
->GetPositionY(), m_caster
->GetPositionZ(), health
, mana
);
251 SendResurrectRequest(pTarget
);
254 void Spell::EffectInstaKill(uint32
/*i*/)
256 if( !unitTarget
|| !unitTarget
->isAlive() )
260 if(m_spellInfo
->Id
==18788 && unitTarget
->GetTypeId()==TYPEID_UNIT
)
262 uint32 entry
= unitTarget
->GetEntry();
266 case 416: spellID
=18789; break; //imp
267 case 417: spellID
=18792; break; //fellhunter
268 case 1860: spellID
=18790; break; //void
269 case 1863: spellID
=18791; break; //succubus
270 case 17252: spellID
=35701; break; //fellguard
272 sLog
.outError("EffectInstaKill: Unhandled creature entry (%u) case.",entry
);
276 m_caster
->CastSpell(m_caster
,spellID
,true);
279 if(m_caster
==unitTarget
) // prevent interrupt message
282 uint32 health
= unitTarget
->GetHealth();
283 m_caster
->DealDamage(unitTarget
, health
, NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
286 void Spell::EffectEnvirinmentalDMG(uint32 i
)
291 // Note: this hack with damage replace required until GO casting not implemented
292 // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support
293 // currently each enemy selected explicitly and self cast damage, we prevent apply self casted spell bonuses/etc
294 damage
= m_spellInfo
->CalculateSimpleValue(i
);
296 m_caster
->CalcAbsorbResist(m_caster
,GetSpellSchoolMask(m_spellInfo
), SPELL_DIRECT_DAMAGE
, damage
, &absorb
, &resist
);
298 m_caster
->SendSpellNonMeleeDamageLog(m_caster
, m_spellInfo
->Id
, damage
, GetSpellSchoolMask(m_spellInfo
), absorb
, resist
, false, 0, false);
299 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
300 ((Player
*)m_caster
)->EnvironmentalDamage(DAMAGE_FIRE
,damage
);
303 void Spell::EffectSchoolDMG(uint32 effect_idx
)
305 if( unitTarget
&& unitTarget
->isAlive())
307 switch(m_spellInfo
->SpellFamilyName
)
309 case SPELLFAMILY_GENERIC
:
312 if(m_spellInfo
->SpellIconID
== 2269 )
314 damage
+= rand()%2 ? damage
: 0;
317 switch(m_spellInfo
->Id
) // better way to check unknown
319 // Meteor like spells (divided damage to targets)
320 case 24340: case 26558: case 28884: // Meteor
321 case 36837: case 38903: case 41276: // Meteor
322 case 26789: // Shard of the Fallen Star
323 case 31436: // Malevolent Cleave
324 case 35181: // Dive Bomb
325 case 40810: case 43267: case 43268: // Saber Lash
326 case 42384: // Brutal Swipe
327 case 45150: // Meteor Slash
330 for(std::list
<TargetInfo
>::iterator ihit
= m_UniqueTargetInfo
.begin();ihit
!= m_UniqueTargetInfo
.end();++ihit
)
331 if(ihit
->effectMask
& (1<<effect_idx
))
334 damage
/= count
; // divide to all targets
337 // percent from health with min
338 case 25599: // Thundercrash
340 damage
= unitTarget
->GetHealth() / 2;
345 // Intercept (warrior spell trigger)
349 damage
+= uint32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.12f
);
356 case SPELLFAMILY_MAGE
:
359 if(m_spellInfo
->SpellFamilyFlags
& 0x20000000LL
)
361 m_caster
->CastSpell(m_caster
,36032,true);
365 case SPELLFAMILY_WARRIOR
:
368 if(m_spellInfo
->SpellFamilyFlags
& 0x40000000000LL
)
370 damage
= uint32(damage
* (m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)) / 100);
373 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000020000000000LL
&& m_spellInfo
->Category
==1209)
374 damage
+= int32(m_caster
->GetShieldBlockValue());
376 else if(m_spellInfo
->SpellFamilyFlags
& 0x10000000000LL
)
378 damage
= uint32(damage
* m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
379 m_caster
->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH
, false);
381 // Revenge ${$m1+$AP*0.207} to ${$M1+$AP*0.207}
382 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000000000000400LL
)
383 damage
+= uint32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.207f
);
384 // Heroic Throw ${$m1+$AP*.50}
385 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000000100000000LL
)
386 damage
+= uint32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.5f
);
387 // Shockwave ${$m3/100*$AP}
388 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000800000000000LL
)
390 int32 pct
= m_caster
->CalculateSpellDamage(m_spellInfo
, 2, m_spellInfo
->EffectBasePoints
[2], unitTarget
);
392 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * pct
/ 100);
397 case SPELLFAMILY_WARLOCK
:
399 // Incinerate Rank 1 & 2
400 if((m_spellInfo
->SpellFamilyFlags
& 0x00004000000000LL
) && m_spellInfo
->SpellIconID
==2128)
402 // Incinerate does more dmg (dmg*0.25) if the target is Immolated.
403 if(unitTarget
->HasAuraState(AURA_STATE_IMMOLATE
))
404 damage
+= int32(damage
*0.25f
);
408 case SPELLFAMILY_PRIEST
:
410 // Shadow Word: Death - deals damage equal to damage done to caster
411 if (m_spellInfo
->SpellFamilyFlags
& 0x0000000200000000LL
)
412 m_caster
->CastCustomSpell(m_caster
, 32409, &damage
, 0, 0, true);
415 case SPELLFAMILY_DRUID
:
418 if(m_caster
->GetTypeId()==TYPEID_PLAYER
&& (m_spellInfo
->SpellFamilyFlags
& 0x000800000) && m_spellInfo
->SpellVisual
[0]==6587)
420 // converts each extra point of energy into ($f1+$AP/410) additional damage
421 float ap
= m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
422 float multiple
= ap
/ 410 + m_spellInfo
->DmgMultiplier
[effect_idx
];
423 damage
+= int32(m_caster
->GetPower(POWER_ENERGY
) * multiple
);
424 damage
+= int32(((Player
*)m_caster
)->GetComboPoints() * ap
* 7 / 100);
425 m_caster
->SetPower(POWER_ENERGY
,0);
428 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000000000001000LL
)
430 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
433 else if(m_spellInfo
->SpellFamilyFlags
& 0x0010000000000000LL
)
435 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.08f
);
437 //Mangle Bonus for the initial damage of Lacerate and Rake
438 if((m_spellInfo
->SpellFamilyFlags
==0x0000000000001000LL
&& m_spellInfo
->SpellIconID
==494) ||
439 (m_spellInfo
->SpellFamilyFlags
==0x0000010000000000LL
&& m_spellInfo
->SpellIconID
==2246))
441 Unit::AuraList
const& mDummyAuras
= unitTarget
->GetAurasByType(SPELL_AURA_DUMMY
);
442 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin(); i
!= mDummyAuras
.end(); ++i
)
443 if((*i
)->GetSpellProto()->SpellFamilyFlags
& 0x0000044000000000LL
&& (*i
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_DRUID
)
445 damage
= int32(damage
*(100.0f
+(*i
)->GetModifier()->m_amount
)/100.0f
);
451 case SPELLFAMILY_ROGUE
:
454 if(m_caster
->GetTypeId()==TYPEID_PLAYER
&& (m_spellInfo
->SpellFamilyFlags
& 0x800000000LL
))
456 // consume from stack dozes not more that have combo-points
457 if(uint32 combo
= ((Player
*)m_caster
)->GetComboPoints())
460 // Lookup for Deadly poison (only attacker applied)
461 Unit::AuraList
const& auras
= unitTarget
->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE
);
462 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
463 if( (*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_ROGUE
&&
464 (*itr
)->GetSpellProto()->SpellFamilyFlags
& 0x10000 &&
465 (*itr
)->GetCasterGUID()==m_caster
->GetGUID() )
470 // count consumed deadly poison doses at target
473 uint32 spellId
= poison
->GetId();
474 uint32 doses
= poison
->GetStackAmount();
477 for (int i
=0; i
< doses
; i
++)
478 unitTarget
->RemoveSingleSpellAurasFromStack(spellId
);
480 damage
+= int32(((Player
*)m_caster
)->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.03f
* doses
);
482 // Eviscerate and Envenom Bonus Damage (item set effect)
483 if(m_caster
->GetDummyAura(37169))
484 damage
+= ((Player
*)m_caster
)->GetComboPoints()*40;
488 else if((m_spellInfo
->SpellFamilyFlags
& 0x00020000LL
) && m_caster
->GetTypeId()==TYPEID_PLAYER
)
490 if(uint32 combo
= ((Player
*)m_caster
)->GetComboPoints())
492 float ap
= m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
493 damage
+= irand(int32(ap
* combo
* 0.03f
), int32(ap
* combo
* 0.07f
));
495 // Eviscerate and Envenom Bonus Damage (item set effect)
496 if(m_caster
->GetDummyAura(37169))
501 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000000000000008LL
)
503 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.02f
);
506 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000000000002000LL
)
508 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.10f
);
511 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000000010000000LL
)
513 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.04f
);
517 case SPELLFAMILY_HUNTER
:
520 if((m_spellInfo
->SpellFamilyFlags
& 0x000000002) && m_spellInfo
->SpellVisual
[0]==342)
522 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.2f
);
525 else if(m_spellInfo
->SpellFamilyFlags
& 0x0008000000000000LL
)
527 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.2f
);
530 else if((m_spellInfo
->SpellFamilyFlags
& 0x00000800) && m_spellInfo
->maxLevel
> 0)
532 damage
+= int32(m_caster
->GetTotalAttackPowerValue(RANGED_ATTACK
)*0.15f
);
535 else if(m_spellInfo
->SpellFamilyFlags
& 0x100000000LL
)
537 int32 base
= irand((int32
)m_caster
->GetWeaponDamageRange(RANGED_ATTACK
, MINDAMAGE
),(int32
)m_caster
->GetWeaponDamageRange(RANGED_ATTACK
, MAXDAMAGE
));
538 damage
+= int32(float(base
)/m_caster
->GetAttackTime(RANGED_ATTACK
)*2800 + m_caster
->GetTotalAttackPowerValue(RANGED_ATTACK
)*0.2f
);
540 // Explosive Trap Effect
541 else if(m_spellInfo
->SpellFamilyFlags
& 0x00000004)
543 damage
+= int32(m_caster
->GetTotalAttackPowerValue(RANGED_ATTACK
)*0.1f
);
547 case SPELLFAMILY_PALADIN
:
549 // Judgement of Vengeance ${1+0.22*$SPH+0.14*$AP} + 10% for each application of Holy Vengeance on the target
550 if((m_spellInfo
->SpellFamilyFlags
& 0x800000000LL
) && m_spellInfo
->SpellIconID
==2292)
552 float ap
= m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
553 int32 holy
= m_caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo
)) +
554 m_caster
->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo
), unitTarget
);
555 damage
+=int32(ap
* 0.14f
) + int32(holy
* 22 / 100);
556 // Get stack of Holy Vengeance on the target added by caster
558 Unit::AuraList
const& auras
= unitTarget
->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE
);
559 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
560 if((*itr
)->GetId() == 31803 && (*itr
)->GetCasterGUID()==m_caster
->GetGUID())
562 stacks
= (*itr
)->GetStackAmount();
565 // + 10% for each application of Holy Vengeance on the target
567 damage
+= damage
* stacks
* 10 /100;
569 // Avenger's Shield ($m1+0.07*$SPH+0.07*$AP) - ranged sdb for future
570 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000000000004000LL
)
572 float ap
= m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
573 int32 holy
= m_caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo
)) +
574 m_caster
->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo
), unitTarget
);
575 damage
+= int32(ap
* 0.07f
) + int32(holy
* 7 / 100);
577 // Hammer of Wrath ($m1+0.15*$SPH+0.15*$AP) - ranged type sdb future fix
578 else if(m_spellInfo
->SpellFamilyFlags
& 0x0000008000000000LL
)
580 float ap
= m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
581 int32 holy
= m_caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo
)) +
582 m_caster
->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo
), unitTarget
);
583 damage
+= int32(ap
* 0.15f
) + int32(holy
* 15 / 100);
585 // Hammer of the Righteous
586 else if(m_spellInfo
->SpellFamilyFlags
&0x0004000000000000LL
)
588 // Add main hand dps * effect[2] amount
589 float averange
= (m_caster
->GetFloatValue(UNIT_FIELD_MINDAMAGE
) + m_caster
->GetFloatValue(UNIT_FIELD_MAXDAMAGE
)) / 2;
590 int32 count
= m_caster
->CalculateSpellDamage(m_spellInfo
, 2, m_spellInfo
->EffectBasePoints
[2], unitTarget
);
591 damage
+= count
* int32(averange
* IN_MILISECONDS
) / m_caster
->GetAttackTime(BASE_ATTACK
);
593 // Shield of Righteousness
594 else if(m_spellInfo
->SpellFamilyFlags
&0x0010000000000000LL
)
596 damage
+=int32(m_caster
->GetShieldBlockValue());
607 void Spell::EffectDummy(uint32 i
)
609 if(!unitTarget
&& !gameObjTarget
&& !itemTarget
)
612 // selection by spell family
613 switch(m_spellInfo
->SpellFamilyName
)
615 case SPELLFAMILY_GENERIC
:
617 switch(m_spellInfo
->Id
)
619 case 8063: // Deviate Fish
621 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
627 case 1: spell_id
= 8064; break; // Sleepy
628 case 2: spell_id
= 8065; break; // Invigorate
629 case 3: spell_id
= 8066; break; // Shrink
630 case 4: spell_id
= 8067; break; // Party Time!
631 case 5: spell_id
= 8068; break; // Healthy Spirit
633 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
636 case 8213: // Savory Deviate Delight
638 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
645 case 1: spell_id
= (m_caster
->getGender() == GENDER_MALE
? 8219 : 8220); break;
647 case 2: spell_id
= (m_caster
->getGender() == GENDER_MALE
? 8221 : 8222); break;
649 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
652 case 8593: // Symbol of life (restore creature to life)
653 case 31225: // Shimmering Vessel (restore creature to life)
655 if(!unitTarget
|| unitTarget
->GetTypeId()!=TYPEID_UNIT
)
657 ((Creature
*)unitTarget
)->setDeathState(JUST_ALIVED
);
660 case 12162: // Deep wounds
661 case 12850: // (now good common check for this spells)
668 // DW should benefit of attack power, damage percent mods etc.
669 // TODO: check if using offhand damage is correct and if it should be divided by 2
670 if (m_caster
->haveOffhandWeapon() && m_caster
->getAttackTimer(BASE_ATTACK
) > m_caster
->getAttackTimer(OFF_ATTACK
))
671 damage
= (m_caster
->GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE
) + m_caster
->GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE
))/2;
673 damage
= (m_caster
->GetFloatValue(UNIT_FIELD_MINDAMAGE
) + m_caster
->GetFloatValue(UNIT_FIELD_MAXDAMAGE
))/2;
675 switch (m_spellInfo
->Id
)
677 case 12850: damage
*= 0.2f
; break;
678 case 12162: damage
*= 0.4f
; break;
679 case 12868: damage
*= 0.6f
; break;
681 sLog
.outError("Spell::EffectDummy: Spell %u not handled in DW",m_spellInfo
->Id
);
685 int32 deepWoundsDotBasePoints0
= int32(damage
/ 4);
686 m_caster
->CastCustomSpell(unitTarget
, 12721, &deepWoundsDotBasePoints0
, NULL
, NULL
, true, NULL
);
689 case 13120: // net-o-matic
696 uint32 roll
= urand(0, 99);
698 if(roll
< 2) // 2% for 30 sec self root (off-like chance unknown)
700 else if(roll
< 4) // 2% for 20 sec root, charge to target (off-like chance unknown)
705 m_caster
->CastSpell(unitTarget
,spell_id
,true,NULL
);
708 case 13567: // Dummy Trigger
710 // can be used for different aura triggering, so select by aura
711 if(!m_triggeredByAuraSpell
|| !unitTarget
)
714 switch(m_triggeredByAuraSpell
->Id
)
716 case 26467: // Persistent Shield
717 m_caster
->CastCustomSpell(unitTarget
, 26470, &damage
, NULL
, NULL
, true);
720 sLog
.outError("EffectDummy: Non-handled case for spell 13567 for triggered aura %u",m_triggeredByAuraSpell
->Id
);
725 case 15998: // Capture Worg Pup
726 case 29435: // Capture Female Kaliri Hatchling
728 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
)
731 Creature
* creatureTarget
= (Creature
*)unitTarget
;
732 creatureTarget
->setDeathState(JUST_DIED
);
733 creatureTarget
->RemoveCorpse();
734 creatureTarget
->SetHealth(0); // just for nice GM-mode view
737 case 16589: // Noggenfogger Elixir
739 if(m_caster
->GetTypeId()!=TYPEID_PLAYER
)
745 case 1: spell_id
= 16595; break;
746 case 2: spell_id
= 16593; break;
747 default:spell_id
= 16591; break;
750 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
753 case 17251: // Spirit Healer Res
755 if(!unitTarget
|| !m_originalCaster
)
758 if(m_originalCaster
->GetTypeId() == TYPEID_PLAYER
)
760 WorldPacket
data(SMSG_SPIRIT_HEALER_CONFIRM
, 8);
761 data
<< unitTarget
->GetGUID();
762 ((Player
*)m_originalCaster
)->GetSession()->SendPacket( &data
);
766 case 17271: // Test Fetid Skull
768 if(!itemTarget
&& m_caster
->GetTypeId()!=TYPEID_PLAYER
)
771 uint32 spell_id
= roll_chance_i(50) ? 17269 : 17270;
773 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
776 case 20577: // Cannibalize
778 m_caster
->CastSpell(m_caster
,20578,false,NULL
);
780 case 23019: // Crystal Prison Dummy DND
782 if(!unitTarget
|| !unitTarget
->isAlive() || unitTarget
->GetTypeId() != TYPEID_UNIT
|| ((Creature
*)unitTarget
)->isPet())
785 Creature
* creatureTarget
= (Creature
*)unitTarget
;
786 if(creatureTarget
->isPet())
789 GameObject
* pGameObj
= new GameObject
;
791 Map
*map
= creatureTarget
->GetMap();
793 // create before death for get proper coordinates
794 if(!pGameObj
->Create(objmgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), 179644, map
, m_caster
->GetPhaseMask(),
795 creatureTarget
->GetPositionX(), creatureTarget
->GetPositionY(), creatureTarget
->GetPositionZ(),
796 creatureTarget
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
) )
802 pGameObj
->SetRespawnTime(creatureTarget
->GetRespawnTime()-time(NULL
));
803 pGameObj
->SetOwnerGUID(m_caster
->GetGUID() );
804 pGameObj
->SetUInt32Value(GAMEOBJECT_LEVEL
, m_caster
->getLevel() );
805 pGameObj
->SetSpellId(m_spellInfo
->Id
);
807 creatureTarget
->setDeathState(JUST_DIED
);
808 creatureTarget
->RemoveCorpse();
809 creatureTarget
->SetHealth(0); // just for nice GM-mode view
811 DEBUG_LOG("AddObject at SpellEfects.cpp EffectDummy");
814 WorldPacket
data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE
, 8);
815 data
<< uint64(pGameObj
->GetGUID());
816 m_caster
->SendMessageToSet(&data
,true);
820 case 23074: // Arcanite Dragonling
821 if (!m_CastItem
) return;
822 m_caster
->CastSpell(m_caster
,19804,true,m_CastItem
);
824 case 23075: // Mithril Mechanical Dragonling
825 if (!m_CastItem
) return;
826 m_caster
->CastSpell(m_caster
,12749,true,m_CastItem
);
828 case 23076: // Mechanical Dragonling
829 if (!m_CastItem
) return;
830 m_caster
->CastSpell(m_caster
,4073,true,m_CastItem
);
832 case 23133: // Gnomish Battle Chicken
833 if (!m_CastItem
) return;
834 m_caster
->CastSpell(m_caster
,13166,true,m_CastItem
);
836 case 23448: // Ultrasafe Transporter: Gadgetzan - backfires
838 int32 r
= irand(0, 119);
839 if ( r
< 20 ) // 1/6 polymorph
840 m_caster
->CastSpell(m_caster
,23444,true);
841 else if ( r
< 100 ) // 4/6 evil twin
842 m_caster
->CastSpell(m_caster
,23445,true);
843 else // 1/6 miss the target
844 m_caster
->CastSpell(m_caster
,36902,true);
847 case 23453: // Ultrasafe Transporter: Gadgetzan
848 if ( roll_chance_i(50) ) // success
849 m_caster
->CastSpell(m_caster
,23441,true);
851 m_caster
->CastSpell(m_caster
,23446,true);
853 case 23645: // Hourglass Sand
854 m_caster
->RemoveAurasDueToSpell(23170);
856 case 23725: // Gift of Life (warrior bwl trinket)
857 m_caster
->CastSpell(m_caster
,23782,true);
858 m_caster
->CastSpell(m_caster
,23783,true);
860 case 25860: // Reindeer Transformation
862 if (!m_caster
->HasAuraType(SPELL_AURA_MOUNTED
))
865 float flyspeed
= m_caster
->GetSpeedRate(MOVE_FLIGHT
);
866 float speed
= m_caster
->GetSpeedRate(MOVE_RUN
);
868 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
870 //5 different spells used depending on mounted speed and if mount can fly or not
871 if (flyspeed
>= 4.1f
)
872 m_caster
->CastSpell(m_caster
, 44827, true); //310% flying Reindeer
873 else if (flyspeed
>= 3.8f
)
874 m_caster
->CastSpell(m_caster
, 44825, true); //280% flying Reindeer
875 else if (flyspeed
>= 1.6f
)
876 m_caster
->CastSpell(m_caster
, 44824, true); //60% flying Reindeer
877 else if (speed
>= 2.0f
)
878 m_caster
->CastSpell(m_caster
, 25859, true); //100% ground Reindeer
880 m_caster
->CastSpell(m_caster
, 25858, true); //60% ground Reindeer
884 //case 26074: // Holiday Cheer
885 // return; -- implemented at client side
886 case 28006: // Arcane Cloaking
888 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
889 m_caster
->CastSpell(unitTarget
,29294,true);
892 case 28730: // Arcane Torrent (Mana)
894 Aura
* dummy
= m_caster
->GetDummyAura(28734);
897 int32 bp
= damage
* dummy
->GetStackAmount();
898 m_caster
->CastCustomSpell(m_caster
, 28733, &bp
, NULL
, NULL
, true);
899 m_caster
->RemoveAurasDueToSpell(28734);
903 case 29200: // Purify Helboar Meat
905 if( m_caster
->GetTypeId() != TYPEID_PLAYER
)
908 uint32 spell_id
= roll_chance_i(50) ? 29277 : 29278;
910 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
913 case 29858: // Soulshatter
914 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_UNIT
&& unitTarget
->IsHostileTo(m_caster
))
915 m_caster
->CastSpell(unitTarget
,32835,true);
917 case 30458: // Nigh Invulnerability
918 if (!m_CastItem
) return;
919 if(roll_chance_i(86)) // success
920 m_caster
->CastSpell(m_caster
, 30456, true, m_CastItem
);
921 else // backfire in 14% casts
922 m_caster
->CastSpell(m_caster
, 30457, true, m_CastItem
);
924 case 30507: // Poultryizer
925 if (!m_CastItem
) return;
926 if(roll_chance_i(80)) // success
927 m_caster
->CastSpell(unitTarget
, 30501, true, m_CastItem
);
929 m_caster
->CastSpell(unitTarget
, 30504, true, m_CastItem
);
931 case 33060: // Make a Wish
933 if(m_caster
->GetTypeId()!=TYPEID_PLAYER
)
940 case 1: spell_id
= 33053; break;
941 case 2: spell_id
= 33057; break;
942 case 3: spell_id
= 33059; break;
943 case 4: spell_id
= 33062; break;
944 case 5: spell_id
= 33064; break;
947 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
953 switch(m_caster
->GetAreaId())
955 case 3900: spell_id
= 35743; break;
956 case 3742: spell_id
= 35744; break;
960 m_caster
->CastSpell(m_caster
,spell_id
,true);
963 case 37674: // Chaos Blast
968 int32 basepoints0
= 100;
969 m_caster
->CastCustomSpell(unitTarget
,37675,&basepoints0
,NULL
,NULL
,true);
972 case 40802: // Mingo's Fortune Generator (Mingo's Fortune Giblets)
974 // selecting one from Bloodstained Fortune item
978 case 1: newitemid
= 32688; break;
979 case 2: newitemid
= 32689; break;
980 case 3: newitemid
= 32690; break;
981 case 4: newitemid
= 32691; break;
982 case 5: newitemid
= 32692; break;
983 case 6: newitemid
= 32693; break;
984 case 7: newitemid
= 32700; break;
985 case 8: newitemid
= 32701; break;
986 case 9: newitemid
= 32702; break;
987 case 10: newitemid
= 32703; break;
988 case 11: newitemid
= 32704; break;
989 case 12: newitemid
= 32705; break;
990 case 13: newitemid
= 32706; break;
991 case 14: newitemid
= 32707; break;
992 case 15: newitemid
= 32708; break;
993 case 16: newitemid
= 32709; break;
994 case 17: newitemid
= 32710; break;
995 case 18: newitemid
= 32711; break;
996 case 19: newitemid
= 32712; break;
997 case 20: newitemid
= 32713; break;
1002 DoCreateItem(i
,newitemid
);
1005 // Demon Broiled Surprise
1006 /* FIX ME: Required for correct work implementing implicit target 7 (in pair (22,7))
1009 if (m_caster->GetTypeId() != TYPEID_PLAYER)
1012 ((Player*)m_caster)->CastSpell(unitTarget, 43753, true);
1016 case 44875: // Complete Raptor Capture
1018 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
)
1021 Creature
* creatureTarget
= (Creature
*)unitTarget
;
1023 creatureTarget
->setDeathState(JUST_DIED
);
1024 creatureTarget
->RemoveCorpse();
1025 creatureTarget
->SetHealth(0); // just for nice GM-mode view
1027 //cast spell Raptor Capture Credit
1028 m_caster
->CastSpell(m_caster
,42337,true,NULL
);
1031 case 34665: //Administer Antidote
1033 if(!unitTarget
|| m_caster
->GetTypeId() != TYPEID_PLAYER
)
1039 TemporarySummon
* tempSummon
= dynamic_cast<TemporarySummon
*>(unitTarget
);
1043 uint32 health
= tempSummon
->GetHealth();
1045 float x
= tempSummon
->GetPositionX();
1046 float y
= tempSummon
->GetPositionY();
1047 float z
= tempSummon
->GetPositionZ();
1048 float o
= tempSummon
->GetOrientation();
1049 tempSummon
->UnSummon();
1051 Creature
* pCreature
= m_caster
->SummonCreature(16992, x
, y
, z
, o
,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
,180000);
1055 pCreature
->SetHealth(health
);
1056 ((Player
*)m_caster
)->RewardPlayerAndGroupAtEvent(16992,pCreature
);
1058 if (pCreature
->AI())
1059 pCreature
->AI()->AttackStart(m_caster
);
1063 case 44997: // Converting Sentry
1065 //Converted Sentry Credit
1066 m_caster
->CastSpell(m_caster
, 45009, true);
1069 case 45030: // Impale Emissary
1071 // Emissary of Hate Credit
1072 m_caster
->CastSpell(m_caster
, 45088, true);
1075 case 50243: // Teach Language
1077 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
1080 // spell has a 1/3 chance to trigger one of the below
1081 if(roll_chance_i(66))
1083 if(((Player
*)m_caster
)->GetTeam() == ALLIANCE
)
1085 // 1000001 - gnomish binary
1086 m_caster
->CastSpell(m_caster
, 50242, true);
1090 // 01001000 - goblin binary
1091 m_caster
->CastSpell(m_caster
, 50246, true);
1096 case 51582: //Rocket Boots Engaged (Rocket Boots Xtreme and Rocket Boots Xtreme Lite)
1098 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
1101 if(BattleGround
* bg
= ((Player
*)m_caster
)->GetBattleGround())
1102 bg
->EventPlayerDroppedFlag((Player
*)m_caster
);
1104 m_caster
->CastSpell(m_caster
, 30452, true, NULL
);
1113 uint32 spellID
= m_spellInfo
->CalculateSimpleValue(0);
1114 uint32 reqAuraID
= m_spellInfo
->CalculateSimpleValue(1);
1116 if (m_caster
->HasAura(reqAuraID
,0))
1117 m_caster
->CastSpell(m_caster
,spellID
,true,NULL
);
1121 return; // additional data for dummy[0]
1128 m_caster
->CastSpell(m_caster
,54586,true);
1131 case 58418: // Portal to Orgrimmar
1132 case 58420: // Portal to Stormwind
1133 return; // implemented in EffectScript[0]
1136 //All IconID Check in there
1137 switch(m_spellInfo
->SpellIconID
)
1139 // Berserking (troll racial traits)
1142 uint32 healthPerc
= uint32((float(m_caster
->GetHealth())/m_caster
->GetMaxHealth())*100);
1143 int32 melee_mod
= 10;
1144 if (healthPerc
<= 40)
1146 if (healthPerc
< 100 && healthPerc
> 40)
1147 melee_mod
= 10+(100-healthPerc
)/3;
1149 int32 hasteModBasePoints0
= melee_mod
; // (EffectBasePoints[0]+1)-1+(5-melee_mod) = (melee_mod-1+1)-1+5-melee_mod = 5-1
1150 int32 hasteModBasePoints1
= (5-melee_mod
);
1151 int32 hasteModBasePoints2
= 5;
1153 // FIXME: custom spell required this aura state by some unknown reason, we not need remove it anyway
1154 m_caster
->ModifyAuraState(AURA_STATE_BERSERKING
,true);
1155 m_caster
->CastCustomSpell(m_caster
,26635,&hasteModBasePoints0
,&hasteModBasePoints1
,&hasteModBasePoints2
,true,NULL
);
1161 case SPELLFAMILY_MAGE
:
1162 switch(m_spellInfo
->Id
)
1164 case 11958: // Cold Snap
1166 if(m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1169 // immediately finishes the cooldown on Frost spells
1170 const PlayerSpellMap
& sp_list
= ((Player
*)m_caster
)->GetSpellMap();
1171 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
1173 if (itr
->second
->state
== PLAYERSPELL_REMOVED
)
1176 uint32 classspell
= itr
->first
;
1177 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(classspell
);
1179 if( spellInfo
->SpellFamilyName
== SPELLFAMILY_MAGE
&&
1180 (GetSpellSchoolMask(spellInfo
) & SPELL_SCHOOL_MASK_FROST
) &&
1181 spellInfo
->Id
!= 11958 && GetSpellRecoveryTime(spellInfo
) > 0 )
1183 ((Player
*)m_caster
)->RemoveSpellCooldown(classspell
);
1185 WorldPacket
data(SMSG_CLEAR_COOLDOWN
, (4+8));
1186 data
<< uint32(classspell
);
1187 data
<< uint64(m_caster
->GetGUID());
1188 ((Player
*)m_caster
)->GetSession()->SendPacket(&data
);
1195 if ( unitTarget
&& unitTarget
->GetTypeId() == TYPEID_UNIT
)
1197 //Polymorph Cast Visual Rank 1
1198 const uint32 spell_list
[6] = {32813, 32816, 32817, 32818, 32819, 32820};
1199 unitTarget
->CastSpell( unitTarget
, spell_list
[urand(0, 5)], true);
1205 case SPELLFAMILY_WARRIOR
:
1207 if(m_spellInfo
->SpellFamilyFlags
& 0x1 && m_spellInfo
->SpellVisual
[0] == 867)
1209 int32 chargeBasePoints0
= damage
;
1210 m_caster
->CastCustomSpell(m_caster
,34846,&chargeBasePoints0
,NULL
,NULL
,true);
1214 if(m_spellInfo
->SpellFamilyFlags
& 0x20000000)
1219 uint32 rage
= m_caster
->GetPower(POWER_RAGE
);
1220 // Glyph of Execution bonus
1221 if (Aura
*aura
= m_caster
->GetDummyAura(58367))
1222 rage
+=aura
->GetModifier()->m_amount
;
1224 int32 basePoints0
= damage
+int32(rage
* m_spellInfo
->DmgMultiplier
[i
] +
1225 m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.2f
);
1226 m_caster
->CastCustomSpell(unitTarget
, 20647, &basePoints0
, NULL
, NULL
, true, 0);
1227 m_caster
->SetPower(POWER_RAGE
,0);
1231 if(m_spellInfo
->SpellFamilyFlags
& 0x0000000000200000LL
)
1235 m_damage
+=m_caster
->CalculateDamage(m_attackType
, false);
1240 if(m_spellInfo
->SpellFamilyFlags
& 0x0000000004000000LL
)
1242 m_damage
+= uint32(damage
* m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
1245 switch(m_spellInfo
->Id
)
1252 m_caster
->CastSpell(unitTarget
,21887,true); // spell mod
1258 int32 healthModSpellBasePoints0
= int32(m_caster
->GetMaxHealth()*0.3);
1259 m_caster
->CastCustomSpell(m_caster
, 12976, &healthModSpellBasePoints0
, NULL
, NULL
, true, NULL
);
1265 m_caster
->CastCustomSpell(unitTarget
, 23885, &damage
, NULL
, NULL
, true, NULL
);
1270 case SPELLFAMILY_WARLOCK
:
1272 if (m_spellInfo
->SpellFamilyFlags
& 0x0000000000040000LL
)
1274 // In 303 exist spirit depend
1275 uint32 spirit
= uint32(m_caster
->GetStat(STAT_SPIRIT
));
1276 switch (m_spellInfo
->Id
)
1278 case 1454: damage
+=spirit
; break;
1279 case 1455: damage
+=spirit
*15/10; break;
1280 case 1456: damage
+=spirit
*2; break;
1281 case 11687: damage
+=spirit
*25/10; break;
1285 case 57946: damage
+=spirit
*3; break;
1287 sLog
.outError("Spell::EffectDummy: %u Life Tap need set spirit multipler", m_spellInfo
->Id
);
1290 // Think its not need (also need remove Life Tap from SpellDamageBonus or add new value)
1291 // damage = m_caster->SpellDamageBonus(m_caster, m_spellInfo,uint32(damage > 0 ? damage : 0), SPELL_DIRECT_DAMAGE);
1292 if(unitTarget
&& (int32(unitTarget
->GetHealth()) > damage
))
1294 // Shouldn't Appear in Combat Log
1295 unitTarget
->ModifyHealth(-damage
);
1297 int32 mana
= damage
;
1298 // Improved Life Tap mod
1299 Unit::AuraList
const& auraDummy
= m_caster
->GetAurasByType(SPELL_AURA_DUMMY
);
1300 for(Unit::AuraList::const_iterator itr
= auraDummy
.begin(); itr
!= auraDummy
.end(); ++itr
)
1302 if((*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (*itr
)->GetSpellProto()->SpellIconID
== 208)
1303 mana
= ((*itr
)->GetModifier()->m_amount
+ 100)* mana
/ 100;
1305 m_caster
->CastCustomSpell(unitTarget
, 31818, &mana
, NULL
, NULL
, true);
1308 int32 manaFeedVal
= 0;
1309 Unit::AuraList
const& mod
= m_caster
->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER
);
1310 for(Unit::AuraList::const_iterator itr
= mod
.begin(); itr
!= mod
.end(); ++itr
)
1312 if((*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (*itr
)->GetSpellProto()->SpellIconID
== 1982)
1313 manaFeedVal
+= (*itr
)->GetModifier()->m_amount
;
1317 manaFeedVal
= manaFeedVal
* mana
/ 100;
1318 m_caster
->CastCustomSpell(m_caster
, 32553, &manaFeedVal
, NULL
, NULL
, true, NULL
);
1322 SendCastResult(SPELL_FAILED_FIZZLE
);
1326 case SPELLFAMILY_PRIEST
:
1328 if (m_spellInfo
->SpellFamilyFlags
& 0x0080000000000000LL
)
1335 switch(m_spellInfo
->Id
)
1337 case 47540: hurt
= 47758; heal
= 47757; break;
1338 case 53005: hurt
= 53001; heal
= 52986; break;
1339 case 53006: hurt
= 53002; heal
= 52987; break;
1340 case 53007: hurt
= 53003; heal
= 52988; break;
1342 sLog
.outError("Spell::EffectDummy: Spell %u Penance need set correct heal/damage spell", m_spellInfo
->Id
);
1345 if (m_caster
->IsFriendlyTo(unitTarget
))
1346 m_caster
->CastSpell(unitTarget
, heal
, true, 0);
1348 m_caster
->CastSpell(unitTarget
, hurt
, true, 0);
1352 case SPELLFAMILY_DRUID
:
1354 if (m_spellInfo
->SpellFamilyFlags2
& 0x00000100LL
)
1356 //Shapeshifting into an animal form or mounting cancels the effect.
1357 if(m_caster
->GetCreatureType() == CREATURE_TYPE_BEAST
|| m_caster
->IsMounted())
1359 if(m_triggeredByAuraSpell
)
1360 m_caster
->RemoveAurasDueToSpell(m_triggeredByAuraSpell
->Id
);
1364 //Any effect which causes you to lose control of your character will supress the starfall effect.
1365 if(m_caster
->hasUnitState(UNIT_STAT_STUNNED
| UNIT_STAT_FLEEING
| UNIT_STAT_ROOT
| UNIT_STAT_CONFUSED
))
1368 switch(m_spellInfo
->Id
)
1370 case 50286: m_caster
->CastSpell(unitTarget
, 50288, true); return;
1371 case 53196: m_caster
->CastSpell(unitTarget
, 53191, true); return;
1372 case 53197: m_caster
->CastSpell(unitTarget
, 53194, true); return;
1373 case 53198: m_caster
->CastSpell(unitTarget
, 53195, true); return;
1375 sLog
.outError("Spell::EffectDummy: Unhandeled Starfall spell rank %u",m_spellInfo
->Id
);
1380 case SPELLFAMILY_ROGUE
:
1381 switch(m_spellInfo
->Id
)
1385 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
1388 Player
*pCaster
= ((Player
*)m_caster
);
1390 Item
*item
= pCaster
->GetWeaponForAttack(OFF_ATTACK
);
1394 // all poison enchantments is temporary
1395 uint32 enchant_id
= item
->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT
);
1399 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
1403 for (int s
=0;s
<3;s
++)
1405 if(pEnchant
->type
[s
]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL
)
1408 SpellEntry
const* combatEntry
= sSpellStore
.LookupEntry(pEnchant
->spellid
[s
]);
1409 if(!combatEntry
|| combatEntry
->Dispel
!= DISPEL_POISON
)
1412 m_caster
->CastSpell(unitTarget
, combatEntry
, true, item
);
1415 m_caster
->CastSpell(unitTarget
, 5940, true);
1418 case 14185: // Preparation Rogue
1420 if(m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1423 //immediately finishes the cooldown on certain Rogue abilities
1424 const PlayerSpellMap
& sp_list
= ((Player
*)m_caster
)->GetSpellMap();
1425 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
1427 uint32 classspell
= itr
->first
;
1428 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(classspell
);
1430 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& (spellInfo
->SpellFamilyFlags
& 0x0000024000000860LL
))
1432 ((Player
*)m_caster
)->RemoveSpellCooldown(classspell
);
1434 WorldPacket
data(SMSG_CLEAR_COOLDOWN
, (4+8));
1435 data
<< uint32(classspell
);
1436 data
<< uint64(m_caster
->GetGUID());
1437 ((Player
*)m_caster
)->GetSession()->SendPacket(&data
);
1442 case 31231: // Cheat Death
1444 m_caster
->CastSpell(m_caster
,45182,true);
1449 case SPELLFAMILY_HUNTER
:
1451 if(m_spellInfo
->SpellFamilyFlags
& 0x100000000LL
)
1453 if( !unitTarget
|| !unitTarget
->isAlive())
1458 // check dazed affect
1459 Unit::AuraList
const& decSpeedList
= unitTarget
->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED
);
1460 for(Unit::AuraList::const_iterator iter
= decSpeedList
.begin(); iter
!= decSpeedList
.end(); ++iter
)
1462 if((*iter
)->GetSpellProto()->SpellIconID
==15 && (*iter
)->GetSpellProto()->Dispel
==0)
1474 switch(m_spellInfo
->Id
)
1476 case 23989: //Readiness talent
1478 if(m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1481 //immediately finishes the cooldown for hunter abilities
1482 const PlayerSpellMap
& sp_list
= ((Player
*)m_caster
)->GetSpellMap();
1483 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
1485 uint32 classspell
= itr
->first
;
1486 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(classspell
);
1488 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_HUNTER
&& spellInfo
->Id
!= 23989 && GetSpellRecoveryTime(spellInfo
) > 0 )
1490 ((Player
*)m_caster
)->RemoveSpellCooldown(classspell
);
1492 WorldPacket
data(SMSG_CLEAR_COOLDOWN
, (4+8));
1493 data
<< uint32(classspell
);
1494 data
<< uint64(m_caster
->GetGUID());
1495 ((Player
*)m_caster
)->GetSession()->SendPacket(&data
);
1500 case 37506: // Scatter Shot
1502 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1505 // break Auto Shot and autohit
1506 m_caster
->InterruptSpell(CURRENT_AUTOREPEAT_SPELL
);
1507 m_caster
->AttackStop();
1508 ((Player
*)m_caster
)->SendAttackSwingCancelAttack();
1513 case SPELLFAMILY_PALADIN
:
1514 switch(m_spellInfo
->SpellIconID
)
1516 case 156: // Holy Shock
1524 switch(m_spellInfo
->Id
)
1526 case 20473: hurt
= 25912; heal
= 25914; break;
1527 case 20929: hurt
= 25911; heal
= 25913; break;
1528 case 20930: hurt
= 25902; heal
= 25903; break;
1529 case 27174: hurt
= 27176; heal
= 27175; break;
1530 case 33072: hurt
= 33073; heal
= 33074; break;
1531 case 48824: hurt
= 48822; heal
= 48820; break;
1532 case 48825: hurt
= 48823; heal
= 48821; break;
1534 sLog
.outError("Spell::EffectDummy: Spell %u not handled in HS",m_spellInfo
->Id
);
1538 if(m_caster
->IsFriendlyTo(unitTarget
))
1539 m_caster
->CastSpell(unitTarget
, heal
, true, 0);
1541 m_caster
->CastSpell(unitTarget
, hurt
, true, 0);
1545 case 561: // Judgement of command
1550 uint32 spell_id
= m_currentBasePoints
[i
]+1;
1551 SpellEntry
const* spell_proto
= sSpellStore
.LookupEntry(spell_id
);
1555 if( !unitTarget
->hasUnitState(UNIT_STAT_STUNNED
) && m_caster
->GetTypeId()==TYPEID_PLAYER
)
1557 // decreased damage (/2) for non-stunned target.
1558 SpellModifier
*mod
= new SpellModifier
;
1559 mod
->op
= SPELLMOD_DAMAGE
;
1561 mod
->type
= SPELLMOD_PCT
;
1562 mod
->spellId
= m_spellInfo
->Id
;
1563 mod
->mask
= 0x0000020000000000LL
;
1566 ((Player
*)m_caster
)->AddSpellMod(mod
, true);
1567 m_caster
->CastSpell(unitTarget
,spell_proto
,true,NULL
);
1569 ((Player
*)m_caster
)->AddSpellMod(mod
, false);
1572 m_caster
->CastSpell(unitTarget
,spell_proto
,true,NULL
);
1578 switch(m_spellInfo
->Id
)
1580 // Judgement of Righteousness (0.2*$AP+0.32*$SPH) holy added in spellDamagBonus
1585 m_damage
+=int32(0.2f
*m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
));
1588 case 31789: // Righteous Defense (step 1)
1590 // 31989 -> dummy effect (step 1) + dummy effect (step 2) -> 31709 (taunt like spell for each target)
1592 // non-standard cast requirement check
1593 if (!unitTarget
|| unitTarget
->getAttackers().empty())
1595 // clear cooldown at fail
1596 if(m_caster
->GetTypeId()==TYPEID_PLAYER
)
1598 ((Player
*)m_caster
)->RemoveSpellCooldown(m_spellInfo
->Id
);
1600 WorldPacket
data(SMSG_CLEAR_COOLDOWN
, (4+8));
1601 data
<< uint32(m_spellInfo
->Id
);
1602 data
<< uint64(m_caster
->GetGUID());
1603 ((Player
*)m_caster
)->GetSession()->SendPacket(&data
);
1606 SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT
);
1610 // Righteous Defense (step 2) (in old version 31980 dummy effect)
1611 // Clear targets for eff 1
1612 for(std::list
<TargetInfo
>::iterator ihit
= m_UniqueTargetInfo
.begin();ihit
!= m_UniqueTargetInfo
.end();++ihit
)
1613 ihit
->effectMask
&= ~(1<<1);
1615 // not empty (checked)
1616 Unit::AttackerSet
const& attackers
= unitTarget
->getAttackers();
1618 // chance to be selected from list
1619 float chance
= 100.0f
/attackers
.size();
1621 for(Unit::AttackerSet::const_iterator aItr
= attackers
.begin(); aItr
!= attackers
.end() && count
< 3; ++aItr
)
1623 if(!roll_chance_f(chance
))
1626 AddUnitTarget((*aItr
), 1);
1629 // now let next effect cast spell at each target.
1632 case 37877: // Blessing of Faith
1637 uint32 spell_id
= 0;
1638 switch(unitTarget
->getClass())
1640 case CLASS_DRUID
: spell_id
= 37878; break;
1641 case CLASS_PALADIN
: spell_id
= 37879; break;
1642 case CLASS_PRIEST
: spell_id
= 37880; break;
1643 case CLASS_SHAMAN
: spell_id
= 37881; break;
1644 default: return; // ignore for not healing classes
1647 m_caster
->CastSpell(m_caster
,spell_id
,true);
1652 case SPELLFAMILY_SHAMAN
:
1653 //Shaman Rockbiter Weapon
1654 if (m_spellInfo
->SpellFamilyFlags
== 0x400000)
1656 // TODO: use expect spell for enchant (if exist talent)
1657 // In 3.0.3 no mods present for rockbiter
1658 uint32 spell_id
= 0;
1659 switch(m_spellInfo
->Id
)
1661 case 8017: spell_id
= 36494; break; // Rank 1
1662 case 8018: spell_id
= 36750; break; // Rank 2
1663 case 8019: spell_id
= 36755; break; // Rank 3
1664 case 10399: spell_id
= 36759; break; // Rank 4
1666 sLog
.outError("Spell::EffectDummy: Spell %u not handled in RW",m_spellInfo
->Id
);
1670 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( spell_id
);
1674 sLog
.outError("WORLD: unknown spell id %i", spell_id
);
1678 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
1681 for(int j
= BASE_ATTACK
; j
<= OFF_ATTACK
; ++j
)
1683 if(Item
* item
= ((Player
*)m_caster
)->GetWeaponForAttack(WeaponAttackType(j
)))
1685 if(item
->IsFitToSpellRequirements(m_spellInfo
))
1687 Spell
*spell
= new Spell(m_caster
, spellInfo
, true);
1689 // enchanting spell selected by calculated damage-per-sec in enchanting effect
1690 // at calculation applied affect from Elemental Weapons talent
1691 // real enchantment damage-1
1692 spell
->m_currentBasePoints
[1] = damage
-1;
1694 SpellCastTargets targets
;
1695 targets
.setItemTarget( item
);
1696 spell
->prepare(&targets
);
1702 // Healing Stream Totem
1703 if(m_spellInfo
->SpellFamilyFlags
& 0x0000000000002000LL
)
1705 m_caster
->CastCustomSpell(unitTarget
, 52042, &damage
, 0, 0, true, 0, 0, m_originalCasterGUID
);
1708 // Mana Spring Totem
1709 if(m_spellInfo
->SpellFamilyFlags
& 0x0000000000004000LL
)
1711 if(unitTarget
->getPowerType()!=POWER_MANA
)
1713 m_caster
->CastCustomSpell(unitTarget
, 52032, &damage
, 0, 0, true, 0, 0, m_originalCasterGUID
);
1716 if(m_spellInfo
->Id
== 39610) // Mana Tide Totem effect
1718 if(!unitTarget
|| unitTarget
->getPowerType() != POWER_MANA
)
1720 // Glyph of Mana Tide
1721 Unit
*owner
= m_caster
->GetOwner();
1723 if (Aura
*dummy
= owner
->GetDummyAura(55441))
1724 damage
+=dummy
->GetModifier()->m_amount
;
1725 // Regenerate 6% of Total Mana Every 3 secs
1726 int32 EffectBasePoints0
= unitTarget
->GetMaxPower(POWER_MANA
) * damage
/ 100;
1727 m_caster
->CastCustomSpell(unitTarget
,39609,&EffectBasePoints0
,NULL
,NULL
,true,NULL
,NULL
,m_originalCasterGUID
);
1731 if (m_spellInfo
->SpellFamilyFlags2
& 0x00000004)
1733 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1735 Item
*item
= ((Player
*)m_caster
)->GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_OFFHAND
);
1738 // Damage is increased if your off-hand weapon is enchanted with Flametongue.
1739 Unit::AuraList
const& auraDummy
= m_caster
->GetAurasByType(SPELL_AURA_DUMMY
);
1740 for(Unit::AuraList::const_iterator itr
= auraDummy
.begin(); itr
!= auraDummy
.end(); ++itr
)
1742 if( (*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_SHAMAN
&&
1743 (*itr
)->GetSpellProto()->SpellFamilyFlags
& 0x0000000000200000LL
&&
1744 (*itr
)->GetCastItemGUID() == item
->GetGUID())
1746 m_damage
+= m_damage
* damage
/ 100;
1754 case SPELLFAMILY_DEATHKNIGHT
:
1756 if(m_spellInfo
->SpellFamilyFlags
& 0x002000LL
)
1758 if(m_caster
->IsFriendlyTo(unitTarget
))
1760 if(unitTarget
->GetCreatureType() != CREATURE_TYPE_UNDEAD
)
1763 int32 bp
= damage
* 1.5f
;
1764 m_caster
->CastCustomSpell(unitTarget
,47633,&bp
,NULL
,NULL
,true);
1769 m_caster
->CastCustomSpell(unitTarget
,47632,&bp
,NULL
,NULL
,true);
1777 if(PetAura
const* petSpell
= spellmgr
.GetPetAura(m_spellInfo
->Id
))
1779 m_caster
->AddPetAura(petSpell
);
1783 // Script based implementation. Must be used only for not good for implementation in core spell effects
1784 // So called only for not proccessed cases
1786 Script
->EffectDummyGameObj(m_caster
, m_spellInfo
->Id
, i
, gameObjTarget
);
1787 else if(unitTarget
&& unitTarget
->GetTypeId()==TYPEID_UNIT
)
1788 Script
->EffectDummyCreature(m_caster
, m_spellInfo
->Id
, i
, (Creature
*)unitTarget
);
1790 Script
->EffectDummyItem(m_caster
, m_spellInfo
->Id
, i
, itemTarget
);
1793 void Spell::EffectTriggerSpellWithValue(uint32 i
)
1795 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[i
];
1798 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
1802 sLog
.outError("EffectTriggerSpellWithValue of spell %u: triggering unknown spell id %i", m_spellInfo
->Id
,triggered_spell_id
);
1807 m_caster
->CastCustomSpell(unitTarget
,triggered_spell_id
,&bp
,&bp
,&bp
,true,NULL
,NULL
,m_originalCasterGUID
);
1810 void Spell::EffectTriggerRitualOfSummoning(uint32 i
)
1812 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[i
];
1813 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
1817 sLog
.outError("EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", m_spellInfo
->Id
,triggered_spell_id
);
1822 Spell
*spell
= new Spell(m_caster
, spellInfo
, true);
1824 SpellCastTargets targets
;
1825 targets
.setUnitTarget( unitTarget
);
1826 spell
->prepare(&targets
);
1828 m_caster
->SetCurrentCastedSpell(spell
);
1829 spell
->m_selfContainer
= &(m_caster
->m_currentSpells
[spell
->GetCurrentContainer()]);
1833 void Spell::EffectForceCast(uint32 i
)
1838 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[i
];
1841 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
1845 sLog
.outError("EffectForceCast of spell %u: triggering unknown spell id %i", m_spellInfo
->Id
,triggered_spell_id
);
1849 unitTarget
->CastSpell(unitTarget
,spellInfo
,true,NULL
,NULL
,m_originalCasterGUID
);
1852 void Spell::EffectTriggerSpell(uint32 i
)
1854 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[i
];
1857 switch(triggered_spell_id
)
1862 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
1863 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
1864 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED
);
1866 // if this spell is given to NPC it must handle rest by it's own AI
1867 if ( m_caster
->GetTypeId() != TYPEID_PLAYER
)
1870 // get highest rank of the Stealth spell
1872 const PlayerSpellMap
& sp_list
= ((Player
*)m_caster
)->GetSpellMap();
1873 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
1875 // only highest rank is shown in spell book, so simply check if shown in spell book
1876 if(!itr
->second
->active
|| itr
->second
->disabled
|| itr
->second
->state
== PLAYERSPELL_REMOVED
)
1879 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
1883 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& spellInfo
->SpellFamilyFlags
& SPELLFAMILYFLAG_ROGUE_STEALTH
)
1885 spellId
= spellInfo
->Id
;
1890 // no Stealth spell found
1894 // reset cooldown on it if needed
1895 if(((Player
*)m_caster
)->HasSpellCooldown(spellId
))
1896 ((Player
*)m_caster
)->RemoveSpellCooldown(spellId
);
1898 m_caster
->CastSpell(m_caster
, spellId
, true);
1902 case 23770: // Sayge's Dark Fortune of *
1903 // not exist, common cooldown can be implemented in scripts if need.
1905 // Brittle Armor - (need add max stack of 24575 Brittle Armor)
1908 const SpellEntry
*spell
= sSpellStore
.LookupEntry(24575);
1912 for (int j
=0; j
< spell
->StackAmount
; ++j
)
1913 m_caster
->CastSpell(unitTarget
,spell
->Id
, true, m_CastItem
, NULL
, m_originalCasterGUID
);
1916 // Mercurial Shield - (need add max stack of 26464 Mercurial Shield)
1919 const SpellEntry
*spell
= sSpellStore
.LookupEntry(26464);
1923 for (int j
=0; j
< spell
->StackAmount
; ++j
)
1924 m_caster
->CastSpell(unitTarget
,spell
->Id
, true, m_CastItem
, NULL
, m_originalCasterGUID
);
1927 // Righteous Defense
1930 m_caster
->CastSpell(unitTarget
, 31790, true,m_CastItem
,NULL
,m_originalCasterGUID
);
1936 Unit::AuraMap
& Auras
= m_caster
->GetAuras();
1937 for(Unit::AuraMap::iterator iter
= Auras
.begin(); iter
!= Auras
.end(); ++iter
)
1939 // remove all harmful spells on you...
1940 if( // ignore positive and passive auras
1941 !iter
->second
->IsPositive() && !iter
->second
->IsPassive() &&
1942 // ignore physical auras
1943 (GetSpellSchoolMask(iter
->second
->GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
)==0 )
1945 m_caster
->RemoveAurasDueToSpell(iter
->second
->GetSpellProto()->Id
);
1946 iter
= Auras
.begin();
1951 // Priest Shadowfiend (34433) need apply mana gain trigger aura on pet
1954 if (Unit
*pet
= m_caster
->GetPet())
1955 pet
->CastSpell(pet
, 28305, true);
1961 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
1965 sLog
.outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo
->Id
,triggered_spell_id
);
1969 // some triggered spells require specific equipment
1970 if(spellInfo
->EquippedItemClass
>=0 && m_caster
->GetTypeId()==TYPEID_PLAYER
)
1972 // main hand weapon required
1973 if(spellInfo
->AttributesEx3
& SPELL_ATTR_EX3_MAIN_HAND
)
1975 Item
* item
= ((Player
*)m_caster
)->GetWeaponForAttack(BASE_ATTACK
);
1977 // skip spell if no weapon in slot or broken
1978 if(!item
|| item
->IsBroken() )
1981 // skip spell if weapon not fit to triggered spell
1982 if(!item
->IsFitToSpellRequirements(spellInfo
))
1986 // offhand hand weapon required
1987 if(spellInfo
->AttributesEx3
& SPELL_ATTR_EX3_REQ_OFFHAND
)
1989 Item
* item
= ((Player
*)m_caster
)->GetWeaponForAttack(OFF_ATTACK
);
1991 // skip spell if no weapon in slot or broken
1992 if(!item
|| item
->IsBroken() )
1995 // skip spell if weapon not fit to triggered spell
1996 if(!item
->IsFitToSpellRequirements(spellInfo
))
2001 // some triggered spells must be casted instantly (for example, if next effect case instant kill caster)
2002 bool instant
= false;
2003 for(uint32 j
= i
+1; j
< 3; ++j
)
2005 if(m_spellInfo
->Effect
[j
]==SPELL_EFFECT_INSTAKILL
&& m_spellInfo
->EffectImplicitTargetA
[j
]==TARGET_SELF
)
2015 m_caster
->CastSpell(unitTarget
,spellInfo
,true,m_CastItem
,NULL
,m_originalCasterGUID
);
2018 m_TriggerSpells
.push_back(spellInfo
);
2021 void Spell::EffectTriggerMissileSpell(uint32 effect_idx
)
2023 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[effect_idx
];
2026 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
2030 sLog
.outError("EffectTriggerMissileSpell of spell %u (eff: %u): triggering unknown spell id %u",
2031 m_spellInfo
->Id
,effect_idx
,triggered_spell_id
);
2036 DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo
->Id
);
2038 m_caster
->CastSpell(m_targets
.m_destX
, m_targets
.m_destY
, m_targets
.m_destZ
, spellInfo
, true, m_CastItem
, 0, m_originalCasterGUID
);
2041 void Spell::EffectJump(uint32 i
)
2043 if(m_caster
->isInFlight())
2046 // Init dest coordinates
2048 if(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
2050 x
= m_targets
.m_destX
;
2051 y
= m_targets
.m_destY
;
2052 z
= m_targets
.m_destZ
;
2054 if(m_spellInfo
->EffectImplicitTargetA
[i
] == TARGET_BEHIND_VICTIM
)
2056 // explicit cast data from client or server-side cast
2057 // some spell at client send caster
2058 Unit
* pTarget
= NULL
;
2059 if(m_targets
.getUnitTarget() && m_targets
.getUnitTarget()!=m_caster
)
2060 pTarget
= m_targets
.getUnitTarget();
2061 else if(unitTarget
->getVictim())
2062 pTarget
= m_caster
->getVictim();
2063 else if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
2064 pTarget
= ObjectAccessor::GetUnit(*m_caster
, ((Player
*)m_caster
)->GetSelection());
2066 o
= pTarget
? pTarget
->GetOrientation() : m_caster
->GetOrientation();
2069 o
= m_caster
->GetOrientation();
2073 unitTarget
->GetContactPoint(m_caster
,x
,y
,z
,CONTACT_DISTANCE
);
2074 o
= m_caster
->GetOrientation();
2076 else if(gameObjTarget
)
2078 gameObjTarget
->GetContactPoint(m_caster
,x
,y
,z
,CONTACT_DISTANCE
);
2079 o
= m_caster
->GetOrientation();
2083 sLog
.outError( "Spell::EffectJump - unsupported target mode for spell ID %u", m_spellInfo
->Id
);
2087 m_caster
->NearTeleportTo(x
,y
,z
,o
,true);
2090 void Spell::EffectTeleportUnits(uint32 i
)
2092 if(!unitTarget
|| unitTarget
->isInFlight())
2095 switch (m_spellInfo
->EffectImplicitTargetB
[i
])
2097 case TARGET_INNKEEPER_COORDINATES
:
2099 // Only players can teleport to innkeeper
2100 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
2103 ((Player
*)unitTarget
)->TeleportTo(((Player
*)unitTarget
)->m_homebindMapId
,((Player
*)unitTarget
)->m_homebindX
,((Player
*)unitTarget
)->m_homebindY
,((Player
*)unitTarget
)->m_homebindZ
,unitTarget
->GetOrientation(),unitTarget
==m_caster
? TELE_TO_SPELL
: 0);
2106 case TARGET_AREAEFFECT_INSTANT
: // in all cases first TARGET_TABLE_X_Y_Z_COORDINATES
2107 case TARGET_TABLE_X_Y_Z_COORDINATES
:
2109 SpellTargetPosition
const* st
= spellmgr
.GetSpellTargetPosition(m_spellInfo
->Id
);
2112 sLog
.outError( "Spell::EffectTeleportUnits - unknown Teleport coordinates for spell ID %u", m_spellInfo
->Id
);
2116 if(st
->target_mapId
==unitTarget
->GetMapId())
2117 unitTarget
->NearTeleportTo(st
->target_X
,st
->target_Y
,st
->target_Z
,st
->target_Orientation
,unitTarget
==m_caster
);
2118 else if(unitTarget
->GetTypeId()==TYPEID_PLAYER
)
2119 ((Player
*)unitTarget
)->TeleportTo(st
->target_mapId
,st
->target_X
,st
->target_Y
,st
->target_Z
,st
->target_Orientation
,unitTarget
==m_caster
? TELE_TO_SPELL
: 0);
2122 case TARGET_BEHIND_VICTIM
:
2124 Unit
*pTarget
= NULL
;
2126 // explicit cast data from client or server-side cast
2127 // some spell at client send caster
2128 if(m_targets
.getUnitTarget() && m_targets
.getUnitTarget()!=unitTarget
)
2129 pTarget
= m_targets
.getUnitTarget();
2130 else if(unitTarget
->getVictim())
2131 pTarget
= unitTarget
->getVictim();
2132 else if(unitTarget
->GetTypeId() == TYPEID_PLAYER
)
2133 pTarget
= ObjectAccessor::GetUnit(*unitTarget
, ((Player
*)unitTarget
)->GetSelection());
2135 // Init dest coordinates
2136 float x
= m_targets
.m_destX
;
2137 float y
= m_targets
.m_destY
;
2138 float z
= m_targets
.m_destZ
;
2139 float orientation
= pTarget
? pTarget
->GetOrientation() : unitTarget
->GetOrientation();
2140 unitTarget
->NearTeleportTo(x
,y
,z
,orientation
,unitTarget
==m_caster
);
2145 // If not exist data for dest location - return
2146 if(!(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
))
2148 sLog
.outError( "Spell::EffectTeleportUnits - unknown EffectImplicitTargetB[%u] = %u for spell ID %u", i
, m_spellInfo
->EffectImplicitTargetB
[i
], m_spellInfo
->Id
);
2151 // Init dest coordinates
2152 uint32 mapid
= m_caster
->GetMapId();
2153 float x
= m_targets
.m_destX
;
2154 float y
= m_targets
.m_destY
;
2155 float z
= m_targets
.m_destZ
;
2156 float orientation
= unitTarget
->GetOrientation();
2158 unitTarget
->NearTeleportTo(x
,y
,z
,orientation
,unitTarget
==m_caster
);
2163 // post effects for TARGET_TABLE_X_Y_Z_COORDINATES
2164 switch ( m_spellInfo
->Id
)
2166 // Dimensional Ripper - Everlook
2169 int32 r
= irand(0, 119);
2170 if ( r
>= 70 ) // 7/12 success
2172 if ( r
< 100 ) // 4/12 evil twin
2173 m_caster
->CastSpell(m_caster
,23445,true);
2175 m_caster
->CastSpell(m_caster
,23449,true);
2179 // Ultrasafe Transporter: Toshley's Station
2182 if ( roll_chance_i(50) ) // 50% success
2184 int32 rand_eff
= urand(1,7);
2188 // soul split - evil
2189 m_caster
->CastSpell(m_caster
,36900,true);
2192 // soul split - good
2193 m_caster
->CastSpell(m_caster
,36901,true);
2196 // Increase the size
2197 m_caster
->CastSpell(m_caster
,36895,true);
2200 // Decrease the size
2201 m_caster
->CastSpell(m_caster
,36893,true);
2206 if (((Player
*)m_caster
)->GetTeam() == ALLIANCE
)
2207 m_caster
->CastSpell(m_caster
,36897,true);
2209 m_caster
->CastSpell(m_caster
,36899,true);
2214 m_caster
->CastSpell(m_caster
,36940,true);
2218 m_caster
->CastSpell(m_caster
,23445,true);
2224 // Dimensional Ripper - Area 52
2227 if ( roll_chance_i(50) ) // 50% success
2229 int32 rand_eff
= urand(1,4);
2233 // soul split - evil
2234 m_caster
->CastSpell(m_caster
,36900,true);
2237 // soul split - good
2238 m_caster
->CastSpell(m_caster
,36901,true);
2241 // Increase the size
2242 m_caster
->CastSpell(m_caster
,36895,true);
2247 if (((Player
*)m_caster
)->GetTeam() == ALLIANCE
)
2248 m_caster
->CastSpell(m_caster
,36897,true);
2250 m_caster
->CastSpell(m_caster
,36899,true);
2260 void Spell::EffectApplyAura(uint32 i
)
2265 // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load)
2266 if( !unitTarget
->isAlive() && m_spellInfo
->Id
!= 20584 && m_spellInfo
->Id
!= 8326 &&
2267 (unitTarget
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)unitTarget
)->GetSession()->PlayerLoading()) )
2270 Unit
* caster
= m_originalCaster
? m_originalCaster
: m_caster
;
2274 sLog
.outDebug("Spell: Aura is: %u", m_spellInfo
->EffectApplyAuraName
[i
]);
2276 Aura
* Aur
= CreateAura(m_spellInfo
, i
, &m_currentBasePoints
[i
], unitTarget
, caster
, m_CastItem
);
2278 // Now Reduce spell duration using data received at spell hit
2279 int32 duration
= Aur
->GetAuraMaxDuration();
2280 unitTarget
->ApplyDiminishingToDuration(m_diminishGroup
,duration
,m_caster
,m_diminishLevel
);
2281 Aur
->setDiminishGroup(m_diminishGroup
);
2283 // if Aura removed and deleted, do not continue.
2284 if(duration
== 0 && !(Aur
->IsPermanent()))
2290 if(duration
!= Aur
->GetAuraMaxDuration())
2292 Aur
->SetAuraMaxDuration(duration
);
2293 Aur
->SetAuraDuration(duration
);
2296 bool added
= unitTarget
->AddAura(Aur
);
2298 // Aura not added and deleted in AddAura call;
2302 // found crash at character loading, broken pointer to Aur...
2303 // Aur was deleted in AddAura()...
2307 // Prayer of Mending (jump animation), we need formal caster instead original for correct animation
2308 if( m_spellInfo
->SpellFamilyName
== SPELLFAMILY_PRIEST
&& (m_spellInfo
->SpellFamilyFlags
& 0x00002000000000LL
))
2309 m_caster
->CastSpell(unitTarget
, 41637, true, NULL
, Aur
, m_originalCasterGUID
);
2312 void Spell::EffectUnlearnSpecialization( uint32 i
)
2314 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
2317 Player
*_player
= (Player
*)unitTarget
;
2318 uint32 spellToUnlearn
= m_spellInfo
->EffectTriggerSpell
[i
];
2320 _player
->removeSpell(spellToUnlearn
);
2322 sLog
.outDebug( "Spell: Player %u have unlearned spell %u from NpcGUID: %u", _player
->GetGUIDLow(), spellToUnlearn
, m_caster
->GetGUIDLow() );
2325 void Spell::EffectPowerDrain(uint32 i
)
2327 if(m_spellInfo
->EffectMiscValue
[i
] < 0 || m_spellInfo
->EffectMiscValue
[i
] >= MAX_POWERS
)
2330 Powers drain_power
= Powers(m_spellInfo
->EffectMiscValue
[i
]);
2334 if(!unitTarget
->isAlive())
2336 if(unitTarget
->getPowerType() != drain_power
)
2341 uint32 curPower
= unitTarget
->GetPower(drain_power
);
2343 //add spell damage bonus
2344 damage
=m_caster
->SpellDamageBonus(unitTarget
,m_spellInfo
,uint32(damage
),SPELL_DIRECT_DAMAGE
);
2346 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
2347 uint32 power
= damage
;
2348 if ( drain_power
== POWER_MANA
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
2349 power
-= ((Player
*)unitTarget
)->GetSpellCritDamageReduction(power
);
2352 if(curPower
< power
)
2353 new_damage
= curPower
;
2357 unitTarget
->ModifyPower(drain_power
,-new_damage
);
2359 // Don`t restore from self drain
2360 if(drain_power
== POWER_MANA
&& m_caster
!= unitTarget
)
2362 float manaMultiplier
= m_spellInfo
->EffectMultipleValue
[i
];
2363 if(manaMultiplier
==0)
2366 if(Player
*modOwner
= m_caster
->GetSpellModOwner())
2367 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_MULTIPLE_VALUE
, manaMultiplier
);
2369 int32 gain
= int32(new_damage
*manaMultiplier
);
2371 m_caster
->ModifyPower(POWER_MANA
,gain
);
2373 m_caster
->SendEnergizeSpellLog(m_caster
, m_spellInfo
->Id
,gain
,POWER_MANA
);
2377 void Spell::EffectSendEvent(uint32 EffectIndex
)
2380 we do not handle a flag dropping or clicking on flag in battleground by sendevent system
2382 sLog
.outDebug("Spell ScriptStart %u for spellid %u in EffectSendEvent ", m_spellInfo
->EffectMiscValue
[EffectIndex
], m_spellInfo
->Id
);
2383 sWorld
.ScriptsStart(sEventScripts
, m_spellInfo
->EffectMiscValue
[EffectIndex
], m_caster
, focusObject
);
2386 void Spell::EffectPowerBurn(uint32 i
)
2388 if(m_spellInfo
->EffectMiscValue
[i
] < 0 || m_spellInfo
->EffectMiscValue
[i
] >= MAX_POWERS
)
2391 Powers powertype
= Powers(m_spellInfo
->EffectMiscValue
[i
]);
2395 if(!unitTarget
->isAlive())
2397 if(unitTarget
->getPowerType()!=powertype
)
2402 // burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn)
2403 if(m_spellInfo
->ManaCostPercentage
)
2405 uint32 maxdamage
= m_caster
->GetMaxPower(powertype
) * damage
* 2 / 100;
2406 damage
= unitTarget
->GetMaxPower(powertype
) * damage
/ 100;
2407 if(damage
> maxdamage
) damage
= maxdamage
;
2410 int32 curPower
= int32(unitTarget
->GetPower(powertype
));
2412 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
2413 uint32 power
= damage
;
2414 if ( powertype
== POWER_MANA
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
2415 power
-= ((Player
*)unitTarget
)->GetSpellCritDamageReduction(power
);
2417 int32 new_damage
= (curPower
< power
) ? curPower
: power
;
2419 unitTarget
->ModifyPower(powertype
,-new_damage
);
2420 float multiplier
= m_spellInfo
->EffectMultipleValue
[i
];
2422 if(Player
*modOwner
= m_caster
->GetSpellModOwner())
2423 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_MULTIPLE_VALUE
, multiplier
);
2425 new_damage
= int32(new_damage
*multiplier
);
2426 m_damage
+=new_damage
;
2429 void Spell::EffectHeal( uint32
/*i*/ )
2431 if( unitTarget
&& unitTarget
->isAlive() && damage
>= 0)
2433 // Try to get original caster
2434 Unit
*caster
= m_originalCasterGUID
? m_originalCaster
: m_caster
;
2436 // Skip if m_originalCaster not available
2440 int32 addhealth
= damage
;
2442 // Vessel of the Naaru (Vial of the Sunwell trinket)
2443 if (m_spellInfo
->Id
== 45064)
2445 // Amount of heal - depends from stacked Holy Energy
2446 int damageAmount
= 0;
2447 Unit::AuraList
const& mDummyAuras
= m_caster
->GetAurasByType(SPELL_AURA_DUMMY
);
2448 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
2449 if((*i
)->GetId() == 45062)
2450 damageAmount
+=(*i
)->GetModifier()->m_amount
;
2452 m_caster
->RemoveAurasDueToSpell(45062);
2454 addhealth
+= damageAmount
;
2456 // Swiftmend - consumes Regrowth or Rejuvenation
2457 else if (m_spellInfo
->TargetAuraState
== AURA_STATE_SWIFTMEND
&& unitTarget
->HasAuraState(AURA_STATE_SWIFTMEND
))
2459 Unit::AuraList
const& RejorRegr
= unitTarget
->GetAurasByType(SPELL_AURA_PERIODIC_HEAL
);
2460 // find most short by duration
2461 Aura
*targetAura
= NULL
;
2462 for(Unit::AuraList::const_iterator i
= RejorRegr
.begin(); i
!= RejorRegr
.end(); ++i
)
2464 if((*i
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DRUID
2465 && ((*i
)->GetSpellProto()->SpellFamilyFlags
== 0x40 || (*i
)->GetSpellProto()->SpellFamilyFlags
== 0x10) )
2467 if(!targetAura
|| (*i
)->GetAuraDuration() < targetAura
->GetAuraDuration())
2474 sLog
.outError("Target(GUID:" I64FMTD
") has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget
->GetGUID());
2480 if(targetAura
->GetSpellProto()->EffectApplyAuraName
[idx
] == SPELL_AURA_PERIODIC_HEAL
)
2485 int32 tickheal
= caster
->SpellHealingBonus(unitTarget
, targetAura
->GetSpellProto(), targetAura
->GetModifier()->m_amount
, DOT
);
2486 int32 tickcount
= GetSpellDuration(targetAura
->GetSpellProto()) / targetAura
->GetSpellProto()->EffectAmplitude
[idx
];
2487 unitTarget
->RemoveAurasDueToSpell(targetAura
->GetId());
2489 addhealth
+= tickheal
* tickcount
;
2492 addhealth
= caster
->SpellHealingBonus(unitTarget
, m_spellInfo
, addhealth
, HEAL
);
2494 m_healing
+=addhealth
;
2498 void Spell::EffectHealPct( uint32
/*i*/ )
2500 if( unitTarget
&& unitTarget
->isAlive() && damage
>= 0)
2502 // Try to get original caster
2503 Unit
*caster
= m_originalCasterGUID
? m_originalCaster
: m_caster
;
2505 // Skip if m_originalCaster not available
2509 uint32 addhealth
= unitTarget
->GetMaxHealth() * damage
/ 100;
2510 if(Player
* modOwner
= m_caster
->GetSpellModOwner())
2511 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_DAMAGE
, addhealth
, this);
2513 int32 gain
= caster
->DealHeal(unitTarget
, addhealth
, m_spellInfo
);
2514 unitTarget
->getHostilRefManager().threatAssist(m_caster
, float(gain
) * 0.5f
, m_spellInfo
);
2518 void Spell::EffectHealMechanical( uint32
/*i*/ )
2520 // Mechanic creature type should be correctly checked by targetCreatureType field
2521 if( unitTarget
&& unitTarget
->isAlive() && damage
>= 0)
2523 // Try to get original caster
2524 Unit
*caster
= m_originalCasterGUID
? m_originalCaster
: m_caster
;
2526 // Skip if m_originalCaster not available
2530 uint32 addhealth
= caster
->SpellHealingBonus(unitTarget
, m_spellInfo
, uint32(damage
), HEAL
);
2531 caster
->DealHeal(unitTarget
, addhealth
, m_spellInfo
);
2535 void Spell::EffectHealthLeech(uint32 i
)
2539 if(!unitTarget
->isAlive())
2545 sLog
.outDebug("HealthLeech :%i", damage
);
2547 float multiplier
= m_spellInfo
->EffectMultipleValue
[i
];
2549 if(Player
*modOwner
= m_caster
->GetSpellModOwner())
2550 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_MULTIPLE_VALUE
, multiplier
);
2552 int32 new_damage
= int32(damage
*multiplier
);
2553 uint32 curHealth
= unitTarget
->GetHealth();
2554 new_damage
= m_caster
->SpellNonMeleeDamageLog(unitTarget
, m_spellInfo
->Id
, new_damage
, m_IsTriggeredSpell
, true);
2555 if(curHealth
< new_damage
)
2556 new_damage
= curHealth
;
2558 if(m_caster
->isAlive())
2560 new_damage
= m_caster
->SpellHealingBonus(m_caster
, m_spellInfo
, new_damage
, HEAL
);
2561 m_caster
->DealHeal(m_caster
, uint32(new_damage
), m_spellInfo
);
2563 // m_healthLeech+=tmpvalue;
2564 // m_damage+=new_damage;
2567 void Spell::DoCreateItem(uint32 i
, uint32 itemtype
)
2569 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
2572 Player
* player
= (Player
*)unitTarget
;
2574 uint32 newitemid
= itemtype
;
2575 ItemPrototype
const *pProto
= objmgr
.GetItemPrototype( newitemid
);
2578 player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
2584 // TODO: maybe all this can be replaced by using correct calculated `damage` value
2585 if(pProto
->Class
!= ITEM_CLASS_CONSUMABLE
|| m_spellInfo
->SpellFamilyName
!= SPELLFAMILY_MAGE
)
2587 int32 basePoints
= m_currentBasePoints
[i
];
2588 int32 randomPoints
= m_spellInfo
->EffectDieSides
[i
];
2590 num_to_add
= basePoints
+ irand(1, randomPoints
);
2592 num_to_add
= basePoints
+ 1;
2594 else if (pProto
->MaxCount
== 1)
2596 else if(player
->getLevel() >= m_spellInfo
->spellLevel
)
2598 int32 basePoints
= m_currentBasePoints
[i
];
2599 float pointPerLevel
= m_spellInfo
->EffectRealPointsPerLevel
[i
];
2600 num_to_add
= basePoints
+ 1 + uint32((player
->getLevel() - m_spellInfo
->spellLevel
)*pointPerLevel
);
2607 if (num_to_add
> pProto
->GetMaxStackSize())
2608 num_to_add
= pProto
->GetMaxStackSize();
2610 // init items_count to 1, since 1 item will be created regardless of specialization
2612 // the chance to create additional items
2613 float additionalCreateChance
=0.0f
;
2614 // the maximum number of created additional items
2615 uint8 additionalMaxNum
=0;
2616 // get the chance and maximum number for creating extra items
2617 if ( canCreateExtraItems(player
, m_spellInfo
->Id
, additionalCreateChance
, additionalMaxNum
) )
2619 // roll with this chance till we roll not to create or we create the max num
2620 while ( roll_chance_f(additionalCreateChance
) && items_count
<=additionalMaxNum
)
2624 // really will be created more items
2625 num_to_add
*= items_count
;
2627 // can the player store the new item?
2628 ItemPosCountVec dest
;
2629 uint32 no_space
= 0;
2630 uint8 msg
= player
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, newitemid
, num_to_add
, &no_space
);
2631 if( msg
!= EQUIP_ERR_OK
)
2633 // convert to possible store amount
2634 if( msg
== EQUIP_ERR_INVENTORY_FULL
|| msg
== EQUIP_ERR_CANT_CARRY_MORE_OF_THIS
)
2635 num_to_add
-= no_space
;
2638 // if not created by another reason from full inventory or unique items amount limitation
2639 player
->SendEquipError( msg
, NULL
, NULL
);
2646 // create the new item and store it
2647 Item
* pItem
= player
->StoreNewItem( dest
, newitemid
, true, Item::GenerateItemRandomPropertyId(newitemid
));
2649 // was it successful? return error if not
2652 player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
2656 // set the "Crafted by ..." property of the item
2657 if( pItem
->GetProto()->Class
!= ITEM_CLASS_CONSUMABLE
&& pItem
->GetProto()->Class
!= ITEM_CLASS_QUEST
)
2658 pItem
->SetUInt32Value(ITEM_FIELD_CREATOR
,player
->GetGUIDLow());
2660 // send info to the client
2662 player
->SendNewItem(pItem
, num_to_add
, true, true);
2664 // we succeeded in creating at least one item, so a levelup is possible
2665 player
->UpdateCraftSkill(m_spellInfo
->Id
);
2668 // for battleground marks send by mail if not add all expected
2671 BattleGroundTypeId bgType
;
2672 switch(m_spellInfo
->Id
)
2674 case SPELL_AV_MARK_WINNER
:
2675 case SPELL_AV_MARK_LOSER
:
2676 bgType
= BATTLEGROUND_AV
;
2678 case SPELL_WS_MARK_WINNER
:
2679 case SPELL_WS_MARK_LOSER
:
2680 bgType
= BATTLEGROUND_WS
;
2682 case SPELL_AB_MARK_WINNER
:
2683 case SPELL_AB_MARK_LOSER
:
2684 bgType
= BATTLEGROUND_AB
;
2690 if(BattleGround
* bg
= sBattleGroundMgr
.GetBattleGroundTemplate(bgType
))
2691 bg
->SendRewardMarkByMail(player
,newitemid
,no_space
);
2695 void Spell::EffectCreateItem(uint32 i
)
2697 DoCreateItem(i
,m_spellInfo
->EffectItemType
[i
]);
2700 void Spell::EffectCreateItem2(uint32 i
)
2702 // special case: generate using spell_loot_template
2703 if(!m_spellInfo
->EffectItemType
[i
])
2705 if(m_caster
->GetTypeId()!=TYPEID_PLAYER
)
2708 // create some random items
2709 ((Player
*)m_caster
)->AutoStoreLoot(m_spellInfo
->Id
,LootTemplates_Spell
);
2712 DoCreateItem(i
,m_spellInfo
->EffectItemType
[i
]);
2715 void Spell::EffectPersistentAA(uint32 i
)
2717 float radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
2719 if(Player
* modOwner
= m_caster
->GetSpellModOwner())
2720 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_RADIUS
, radius
);
2722 int32 duration
= GetSpellDuration(m_spellInfo
);
2723 DynamicObject
* dynObj
= new DynamicObject
;
2724 if(!dynObj
->Create(objmgr
.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT
), m_caster
, m_spellInfo
->Id
, i
, m_targets
.m_destX
, m_targets
.m_destY
, m_targets
.m_destZ
, duration
, radius
))
2729 dynObj
->SetUInt32Value(OBJECT_FIELD_TYPE
, 65);
2730 dynObj
->SetUInt32Value(GAMEOBJECT_DISPLAYID
, 368003);
2731 dynObj
->SetUInt32Value(DYNAMICOBJECT_BYTES
, 0x01eeeeee);
2732 m_caster
->AddDynObject(dynObj
);
2733 dynObj
->GetMap()->Add(dynObj
);
2736 void Spell::EffectEnergize(uint32 i
)
2740 if(!unitTarget
->isAlive())
2743 if(m_spellInfo
->EffectMiscValue
[i
] < 0 || m_spellInfo
->EffectMiscValue
[i
] >= MAX_POWERS
)
2746 Powers power
= Powers(m_spellInfo
->EffectMiscValue
[i
]);
2748 // Some level depends spells
2751 switch (m_spellInfo
->Id
)
2755 level_diff
= m_caster
->getLevel() - 40;
2760 level_diff
= m_caster
->getLevel() - 60;
2765 level_diff
= m_caster
->getLevel() - 60;
2773 damage
-= multiplier
* level_diff
;
2778 if(unitTarget
->GetMaxPower(power
) == 0)
2781 unitTarget
->ModifyPower(power
,damage
);
2782 m_caster
->SendEnergizeSpellLog(unitTarget
, m_spellInfo
->Id
, damage
, power
);
2784 // Mad Alchemist's Potion
2785 if (m_spellInfo
->Id
== 45051)
2787 // find elixirs on target
2788 uint32 elixir_mask
= 0;
2789 Unit::AuraMap
& Auras
= unitTarget
->GetAuras();
2790 for(Unit::AuraMap::iterator itr
= Auras
.begin(); itr
!= Auras
.end(); ++itr
)
2792 uint32 spell_id
= itr
->second
->GetId();
2793 if(uint32 mask
= spellmgr
.GetSpellElixirMask(spell_id
))
2794 elixir_mask
|= mask
;
2797 // get available elixir mask any not active type from battle/guardian (and flask if no any)
2798 elixir_mask
= (elixir_mask
& ELIXIR_FLASK_MASK
) ^ ELIXIR_FLASK_MASK
;
2800 // get all available elixirs by mask and spell level
2801 std::vector
<uint32
> elixirs
;
2802 SpellElixirMap
const& m_spellElixirs
= spellmgr
.GetSpellElixirMap();
2803 for(SpellElixirMap::const_iterator itr
= m_spellElixirs
.begin(); itr
!= m_spellElixirs
.end(); ++itr
)
2805 if (itr
->second
& elixir_mask
)
2807 if (itr
->second
& (ELIXIR_UNSTABLE_MASK
| ELIXIR_SHATTRATH_MASK
))
2810 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
2811 if (spellInfo
&& (spellInfo
->spellLevel
< m_spellInfo
->spellLevel
|| spellInfo
->spellLevel
> unitTarget
->getLevel()))
2814 elixirs
.push_back(itr
->first
);
2818 if (!elixirs
.empty())
2820 // cast random elixir on target
2821 uint32 rand_spell
= urand(0,elixirs
.size()-1);
2822 m_caster
->CastSpell(unitTarget
,elixirs
[rand_spell
],true,m_CastItem
);
2827 void Spell::EffectEnergisePct(uint32 i
)
2831 if(!unitTarget
->isAlive())
2834 if(m_spellInfo
->EffectMiscValue
[i
] < 0 || m_spellInfo
->EffectMiscValue
[i
] >= MAX_POWERS
)
2837 Powers power
= Powers(m_spellInfo
->EffectMiscValue
[i
]);
2839 uint32 maxPower
= unitTarget
->GetMaxPower(power
);
2843 uint32 gain
= damage
* maxPower
/ 100;
2844 unitTarget
->ModifyPower(power
, gain
);
2845 m_caster
->SendEnergizeSpellLog(unitTarget
, m_spellInfo
->Id
, gain
, power
);
2848 void Spell::SendLoot(uint64 guid
, LootType loottype
)
2850 Player
* player
= (Player
*)m_caster
;
2856 if (Script
->GOHello(player
, gameObjTarget
))
2859 switch (gameObjTarget
->GetGoType())
2861 case GAMEOBJECT_TYPE_DOOR
:
2862 case GAMEOBJECT_TYPE_BUTTON
:
2863 gameObjTarget
->UseDoorOrButton();
2864 sWorld
.ScriptsStart(sGameObjectScripts
, gameObjTarget
->GetDBTableGUIDLow(), player
, gameObjTarget
);
2867 case GAMEOBJECT_TYPE_QUESTGIVER
:
2868 // start or end quest
2869 player
->PrepareQuestMenu(guid
);
2870 player
->SendPreparedQuest(guid
);
2873 case GAMEOBJECT_TYPE_SPELL_FOCUS
:
2874 // triggering linked GO
2875 if(uint32 trapEntry
= gameObjTarget
->GetGOInfo()->spellFocus
.linkedTrapId
)
2876 gameObjTarget
->TriggeringLinkedGameObject(trapEntry
,m_caster
);
2879 case GAMEOBJECT_TYPE_GOOBER
:
2880 // goober_scripts can be triggered if the player don't have the quest
2881 if (gameObjTarget
->GetGOInfo()->goober
.eventId
)
2883 sLog
.outDebug("Goober ScriptStart id %u for GO %u", gameObjTarget
->GetGOInfo()->goober
.eventId
,gameObjTarget
->GetDBTableGUIDLow());
2884 sWorld
.ScriptsStart(sEventScripts
, gameObjTarget
->GetGOInfo()->goober
.eventId
, player
, gameObjTarget
);
2887 // cast goober spell
2888 if (gameObjTarget
->GetGOInfo()->goober
.questId
)
2889 ///Quest require to be active for GO using
2890 if(player
->GetQuestStatus(gameObjTarget
->GetGOInfo()->goober
.questId
) != QUEST_STATUS_INCOMPLETE
)
2893 gameObjTarget
->AddUniqueUse(player
);
2894 gameObjTarget
->SetLootState(GO_JUST_DEACTIVATED
);
2896 //TODO? Objective counting called without spell check but with quest objective check
2897 // if send spell id then this line will duplicate to spell casting call (double counting)
2898 // So we or have this line and not required in quest_template have reqSpellIdN
2899 // or must remove this line and required in DB have data in quest_template have reqSpellIdN for all quest using cases.
2900 player
->CastedCreatureOrGO(gameObjTarget
->GetEntry(), gameObjTarget
->GetGUID(), 0);
2902 // triggering linked GO
2903 if(uint32 trapEntry
= gameObjTarget
->GetGOInfo()->goober
.linkedTrapId
)
2904 gameObjTarget
->TriggeringLinkedGameObject(trapEntry
,m_caster
);
2908 case GAMEOBJECT_TYPE_CHEST
:
2909 // TODO: possible must be moved to loot release (in different from linked triggering)
2910 if (gameObjTarget
->GetGOInfo()->chest
.eventId
)
2912 sLog
.outDebug("Chest ScriptStart id %u for GO %u", gameObjTarget
->GetGOInfo()->chest
.eventId
,gameObjTarget
->GetDBTableGUIDLow());
2913 sWorld
.ScriptsStart(sEventScripts
, gameObjTarget
->GetGOInfo()->chest
.eventId
, player
, gameObjTarget
);
2916 // triggering linked GO
2917 if(uint32 trapEntry
= gameObjTarget
->GetGOInfo()->chest
.linkedTrapId
)
2918 gameObjTarget
->TriggeringLinkedGameObject(trapEntry
,m_caster
);
2920 // Don't return, let loots been taken
2925 player
->SendLoot(guid
, loottype
);
2928 void Spell::EffectOpenLock(uint32 effIndex
)
2930 if(!m_caster
|| m_caster
->GetTypeId() != TYPEID_PLAYER
)
2932 sLog
.outDebug( "WORLD: Open Lock - No Player Caster!");
2936 Player
* player
= (Player
*)m_caster
;
2944 GameObjectInfo
const* goInfo
= gameObjTarget
->GetGOInfo();
2945 // Arathi Basin banner opening !
2946 if( goInfo
->type
== GAMEOBJECT_TYPE_BUTTON
&& goInfo
->button
.noDamageImmune
||
2947 goInfo
->type
== GAMEOBJECT_TYPE_GOOBER
&& goInfo
->goober
.losOK
)
2949 //CanUseBattleGroundObject() already called in CheckCast()
2950 // in battleground check
2951 if(BattleGround
*bg
= player
->GetBattleGround())
2953 // check if it's correct bg
2954 if(bg
&& bg
->GetTypeID() == BATTLEGROUND_AB
)
2955 bg
->EventPlayerClickedOnFlag(player
, gameObjTarget
);
2959 else if (goInfo
->type
== GAMEOBJECT_TYPE_FLAGSTAND
)
2961 //CanUseBattleGroundObject() already called in CheckCast()
2962 // in battleground check
2963 if(BattleGround
*bg
= player
->GetBattleGround())
2965 if(bg
->GetTypeID() == BATTLEGROUND_EY
)
2966 bg
->EventPlayerClickedOnFlag(player
, gameObjTarget
);
2970 lockId
= gameObjTarget
->GetLockId();
2971 guid
= gameObjTarget
->GetGUID();
2975 lockId
= itemTarget
->GetProto()->LockID
;
2976 guid
= itemTarget
->GetGUID();
2980 sLog
.outDebug( "WORLD: Open Lock - No GameObject/Item Target!");
2984 SkillType skillId
= SKILL_NONE
;
2985 int32 reqSkillValue
= 0;
2988 SpellCastResult res
= CanOpenLock(effIndex
,lockId
,skillId
,reqSkillValue
,skillValue
);
2989 if(res
!= SPELL_CAST_OK
)
2991 SendCastResult(res
);
2995 SendLoot(guid
, LOOT_SKINNING
);
2997 // not allow use skill grow at item base open
2998 if(!m_CastItem
&& skillId
!= SKILL_NONE
)
3000 // update skill if really known
3001 if(uint32 pureSkillValue
= player
->GetPureSkillValue(skillId
))
3005 // Allow one skill-up until respawned
3006 if ( !gameObjTarget
->IsInSkillupList( player
->GetGUIDLow() ) &&
3007 player
->UpdateGatherSkill(skillId
, pureSkillValue
, reqSkillValue
) )
3008 gameObjTarget
->AddToSkillupList( player
->GetGUIDLow() );
3013 player
->UpdateGatherSkill(skillId
, pureSkillValue
, reqSkillValue
);
3019 void Spell::EffectSummonChangeItem(uint32 i
)
3021 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
3024 Player
*player
= (Player
*)m_caster
;
3026 // applied only to using item
3030 // ... only to item in own inventory/bank/equip_slot
3031 if(m_CastItem
->GetOwnerGUID()!=player
->GetGUID())
3034 uint32 newitemid
= m_spellInfo
->EffectItemType
[i
];
3038 uint16 pos
= m_CastItem
->GetPos();
3040 Item
*pNewItem
= Item::CreateItem( newitemid
, 1, player
);
3044 for(uint8 j
= PERM_ENCHANTMENT_SLOT
; j
<=TEMP_ENCHANTMENT_SLOT
; ++j
)
3046 if(m_CastItem
->GetEnchantmentId(EnchantmentSlot(j
)))
3047 pNewItem
->SetEnchantment(EnchantmentSlot(j
), m_CastItem
->GetEnchantmentId(EnchantmentSlot(j
)), m_CastItem
->GetEnchantmentDuration(EnchantmentSlot(j
)), m_CastItem
->GetEnchantmentCharges(EnchantmentSlot(j
)));
3050 if(m_CastItem
->GetUInt32Value(ITEM_FIELD_DURABILITY
) < m_CastItem
->GetUInt32Value(ITEM_FIELD_MAXDURABILITY
))
3052 double loosePercent
= 1 - m_CastItem
->GetUInt32Value(ITEM_FIELD_DURABILITY
) / double(m_CastItem
->GetUInt32Value(ITEM_FIELD_MAXDURABILITY
));
3053 player
->DurabilityLoss(pNewItem
, loosePercent
);
3056 if( player
->IsInventoryPos( pos
) )
3058 ItemPosCountVec dest
;
3059 uint8 msg
= player
->CanStoreItem( m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(), dest
, pNewItem
, true );
3060 if( msg
== EQUIP_ERR_OK
)
3062 player
->DestroyItem(m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(),true);
3064 // prevent crash at access and unexpected charges counting with item update queue corrupt
3065 if(m_CastItem
==m_targets
.getItemTarget())
3066 m_targets
.setItemTarget(NULL
);
3070 player
->StoreItem( dest
, pNewItem
, true);
3074 else if( player
->IsBankPos ( pos
) )
3076 ItemPosCountVec dest
;
3077 uint8 msg
= player
->CanBankItem( m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(), dest
, pNewItem
, true );
3078 if( msg
== EQUIP_ERR_OK
)
3080 player
->DestroyItem(m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(),true);
3082 // prevent crash at access and unexpected charges counting with item update queue corrupt
3083 if(m_CastItem
==m_targets
.getItemTarget())
3084 m_targets
.setItemTarget(NULL
);
3088 player
->BankItem( dest
, pNewItem
, true);
3092 else if( player
->IsEquipmentPos ( pos
) )
3095 uint8 msg
= player
->CanEquipItem( m_CastItem
->GetSlot(), dest
, pNewItem
, true );
3096 if( msg
== EQUIP_ERR_OK
)
3098 player
->DestroyItem(m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(),true);
3100 // prevent crash at access and unexpected charges counting with item update queue corrupt
3101 if(m_CastItem
==m_targets
.getItemTarget())
3102 m_targets
.setItemTarget(NULL
);
3106 player
->EquipItem( dest
, pNewItem
, true);
3107 player
->AutoUnequipOffhandIfNeed();
3116 void Spell::EffectOpenSecretSafe(uint32 i
)
3118 EffectOpenLock(i
); //no difference for now
3121 void Spell::EffectProficiency(uint32
/*i*/)
3123 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3125 Player
*p_target
= (Player
*)unitTarget
;
3127 uint32 subClassMask
= m_spellInfo
->EquippedItemSubClassMask
;
3128 if(m_spellInfo
->EquippedItemClass
== 2 && !(p_target
->GetWeaponProficiency() & subClassMask
))
3130 p_target
->AddWeaponProficiency(subClassMask
);
3131 p_target
->SendProficiency(uint8(0x02),p_target
->GetWeaponProficiency());
3133 if(m_spellInfo
->EquippedItemClass
== 4 && !(p_target
->GetArmorProficiency() & subClassMask
))
3135 p_target
->AddArmorProficiency(subClassMask
);
3136 p_target
->SendProficiency(uint8(0x04),p_target
->GetArmorProficiency());
3140 void Spell::EffectApplyAreaAura(uint32 i
)
3144 if(!unitTarget
->isAlive())
3147 AreaAura
* Aur
= new AreaAura(m_spellInfo
, i
, &m_currentBasePoints
[i
], unitTarget
, m_caster
, m_CastItem
);
3148 unitTarget
->AddAura(Aur
);
3151 void Spell::EffectSummonType(uint32 i
)
3153 switch(m_spellInfo
->EffectMiscValueB
[i
])
3155 case SUMMON_TYPE_GUARDIAN
:
3156 case SUMMON_TYPE_POSESSED
:
3157 case SUMMON_TYPE_POSESSED2
:
3158 case SUMMON_TYPE_FORCE_OF_NATURE
:
3159 case SUMMON_TYPE_GUARDIAN2
:
3160 EffectSummonGuardian(i
);
3162 case SUMMON_TYPE_WILD
:
3163 EffectSummonWild(i
);
3165 case SUMMON_TYPE_DEMON
:
3166 EffectSummonDemon(i
);
3168 case SUMMON_TYPE_SUMMON
:
3171 case SUMMON_TYPE_CRITTER
:
3172 case SUMMON_TYPE_CRITTER2
:
3173 case SUMMON_TYPE_CRITTER3
:
3174 EffectSummonCritter(i
);
3176 case SUMMON_TYPE_TOTEM_SLOT1
:
3177 case SUMMON_TYPE_TOTEM_SLOT2
:
3178 case SUMMON_TYPE_TOTEM_SLOT3
:
3179 case SUMMON_TYPE_TOTEM_SLOT4
:
3180 case SUMMON_TYPE_TOTEM
:
3181 EffectSummonTotem(i
);
3183 case SUMMON_TYPE_UNKNOWN1
:
3184 case SUMMON_TYPE_UNKNOWN2
:
3185 case SUMMON_TYPE_UNKNOWN3
:
3186 case SUMMON_TYPE_UNKNOWN4
:
3187 case SUMMON_TYPE_UNKNOWN5
:
3190 sLog
.outError("EffectSummonType: Unhandled summon type %u", m_spellInfo
->EffectMiscValueB
[i
]);
3195 void Spell::EffectSummon(uint32 i
)
3197 if(m_caster
->GetPetGUID())
3202 uint32 pet_entry
= m_spellInfo
->EffectMiscValue
[i
];
3205 uint32 level
= m_caster
->getLevel();
3206 Pet
* spawnCreature
= new Pet(SUMMON_PET
);
3208 if(m_caster
->GetTypeId()==TYPEID_PLAYER
&& spawnCreature
->LoadPetFromDB((Player
*)m_caster
,pet_entry
))
3210 // set timer for unsummon
3211 int32 duration
= GetSpellDuration(m_spellInfo
);
3213 spawnCreature
->SetDuration(duration
);
3218 Map
*map
= m_caster
->GetMap();
3219 uint32 pet_number
= objmgr
.GeneratePetNumber();
3220 if(!spawnCreature
->Create(objmgr
.GenerateLowGuid(HIGHGUID_PET
),map
,m_caster
->GetPhaseMask(),
3221 m_spellInfo
->EffectMiscValue
[i
], pet_number
))
3223 sLog
.outErrorDb("Spell::EffectSummon: no such creature entry %u",m_spellInfo
->EffectMiscValue
[i
]);
3224 delete spawnCreature
;
3228 // Summon in dest location
3230 if(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
3232 x
= m_targets
.m_destX
;
3233 y
= m_targets
.m_destY
;
3234 z
= m_targets
.m_destZ
;
3237 m_caster
->GetClosePoint(x
,y
,z
,spawnCreature
->GetObjectSize());
3239 spawnCreature
->Relocate(x
,y
,z
,-m_caster
->GetOrientation());
3241 if(!spawnCreature
->IsPositionValid())
3243 sLog
.outError("Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
3244 spawnCreature
->GetGUIDLow(), spawnCreature
->GetEntry(), spawnCreature
->GetPositionX(), spawnCreature
->GetPositionY());
3245 delete spawnCreature
;
3249 // set timer for unsummon
3250 int32 duration
= GetSpellDuration(m_spellInfo
);
3252 spawnCreature
->SetDuration(duration
);
3254 spawnCreature
->SetOwnerGUID(m_caster
->GetGUID());
3255 spawnCreature
->SetUInt32Value(UNIT_NPC_FLAGS
, 0);
3256 spawnCreature
->setPowerType(POWER_MANA
);
3257 spawnCreature
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
, m_caster
->getFaction());
3258 spawnCreature
->SetUInt32Value(UNIT_FIELD_FLAGS
, 0);
3259 spawnCreature
->SetUInt32Value(UNIT_FIELD_BYTES_0
, 2048);
3260 spawnCreature
->SetUInt32Value(UNIT_FIELD_BYTES_1
, 0);
3261 spawnCreature
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, 0);
3262 spawnCreature
->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE
, 0);
3263 spawnCreature
->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP
, 1000);
3264 spawnCreature
->SetCreatorGUID(m_caster
->GetGUID());
3265 spawnCreature
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
3267 spawnCreature
->InitStatsForLevel(level
);
3269 spawnCreature
->GetCharmInfo()->SetPetNumber(pet_number
, false);
3271 spawnCreature
->AIM_Initialize();
3272 spawnCreature
->InitPetCreateSpells();
3273 spawnCreature
->SetHealth(spawnCreature
->GetMaxHealth());
3274 spawnCreature
->SetPower(POWER_MANA
, spawnCreature
->GetMaxPower(POWER_MANA
));
3276 std::string name
= m_caster
->GetName();
3277 name
.append(petTypeSuffix
[spawnCreature
->getPetType()]);
3278 spawnCreature
->SetName( name
);
3280 map
->Add((Creature
*)spawnCreature
);
3282 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
3284 m_caster
->SetPet(spawnCreature
);
3285 spawnCreature
->GetCharmInfo()->SetReactState( REACT_DEFENSIVE
);
3286 spawnCreature
->SavePetToDB(PET_SAVE_AS_CURRENT
);
3287 ((Player
*)m_caster
)->PetSpellInitialize();
3291 void Spell::EffectLearnSpell(uint32 i
)
3296 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3298 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
3299 EffectLearnPetSpell(i
);
3304 Player
*player
= (Player
*)unitTarget
;
3306 uint32 spellToLearn
= ((m_spellInfo
->Id
==SPELL_ID_GENERIC_LEARN
) || (m_spellInfo
->Id
==SPELL_ID_GENERIC_LEARN_PET
)) ? damage
: m_spellInfo
->EffectTriggerSpell
[i
];
3307 player
->learnSpell(spellToLearn
,false);
3309 sLog
.outDebug( "Spell: Player %u have learned spell %u from NpcGUID=%u", player
->GetGUIDLow(), spellToLearn
, m_caster
->GetGUIDLow() );
3312 void Spell::EffectDispel(uint32 i
)
3317 // Fill possible dispell list
3318 std::vector
<Aura
*> dispel_list
;
3320 // Create dispel mask by dispel type
3321 uint32 dispel_type
= m_spellInfo
->EffectMiscValue
[i
];
3322 uint32 dispelMask
= GetDispellMask( DispelType(dispel_type
) );
3323 Unit::AuraMap
const& auras
= unitTarget
->GetAuras();
3324 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3326 Aura
*aur
= (*itr
).second
;
3327 if (aur
&& (1<<aur
->GetSpellProto()->Dispel
) & dispelMask
)
3329 if(aur
->GetSpellProto()->Dispel
== DISPEL_MAGIC
)
3331 bool positive
= true;
3332 if (!aur
->IsPositive())
3335 positive
= (aur
->GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_NEGATIVE
)==0;
3337 // do not remove positive auras if friendly target
3338 // negative auras if non-friendly target
3339 if(positive
== unitTarget
->IsFriendlyTo(m_caster
))
3342 // Add aura to dispel list
3343 dispel_list
.push_back(aur
);
3346 // Ok if exist some buffs for dispel try dispel it
3347 if (!dispel_list
.empty())
3349 std::list
< std::pair
<uint32
,uint64
> > success_list
;// (spell_id,casterGuid)
3350 std::list
< uint32
> fail_list
; // spell_id
3351 int32 list_size
= dispel_list
.size();
3352 // Dispell N = damage buffs (or while exist buffs for dispel)
3353 for (int32 count
=0; count
< damage
&& list_size
> 0; ++count
)
3355 // Random select buff for dispel
3356 Aura
*aur
= dispel_list
[urand(0, list_size
-1)];
3358 SpellEntry
const* spellInfo
= aur
->GetSpellProto();
3359 // Base dispel chance
3360 // TODO: possible chance depend from spell level??
3361 int32 miss_chance
= 0;
3362 // Apply dispel mod from aura caster
3363 if (Unit
*caster
= aur
->GetCaster())
3365 if ( Player
* modOwner
= caster
->GetSpellModOwner() )
3366 modOwner
->ApplySpellMod(spellInfo
->Id
, SPELLMOD_RESIST_DISPEL_CHANCE
, miss_chance
, this);
3369 if (roll_chance_i(miss_chance
))
3370 fail_list
.push_back(aur
->GetId());
3372 success_list
.push_back(std::pair
<uint32
,uint64
>(aur
->GetId(),aur
->GetCasterGUID()));
3373 // Remove buff from list for prevent doubles
3374 for (std::vector
<Aura
*>::iterator j
= dispel_list
.begin(); j
!= dispel_list
.end(); )
3376 Aura
*dispeled
= *j
;
3377 if (dispeled
->GetId() == aur
->GetId() && dispeled
->GetCasterGUID() == aur
->GetCasterGUID())
3379 j
= dispel_list
.erase(j
);
3386 // Send success log and really remove auras
3387 if (!success_list
.empty())
3389 int32 count
= success_list
.size();
3390 WorldPacket
data(SMSG_SPELLDISPELLOG
, 8+8+4+1+4+count
*5);
3391 data
.append(unitTarget
->GetPackGUID()); // Victim GUID
3392 data
.append(m_caster
->GetPackGUID()); // Caster GUID
3393 data
<< uint32(m_spellInfo
->Id
); // Dispell spell id
3394 data
<< uint8(0); // not used
3395 data
<< uint32(count
); // count
3396 for (std::list
<std::pair
<uint32
,uint64
> >::iterator j
= success_list
.begin(); j
!= success_list
.end(); ++j
)
3398 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(j
->first
);
3399 data
<< uint32(spellInfo
->Id
); // Spell Id
3400 data
<< uint8(0); // 0 - dispeled !=0 cleansed
3401 unitTarget
->RemoveAurasDueToSpellByDispel(spellInfo
->Id
, j
->second
, m_caster
);
3403 m_caster
->SendMessageToSet(&data
, true);
3407 if (m_spellInfo
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& m_spellInfo
->Category
== SPELLCATEGORY_DEVOUR_MAGIC
)
3409 uint32 heal_spell
= 0;
3410 switch (m_spellInfo
->Id
)
3412 case 19505: heal_spell
= 19658; break;
3413 case 19731: heal_spell
= 19732; break;
3414 case 19734: heal_spell
= 19733; break;
3415 case 19736: heal_spell
= 19735; break;
3416 case 27276: heal_spell
= 27278; break;
3417 case 27277: heal_spell
= 27279; break;
3419 sLog
.outDebug("Spell for Devour Magic %d not handled in Spell::EffectDispel", m_spellInfo
->Id
);
3423 m_caster
->CastSpell(m_caster
, heal_spell
, true);
3426 // Send fail log to client
3427 if (!fail_list
.empty())
3429 // Failed to dispell
3430 WorldPacket
data(SMSG_DISPEL_FAILED
, 8+8+4+4*fail_list
.size());
3431 data
<< uint64(m_caster
->GetGUID()); // Caster GUID
3432 data
<< uint64(unitTarget
->GetGUID()); // Victim GUID
3433 data
<< uint32(m_spellInfo
->Id
); // Dispell spell id
3434 for (std::list
< uint32
>::iterator j
= fail_list
.begin(); j
!= fail_list
.end(); ++j
)
3435 data
<< uint32(*j
); // Spell Id
3436 m_caster
->SendMessageToSet(&data
, true);
3441 void Spell::EffectDualWield(uint32
/*i*/)
3443 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
3444 ((Player
*)unitTarget
)->SetCanDualWield(true);
3447 void Spell::EffectPull(uint32
/*i*/)
3449 // TODO: create a proper pull towards distract spell center for distract
3450 sLog
.outDebug("WORLD: Spell Effect DUMMY");
3453 void Spell::EffectDistract(uint32
/*i*/)
3455 // Check for possible target
3456 if (!unitTarget
|| unitTarget
->isInCombat())
3459 // target must be OK to do this
3460 if( unitTarget
->hasUnitState(UNIT_STAT_CONFUSED
| UNIT_STAT_STUNNED
| UNIT_STAT_FLEEING
) )
3463 float angle
= unitTarget
->GetAngle(m_targets
.m_destX
, m_targets
.m_destY
);
3465 if ( unitTarget
->GetTypeId() == TYPEID_PLAYER
)
3467 // For players just turn them
3469 ((Player
*)unitTarget
)->BuildTeleportAckMsg(&data
, unitTarget
->GetPositionX(), unitTarget
->GetPositionY(), unitTarget
->GetPositionZ(), angle
);
3470 ((Player
*)unitTarget
)->GetSession()->SendPacket( &data
);
3471 ((Player
*)unitTarget
)->SetPosition(unitTarget
->GetPositionX(), unitTarget
->GetPositionY(), unitTarget
->GetPositionZ(), angle
, false);
3475 // Set creature Distracted, Stop it, And turn it
3476 unitTarget
->SetOrientation(angle
);
3477 unitTarget
->StopMoving();
3478 unitTarget
->GetMotionMaster()->MoveDistract(damage
*IN_MILISECONDS
);
3482 void Spell::EffectPickPocket(uint32
/*i*/)
3484 if( m_caster
->GetTypeId() != TYPEID_PLAYER
)
3487 // victim must be creature and attackable
3488 if( !unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
|| m_caster
->IsFriendlyTo(unitTarget
) )
3491 // victim have to be alive and humanoid or undead
3492 if( unitTarget
->isAlive() && (unitTarget
->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD
) != 0)
3494 int32 chance
= 10 + int32(m_caster
->getLevel()) - int32(unitTarget
->getLevel());
3496 if (chance
> irand(0, 19))
3498 // Stealing successful
3499 //sLog.outDebug("Sending loot from pickpocket");
3500 ((Player
*)m_caster
)->SendLoot(unitTarget
->GetGUID(),LOOT_PICKPOCKETING
);
3504 // Reveal action + get attack
3505 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH
);
3506 if (((Creature
*)unitTarget
)->AI())
3507 ((Creature
*)unitTarget
)->AI()->AttackedBy(m_caster
);
3512 void Spell::EffectAddFarsight(uint32 i
)
3514 float radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
3515 int32 duration
= GetSpellDuration(m_spellInfo
);
3516 DynamicObject
* dynObj
= new DynamicObject
;
3517 if(!dynObj
->Create(objmgr
.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT
), m_caster
, m_spellInfo
->Id
, i
, m_targets
.m_destX
, m_targets
.m_destY
, m_targets
.m_destZ
, duration
, radius
))
3522 dynObj
->SetUInt32Value(OBJECT_FIELD_TYPE
, 65);
3523 dynObj
->SetUInt32Value(DYNAMICOBJECT_BYTES
, 0x80000002);
3524 m_caster
->AddDynObject(dynObj
);
3525 dynObj
->GetMap()->Add(dynObj
);
3526 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
3527 ((Player
*)m_caster
)->SetFarSightGUID(dynObj
->GetGUID());
3530 void Spell::EffectSummonWild(uint32 i
)
3532 uint32 creature_entry
= m_spellInfo
->EffectMiscValue
[i
];
3536 uint32 level
= m_caster
->getLevel();
3538 // level of creature summoned using engineering item based at engineering skill level
3539 if(m_caster
->GetTypeId()==TYPEID_PLAYER
&& m_CastItem
)
3541 ItemPrototype
const *proto
= m_CastItem
->GetProto();
3542 if(proto
&& proto
->RequiredSkill
== SKILL_ENGINERING
)
3544 uint16 skill202
= ((Player
*)m_caster
)->GetSkillValue(SKILL_ENGINERING
);
3552 // select center of summon position
3553 float center_x
= m_targets
.m_destX
;
3554 float center_y
= m_targets
.m_destY
;
3555 float center_z
= m_targets
.m_destZ
;
3557 float radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
3559 int32 amount
= damage
> 0 ? damage
: 1;
3561 for(int32 count
= 0; count
< amount
; ++count
)
3564 // If dest location if present
3565 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
3567 // Summon 1 unit in dest location
3570 px
= m_targets
.m_destX
;
3571 py
= m_targets
.m_destY
;
3572 pz
= m_targets
.m_destZ
;
3574 // Summon in random point all other units if location present
3576 m_caster
->GetRandomPoint(center_x
,center_y
,center_z
,radius
,px
,py
,pz
);
3578 // Summon if dest location not present near caster
3580 m_caster
->GetClosePoint(px
,py
,pz
,3.0f
);
3582 int32 duration
= GetSpellDuration(m_spellInfo
);
3584 TempSummonType summonType
= (duration
== 0) ? TEMPSUMMON_DEAD_DESPAWN
: TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
;
3586 m_caster
->SummonCreature(creature_entry
,px
,py
,pz
,m_caster
->GetOrientation(),summonType
,duration
);
3590 void Spell::EffectSummonGuardian(uint32 i
)
3592 uint32 pet_entry
= m_spellInfo
->EffectMiscValue
[i
];
3596 // Jewelery statue case (totem like)
3597 if(m_spellInfo
->SpellIconID
==2056)
3599 EffectSummonTotem(i
);
3603 // set timer for unsummon
3604 int32 duration
= GetSpellDuration(m_spellInfo
);
3606 // Search old Guardian only for players (if casted spell not have duration or cooldown)
3607 // FIXME: some guardians have control spell applied and controlled by player and anyway player can't summon in this time
3608 // so this code hack in fact
3609 if( m_caster
->GetTypeId() == TYPEID_PLAYER
&& (duration
<= 0 || GetSpellRecoveryTime(m_spellInfo
)==0) )
3610 if(((Player
*)m_caster
)->HasGuardianWithEntry(pet_entry
))
3611 return; // find old guardian, ignore summon
3613 // in another case summon new
3614 uint32 level
= m_caster
->getLevel();
3616 // level of pet summoned using engineering item based at engineering skill level
3617 if(m_caster
->GetTypeId()==TYPEID_PLAYER
&& m_CastItem
)
3619 ItemPrototype
const *proto
= m_CastItem
->GetProto();
3620 if(proto
&& proto
->RequiredSkill
== SKILL_ENGINERING
)
3622 uint16 skill202
= ((Player
*)m_caster
)->GetSkillValue(SKILL_ENGINERING
);
3630 // select center of summon position
3631 float center_x
= m_targets
.m_destX
;
3632 float center_y
= m_targets
.m_destY
;
3633 float center_z
= m_targets
.m_destZ
;
3635 float radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
3637 int32 amount
= damage
> 0 ? damage
: 1;
3639 for(int32 count
= 0; count
< amount
; ++count
)
3641 Pet
* spawnCreature
= new Pet(GUARDIAN_PET
);
3643 Map
*map
= m_caster
->GetMap();
3644 uint32 pet_number
= objmgr
.GeneratePetNumber();
3645 if(!spawnCreature
->Create(objmgr
.GenerateLowGuid(HIGHGUID_PET
), map
,m_caster
->GetPhaseMask(),
3646 m_spellInfo
->EffectMiscValue
[i
], pet_number
))
3648 sLog
.outError("no such creature entry %u",m_spellInfo
->EffectMiscValue
[i
]);
3649 delete spawnCreature
;
3654 // If dest location if present
3655 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
3657 // Summon 1 unit in dest location
3660 px
= m_targets
.m_destX
;
3661 py
= m_targets
.m_destY
;
3662 pz
= m_targets
.m_destZ
;
3664 // Summon in random point all other units if location present
3666 m_caster
->GetRandomPoint(center_x
,center_y
,center_z
,radius
,px
,py
,pz
);
3668 // Summon if dest location not present near caster
3670 m_caster
->GetClosePoint(px
,py
,pz
,spawnCreature
->GetObjectSize());
3672 spawnCreature
->Relocate(px
,py
,pz
,m_caster
->GetOrientation());
3674 if(!spawnCreature
->IsPositionValid())
3676 sLog
.outError("Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)",
3677 spawnCreature
->GetGUIDLow(), spawnCreature
->GetEntry(), spawnCreature
->GetPositionX(), spawnCreature
->GetPositionY());
3678 delete spawnCreature
;
3683 spawnCreature
->SetDuration(duration
);
3685 spawnCreature
->SetOwnerGUID(m_caster
->GetGUID());
3686 spawnCreature
->setPowerType(POWER_MANA
);
3687 spawnCreature
->SetUInt32Value(UNIT_NPC_FLAGS
, 0);
3688 spawnCreature
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,m_caster
->getFaction());
3689 spawnCreature
->SetUInt32Value(UNIT_FIELD_FLAGS
,0);
3690 spawnCreature
->SetUInt32Value(UNIT_FIELD_BYTES_1
,0);
3691 spawnCreature
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
,0);
3692 spawnCreature
->SetCreatorGUID(m_caster
->GetGUID());
3693 spawnCreature
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
3695 spawnCreature
->InitStatsForLevel(level
);
3696 spawnCreature
->GetCharmInfo()->SetPetNumber(pet_number
, false);
3698 spawnCreature
->AIM_Initialize();
3700 if(m_caster
->GetTypeId()==TYPEID_PLAYER
)
3701 ((Player
*)m_caster
)->AddGuardian(spawnCreature
);
3703 map
->Add((Creature
*)spawnCreature
);
3707 void Spell::EffectTeleUnitsFaceCaster(uint32 i
)
3712 if(unitTarget
->isInFlight())
3715 float dis
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
3718 m_caster
->GetClosePoint(fx
,fy
,fz
,unitTarget
->GetObjectSize(),dis
);
3720 unitTarget
->NearTeleportTo(fx
,fy
,fz
,-m_caster
->GetOrientation(),unitTarget
==m_caster
);
3723 void Spell::EffectLearnSkill(uint32 i
)
3725 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3731 uint32 skillid
= m_spellInfo
->EffectMiscValue
[i
];
3732 uint16 skillval
= ((Player
*)unitTarget
)->GetPureSkillValue(skillid
);
3733 ((Player
*)unitTarget
)->SetSkill(skillid
, skillval
?skillval
:1, damage
*75);
3736 void Spell::EffectAddHonor(uint32
/*i*/)
3738 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3741 // not scale value for item based reward (/10 value expected)
3744 ((Player
*)unitTarget
)->RewardHonor(NULL
, 1, damage
/10);
3745 sLog
.outError("SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo
->Id
, damage
/10, m_CastItem
->GetEntry(),((Player
*)unitTarget
)->GetGUIDLow());
3749 // do not allow to add too many honor for player (50 * 21) = 1040 at level 70, or (50 * 31) = 1550 at level 80
3752 uint32 honor_reward
= MaNGOS::Honor::hk_honor_at_level(unitTarget
->getLevel(), damage
);
3753 ((Player
*)unitTarget
)->RewardHonor(NULL
, 1, honor_reward
);
3754 sLog
.outDebug("SpellEffect::AddHonor (spell_id %u) rewards %u honor points (scale) to player: %u", m_spellInfo
->Id
, honor_reward
, ((Player
*)unitTarget
)->GetGUIDLow());
3758 //maybe we have correct honor_gain in damage already
3759 ((Player
*)unitTarget
)->RewardHonor(NULL
, 1, damage
);
3760 sLog
.outError("SpellEffect::AddHonor (spell_id %u) rewards %u honor points (non scale) for player: %u", m_spellInfo
->Id
, damage
, ((Player
*)unitTarget
)->GetGUIDLow());
3764 void Spell::EffectTradeSkill(uint32
/*i*/)
3766 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3768 // uint32 skillid = m_spellInfo->EffectMiscValue[i];
3769 // uint16 skillmax = ((Player*)unitTarget)->(skillid);
3770 // ((Player*)unitTarget)->SetSkill(skillid,skillval?skillval:1,skillmax+75);
3773 void Spell::EffectEnchantItemPerm(uint32 effect_idx
)
3775 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
3780 Player
* p_caster
= (Player
*)m_caster
;
3782 // not grow at item use at item case
3783 p_caster
->UpdateCraftSkill(m_spellInfo
->Id
);
3785 uint32 enchant_id
= m_spellInfo
->EffectMiscValue
[effect_idx
];
3789 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
3793 // item can be in trade slot and have owner diff. from caster
3794 Player
* item_owner
= itemTarget
->GetOwner();
3798 if(item_owner
!=p_caster
&& p_caster
->GetSession()->GetSecurity() > SEC_PLAYER
&& sWorld
.getConfig(CONFIG_GM_LOG_TRADE
) )
3800 sLog
.outCommand(p_caster
->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
3801 p_caster
->GetName(),p_caster
->GetSession()->GetAccountId(),
3802 itemTarget
->GetProto()->Name1
,itemTarget
->GetEntry(),
3803 item_owner
->GetName(),item_owner
->GetSession()->GetAccountId());
3806 // remove old enchanting before applying new if equipped
3807 item_owner
->ApplyEnchantment(itemTarget
,PERM_ENCHANTMENT_SLOT
,false);
3809 itemTarget
->SetEnchantment(PERM_ENCHANTMENT_SLOT
, enchant_id
, 0, 0);
3811 // add new enchanting if equipped
3812 item_owner
->ApplyEnchantment(itemTarget
,PERM_ENCHANTMENT_SLOT
,true);
3815 void Spell::EffectEnchantItemPrismatic(uint32 effect_idx
)
3817 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
3822 Player
* p_caster
= (Player
*)m_caster
;
3824 uint32 enchant_id
= m_spellInfo
->EffectMiscValue
[effect_idx
];
3828 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
3832 // support only enchantings with add socket in this slot
3834 bool add_socket
= false;
3835 for(int i
= 0; i
< 3; ++i
)
3837 if(pEnchant
->type
[i
]==ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET
)
3845 sLog
.outError("Spell::EffectEnchantItemPrismatic: attempt apply enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u) but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (u), not suppoted yet.",
3846 m_spellInfo
->Id
,SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC
,ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET
);
3851 // item can be in trade slot and have owner diff. from caster
3852 Player
* item_owner
= itemTarget
->GetOwner();
3856 if(item_owner
!=p_caster
&& p_caster
->GetSession()->GetSecurity() > SEC_PLAYER
&& sWorld
.getConfig(CONFIG_GM_LOG_TRADE
) )
3858 sLog
.outCommand(p_caster
->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
3859 p_caster
->GetName(),p_caster
->GetSession()->GetAccountId(),
3860 itemTarget
->GetProto()->Name1
,itemTarget
->GetEntry(),
3861 item_owner
->GetName(),item_owner
->GetSession()->GetAccountId());
3864 // remove old enchanting before applying new if equipped
3865 item_owner
->ApplyEnchantment(itemTarget
,PRISMATIC_ENCHANTMENT_SLOT
,false);
3867 itemTarget
->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT
, enchant_id
, 0, 0);
3869 // add new enchanting if equipped
3870 item_owner
->ApplyEnchantment(itemTarget
,PRISMATIC_ENCHANTMENT_SLOT
,true);
3873 void Spell::EffectEnchantItemTmp(uint32 i
)
3875 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
3878 Player
* p_caster
= (Player
*)m_caster
;
3883 uint32 enchant_id
= m_spellInfo
->EffectMiscValue
[i
];
3885 // Shaman Rockbiter Weapon
3886 if(i
==0 && m_spellInfo
->Effect
[1]==SPELL_EFFECT_DUMMY
)
3888 int32 enchnting_damage
= m_currentBasePoints
[1]+1;
3890 // enchanting id selected by calculated damage-per-sec stored in Effect[1] base value
3891 // with already applied percent bonus from Elemental Weapons talent
3892 // Note: damage calculated (correctly) with rounding int32(float(v)) but
3893 // RW enchantments applied damage int32(float(v)+0.5), this create 0..1 difference sometime
3894 switch(enchnting_damage
)
3897 case 2: enchant_id
= 29; break; // 0% [ 7% == 2, 14% == 2, 20% == 2]
3899 case 4: enchant_id
= 6; break; // 0% [ 7% == 4, 14% == 4]
3900 case 5: enchant_id
= 3025; break; // 20%
3902 case 6: enchant_id
= 1; break; // 0% [ 7% == 6, 14% == 6]
3903 case 7: enchant_id
= 3027; break; // 20%
3905 case 9: enchant_id
= 3032; break; // 0% [ 7% == 6]
3906 case 10: enchant_id
= 503; break; // 14%
3907 case 11: enchant_id
= 3031; break; // 20%
3909 case 15: enchant_id
= 3035; break; // 0%
3910 case 16: enchant_id
= 1663; break; // 7%
3911 case 17: enchant_id
= 3033; break; // 14%
3912 case 18: enchant_id
= 3034; break; // 20%
3914 case 28: enchant_id
= 3038; break; // 0%
3915 case 29: enchant_id
= 683; break; // 7%
3916 case 31: enchant_id
= 3036; break; // 14%
3917 case 33: enchant_id
= 3037; break; // 20%
3919 case 40: enchant_id
= 3041; break; // 0%
3920 case 42: enchant_id
= 1664; break; // 7%
3921 case 45: enchant_id
= 3039; break; // 14%
3922 case 48: enchant_id
= 3040; break; // 20%
3924 case 49: enchant_id
= 3044; break; // 0%
3925 case 52: enchant_id
= 2632; break; // 7%
3926 case 55: enchant_id
= 3042; break; // 14%
3927 case 58: enchant_id
= 3043; break; // 20%
3929 case 62: enchant_id
= 2633; break; // 0%
3930 case 66: enchant_id
= 3018; break; // 7%
3931 case 70: enchant_id
= 3019; break; // 14%
3932 case 74: enchant_id
= 3020; break; // 20%
3934 sLog
.outError("Spell::EffectEnchantItemTmp: Damage %u not handled in S'RW",enchnting_damage
);
3941 sLog
.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id",m_spellInfo
->Id
,i
);
3945 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
3948 sLog
.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ",m_spellInfo
->Id
,i
,enchant_id
);
3952 // select enchantment duration
3955 // rogue family enchantments exception by duration
3956 if(m_spellInfo
->Id
==38615)
3957 duration
= 1800; // 30 mins
3958 // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints)
3959 else if(m_spellInfo
->SpellFamilyName
==SPELLFAMILY_ROGUE
)
3960 duration
= 3600; // 1 hour
3961 // shaman family enchantments
3962 else if(m_spellInfo
->SpellFamilyName
==SPELLFAMILY_SHAMAN
)
3963 duration
= 1800; // 30 mins
3964 // other cases with this SpellVisual already selected
3965 else if(m_spellInfo
->SpellVisual
[0]==215)
3966 duration
= 1800; // 30 mins
3967 // some fishing pole bonuses
3968 else if(m_spellInfo
->SpellVisual
[0]==563)
3969 duration
= 600; // 10 mins
3970 // shaman rockbiter enchantments
3971 else if(m_spellInfo
->SpellVisual
[0]==0)
3972 duration
= 1800; // 30 mins
3973 else if(m_spellInfo
->Id
==29702)
3974 duration
= 300; // 5 mins
3975 else if(m_spellInfo
->Id
==37360)
3976 duration
= 300; // 5 mins
3979 duration
= 3600; // 1 hour
3981 // item can be in trade slot and have owner diff. from caster
3982 Player
* item_owner
= itemTarget
->GetOwner();
3986 if(item_owner
!=p_caster
&& p_caster
->GetSession()->GetSecurity() > SEC_PLAYER
&& sWorld
.getConfig(CONFIG_GM_LOG_TRADE
) )
3988 sLog
.outCommand(p_caster
->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
3989 p_caster
->GetName(),p_caster
->GetSession()->GetAccountId(),
3990 itemTarget
->GetProto()->Name1
,itemTarget
->GetEntry(),
3991 item_owner
->GetName(),item_owner
->GetSession()->GetAccountId());
3994 // remove old enchanting before applying new if equipped
3995 item_owner
->ApplyEnchantment(itemTarget
,TEMP_ENCHANTMENT_SLOT
,false);
3997 itemTarget
->SetEnchantment(TEMP_ENCHANTMENT_SLOT
, enchant_id
, duration
*1000, 0);
3999 // add new enchanting if equipped
4000 item_owner
->ApplyEnchantment(itemTarget
,TEMP_ENCHANTMENT_SLOT
,true);
4003 void Spell::EffectTameCreature(uint32
/*i*/)
4005 if(m_caster
->GetPetGUID())
4011 if(unitTarget
->GetTypeId() == TYPEID_PLAYER
)
4014 Creature
* creatureTarget
= (Creature
*)unitTarget
;
4016 if(creatureTarget
->isPet())
4019 if(m_caster
->getClass() != CLASS_HUNTER
)
4022 // cast finish successfully
4023 //SendChannelUpdate(0);
4026 Pet
* pet
= m_caster
->CreateTamedPetFrom(creatureTarget
,m_spellInfo
->Id
);
4028 // kill original creature
4029 creatureTarget
->setDeathState(JUST_DIED
);
4030 creatureTarget
->RemoveCorpse();
4031 creatureTarget
->SetHealth(0); // just for nice GM-mode view
4033 uint32 level
= (creatureTarget
->getLevel() < (m_caster
->getLevel() - 5)) ? (m_caster
->getLevel() - 5) : creatureTarget
->getLevel();
4035 // prepare visual effect for levelup
4036 pet
->SetUInt32Value(UNIT_FIELD_LEVEL
, level
- 1);
4039 pet
->GetMap()->Add((Creature
*)pet
);
4041 // visual effect for levelup
4042 pet
->SetUInt32Value(UNIT_FIELD_LEVEL
, level
);
4044 // caster have pet now
4045 m_caster
->SetPet(pet
);
4047 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4049 pet
->SavePetToDB(PET_SAVE_AS_CURRENT
);
4050 ((Player
*)m_caster
)->PetSpellInitialize();
4054 void Spell::EffectSummonPet(uint32 i
)
4056 uint32 petentry
= m_spellInfo
->EffectMiscValue
[i
];
4058 Pet
*OldSummon
= m_caster
->GetPet();
4060 // if pet requested type already exist
4063 if(petentry
== 0 || OldSummon
->GetEntry() == petentry
)
4065 // pet in corpse state can't be summoned
4066 if( OldSummon
->isDead() )
4069 OldSummon
->GetMap()->Remove((Creature
*)OldSummon
,false);
4070 OldSummon
->SetMapId(m_caster
->GetMapId());
4073 m_caster
->GetClosePoint(px
, py
, pz
, OldSummon
->GetObjectSize());
4075 OldSummon
->Relocate(px
, py
, pz
, OldSummon
->GetOrientation());
4076 m_caster
->GetMap()->Add((Creature
*)OldSummon
);
4078 if(m_caster
->GetTypeId() == TYPEID_PLAYER
&& OldSummon
->isControlled() )
4080 ((Player
*)m_caster
)->PetSpellInitialize();
4085 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4086 ((Player
*)m_caster
)->RemovePet(OldSummon
,(OldSummon
->getPetType()==HUNTER_PET
? PET_SAVE_AS_DELETED
: PET_SAVE_NOT_IN_SLOT
),false);
4091 Pet
* NewSummon
= new Pet
;
4093 // petentry==0 for hunter "call pet" (current pet summoned if any)
4094 if(m_caster
->GetTypeId() == TYPEID_PLAYER
&& NewSummon
->LoadPetFromDB((Player
*)m_caster
,petentry
))
4096 if(NewSummon
->getPetType()==SUMMON_PET
)
4098 // Remove Demonic Sacrifice auras (known pet)
4099 Unit::AuraList
const& auraClassScripts
= m_caster
->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
);
4100 for(Unit::AuraList::const_iterator itr
= auraClassScripts
.begin();itr
!=auraClassScripts
.end();)
4102 if((*itr
)->GetModifier()->m_miscvalue
==2228)
4104 m_caster
->RemoveAurasDueToSpell((*itr
)->GetId());
4105 itr
= auraClassScripts
.begin();
4115 // not error in case fail hunter call pet
4122 CreatureInfo
const* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
>(petentry
);
4126 sLog
.outError("EffectSummonPet: creature entry %u not found.",petentry
);
4131 Map
*map
= m_caster
->GetMap();
4132 uint32 pet_number
= objmgr
.GeneratePetNumber();
4133 if(!NewSummon
->Create(objmgr
.GenerateLowGuid(HIGHGUID_PET
), map
, m_caster
->GetPhaseMask(),
4134 petentry
, pet_number
))
4141 m_caster
->GetClosePoint(px
, py
, pz
, NewSummon
->GetObjectSize());
4143 NewSummon
->Relocate(px
, py
, pz
, m_caster
->GetOrientation());
4145 if(!NewSummon
->IsPositionValid())
4147 sLog
.outError("Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
4148 NewSummon
->GetGUIDLow(), NewSummon
->GetEntry(), NewSummon
->GetPositionX(), NewSummon
->GetPositionY());
4153 uint32 petlevel
= m_caster
->getLevel();
4154 NewSummon
->setPetType(SUMMON_PET
);
4156 uint32 faction
= m_caster
->getFaction();
4157 if(m_caster
->GetTypeId() == TYPEID_UNIT
)
4159 if ( ((Creature
*)m_caster
)->isTotem() )
4160 NewSummon
->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE
);
4162 NewSummon
->GetCharmInfo()->SetReactState(REACT_DEFENSIVE
);
4165 NewSummon
->SetOwnerGUID(m_caster
->GetGUID());
4166 NewSummon
->SetCreatorGUID(m_caster
->GetGUID());
4167 NewSummon
->SetUInt32Value(UNIT_NPC_FLAGS
, 0);
4168 NewSummon
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
, faction
);
4169 NewSummon
->SetUInt32Value(UNIT_FIELD_BYTES_0
, 2048);
4170 NewSummon
->SetUInt32Value(UNIT_FIELD_BYTES_1
, 0);
4171 NewSummon
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, time(NULL
));
4172 NewSummon
->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE
, 0);
4173 NewSummon
->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP
, 1000);
4174 NewSummon
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
4176 NewSummon
->GetCharmInfo()->SetPetNumber(pet_number
, true);
4177 // this enables pet details window (Shift+P)
4179 // this enables popup window (pet dismiss, cancel), hunter pet additional flags set later
4180 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4181 NewSummon
->SetUInt32Value(UNIT_FIELD_FLAGS
,UNIT_FLAG_PVP_ATTACKABLE
);
4183 NewSummon
->InitStatsForLevel(petlevel
);
4184 NewSummon
->InitPetCreateSpells();
4185 NewSummon
->InitTalentForLevel();
4187 if(NewSummon
->getPetType()==SUMMON_PET
)
4189 // Remove Demonic Sacrifice auras (new pet)
4190 Unit::AuraList
const& auraClassScripts
= m_caster
->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
);
4191 for(Unit::AuraList::const_iterator itr
= auraClassScripts
.begin();itr
!=auraClassScripts
.end();)
4193 if((*itr
)->GetModifier()->m_miscvalue
==2228)
4195 m_caster
->RemoveAurasDueToSpell((*itr
)->GetId());
4196 itr
= auraClassScripts
.begin();
4202 // generate new name for summon pet
4203 std::string new_name
=objmgr
.GeneratePetName(petentry
);
4204 if(!new_name
.empty())
4205 NewSummon
->SetName(new_name
);
4207 else if(NewSummon
->getPetType()==HUNTER_PET
)
4208 NewSummon
->SetByteValue(UNIT_FIELD_BYTES_2
, 2, UNIT_RENAME_NOT_ALLOWED
);
4210 NewSummon
->AIM_Initialize();
4211 NewSummon
->SetHealth(NewSummon
->GetMaxHealth());
4212 NewSummon
->SetPower(POWER_MANA
, NewSummon
->GetMaxPower(POWER_MANA
));
4214 map
->Add((Creature
*)NewSummon
);
4216 m_caster
->SetPet(NewSummon
);
4217 sLog
.outDebug("New Pet has guid %u", NewSummon
->GetGUIDLow());
4219 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4221 NewSummon
->SavePetToDB(PET_SAVE_AS_CURRENT
);
4222 ((Player
*)m_caster
)->PetSpellInitialize();
4226 void Spell::EffectLearnPetSpell(uint32 i
)
4228 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
4231 Player
*_player
= (Player
*)m_caster
;
4233 Pet
*pet
= _player
->GetPet();
4239 SpellEntry
const *learn_spellproto
= sSpellStore
.LookupEntry(m_spellInfo
->EffectTriggerSpell
[i
]);
4240 if(!learn_spellproto
)
4243 pet
->learnSpell(learn_spellproto
->Id
);
4245 pet
->SavePetToDB(PET_SAVE_AS_CURRENT
);
4246 _player
->PetSpellInitialize();
4249 void Spell::EffectTaunt(uint32
/*i*/)
4254 // this effect use before aura Taunt apply for prevent taunt already attacking target
4255 // for spell as marked "non effective at already attacking target"
4256 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
4258 if (unitTarget
->getVictim()==m_caster
)
4260 SendCastResult(SPELL_FAILED_DONT_REPORT
);
4265 // Also use this effect to set the taunter's threat to the taunted creature's highest value
4266 if (unitTarget
->CanHaveThreatList() && unitTarget
->getThreatManager().getCurrentVictim())
4267 unitTarget
->getThreatManager().addThreat(m_caster
,unitTarget
->getThreatManager().getCurrentVictim()->getThreat());
4270 void Spell::EffectWeaponDmg(uint32 i
)
4274 if(!unitTarget
->isAlive())
4277 // multiple weapon dmg effect workaround
4278 // execute only the last weapon damage
4279 // and handle all effects at once
4280 for (int j
= 0; j
< 3; j
++)
4282 switch(m_spellInfo
->Effect
[j
])
4284 case SPELL_EFFECT_WEAPON_DAMAGE
:
4285 case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
:
4286 case SPELL_EFFECT_NORMALIZED_WEAPON_DMG
:
4287 case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
:
4288 if (j
< i
) // we must calculate only at last weapon effect
4294 // some spell specific modifiers
4295 bool spellBonusNeedWeaponDamagePercentMod
= false; // if set applied weapon damage percent mode to spell bonus
4297 float weaponDamagePercentMod
= 1.0f
; // applied to weapon damage and to fixed effect damage bonus
4298 float totalDamagePercentMod
= 1.0f
; // applied to final bonus+weapon damage
4299 bool normalized
= false;
4301 int32 spell_bonus
= 0; // bonus specific for spell
4302 switch(m_spellInfo
->SpellFamilyName
)
4304 case SPELLFAMILY_WARRIOR
:
4306 // Whirlwind, single only spell with 2 weapon white damage apply if have
4307 if(m_caster
->GetTypeId()==TYPEID_PLAYER
&& (m_spellInfo
->SpellFamilyFlags
& 0x00000400000000LL
))
4309 if(((Player
*)m_caster
)->GetWeaponForAttack(OFF_ATTACK
,true))
4310 spell_bonus
+= m_caster
->CalculateDamage (OFF_ATTACK
, normalized
);
4312 // Devastate bonus and sunder armor refresh
4313 else if(m_spellInfo
->SpellVisual
[0] == 671 && m_spellInfo
->SpellIconID
== 1508)
4316 // Need refresh all Sunder Armor auras from this caster
4317 Unit::AuraMap
& suAuras
= unitTarget
->GetAuras();
4318 for(Unit::AuraMap::iterator itr
= suAuras
.begin(); itr
!= suAuras
.end(); ++itr
)
4320 SpellEntry
const *spellInfo
= (*itr
).second
->GetSpellProto();
4321 if( spellInfo
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&&
4322 spellInfo
->SpellFamilyFlags
& 0x0000000000004000LL
&&
4323 (*itr
).second
->GetCasterGUID() == m_caster
->GetGUID())
4325 (*itr
).second
->RefreshAura();
4326 stack
= (*itr
).second
->GetStackAmount();
4330 spell_bonus
+= stack
* CalculateDamage(2, unitTarget
);
4334 case SPELLFAMILY_ROGUE
:
4336 // Mutilate (for each hand)
4337 if(m_spellInfo
->SpellFamilyFlags
& 0x600000000LL
)
4341 if(unitTarget
->HasAuraState(AURA_STATE_DEADLY_POISON
))
4346 Unit::AuraMap
const& auras
= unitTarget
->GetAuras();
4347 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
4349 if(itr
->second
->GetSpellProto()->Dispel
== DISPEL_POISON
)
4358 totalDamagePercentMod
*= 1.2f
; // 120% if poisoned
4362 case SPELLFAMILY_PALADIN
:
4364 // Seal of Command - receive benefit from Spell Damage and Healing
4365 if(m_spellInfo
->SpellFamilyFlags
& 0x00000002000000LL
)
4367 spellBonusNeedWeaponDamagePercentMod
= true;// apply weaponDamagePercentMod to spell_bonus (and then to all bonus, fixes and weapon already have applied)
4368 spell_bonus
+= int32(0.23f
*m_caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo
)));
4369 spell_bonus
+= int32(0.29f
*m_caster
->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo
), unitTarget
));
4373 case SPELLFAMILY_SHAMAN
:
4375 // Skyshatter Harness item set bonus
4377 if(m_spellInfo
->SpellFamilyFlags
& 0x001000000000LL
)
4379 Unit::AuraList
const& m_OverrideClassScript
= m_caster
->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
);
4380 for(Unit::AuraList::const_iterator citr
= m_OverrideClassScript
.begin(); citr
!= m_OverrideClassScript
.end(); ++citr
)
4382 // Stormstrike AP Buff
4383 if ( (*citr
)->GetModifier()->m_miscvalue
== 5634 )
4385 m_caster
->CastSpell(m_caster
,38430,true,NULL
,*citr
);
4393 int32 fixed_bonus
= 0;
4394 for (int j
= 0; j
< 3; j
++)
4396 switch(m_spellInfo
->Effect
[j
])
4398 case SPELL_EFFECT_WEAPON_DAMAGE
:
4399 case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
:
4400 fixed_bonus
+= CalculateDamage(j
,unitTarget
);
4402 case SPELL_EFFECT_NORMALIZED_WEAPON_DMG
:
4403 fixed_bonus
+= CalculateDamage(j
,unitTarget
);
4406 case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
:
4407 weaponDamagePercentMod
*= float(CalculateDamage(j
,unitTarget
)) / 100.0f
;
4409 // applied only to prev.effects fixed damage
4410 fixed_bonus
= int32(fixed_bonus
*weaponDamagePercentMod
);
4413 break; // not weapon damage effect, just skip
4417 // apply weaponDamagePercentMod to spell bonus also
4418 if(spellBonusNeedWeaponDamagePercentMod
)
4419 spell_bonus
= int32(spell_bonus
*weaponDamagePercentMod
);
4421 // non-weapon damage
4422 int32 bonus
= spell_bonus
+ fixed_bonus
;
4424 // apply to non-weapon bonus weapon total pct effect, weapon total flat effect included in weapon damage
4428 switch(m_attackType
)
4431 case BASE_ATTACK
: unitMod
= UNIT_MOD_DAMAGE_MAINHAND
; break;
4432 case OFF_ATTACK
: unitMod
= UNIT_MOD_DAMAGE_OFFHAND
; break;
4433 case RANGED_ATTACK
: unitMod
= UNIT_MOD_DAMAGE_RANGED
; break;
4436 float weapon_total_pct
= m_caster
->GetModifierValue(unitMod
, TOTAL_PCT
);
4437 bonus
= int32(bonus
*weapon_total_pct
);
4440 // + weapon damage with applied weapon% dmg to base weapon damage in call
4441 bonus
+= int32(m_caster
->CalculateDamage(m_attackType
, normalized
)*weaponDamagePercentMod
);
4444 bonus
= int32(bonus
*totalDamagePercentMod
);
4446 // prevent negative damage
4447 uint32 eff_damage
= uint32(bonus
> 0 ? bonus
: 0);
4449 // Add melee damage bonuses (also check for negative)
4450 m_caster
->MeleeDamageBonus(unitTarget
, &eff_damage
, m_attackType
, m_spellInfo
);
4451 m_damage
+= eff_damage
;
4454 if(m_spellInfo
->SpellFamilyName
==SPELLFAMILY_ROGUE
&& (m_spellInfo
->SpellFamilyFlags
& 0x2000000))
4456 if(m_caster
->GetTypeId()==TYPEID_PLAYER
)
4457 ((Player
*)m_caster
)->AddComboPoints(unitTarget
, 1);
4461 if(m_spellInfo
->SpellFamilyName
==SPELLFAMILY_DRUID
&& (m_spellInfo
->SpellFamilyFlags
==0x0000040000000000LL
))
4463 if(m_caster
->GetTypeId()==TYPEID_PLAYER
)
4464 ((Player
*)m_caster
)->AddComboPoints(unitTarget
,1);
4468 if(m_attackType
== RANGED_ATTACK
&& m_caster
->GetTypeId() == TYPEID_PLAYER
)
4470 Item
*pItem
= ((Player
*)m_caster
)->GetWeaponForAttack( RANGED_ATTACK
);
4472 // wands don't have ammo
4473 if(!pItem
|| pItem
->IsBroken() || pItem
->GetProto()->SubClass
==ITEM_SUBCLASS_WEAPON_WAND
)
4476 if( pItem
->GetProto()->InventoryType
== INVTYPE_THROWN
)
4478 if(pItem
->GetMaxStackCount()==1)
4480 // decrease durability for non-stackable throw weapon
4481 ((Player
*)m_caster
)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_RANGED
);
4485 // decrease items amount for stackable throw weapon
4487 ((Player
*)m_caster
)->DestroyItemCount( pItem
, count
, true);
4490 else if(uint32 ammo
= ((Player
*)m_caster
)->GetUInt32Value(PLAYER_AMMO_ID
))
4491 ((Player
*)m_caster
)->DestroyItemCount(ammo
, 1, true);
4495 void Spell::EffectThreat(uint32
/*i*/)
4497 if(!unitTarget
|| !unitTarget
->isAlive() || !m_caster
->isAlive())
4500 if(!unitTarget
->CanHaveThreatList())
4503 unitTarget
->AddThreat(m_caster
, float(damage
));
4506 void Spell::EffectHealMaxHealth(uint32
/*i*/)
4510 if(!unitTarget
->isAlive())
4513 uint32 heal
= m_caster
->GetMaxHealth();
4518 void Spell::EffectInterruptCast(uint32
/*i*/)
4522 if(!unitTarget
->isAlive())
4525 // TODO: not all spells that used this effect apply cooldown at school spells
4526 // also exist case: apply cooldown to interrupted cast only and to all spells
4527 for (uint32 i
= CURRENT_FIRST_NON_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; i
++)
4529 if (unitTarget
->m_currentSpells
[i
])
4531 // check if we can interrupt spell
4532 if ( unitTarget
->m_currentSpells
[i
]->m_spellInfo
->InterruptFlags
& SPELL_INTERRUPT_FLAG_INTERRUPT
&& unitTarget
->m_currentSpells
[i
]->m_spellInfo
->PreventionType
== SPELL_PREVENTION_TYPE_SILENCE
)
4534 unitTarget
->ProhibitSpellScholl(GetSpellSchoolMask(unitTarget
->m_currentSpells
[i
]->m_spellInfo
), GetSpellDuration(m_spellInfo
));
4535 unitTarget
->InterruptSpell(i
,false);
4541 void Spell::EffectSummonObjectWild(uint32 i
)
4543 uint32 gameobject_id
= m_spellInfo
->EffectMiscValue
[i
];
4545 GameObject
* pGameObj
= new GameObject
;
4547 WorldObject
* target
= focusObject
;
4552 if(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
4554 x
= m_targets
.m_destX
;
4555 y
= m_targets
.m_destY
;
4556 z
= m_targets
.m_destZ
;
4559 m_caster
->GetClosePoint(x
,y
,z
,DEFAULT_WORLD_OBJECT_SIZE
);
4561 Map
*map
= target
->GetMap();
4563 if(!pGameObj
->Create(objmgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), gameobject_id
, map
,
4564 m_caster
->GetPhaseMask(), x
, y
, z
, target
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
4570 int32 duration
= GetSpellDuration(m_spellInfo
);
4571 pGameObj
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
4572 pGameObj
->SetSpellId(m_spellInfo
->Id
);
4574 if(pGameObj
->GetGoType() != GAMEOBJECT_TYPE_FLAGDROP
) // make dropped flag clickable for other players (not set owner guid (created by) for this)...
4575 m_caster
->AddGameObject(pGameObj
);
4578 if(pGameObj
->GetMapId() == 489 && pGameObj
->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP
) //WS
4580 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4582 Player
*pl
= (Player
*)m_caster
;
4583 BattleGround
* bg
= ((Player
*)m_caster
)->GetBattleGround();
4584 if(bg
&& bg
->GetTypeID()==BATTLEGROUND_WS
&& bg
->GetStatus() == STATUS_IN_PROGRESS
)
4586 uint32 team
= ALLIANCE
;
4588 if(pl
->GetTeam() == team
)
4591 ((BattleGroundWS
*)bg
)->SetDroppedFlagGUID(pGameObj
->GetGUID(),team
);
4596 if(pGameObj
->GetMapId() == 566 && pGameObj
->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP
) //EY
4598 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4600 BattleGround
* bg
= ((Player
*)m_caster
)->GetBattleGround();
4601 if(bg
&& bg
->GetTypeID()==BATTLEGROUND_EY
&& bg
->GetStatus() == STATUS_IN_PROGRESS
)
4603 ((BattleGroundEY
*)bg
)->SetDroppedFlagGUID(pGameObj
->GetGUID());
4608 if(uint32 linkedEntry
= pGameObj
->GetLinkedGameObjectEntry())
4610 GameObject
* linkedGO
= new GameObject
;
4611 if(linkedGO
->Create(objmgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), linkedEntry
, map
,
4612 m_caster
->GetPhaseMask(), x
, y
, z
, target
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
4614 linkedGO
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
4615 linkedGO
->SetSpellId(m_spellInfo
->Id
);
4617 m_caster
->AddGameObject(linkedGO
);
4629 void Spell::EffectScriptEffect(uint32 effIndex
)
4631 // TODO: we must implement hunter pet summon at login there (spell 6962)
4633 switch(m_spellInfo
->SpellFamilyName
)
4635 case SPELLFAMILY_GENERIC
:
4637 switch(m_spellInfo
->Id
)
4639 // PX-238 Winter Wondervolt TRAP
4642 uint32 spells
[4] = { 26272, 26157, 26273, 26274 };
4645 for(int j
= 0; j
< 4; ++j
)
4646 if(unitTarget
->HasAura(spells
[j
],0))
4650 uint32 iTmpSpellId
= spells
[urand(0,3)];
4653 unitTarget
->CastSpell(unitTarget
, iTmpSpellId
, true);
4659 if(!itemTarget
&& m_caster
->GetTypeId()!=TYPEID_PLAYER
)
4662 uint32 spell_id
= 0;
4665 case 1: spell_id
= 8854; break;
4666 default: spell_id
= 8855; break;
4669 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
4672 // Brittle Armor - need remove one 24575 Brittle Armor aura
4674 unitTarget
->RemoveSingleSpellAurasFromStack(24575);
4676 // Mercurial Shield - need remove one 26464 Mercurial Shield aura
4678 unitTarget
->RemoveSingleSpellAurasFromStack(26464);
4680 // Orb teleport spells
4694 switch(m_spellInfo
->Id
)
4696 case 25140: spellid
= 32571; break;
4697 case 25143: spellid
= 32572; break;
4698 case 25650: spellid
= 30140; break;
4699 case 25652: spellid
= 30141; break;
4700 case 29128: spellid
= 32568; break;
4701 case 29129: spellid
= 32569; break;
4702 case 35376: spellid
= 25649; break;
4703 case 35727: spellid
= 35730; break;
4708 unitTarget
->CastSpell(unitTarget
,spellid
,false);
4711 // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell)
4726 if(!unitTarget
|| !unitTarget
->isAlive())
4729 // Onyxia Scale Cloak
4730 if(unitTarget
->GetDummyAura(22683))
4734 m_caster
->CastSpell(unitTarget
, 22682, true);
4737 // Summon Black Qiraji Battle Tank
4743 // Prevent stacking of mounts
4744 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
4746 // Two separate mounts depending on area id (allows use both in and out of specific instance)
4747 if (unitTarget
->GetAreaId() == 3428)
4748 unitTarget
->CastSpell(unitTarget
, 25863, false);
4750 unitTarget
->CastSpell(unitTarget
, 26655, false);
4753 // Piccolo of the Flaming Fire
4756 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
4758 unitTarget
->HandleEmoteCommand(EMOTE_STATE_DANCE
);
4764 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
4765 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
4768 // Mirren's Drinking Hat
4772 switch ( urand(1,6) )
4774 case 1:case 2:case 3:
4775 item
= 23584;break; // Loch Modan Lager
4777 item
= 23585;break; // Stouthammer Lite
4779 item
= 23586;break; // Aerie Peak Pale Ale
4782 DoCreateItem(effIndex
,item
);
4788 // Removes snares and roots.
4789 uint32 mechanic_mask
= (1<<MECHANIC_ROOT
) | (1<<MECHANIC_SNARE
);
4790 Unit::AuraMap
& Auras
= unitTarget
->GetAuras();
4791 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
4795 Aura
*aur
= iter
->second
;
4796 if (!aur
->IsPositive()) //only remove negative spells
4798 // check for mechanic mask
4799 if(GetSpellMechanicMask(aur
->GetSpellProto(), aur
->GetEffIndex()) & mechanic_mask
)
4801 unitTarget
->RemoveAurasDueToSpell(aur
->GetId());
4805 next
= Auras
.begin();
4817 unitTarget
->CastSpell(unitTarget
, 41131, true);
4820 // Force Cast - Portal Effect: Sunwell Isle
4826 unitTarget
->CastSpell(unitTarget
, 44870, true);
4829 // Goblin Weather Machine
4838 case 0: spellId
= 46740; break;
4839 case 1: spellId
= 46739; break;
4840 case 2: spellId
= 46738; break;
4841 case 3: spellId
= 46736; break;
4843 unitTarget
->CastSpell(unitTarget
, spellId
, true);
4849 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
4852 ((Player
*)unitTarget
)->ModifyMoney(50000000);
4856 // Emblazon Runeblade
4862 unitTarget
->CastSpell(unitTarget
,51771,false);
4868 if(!unitTarget
|| unitTarget
->getClass() != CLASS_DEATH_KNIGHT
)
4870 // triggered spell is stored in m_spellInfo->EffectBasePoints[0]
4871 unitTarget
->CastSpell(unitTarget
, damage
, false);
4874 case 58418: // Portal to Orgrimmar
4875 case 58420: // Portal to Stormwind
4877 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
|| effIndex
!=0)
4880 uint32 spellID
= m_spellInfo
->CalculateSimpleValue(0);
4881 uint32 questID
= m_spellInfo
->CalculateSimpleValue(1);
4883 if( ((Player
*)unitTarget
)->GetQuestStatus(questID
) == QUEST_STATUS_COMPLETE
&& !((Player
*)unitTarget
)->GetQuestRewardStatus (questID
) )
4884 unitTarget
->CastSpell(unitTarget
, spellID
, true);
4888 // random spell learn instead placeholder
4889 case 60893: // Northrend Alchemy Research
4890 case 61177: // Northrend Inscription Research
4891 case 61288: // Minor Inscription Research
4892 case 61756: // Northrend Inscription Research (FAST QA VERSION)
4894 if(!IsExplicitDiscoverySpell(m_spellInfo
))
4896 sLog
.outError("Wrong explicit discovery spell %u structure, or outdated...",m_spellInfo
->Id
);
4900 if(m_caster
->GetTypeId()!=TYPEID_PLAYER
)
4902 Player
* player
= (Player
*)m_caster
;
4904 // need replace effect 0 item by loot
4905 uint32 reagent_id
= m_spellInfo
->EffectItemType
[0];
4907 if(!player
->HasItemCount(reagent_id
,1))
4912 player
->DestroyItemCount (reagent_id
,count
,true);
4914 // create some random items
4915 player
->AutoStoreLoot(m_spellInfo
->Id
,LootTemplates_Spell
);
4917 // learn random explicit discovery recipe (if any)
4918 if(uint32 discoveredSpell
= GetExplicitDiscoverySpell(m_spellInfo
->Id
, player
))
4919 player
->learnSpell(discoveredSpell
,false);
4925 case SPELLFAMILY_WARLOCK
:
4927 switch(m_spellInfo
->Id
)
4929 // Healthstone creating spells
4941 Unit::AuraList
const& mDummyAuras
= unitTarget
->GetAurasByType(SPELL_AURA_DUMMY
);
4942 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
4944 if((*i
)->GetId() == 18692)
4949 else if((*i
)->GetId() == 18693)
4956 static uint32
const itypes
[8][3] = {
4957 { 5512,19004,19005}, // Minor Healthstone
4958 { 5511,19006,19007}, // Lesser Healthstone
4959 { 5509,19008,19009}, // Healthstone
4960 { 5510,19010,19011}, // Greater Healthstone
4961 { 9421,19012,19013}, // Major Healthstone
4962 {22103,22104,22105}, // Master Healthstone
4963 {36889,36890,36891}, // Demonic Healthstone
4964 {36892,36893,36894} // Fel Healthstone
4967 switch(m_spellInfo
->Id
)
4970 itemtype
=itypes
[0][rank
];break; // Minor Healthstone
4972 itemtype
=itypes
[1][rank
];break; // Lesser Healthstone
4974 itemtype
=itypes
[2][rank
];break; // Healthstone
4976 itemtype
=itypes
[3][rank
];break; // Greater Healthstone
4978 itemtype
=itypes
[4][rank
];break; // Major Healthstone
4980 itemtype
=itypes
[5][rank
];break; // Master Healthstone
4982 itemtype
=itypes
[6][rank
];break; // Demonic Healthstone
4984 itemtype
=itypes
[7][rank
];break; // Fel Healthstone
4988 DoCreateItem( effIndex
, itemtype
);
4991 // Everlasting Affliction
4994 // Need refresh caster corruption auras on target
4995 Unit::AuraMap
& suAuras
= unitTarget
->GetAuras();
4996 for(Unit::AuraMap::iterator itr
= suAuras
.begin(); itr
!= suAuras
.end(); ++itr
)
4998 SpellEntry
const *spellInfo
= (*itr
).second
->GetSpellProto();
4999 if(spellInfo
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&&
5000 spellInfo
->SpellFamilyFlags
& 0x0000000000000002LL
&&
5001 (*itr
).second
->GetCasterGUID()==m_caster
->GetGUID())
5002 (*itr
).second
->RefreshAura();
5009 case SPELLFAMILY_PRIEST
:
5011 switch(m_spellInfo
->Id
)
5013 // Pain and Suffering
5018 // Refresh Shadow Word: Pain on target
5019 Unit::AuraMap
& auras
= unitTarget
->GetAuras();
5020 for(Unit::AuraMap::iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
5022 SpellEntry
const *spellInfo
= (*itr
).second
->GetSpellProto();
5023 if( spellInfo
->SpellFamilyName
== SPELLFAMILY_PRIEST
&&
5024 spellInfo
->SpellFamilyFlags
& 0x0000000000008000LL
&&
5025 (*itr
).second
->GetCasterGUID() == m_caster
->GetGUID())
5027 (*itr
).second
->RefreshAura();
5038 case SPELLFAMILY_HUNTER
:
5040 switch(m_spellInfo
->Id
)
5046 int32 basePoint
= 0;
5047 Unit::AuraMap
& Auras
= unitTarget
->GetAuras();
5048 for(Unit::AuraMap::iterator i
= Auras
.begin(); i
!= Auras
.end(); ++i
)
5050 Aura
*aura
= (*i
).second
;
5051 if (aura
->GetCasterGUID() != m_caster
->GetGUID())
5053 // Search only Serpent Sting, Viper Sting, Scorpid Sting auras
5054 uint64 familyFlag
= aura
->GetSpellProto()->SpellFamilyFlags
;
5055 if (!(familyFlag
& 0x000000800000C000LL
))
5057 // Refresh aura duration
5058 aura
->RefreshAura();
5060 // Serpent Sting - Instantly deals 40% of the damage done by your Serpent Sting.
5061 if (familyFlag
& 0x0000000000004000LL
&& aura
->GetEffIndex() == 0)
5063 spellId
= 53353; // 53353 Chimera Shot - Serpent
5064 basePoint
= aura
->GetModifier()->m_amount
* 5 * 40 / 100;
5066 // Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting.
5067 if (familyFlag
& 0x0000008000000000LL
&& aura
->GetEffIndex() == 0)
5069 spellId
= 53358; // 53358 Chimera Shot - Viper
5070 basePoint
= aura
->GetModifier()->m_amount
* 4 * 60 / 100;
5072 // Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute.
5073 if (familyFlag
& 0x0000000000008000LL
)
5074 spellId
= 53359; // 53359 Chimera Shot - Scorpid
5075 // ?? nothing say in spell desc (possibly need addition check)
5076 //if (familyFlag & 0x0000010000000000LL || // dot
5077 // familyFlag & 0x0000100000000000LL) // stun
5079 // spellId = 53366; // 53366 Chimera Shot - Wyvern
5083 m_caster
->CastCustomSpell(unitTarget
, spellId
, &basePoint
, 0, 0, false);
5091 case SPELLFAMILY_PALADIN
:
5094 if (m_spellInfo
->SpellFamilyFlags
& 0x0000000000800000LL
)
5096 if(!unitTarget
|| !unitTarget
->isAlive())
5098 uint32 spellId1
= 0;
5099 uint32 spellId2
= 0;
5101 // Judgement self add switch
5102 switch (m_spellInfo
->Id
)
5104 case 41467: break; // Judgement
5105 case 53407: spellId1
= 20184; break; // Judgement of Justice
5106 case 20271: // Judgement of Light
5107 case 57774: spellId1
= 20185; break; // Judgement of Light
5108 case 53408: spellId1
= 20186; break; // Judgement of Wisdom
5112 // all seals have aura dummy in 2 effect
5113 Unit::AuraList
const& m_dummyAuras
= m_caster
->GetAurasByType(SPELL_AURA_DUMMY
);
5114 for(Unit::AuraList::const_iterator itr
= m_dummyAuras
.begin(); itr
!= m_dummyAuras
.end(); ++itr
)
5116 SpellEntry
const *spellInfo
= (*itr
)->GetSpellProto();
5117 // search seal (all seals have judgement's aura dummy spell id in 2 effect
5118 if ((*itr
)->GetEffIndex() != 2 || !spellInfo
|| !IsSealSpell(spellInfo
))
5120 spellId2
= (*itr
)->GetModifier()->m_amount
;
5121 SpellEntry
const *judge
= sSpellStore
.LookupEntry(spellId2
);
5127 m_caster
->CastSpell(unitTarget
, spellId1
, true);
5129 m_caster
->CastSpell(unitTarget
, spellId2
, true);
5133 case SPELLFAMILY_POTION
:
5135 switch(m_spellInfo
->Id
)
5142 unitTarget
->CastSpell(unitTarget
, 28694, true);
5150 // 25% chance of casting a random buff
5151 if(roll_chance_i(75))
5154 // triggered spells are 28703 to 28707
5155 // Note: some sources say, that there was the possibility of
5156 // receiving a debuff. However, this seems to be removed by a patch.
5157 const uint32 spellid
= 28703;
5159 // don't overwrite an existing aura
5160 for(uint8 i
=0; i
<5; i
++)
5161 if(unitTarget
->HasAura(spellid
+i
, 0))
5163 unitTarget
->CastSpell(unitTarget
, spellid
+urand(0, 4), true);
5172 // 25% chance of casting Nightmare Pollen
5173 if(roll_chance_i(75))
5175 unitTarget
->CastSpell(unitTarget
, 28721, true);
5183 // normal DB scripted effect
5187 sLog
.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect ", m_spellInfo
->Id
);
5188 sWorld
.ScriptsStart(sSpellScripts
, m_spellInfo
->Id
, m_caster
, unitTarget
);
5191 void Spell::EffectSanctuary(uint32
/*i*/)
5195 //unitTarget->CombatStop();
5197 unitTarget
->CombatStop();
5198 unitTarget
->getHostilRefManager().deleteReferences(); // stop all fighting
5199 // Vanish allows to remove all threat and cast regular stealth so other spells can be used
5200 if(m_spellInfo
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& (m_spellInfo
->SpellFamilyFlags
& SPELLFAMILYFLAG_ROGUE_VANISH
))
5202 ((Player
*)m_caster
)->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
5206 void Spell::EffectAddComboPoints(uint32
/*i*/)
5211 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5217 ((Player
*)m_caster
)->AddComboPoints(unitTarget
, damage
);
5220 void Spell::EffectDuel(uint32 i
)
5222 if(!m_caster
|| !unitTarget
|| m_caster
->GetTypeId() != TYPEID_PLAYER
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5225 Player
*caster
= (Player
*)m_caster
;
5226 Player
*target
= (Player
*)unitTarget
;
5228 // caster or target already have requested duel
5229 if( caster
->duel
|| target
->duel
|| !target
->GetSocial() || target
->GetSocial()->HasIgnore(caster
->GetGUIDLow()) )
5232 // Players can only fight a duel with each other outside (=not inside dungeons and not in capital cities)
5233 // Don't have to check the target's map since you cannot challenge someone across maps
5234 uint32 mapid
= caster
->GetMapId();
5235 if( mapid
!= 0 && mapid
!= 1 && mapid
!= 530 && mapid
!= 571 && mapid
!= 609)
5237 SendCastResult(SPELL_FAILED_NO_DUELING
); // Dueling isn't allowed here
5241 AreaTableEntry
const* casterAreaEntry
= GetAreaEntryByAreaID(caster
->GetZoneId());
5242 if(casterAreaEntry
&& (casterAreaEntry
->flags
& AREA_FLAG_CAPITAL
) )
5244 SendCastResult(SPELL_FAILED_NO_DUELING
); // Dueling isn't allowed here
5248 AreaTableEntry
const* targetAreaEntry
= GetAreaEntryByAreaID(target
->GetZoneId());
5249 if(targetAreaEntry
&& (targetAreaEntry
->flags
& AREA_FLAG_CAPITAL
) )
5251 SendCastResult(SPELL_FAILED_NO_DUELING
); // Dueling isn't allowed here
5255 //CREATE DUEL FLAG OBJECT
5256 GameObject
* pGameObj
= new GameObject
;
5258 uint32 gameobject_id
= m_spellInfo
->EffectMiscValue
[i
];
5260 Map
*map
= m_caster
->GetMap();
5261 if(!pGameObj
->Create(objmgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), gameobject_id
,
5262 map
, m_caster
->GetPhaseMask(),
5263 m_caster
->GetPositionX()+(unitTarget
->GetPositionX()-m_caster
->GetPositionX())/2 ,
5264 m_caster
->GetPositionY()+(unitTarget
->GetPositionY()-m_caster
->GetPositionY())/2 ,
5265 m_caster
->GetPositionZ(),
5266 m_caster
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0, GO_STATE_READY
))
5272 pGameObj
->SetUInt32Value(GAMEOBJECT_FACTION
, m_caster
->getFaction() );
5273 pGameObj
->SetUInt32Value(GAMEOBJECT_LEVEL
, m_caster
->getLevel()+1 );
5274 int32 duration
= GetSpellDuration(m_spellInfo
);
5275 pGameObj
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
5276 pGameObj
->SetSpellId(m_spellInfo
->Id
);
5278 m_caster
->AddGameObject(pGameObj
);
5283 WorldPacket
data(SMSG_DUEL_REQUESTED
, 16);
5284 data
<< pGameObj
->GetGUID();
5285 data
<< caster
->GetGUID();
5286 caster
->GetSession()->SendPacket(&data
);
5287 target
->GetSession()->SendPacket(&data
);
5290 DuelInfo
*duel
= new DuelInfo
;
5291 duel
->initiator
= caster
;
5292 duel
->opponent
= target
;
5293 duel
->startTime
= 0;
5294 duel
->startTimer
= 0;
5295 caster
->duel
= duel
;
5297 DuelInfo
*duel2
= new DuelInfo
;
5298 duel2
->initiator
= caster
;
5299 duel2
->opponent
= caster
;
5300 duel2
->startTime
= 0;
5301 duel2
->startTimer
= 0;
5302 target
->duel
= duel2
;
5304 caster
->SetUInt64Value(PLAYER_DUEL_ARBITER
,pGameObj
->GetGUID());
5305 target
->SetUInt64Value(PLAYER_DUEL_ARBITER
,pGameObj
->GetGUID());
5308 void Spell::EffectStuck(uint32
/*i*/)
5310 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5313 if(!sWorld
.getConfig(CONFIG_CAST_UNSTUCK
))
5316 Player
* pTarget
= (Player
*)unitTarget
;
5318 sLog
.outDebug("Spell Effect: Stuck");
5319 sLog
.outDetail("Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", pTarget
->GetName(), pTarget
->GetGUIDLow(), m_caster
->GetMapId(), m_caster
->GetPositionX(), pTarget
->GetPositionY(), pTarget
->GetPositionZ());
5321 if(pTarget
->isInFlight())
5324 // homebind location is loaded always
5325 pTarget
->TeleportTo(pTarget
->m_homebindMapId
,pTarget
->m_homebindX
,pTarget
->m_homebindY
,pTarget
->m_homebindZ
,pTarget
->GetOrientation(), (unitTarget
==m_caster
? TELE_TO_SPELL
: 0));
5327 // Stuck spell trigger Hearthstone cooldown
5328 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(8690);
5331 Spell
spell(pTarget
,spellInfo
,true,0);
5332 spell
.SendSpellCooldown();
5335 void Spell::EffectSummonPlayer(uint32
/*i*/)
5337 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5340 // Evil Twin (ignore player summon, but hide this for summoner)
5341 if(unitTarget
->GetDummyAura(23445))
5345 m_caster
->GetClosePoint(x
,y
,z
,unitTarget
->GetObjectSize());
5347 ((Player
*)unitTarget
)->SetSummonPoint(m_caster
->GetMapId(),x
,y
,z
);
5349 WorldPacket
data(SMSG_SUMMON_REQUEST
, 8+4+4);
5350 data
<< uint64(m_caster
->GetGUID()); // summoner guid
5351 data
<< uint32(m_caster
->GetZoneId()); // summoner zone
5352 data
<< uint32(MAX_PLAYER_SUMMON_DELAY
*IN_MILISECONDS
); // auto decline after msecs
5353 ((Player
*)unitTarget
)->GetSession()->SendPacket(&data
);
5356 static ScriptInfo
generateActivateCommand()
5359 si
.command
= SCRIPT_COMMAND_ACTIVATE_OBJECT
;
5363 void Spell::EffectActivateObject(uint32 effect_idx
)
5368 static ScriptInfo activateCommand
= generateActivateCommand();
5370 int32 delay_secs
= m_spellInfo
->EffectMiscValue
[effect_idx
];
5372 sWorld
.ScriptCommandStart(activateCommand
, delay_secs
, m_caster
, gameObjTarget
);
5375 void Spell::EffectApplyGlyph(uint32 i
)
5377 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5380 Player
*player
= (Player
*)m_caster
;
5383 if(uint32 glyph
= m_spellInfo
->EffectMiscValue
[i
])
5385 if(GlyphPropertiesEntry
const *gp
= sGlyphPropertiesStore
.LookupEntry(glyph
))
5387 if(GlyphSlotEntry
const *gs
= sGlyphSlotStore
.LookupEntry(player
->GetGlyphSlot(m_glyphIndex
)))
5389 if(gp
->TypeFlags
!= gs
->TypeFlags
)
5391 SendCastResult(SPELL_FAILED_INVALID_GLYPH
);
5392 return; // glyph slot mismatch
5397 if(uint32 oldglyph
= player
->GetGlyph(m_glyphIndex
))
5399 if(GlyphPropertiesEntry
const *old_gp
= sGlyphPropertiesStore
.LookupEntry(oldglyph
))
5401 player
->RemoveAurasDueToSpell(old_gp
->SpellId
);
5402 player
->SetGlyph(m_glyphIndex
, 0);
5406 player
->CastSpell(m_caster
, gp
->SpellId
, true);
5407 player
->SetGlyph(m_glyphIndex
, glyph
);
5412 void Spell::EffectSummonTotem(uint32 i
)
5415 switch(m_spellInfo
->EffectMiscValueB
[i
])
5417 case SUMMON_TYPE_TOTEM_SLOT1
: slot
= 0; break;
5418 case SUMMON_TYPE_TOTEM_SLOT2
: slot
= 1; break;
5419 case SUMMON_TYPE_TOTEM_SLOT3
: slot
= 2; break;
5420 case SUMMON_TYPE_TOTEM_SLOT4
: slot
= 3; break;
5421 // Battle standard case
5422 case SUMMON_TYPE_TOTEM
: slot
= 254; break;
5423 // jewelery statue case, like totem without slot
5424 case SUMMON_TYPE_GUARDIAN
: slot
= 255; break;
5428 if(slot
< MAX_TOTEM
)
5430 uint64 guid
= m_caster
->m_TotemSlot
[slot
];
5433 Creature
*OldTotem
= m_caster
->GetMap()->GetCreature(guid
);
5434 if(OldTotem
&& OldTotem
->isTotem())
5435 ((Totem
*)OldTotem
)->UnSummon();
5440 if (m_caster
->GetTypeId()==TYPEID_PLAYER
)
5441 team
= ((Player
*)m_caster
)->GetTeam();
5443 Totem
* pTotem
= new Totem
;
5445 if(!pTotem
->Create(objmgr
.GenerateLowGuid(HIGHGUID_UNIT
), m_caster
->GetMap(), m_caster
->GetPhaseMask(),
5446 m_spellInfo
->EffectMiscValue
[i
], team
))
5452 float angle
= slot
< MAX_TOTEM
? M_PI
/MAX_TOTEM
- (slot
*2*M_PI
/MAX_TOTEM
) : 0;
5455 m_caster
->GetClosePoint(x
,y
,z
,pTotem
->GetObjectSize(),2.0f
,angle
);
5457 // totem must be at same Z in case swimming caster and etc.
5458 if( fabs( z
- m_caster
->GetPositionZ() ) > 5 )
5459 z
= m_caster
->GetPositionZ();
5461 pTotem
->Relocate(x
, y
, z
, m_caster
->GetOrientation());
5463 if(slot
< MAX_TOTEM
)
5464 m_caster
->m_TotemSlot
[slot
] = pTotem
->GetGUID();
5466 pTotem
->SetOwner(m_caster
->GetGUID());
5467 pTotem
->SetTypeBySummonSpell(m_spellInfo
); // must be after Create call where m_spells initilized
5469 int32 duration
=GetSpellDuration(m_spellInfo
);
5470 if(Player
* modOwner
= m_caster
->GetSpellModOwner())
5471 modOwner
->ApplySpellMod(m_spellInfo
->Id
,SPELLMOD_DURATION
, duration
);
5472 pTotem
->SetDuration(duration
);
5474 if (damage
) // if not spell info, DB values used
5476 pTotem
->SetMaxHealth(damage
);
5477 pTotem
->SetHealth(damage
);
5480 pTotem
->SetUInt32Value(UNIT_CREATED_BY_SPELL
,m_spellInfo
->Id
);
5482 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
5483 pTotem
->SetFlag(UNIT_FIELD_FLAGS
,UNIT_FLAG_PVP_ATTACKABLE
);
5485 pTotem
->Summon(m_caster
);
5487 if(slot
< MAX_TOTEM
&& m_caster
->GetTypeId() == TYPEID_PLAYER
)
5489 WorldPacket
data(SMSG_TOTEM_CREATED
, 1+8+4+4);
5490 data
<< uint8(slot
);
5491 data
<< uint64(pTotem
->GetGUID());
5492 data
<< uint32(duration
);
5493 data
<< uint32(m_spellInfo
->Id
);
5494 ((Player
*)m_caster
)->SendDirectMessage(&data
);
5498 void Spell::EffectEnchantHeldItem(uint32 i
)
5500 // this is only item spell effect applied to main-hand weapon of target player (players in area)
5501 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5504 Player
* item_owner
= (Player
*)unitTarget
;
5505 Item
* item
= item_owner
->GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_MAINHAND
);
5511 if(!item
->IsEquipped())
5514 if (m_spellInfo
->EffectMiscValue
[i
])
5516 uint32 enchant_id
= m_spellInfo
->EffectMiscValue
[i
];
5517 int32 duration
= GetSpellDuration(m_spellInfo
); //Try duration index first ..
5519 duration
= m_currentBasePoints
[i
]+1; //Base points after ..
5521 duration
= 10; //10 seconds for enchants which don't have listed duration
5523 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
5527 // Always go to temp enchantment slot
5528 EnchantmentSlot slot
= TEMP_ENCHANTMENT_SLOT
;
5530 // Enchantment will not be applied if a different one already exists
5531 if(item
->GetEnchantmentId(slot
) && item
->GetEnchantmentId(slot
) != enchant_id
)
5534 // Apply the temporary enchantment
5535 item
->SetEnchantment(slot
, enchant_id
, duration
*IN_MILISECONDS
, 0);
5536 item_owner
->ApplyEnchantment(item
,slot
,true);
5540 void Spell::EffectDisEnchant(uint32
/*i*/)
5542 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5545 Player
* p_caster
= (Player
*)m_caster
;
5546 if(!itemTarget
|| !itemTarget
->GetProto()->DisenchantID
)
5549 p_caster
->UpdateCraftSkill(m_spellInfo
->Id
);
5551 ((Player
*)m_caster
)->SendLoot(itemTarget
->GetGUID(),LOOT_DISENCHANTING
);
5553 // item will be removed at disenchanting end
5556 void Spell::EffectInebriate(uint32
/*i*/)
5558 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5561 Player
*player
= (Player
*)unitTarget
;
5562 uint16 currentDrunk
= player
->GetDrunkValue();
5563 uint16 drunkMod
= damage
* 256;
5564 if (currentDrunk
+ drunkMod
> 0xFFFF)
5565 currentDrunk
= 0xFFFF;
5567 currentDrunk
+= drunkMod
;
5568 player
->SetDrunkValue(currentDrunk
, m_CastItem
?m_CastItem
->GetEntry():0);
5571 void Spell::EffectFeedPet(uint32 i
)
5573 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5576 Player
*_player
= (Player
*)m_caster
;
5578 Item
* foodItem
= m_targets
.getItemTarget();
5582 Pet
*pet
= _player
->GetPet();
5589 int32 benefit
= pet
->GetCurrentFoodBenefitLevel(foodItem
->GetProto()->ItemLevel
);
5594 _player
->DestroyItemCount(foodItem
,count
,true);
5595 // TODO: fix crash when a spell has two effects, both pointed at the same item target
5597 m_caster
->CastCustomSpell(pet
,m_spellInfo
->EffectTriggerSpell
[i
],&benefit
,NULL
,NULL
,true);
5600 void Spell::EffectDismissPet(uint32
/*i*/)
5602 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5605 Pet
* pet
= m_caster
->GetPet();
5607 // not let dismiss dead pet
5608 if(!pet
||!pet
->isAlive())
5611 ((Player
*)m_caster
)->RemovePet(pet
,PET_SAVE_NOT_IN_SLOT
);
5614 void Spell::EffectSummonObject(uint32 i
)
5616 uint32 go_id
= m_spellInfo
->EffectMiscValue
[i
];
5619 switch(m_spellInfo
->Effect
[i
])
5621 case SPELL_EFFECT_SUMMON_OBJECT_SLOT1
: slot
= 0; break;
5622 case SPELL_EFFECT_SUMMON_OBJECT_SLOT2
: slot
= 1; break;
5623 case SPELL_EFFECT_SUMMON_OBJECT_SLOT3
: slot
= 2; break;
5624 case SPELL_EFFECT_SUMMON_OBJECT_SLOT4
: slot
= 3; break;
5628 uint64 guid
= m_caster
->m_ObjectSlot
[slot
];
5631 GameObject
* obj
= NULL
;
5633 obj
= m_caster
->GetMap()->GetGameObject(guid
);
5635 if(obj
) obj
->Delete();
5636 m_caster
->m_ObjectSlot
[slot
] = 0;
5639 GameObject
* pGameObj
= new GameObject
;
5642 // If dest location if present
5643 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
5645 x
= m_targets
.m_destX
;
5646 y
= m_targets
.m_destY
;
5647 z
= m_targets
.m_destZ
;
5649 // Summon in random point all other units if location present
5651 m_caster
->GetClosePoint(x
,y
,z
,DEFAULT_WORLD_OBJECT_SIZE
);
5653 Map
*map
= m_caster
->GetMap();
5654 if(!pGameObj
->Create(objmgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), go_id
, map
,
5655 m_caster
->GetPhaseMask(), x
, y
, z
, m_caster
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0, GO_STATE_READY
))
5661 pGameObj
->SetUInt32Value(GAMEOBJECT_LEVEL
,m_caster
->getLevel());
5662 int32 duration
= GetSpellDuration(m_spellInfo
);
5663 pGameObj
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
5664 pGameObj
->SetSpellId(m_spellInfo
->Id
);
5665 m_caster
->AddGameObject(pGameObj
);
5668 WorldPacket
data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE
, 8);
5669 data
<< pGameObj
->GetGUID();
5670 m_caster
->SendMessageToSet(&data
,true);
5672 m_caster
->m_ObjectSlot
[slot
] = pGameObj
->GetGUID();
5675 void Spell::EffectResurrect(uint32
/*effIndex*/)
5679 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5682 if(unitTarget
->isAlive())
5684 if(!unitTarget
->IsInWorld())
5687 switch (m_spellInfo
->Id
)
5689 // Defibrillate (Goblin Jumper Cables) have 33% chance on success
5691 if (roll_chance_i(67))
5693 m_caster
->CastSpell(m_caster
, 8338, true, m_CastItem
);
5697 // Defibrillate (Goblin Jumper Cables XL) have 50% chance on success
5699 if (roll_chance_i(50))
5701 m_caster
->CastSpell(m_caster
, 23055, true, m_CastItem
);
5709 Player
* pTarget
= ((Player
*)unitTarget
);
5711 if(pTarget
->isRessurectRequested()) // already have one active request
5714 uint32 health
= pTarget
->GetMaxHealth() * damage
/ 100;
5715 uint32 mana
= pTarget
->GetMaxPower(POWER_MANA
) * damage
/ 100;
5717 pTarget
->setResurrectRequestData(m_caster
->GetGUID(), m_caster
->GetMapId(), m_caster
->GetPositionX(), m_caster
->GetPositionY(), m_caster
->GetPositionZ(), health
, mana
);
5718 SendResurrectRequest(pTarget
);
5721 void Spell::EffectAddExtraAttacks(uint32
/*i*/)
5723 if(!unitTarget
|| !unitTarget
->isAlive())
5726 if( unitTarget
->m_extraAttacks
)
5729 unitTarget
->m_extraAttacks
= damage
;
5732 void Spell::EffectParry(uint32
/*i*/)
5734 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
5735 ((Player
*)unitTarget
)->SetCanParry(true);
5738 void Spell::EffectBlock(uint32
/*i*/)
5740 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
5741 ((Player
*)unitTarget
)->SetCanBlock(true);
5744 void Spell::EffectMomentMove(uint32 i
)
5746 if(unitTarget
->isInFlight())
5749 if( m_spellInfo
->rangeIndex
== 1) //self range
5751 float dis
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
5755 unitTarget
->GetClosePoint(fx
,fy
,fz
,unitTarget
->GetObjectSize(),dis
);
5757 unitTarget
->GetPosition(ox
,oy
,oz
);
5759 float fx2
,fy2
,fz2
; // getObjectHitPos overwrite last args in any result case
5760 if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(unitTarget
->GetMapId(), ox
,oy
,oz
+0.5, fx
,fy
,oz
+0.5,fx2
,fy2
,fz2
, -0.5))
5765 unitTarget
->UpdateGroundPositionZ(fx
,fy
,fz
);
5768 unitTarget
->NearTeleportTo(fx
, fy
, fz
, unitTarget
->GetOrientation(),unitTarget
==m_caster
);
5772 void Spell::EffectReputation(uint32 i
)
5774 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5777 Player
*_player
= (Player
*)unitTarget
;
5779 int32 rep_change
= m_currentBasePoints
[i
]+1; // field store reputation change -1
5781 uint32 faction_id
= m_spellInfo
->EffectMiscValue
[i
];
5783 FactionEntry
const* factionEntry
= sFactionStore
.LookupEntry(faction_id
);
5788 _player
->GetReputationMgr().ModifyReputation(factionEntry
,rep_change
);
5791 void Spell::EffectQuestComplete(uint32 i
)
5793 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5796 Player
*_player
= (Player
*)m_caster
;
5798 uint32 quest_id
= m_spellInfo
->EffectMiscValue
[i
];
5799 _player
->AreaExploredOrEventHappens(quest_id
);
5802 void Spell::EffectSelfResurrect(uint32 i
)
5804 if(!unitTarget
|| unitTarget
->isAlive())
5806 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5808 if(!unitTarget
->IsInWorld())
5817 health
= uint32(-damage
);
5818 mana
= m_spellInfo
->EffectMiscValue
[i
];
5823 health
= uint32(damage
/100.0f
*unitTarget
->GetMaxHealth());
5824 if(unitTarget
->GetMaxPower(POWER_MANA
) > 0)
5825 mana
= uint32(damage
/100.0f
*unitTarget
->GetMaxPower(POWER_MANA
));
5828 Player
*plr
= ((Player
*)unitTarget
);
5829 plr
->ResurrectPlayer(0.0f
);
5831 plr
->SetHealth( health
);
5832 plr
->SetPower(POWER_MANA
, mana
);
5833 plr
->SetPower(POWER_RAGE
, 0 );
5834 plr
->SetPower(POWER_ENERGY
, plr
->GetMaxPower(POWER_ENERGY
) );
5836 plr
->SpawnCorpseBones();
5841 void Spell::EffectSkinning(uint32
/*i*/)
5843 if(unitTarget
->GetTypeId() != TYPEID_UNIT
)
5845 if(!m_caster
|| m_caster
->GetTypeId() != TYPEID_PLAYER
)
5848 Creature
* creature
= (Creature
*) unitTarget
;
5849 int32 targetLevel
= creature
->getLevel();
5851 uint32 skill
= creature
->GetCreatureInfo()->GetRequiredLootSkill();
5853 ((Player
*)m_caster
)->SendLoot(creature
->GetGUID(),LOOT_SKINNING
);
5854 creature
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SKINNABLE
);
5856 int32 reqValue
= targetLevel
< 10 ? 0 : targetLevel
< 20 ? (targetLevel
-10)*10 : targetLevel
*5;
5858 int32 skillValue
= ((Player
*)m_caster
)->GetPureSkillValue(skill
);
5860 // Double chances for elites
5861 ((Player
*)m_caster
)->UpdateGatherSkill(skill
, skillValue
, reqValue
, creature
->isElite() ? 2 : 1 );
5864 void Spell::EffectCharge(uint32
/*i*/)
5866 if(!unitTarget
|| !m_caster
)
5870 unitTarget
->GetContactPoint(m_caster
, x
, y
, z
);
5871 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5872 ((Creature
*)unitTarget
)->StopMoving();
5874 // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags
5875 m_caster
->SendMonsterMove(x
, y
, z
, 0, MOVEMENTFLAG_WALK_MODE
, 1);
5877 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5878 m_caster
->GetMap()->CreatureRelocation((Creature
*)m_caster
,x
,y
,z
,m_caster
->GetOrientation());
5880 // not all charge effects used in negative spells
5881 if ( !IsPositiveSpell(m_spellInfo
->Id
))
5882 m_caster
->Attack(unitTarget
,true);
5885 void Spell::EffectSummonCritter(uint32 i
)
5887 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5889 Player
* player
= (Player
*)m_caster
;
5891 uint32 pet_entry
= m_spellInfo
->EffectMiscValue
[i
];
5895 Pet
* old_critter
= player
->GetMiniPet();
5897 // for same pet just despawn
5898 if(old_critter
&& old_critter
->GetEntry() == pet_entry
)
5900 player
->RemoveMiniPet();
5904 // despawn old pet before summon new
5906 player
->RemoveMiniPet();
5909 Pet
* critter
= new Pet(MINI_PET
);
5911 Map
*map
= m_caster
->GetMap();
5912 uint32 pet_number
= objmgr
.GeneratePetNumber();
5913 if(!critter
->Create(objmgr
.GenerateLowGuid(HIGHGUID_PET
), map
, m_caster
->GetPhaseMask(),
5914 pet_entry
, pet_number
))
5916 sLog
.outError("Spell::EffectSummonCritter, spellid %u: no such creature entry %u", m_spellInfo
->Id
, pet_entry
);
5922 // If dest location if present
5923 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
5925 x
= m_targets
.m_destX
;
5926 y
= m_targets
.m_destY
;
5927 z
= m_targets
.m_destZ
;
5929 // Summon if dest location not present near caster
5931 m_caster
->GetClosePoint(x
,y
,z
,critter
->GetObjectSize());
5933 critter
->Relocate(x
,y
,z
,m_caster
->GetOrientation());
5935 if(!critter
->IsPositionValid())
5937 sLog
.outError("Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
5938 critter
->GetGUIDLow(), critter
->GetEntry(), critter
->GetPositionX(), critter
->GetPositionY());
5943 critter
->SetOwnerGUID(m_caster
->GetGUID());
5944 critter
->SetCreatorGUID(m_caster
->GetGUID());
5945 critter
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,m_caster
->getFaction());
5946 critter
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
5948 critter
->AIM_Initialize();
5949 critter
->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as critter...
5950 critter
->SetMaxHealth(1);
5951 critter
->SetHealth(1);
5952 critter
->SetLevel(1);
5954 // set timer for unsummon
5955 int32 duration
= GetSpellDuration(m_spellInfo
);
5957 critter
->SetDuration(duration
);
5959 std::string name
= player
->GetName();
5960 name
.append(petTypeSuffix
[critter
->getPetType()]);
5961 critter
->SetName( name
);
5962 player
->SetMiniPet(critter
);
5964 map
->Add((Creature
*)critter
);
5967 void Spell::EffectKnockBack(uint32 i
)
5969 if(!unitTarget
|| !m_caster
)
5972 // Effect only works on players
5973 if(unitTarget
->GetTypeId()!=TYPEID_PLAYER
)
5976 float vsin
= sin(m_caster
->GetAngle(unitTarget
));
5977 float vcos
= cos(m_caster
->GetAngle(unitTarget
));
5979 WorldPacket
data(SMSG_MOVE_KNOCK_BACK
, (8+4+4+4+4+4));
5980 data
.append(unitTarget
->GetPackGUID());
5981 data
<< uint32(0); // Sequence
5982 data
<< float(vcos
); // x direction
5983 data
<< float(vsin
); // y direction
5984 data
<< float(m_spellInfo
->EffectMiscValue
[i
])/10; // Horizontal speed
5985 data
<< float(damage
/-10); // Z Movement speed (vertical)
5987 ((Player
*)unitTarget
)->GetSession()->SendPacket(&data
);
5990 void Spell::EffectSendTaxi(uint32 i
)
5992 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5995 TaxiPathEntry
const* entry
= sTaxiPathStore
.LookupEntry(m_spellInfo
->EffectMiscValue
[i
]);
5999 std::vector
<uint32
> nodes
;
6002 nodes
[0] = entry
->from
;
6003 nodes
[1] = entry
->to
;
6006 switch(m_spellInfo
->Id
)
6008 case 31606: //Stormcrow Amulet
6011 case 45071: //Quest - Sunwell Daily - Dead Scar Bombing Run
6012 case 45113: //Quest - Sunwell Daily - Ship Bombing Run
6013 case 45353: //Quest - Sunwell Daily - Ship Bombing Run Return
6016 case 34905: //Stealth Flight
6019 case 45883: //Amber Ledge to Beryl Point
6022 case 46064: //Amber Ledge to Coldarra
6025 case 53335: //Stormwind Harbor Flight - Peaceful
6030 ((Player
*)unitTarget
)->ActivateTaxiPathTo(nodes
,mountid
);
6034 void Spell::EffectPlayerPull(uint32 i
)
6036 if(!unitTarget
|| !m_caster
)
6039 // Effect only works on players
6040 if(unitTarget
->GetTypeId()!=TYPEID_PLAYER
)
6043 float vsin
= sin(unitTarget
->GetAngle(m_caster
));
6044 float vcos
= cos(unitTarget
->GetAngle(m_caster
));
6046 WorldPacket
data(SMSG_MOVE_KNOCK_BACK
, (8+4+4+4+4+4));
6047 data
.append(unitTarget
->GetPackGUID());
6048 data
<< uint32(0); // Sequence
6049 data
<< float(vcos
); // x direction
6050 data
<< float(vsin
); // y direction
6052 data
<< float(damage
? damage
: unitTarget
->GetDistance2d(m_caster
));
6053 data
<< float(m_spellInfo
->EffectMiscValue
[i
])/-10; // Z Movement speed
6055 ((Player
*)unitTarget
)->GetSession()->SendPacket(&data
);
6058 void Spell::EffectDispelMechanic(uint32 i
)
6063 uint32 mechanic
= m_spellInfo
->EffectMiscValue
[i
];
6065 Unit::AuraMap
& Auras
= unitTarget
->GetAuras();
6066 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
6070 SpellEntry
const *spell
= sSpellStore
.LookupEntry(iter
->second
->GetSpellProto()->Id
);
6071 if(spell
->Mechanic
== mechanic
|| spell
->EffectMechanic
[iter
->second
->GetEffIndex()] == mechanic
)
6073 unitTarget
->RemoveAurasDueToSpell(spell
->Id
);
6077 next
= Auras
.begin();
6083 void Spell::EffectSummonDeadPet(uint32
/*i*/)
6085 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6087 Player
*_player
= (Player
*)m_caster
;
6088 Pet
*pet
= _player
->GetPet();
6095 pet
->SetUInt32Value(UNIT_DYNAMIC_FLAGS
, 0);
6096 pet
->RemoveFlag (UNIT_FIELD_FLAGS
, UNIT_FLAG_SKINNABLE
);
6097 pet
->setDeathState( ALIVE
);
6098 pet
->clearUnitState(UNIT_STAT_ALL_STATE
);
6099 pet
->SetHealth( uint32(pet
->GetMaxHealth()*(float(damage
)/100)));
6101 pet
->AIM_Initialize();
6103 _player
->PetSpellInitialize();
6104 pet
->SavePetToDB(PET_SAVE_AS_CURRENT
);
6107 void Spell::EffectDestroyAllTotems(uint32
/*i*/)
6110 for(int slot
= 0; slot
< MAX_TOTEM
; ++slot
)
6112 if(!m_caster
->m_TotemSlot
[slot
])
6115 Creature
* totem
= m_caster
->GetMap()->GetCreature(m_caster
->m_TotemSlot
[slot
]);
6116 if(totem
&& totem
->isTotem())
6118 uint32 spell_id
= totem
->GetUInt32Value(UNIT_CREATED_BY_SPELL
);
6119 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell_id
);
6121 mana
+= spellInfo
->manaCost
* damage
/ 100;
6122 ((Totem
*)totem
)->UnSummon();
6126 int32 gain
= m_caster
->ModifyPower(POWER_MANA
,int32(mana
));
6127 m_caster
->SendEnergizeSpellLog(m_caster
, m_spellInfo
->Id
, gain
, POWER_MANA
);
6130 void Spell::EffectDurabilityDamage(uint32 i
)
6132 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6135 int32 slot
= m_spellInfo
->EffectMiscValue
[i
];
6137 // FIXME: some spells effects have value -1/-2
6138 // Possibly its mean -1 all player equipped items and -2 all items
6141 ((Player
*)unitTarget
)->DurabilityPointsLossAll(damage
,(slot
< -1));
6145 // invalid slot value
6146 if(slot
>= INVENTORY_SLOT_BAG_END
)
6149 if(Item
* item
= ((Player
*)unitTarget
)->GetItemByPos(INVENTORY_SLOT_BAG_0
,slot
))
6150 ((Player
*)unitTarget
)->DurabilityPointsLoss(item
,damage
);
6153 void Spell::EffectDurabilityDamagePCT(uint32 i
)
6155 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6158 int32 slot
= m_spellInfo
->EffectMiscValue
[i
];
6160 // FIXME: some spells effects have value -1/-2
6161 // Possibly its mean -1 all player equipped items and -2 all items
6164 ((Player
*)unitTarget
)->DurabilityLossAll(double(damage
)/100.0f
,(slot
< -1));
6168 // invalid slot value
6169 if(slot
>= INVENTORY_SLOT_BAG_END
)
6175 if(Item
* item
= ((Player
*)unitTarget
)->GetItemByPos(INVENTORY_SLOT_BAG_0
,slot
))
6176 ((Player
*)unitTarget
)->DurabilityLoss(item
,double(damage
)/100.0f
);
6179 void Spell::EffectModifyThreatPercent(uint32
/*effIndex*/)
6184 unitTarget
->getThreatManager().modifyThreatPercent(m_caster
, damage
);
6187 void Spell::EffectTransmitted(uint32 effIndex
)
6189 uint32 name_id
= m_spellInfo
->EffectMiscValue
[effIndex
];
6191 GameObjectInfo
const* goinfo
= objmgr
.GetGameObjectInfo(name_id
);
6195 sLog
.outErrorDb("Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast",name_id
, m_spellInfo
->Id
);
6201 if(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
6203 fx
= m_targets
.m_destX
;
6204 fy
= m_targets
.m_destY
;
6205 fz
= m_targets
.m_destZ
;
6207 //FIXME: this can be better check for most objects but still hack
6208 else if(m_spellInfo
->EffectRadiusIndex
[effIndex
] && m_spellInfo
->speed
==0)
6210 float dis
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[effIndex
]));
6211 m_caster
->GetClosePoint(fx
,fy
,fz
,DEFAULT_WORLD_OBJECT_SIZE
, dis
);
6215 float min_dis
= GetSpellMinRange(sSpellRangeStore
.LookupEntry(m_spellInfo
->rangeIndex
));
6216 float max_dis
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(m_spellInfo
->rangeIndex
));
6217 float dis
= rand_norm() * (max_dis
- min_dis
) + min_dis
;
6219 m_caster
->GetClosePoint(fx
,fy
,fz
,DEFAULT_WORLD_OBJECT_SIZE
, dis
);
6222 Map
*cMap
= m_caster
->GetMap();
6224 if(goinfo
->type
==GAMEOBJECT_TYPE_FISHINGNODE
)
6226 if ( !cMap
->IsInWater(fx
,fy
,fz
-0.5f
)) // Hack to prevent fishing bobber from failing to land on fishing hole
6227 { // but this is not proper, we really need to ignore not materialized objects
6228 SendCastResult(SPELL_FAILED_NOT_HERE
);
6229 SendChannelUpdate(0);
6233 // replace by water level in this case
6234 fz
= cMap
->GetWaterLevel(fx
,fy
);
6236 // if gameobject is summoning object, it should be spawned right on caster's position
6237 else if(goinfo
->type
==GAMEOBJECT_TYPE_SUMMONING_RITUAL
)
6239 m_caster
->GetPosition(fx
,fy
,fz
);
6242 GameObject
* pGameObj
= new GameObject
;
6244 if(!pGameObj
->Create(objmgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), name_id
, cMap
,
6245 m_caster
->GetPhaseMask(), fx
, fy
, fz
, m_caster
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
6251 int32 duration
= GetSpellDuration(m_spellInfo
);
6253 switch(goinfo
->type
)
6255 case GAMEOBJECT_TYPE_FISHINGNODE
:
6257 m_caster
->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT
,pGameObj
->GetGUID());
6258 m_caster
->AddGameObject(pGameObj
); // will removed at spell cancel
6260 // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
6261 // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME)
6265 case 0: lastSec
= 3; break;
6266 case 1: lastSec
= 7; break;
6267 case 2: lastSec
= 13; break;
6268 case 3: lastSec
= 17; break;
6271 duration
= duration
- lastSec
*IN_MILISECONDS
+ FISHING_BOBBER_READY_TIME
*IN_MILISECONDS
;
6274 case GAMEOBJECT_TYPE_SUMMONING_RITUAL
:
6276 if(m_caster
->GetTypeId()==TYPEID_PLAYER
)
6278 pGameObj
->AddUniqueUse((Player
*)m_caster
);
6279 m_caster
->AddGameObject(pGameObj
); // will removed at spell cancel
6283 case GAMEOBJECT_TYPE_FISHINGHOLE
:
6284 case GAMEOBJECT_TYPE_CHEST
:
6291 pGameObj
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
6293 pGameObj
->SetOwnerGUID(m_caster
->GetGUID() );
6295 pGameObj
->SetUInt32Value(GAMEOBJECT_LEVEL
, m_caster
->getLevel() );
6296 pGameObj
->SetSpellId(m_spellInfo
->Id
);
6298 DEBUG_LOG("AddObject at SpellEfects.cpp EffectTransmitted");
6299 //m_caster->AddGameObject(pGameObj);
6300 //m_ObjToDel.push_back(pGameObj);
6302 cMap
->Add(pGameObj
);
6304 WorldPacket
data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE
, 8);
6305 data
<< uint64(pGameObj
->GetGUID());
6306 m_caster
->SendMessageToSet(&data
,true);
6308 if(uint32 linkedEntry
= pGameObj
->GetLinkedGameObjectEntry())
6310 GameObject
* linkedGO
= new GameObject
;
6311 if(linkedGO
->Create(objmgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), linkedEntry
, cMap
,
6312 m_caster
->GetPhaseMask(), fx
, fy
, fz
, m_caster
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
6314 linkedGO
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
6315 linkedGO
->SetUInt32Value(GAMEOBJECT_LEVEL
, m_caster
->getLevel() );
6316 linkedGO
->SetSpellId(m_spellInfo
->Id
);
6317 linkedGO
->SetOwnerGUID(m_caster
->GetGUID() );
6319 linkedGO
->GetMap()->Add(linkedGO
);
6330 void Spell::EffectProspecting(uint32
/*i*/)
6332 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6335 Player
* p_caster
= (Player
*)m_caster
;
6336 if(!itemTarget
|| !(itemTarget
->GetProto()->BagFamily
& BAG_FAMILY_MASK_MINING_SUPP
))
6339 if(itemTarget
->GetCount() < 5)
6342 if( sWorld
.getConfig(CONFIG_SKILL_PROSPECTING
))
6344 uint32 SkillValue
= p_caster
->GetPureSkillValue(SKILL_JEWELCRAFTING
);
6345 uint32 reqSkillValue
= itemTarget
->GetProto()->RequiredSkillRank
;
6346 p_caster
->UpdateGatherSkill(SKILL_JEWELCRAFTING
, SkillValue
, reqSkillValue
);
6349 ((Player
*)m_caster
)->SendLoot(itemTarget
->GetGUID(), LOOT_PROSPECTING
);
6352 void Spell::EffectMilling(uint32
/*i*/)
6354 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6357 Player
* p_caster
= (Player
*)m_caster
;
6358 if(!itemTarget
|| !(itemTarget
->GetProto()->BagFamily
& BAG_FAMILY_MASK_HERBS
))
6361 if(itemTarget
->GetCount() < 5)
6364 if( sWorld
.getConfig(CONFIG_SKILL_MILLING
))
6366 uint32 SkillValue
= p_caster
->GetPureSkillValue(SKILL_INSCRIPTION
);
6367 uint32 reqSkillValue
= itemTarget
->GetProto()->RequiredSkillRank
;
6368 p_caster
->UpdateGatherSkill(SKILL_INSCRIPTION
, SkillValue
, reqSkillValue
);
6371 ((Player
*)m_caster
)->SendLoot(itemTarget
->GetGUID(), LOOT_MILLING
);
6374 void Spell::EffectSkill(uint32
/*i*/)
6376 sLog
.outDebug("WORLD: SkillEFFECT");
6379 void Spell::EffectSummonDemon(uint32 i
)
6381 // select center of summon position
6382 float center_x
= m_targets
.m_destX
;
6383 float center_y
= m_targets
.m_destY
;
6384 float center_z
= m_targets
.m_destZ
;
6386 float radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
6388 int32 amount
= damage
> 0 ? damage
: 1;
6390 for(int32 count
= 0; count
< amount
; ++count
)
6393 // If dest location if present
6394 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
6396 // Summon 1 unit in dest location
6399 px
= m_targets
.m_destX
;
6400 py
= m_targets
.m_destY
;
6401 pz
= m_targets
.m_destZ
;
6403 // Summon in random point all other units if location present
6405 m_caster
->GetRandomPoint(center_x
,center_y
,center_z
,radius
,px
,py
,pz
);
6407 // Summon if dest location not present near caster
6409 m_caster
->GetClosePoint(px
,py
,pz
,3.0f
);
6411 int32 duration
= GetSpellDuration(m_spellInfo
);
6413 Creature
* Charmed
= m_caster
->SummonCreature(m_spellInfo
->EffectMiscValue
[i
], px
, py
, pz
, m_caster
->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
,duration
);
6414 if (!Charmed
) // something fatal, not attempt more
6417 // might not always work correctly, maybe the creature that dies from CoD casts the effect on itself and is therefore the caster?
6418 Charmed
->SetLevel(m_caster
->getLevel());
6420 // TODO: Add damage/mana/hp according to level
6422 if (m_spellInfo
->EffectMiscValue
[i
] == 89) // Inferno summon
6424 // Enslave demon effect, without mana cost and cooldown
6425 m_caster
->CastSpell(Charmed
, 20882, true); // FIXME: enslave does not scale with level, level 62+ minions cannot be enslaved
6428 Charmed
->CastSpell(Charmed
, 22703, true, 0);
6433 /* There is currently no need for this effect. We handle it in BattleGround.cpp
6434 If we would handle the resurrection here, the spiritguide would instantly disappear as the
6435 player revives, and so we wouldn't see the spirit heal visual effect on the npc.
6436 This is why we use a half sec delay between the visual effect and the resurrection itself */
6437 void Spell::EffectSpiritHeal(uint32
/*i*/)
6440 if(!unitTarget || unitTarget->isAlive())
6442 if(unitTarget->GetTypeId() != TYPEID_PLAYER)
6444 if(!unitTarget->IsInWorld())
6447 //m_spellInfo->EffectBasePoints[i]; == 99 (percent?)
6448 //((Player*)unitTarget)->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA));
6449 ((Player*)unitTarget)->ResurrectPlayer(1.0f);
6450 ((Player*)unitTarget)->SpawnCorpseBones();
6454 // remove insignia spell effect
6455 void Spell::EffectSkinPlayerCorpse(uint32
/*i*/)
6457 sLog
.outDebug("Effect: SkinPlayerCorpse");
6458 if ( (m_caster
->GetTypeId() != TYPEID_PLAYER
) || (unitTarget
->GetTypeId() != TYPEID_PLAYER
) || (unitTarget
->isAlive()) )
6461 ((Player
*)unitTarget
)->RemovedInsignia( (Player
*)m_caster
);
6464 void Spell::EffectStealBeneficialBuff(uint32 i
)
6466 sLog
.outDebug("Effect: StealBeneficialBuff");
6468 if(!unitTarget
|| unitTarget
==m_caster
) // can't steal from self
6471 std::vector
<Aura
*> steal_list
;
6472 // Create dispel mask by dispel type
6473 uint32 dispelMask
= GetDispellMask( DispelType(m_spellInfo
->EffectMiscValue
[i
]) );
6474 Unit::AuraMap
const& auras
= unitTarget
->GetAuras();
6475 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
6477 Aura
*aur
= (*itr
).second
;
6478 if (aur
&& (1<<aur
->GetSpellProto()->Dispel
) & dispelMask
)
6480 // Need check for passive? this
6481 if (aur
->IsPositive() && !aur
->IsPassive() && !(aur
->GetSpellProto()->AttributesEx4
& SPELL_ATTR_EX4_NOT_STEALABLE
))
6482 steal_list
.push_back(aur
);
6485 // Ok if exist some buffs for dispel try dispel it
6486 if (!steal_list
.empty())
6488 std::list
< std::pair
<uint32
,uint64
> > success_list
;
6489 int32 list_size
= steal_list
.size();
6490 // Dispell N = damage buffs (or while exist buffs for dispel)
6491 for (int32 count
=0; count
< damage
&& list_size
> 0; ++count
)
6493 // Random select buff for dispel
6494 Aura
*aur
= steal_list
[urand(0, list_size
-1)];
6495 // Not use chance for steal
6496 // TODO possible need do it
6497 success_list
.push_back( std::pair
<uint32
,uint64
>(aur
->GetId(),aur
->GetCasterGUID()));
6499 // Remove buff from list for prevent doubles
6500 for (std::vector
<Aura
*>::iterator j
= steal_list
.begin(); j
!= steal_list
.end(); )
6503 if (stealed
->GetId() == aur
->GetId() && stealed
->GetCasterGUID() == aur
->GetCasterGUID())
6505 j
= steal_list
.erase(j
);
6512 // Really try steal and send log
6513 if (!success_list
.empty())
6515 int32 count
= success_list
.size();
6516 WorldPacket
data(SMSG_SPELLSTEALLOG
, 8+8+4+1+4+count
*5);
6517 data
.append(unitTarget
->GetPackGUID()); // Victim GUID
6518 data
.append(m_caster
->GetPackGUID()); // Caster GUID
6519 data
<< uint32(m_spellInfo
->Id
); // Dispell spell id
6520 data
<< uint8(0); // not used
6521 data
<< uint32(count
); // count
6522 for (std::list
<std::pair
<uint32
,uint64
> >::iterator j
= success_list
.begin(); j
!= success_list
.end(); ++j
)
6524 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(j
->first
);
6525 data
<< uint32(spellInfo
->Id
); // Spell Id
6526 data
<< uint8(0); // 0 - steals !=0 transfers
6527 unitTarget
->RemoveAurasDueToSpellBySteal(spellInfo
->Id
, j
->second
, m_caster
);
6529 m_caster
->SendMessageToSet(&data
, true);
6534 void Spell::EffectKillCredit(uint32 i
)
6536 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6539 ((Player
*)unitTarget
)->RewardPlayerAndGroupAtEvent(m_spellInfo
->EffectMiscValue
[i
], unitTarget
);
6542 void Spell::EffectQuestFail(uint32 i
)
6544 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6547 ((Player
*)unitTarget
)->FailQuest(m_spellInfo
->EffectMiscValue
[i
]);
6550 void Spell::EffectActivateRune(uint32 eff_idx
)
6552 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6555 Player
*plr
= (Player
*)m_caster
;
6557 if(plr
->getClass() != CLASS_DEATH_KNIGHT
)
6560 for(uint32 j
= 0; j
< MAX_RUNES
; ++j
)
6562 if(plr
->GetRuneCooldown(j
) && plr
->GetCurrentRune(j
) == m_spellInfo
->EffectMiscValue
[eff_idx
])
6564 plr
->SetRuneCooldown(j
, 0);
6569 void Spell::EffectTitanGrip(uint32
/*eff_idx*/)
6571 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
6572 ((Player
*)unitTarget
)->SetCanTitanGrip(true);
6575 void Spell::EffectRenamePet(uint32
/*eff_idx*/)
6577 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
||
6578 !((Creature
*)unitTarget
)->isPet() || ((Pet
*)unitTarget
)->getPetType() != HUNTER_PET
)
6581 unitTarget
->SetByteValue(UNIT_FIELD_BYTES_2
, 2, UNIT_RENAME_ALLOWED
);