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::EffectLeapForward
, // 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::EffectCreateRandomItem
, // 59 SPELL_EFFECT_CREATE_RANDOM_ITEM create item base at spell specific loot
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::EffectKillCreditPersonal
, // 90 SPELL_EFFECT_KILL_CREDIT Kill credit but only for single person
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::EffectPlayMusic
, //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::EffectLeapBack
, //138 SPELL_EFFECT_LEAP_BACK Leap back
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::EffectCharge2
, //149 SPELL_EFFECT_CHARGE2 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 item or create item template and replace by some randon spell loot item
218 &Spell::EffectMilling
, //158 SPELL_EFFECT_MILLING milling
219 &Spell::EffectRenamePet
, //159 SPELL_EFFECT_ALLOW_RENAME_PET allow rename pet once again
220 &Spell::EffectNULL
, //160 SPELL_EFFECT_160 unused
221 &Spell::EffectNULL
, //161 SPELL_EFFECT_TALENT_SPEC_COUNT second talent spec (learn/revert)
222 &Spell::EffectNULL
, //162 SPELL_EFFECT_TALENT_SPEC_SELECT activate primary/secondary spec
225 void Spell::EffectNULL(uint32
/*i*/)
227 sLog
.outDebug("WORLD: Spell Effect DUMMY");
230 void Spell::EffectUnused(uint32
/*i*/)
232 // NOT USED BY ANY SPELL OR USELESS OR IMPLEMENTED IN DIFFERENT WAY IN MANGOS
235 void Spell::EffectResurrectNew(uint32 i
)
237 if(!unitTarget
|| unitTarget
->isAlive())
240 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
243 if(!unitTarget
->IsInWorld())
246 Player
* pTarget
= ((Player
*)unitTarget
);
248 if(pTarget
->isRessurectRequested()) // already have one active request
251 uint32 health
= damage
;
252 uint32 mana
= m_spellInfo
->EffectMiscValue
[i
];
253 pTarget
->setResurrectRequestData(m_caster
->GetGUID(), m_caster
->GetMapId(), m_caster
->GetPositionX(), m_caster
->GetPositionY(), m_caster
->GetPositionZ(), health
, mana
);
254 SendResurrectRequest(pTarget
);
257 void Spell::EffectInstaKill(uint32
/*i*/)
259 if( !unitTarget
|| !unitTarget
->isAlive() )
263 if(m_spellInfo
->Id
==18788 && unitTarget
->GetTypeId()==TYPEID_UNIT
)
265 uint32 entry
= unitTarget
->GetEntry();
269 case 416: spellID
=18789; break; //imp
270 case 417: spellID
=18792; break; //fellhunter
271 case 1860: spellID
=18790; break; //void
272 case 1863: spellID
=18791; break; //succubus
273 case 17252: spellID
=35701; break; //fellguard
275 sLog
.outError("EffectInstaKill: Unhandled creature entry (%u) case.", entry
);
279 m_caster
->CastSpell(m_caster
, spellID
, true);
282 if(m_caster
== unitTarget
) // prevent interrupt message
285 m_caster
->DealDamage(unitTarget
, unitTarget
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
288 void Spell::EffectEnvirinmentalDMG(uint32 i
)
293 // Note: this hack with damage replace required until GO casting not implemented
294 // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support
295 // currently each enemy selected explicitly and self cast damage, we prevent apply self casted spell bonuses/etc
296 damage
= m_spellInfo
->CalculateSimpleValue(i
);
298 m_caster
->CalcAbsorbResist(m_caster
, GetSpellSchoolMask(m_spellInfo
), SPELL_DIRECT_DAMAGE
, damage
, &absorb
, &resist
);
300 m_caster
->SendSpellNonMeleeDamageLog(m_caster
, m_spellInfo
->Id
, damage
, GetSpellSchoolMask(m_spellInfo
), absorb
, resist
, false, 0, false);
301 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
302 ((Player
*)m_caster
)->EnvironmentalDamage(DAMAGE_FIRE
, damage
);
305 void Spell::EffectSchoolDMG(uint32 effect_idx
)
307 if( unitTarget
&& unitTarget
->isAlive())
309 switch(m_spellInfo
->SpellFamilyName
)
311 case SPELLFAMILY_GENERIC
:
313 switch(m_spellInfo
->Id
) // better way to check unknown
315 // Meteor like spells (divided damage to targets)
316 case 24340: case 26558: case 28884: // Meteor
317 case 36837: case 38903: case 41276: // Meteor
318 case 26789: // Shard of the Fallen Star
319 case 31436: // Malevolent Cleave
320 case 35181: // Dive Bomb
321 case 40810: case 43267: case 43268: // Saber Lash
322 case 42384: // Brutal Swipe
323 case 45150: // Meteor Slash
324 case 64422: case 64688: // Sonic Screech
327 for(std::list
<TargetInfo
>::iterator ihit
= m_UniqueTargetInfo
.begin();ihit
!= m_UniqueTargetInfo
.end();++ihit
)
328 if(ihit
->effectMask
& (1<<effect_idx
))
331 damage
/= count
; // divide to all targets
334 // percent from health with min
335 case 25599: // Thundercrash
337 damage
= unitTarget
->GetHealth() / 2;
342 // Intercept (warrior spell trigger)
346 damage
+= uint32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.12f
);
352 damage
= unitTarget
->GetMaxHealth() / 2;
358 damage
= unitTarget
->GetMaxHealth() / 10;
361 // Hand of Rekoning (name not have typos ;) )
363 damage
+= uint32(0.5f
* m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
));
368 case SPELLFAMILY_MAGE
:
369 // remove Arcane Blast buffs at any non-Arcane Blast arcane damage spell.
370 // NOTE: it removed at hit instead cast because currently spell done-damage calculated at hit instead cast
371 if ((m_spellInfo
->SchoolMask
& SPELL_SCHOOL_MASK_ARCANE
) && !(m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x20000000)))
372 m_caster
->RemoveAurasDueToSpell(36032); // Arcane Blast buff
374 case SPELLFAMILY_WARRIOR
:
377 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x40000000000))
379 damage
= uint32(damage
* (m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)) / 100);
382 else if ((m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000020000000000)) && m_spellInfo
->Category
==1209)
383 damage
+= int32(m_caster
->GetShieldBlockValue());
385 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x10000000000))
387 damage
= uint32(damage
* m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
388 m_caster
->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH
, false);
390 // Revenge ${$m1+$AP*0.207} to ${$M1+$AP*0.207}
391 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000000400))
392 damage
+= uint32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.207f
);
393 // Heroic Throw ${$m1+$AP*.50}
394 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000100000000))
395 damage
+= uint32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.5f
);
396 // Shockwave ${$m3/100*$AP}
397 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000800000000000))
399 int32 pct
= m_caster
->CalculateSpellDamage(m_spellInfo
, 2, m_spellInfo
->EffectBasePoints
[2], unitTarget
);
401 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * pct
/ 100);
405 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000000080))
407 damage
+=int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 12 / 100);
411 case SPELLFAMILY_WARLOCK
:
413 // Incinerate Rank 1 & 2
414 if ((m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x00004000000000)) && m_spellInfo
->SpellIconID
==2128)
416 // Incinerate does more dmg (dmg*0.25) if the target have Immolate debuff.
417 // Check aura state for speed but aura state set not only for Immolate spell
418 if(unitTarget
->HasAuraState(AURA_STATE_CONFLAGRATE
))
420 Unit::AuraList
const& RejorRegr
= unitTarget
->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE
);
421 for(Unit::AuraList::const_iterator i
= RejorRegr
.begin(); i
!= RejorRegr
.end(); ++i
)
424 if((*i
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_WARLOCK
&&
425 ((*i
)->GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x00000000000004)))
434 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0001000000000000))
437 switch(m_spellInfo
->Id
)
439 case 47897: m_caster
->CastSpell(unitTarget
, 47960, true); break;
440 case 61290: m_caster
->CastSpell(unitTarget
, 61291, true); break;
442 sLog
.outError("Spell::EffectDummy: Unhandeled Shadowflame spell rank %u",m_spellInfo
->Id
);
446 // Conflagrate - consumes Immolate or Shadowflame
447 else if (m_spellInfo
->TargetAuraState
== AURA_STATE_CONFLAGRATE
)
449 Aura
const* aura
= NULL
; // found req. aura for damage calculation
451 Unit::AuraList
const &mPeriodic
= unitTarget
->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE
);
452 for(Unit::AuraList::const_iterator i
= mPeriodic
.begin(); i
!= mPeriodic
.end(); ++i
)
454 // for caster applied auras only
455 if ((*i
)->GetSpellProto()->SpellFamilyName
!= SPELLFAMILY_WARLOCK
||
456 (*i
)->GetCasterGUID()!=m_caster
->GetGUID())
460 if ((*i
)->GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000004))
462 aura
= *i
; // it selected always if exist
467 if ((*i
)->GetSpellProto()->SpellFamilyFlags2
& 0x00000002)
468 aura
= *i
; // remember but wait possible Immolate as primary priority
471 // found Immolate or Shadowflame
474 // DoT not have applied spell bonuses in m_amount
475 int32 damagetick
= m_caster
->SpellDamageBonus(unitTarget
, aura
->GetSpellProto(), aura
->GetModifier()->m_amount
, DOT
);
476 damage
+= damagetick
* 4;
478 // Glyph of Conflagrate
479 if (!m_caster
->HasAura(56235))
480 unitTarget
->RemoveAurasByCasterSpell(aura
->GetId(), m_caster
->GetGUID());
486 case SPELLFAMILY_PRIEST
:
488 // Shadow Word: Death - deals damage equal to damage done to caster
489 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000200000000))
490 m_caster
->CastCustomSpell(m_caster
, 32409, &damage
, 0, 0, true);
491 // Improved Mind Blast (Mind Blast in shadow form bonus)
492 else if (m_caster
->m_form
== FORM_SHADOW
&& (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x00002000)))
494 Unit::AuraList
const& ImprMindBlast
= m_caster
->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER
);
495 for(Unit::AuraList::const_iterator i
= ImprMindBlast
.begin(); i
!= ImprMindBlast
.end(); ++i
)
497 if ((*i
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_PRIEST
&&
498 ((*i
)->GetSpellProto()->SpellIconID
== 95))
500 int chance
= (*i
)->GetSpellProto()->CalculateSimpleValue(1);
501 if (roll_chance_i(chance
))
503 m_caster
->CastSpell(unitTarget
, 48301, true, 0);
510 case SPELLFAMILY_DRUID
:
513 if (m_caster
->GetTypeId()==TYPEID_PLAYER
&& (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x000800000)) && m_spellInfo
->SpellVisual
[0]==6587)
515 // converts up to 30 points of energy into ($f1+$AP/410) additional damage
516 float ap
= m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
517 float multiple
= ap
/ 410 + m_spellInfo
->DmgMultiplier
[effect_idx
];
518 damage
+= int32(((Player
*)m_caster
)->GetComboPoints() * ap
* 7 / 100);
519 uint32 energy
= m_caster
->GetPower(POWER_ENERGY
);
520 uint32 used_energy
= energy
> 30 ? 30 : energy
;
521 damage
+= int32(used_energy
* multiple
);
522 m_caster
->SetPower(POWER_ENERGY
,energy
-used_energy
);
525 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000001000) && m_spellInfo
->Effect
[2]==SPELL_EFFECT_ADD_COMBO_POINTS
)
528 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
531 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0010000000000000))
533 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.08f
);
537 case SPELLFAMILY_ROGUE
:
540 if (m_caster
->GetTypeId()==TYPEID_PLAYER
&& (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x800000000)))
542 // consume from stack dozes not more that have combo-points
543 if(uint32 combo
= ((Player
*)m_caster
)->GetComboPoints())
546 // Lookup for Deadly poison (only attacker applied)
547 Unit::AuraList
const& auras
= unitTarget
->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE
);
548 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
549 if( (*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_ROGUE
&&
550 ((*itr
)->GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x10000)) &&
551 (*itr
)->GetCasterGUID()==m_caster
->GetGUID() )
556 // count consumed deadly poison doses at target
559 uint32 spellId
= poison
->GetId();
560 uint32 doses
= poison
->GetStackAmount();
563 for (int i
=0; i
< doses
; i
++)
564 unitTarget
->RemoveSingleSpellAurasFromStack(spellId
);
566 damage
+= int32(((Player
*)m_caster
)->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.09f
* doses
);
568 // Eviscerate and Envenom Bonus Damage (item set effect)
569 if(m_caster
->GetDummyAura(37169))
570 damage
+= ((Player
*)m_caster
)->GetComboPoints()*40;
574 else if ((m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x00020000)) && m_caster
->GetTypeId()==TYPEID_PLAYER
)
576 if(uint32 combo
= ((Player
*)m_caster
)->GetComboPoints())
578 float ap
= m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
579 damage
+= irand(int32(ap
* combo
* 0.03f
), int32(ap
* combo
* 0.07f
));
581 // Eviscerate and Envenom Bonus Damage (item set effect)
582 if(m_caster
->GetDummyAura(37169))
587 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000000008))
589 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.21f
);
592 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000002000))
594 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.10f
);
597 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000010000000))
599 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.04f
);
603 case SPELLFAMILY_HUNTER
:
606 if (m_spellInfo
->SpellIconID
== 1578)
608 if (m_caster
->HasAura(57627)) // Charge 6 sec post-affect
612 else if ((m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x000000002)) && m_spellInfo
->SpellVisual
[0]==342)
614 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.2f
);
617 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0008000000000000))
619 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.2f
);
622 else if ((m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x00000800)) && m_spellInfo
->maxLevel
> 0)
624 damage
+= int32(m_caster
->GetTotalAttackPowerValue(RANGED_ATTACK
)*0.15f
);
627 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x100000000))
629 int32 base
= irand((int32
)m_caster
->GetWeaponDamageRange(RANGED_ATTACK
, MINDAMAGE
),(int32
)m_caster
->GetWeaponDamageRange(RANGED_ATTACK
, MAXDAMAGE
));
630 damage
+= int32(float(base
)/m_caster
->GetAttackTime(RANGED_ATTACK
)*2800 + m_caster
->GetTotalAttackPowerValue(RANGED_ATTACK
)*0.1f
);
632 // Explosive Trap Effect
633 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x00000004))
635 damage
+= int32(m_caster
->GetTotalAttackPowerValue(RANGED_ATTACK
)*0.1f
);
639 case SPELLFAMILY_PALADIN
:
641 // Judgement of Vengeance/Corruption ${1+0.22*$SPH+0.14*$AP} + 10% for each application of Holy Vengeance/Blood Corruption on the target
642 if ((m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x800000000)) && m_spellInfo
->SpellIconID
==2292)
645 switch(m_spellInfo
->Id
)
647 case 53733: debuf_id
= 53742; break;// Judgement of Corruption -> Blood Corruption
648 case 31804: debuf_id
= 31803; break;// Judgement of Vengeance -> Holy Vengeance
652 float ap
= m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
653 int32 holy
= m_caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo
)) +
654 m_caster
->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo
), unitTarget
);
655 damage
+=int32(ap
* 0.14f
) + int32(holy
* 22 / 100);
656 // Get stack of Holy Vengeance on the target added by caster
658 Unit::AuraList
const& auras
= unitTarget
->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE
);
659 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
661 if( ((*itr
)->GetId() == debuf_id
) && (*itr
)->GetCasterGUID()==m_caster
->GetGUID())
663 stacks
= (*itr
)->GetStackAmount();
667 // + 10% for each application of Holy Vengeance on the target
669 damage
+= damage
* stacks
* 10 /100;
671 // Hammer of the Righteous
672 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0004000000000000))
674 // Add main hand dps * effect[2] amount
675 float average
= (m_caster
->GetFloatValue(UNIT_FIELD_MINDAMAGE
) + m_caster
->GetFloatValue(UNIT_FIELD_MAXDAMAGE
)) / 2;
676 int32 count
= m_caster
->CalculateSpellDamage(m_spellInfo
, 2, m_spellInfo
->EffectBasePoints
[2], unitTarget
);
677 damage
+= count
* int32(average
* IN_MILISECONDS
) / m_caster
->GetAttackTime(BASE_ATTACK
);
679 // Shield of Righteousness
680 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0010000000000000))
682 damage
+=int32(m_caster
->GetShieldBlockValue());
685 else if (m_spellInfo
->Id
== 54158)
687 // [1 + 0.25 * SPH + 0.16 * AP]
688 damage
+= int32(m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.16f
);
699 void Spell::EffectDummy(uint32 i
)
701 if (!unitTarget
&& !gameObjTarget
&& !itemTarget
)
704 // selection by spell family
705 switch(m_spellInfo
->SpellFamilyName
)
707 case SPELLFAMILY_GENERIC
:
709 switch(m_spellInfo
->Id
)
711 case 8063: // Deviate Fish
713 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
719 case 1: spell_id
= 8064; break; // Sleepy
720 case 2: spell_id
= 8065; break; // Invigorate
721 case 3: spell_id
= 8066; break; // Shrink
722 case 4: spell_id
= 8067; break; // Party Time!
723 case 5: spell_id
= 8068; break; // Healthy Spirit
725 m_caster
->CastSpell(m_caster
, spell_id
, true, NULL
);
728 case 8213: // Savory Deviate Delight
730 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
737 case 1: spell_id
= (m_caster
->getGender() == GENDER_MALE
? 8219 : 8220); break;
739 case 2: spell_id
= (m_caster
->getGender() == GENDER_MALE
? 8221 : 8222); break;
741 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
744 case 8593: // Symbol of life (restore creature to life)
745 case 31225: // Shimmering Vessel (restore creature to life)
747 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
)
749 ((Creature
*)unitTarget
)->setDeathState(JUST_ALIVED
);
752 case 13120: // net-o-matic
759 uint32 roll
= urand(0, 99);
761 if (roll
< 2) // 2% for 30 sec self root (off-like chance unknown)
763 else if (roll
< 4) // 2% for 20 sec root, charge to target (off-like chance unknown)
768 m_caster
->CastSpell(unitTarget
,spell_id
,true,NULL
);
771 case 13567: // Dummy Trigger
773 // can be used for different aura triggering, so select by aura
774 if (!m_triggeredByAuraSpell
|| !unitTarget
)
777 switch(m_triggeredByAuraSpell
->Id
)
779 case 26467: // Persistent Shield
780 m_caster
->CastCustomSpell(unitTarget
, 26470, &damage
, NULL
, NULL
, true);
783 sLog
.outError("EffectDummy: Non-handled case for spell 13567 for triggered aura %u",m_triggeredByAuraSpell
->Id
);
788 case 15998: // Capture Worg Pup
789 case 29435: // Capture Female Kaliri Hatchling
791 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
)
794 Creature
* creatureTarget
= (Creature
*)unitTarget
;
796 creatureTarget
->ForcedDespawn();
799 case 16589: // Noggenfogger Elixir
801 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
807 case 1: spell_id
= 16595; break;
808 case 2: spell_id
= 16593; break;
809 default:spell_id
= 16591; break;
812 m_caster
->CastSpell(m_caster
, spell_id
, true, NULL
);
815 case 17251: // Spirit Healer Res
817 if (!unitTarget
|| !m_originalCaster
)
820 if (m_originalCaster
->GetTypeId() == TYPEID_PLAYER
)
822 WorldPacket
data(SMSG_SPIRIT_HEALER_CONFIRM
, 8);
823 data
<< uint64(unitTarget
->GetGUID());
824 ((Player
*)m_originalCaster
)->GetSession()->SendPacket( &data
);
828 case 17271: // Test Fetid Skull
830 if (!itemTarget
&& m_caster
->GetTypeId()!=TYPEID_PLAYER
)
833 uint32 spell_id
= roll_chance_i(50)
834 ? 17269 // Create Resonating Skull
835 : 17270; // Create Bone Dust
837 m_caster
->CastSpell(m_caster
, spell_id
, true, NULL
);
840 case 20577: // Cannibalize
842 m_caster
->CastSpell(m_caster
, 20578, false, NULL
);
844 case 23019: // Crystal Prison Dummy DND
846 if (!unitTarget
|| !unitTarget
->isAlive() || unitTarget
->GetTypeId() != TYPEID_UNIT
|| ((Creature
*)unitTarget
)->isPet())
849 Creature
* creatureTarget
= (Creature
*)unitTarget
;
850 if (creatureTarget
->isPet())
853 GameObject
* pGameObj
= new GameObject
;
855 Map
*map
= creatureTarget
->GetMap();
857 // create before death for get proper coordinates
858 if (!pGameObj
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), 179644, map
, m_caster
->GetPhaseMask(),
859 creatureTarget
->GetPositionX(), creatureTarget
->GetPositionY(), creatureTarget
->GetPositionZ(),
860 creatureTarget
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
) )
866 pGameObj
->SetRespawnTime(creatureTarget
->GetRespawnTime()-time(NULL
));
867 pGameObj
->SetOwnerGUID(m_caster
->GetGUID() );
868 pGameObj
->SetUInt32Value(GAMEOBJECT_LEVEL
, m_caster
->getLevel() );
869 pGameObj
->SetSpellId(m_spellInfo
->Id
);
871 creatureTarget
->ForcedDespawn();
873 DEBUG_LOG("AddObject at SpellEfects.cpp EffectDummy");
878 case 23074: // Arcanite Dragonling
881 m_caster
->CastSpell(m_caster
, 19804, true, m_CastItem
);
883 case 23075: // Mithril Mechanical Dragonling
886 m_caster
->CastSpell(m_caster
, 12749, true, m_CastItem
);
888 case 23076: // Mechanical Dragonling
891 m_caster
->CastSpell(m_caster
, 4073, true, m_CastItem
);
893 case 23133: // Gnomish Battle Chicken
896 m_caster
->CastSpell(m_caster
, 13166, true, m_CastItem
);
898 case 23448: // Transporter Arrival - Ultrasafe Transporter: Gadgetzan - backfires
900 int32 r
= irand(0, 119);
901 if (r
< 20) // Transporter Malfunction - 1/6 polymorph
902 m_caster
->CastSpell(m_caster
, 23444, true);
903 else if (r
< 100) // Evil Twin - 4/6 evil twin
904 m_caster
->CastSpell(m_caster
, 23445, true);
905 else // Transporter Malfunction - 1/6 miss the target
906 m_caster
->CastSpell(m_caster
, 36902, true);
909 case 23453: // Gnomish Transporter - Ultrasafe Transporter: Gadgetzan
910 if (roll_chance_i(50)) // Gadgetzan Transporter - success
911 m_caster
->CastSpell(m_caster
, 23441, true);
912 else // Gadgetzan Transporter Failure - failure
913 m_caster
->CastSpell(m_caster
, 23446, true);
915 case 23645: // Hourglass Sand
916 m_caster
->RemoveAurasDueToSpell(23170); // Brood Affliction: Bronze
918 case 23725: // Gift of Life (warrior bwl trinket)
919 m_caster
->CastSpell(m_caster
, 23782, true);
920 m_caster
->CastSpell(m_caster
, 23783, true);
922 case 25860: // Reindeer Transformation
924 if (!m_caster
->HasAuraType(SPELL_AURA_MOUNTED
))
927 float flyspeed
= m_caster
->GetSpeedRate(MOVE_FLIGHT
);
928 float speed
= m_caster
->GetSpeedRate(MOVE_RUN
);
930 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
932 //5 different spells used depending on mounted speed and if mount can fly or not
933 if (flyspeed
>= 4.1f
)
935 m_caster
->CastSpell(m_caster
, 44827, true); //310% flying Reindeer
936 else if (flyspeed
>= 3.8f
)
938 m_caster
->CastSpell(m_caster
, 44825, true); //280% flying Reindeer
939 else if (flyspeed
>= 1.6f
)
941 m_caster
->CastSpell(m_caster
, 44824, true); //60% flying Reindeer
942 else if (speed
>= 2.0f
)
944 m_caster
->CastSpell(m_caster
, 25859, true); //100% ground Reindeer
947 m_caster
->CastSpell(m_caster
, 25858, true); //60% ground Reindeer
951 case 26074: // Holiday Cheer
952 // implemented at client side
954 case 28006: // Arcane Cloaking
956 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
957 // Naxxramas Entry Flag Effect DND
958 m_caster
->CastSpell(unitTarget
, 29294, true);
961 case 29200: // Purify Helboar Meat
963 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
966 uint32 spell_id
= roll_chance_i(50)
967 ? 29277 // Summon Purified Helboar Meat
968 : 29278; // Summon Toxic Helboar Meat
970 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
973 case 29858: // Soulshatter
974 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_UNIT
&& unitTarget
->IsHostileTo(m_caster
))
975 m_caster
->CastSpell(unitTarget
,32835,true);
977 case 30458: // Nigh Invulnerability
980 if (roll_chance_i(86)) // Nigh-Invulnerability - success
981 m_caster
->CastSpell(m_caster
, 30456, true, m_CastItem
);
982 else // Complete Vulnerability - backfire in 14% casts
983 m_caster
->CastSpell(m_caster
, 30457, true, m_CastItem
);
985 case 30507: // Poultryizer
988 if (roll_chance_i(80)) // Poultryized! - success
989 m_caster
->CastSpell(unitTarget
, 30501, true, m_CastItem
);
990 else // Poultryized! - backfire 20%
991 m_caster
->CastSpell(unitTarget
, 30504, true, m_CastItem
);
993 case 33060: // Make a Wish
995 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1002 case 1: spell_id
= 33053; break; // Mr Pinchy's Blessing
1003 case 2: spell_id
= 33057; break; // Summon Mighty Mr. Pinchy
1004 case 3: spell_id
= 33059; break; // Summon Furious Mr. Pinchy
1005 case 4: spell_id
= 33062; break; // Tiny Magical Crawdad
1006 case 5: spell_id
= 33064; break; // Mr. Pinchy's Gift
1009 m_caster
->CastSpell(m_caster
, spell_id
, true, NULL
);
1012 case 34665: //Administer Antidote
1014 if (!unitTarget
|| m_caster
->GetTypeId() != TYPEID_PLAYER
)
1016 // Spell has scriptable target but for sure.
1017 if (unitTarget
->GetTypeId() != TYPEID_UNIT
)
1020 uint32 health
= unitTarget
->GetHealth();
1023 unitTarget
->GetPosition(x
, y
, z
);
1024 o
= unitTarget
->GetOrientation();
1025 ((Creature
*)unitTarget
)->ForcedDespawn();
1027 if (Creature
* summon
= m_caster
->SummonCreature(16992, x
, y
, z
, o
,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
,180000))
1029 summon
->SetHealth(health
);
1030 ((Player
*)m_caster
)->RewardPlayerAndGroupAtEvent(16992, summon
);
1033 summon
->AI()->AttackStart(m_caster
);
1037 case 35745: // Socrethar's Stone
1040 switch(m_caster
->GetAreaId())
1042 case 3900: spell_id
= 35743; break; // Socrethar Portal
1043 case 3742: spell_id
= 35744; break; // Socrethar Portal
1047 m_caster
->CastSpell(m_caster
, spell_id
, true);
1050 case 37674: // Chaos Blast
1055 int32 basepoints0
= 100;
1056 m_caster
->CastCustomSpell(unitTarget
, 37675, &basepoints0
, NULL
, NULL
, true);
1059 case 40802: // Mingo's Fortune Generator (Mingo's Fortune Giblets)
1061 // selecting one from Bloodstained Fortune item
1063 switch(urand(1, 20))
1065 case 1: newitemid
= 32688; break;
1066 case 2: newitemid
= 32689; break;
1067 case 3: newitemid
= 32690; break;
1068 case 4: newitemid
= 32691; break;
1069 case 5: newitemid
= 32692; break;
1070 case 6: newitemid
= 32693; break;
1071 case 7: newitemid
= 32700; break;
1072 case 8: newitemid
= 32701; break;
1073 case 9: newitemid
= 32702; break;
1074 case 10: newitemid
= 32703; break;
1075 case 11: newitemid
= 32704; break;
1076 case 12: newitemid
= 32705; break;
1077 case 13: newitemid
= 32706; break;
1078 case 14: newitemid
= 32707; break;
1079 case 15: newitemid
= 32708; break;
1080 case 16: newitemid
= 32709; break;
1081 case 17: newitemid
= 32710; break;
1082 case 18: newitemid
= 32711; break;
1083 case 19: newitemid
= 32712; break;
1084 case 20: newitemid
= 32713; break;
1089 DoCreateItem(i
, newitemid
);
1092 // Demon Broiled Surprise
1093 /* FIX ME: Required for correct work implementing implicit target 7 (in pair (22,7))
1096 if (m_caster->GetTypeId() != TYPEID_PLAYER)
1099 ((Player*)m_caster)->CastSpell(unitTarget, 43753, true);
1103 case 44875: // Complete Raptor Capture
1105 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
)
1108 Creature
* creatureTarget
= (Creature
*)unitTarget
;
1110 creatureTarget
->ForcedDespawn();
1112 //cast spell Raptor Capture Credit
1113 m_caster
->CastSpell(m_caster
, 42337, true, NULL
);
1116 case 44997: // Converting Sentry
1118 //Converted Sentry Credit
1119 m_caster
->CastSpell(m_caster
, 45009, true);
1122 case 45030: // Impale Emissary
1124 // Emissary of Hate Credit
1125 m_caster
->CastSpell(m_caster
, 45088, true);
1128 case 49357: // Brewfest Mount Transformation
1129 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
1132 if (!m_caster
->HasAuraType(SPELL_AURA_MOUNTED
))
1135 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
1137 // Ram for Alliance, Kodo for Horde
1138 if (((Player
*)m_caster
)->GetTeam() == ALLIANCE
)
1140 if (m_caster
->GetSpeedRate(MOVE_RUN
) >= 2.0f
)
1142 m_caster
->CastSpell(m_caster
, 43900, true);
1145 m_caster
->CastSpell(m_caster
, 43899, true);
1149 if (((Player
*)m_caster
)->GetSpeedRate(MOVE_RUN
) >= 2.0f
)
1151 m_caster
->CastSpell(m_caster
, 49379, true);
1154 m_caster
->CastSpell(m_caster
, 49378, true);
1157 case 50243: // Teach Language
1159 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
1162 // spell has a 1/3 chance to trigger one of the below
1163 if (roll_chance_i(66))
1165 if (((Player
*)m_caster
)->GetTeam() == ALLIANCE
)
1167 // 1000001 - gnomish binary
1168 m_caster
->CastSpell(m_caster
, 50242, true);
1172 // 01001000 - goblin binary
1173 m_caster
->CastSpell(m_caster
, 50246, true);
1178 case 51582: //Rocket Boots Engaged (Rocket Boots Xtreme and Rocket Boots Xtreme Lite)
1180 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
1183 if (BattleGround
* bg
= ((Player
*)m_caster
)->GetBattleGround())
1184 bg
->EventPlayerDroppedFlag((Player
*)m_caster
);
1186 m_caster
->CastSpell(m_caster
, 30452, true, NULL
);
1189 case 51592: // Pickup Primordial Hatchling
1191 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
)
1194 Creature
* creatureTarget
= (Creature
*)unitTarget
;
1196 creatureTarget
->ForcedDespawn();
1200 case 52308: // Take Sputum Sample
1206 uint32 spellID
= m_spellInfo
->CalculateSimpleValue(0);
1207 uint32 reqAuraID
= m_spellInfo
->CalculateSimpleValue(1);
1209 if (m_caster
->HasAura(reqAuraID
,0))
1210 m_caster
->CastSpell(m_caster
, spellID
, true, NULL
);
1214 return; // additional data for dummy[0]
1218 case 52759: // Ancestral Awakening
1221 m_caster
->CastCustomSpell(unitTarget
, 52752, &damage
, NULL
, NULL
, true);
1223 case 52845: // Brewfest Mount Transformation (Faction Swap)
1224 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
1227 if (!m_caster
->HasAuraType(SPELL_AURA_MOUNTED
))
1230 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
1232 // Ram for Horde, Kodo for Alliance
1233 if (((Player
*)m_caster
)->GetTeam() == HORDE
)
1235 if (m_caster
->GetSpeedRate(MOVE_RUN
) >= 2.0f
)
1236 // Swift Brewfest Ram, 100% Ram
1237 m_caster
->CastSpell(m_caster
, 43900, true);
1239 // Brewfest Ram, 60% Ram
1240 m_caster
->CastSpell(m_caster
, 43899, true);
1244 if (((Player
*)m_caster
)->GetSpeedRate(MOVE_RUN
) >= 2.0f
)
1245 // Great Brewfest Kodo, 100% Kodo
1246 m_caster
->CastSpell(m_caster
, 49379, true);
1248 // Brewfest Riding Kodo, 60% Kodo
1249 m_caster
->CastSpell(m_caster
, 49378, true);
1252 case 53341: // Rune of Cinderglacier
1253 case 53343: // Rune of Razorice
1255 // Runeforging Credit
1256 m_caster
->CastSpell(m_caster
, 54586, true);
1259 case 55004: // Nitro Boosts
1262 if (roll_chance_i(95)) // Nitro Boosts - success
1263 m_caster
->CastSpell(m_caster
, 54861, true, m_CastItem
);
1264 else // Knocked Up - backfire 5%
1265 m_caster
->CastSpell(m_caster
, 46014, true, m_CastItem
);
1267 case 58418: // Portal to Orgrimmar
1268 case 58420: // Portal to Stormwind
1269 return; // implemented in EffectScript[0]
1270 case 59640: // Underbelly Elixir
1272 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
1275 uint32 spell_id
= 0;
1278 case 1: spell_id
= 59645; break;
1279 case 2: spell_id
= 59831; break;
1280 case 3: spell_id
= 59843; break;
1282 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
1285 case 60932: // Disengage (one from creature versions)
1288 m_caster
->CastSpell(unitTarget
,60934,true,NULL
);
1290 case 67019: // Flask of the North
1292 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
1295 uint32 spell_id
= 0;
1296 switch(m_caster
->getClass())
1299 case CLASS_DEATH_KNIGHT
:
1300 spell_id
= 67018; // STR for Warriors, Death Knights
1304 spell_id
= 67017; // AP for Rogues, Hunters
1309 spell_id
= 67016; // SPD for Priests, Mages, Warlocks
1313 spell_id
= roll_chance_i(50) ? 67016 : 67017;
1318 // random (SPD, STR)
1319 spell_id
= roll_chance_i(50) ? 67016 : 67018;
1322 m_caster
->CastSpell(m_caster
, spell_id
, true);
1328 case SPELLFAMILY_MAGE
:
1329 switch(m_spellInfo
->Id
)
1331 case 11958: // Cold Snap
1333 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1336 // immediately finishes the cooldown on Frost spells
1337 const SpellCooldowns
& cm
= ((Player
*)m_caster
)->GetSpellCooldownMap();
1338 for (SpellCooldowns::const_iterator itr
= cm
.begin(); itr
!= cm
.end();)
1340 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
1342 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_MAGE
&&
1343 (GetSpellSchoolMask(spellInfo
) & SPELL_SCHOOL_MASK_FROST
) &&
1344 spellInfo
->Id
!= 11958 && GetSpellRecoveryTime(spellInfo
) > 0)
1346 ((Player
*)m_caster
)->RemoveSpellCooldown((itr
++)->first
, true);
1353 case 32826: // Polymorph Cast Visual
1355 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_UNIT
)
1357 //Polymorph Cast Visual Rank 1
1358 const uint32 spell_list
[6] = {
1359 32813, // Squirrel Form
1360 32816, // Giraffe Form
1361 32817, // Serpent Form
1362 32818, // Dragonhawk Form
1363 32819, // Worgen Form
1366 unitTarget
->CastSpell( unitTarget
, spell_list
[urand(0, 5)], true);
1372 case SPELLFAMILY_WARRIOR
:
1374 if ((m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x1)) && m_spellInfo
->SpellVisual
[0] == 867)
1376 int32 chargeBasePoints0
= damage
;
1377 m_caster
->CastCustomSpell(m_caster
, 34846, &chargeBasePoints0
, NULL
, NULL
, true);
1381 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x20000000))
1386 uint32 rage
= m_caster
->GetPower(POWER_RAGE
);
1388 // up to max 30 rage cost
1392 // Glyph of Execution bonus
1393 uint32 rage_modified
= rage
;
1395 if (Aura
*aura
= m_caster
->GetDummyAura(58367))
1396 rage_modified
+= aura
->GetModifier()->m_amount
*10;
1398 int32 basePoints0
= damage
+int32(rage_modified
* m_spellInfo
->DmgMultiplier
[i
] +
1399 m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
)*0.2f
);
1401 m_caster
->CastCustomSpell(unitTarget
, 20647, &basePoints0
, NULL
, NULL
, true, 0);
1404 if(m_caster
->HasAura(52437))
1406 Unit::AuraList
const& auras
= m_caster
->GetAurasByType(SPELL_AURA_PROC_TRIGGER_SPELL
);
1407 for (Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
1409 // Only Sudden Death have this SpellIconID with SPELL_AURA_PROC_TRIGGER_SPELL
1410 if ((*itr
)->GetSpellProto()->SpellIconID
== 1989)
1412 // saved rage top stored in next affect
1413 uint32 lastrage
= (*itr
)->GetSpellProto()->CalculateSimpleValue(1)*10;
1421 m_caster
->SetPower(POWER_RAGE
,m_caster
->GetPower(POWER_RAGE
)-rage
);
1425 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000200000))
1429 m_damage
+=m_caster
->CalculateDamage(m_attackType
, false);
1434 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000004000000))
1436 m_damage
+= uint32(damage
* m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
1440 switch(m_spellInfo
->Id
)
1447 m_caster
->CastSpell(unitTarget
, 21887, true);// spell mod
1453 int32 healthModSpellBasePoints0
= int32(m_caster
->GetMaxHealth()*0.3);
1454 m_caster
->CastCustomSpell(m_caster
, 12976, &healthModSpellBasePoints0
, NULL
, NULL
, true, NULL
);
1460 m_caster
->CastCustomSpell(unitTarget
, 23885, &damage
, NULL
, NULL
, true, NULL
);
1465 case SPELLFAMILY_WARLOCK
:
1467 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000040000))
1469 // In 303 exist spirit depend
1470 uint32 spirit
= uint32(m_caster
->GetStat(STAT_SPIRIT
));
1471 switch (m_spellInfo
->Id
)
1473 case 1454: damage
+=spirit
; break;
1474 case 1455: damage
+=spirit
*15/10; break;
1475 case 1456: damage
+=spirit
*2; break;
1476 case 11687: damage
+=spirit
*25/10; break;
1480 case 57946: damage
+=spirit
*3; break;
1482 sLog
.outError("Spell::EffectDummy: %u Life Tap need set spirit multipler", m_spellInfo
->Id
);
1485 // Think its not need (also need remove Life Tap from SpellDamageBonus or add new value)
1486 // damage = m_caster->SpellDamageBonus(m_caster, m_spellInfo,uint32(damage > 0 ? damage : 0), SPELL_DIRECT_DAMAGE);
1487 if (unitTarget
&& (int32(unitTarget
->GetHealth()) > damage
))
1489 // Shouldn't Appear in Combat Log
1490 unitTarget
->ModifyHealth(-damage
);
1492 int32 mana
= damage
;
1493 // Improved Life Tap mod
1494 Unit::AuraList
const& auraDummy
= m_caster
->GetAurasByType(SPELL_AURA_DUMMY
);
1495 for(Unit::AuraList::const_iterator itr
= auraDummy
.begin(); itr
!= auraDummy
.end(); ++itr
)
1497 if((*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (*itr
)->GetSpellProto()->SpellIconID
== 208)
1498 mana
= ((*itr
)->GetModifier()->m_amount
+ 100)* mana
/ 100;
1500 m_caster
->CastCustomSpell(unitTarget
, 31818, &mana
, NULL
, NULL
, true);
1503 int32 manaFeedVal
= 0;
1504 Unit::AuraList
const& mod
= m_caster
->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER
);
1505 for(Unit::AuraList::const_iterator itr
= mod
.begin(); itr
!= mod
.end(); ++itr
)
1507 if((*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (*itr
)->GetSpellProto()->SpellIconID
== 1982)
1508 manaFeedVal
+= (*itr
)->GetModifier()->m_amount
;
1510 if (manaFeedVal
> 0)
1512 manaFeedVal
= manaFeedVal
* mana
/ 100;
1513 m_caster
->CastCustomSpell(m_caster
, 32553, &manaFeedVal
, NULL
, NULL
, true, NULL
);
1517 SendCastResult(SPELL_FAILED_FIZZLE
);
1521 case SPELLFAMILY_PRIEST
:
1523 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0080000000000000))
1530 switch(m_spellInfo
->Id
)
1532 case 47540: hurt
= 47758; heal
= 47757; break;
1533 case 53005: hurt
= 53001; heal
= 52986; break;
1534 case 53006: hurt
= 53002; heal
= 52987; break;
1535 case 53007: hurt
= 53003; heal
= 52988; break;
1537 sLog
.outError("Spell::EffectDummy: Spell %u Penance need set correct heal/damage spell", m_spellInfo
->Id
);
1540 if (m_caster
->IsFriendlyTo(unitTarget
))
1541 m_caster
->CastSpell(unitTarget
, heal
, true, 0);
1543 m_caster
->CastSpell(unitTarget
, hurt
, true, 0);
1547 case SPELLFAMILY_DRUID
:
1549 if (m_spellInfo
->SpellFamilyFlags2
& UI64LIT(0x00000100))
1551 //Shapeshifting into an animal form or mounting cancels the effect.
1552 if(m_caster
->GetCreatureType() == CREATURE_TYPE_BEAST
|| m_caster
->IsMounted())
1554 if(m_triggeredByAuraSpell
)
1555 m_caster
->RemoveAurasDueToSpell(m_triggeredByAuraSpell
->Id
);
1559 //Any effect which causes you to lose control of your character will supress the starfall effect.
1560 if (m_caster
->hasUnitState(UNIT_STAT_STUNNED
| UNIT_STAT_FLEEING
| UNIT_STAT_ROOT
| UNIT_STAT_CONFUSED
))
1563 switch(m_spellInfo
->Id
)
1565 case 50286: m_caster
->CastSpell(unitTarget
, 50288, true); return;
1566 case 53196: m_caster
->CastSpell(unitTarget
, 53191, true); return;
1567 case 53197: m_caster
->CastSpell(unitTarget
, 53194, true); return;
1568 case 53198: m_caster
->CastSpell(unitTarget
, 53195, true); return;
1570 sLog
.outError("Spell::EffectDummy: Unhandeled Starfall spell rank %u",m_spellInfo
->Id
);
1575 case SPELLFAMILY_ROGUE
:
1576 switch(m_spellInfo
->Id
)
1580 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
1583 Player
*pCaster
= ((Player
*)m_caster
);
1585 Item
*item
= pCaster
->GetWeaponForAttack(OFF_ATTACK
);
1589 // all poison enchantments is temporary
1590 uint32 enchant_id
= item
->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT
);
1594 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
1598 for (int s
=0;s
<3;s
++)
1600 if (pEnchant
->type
[s
]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL
)
1603 SpellEntry
const* combatEntry
= sSpellStore
.LookupEntry(pEnchant
->spellid
[s
]);
1604 if (!combatEntry
|| combatEntry
->Dispel
!= DISPEL_POISON
)
1607 m_caster
->CastSpell(unitTarget
, combatEntry
, true, item
);
1610 m_caster
->CastSpell(unitTarget
, 5940, true);
1613 case 14185: // Preparation
1615 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1618 //immediately finishes the cooldown on certain Rogue abilities
1619 const SpellCooldowns
& cm
= ((Player
*)m_caster
)->GetSpellCooldownMap();
1620 for (SpellCooldowns::const_iterator itr
= cm
.begin(); itr
!= cm
.end();)
1622 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
1624 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& (spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000024000000860)))
1625 ((Player
*)m_caster
)->RemoveSpellCooldown((itr
++)->first
,true);
1631 case 31231: // Cheat Death
1633 m_caster
->CastSpell(m_caster
, 45182, true);
1638 case SPELLFAMILY_HUNTER
:
1640 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x100000000))
1642 if (!unitTarget
|| !unitTarget
->isAlive())
1647 // check dazed affect
1648 Unit::AuraList
const& decSpeedList
= unitTarget
->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED
);
1649 for(Unit::AuraList::const_iterator iter
= decSpeedList
.begin(); iter
!= decSpeedList
.end(); ++iter
)
1651 if ((*iter
)->GetSpellProto()->SpellIconID
==15 && (*iter
)->GetSpellProto()->Dispel
==0)
1664 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000400000000000))
1666 Unit
* target
= unitTarget
;
1668 switch(m_spellInfo
->Id
)
1670 case 57635: spellid
= 57636; break; // one from creature cases
1671 case 61507: spellid
= 61508; break; // one from creature cases
1673 sLog
.outError("Spell %u not handled propertly in EffectDummy(Disengage)",m_spellInfo
->Id
);
1676 if (!target
|| !target
->isAlive())
1678 m_caster
->CastSpell(target
,spellid
,true,NULL
);
1681 switch(m_spellInfo
->Id
)
1683 case 23989: // Readiness talent
1685 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1688 //immediately finishes the cooldown for hunter abilities
1689 const SpellCooldowns
& cm
= ((Player
*)m_caster
)->GetSpellCooldownMap();
1690 for (SpellCooldowns::const_iterator itr
= cm
.begin(); itr
!= cm
.end();)
1692 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
1694 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_HUNTER
&& spellInfo
->Id
!= 23989 && GetSpellRecoveryTime(spellInfo
) > 0 )
1695 ((Player
*)m_caster
)->RemoveSpellCooldown((itr
++)->first
,true);
1701 case 37506: // Scatter Shot
1703 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1706 // break Auto Shot and autohit
1707 m_caster
->InterruptSpell(CURRENT_AUTOREPEAT_SPELL
);
1708 m_caster
->AttackStop();
1709 ((Player
*)m_caster
)->SendAttackSwingCancelAttack();
1717 int32 healthModSpellBasePoints0
= int32(unitTarget
->GetMaxHealth() * 0.3);
1718 unitTarget
->CastCustomSpell(unitTarget
, 53479, &healthModSpellBasePoints0
, NULL
, NULL
, true, NULL
);
1724 Pet
* pet
= m_caster
->GetPet();
1725 if (!pet
|| !unitTarget
)
1728 pet
->CastSpell(unitTarget
, m_spellInfo
->CalculateSimpleValue(i
), true);
1733 case SPELLFAMILY_PALADIN
:
1734 switch(m_spellInfo
->SpellIconID
)
1736 case 156: // Holy Shock
1744 switch(m_spellInfo
->Id
)
1746 case 20473: hurt
= 25912; heal
= 25914; break;
1747 case 20929: hurt
= 25911; heal
= 25913; break;
1748 case 20930: hurt
= 25902; heal
= 25903; break;
1749 case 27174: hurt
= 27176; heal
= 27175; break;
1750 case 33072: hurt
= 33073; heal
= 33074; break;
1751 case 48824: hurt
= 48822; heal
= 48820; break;
1752 case 48825: hurt
= 48823; heal
= 48821; break;
1754 sLog
.outError("Spell::EffectDummy: Spell %u not handled in HS",m_spellInfo
->Id
);
1758 if (m_caster
->IsFriendlyTo(unitTarget
))
1759 m_caster
->CastSpell(unitTarget
, heal
, true, 0);
1761 m_caster
->CastSpell(unitTarget
, hurt
, true, 0);
1765 case 561: // Judgement of command
1770 uint32 spell_id
= m_currentBasePoints
[i
]+1;
1771 SpellEntry
const* spell_proto
= sSpellStore
.LookupEntry(spell_id
);
1775 m_caster
->CastSpell(unitTarget
, spell_proto
, true, NULL
);
1780 switch(m_spellInfo
->Id
)
1782 // Judgement of Righteousness (0.2*$AP+0.32*$SPH) holy added in spellDamagBonus
1787 m_damage
+=int32(0.2f
*m_caster
->GetTotalAttackPowerValue(BASE_ATTACK
));
1790 case 31789: // Righteous Defense (step 1)
1792 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
1794 SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT
);
1798 // 31989 -> dummy effect (step 1) + dummy effect (step 2) -> 31709 (taunt like spell for each target)
1799 Unit
* friendTarget
= !unitTarget
|| unitTarget
->IsFriendlyTo(m_caster
) ? unitTarget
: unitTarget
->getVictim();
1802 Player
* player
= friendTarget
->GetCharmerOrOwnerPlayerOrPlayerItself();
1803 if (!player
|| !player
->IsInSameRaidWith((Player
*)m_caster
))
1804 friendTarget
= NULL
;
1807 // non-standard cast requirement check
1808 if (!friendTarget
|| friendTarget
->getAttackers().empty())
1810 ((Player
*)m_caster
)->RemoveSpellCooldown(m_spellInfo
->Id
,true);
1811 SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT
);
1815 // Righteous Defense (step 2) (in old version 31980 dummy effect)
1816 // Clear targets for eff 1
1817 for(std::list
<TargetInfo
>::iterator ihit
= m_UniqueTargetInfo
.begin();ihit
!= m_UniqueTargetInfo
.end();++ihit
)
1818 ihit
->effectMask
&= ~(1<<1);
1820 // not empty (checked), copy
1821 Unit::AttackerSet attackers
= friendTarget
->getAttackers();
1823 // selected from list 3
1824 for(int i
= 0; i
< std::min(size_t(3),attackers
.size()); ++i
)
1826 Unit::AttackerSet::iterator aItr
= attackers
.begin();
1827 std::advance(aItr
, rand() % attackers
.size());
1828 AddUnitTarget((*aItr
), 1);
1829 attackers
.erase(aItr
);
1832 // now let next effect cast spell at each target.
1835 case 37877: // Blessing of Faith
1840 uint32 spell_id
= 0;
1841 switch(unitTarget
->getClass())
1843 case CLASS_DRUID
: spell_id
= 37878; break;
1844 case CLASS_PALADIN
: spell_id
= 37879; break;
1845 case CLASS_PRIEST
: spell_id
= 37880; break;
1846 case CLASS_SHAMAN
: spell_id
= 37881; break;
1847 default: return; // ignore for not healing classes
1850 m_caster
->CastSpell(m_caster
, spell_id
, true);
1855 case SPELLFAMILY_SHAMAN
:
1857 if ((m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000004000000)) && m_spellInfo
->SpellIconID
==1673)
1860 m_caster
->CastSpell(unitTarget
, 52025, true);
1863 // Healing Stream Totem
1864 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000002000))
1867 m_caster
->CastCustomSpell(unitTarget
, 52042, &damage
, 0, 0, true, 0, 0, m_originalCasterGUID
);
1870 // Mana Spring Totem
1871 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000004000))
1873 if (!unitTarget
|| unitTarget
->getPowerType()!=POWER_MANA
)
1875 m_caster
->CastCustomSpell(unitTarget
, 52032, &damage
, 0, 0, true, 0, 0, m_originalCasterGUID
);
1878 if (m_spellInfo
->Id
== 39610) // Mana Tide Totem effect
1880 if (!unitTarget
|| unitTarget
->getPowerType() != POWER_MANA
)
1882 // Glyph of Mana Tide
1883 if (Unit
*owner
= m_caster
->GetOwner())
1884 if (Aura
*dummy
= owner
->GetDummyAura(55441))
1885 damage
+=dummy
->GetModifier()->m_amount
;
1886 // Regenerate 6% of Total Mana Every 3 secs
1887 int32 EffectBasePoints0
= unitTarget
->GetMaxPower(POWER_MANA
) * damage
/ 100;
1888 m_caster
->CastCustomSpell(unitTarget
, 39609, &EffectBasePoints0
, NULL
, NULL
, true, NULL
, NULL
, m_originalCasterGUID
);
1892 if (m_spellInfo
->SpellFamilyFlags2
& 0x00000004)
1894 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
1896 Item
*item
= ((Player
*)m_caster
)->GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_OFFHAND
);
1899 // Damage is increased if your off-hand weapon is enchanted with Flametongue.
1900 Unit::AuraList
const& auraDummy
= m_caster
->GetAurasByType(SPELL_AURA_DUMMY
);
1901 for(Unit::AuraList::const_iterator itr
= auraDummy
.begin(); itr
!= auraDummy
.end(); ++itr
)
1903 if ((*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_SHAMAN
&&
1904 ((*itr
)->GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000200000)) &&
1905 (*itr
)->GetCastItemGUID() == item
->GetGUID())
1907 m_damage
+= m_damage
* damage
/ 100;
1915 case SPELLFAMILY_DEATHKNIGHT
:
1917 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x002000))
1919 if (m_caster
->IsFriendlyTo(unitTarget
))
1921 if (unitTarget
->GetCreatureType() != CREATURE_TYPE_UNDEAD
)
1924 int32 bp
= damage
* 1.5f
;
1925 m_caster
->CastCustomSpell(unitTarget
, 47633, &bp
, NULL
, NULL
, true);
1930 m_caster
->CastCustomSpell(unitTarget
, 47632, &bp
, NULL
, NULL
, true);
1935 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000100000000000))
1937 m_caster
->CastSpell(m_caster
, 51209, true);
1941 else if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000000010))
1944 Unit::AuraMap
const& auras
= unitTarget
->GetAuras();
1945 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
1947 if (itr
->second
->GetSpellProto()->Dispel
== DISPEL_DISEASE
&&
1948 itr
->second
->GetCasterGUID() == m_caster
->GetGUID() &&
1949 IsSpellLastAuraEffect(itr
->second
->GetSpellProto(), itr
->second
->GetEffIndex()))
1958 int32 bp
= count
* m_caster
->GetMaxHealth() * m_spellInfo
->DmgMultiplier
[0] / 100;
1959 m_caster
->CastCustomSpell(m_caster
, 45470, &bp
, NULL
, NULL
, true);
1966 if (PetAura
const* petSpell
= sSpellMgr
.GetPetAura(m_spellInfo
->Id
, i
))
1968 m_caster
->AddPetAura(petSpell
);
1972 // Script based implementation. Must be used only for not good for implementation in core spell effects
1973 // So called only for not proccessed cases
1975 Script
->EffectDummyGameObj(m_caster
, m_spellInfo
->Id
, i
, gameObjTarget
);
1976 else if (unitTarget
&& unitTarget
->GetTypeId()==TYPEID_UNIT
)
1977 Script
->EffectDummyCreature(m_caster
, m_spellInfo
->Id
, i
, (Creature
*)unitTarget
);
1978 else if (itemTarget
)
1979 Script
->EffectDummyItem(m_caster
, m_spellInfo
->Id
, i
, itemTarget
);
1982 void Spell::EffectTriggerSpellWithValue(uint32 i
)
1984 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[i
];
1987 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
1991 sLog
.outError("EffectTriggerSpellWithValue of spell %u: triggering unknown spell id %i", m_spellInfo
->Id
,triggered_spell_id
);
1996 m_caster
->CastCustomSpell(unitTarget
,triggered_spell_id
,&bp
,&bp
,&bp
,true,NULL
,NULL
,m_originalCasterGUID
);
1999 void Spell::EffectTriggerRitualOfSummoning(uint32 i
)
2001 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[i
];
2002 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
2006 sLog
.outError("EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", m_spellInfo
->Id
,triggered_spell_id
);
2012 m_caster
->CastSpell(unitTarget
,spellInfo
,false);
2015 void Spell::EffectForceCast(uint32 i
)
2020 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[i
];
2023 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
2027 sLog
.outError("EffectForceCast of spell %u: triggering unknown spell id %i", m_spellInfo
->Id
,triggered_spell_id
);
2031 unitTarget
->CastSpell(unitTarget
, spellInfo
, true, NULL
, NULL
, m_originalCasterGUID
);
2034 void Spell::EffectTriggerSpell(uint32 effIndex
)
2036 // only unit case known
2039 if(gameObjTarget
|| itemTarget
)
2040 sLog
.outError("Spell::EffectTriggerSpell (Spell: %u): Unsupported non-unit case!",m_spellInfo
->Id
);
2044 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[effIndex
];
2047 switch(triggered_spell_id
)
2049 // Vanish (not exist)
2052 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
2053 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
2054 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED
);
2056 // if this spell is given to NPC it must handle rest by it's own AI
2057 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
2060 // get highest rank of the Stealth spell
2062 const PlayerSpellMap
& sp_list
= ((Player
*)unitTarget
)->GetSpellMap();
2063 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
2065 // only highest rank is shown in spell book, so simply check if shown in spell book
2066 if (!itr
->second
->active
|| itr
->second
->disabled
|| itr
->second
->state
== PLAYERSPELL_REMOVED
)
2069 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
2073 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& spellInfo
->SpellFamilyFlags
& SPELLFAMILYFLAG_ROGUE_STEALTH
)
2075 spellId
= spellInfo
->Id
;
2080 // no Stealth spell found
2084 // reset cooldown on it if needed
2085 if (((Player
*)unitTarget
)->HasSpellCooldown(spellId
))
2086 ((Player
*)unitTarget
)->RemoveSpellCooldown(spellId
);
2088 m_caster
->CastSpell(unitTarget
, spellId
, true);
2092 case 23770: // Sayge's Dark Fortune of *
2093 // not exist, common cooldown can be implemented in scripts if need.
2095 // Brittle Armor - (need add max stack of 24575 Brittle Armor)
2099 SpellEntry
const* spell
= sSpellStore
.LookupEntry(24575);
2103 for (int j
=0; j
< spell
->StackAmount
; ++j
)
2104 m_caster
->CastSpell(unitTarget
, spell
->Id
, true, m_CastItem
, NULL
, m_originalCasterGUID
);
2107 // Mercurial Shield - (need add max stack of 26464 Mercurial Shield)
2111 SpellEntry
const* spell
= sSpellStore
.LookupEntry(26464);
2115 for (int j
=0; j
< spell
->StackAmount
; ++j
)
2116 m_caster
->CastSpell(unitTarget
, spell
->Id
, true, m_CastItem
, NULL
, m_originalCasterGUID
);
2119 // Righteous Defense
2122 m_caster
->CastSpell(unitTarget
, 31790, true, m_CastItem
, NULL
, m_originalCasterGUID
);
2128 Unit::AuraMap
& Auras
= unitTarget
->GetAuras();
2129 for(Unit::AuraMap::iterator iter
= Auras
.begin(); iter
!= Auras
.end(); ++iter
)
2131 // remove all harmful spells on you...
2132 if( // ignore positive and passive auras
2133 !iter
->second
->IsPositive() && !iter
->second
->IsPassive() &&
2134 // ignore physical auras
2135 (GetSpellSchoolMask(iter
->second
->GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
)==0 )
2137 m_caster
->RemoveAurasDueToSpell(iter
->second
->GetSpellProto()->Id
);
2138 iter
= Auras
.begin();
2143 // Priest Shadowfiend (34433) need apply mana gain trigger aura on pet
2146 if (Unit
*pet
= unitTarget
->GetPet())
2147 pet
->CastSpell(pet
, 28305, true);
2153 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
2156 sLog
.outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo
->Id
,triggered_spell_id
);
2160 // select formal caster for triggered spell
2161 Unit
* caster
= m_caster
;
2163 // some triggered spells require specific equipment
2164 if (spellInfo
->EquippedItemClass
>=0 && m_caster
->GetTypeId()==TYPEID_PLAYER
)
2166 // main hand weapon required
2167 if (spellInfo
->AttributesEx3
& SPELL_ATTR_EX3_MAIN_HAND
)
2169 Item
* item
= ((Player
*)m_caster
)->GetWeaponForAttack(BASE_ATTACK
, true, false);
2171 // skip spell if no weapon in slot or broken
2175 // skip spell if weapon not fit to triggered spell
2176 if (!item
->IsFitToSpellRequirements(spellInfo
))
2180 // offhand hand weapon required
2181 if (spellInfo
->AttributesEx3
& SPELL_ATTR_EX3_REQ_OFFHAND
)
2183 Item
* item
= ((Player
*)m_caster
)->GetWeaponForAttack(OFF_ATTACK
, true, false);
2185 // skip spell if no weapon in slot or broken
2189 // skip spell if weapon not fit to triggered spell
2190 if (!item
->IsFitToSpellRequirements(spellInfo
))
2196 // Note: not exist spells with weapon req. and IsSpellHaveCasterSourceTargets == true
2197 // so this just for speedup places in else
2198 caster
= IsSpellWithCasterSourceTargetsOnly(spellInfo
) ? unitTarget
: m_caster
;
2201 caster
->CastSpell(unitTarget
,spellInfo
,true,NULL
,NULL
,m_originalCasterGUID
);
2204 void Spell::EffectTriggerMissileSpell(uint32 effect_idx
)
2206 uint32 triggered_spell_id
= m_spellInfo
->EffectTriggerSpell
[effect_idx
];
2209 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( triggered_spell_id
);
2213 sLog
.outError("EffectTriggerMissileSpell of spell %u (eff: %u): triggering unknown spell id %u",
2214 m_spellInfo
->Id
,effect_idx
,triggered_spell_id
);
2219 DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo
->Id
);
2221 m_caster
->CastSpell(m_targets
.m_destX
, m_targets
.m_destY
, m_targets
.m_destZ
, spellInfo
, true, m_CastItem
, 0, m_originalCasterGUID
);
2224 void Spell::EffectJump(uint32 i
)
2226 if(m_caster
->isInFlight())
2229 // Init dest coordinates
2231 if(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
2233 x
= m_targets
.m_destX
;
2234 y
= m_targets
.m_destY
;
2235 z
= m_targets
.m_destZ
;
2237 if(m_spellInfo
->EffectImplicitTargetA
[i
] == TARGET_BEHIND_VICTIM
)
2239 // explicit cast data from client or server-side cast
2240 // some spell at client send caster
2241 Unit
* pTarget
= NULL
;
2242 if(m_targets
.getUnitTarget() && m_targets
.getUnitTarget()!=m_caster
)
2243 pTarget
= m_targets
.getUnitTarget();
2244 else if(unitTarget
->getVictim())
2245 pTarget
= m_caster
->getVictim();
2246 else if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
2247 pTarget
= ObjectAccessor::GetUnit(*m_caster
, ((Player
*)m_caster
)->GetSelection());
2249 o
= pTarget
? pTarget
->GetOrientation() : m_caster
->GetOrientation();
2252 o
= m_caster
->GetOrientation();
2256 unitTarget
->GetContactPoint(m_caster
,x
,y
,z
,CONTACT_DISTANCE
);
2257 o
= m_caster
->GetOrientation();
2259 else if(gameObjTarget
)
2261 gameObjTarget
->GetContactPoint(m_caster
,x
,y
,z
,CONTACT_DISTANCE
);
2262 o
= m_caster
->GetOrientation();
2266 sLog
.outError( "Spell::EffectJump - unsupported target mode for spell ID %u", m_spellInfo
->Id
);
2270 m_caster
->NearTeleportTo(x
, y
, z
, o
, true);
2273 void Spell::EffectTeleportUnits(uint32 i
)
2275 if(!unitTarget
|| unitTarget
->isInFlight())
2278 switch (m_spellInfo
->EffectImplicitTargetB
[i
])
2280 case TARGET_INNKEEPER_COORDINATES
:
2282 // Only players can teleport to innkeeper
2283 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
2286 ((Player
*)unitTarget
)->TeleportToHomebind(unitTarget
==m_caster
? TELE_TO_SPELL
: 0);
2289 case TARGET_AREAEFFECT_INSTANT
: // in all cases first TARGET_TABLE_X_Y_Z_COORDINATES
2290 case TARGET_TABLE_X_Y_Z_COORDINATES
:
2292 SpellTargetPosition
const* st
= sSpellMgr
.GetSpellTargetPosition(m_spellInfo
->Id
);
2295 sLog
.outError( "Spell::EffectTeleportUnits - unknown Teleport coordinates for spell ID %u", m_spellInfo
->Id
);
2299 if(st
->target_mapId
==unitTarget
->GetMapId())
2300 unitTarget
->NearTeleportTo(st
->target_X
,st
->target_Y
,st
->target_Z
,st
->target_Orientation
,unitTarget
==m_caster
);
2301 else if(unitTarget
->GetTypeId()==TYPEID_PLAYER
)
2302 ((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);
2305 case TARGET_BEHIND_VICTIM
:
2307 Unit
*pTarget
= NULL
;
2309 // explicit cast data from client or server-side cast
2310 // some spell at client send caster
2311 if(m_targets
.getUnitTarget() && m_targets
.getUnitTarget()!=unitTarget
)
2312 pTarget
= m_targets
.getUnitTarget();
2313 else if(unitTarget
->getVictim())
2314 pTarget
= unitTarget
->getVictim();
2315 else if(unitTarget
->GetTypeId() == TYPEID_PLAYER
)
2316 pTarget
= ObjectAccessor::GetUnit(*unitTarget
, ((Player
*)unitTarget
)->GetSelection());
2318 // Init dest coordinates
2319 float x
= m_targets
.m_destX
;
2320 float y
= m_targets
.m_destY
;
2321 float z
= m_targets
.m_destZ
;
2322 float orientation
= pTarget
? pTarget
->GetOrientation() : unitTarget
->GetOrientation();
2323 unitTarget
->NearTeleportTo(x
,y
,z
,orientation
,unitTarget
==m_caster
);
2328 // If not exist data for dest location - return
2329 if(!(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
))
2331 sLog
.outError( "Spell::EffectTeleportUnits - unknown EffectImplicitTargetB[%u] = %u for spell ID %u", i
, m_spellInfo
->EffectImplicitTargetB
[i
], m_spellInfo
->Id
);
2334 // Init dest coordinates
2335 float x
= m_targets
.m_destX
;
2336 float y
= m_targets
.m_destY
;
2337 float z
= m_targets
.m_destZ
;
2338 float orientation
= unitTarget
->GetOrientation();
2340 unitTarget
->NearTeleportTo(x
,y
,z
,orientation
,unitTarget
==m_caster
);
2345 // post effects for TARGET_TABLE_X_Y_Z_COORDINATES
2346 switch ( m_spellInfo
->Id
)
2348 // Dimensional Ripper - Everlook
2351 int32 r
= irand(0, 119);
2352 if ( r
>= 70 ) // 7/12 success
2354 if ( r
< 100 ) // 4/12 evil twin
2355 m_caster
->CastSpell(m_caster
, 23445, true);
2357 m_caster
->CastSpell(m_caster
, 23449, true);
2361 // Ultrasafe Transporter: Toshley's Station
2364 if ( roll_chance_i(50) ) // 50% success
2366 int32 rand_eff
= urand(1, 7);
2370 // soul split - evil
2371 m_caster
->CastSpell(m_caster
, 36900, true);
2374 // soul split - good
2375 m_caster
->CastSpell(m_caster
, 36901, true);
2378 // Increase the size
2379 m_caster
->CastSpell(m_caster
, 36895, true);
2382 // Decrease the size
2383 m_caster
->CastSpell(m_caster
, 36893, true);
2388 if (((Player
*)m_caster
)->GetTeam() == ALLIANCE
)
2389 m_caster
->CastSpell(m_caster
, 36897, true);
2391 m_caster
->CastSpell(m_caster
, 36899, true);
2396 m_caster
->CastSpell(m_caster
, 36940, true);
2400 m_caster
->CastSpell(m_caster
, 23445, true);
2406 // Dimensional Ripper - Area 52
2409 if ( roll_chance_i(50) ) // 50% success
2411 int32 rand_eff
= urand(1, 4);
2415 // soul split - evil
2416 m_caster
->CastSpell(m_caster
, 36900, true);
2419 // soul split - good
2420 m_caster
->CastSpell(m_caster
, 36901, true);
2423 // Increase the size
2424 m_caster
->CastSpell(m_caster
, 36895, true);
2429 if (((Player
*)m_caster
)->GetTeam() == ALLIANCE
)
2430 m_caster
->CastSpell(m_caster
, 36897, true);
2432 m_caster
->CastSpell(m_caster
, 36899, true);
2442 void Spell::EffectApplyAura(uint32 i
)
2447 // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load)
2448 if ( (!unitTarget
->isAlive() && !(IsDeathOnlySpell(m_spellInfo
) || IsDeathPersistentSpell(m_spellInfo
))) &&
2449 (unitTarget
->GetTypeId() != TYPEID_PLAYER
|| !((Player
*)unitTarget
)->GetSession()->PlayerLoading()) )
2452 Unit
* caster
= m_originalCaster
? m_originalCaster
: m_caster
;
2456 sLog
.outDebug("Spell: Aura is: %u", m_spellInfo
->EffectApplyAuraName
[i
]);
2458 Aura
* Aur
= CreateAura(m_spellInfo
, i
, &m_currentBasePoints
[i
], unitTarget
, caster
, m_CastItem
);
2460 // Now Reduce spell duration using data received at spell hit
2461 int32 duration
= Aur
->GetAuraMaxDuration();
2462 int32 limitduration
= GetDiminishingReturnsLimitDuration(m_diminishGroup
,m_spellInfo
);
2463 unitTarget
->ApplyDiminishingToDuration(m_diminishGroup
, duration
, m_caster
, m_diminishLevel
,limitduration
);
2464 Aur
->setDiminishGroup(m_diminishGroup
);
2466 // if Aura removed and deleted, do not continue.
2467 if(duration
== 0 && !(Aur
->IsPermanent()))
2473 if(duration
!= Aur
->GetAuraMaxDuration())
2475 Aur
->SetAuraMaxDuration(duration
);
2476 Aur
->SetAuraDuration(duration
);
2479 unitTarget
->AddAura(Aur
);
2482 void Spell::EffectUnlearnSpecialization( uint32 i
)
2484 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
2487 Player
*_player
= (Player
*)unitTarget
;
2488 uint32 spellToUnlearn
= m_spellInfo
->EffectTriggerSpell
[i
];
2490 _player
->removeSpell(spellToUnlearn
);
2492 sLog
.outDebug( "Spell: Player %u has unlearned spell %u from NpcGUID: %u", _player
->GetGUIDLow(), spellToUnlearn
, m_caster
->GetGUIDLow() );
2495 void Spell::EffectPowerDrain(uint32 i
)
2497 if(m_spellInfo
->EffectMiscValue
[i
] < 0 || m_spellInfo
->EffectMiscValue
[i
] >= MAX_POWERS
)
2500 Powers drain_power
= Powers(m_spellInfo
->EffectMiscValue
[i
]);
2504 if(!unitTarget
->isAlive())
2506 if(unitTarget
->getPowerType() != drain_power
)
2511 uint32 curPower
= unitTarget
->GetPower(drain_power
);
2513 //add spell damage bonus
2514 damage
=m_caster
->SpellDamageBonus(unitTarget
,m_spellInfo
,uint32(damage
),SPELL_DIRECT_DAMAGE
);
2516 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
2517 uint32 power
= damage
;
2518 if (drain_power
== POWER_MANA
)
2519 power
-= unitTarget
->GetSpellCritDamageReduction(power
);
2522 if(curPower
< power
)
2523 new_damage
= curPower
;
2527 unitTarget
->ModifyPower(drain_power
,-new_damage
);
2529 // Don`t restore from self drain
2530 if(drain_power
== POWER_MANA
&& m_caster
!= unitTarget
)
2532 float manaMultiplier
= m_spellInfo
->EffectMultipleValue
[i
];
2533 if(manaMultiplier
==0)
2536 if(Player
*modOwner
= m_caster
->GetSpellModOwner())
2537 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_MULTIPLE_VALUE
, manaMultiplier
);
2539 int32 gain
= int32(new_damage
* manaMultiplier
);
2541 m_caster
->EnergizeBySpell(m_caster
, m_spellInfo
->Id
, gain
, POWER_MANA
);
2545 void Spell::EffectSendEvent(uint32 EffectIndex
)
2548 we do not handle a flag dropping or clicking on flag in battleground by sendevent system
2550 sLog
.outDebug("Spell ScriptStart %u for spellid %u in EffectSendEvent ", m_spellInfo
->EffectMiscValue
[EffectIndex
], m_spellInfo
->Id
);
2551 m_caster
->GetMap()->ScriptsStart(sEventScripts
, m_spellInfo
->EffectMiscValue
[EffectIndex
], m_caster
, focusObject
);
2554 void Spell::EffectPowerBurn(uint32 i
)
2556 if (m_spellInfo
->EffectMiscValue
[i
] < 0 || m_spellInfo
->EffectMiscValue
[i
] >= MAX_POWERS
)
2559 Powers powertype
= Powers(m_spellInfo
->EffectMiscValue
[i
]);
2563 if (!unitTarget
->isAlive())
2565 if (unitTarget
->getPowerType()!=powertype
)
2570 // burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn)
2571 if (m_spellInfo
->ManaCostPercentage
)
2573 uint32 maxdamage
= m_caster
->GetMaxPower(powertype
) * damage
* 2 / 100;
2574 damage
= unitTarget
->GetMaxPower(powertype
) * damage
/ 100;
2575 if(damage
> maxdamage
) damage
= maxdamage
;
2578 int32 curPower
= int32(unitTarget
->GetPower(powertype
));
2580 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
2581 uint32 power
= damage
;
2582 if (powertype
== POWER_MANA
)
2583 power
-= unitTarget
->GetSpellCritDamageReduction(power
);
2585 int32 new_damage
= (curPower
< power
) ? curPower
: power
;
2587 unitTarget
->ModifyPower(powertype
, -new_damage
);
2588 float multiplier
= m_spellInfo
->EffectMultipleValue
[i
];
2590 if (Player
*modOwner
= m_caster
->GetSpellModOwner())
2591 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_MULTIPLE_VALUE
, multiplier
);
2593 new_damage
= int32(new_damage
* multiplier
);
2594 m_damage
+= new_damage
;
2597 void Spell::EffectHeal( uint32
/*i*/ )
2599 if (unitTarget
&& unitTarget
->isAlive() && damage
>= 0)
2601 // Try to get original caster
2602 Unit
*caster
= m_originalCasterGUID
? m_originalCaster
: m_caster
;
2604 // Skip if m_originalCaster not available
2608 int32 addhealth
= damage
;
2610 // Vessel of the Naaru (Vial of the Sunwell trinket)
2611 if (m_spellInfo
->Id
== 45064)
2613 // Amount of heal - depends from stacked Holy Energy
2614 int damageAmount
= 0;
2615 Unit::AuraList
const& mDummyAuras
= m_caster
->GetAurasByType(SPELL_AURA_DUMMY
);
2616 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin(); i
!= mDummyAuras
.end(); ++i
)
2617 if ((*i
)->GetId() == 45062)
2618 damageAmount
+=(*i
)->GetModifier()->m_amount
;
2620 m_caster
->RemoveAurasDueToSpell(45062);
2622 addhealth
+= damageAmount
;
2624 // Death Pact (percent heal)
2625 else if (m_spellInfo
->Id
==48743)
2626 addhealth
= addhealth
* unitTarget
->GetMaxHealth() / 100;
2627 // Swiftmend - consumes Regrowth or Rejuvenation
2628 else if (m_spellInfo
->TargetAuraState
== AURA_STATE_SWIFTMEND
&& unitTarget
->HasAuraState(AURA_STATE_SWIFTMEND
))
2630 Unit::AuraList
const& RejorRegr
= unitTarget
->GetAurasByType(SPELL_AURA_PERIODIC_HEAL
);
2631 // find most short by duration
2632 Aura
*targetAura
= NULL
;
2633 for(Unit::AuraList::const_iterator i
= RejorRegr
.begin(); i
!= RejorRegr
.end(); ++i
)
2635 if ((*i
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DRUID
&&
2636 // Regrowth or Rejuvenation 0x40 | 0x10
2637 ((*i
)->GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000050)))
2639 if (!targetAura
|| (*i
)->GetAuraDuration() < targetAura
->GetAuraDuration())
2646 sLog
.outError("Target (GUID: %u TypeId: %u) has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget
->GetGUIDLow(), unitTarget
->GetTypeId());
2652 if(targetAura
->GetSpellProto()->EffectApplyAuraName
[idx
] == SPELL_AURA_PERIODIC_HEAL
)
2657 int32 tickheal
= caster
->SpellHealingBonus(unitTarget
, targetAura
->GetSpellProto(), targetAura
->GetModifier()->m_amount
, DOT
);
2658 int32 tickcount
= GetSpellDuration(targetAura
->GetSpellProto()) / targetAura
->GetSpellProto()->EffectAmplitude
[idx
];
2660 // Glyph of Swiftmend
2661 if (!caster
->HasAura(54824))
2662 unitTarget
->RemoveAurasDueToSpell(targetAura
->GetId());
2664 addhealth
+= tickheal
* tickcount
;
2667 addhealth
= caster
->SpellHealingBonus(unitTarget
, m_spellInfo
, addhealth
, HEAL
);
2669 m_healing
+=addhealth
;
2673 void Spell::EffectHealPct( uint32
/*i*/ )
2675 if (unitTarget
&& unitTarget
->isAlive() && damage
>= 0)
2677 // Try to get original caster
2678 Unit
*caster
= m_originalCasterGUID
? m_originalCaster
: m_caster
;
2680 // Skip if m_originalCaster not available
2684 uint32 addhealth
= unitTarget
->GetMaxHealth() * damage
/ 100;
2685 if (Player
* modOwner
= m_caster
->GetSpellModOwner())
2686 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_DAMAGE
, addhealth
, this);
2688 int32 gain
= caster
->DealHeal(unitTarget
, addhealth
, m_spellInfo
);
2689 unitTarget
->getHostileRefManager().threatAssist(m_caster
, float(gain
) * 0.5f
, m_spellInfo
);
2693 void Spell::EffectHealMechanical( uint32
/*i*/ )
2695 // Mechanic creature type should be correctly checked by targetCreatureType field
2696 if (unitTarget
&& unitTarget
->isAlive() && damage
>= 0)
2698 // Try to get original caster
2699 Unit
*caster
= m_originalCasterGUID
? m_originalCaster
: m_caster
;
2701 // Skip if m_originalCaster not available
2705 uint32 addhealth
= caster
->SpellHealingBonus(unitTarget
, m_spellInfo
, uint32(damage
), HEAL
);
2706 caster
->DealHeal(unitTarget
, addhealth
, m_spellInfo
);
2710 void Spell::EffectHealthLeech(uint32 i
)
2714 if (!unitTarget
->isAlive())
2720 sLog
.outDebug("HealthLeech :%i", damage
);
2722 uint32 curHealth
= unitTarget
->GetHealth();
2723 damage
= m_caster
->SpellNonMeleeDamageLog(unitTarget
, m_spellInfo
->Id
, damage
);
2724 if (curHealth
< damage
)
2727 float multiplier
= m_spellInfo
->EffectMultipleValue
[i
];
2729 if (Player
*modOwner
= m_caster
->GetSpellModOwner())
2730 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_MULTIPLE_VALUE
, multiplier
);
2732 uint32 heal
= uint32(damage
*multiplier
);
2733 if (m_caster
->isAlive())
2735 heal
= m_caster
->SpellHealingBonus(m_caster
, m_spellInfo
, heal
, HEAL
);
2736 m_caster
->DealHeal(m_caster
, heal
, m_spellInfo
);
2740 void Spell::DoCreateItem(uint32 i
, uint32 itemtype
)
2742 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
2745 Player
* player
= (Player
*)unitTarget
;
2747 uint32 newitemid
= itemtype
;
2748 ItemPrototype
const *pProto
= ObjectMgr::GetItemPrototype( newitemid
);
2751 player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
2755 // bg reward have some special in code work
2757 switch(m_spellInfo
->Id
)
2759 case SPELL_AV_MARK_WINNER
:
2760 case SPELL_AV_MARK_LOSER
:
2761 bgType
= BATTLEGROUND_AV
;
2763 case SPELL_WS_MARK_WINNER
:
2764 case SPELL_WS_MARK_LOSER
:
2765 bgType
= BATTLEGROUND_WS
;
2767 case SPELL_AB_MARK_WINNER
:
2768 case SPELL_AB_MARK_LOSER
:
2769 bgType
= BATTLEGROUND_AB
;
2777 // TODO: maybe all this can be replaced by using correct calculated `damage` value
2778 if(pProto
->Class
!= ITEM_CLASS_CONSUMABLE
|| m_spellInfo
->SpellFamilyName
!= SPELLFAMILY_MAGE
)
2780 int32 basePoints
= m_currentBasePoints
[i
];
2781 int32 randomPoints
= m_spellInfo
->EffectDieSides
[i
];
2783 num_to_add
= basePoints
+ irand(1, randomPoints
);
2785 num_to_add
= basePoints
+ 1;
2787 else if (pProto
->MaxCount
== 1)
2789 else if(player
->getLevel() >= m_spellInfo
->spellLevel
)
2791 int32 basePoints
= m_currentBasePoints
[i
];
2792 float pointPerLevel
= m_spellInfo
->EffectRealPointsPerLevel
[i
];
2793 num_to_add
= basePoints
+ 1 + uint32((player
->getLevel() - m_spellInfo
->spellLevel
)*pointPerLevel
);
2800 if (num_to_add
> pProto
->GetMaxStackSize())
2801 num_to_add
= pProto
->GetMaxStackSize();
2803 // init items_count to 1, since 1 item will be created regardless of specialization
2805 // the chance to create additional items
2806 float additionalCreateChance
=0.0f
;
2807 // the maximum number of created additional items
2808 uint8 additionalMaxNum
=0;
2809 // get the chance and maximum number for creating extra items
2810 if ( canCreateExtraItems(player
, m_spellInfo
->Id
, additionalCreateChance
, additionalMaxNum
) )
2812 // roll with this chance till we roll not to create or we create the max num
2813 while ( roll_chance_f(additionalCreateChance
) && items_count
<=additionalMaxNum
)
2817 // really will be created more items
2818 num_to_add
*= items_count
;
2820 // can the player store the new item?
2821 ItemPosCountVec dest
;
2822 uint32 no_space
= 0;
2823 uint8 msg
= player
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, newitemid
, num_to_add
, &no_space
);
2824 if( msg
!= EQUIP_ERR_OK
)
2826 // convert to possible store amount
2827 if( msg
== EQUIP_ERR_INVENTORY_FULL
|| msg
== EQUIP_ERR_CANT_CARRY_MORE_OF_THIS
)
2828 num_to_add
-= no_space
;
2831 // if not created by another reason from full inventory or unique items amount limitation
2832 player
->SendEquipError( msg
, NULL
, NULL
);
2839 // create the new item and store it
2840 Item
* pItem
= player
->StoreNewItem( dest
, newitemid
, true, Item::GenerateItemRandomPropertyId(newitemid
));
2842 // was it successful? return error if not
2845 player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
2849 // set the "Crafted by ..." property of the item
2850 if( pItem
->GetProto()->Class
!= ITEM_CLASS_CONSUMABLE
&& pItem
->GetProto()->Class
!= ITEM_CLASS_QUEST
)
2851 pItem
->SetUInt32Value(ITEM_FIELD_CREATOR
, player
->GetGUIDLow());
2853 // send info to the client
2855 player
->SendNewItem(pItem
, num_to_add
, true, bgType
== 0);
2857 // we succeeded in creating at least one item, so a levelup is possible
2859 player
->UpdateCraftSkill(m_spellInfo
->Id
);
2862 // for battleground marks send by mail if not add all expected
2863 if(no_space
> 0 && bgType
)
2865 if(BattleGround
* bg
= sBattleGroundMgr
.GetBattleGroundTemplate(BattleGroundTypeId(bgType
)))
2866 bg
->SendRewardMarkByMail(player
, newitemid
, no_space
);
2870 void Spell::EffectCreateItem(uint32 i
)
2872 DoCreateItem(i
,m_spellInfo
->EffectItemType
[i
]);
2875 void Spell::EffectCreateItem2(uint32 i
)
2877 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
2879 Player
* player
= (Player
*)m_caster
;
2881 uint32 item_id
= m_spellInfo
->EffectItemType
[i
];
2883 DoCreateItem(i
, item_id
);
2885 // special case: fake item replaced by generate using spell_loot_template
2886 if (IsLootCraftingSpell(m_spellInfo
))
2888 if (!player
->HasItemCount(item_id
, 1))
2893 player
->DestroyItemCount(item_id
, count
, true);
2895 // create some random items
2896 player
->AutoStoreLoot(m_spellInfo
->Id
, LootTemplates_Spell
);
2900 void Spell::EffectCreateRandomItem(uint32 i
)
2902 if (m_caster
->GetTypeId()!=TYPEID_PLAYER
)
2904 Player
* player
= (Player
*)m_caster
;
2906 // create some random items
2907 player
->AutoStoreLoot(m_spellInfo
->Id
, LootTemplates_Spell
);
2910 void Spell::EffectPersistentAA(uint32 i
)
2912 float radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
2914 if (Player
* modOwner
= m_caster
->GetSpellModOwner())
2915 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_RADIUS
, radius
);
2917 int32 duration
= GetSpellDuration(m_spellInfo
);
2918 DynamicObject
* dynObj
= new DynamicObject
;
2919 if (!dynObj
->Create(m_caster
->GetMap()->GenerateLocalLowGuid(HIGHGUID_DYNAMICOBJECT
), m_caster
, m_spellInfo
->Id
, i
, m_targets
.m_destX
, m_targets
.m_destY
, m_targets
.m_destZ
, duration
, radius
))
2924 dynObj
->SetUInt32Value(OBJECT_FIELD_TYPE
, 65);
2925 dynObj
->SetUInt32Value(GAMEOBJECT_DISPLAYID
, 368003);
2926 dynObj
->SetUInt32Value(DYNAMICOBJECT_BYTES
, 0x01eeeeee);
2927 m_caster
->AddDynObject(dynObj
);
2928 m_caster
->GetMap()->Add(dynObj
);
2931 void Spell::EffectEnergize(uint32 i
)
2935 if(!unitTarget
->isAlive())
2938 if(m_spellInfo
->EffectMiscValue
[i
] < 0 || m_spellInfo
->EffectMiscValue
[i
] >= MAX_POWERS
)
2941 Powers power
= Powers(m_spellInfo
->EffectMiscValue
[i
]);
2943 // Some level depends spells
2944 int level_multiplier
= 0;
2946 switch (m_spellInfo
->Id
)
2948 case 9512: // Restore Energy
2949 level_diff
= m_caster
->getLevel() - 40;
2950 level_multiplier
= 2;
2952 case 24571: // Blood Fury
2953 level_diff
= m_caster
->getLevel() - 60;
2954 level_multiplier
= 10;
2956 case 24532: // Burst of Energy
2957 level_diff
= m_caster
->getLevel() - 60;
2958 level_multiplier
= 4;
2960 case 31930: // Judgements of the Wise
2961 case 48542: // Revitalize (mana restore case)
2962 case 63375: // Improved Stormstrike
2963 damage
= damage
* unitTarget
->GetCreateMana() / 100;
2970 damage
-= level_multiplier
* level_diff
;
2975 if(unitTarget
->GetMaxPower(power
) == 0)
2978 m_caster
->EnergizeBySpell(unitTarget
, m_spellInfo
->Id
, damage
, power
);
2980 // Mad Alchemist's Potion
2981 if (m_spellInfo
->Id
== 45051)
2983 // find elixirs on target
2984 uint32 elixir_mask
= 0;
2985 Unit::AuraMap
& Auras
= unitTarget
->GetAuras();
2986 for(Unit::AuraMap::iterator itr
= Auras
.begin(); itr
!= Auras
.end(); ++itr
)
2988 uint32 spell_id
= itr
->second
->GetId();
2989 if(uint32 mask
= sSpellMgr
.GetSpellElixirMask(spell_id
))
2990 elixir_mask
|= mask
;
2993 // get available elixir mask any not active type from battle/guardian (and flask if no any)
2994 elixir_mask
= (elixir_mask
& ELIXIR_FLASK_MASK
) ^ ELIXIR_FLASK_MASK
;
2996 // get all available elixirs by mask and spell level
2997 std::vector
<uint32
> elixirs
;
2998 SpellElixirMap
const& m_spellElixirs
= sSpellMgr
.GetSpellElixirMap();
2999 for(SpellElixirMap::const_iterator itr
= m_spellElixirs
.begin(); itr
!= m_spellElixirs
.end(); ++itr
)
3001 if (itr
->second
& elixir_mask
)
3003 if (itr
->second
& (ELIXIR_UNSTABLE_MASK
| ELIXIR_SHATTRATH_MASK
))
3006 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
3007 if (spellInfo
&& (spellInfo
->spellLevel
< m_spellInfo
->spellLevel
|| spellInfo
->spellLevel
> unitTarget
->getLevel()))
3010 elixirs
.push_back(itr
->first
);
3014 if (!elixirs
.empty())
3016 // cast random elixir on target
3017 uint32 rand_spell
= urand(0,elixirs
.size()-1);
3018 m_caster
->CastSpell(unitTarget
,elixirs
[rand_spell
],true,m_CastItem
);
3023 void Spell::EffectEnergisePct(uint32 i
)
3027 if (!unitTarget
->isAlive())
3030 if (m_spellInfo
->EffectMiscValue
[i
] < 0 || m_spellInfo
->EffectMiscValue
[i
] >= MAX_POWERS
)
3033 Powers power
= Powers(m_spellInfo
->EffectMiscValue
[i
]);
3035 uint32 maxPower
= unitTarget
->GetMaxPower(power
);
3039 uint32 gain
= damage
* maxPower
/ 100;
3040 m_caster
->EnergizeBySpell(unitTarget
, m_spellInfo
->Id
, gain
, power
);
3043 void Spell::SendLoot(uint64 guid
, LootType loottype
)
3045 Player
* player
= (Player
*)m_caster
;
3051 if (Script
->GOHello(player
, gameObjTarget
))
3054 switch (gameObjTarget
->GetGoType())
3056 case GAMEOBJECT_TYPE_DOOR
:
3057 case GAMEOBJECT_TYPE_BUTTON
:
3058 gameObjTarget
->UseDoorOrButton();
3059 player
->GetMap()->ScriptsStart(sGameObjectScripts
, gameObjTarget
->GetDBTableGUIDLow(), player
, gameObjTarget
);
3062 case GAMEOBJECT_TYPE_QUESTGIVER
:
3063 // start or end quest
3064 player
->PrepareQuestMenu(guid
);
3065 player
->SendPreparedQuest(guid
);
3068 case GAMEOBJECT_TYPE_SPELL_FOCUS
:
3069 // triggering linked GO
3070 if (uint32 trapEntry
= gameObjTarget
->GetGOInfo()->spellFocus
.linkedTrapId
)
3071 gameObjTarget
->TriggeringLinkedGameObject(trapEntry
,m_caster
);
3074 case GAMEOBJECT_TYPE_GOOBER
:
3075 // goober_scripts can be triggered if the player don't have the quest
3076 if (gameObjTarget
->GetGOInfo()->goober
.eventId
)
3078 sLog
.outDebug("Goober ScriptStart id %u for GO %u", gameObjTarget
->GetGOInfo()->goober
.eventId
,gameObjTarget
->GetDBTableGUIDLow());
3079 player
->GetMap()->ScriptsStart(sEventScripts
, gameObjTarget
->GetGOInfo()->goober
.eventId
, player
, gameObjTarget
);
3082 // cast goober spell
3083 if (gameObjTarget
->GetGOInfo()->goober
.questId
)
3084 ///Quest require to be active for GO using
3085 if (player
->GetQuestStatus(gameObjTarget
->GetGOInfo()->goober
.questId
) != QUEST_STATUS_INCOMPLETE
)
3088 gameObjTarget
->AddUniqueUse(player
);
3089 gameObjTarget
->SetLootState(GO_JUST_DEACTIVATED
);
3091 //TODO? Objective counting called without spell check but with quest objective check
3092 // if send spell id then this line will duplicate to spell casting call (double counting)
3093 // So we or have this line and not required in quest_template have reqSpellIdN
3094 // or must remove this line and required in DB have data in quest_template have reqSpellIdN for all quest using cases.
3095 player
->CastedCreatureOrGO(gameObjTarget
->GetEntry(), gameObjTarget
->GetGUID(), 0);
3097 // triggering linked GO
3098 if (uint32 trapEntry
= gameObjTarget
->GetGOInfo()->goober
.linkedTrapId
)
3099 gameObjTarget
->TriggeringLinkedGameObject(trapEntry
,m_caster
);
3103 case GAMEOBJECT_TYPE_CHEST
:
3104 // TODO: possible must be moved to loot release (in different from linked triggering)
3105 if (gameObjTarget
->GetGOInfo()->chest
.eventId
)
3107 sLog
.outDebug("Chest ScriptStart id %u for GO %u", gameObjTarget
->GetGOInfo()->chest
.eventId
,gameObjTarget
->GetDBTableGUIDLow());
3108 player
->GetMap()->ScriptsStart(sEventScripts
, gameObjTarget
->GetGOInfo()->chest
.eventId
, player
, gameObjTarget
);
3111 // triggering linked GO
3112 if (uint32 trapEntry
= gameObjTarget
->GetGOInfo()->chest
.linkedTrapId
)
3113 gameObjTarget
->TriggeringLinkedGameObject(trapEntry
,m_caster
);
3115 // Don't return, let loots been taken
3122 player
->SendLoot(guid
, loottype
);
3125 void Spell::EffectOpenLock(uint32 effIndex
)
3127 if (!m_caster
|| m_caster
->GetTypeId() != TYPEID_PLAYER
)
3129 sLog
.outDebug( "WORLD: Open Lock - No Player Caster!");
3133 Player
* player
= (Player
*)m_caster
;
3141 GameObjectInfo
const* goInfo
= gameObjTarget
->GetGOInfo();
3142 // Arathi Basin banner opening !
3143 if (goInfo
->type
== GAMEOBJECT_TYPE_BUTTON
&& goInfo
->button
.noDamageImmune
||
3144 goInfo
->type
== GAMEOBJECT_TYPE_GOOBER
&& goInfo
->goober
.losOK
)
3146 //CanUseBattleGroundObject() already called in CheckCast()
3147 // in battleground check
3148 if (BattleGround
*bg
= player
->GetBattleGround())
3150 // check if it's correct bg
3151 if (bg
->GetTypeID() == BATTLEGROUND_AB
|| bg
->GetTypeID() == BATTLEGROUND_AV
)
3152 bg
->EventPlayerClickedOnFlag(player
, gameObjTarget
);
3156 else if (goInfo
->type
== GAMEOBJECT_TYPE_FLAGSTAND
)
3158 //CanUseBattleGroundObject() already called in CheckCast()
3159 // in battleground check
3160 if (BattleGround
*bg
= player
->GetBattleGround())
3162 if (bg
->GetTypeID() == BATTLEGROUND_EY
)
3163 bg
->EventPlayerClickedOnFlag(player
, gameObjTarget
);
3167 lockId
= goInfo
->GetLockId();
3168 guid
= gameObjTarget
->GetGUID();
3170 else if (itemTarget
)
3172 lockId
= itemTarget
->GetProto()->LockID
;
3173 guid
= itemTarget
->GetGUID();
3177 sLog
.outDebug( "WORLD: Open Lock - No GameObject/Item Target!");
3181 SkillType skillId
= SKILL_NONE
;
3182 int32 reqSkillValue
= 0;
3185 SpellCastResult res
= CanOpenLock(effIndex
, lockId
, skillId
, reqSkillValue
, skillValue
);
3186 if (res
!= SPELL_CAST_OK
)
3188 SendCastResult(res
);
3192 SendLoot(guid
, LOOT_SKINNING
);
3194 // not allow use skill grow at item base open
3195 if (!m_CastItem
&& skillId
!= SKILL_NONE
)
3197 // update skill if really known
3198 if (uint32 pureSkillValue
= player
->GetPureSkillValue(skillId
))
3202 // Allow one skill-up until respawned
3203 if (!gameObjTarget
->IsInSkillupList(player
->GetGUIDLow()) &&
3204 player
->UpdateGatherSkill(skillId
, pureSkillValue
, reqSkillValue
))
3205 gameObjTarget
->AddToSkillupList(player
->GetGUIDLow());
3207 else if (itemTarget
)
3210 player
->UpdateGatherSkill(skillId
, pureSkillValue
, reqSkillValue
);
3216 void Spell::EffectSummonChangeItem(uint32 i
)
3218 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
3221 Player
*player
= (Player
*)m_caster
;
3223 // applied only to using item
3227 // ... only to item in own inventory/bank/equip_slot
3228 if (m_CastItem
->GetOwnerGUID()!=player
->GetGUID())
3231 uint32 newitemid
= m_spellInfo
->EffectItemType
[i
];
3235 uint16 pos
= m_CastItem
->GetPos();
3237 Item
*pNewItem
= Item::CreateItem( newitemid
, 1, player
);
3241 for(uint8 j
= PERM_ENCHANTMENT_SLOT
; j
<=TEMP_ENCHANTMENT_SLOT
; ++j
)
3243 if (m_CastItem
->GetEnchantmentId(EnchantmentSlot(j
)))
3244 pNewItem
->SetEnchantment(EnchantmentSlot(j
), m_CastItem
->GetEnchantmentId(EnchantmentSlot(j
)), m_CastItem
->GetEnchantmentDuration(EnchantmentSlot(j
)), m_CastItem
->GetEnchantmentCharges(EnchantmentSlot(j
)));
3247 if (m_CastItem
->GetUInt32Value(ITEM_FIELD_DURABILITY
) < m_CastItem
->GetUInt32Value(ITEM_FIELD_MAXDURABILITY
))
3249 double loosePercent
= 1 - m_CastItem
->GetUInt32Value(ITEM_FIELD_DURABILITY
) / double(m_CastItem
->GetUInt32Value(ITEM_FIELD_MAXDURABILITY
));
3250 player
->DurabilityLoss(pNewItem
, loosePercent
);
3253 if (player
->IsInventoryPos(pos
))
3255 ItemPosCountVec dest
;
3256 uint8 msg
= player
->CanStoreItem( m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(), dest
, pNewItem
, true );
3257 if (msg
== EQUIP_ERR_OK
)
3259 player
->DestroyItem(m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(), true);
3261 // prevent crash at access and unexpected charges counting with item update queue corrupt
3262 if (m_CastItem
==m_targets
.getItemTarget())
3263 m_targets
.setItemTarget(NULL
);
3267 player
->StoreItem( dest
, pNewItem
, true);
3271 else if (player
->IsBankPos (pos
))
3273 ItemPosCountVec dest
;
3274 uint8 msg
= player
->CanBankItem( m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(), dest
, pNewItem
, true );
3275 if (msg
== EQUIP_ERR_OK
)
3277 player
->DestroyItem(m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(), true);
3279 // prevent crash at access and unexpected charges counting with item update queue corrupt
3280 if (m_CastItem
==m_targets
.getItemTarget())
3281 m_targets
.setItemTarget(NULL
);
3285 player
->BankItem( dest
, pNewItem
, true);
3289 else if (player
->IsEquipmentPos (pos
))
3292 uint8 msg
= player
->CanEquipItem( m_CastItem
->GetSlot(), dest
, pNewItem
, true );
3293 if (msg
== EQUIP_ERR_OK
)
3295 player
->DestroyItem(m_CastItem
->GetBagSlot(), m_CastItem
->GetSlot(), true);
3297 // prevent crash at access and unexpected charges counting with item update queue corrupt
3298 if (m_CastItem
==m_targets
.getItemTarget())
3299 m_targets
.setItemTarget(NULL
);
3303 player
->EquipItem( dest
, pNewItem
, true);
3304 player
->AutoUnequipOffhandIfNeed();
3313 void Spell::EffectProficiency(uint32
/*i*/)
3315 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3317 Player
*p_target
= (Player
*)unitTarget
;
3319 uint32 subClassMask
= m_spellInfo
->EquippedItemSubClassMask
;
3320 if (m_spellInfo
->EquippedItemClass
== ITEM_CLASS_WEAPON
&& !(p_target
->GetWeaponProficiency() & subClassMask
))
3322 p_target
->AddWeaponProficiency(subClassMask
);
3323 p_target
->SendProficiency(ITEM_CLASS_WEAPON
, p_target
->GetWeaponProficiency());
3325 if (m_spellInfo
->EquippedItemClass
== ITEM_CLASS_ARMOR
&& !(p_target
->GetArmorProficiency() & subClassMask
))
3327 p_target
->AddArmorProficiency(subClassMask
);
3328 p_target
->SendProficiency(ITEM_CLASS_ARMOR
, p_target
->GetArmorProficiency());
3332 void Spell::EffectApplyAreaAura(uint32 i
)
3336 if (!unitTarget
->isAlive())
3339 AreaAura
* Aur
= new AreaAura(m_spellInfo
, i
, &m_currentBasePoints
[i
], unitTarget
, m_caster
, m_CastItem
);
3340 unitTarget
->AddAura(Aur
);
3343 void Spell::EffectSummonType(uint32 i
)
3345 uint32 prop_id
= m_spellInfo
->EffectMiscValueB
[i
];
3346 SummonPropertiesEntry
const *summon_prop
= sSummonPropertiesStore
.LookupEntry(prop_id
);
3349 sLog
.outError("EffectSummonType: Unhandled summon type %u", prop_id
);
3353 switch(summon_prop
->Group
)
3355 // faction handled later on, or loaded from template
3356 case SUMMON_PROP_GROUP_WILD
:
3357 case SUMMON_PROP_GROUP_FRIENDLY
:
3359 switch(summon_prop
->Type
)
3361 case SUMMON_PROP_TYPE_OTHER
:
3363 // those are classical totems - effectbasepoints is their hp and not summon ammount!
3364 //SUMMON_TYPE_TOTEM = 121: 23035, battlestands
3365 //SUMMON_TYPE_TOTEM2 = 647: 52893, Anti-Magic Zone (npc used)
3366 if(prop_id
== 121 || prop_id
== 647)
3367 EffectSummonTotem(i
);
3369 EffectSummonWild(i
, summon_prop
->FactionId
);
3372 case SUMMON_PROP_TYPE_SUMMON
:
3373 case SUMMON_PROP_TYPE_GUARDIAN
:
3374 case SUMMON_PROP_TYPE_ARMY
:
3375 case SUMMON_PROP_TYPE_DK
:
3376 case SUMMON_PROP_TYPE_CONSTRUCT
:
3378 // JC golems - 32804, etc -- fits much better totem AI
3379 if(m_spellInfo
->SpellIconID
== 2056)
3380 EffectSummonTotem(i
);
3381 if(prop_id
== 832) // scrapbot
3382 EffectSummonWild(i
, summon_prop
->FactionId
);
3384 EffectSummonGuardian(i
, summon_prop
->FactionId
);
3387 case SUMMON_PROP_TYPE_TOTEM
:
3388 EffectSummonTotem(i
, summon_prop
->Slot
);
3390 case SUMMON_PROP_TYPE_CRITTER
:
3391 EffectSummonCritter(i
, summon_prop
->FactionId
);
3393 case SUMMON_PROP_TYPE_PHASING
:
3394 case SUMMON_PROP_TYPE_LIGHTWELL
:
3395 case SUMMON_PROP_TYPE_REPAIR_BOT
:
3396 EffectSummonWild(i
, summon_prop
->FactionId
);
3398 case SUMMON_PROP_TYPE_SIEGE_VEH
:
3399 case SUMMON_PROP_TYPE_DRAKE_VEH
:
3401 // EffectSummonVehicle(i);
3404 sLog
.outError("EffectSummonType: Unhandled summon type %u", summon_prop
->Type
);
3409 case SUMMON_PROP_GROUP_PETS
:
3411 // FIXME : multiple summons - not yet supported as pet
3412 //1562 - force of nature - sid 33831
3413 //1161 - feral spirit - sid 51533
3414 if(prop_id
== 1562) // 3 uncontrolable instead of one controllable :/
3415 EffectSummonGuardian(i
, summon_prop
->FactionId
);
3420 case SUMMON_PROP_GROUP_CONTROLLABLE
:
3423 // maybe wrong - but thats the handler currently used for those
3424 EffectSummonGuardian(i
, summon_prop
->FactionId
);
3427 case SUMMON_PROP_GROUP_VEHICLE
:
3430 // EffectSummonVehicle(i);
3434 sLog
.outError("EffectSummonType: Unhandled summon group type %u", summon_prop
->Group
);
3439 void Spell::EffectSummon(uint32 i
)
3441 if (m_caster
->GetPetGUID())
3446 uint32 pet_entry
= m_spellInfo
->EffectMiscValue
[i
];
3449 uint32 level
= m_caster
->getLevel();
3450 Pet
* spawnCreature
= new Pet(SUMMON_PET
);
3452 int32 duration
= GetSpellDuration(m_spellInfo
);
3453 if(Player
* modOwner
= m_caster
->GetSpellModOwner())
3454 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_DURATION
, duration
);
3456 if (m_caster
->GetTypeId()==TYPEID_PLAYER
&& spawnCreature
->LoadPetFromDB((Player
*)m_caster
,pet_entry
))
3458 // Summon in dest location
3460 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
3462 x
= m_targets
.m_destX
;
3463 y
= m_targets
.m_destY
;
3464 z
= m_targets
.m_destZ
;
3465 spawnCreature
->Relocate(m_targets
.m_destX
, m_targets
.m_destY
, m_targets
.m_destZ
, -m_caster
->GetOrientation());
3468 // set timer for unsummon
3470 spawnCreature
->SetDuration(duration
);
3475 Map
*map
= m_caster
->GetMap();
3476 uint32 pet_number
= sObjectMgr
.GeneratePetNumber();
3477 if (!spawnCreature
->Create(map
->GenerateLocalLowGuid(HIGHGUID_PET
), map
, m_caster
->GetPhaseMask(),
3478 m_spellInfo
->EffectMiscValue
[i
], pet_number
))
3480 sLog
.outErrorDb("Spell::EffectSummon: no such creature entry %u",m_spellInfo
->EffectMiscValue
[i
]);
3481 delete spawnCreature
;
3485 // Summon in dest location
3487 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
3489 x
= m_targets
.m_destX
;
3490 y
= m_targets
.m_destY
;
3491 z
= m_targets
.m_destZ
;
3494 m_caster
->GetClosePoint(x
, y
, z
, spawnCreature
->GetObjectSize());
3496 spawnCreature
->Relocate(x
, y
, z
, -m_caster
->GetOrientation());
3498 if (!spawnCreature
->IsPositionValid())
3500 sLog
.outError("Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
3501 spawnCreature
->GetGUIDLow(), spawnCreature
->GetEntry(), spawnCreature
->GetPositionX(), spawnCreature
->GetPositionY());
3502 delete spawnCreature
;
3506 // set timer for unsummon
3508 spawnCreature
->SetDuration(duration
);
3510 spawnCreature
->SetOwnerGUID(m_caster
->GetGUID());
3511 spawnCreature
->SetUInt32Value(UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_NONE
);
3512 spawnCreature
->setPowerType(POWER_MANA
);
3513 spawnCreature
->setFaction(m_caster
->getFaction());
3514 spawnCreature
->SetUInt32Value(UNIT_FIELD_FLAGS
, 0);
3515 spawnCreature
->SetUInt32Value(UNIT_FIELD_BYTES_0
, 2048);
3516 spawnCreature
->SetUInt32Value(UNIT_FIELD_BYTES_1
, 0);
3517 spawnCreature
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, 0);
3518 spawnCreature
->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE
, 0);
3519 spawnCreature
->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP
, 1000);
3520 spawnCreature
->SetCreatorGUID(m_caster
->GetGUID());
3521 spawnCreature
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
3523 spawnCreature
->InitStatsForLevel(level
, m_caster
);
3525 spawnCreature
->GetCharmInfo()->SetPetNumber(pet_number
, false);
3527 spawnCreature
->AIM_Initialize();
3528 spawnCreature
->InitPetCreateSpells();
3529 spawnCreature
->InitLevelupSpellsForLevel();
3530 spawnCreature
->SetHealth(spawnCreature
->GetMaxHealth());
3531 spawnCreature
->SetPower(POWER_MANA
, spawnCreature
->GetMaxPower(POWER_MANA
));
3533 std::string name
= m_caster
->GetName();
3534 name
.append(petTypeSuffix
[spawnCreature
->getPetType()]);
3535 spawnCreature
->SetName( name
);
3537 map
->Add((Creature
*)spawnCreature
);
3539 m_caster
->SetPet(spawnCreature
);
3541 if (m_caster
->GetTypeId() == TYPEID_PLAYER
)
3543 spawnCreature
->GetCharmInfo()->SetReactState( REACT_DEFENSIVE
);
3544 spawnCreature
->SavePetToDB(PET_SAVE_AS_CURRENT
);
3545 ((Player
*)m_caster
)->PetSpellInitialize();
3549 void Spell::EffectLearnSpell(uint32 i
)
3554 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3556 if (m_caster
->GetTypeId() == TYPEID_PLAYER
)
3557 EffectLearnPetSpell(i
);
3562 Player
*player
= (Player
*)unitTarget
;
3564 uint32 spellToLearn
= ((m_spellInfo
->Id
==SPELL_ID_GENERIC_LEARN
) || (m_spellInfo
->Id
==SPELL_ID_GENERIC_LEARN_PET
)) ? damage
: m_spellInfo
->EffectTriggerSpell
[i
];
3565 player
->learnSpell(spellToLearn
,false);
3567 sLog
.outDebug( "Spell: Player %u has learned spell %u from NpcGUID=%u", player
->GetGUIDLow(), spellToLearn
, m_caster
->GetGUIDLow() );
3570 void Spell::EffectDispel(uint32 i
)
3575 // Fill possible dispell list
3576 std::vector
<Aura
*> dispel_list
;
3578 // Create dispel mask by dispel type
3579 uint32 dispel_type
= m_spellInfo
->EffectMiscValue
[i
];
3580 uint32 dispelMask
= GetDispellMask( DispelType(dispel_type
) );
3581 Unit::AuraMap
const& auras
= unitTarget
->GetAuras();
3582 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3584 Aura
*aur
= (*itr
).second
;
3585 if (aur
&& (1<<aur
->GetSpellProto()->Dispel
) & dispelMask
)
3587 if(aur
->GetSpellProto()->Dispel
== DISPEL_MAGIC
)
3589 bool positive
= true;
3590 if (!aur
->IsPositive())
3593 positive
= (aur
->GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_NEGATIVE
)==0;
3595 // do not remove positive auras if friendly target
3596 // negative auras if non-friendly target
3597 if (positive
== unitTarget
->IsFriendlyTo(m_caster
))
3600 // Add aura to dispel list (all stack cases)
3601 for(int k
= 0; k
< aur
->GetStackAmount(); ++k
)
3602 dispel_list
.push_back(aur
);
3605 // Ok if exist some buffs for dispel try dispel it
3606 if (!dispel_list
.empty())
3608 std::list
< std::pair
<uint32
,uint64
> > success_list
;// (spell_id,casterGuid)
3609 std::list
< uint32
> fail_list
; // spell_id
3611 // some spells have effect value = 0 and all from its by meaning expect 1
3615 // Dispell N = damage buffs (or while exist buffs for dispel)
3616 for (int32 count
=0; count
< damage
&& !dispel_list
.empty(); ++count
)
3618 // Random select buff for dispel
3619 std::vector
<Aura
*>::iterator dispel_itr
= dispel_list
.begin();
3620 std::advance(dispel_itr
,urand(0, dispel_list
.size()-1));
3622 Aura
*aur
= *dispel_itr
;
3624 // remove entry from dispel_list
3625 dispel_list
.erase(dispel_itr
);
3627 SpellEntry
const* spellInfo
= aur
->GetSpellProto();
3628 // Base dispel chance
3629 // TODO: possible chance depend from spell level??
3630 int32 miss_chance
= 0;
3631 // Apply dispel mod from aura caster
3632 if (Unit
*caster
= aur
->GetCaster())
3634 if ( Player
* modOwner
= caster
->GetSpellModOwner() )
3635 modOwner
->ApplySpellMod(spellInfo
->Id
, SPELLMOD_RESIST_DISPEL_CHANCE
, miss_chance
, this);
3638 if (roll_chance_i(miss_chance
))
3639 fail_list
.push_back(spellInfo
->Id
);
3641 success_list
.push_back(std::pair
<uint32
,uint64
>(aur
->GetId(),aur
->GetCasterGUID()));
3643 // Send success log and really remove auras
3644 if (!success_list
.empty())
3646 int32 count
= success_list
.size();
3647 WorldPacket
data(SMSG_SPELLDISPELLOG
, 8+8+4+1+4+count
*5);
3648 data
.append(unitTarget
->GetPackGUID()); // Victim GUID
3649 data
.append(m_caster
->GetPackGUID()); // Caster GUID
3650 data
<< uint32(m_spellInfo
->Id
); // Dispel spell id
3651 data
<< uint8(0); // not used
3652 data
<< uint32(count
); // count
3653 for (std::list
<std::pair
<uint32
,uint64
> >::iterator j
= success_list
.begin(); j
!= success_list
.end(); ++j
)
3655 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(j
->first
);
3656 data
<< uint32(spellInfo
->Id
); // Spell Id
3657 data
<< uint8(0); // 0 - dispeled !=0 cleansed
3658 unitTarget
->RemoveSingleAuraDueToSpellByDispel(spellInfo
->Id
, j
->second
, m_caster
);
3660 m_caster
->SendMessageToSet(&data
, true);
3662 // On success dispel
3664 if (m_spellInfo
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& m_spellInfo
->Category
== SPELLCATEGORY_DEVOUR_MAGIC
)
3666 int32 heal_amount
= m_spellInfo
->CalculateSimpleValue(1);
3667 m_caster
->CastCustomSpell(m_caster
, 19658, &heal_amount
, NULL
, NULL
, true);
3670 // Send fail log to client
3671 if (!fail_list
.empty())
3673 // Failed to dispell
3674 WorldPacket
data(SMSG_DISPEL_FAILED
, 8+8+4+4*fail_list
.size());
3675 data
<< uint64(m_caster
->GetGUID()); // Caster GUID
3676 data
<< uint64(unitTarget
->GetGUID()); // Victim GUID
3677 data
<< uint32(m_spellInfo
->Id
); // Dispell spell id
3678 for (std::list
< uint32
>::iterator j
= fail_list
.begin(); j
!= fail_list
.end(); ++j
)
3679 data
<< uint32(*j
); // Spell Id
3680 m_caster
->SendMessageToSet(&data
, true);
3685 void Spell::EffectDualWield(uint32
/*i*/)
3687 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
3688 ((Player
*)unitTarget
)->SetCanDualWield(true);
3691 void Spell::EffectPull(uint32
/*i*/)
3693 // TODO: create a proper pull towards distract spell center for distract
3694 sLog
.outDebug("WORLD: Spell Effect DUMMY");
3697 void Spell::EffectDistract(uint32
/*i*/)
3699 // Check for possible target
3700 if (!unitTarget
|| unitTarget
->isInCombat())
3703 // target must be OK to do this
3704 if( unitTarget
->hasUnitState(UNIT_STAT_CONFUSED
| UNIT_STAT_STUNNED
| UNIT_STAT_FLEEING
) )
3707 float angle
= unitTarget
->GetAngle(m_targets
.m_destX
, m_targets
.m_destY
);
3709 if ( unitTarget
->GetTypeId() == TYPEID_PLAYER
)
3711 // For players just turn them
3713 ((Player
*)unitTarget
)->BuildTeleportAckMsg(&data
, unitTarget
->GetPositionX(), unitTarget
->GetPositionY(), unitTarget
->GetPositionZ(), angle
);
3714 ((Player
*)unitTarget
)->GetSession()->SendPacket( &data
);
3715 ((Player
*)unitTarget
)->SetPosition(unitTarget
->GetPositionX(), unitTarget
->GetPositionY(), unitTarget
->GetPositionZ(), angle
, false);
3719 // Set creature Distracted, Stop it, And turn it
3720 unitTarget
->SetOrientation(angle
);
3721 unitTarget
->StopMoving();
3722 unitTarget
->GetMotionMaster()->MoveDistract(damage
* IN_MILISECONDS
);
3726 void Spell::EffectPickPocket(uint32
/*i*/)
3728 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
3731 // victim must be creature and attackable
3732 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
|| m_caster
->IsFriendlyTo(unitTarget
))
3735 // victim have to be alive and humanoid or undead
3736 if (unitTarget
->isAlive() && (unitTarget
->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD
) != 0)
3738 int32 chance
= 10 + int32(m_caster
->getLevel()) - int32(unitTarget
->getLevel());
3740 if (chance
> irand(0, 19))
3742 // Stealing successful
3743 //sLog.outDebug("Sending loot from pickpocket");
3744 ((Player
*)m_caster
)->SendLoot(unitTarget
->GetGUID(),LOOT_PICKPOCKETING
);
3748 // Reveal action + get attack
3749 m_caster
->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH
);
3750 if (((Creature
*)unitTarget
)->AI())
3751 ((Creature
*)unitTarget
)->AI()->AttackedBy(m_caster
);
3756 void Spell::EffectAddFarsight(uint32 i
)
3758 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
3761 int32 duration
= GetSpellDuration(m_spellInfo
);
3762 DynamicObject
* dynObj
= new DynamicObject
;
3764 // set radius to 0: spell not expected to work as persistent aura
3765 if(!dynObj
->Create(m_caster
->GetMap()->GenerateLocalLowGuid(HIGHGUID_DYNAMICOBJECT
), m_caster
, m_spellInfo
->Id
, i
, m_targets
.m_destX
, m_targets
.m_destY
, m_targets
.m_destZ
, duration
, 0))
3770 dynObj
->SetUInt32Value(OBJECT_FIELD_TYPE
, 65);
3771 dynObj
->SetUInt32Value(DYNAMICOBJECT_BYTES
, 0x80000002);
3772 m_caster
->AddDynObject(dynObj
);
3773 m_caster
->GetMap()->Add(dynObj
);
3774 ((Player
*)m_caster
)->SetFarSightGUID(dynObj
->GetGUID());
3777 void Spell::EffectSummonWild(uint32 i
, uint32 forceFaction
)
3779 uint32 creature_entry
= m_spellInfo
->EffectMiscValue
[i
];
3780 if (!creature_entry
)
3783 uint32 level
= m_caster
->getLevel();
3785 // level of creature summoned using engineering item based at engineering skill level
3786 if (m_caster
->GetTypeId()==TYPEID_PLAYER
&& m_CastItem
)
3788 ItemPrototype
const *proto
= m_CastItem
->GetProto();
3789 if (proto
&& proto
->RequiredSkill
== SKILL_ENGINERING
)
3791 uint16 skill202
= ((Player
*)m_caster
)->GetSkillValue(SKILL_ENGINERING
);
3797 // select center of summon position
3798 float center_x
= m_targets
.m_destX
;
3799 float center_y
= m_targets
.m_destY
;
3800 float center_z
= m_targets
.m_destZ
;
3802 float radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
3803 int32 duration
= GetSpellDuration(m_spellInfo
);
3804 TempSummonType summonType
= (duration
== 0) ? TEMPSUMMON_DEAD_DESPAWN
: TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
;
3806 int32 amount
= damage
> 0 ? damage
: 1;
3808 for(int32 count
= 0; count
< amount
; ++count
)
3811 // If dest location if present
3812 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
3814 // Summon 1 unit in dest location
3817 px
= m_targets
.m_destX
;
3818 py
= m_targets
.m_destY
;
3819 pz
= m_targets
.m_destZ
;
3821 // Summon in random point all other units if location present
3823 m_caster
->GetRandomPoint(center_x
, center_y
, center_z
, radius
, px
, py
, pz
);
3825 // Summon if dest location not present near caster
3827 m_caster
->GetClosePoint(px
, py
, pz
, 3.0f
);
3829 if(Creature
*summon
= m_caster
->SummonCreature(creature_entry
, px
, py
, pz
, m_caster
->GetOrientation(), summonType
, duration
))
3831 summon
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
3832 summon
->SetCreatorGUID(m_caster
->GetGUID());
3835 summon
->setFaction(forceFaction
);
3840 void Spell::EffectSummonGuardian(uint32 i
, uint32 forceFaction
)
3842 uint32 pet_entry
= m_spellInfo
->EffectMiscValue
[i
];
3846 // in another case summon new
3847 uint32 level
= m_caster
->getLevel();
3849 // level of pet summoned using engineering item based at engineering skill level
3850 if (m_caster
->GetTypeId() == TYPEID_PLAYER
&& m_CastItem
)
3852 ItemPrototype
const *proto
= m_CastItem
->GetProto();
3853 if (proto
&& proto
->RequiredSkill
== SKILL_ENGINERING
)
3855 uint16 skill202
= ((Player
*)m_caster
)->GetSkillValue(SKILL_ENGINERING
);
3858 level
= skill202
/ 5;
3863 // select center of summon position
3864 float center_x
= m_targets
.m_destX
;
3865 float center_y
= m_targets
.m_destY
;
3866 float center_z
= m_targets
.m_destZ
;
3868 float radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
3869 int32 duration
= GetSpellDuration(m_spellInfo
);
3870 if(Player
* modOwner
= m_caster
->GetSpellModOwner())
3871 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_DURATION
, duration
);
3873 int32 amount
= damage
> 0 ? damage
: 1;
3875 for(int32 count
= 0; count
< amount
; ++count
)
3877 Pet
* spawnCreature
= new Pet(GUARDIAN_PET
);
3879 Map
*map
= m_caster
->GetMap();
3880 uint32 pet_number
= sObjectMgr
.GeneratePetNumber();
3881 if (!spawnCreature
->Create(map
->GenerateLocalLowGuid(HIGHGUID_PET
), map
,m_caster
->GetPhaseMask(),
3882 m_spellInfo
->EffectMiscValue
[i
], pet_number
))
3884 sLog
.outError("no such creature entry %u", m_spellInfo
->EffectMiscValue
[i
]);
3885 delete spawnCreature
;
3890 // If dest location if present
3891 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
3893 // Summon 1 unit in dest location
3896 px
= m_targets
.m_destX
;
3897 py
= m_targets
.m_destY
;
3898 pz
= m_targets
.m_destZ
;
3900 // Summon in random point all other units if location present
3902 m_caster
->GetRandomPoint(center_x
, center_y
, center_z
, radius
, px
, py
, pz
);
3904 // Summon if dest location not present near caster
3906 m_caster
->GetClosePoint(px
, py
, pz
,spawnCreature
->GetObjectSize());
3908 spawnCreature
->Relocate(px
, py
, pz
, m_caster
->GetOrientation());
3910 if (!spawnCreature
->IsPositionValid())
3912 sLog
.outError("Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)",
3913 spawnCreature
->GetGUIDLow(), spawnCreature
->GetEntry(), spawnCreature
->GetPositionX(), spawnCreature
->GetPositionY());
3914 delete spawnCreature
;
3919 spawnCreature
->SetDuration(duration
);
3921 spawnCreature
->SetOwnerGUID(m_caster
->GetGUID());
3922 spawnCreature
->setPowerType(POWER_MANA
);
3923 spawnCreature
->SetUInt32Value(UNIT_NPC_FLAGS
, spawnCreature
->GetCreatureInfo()->npcflag
);
3924 spawnCreature
->setFaction(forceFaction
? forceFaction
: m_caster
->getFaction());
3925 spawnCreature
->SetUInt32Value(UNIT_FIELD_FLAGS
, 0);
3926 spawnCreature
->SetUInt32Value(UNIT_FIELD_BYTES_1
, 0);
3927 spawnCreature
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, 0);
3928 spawnCreature
->SetCreatorGUID(m_caster
->GetGUID());
3929 spawnCreature
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
3931 spawnCreature
->InitStatsForLevel(level
, m_caster
);
3932 spawnCreature
->GetCharmInfo()->SetPetNumber(pet_number
, false);
3934 spawnCreature
->AIM_Initialize();
3936 m_caster
->AddGuardian(spawnCreature
);
3938 map
->Add((Creature
*)spawnCreature
);
3942 void Spell::EffectTeleUnitsFaceCaster(uint32 i
)
3947 if (unitTarget
->isInFlight())
3950 float dis
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
3953 m_caster
->GetClosePoint(fx
, fy
, fz
, unitTarget
->GetObjectSize(), dis
);
3955 unitTarget
->NearTeleportTo(fx
, fy
, fz
, -m_caster
->GetOrientation(), unitTarget
==m_caster
);
3958 void Spell::EffectLearnSkill(uint32 i
)
3960 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3966 uint32 skillid
= m_spellInfo
->EffectMiscValue
[i
];
3967 uint16 skillval
= ((Player
*)unitTarget
)->GetPureSkillValue(skillid
);
3968 ((Player
*)unitTarget
)->SetSkill(skillid
, skillval
? skillval
: 1, damage
* 75);
3971 void Spell::EffectAddHonor(uint32
/*i*/)
3973 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
3976 // not scale value for item based reward (/10 value expected)
3979 ((Player
*)unitTarget
)->RewardHonor(NULL
, 1, damage
/ 10);
3980 sLog
.outDebug("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());
3984 // do not allow to add too many honor for player (50 * 21) = 1040 at level 70, or (50 * 31) = 1550 at level 80
3987 uint32 honor_reward
= MaNGOS::Honor::hk_honor_at_level(unitTarget
->getLevel(), damage
);
3988 ((Player
*)unitTarget
)->RewardHonor(NULL
, 1, honor_reward
);
3989 sLog
.outDebug("SpellEffect::AddHonor (spell_id %u) rewards %u honor points (scale) to player: %u", m_spellInfo
->Id
, honor_reward
, ((Player
*)unitTarget
)->GetGUIDLow());
3993 //maybe we have correct honor_gain in damage already
3994 ((Player
*)unitTarget
)->RewardHonor(NULL
, 1, damage
);
3995 sLog
.outError("SpellEffect::AddHonor (spell_id %u) rewards %u honor points (non scale) for player: %u", m_spellInfo
->Id
, damage
, ((Player
*)unitTarget
)->GetGUIDLow());
3999 void Spell::EffectTradeSkill(uint32
/*i*/)
4001 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
4003 // uint32 skillid = m_spellInfo->EffectMiscValue[i];
4004 // uint16 skillmax = ((Player*)unitTarget)->(skillid);
4005 // ((Player*)unitTarget)->SetSkill(skillid,skillval?skillval:1,skillmax+75);
4008 void Spell::EffectEnchantItemPerm(uint32 effect_idx
)
4010 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
4015 Player
* p_caster
= (Player
*)m_caster
;
4017 // not grow at item use at item case
4018 p_caster
->UpdateCraftSkill(m_spellInfo
->Id
);
4020 uint32 enchant_id
= m_spellInfo
->EffectMiscValue
[effect_idx
];
4024 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
4028 // item can be in trade slot and have owner diff. from caster
4029 Player
* item_owner
= itemTarget
->GetOwner();
4033 if (item_owner
!=p_caster
&& p_caster
->GetSession()->GetSecurity() > SEC_PLAYER
&& sWorld
.getConfig(CONFIG_GM_LOG_TRADE
) )
4035 sLog
.outCommand(p_caster
->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
4036 p_caster
->GetName(),p_caster
->GetSession()->GetAccountId(),
4037 itemTarget
->GetProto()->Name1
,itemTarget
->GetEntry(),
4038 item_owner
->GetName(),item_owner
->GetSession()->GetAccountId());
4041 // remove old enchanting before applying new if equipped
4042 item_owner
->ApplyEnchantment(itemTarget
,PERM_ENCHANTMENT_SLOT
,false);
4044 itemTarget
->SetEnchantment(PERM_ENCHANTMENT_SLOT
, enchant_id
, 0, 0);
4046 // add new enchanting if equipped
4047 item_owner
->ApplyEnchantment(itemTarget
,PERM_ENCHANTMENT_SLOT
,true);
4050 void Spell::EffectEnchantItemPrismatic(uint32 effect_idx
)
4052 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
4057 Player
* p_caster
= (Player
*)m_caster
;
4059 uint32 enchant_id
= m_spellInfo
->EffectMiscValue
[effect_idx
];
4063 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
4067 // support only enchantings with add socket in this slot
4069 bool add_socket
= false;
4070 for(int i
= 0; i
< 3; ++i
)
4072 if (pEnchant
->type
[i
]==ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET
)
4080 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.",
4081 m_spellInfo
->Id
,SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC
,ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET
);
4086 // item can be in trade slot and have owner diff. from caster
4087 Player
* item_owner
= itemTarget
->GetOwner();
4091 if (item_owner
!=p_caster
&& p_caster
->GetSession()->GetSecurity() > SEC_PLAYER
&& sWorld
.getConfig(CONFIG_GM_LOG_TRADE
) )
4093 sLog
.outCommand(p_caster
->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
4094 p_caster
->GetName(),p_caster
->GetSession()->GetAccountId(),
4095 itemTarget
->GetProto()->Name1
,itemTarget
->GetEntry(),
4096 item_owner
->GetName(),item_owner
->GetSession()->GetAccountId());
4099 // remove old enchanting before applying new if equipped
4100 item_owner
->ApplyEnchantment(itemTarget
,PRISMATIC_ENCHANTMENT_SLOT
,false);
4102 itemTarget
->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT
, enchant_id
, 0, 0);
4104 // add new enchanting if equipped
4105 item_owner
->ApplyEnchantment(itemTarget
,PRISMATIC_ENCHANTMENT_SLOT
,true);
4108 void Spell::EffectEnchantItemTmp(uint32 i
)
4110 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
4113 Player
* p_caster
= (Player
*)m_caster
;
4115 // Rockbiter Weapon apply to both weapon
4116 if (m_spellInfo
->SpellFamilyName
== SPELLFAMILY_SHAMAN
&& m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000400000))
4118 uint32 spell_id
= 0;
4120 // enchanting spell selected by calculated damage-per-sec stored in Effect[1] base value
4121 // Note: damage calculated (correctly) with rounding int32(float(v)) but
4122 // RW enchantments applied damage int32(float(v)+0.5), this create 0..1 difference sometime
4126 case 2: spell_id
= 36744; break; // 0% [ 7% == 2, 14% == 2, 20% == 2]
4128 case 4: spell_id
= 36753; break; // 0% [ 7% == 4, 14% == 4]
4129 case 5: spell_id
= 36751; break; // 20%
4131 case 6: spell_id
= 36754; break; // 0% [ 7% == 6, 14% == 6]
4132 case 7: spell_id
= 36755; break; // 20%
4134 case 9: spell_id
= 36761; break; // 0% [ 7% == 6]
4135 case 10: spell_id
= 36758; break; // 14%
4136 case 11: spell_id
= 36760; break; // 20%
4138 sLog
.outError("Spell::EffectEnchantItemTmp: Damage %u not handled in S'RW",damage
);
4143 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spell_id
);
4146 sLog
.outError("Spell::EffectEnchantItemTmp: unknown spell id %i", spell_id
);
4150 for(int j
= BASE_ATTACK
; j
<= OFF_ATTACK
; ++j
)
4152 if (Item
* item
= p_caster
->GetWeaponForAttack(WeaponAttackType(j
)))
4154 if (item
->IsFitToSpellRequirements(m_spellInfo
))
4156 Spell
*spell
= new Spell(m_caster
, spellInfo
, true);
4157 SpellCastTargets targets
;
4158 targets
.setItemTarget( item
);
4159 spell
->prepare(&targets
);
4169 uint32 enchant_id
= m_spellInfo
->EffectMiscValue
[i
];
4173 sLog
.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id",m_spellInfo
->Id
,i
);
4177 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
4180 sLog
.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ",m_spellInfo
->Id
,i
,enchant_id
);
4184 // select enchantment duration
4187 // rogue family enchantments exception by duration
4188 if(m_spellInfo
->Id
== 38615)
4189 duration
= 1800; // 30 mins
4190 // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints)
4191 else if(m_spellInfo
->SpellFamilyName
== SPELLFAMILY_ROGUE
)
4192 duration
= 3600; // 1 hour
4193 // shaman family enchantments
4194 else if(m_spellInfo
->SpellFamilyName
== SPELLFAMILY_SHAMAN
)
4195 duration
= 1800; // 30 mins
4196 // other cases with this SpellVisual already selected
4197 else if(m_spellInfo
->SpellVisual
[0] == 215)
4198 duration
= 1800; // 30 mins
4199 // some fishing pole bonuses
4200 else if(m_spellInfo
->SpellVisual
[0] == 563)
4201 duration
= 600; // 10 mins
4202 // shaman rockbiter enchantments
4203 else if(m_spellInfo
->SpellVisual
[0] == 0)
4204 duration
= 1800; // 30 mins
4205 else if(m_spellInfo
->Id
== 29702)
4206 duration
= 300; // 5 mins
4207 else if(m_spellInfo
->Id
== 37360)
4208 duration
= 300; // 5 mins
4211 duration
= 3600; // 1 hour
4213 // item can be in trade slot and have owner diff. from caster
4214 Player
* item_owner
= itemTarget
->GetOwner();
4218 if(item_owner
!=p_caster
&& p_caster
->GetSession()->GetSecurity() > SEC_PLAYER
&& sWorld
.getConfig(CONFIG_GM_LOG_TRADE
) )
4220 sLog
.outCommand(p_caster
->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
4221 p_caster
->GetName(), p_caster
->GetSession()->GetAccountId(),
4222 itemTarget
->GetProto()->Name1
, itemTarget
->GetEntry(),
4223 item_owner
->GetName(), item_owner
->GetSession()->GetAccountId());
4226 // remove old enchanting before applying new if equipped
4227 item_owner
->ApplyEnchantment(itemTarget
,TEMP_ENCHANTMENT_SLOT
, false);
4229 itemTarget
->SetEnchantment(TEMP_ENCHANTMENT_SLOT
, enchant_id
, duration
* 1000, 0);
4231 // add new enchanting if equipped
4232 item_owner
->ApplyEnchantment(itemTarget
, TEMP_ENCHANTMENT_SLOT
, true);
4235 void Spell::EffectTameCreature(uint32
/*i*/)
4237 // Caster must be player, checked in Spell::CheckCast
4238 // Spell can be triggered, we need to check original caster prior to caster
4239 Player
* plr
= (Player
*)(m_originalCaster
? m_originalCaster
: m_caster
);
4241 Creature
* creatureTarget
= (Creature
*)unitTarget
;
4243 // cast finish successfully
4244 //SendChannelUpdate(0);
4247 Pet
* pet
= plr
->CreateTamedPetFrom(creatureTarget
, m_spellInfo
->Id
);
4248 if(!pet
) // in versy specific state like near world end/etc.
4251 // "kill" original creature
4252 creatureTarget
->ForcedDespawn();
4254 uint32 level
= (creatureTarget
->getLevel() < (plr
->getLevel() - 5)) ? (plr
->getLevel() - 5) : creatureTarget
->getLevel();
4256 // prepare visual effect for levelup
4257 pet
->SetUInt32Value(UNIT_FIELD_LEVEL
, level
- 1);
4260 pet
->GetMap()->Add((Creature
*)pet
);
4262 // visual effect for levelup
4263 pet
->SetUInt32Value(UNIT_FIELD_LEVEL
, level
);
4265 // caster have pet now
4268 pet
->SavePetToDB(PET_SAVE_AS_CURRENT
);
4269 plr
->PetSpellInitialize();
4272 void Spell::EffectSummonPet(uint32 i
)
4274 uint32 petentry
= m_spellInfo
->EffectMiscValue
[i
];
4276 Pet
*OldSummon
= m_caster
->GetPet();
4278 // if pet requested type already exist
4281 if(petentry
== 0 || OldSummon
->GetEntry() == petentry
)
4283 // pet in corpse state can't be summoned
4284 if( OldSummon
->isDead() )
4287 OldSummon
->GetMap()->Remove((Creature
*)OldSummon
,false);
4290 m_caster
->GetClosePoint(px
, py
, pz
, OldSummon
->GetObjectSize());
4292 OldSummon
->Relocate(px
, py
, pz
, OldSummon
->GetOrientation());
4293 m_caster
->GetMap()->Add((Creature
*)OldSummon
);
4295 if(m_caster
->GetTypeId() == TYPEID_PLAYER
&& OldSummon
->isControlled() )
4297 ((Player
*)m_caster
)->PetSpellInitialize();
4302 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4303 ((Player
*)m_caster
)->RemovePet(OldSummon
,(OldSummon
->getPetType()==HUNTER_PET
? PET_SAVE_AS_DELETED
: PET_SAVE_NOT_IN_SLOT
),false);
4308 Pet
* NewSummon
= new Pet
;
4310 // petentry==0 for hunter "call pet" (current pet summoned if any)
4311 if(m_caster
->GetTypeId() == TYPEID_PLAYER
&& NewSummon
->LoadPetFromDB((Player
*)m_caster
,petentry
))
4313 if(NewSummon
->getPetType()==SUMMON_PET
)
4315 // Remove Demonic Sacrifice auras (known pet)
4316 Unit::AuraList
const& auraClassScripts
= m_caster
->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
);
4317 for(Unit::AuraList::const_iterator itr
= auraClassScripts
.begin();itr
!=auraClassScripts
.end();)
4319 if((*itr
)->GetModifier()->m_miscvalue
== 2228)
4321 m_caster
->RemoveAurasDueToSpell((*itr
)->GetId());
4322 itr
= auraClassScripts
.begin();
4332 // not error in case fail hunter call pet
4339 CreatureInfo
const* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
>(petentry
);
4343 sLog
.outError("EffectSummonPet: creature entry %u not found.",petentry
);
4348 Map
*map
= m_caster
->GetMap();
4349 uint32 pet_number
= sObjectMgr
.GeneratePetNumber();
4350 if(!NewSummon
->Create(map
->GenerateLocalLowGuid(HIGHGUID_PET
), map
, m_caster
->GetPhaseMask(),
4351 petentry
, pet_number
))
4358 m_caster
->GetClosePoint(px
, py
, pz
, NewSummon
->GetObjectSize());
4360 NewSummon
->Relocate(px
, py
, pz
, m_caster
->GetOrientation());
4362 if(!NewSummon
->IsPositionValid())
4364 sLog
.outError("Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
4365 NewSummon
->GetGUIDLow(), NewSummon
->GetEntry(), NewSummon
->GetPositionX(), NewSummon
->GetPositionY());
4370 uint32 petlevel
= m_caster
->getLevel();
4371 NewSummon
->setPetType(SUMMON_PET
);
4373 uint32 faction
= m_caster
->getFaction();
4374 if(m_caster
->GetTypeId() == TYPEID_UNIT
)
4376 if ( ((Creature
*)m_caster
)->isTotem() )
4377 NewSummon
->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE
);
4379 NewSummon
->GetCharmInfo()->SetReactState(REACT_DEFENSIVE
);
4382 NewSummon
->SetOwnerGUID(m_caster
->GetGUID());
4383 NewSummon
->SetCreatorGUID(m_caster
->GetGUID());
4384 NewSummon
->SetUInt32Value(UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_NONE
);
4385 NewSummon
->setFaction(faction
);
4386 NewSummon
->SetUInt32Value(UNIT_FIELD_BYTES_0
, 2048);
4387 NewSummon
->SetUInt32Value(UNIT_FIELD_BYTES_1
, 0);
4388 NewSummon
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, time(NULL
));
4389 NewSummon
->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE
, 0);
4390 NewSummon
->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP
, 1000);
4391 NewSummon
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
4393 NewSummon
->GetCharmInfo()->SetPetNumber(pet_number
, true);
4394 // this enables pet details window (Shift+P)
4396 // this enables popup window (pet dismiss, cancel), hunter pet additional flags set later
4397 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4398 NewSummon
->SetUInt32Value(UNIT_FIELD_FLAGS
,UNIT_FLAG_PVP_ATTACKABLE
);
4400 if(m_caster
->IsPvP())
4401 NewSummon
->SetPvP(true);
4403 NewSummon
->InitStatsForLevel(petlevel
, m_caster
);
4404 NewSummon
->InitPetCreateSpells();
4405 NewSummon
->InitLevelupSpellsForLevel();
4406 NewSummon
->InitTalentForLevel();
4408 if(NewSummon
->getPetType()==SUMMON_PET
)
4410 // Remove Demonic Sacrifice auras (new pet)
4411 Unit::AuraList
const& auraClassScripts
= m_caster
->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
);
4412 for(Unit::AuraList::const_iterator itr
= auraClassScripts
.begin();itr
!=auraClassScripts
.end();)
4414 if((*itr
)->GetModifier()->m_miscvalue
==2228)
4416 m_caster
->RemoveAurasDueToSpell((*itr
)->GetId());
4417 itr
= auraClassScripts
.begin();
4423 // generate new name for summon pet
4424 std::string new_name
=sObjectMgr
.GeneratePetName(petentry
);
4425 if(!new_name
.empty())
4426 NewSummon
->SetName(new_name
);
4428 else if(NewSummon
->getPetType()==HUNTER_PET
)
4429 NewSummon
->SetByteValue(UNIT_FIELD_BYTES_2
, 2, UNIT_RENAME_NOT_ALLOWED
);
4431 NewSummon
->AIM_Initialize();
4432 NewSummon
->SetHealth(NewSummon
->GetMaxHealth());
4433 NewSummon
->SetPower(POWER_MANA
, NewSummon
->GetMaxPower(POWER_MANA
));
4435 map
->Add((Creature
*)NewSummon
);
4437 m_caster
->SetPet(NewSummon
);
4438 sLog
.outDebug("New Pet has guid %u", NewSummon
->GetGUIDLow());
4440 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
4442 NewSummon
->SavePetToDB(PET_SAVE_AS_CURRENT
);
4443 ((Player
*)m_caster
)->PetSpellInitialize();
4447 void Spell::EffectLearnPetSpell(uint32 i
)
4449 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
4452 Player
*_player
= (Player
*)m_caster
;
4454 Pet
*pet
= _player
->GetPet();
4460 SpellEntry
const *learn_spellproto
= sSpellStore
.LookupEntry(m_spellInfo
->EffectTriggerSpell
[i
]);
4461 if(!learn_spellproto
)
4464 pet
->learnSpell(learn_spellproto
->Id
);
4466 pet
->SavePetToDB(PET_SAVE_AS_CURRENT
);
4467 _player
->PetSpellInitialize();
4470 void Spell::EffectTaunt(uint32
/*i*/)
4475 // this effect use before aura Taunt apply for prevent taunt already attacking target
4476 // for spell as marked "non effective at already attacking target"
4477 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
4479 if (unitTarget
->getVictim()==m_caster
)
4481 SendCastResult(SPELL_FAILED_DONT_REPORT
);
4486 // Also use this effect to set the taunter's threat to the taunted creature's highest value
4487 if (unitTarget
->CanHaveThreatList() && unitTarget
->getThreatManager().getCurrentVictim())
4488 unitTarget
->getThreatManager().addThreat(m_caster
,unitTarget
->getThreatManager().getCurrentVictim()->getThreat());
4491 void Spell::EffectWeaponDmg(uint32 i
)
4495 if(!unitTarget
->isAlive())
4498 // multiple weapon dmg effect workaround
4499 // execute only the last weapon damage
4500 // and handle all effects at once
4501 for (int j
= 0; j
< 3; ++j
)
4503 switch(m_spellInfo
->Effect
[j
])
4505 case SPELL_EFFECT_WEAPON_DAMAGE
:
4506 case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
:
4507 case SPELL_EFFECT_NORMALIZED_WEAPON_DMG
:
4508 case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
:
4509 if (j
< i
) // we must calculate only at last weapon effect
4515 // some spell specific modifiers
4516 bool spellBonusNeedWeaponDamagePercentMod
= false; // if set applied weapon damage percent mode to spell bonus
4518 float weaponDamagePercentMod
= 1.0f
; // applied to weapon damage and to fixed effect damage bonus
4519 float totalDamagePercentMod
= 1.0f
; // applied to final bonus+weapon damage
4520 bool normalized
= false;
4522 int32 spell_bonus
= 0; // bonus specific for spell
4523 switch(m_spellInfo
->SpellFamilyName
)
4525 case SPELLFAMILY_WARRIOR
:
4527 // Devastate bonus and sunder armor refresh
4528 if(m_spellInfo
->SpellVisual
[0] == 12295 && m_spellInfo
->SpellIconID
== 1508)
4531 // Need refresh all Sunder Armor auras from this caster
4532 Unit::AuraMap
& suAuras
= unitTarget
->GetAuras();
4533 SpellEntry
const *spellInfo
;
4534 for(Unit::AuraMap::iterator itr
= suAuras
.begin(); itr
!= suAuras
.end(); ++itr
)
4536 spellInfo
= (*itr
).second
->GetSpellProto();
4537 if( spellInfo
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&&
4538 (spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000004000)) &&
4539 (*itr
).second
->GetCasterGUID() == m_caster
->GetGUID())
4541 (*itr
).second
->RefreshAura();
4542 stack
= (*itr
).second
->GetStackAmount();
4547 spell_bonus
+= stack
* CalculateDamage(2, unitTarget
);
4548 if (!stack
|| stack
< spellInfo
->StackAmount
)
4549 // Devastate causing Sunder Armor Effect
4550 // and no need to cast over max stack amount
4551 m_caster
->CastSpell(unitTarget
, 58567, true);
4555 case SPELLFAMILY_ROGUE
:
4557 // Mutilate (for each hand)
4558 if(m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x600000000))
4562 if(unitTarget
->HasAuraState(AURA_STATE_DEADLY_POISON
))
4567 Unit::AuraMap
const& auras
= unitTarget
->GetAuras();
4568 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
4570 if(itr
->second
->GetSpellProto()->Dispel
== DISPEL_POISON
)
4579 totalDamagePercentMod
*= 1.2f
; // 120% if poisoned
4582 else if (m_caster
->GetTypeId()==TYPEID_PLAYER
&& (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0004000000000000)))
4584 Item
* weapon
= ((Player
*)m_caster
)->GetWeaponForAttack(m_attackType
,true,true);
4585 if (weapon
&& weapon
->GetProto()->SubClass
== ITEM_SUBCLASS_WEAPON_DAGGER
)
4586 totalDamagePercentMod
*= 1.5f
; // 150% to daggers
4590 case SPELLFAMILY_PALADIN
:
4592 // Seal of Command - receive benefit from Spell Damage and Healing
4593 if(m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x00000002000000))
4595 spellBonusNeedWeaponDamagePercentMod
= true;// apply weaponDamagePercentMod to spell_bonus (and then to all bonus, fixes and weapon already have applied)
4596 spell_bonus
+= int32(0.23f
*m_caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo
)));
4597 spell_bonus
+= int32(0.29f
*m_caster
->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo
), unitTarget
));
4601 case SPELLFAMILY_SHAMAN
:
4603 // Skyshatter Harness item set bonus
4605 if(m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x001000000000))
4607 Unit::AuraList
const& m_OverrideClassScript
= m_caster
->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
);
4608 for(Unit::AuraList::const_iterator citr
= m_OverrideClassScript
.begin(); citr
!= m_OverrideClassScript
.end(); ++citr
)
4610 // Stormstrike AP Buff
4611 if ( (*citr
)->GetModifier()->m_miscvalue
== 5634 )
4613 m_caster
->CastSpell(m_caster
, 38430, true, NULL
, *citr
);
4620 case SPELLFAMILY_DEATHKNIGHT
:
4622 // Blood Strike, Heart Strike, Obliterate
4623 // Blood-Caked Strike, Scourge Strike
4624 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0002000001400000) ||
4625 m_spellInfo
->SpellIconID
== 1736 || m_spellInfo
->SpellIconID
== 3143)
4628 Unit::AuraMap
const& auras
= unitTarget
->GetAuras();
4629 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
4631 if(itr
->second
->GetSpellProto()->Dispel
== DISPEL_DISEASE
&&
4632 itr
->second
->GetCasterGUID() == m_caster
->GetGUID() &&
4633 IsSpellLastAuraEffect(itr
->second
->GetSpellProto(), itr
->second
->GetEffIndex()))
4639 // Effect 1(for Blood-Caked Strike)/3(other) damage is bonus
4640 float bonus
= count
* CalculateDamage(m_spellInfo
->SpellIconID
== 1736 ? 0 : 2, unitTarget
) / 100.0f
;
4641 // Blood Strike, Blood-Caked Strike and Obliterate store bonus*2
4642 if (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0002000000400000) ||
4643 m_spellInfo
->SpellIconID
== 1736)
4646 totalDamagePercentMod
*= 1.0f
+ bonus
;
4649 // Glyph of Blood Strike
4650 if( m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000400000) &&
4651 m_caster
->HasAura(59332) &&
4652 unitTarget
->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED
))
4654 totalDamagePercentMod
*= 1.2f
; // 120% if snared
4656 // Glyph of Death Strike
4657 if( m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000000010) &&
4658 m_caster
->HasAura(59336))
4660 int32 rp
= m_caster
->GetPower(POWER_RUNIC_POWER
) / 10;
4663 totalDamagePercentMod
*= 1.0f
+ rp
/ 100.0f
;
4665 // Glyph of Plague Strike
4666 if( m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000000001) &&
4667 m_caster
->HasAura(58657) )
4669 totalDamagePercentMod
*= 1.2f
;
4675 int32 fixed_bonus
= 0;
4676 for (int j
= 0; j
< 3; ++j
)
4678 switch(m_spellInfo
->Effect
[j
])
4680 case SPELL_EFFECT_WEAPON_DAMAGE
:
4681 case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
:
4682 fixed_bonus
+= CalculateDamage(j
, unitTarget
);
4684 case SPELL_EFFECT_NORMALIZED_WEAPON_DMG
:
4685 fixed_bonus
+= CalculateDamage(j
, unitTarget
);
4688 case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
:
4689 weaponDamagePercentMod
*= float(CalculateDamage(j
, unitTarget
)) / 100.0f
;
4691 // applied only to prev.effects fixed damage
4692 fixed_bonus
= int32(fixed_bonus
*weaponDamagePercentMod
);
4695 break; // not weapon damage effect, just skip
4699 // apply weaponDamagePercentMod to spell bonus also
4700 if(spellBonusNeedWeaponDamagePercentMod
)
4701 spell_bonus
= int32(spell_bonus
*weaponDamagePercentMod
);
4703 // non-weapon damage
4704 int32 bonus
= spell_bonus
+ fixed_bonus
;
4706 // apply to non-weapon bonus weapon total pct effect, weapon total flat effect included in weapon damage
4710 switch(m_attackType
)
4713 case BASE_ATTACK
: unitMod
= UNIT_MOD_DAMAGE_MAINHAND
; break;
4714 case OFF_ATTACK
: unitMod
= UNIT_MOD_DAMAGE_OFFHAND
; break;
4715 case RANGED_ATTACK
: unitMod
= UNIT_MOD_DAMAGE_RANGED
; break;
4718 float weapon_total_pct
= m_caster
->GetModifierValue(unitMod
, TOTAL_PCT
);
4719 bonus
= int32(bonus
*weapon_total_pct
);
4722 // + weapon damage with applied weapon% dmg to base weapon damage in call
4723 bonus
+= int32(m_caster
->CalculateDamage(m_attackType
, normalized
)*weaponDamagePercentMod
);
4726 bonus
= int32(bonus
*totalDamagePercentMod
);
4728 // prevent negative damage
4729 m_damage
+= uint32(bonus
> 0 ? bonus
: 0);
4732 if (m_spellInfo
->SpellFamilyName
==SPELLFAMILY_ROGUE
&& (m_spellInfo
->SpellFamilyFlags
& UI64LIT(0x2000000)))
4734 if(m_caster
->GetTypeId()==TYPEID_PLAYER
)
4735 ((Player
*)m_caster
)->AddComboPoints(unitTarget
, 1);
4738 else if (m_spellInfo
->SpellFamilyName
==SPELLFAMILY_DRUID
&& (m_spellInfo
->SpellFamilyFlags
==UI64LIT(0x0000040000000000)))
4740 if(m_caster
->GetTypeId()==TYPEID_PLAYER
)
4741 ((Player
*)m_caster
)->AddComboPoints(unitTarget
, 1);
4743 else if(m_spellInfo
->SpellFamilyName
==SPELLFAMILY_PALADIN
)
4745 // Judgement of Blood/of the Martyr backlash damage (33%)
4746 if(m_spellInfo
->SpellFamilyFlags
& 0x0000000800000000LL
&& m_spellInfo
->SpellIconID
==153)
4748 int32 damagePoint
= m_damage
* 33 / 100;
4749 if(m_spellInfo
->Id
== 31898)
4750 m_caster
->CastCustomSpell(m_caster
, 32220, &damagePoint
, NULL
, NULL
, true);
4752 m_caster
->CastCustomSpell(m_caster
, 53725, &damagePoint
, NULL
, NULL
, true);
4757 if(m_attackType
== RANGED_ATTACK
&& m_caster
->GetTypeId() == TYPEID_PLAYER
)
4759 Item
*pItem
= ((Player
*)m_caster
)->GetWeaponForAttack(RANGED_ATTACK
, true, false);
4761 // wands don't have ammo
4762 if (!pItem
|| pItem
->GetProto()->SubClass
== ITEM_SUBCLASS_WEAPON_WAND
)
4765 if (pItem
->GetProto()->InventoryType
== INVTYPE_THROWN
)
4767 if(pItem
->GetMaxStackCount()==1)
4769 // decrease durability for non-stackable throw weapon
4770 ((Player
*)m_caster
)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_RANGED
);
4774 // decrease items amount for stackable throw weapon
4776 ((Player
*)m_caster
)->DestroyItemCount( pItem
, count
, true);
4779 else if(uint32 ammo
= ((Player
*)m_caster
)->GetUInt32Value(PLAYER_AMMO_ID
))
4780 ((Player
*)m_caster
)->DestroyItemCount(ammo
, 1, true);
4784 void Spell::EffectThreat(uint32
/*i*/)
4786 if(!unitTarget
|| !unitTarget
->isAlive() || !m_caster
->isAlive())
4789 if(!unitTarget
->CanHaveThreatList())
4792 unitTarget
->AddThreat(m_caster
, float(damage
), false, GetSpellSchoolMask(m_spellInfo
), m_spellInfo
);
4795 void Spell::EffectHealMaxHealth(uint32
/*i*/)
4799 if(!unitTarget
->isAlive())
4802 uint32 heal
= m_caster
->GetMaxHealth();
4807 void Spell::EffectInterruptCast(uint32
/*i*/)
4811 if(!unitTarget
->isAlive())
4814 // TODO: not all spells that used this effect apply cooldown at school spells
4815 // also exist case: apply cooldown to interrupted cast only and to all spells
4816 for (uint32 i
= CURRENT_FIRST_NON_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; ++i
)
4818 if (Spell
* spell
= unitTarget
->GetCurrentSpell(CurrentSpellTypes(i
)))
4820 SpellEntry
const* curSpellInfo
= spell
->m_spellInfo
;
4821 // check if we can interrupt spell
4822 if ((curSpellInfo
->InterruptFlags
& SPELL_INTERRUPT_FLAG_INTERRUPT
) && curSpellInfo
->PreventionType
== SPELL_PREVENTION_TYPE_SILENCE
)
4824 unitTarget
->ProhibitSpellScholl(GetSpellSchoolMask(curSpellInfo
), GetSpellDuration(m_spellInfo
));
4825 unitTarget
->InterruptSpell(CurrentSpellTypes(i
),false);
4831 void Spell::EffectSummonObjectWild(uint32 i
)
4833 uint32 gameobject_id
= m_spellInfo
->EffectMiscValue
[i
];
4835 GameObject
* pGameObj
= new GameObject
;
4837 WorldObject
* target
= focusObject
;
4842 if(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
4844 x
= m_targets
.m_destX
;
4845 y
= m_targets
.m_destY
;
4846 z
= m_targets
.m_destZ
;
4849 m_caster
->GetClosePoint(x
, y
, z
, DEFAULT_WORLD_OBJECT_SIZE
);
4851 Map
*map
= target
->GetMap();
4853 if(!pGameObj
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), gameobject_id
, map
,
4854 m_caster
->GetPhaseMask(), x
, y
, z
, target
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
4860 int32 duration
= GetSpellDuration(m_spellInfo
);
4862 pGameObj
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
4863 pGameObj
->SetSpellId(m_spellInfo
->Id
);
4865 // Wild object not have owner and check clickable by players
4868 if(pGameObj
->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP
&& m_caster
->GetTypeId() == TYPEID_PLAYER
)
4870 Player
*pl
= (Player
*)m_caster
;
4871 BattleGround
* bg
= ((Player
*)m_caster
)->GetBattleGround();
4873 switch(pGameObj
->GetMapId())
4877 if(bg
&& bg
->GetTypeID()==BATTLEGROUND_WS
&& bg
->GetStatus() == STATUS_IN_PROGRESS
)
4879 uint32 team
= ALLIANCE
;
4881 if(pl
->GetTeam() == team
)
4884 ((BattleGroundWS
*)bg
)->SetDroppedFlagGUID(pGameObj
->GetGUID(),team
);
4890 if(bg
&& bg
->GetTypeID()==BATTLEGROUND_EY
&& bg
->GetStatus() == STATUS_IN_PROGRESS
)
4892 ((BattleGroundEY
*)bg
)->SetDroppedFlagGUID(pGameObj
->GetGUID());
4899 if(uint32 linkedEntry
= pGameObj
->GetGOInfo()->GetLinkedGameObjectEntry())
4901 GameObject
* linkedGO
= new GameObject
;
4902 if(linkedGO
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), linkedEntry
, map
,
4903 m_caster
->GetPhaseMask(), x
, y
, z
, target
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
4905 linkedGO
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
4906 linkedGO
->SetSpellId(m_spellInfo
->Id
);
4908 // Wild object not have owner and check clickable by players
4920 void Spell::EffectScriptEffect(uint32 effIndex
)
4922 // TODO: we must implement hunter pet summon at login there (spell 6962)
4924 switch(m_spellInfo
->SpellFamilyName
)
4926 case SPELLFAMILY_GENERIC
:
4928 switch(m_spellInfo
->Id
)
4930 // PX-238 Winter Wondervolt TRAP
4933 uint32 spells
[4] = { 26272, 26157, 26273, 26274 };
4936 for(int j
= 0; j
< 4; ++j
)
4937 if(unitTarget
->HasAura(spells
[j
],0))
4941 uint32 iTmpSpellId
= spells
[urand(0,3)];
4944 unitTarget
->CastSpell(unitTarget
, iTmpSpellId
, true);
4950 if(!itemTarget
&& m_caster
->GetTypeId()!=TYPEID_PLAYER
)
4953 uint32 spell_id
= 0;
4956 case 1: spell_id
= 8854; break;
4957 default: spell_id
= 8855; break;
4960 m_caster
->CastSpell(m_caster
,spell_id
,true,NULL
);
4963 // Brittle Armor - need remove one 24575 Brittle Armor aura
4965 unitTarget
->RemoveSingleSpellAurasFromStack(24575);
4967 // Mercurial Shield - need remove one 26464 Mercurial Shield aura
4969 unitTarget
->RemoveSingleSpellAurasFromStack(26464);
4971 // Orb teleport spells
4985 switch(m_spellInfo
->Id
)
4987 case 25140: spellid
= 32571; break;
4988 case 25143: spellid
= 32572; break;
4989 case 25650: spellid
= 30140; break;
4990 case 25652: spellid
= 30141; break;
4991 case 29128: spellid
= 32568; break;
4992 case 29129: spellid
= 32569; break;
4993 case 35376: spellid
= 25649; break;
4994 case 35727: spellid
= 35730; break;
4999 unitTarget
->CastSpell(unitTarget
,spellid
,false);
5002 // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell)
5017 if(!unitTarget
|| !unitTarget
->isAlive())
5020 // Onyxia Scale Cloak
5021 if(unitTarget
->GetDummyAura(22683))
5025 m_caster
->CastSpell(unitTarget
, 22682, true);
5028 // Summon Black Qiraji Battle Tank
5034 // Prevent stacking of mounts
5035 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
5037 // Two separate mounts depending on area id (allows use both in and out of specific instance)
5038 if (unitTarget
->GetAreaId() == 3428)
5039 unitTarget
->CastSpell(unitTarget
, 25863, false);
5041 unitTarget
->CastSpell(unitTarget
, 26655, false);
5044 // Piccolo of the Flaming Fire
5047 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5049 unitTarget
->HandleEmoteCommand(EMOTE_STATE_DANCE
);
5052 // Demonic Empowerment (succubus Vanish effect)
5058 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
5059 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
5060 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED
);
5061 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_STUN
);
5070 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
5071 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
5074 // Mirren's Drinking Hat
5078 switch ( urand(1, 6) )
5083 item
= 23584; break; // Loch Modan Lager
5086 item
= 23585; break; // Stouthammer Lite
5088 item
= 23586; break; // Aerie Peak Pale Ale
5091 DoCreateItem(effIndex
,item
);
5099 // Removes snares and roots.
5100 unitTarget
->RemoveAurasAtMechanicImmunity(IMMUNE_TO_ROOT_AND_SNARE_MASK
,30918,true);
5109 unitTarget
->CastSpell(unitTarget
, 41131, true);
5112 // Force Cast - Portal Effect: Sunwell Isle
5118 unitTarget
->CastSpell(unitTarget
, 44870, true);
5121 // Goblin Weather Machine
5130 case 0: spellId
= 46740; break;
5131 case 1: spellId
= 46739; break;
5132 case 2: spellId
= 46738; break;
5133 case 3: spellId
= 46736; break;
5135 unitTarget
->CastSpell(unitTarget
, spellId
, true);
5141 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5144 ((Player
*)unitTarget
)->ModifyMoney(50000000);
5148 // Emblazon Runeblade
5151 if(!m_originalCaster
)
5154 m_originalCaster
->CastSpell(m_originalCaster
, damage
, false);
5160 if(!unitTarget
|| unitTarget
->getClass() != CLASS_DEATH_KNIGHT
)
5162 // triggered spell is stored in m_spellInfo->EffectBasePoints[0]
5163 unitTarget
->CastSpell(unitTarget
, damage
, false);
5166 // Winged Steed of the Ebon Blade
5169 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5172 // Prevent stacking of mounts
5173 unitTarget
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
5175 // Triggered spell id dependent of riding skill
5176 if(uint16 skillval
= ((Player
*)unitTarget
)->GetSkillValue(SKILL_RIDING
))
5178 if (skillval
>= 300)
5179 unitTarget
->CastSpell(unitTarget
, 54727, true);
5181 unitTarget
->CastSpell(unitTarget
, 54726, true);
5185 case 55693: // Remove Collapsing Cave Aura
5188 unitTarget
->RemoveAurasDueToSpell(m_spellInfo
->CalculateSimpleValue(effIndex
));
5190 case 58418: // Portal to Orgrimmar
5191 case 58420: // Portal to Stormwind
5193 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
|| effIndex
!=0)
5196 uint32 spellID
= m_spellInfo
->CalculateSimpleValue(0);
5197 uint32 questID
= m_spellInfo
->CalculateSimpleValue(1);
5199 if (((Player
*)unitTarget
)->GetQuestStatus(questID
) == QUEST_STATUS_COMPLETE
&& !((Player
*)unitTarget
)->GetQuestRewardStatus (questID
))
5200 unitTarget
->CastSpell(unitTarget
, spellID
, true);
5204 case 59317: // Teleporting
5205 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5209 if (((Player
*)unitTarget
)->GetAreaId() == 4637)
5210 unitTarget
->CastSpell(unitTarget
, 59316, true);
5213 unitTarget
->CastSpell(unitTarget
, 59314, true);
5216 // random spell learn instead placeholder
5217 case 60893: // Northrend Alchemy Research
5218 case 61177: // Northrend Inscription Research
5219 case 61288: // Minor Inscription Research
5220 case 61756: // Northrend Inscription Research (FAST QA VERSION)
5221 case 64323: // Book of Glyph Mastery
5223 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5226 // learn random explicit discovery recipe (if any)
5227 if(uint32 discoveredSpell
= GetExplicitDiscoverySpell(m_spellInfo
->Id
, (Player
*)m_caster
))
5228 ((Player
*)m_caster
)->learnSpell(discoveredSpell
, false);
5234 case SPELLFAMILY_WARLOCK
:
5236 switch(m_spellInfo
->Id
)
5238 // Healthstone creating spells
5252 Unit::AuraList
const& mDummyAuras
= unitTarget
->GetAurasByType(SPELL_AURA_DUMMY
);
5253 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
5255 if((*i
)->GetId() == 18692)
5260 else if((*i
)->GetId() == 18693)
5267 static uint32
const itypes
[8][3] = {
5268 { 5512, 19004, 19005}, // Minor Healthstone
5269 { 5511, 19006, 19007}, // Lesser Healthstone
5270 { 5509, 19008, 19009}, // Healthstone
5271 { 5510, 19010, 19011}, // Greater Healthstone
5272 { 9421, 19012, 19013}, // Major Healthstone
5273 {22103, 22104, 22105}, // Master Healthstone
5274 {36889, 36890, 36891}, // Demonic Healthstone
5275 {36892, 36893, 36894} // Fel Healthstone
5278 switch(m_spellInfo
->Id
)
5281 itemtype
=itypes
[0][rank
];break; // Minor Healthstone
5283 itemtype
=itypes
[1][rank
];break; // Lesser Healthstone
5285 itemtype
=itypes
[2][rank
];break; // Healthstone
5287 itemtype
=itypes
[3][rank
];break; // Greater Healthstone
5289 itemtype
=itypes
[4][rank
];break; // Major Healthstone
5291 itemtype
=itypes
[5][rank
];break; // Master Healthstone
5293 itemtype
=itypes
[6][rank
];break; // Demonic Healthstone
5295 itemtype
=itypes
[7][rank
];break; // Fel Healthstone
5299 DoCreateItem( effIndex
, itemtype
);
5302 // Demonic Empowerment
5307 uint32 entry
= unitTarget
->GetEntry();
5311 case 416: spellID
= 54444; break; //imp
5312 case 417: spellID
= 54509; break; //fellhunter
5313 case 1860: spellID
= 54443; break; //void
5314 case 1863: spellID
= 54435; break; //succubus
5315 case 17252: spellID
= 54508; break; //fellguard
5319 unitTarget
->CastSpell(unitTarget
,spellID
,true);
5322 // Everlasting Affliction
5325 // Need refresh caster corruption auras on target
5326 Unit::AuraMap
& suAuras
= unitTarget
->GetAuras();
5327 for(Unit::AuraMap::iterator itr
= suAuras
.begin(); itr
!= suAuras
.end(); ++itr
)
5329 SpellEntry
const *spellInfo
= (*itr
).second
->GetSpellProto();
5330 if(spellInfo
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&&
5331 (spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000000002)) &&
5332 (*itr
).second
->GetCasterGUID()==m_caster
->GetGUID())
5333 (*itr
).second
->RefreshAura();
5337 // Guarded by The Light (Paladin spell with SPELLFAMILY_WARLOCK)
5340 // Divine Plea, refresh on target (3 aura slots)
5341 if (Aura
* aura
= unitTarget
->GetAura(54428,0))
5342 aura
->RefreshAura();
5348 case SPELLFAMILY_PRIEST
:
5350 switch(m_spellInfo
->Id
)
5352 // Pain and Suffering
5357 // Refresh Shadow Word: Pain on target
5358 Unit::AuraMap
& auras
= unitTarget
->GetAuras();
5359 for(Unit::AuraMap::iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
5361 SpellEntry
const *spellInfo
= (*itr
).second
->GetSpellProto();
5362 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_PRIEST
&&
5363 (spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000008000)) &&
5364 (*itr
).second
->GetCasterGUID() == m_caster
->GetGUID())
5366 (*itr
).second
->RefreshAura();
5377 case SPELLFAMILY_HUNTER
:
5379 switch(m_spellInfo
->Id
)
5387 int32 basePoint
= 0;
5388 Unit
* target
= unitTarget
;
5389 Unit::AuraMap
& Auras
= unitTarget
->GetAuras();
5390 for(Unit::AuraMap::iterator i
= Auras
.begin(); i
!= Auras
.end(); ++i
)
5392 Aura
*aura
= (*i
).second
;
5393 if (aura
->GetCasterGUID() != m_caster
->GetGUID())
5395 // Search only Serpent Sting, Viper Sting, Scorpid Sting auras
5396 uint64 familyFlag
= aura
->GetSpellProto()->SpellFamilyFlags
;
5397 if (!(familyFlag
& UI64LIT(0x000000800000C000)))
5399 // Refresh aura duration
5400 aura
->RefreshAura();
5402 // Serpent Sting - Instantly deals 40% of the damage done by your Serpent Sting.
5403 if ((familyFlag
& UI64LIT(0x0000000000004000)) && aura
->GetEffIndex() == 0)
5405 // m_amount already include RAP bonus
5406 basePoint
= aura
->GetModifier()->m_amount
* 5 * 40 / 100;
5407 spellId
= 53353; // Chimera Shot - Serpent
5409 // Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting.
5410 if ((familyFlag
& UI64LIT(0x0000008000000000)) && aura
->GetEffIndex() == 0)
5412 uint32 target_max_mana
= unitTarget
->GetMaxPower(POWER_MANA
);
5413 if (!target_max_mana
)
5416 // ignore non positive values (can be result apply spellmods to aura damage
5417 uint32 pdamage
= aura
->GetModifier()->m_amount
> 0 ? aura
->GetModifier()->m_amount
: 0;
5419 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
5420 uint32 maxmana
= m_caster
->GetMaxPower(POWER_MANA
) * pdamage
* 2 / 100;
5422 pdamage
= target_max_mana
* pdamage
/ 100;
5423 if (pdamage
> maxmana
)
5426 pdamage
*= 4; // total aura damage
5427 basePoint
= pdamage
* 60 / 100;
5428 spellId
= 53358; // Chimera Shot - Viper
5431 // Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute.
5432 if (familyFlag
& UI64LIT(0x0000000000008000))
5433 spellId
= 53359; // Chimera Shot - Scorpid
5434 // ?? nothing say in spell desc (possibly need addition check)
5435 //if ((familyFlag & UI64LIT(0x0000010000000000)) || // dot
5436 // (familyFlag & UI64LIT(0x0000100000000000))) // stun
5438 // spellId = 53366; // 53366 Chimera Shot - Wyvern
5442 m_caster
->CastCustomSpell(target
, spellId
, &basePoint
, 0, 0, false);
5445 case 53412: // Invigoration (pet triggered script, master targeted)
5450 Unit::AuraList
const& auras
= unitTarget
->GetAurasByType(SPELL_AURA_DUMMY
);
5451 for(Unit::AuraList::const_iterator i
= auras
.begin();i
!= auras
.end(); ++i
)
5453 // Invigoration (master talent)
5454 if ((*i
)->GetModifier()->m_miscvalue
== 8 && (*i
)->GetSpellProto()->SpellIconID
== 3487)
5456 if (roll_chance_i((*i
)->GetModifier()->m_amount
))
5458 unitTarget
->CastSpell(unitTarget
, 53398, true, NULL
, (*i
), m_caster
->GetGUID());
5471 // script effect have in value, but this outdated removed part
5472 unitTarget
->CastSpell(unitTarget
, 62305, true);
5480 case SPELLFAMILY_PALADIN
:
5482 // Judgement (seal trigger)
5483 if (m_spellInfo
->Category
== SPELLCATEGORY_JUDGEMENT
)
5485 if(!unitTarget
|| !unitTarget
->isAlive())
5487 uint32 spellId1
= 0;
5488 uint32 spellId2
= 0;
5490 // Judgement self add switch
5491 switch (m_spellInfo
->Id
)
5493 case 53407: spellId1
= 20184; break; // Judgement of Justice
5494 case 20271: // Judgement of Light
5495 case 57774: spellId1
= 20185; break; // Judgement of Light
5496 case 53408: spellId1
= 20186; break; // Judgement of Wisdom
5498 sLog
.outError("Unsupported Judgement (seal trigger) spell (Id: %u) in Spell::EffectScriptEffect",m_spellInfo
->Id
);
5501 // offensive seals have aura dummy in 2 effect
5502 Unit::AuraList
const& m_dummyAuras
= m_caster
->GetAurasByType(SPELL_AURA_DUMMY
);
5503 for(Unit::AuraList::const_iterator itr
= m_dummyAuras
.begin(); itr
!= m_dummyAuras
.end(); ++itr
)
5505 // search seal (offensive seals have judgement's aura dummy spell id in 2 effect
5506 if ((*itr
)->GetEffIndex() != 2 || !IsSealSpell((*itr
)->GetSpellProto()))
5508 spellId2
= (*itr
)->GetModifier()->m_amount
;
5509 SpellEntry
const *judge
= sSpellStore
.LookupEntry(spellId2
);
5514 // if there were no offensive seals than there is seal with proc trigger aura
5517 Unit::AuraList
const& procTriggerAuras
= m_caster
->GetAurasByType(SPELL_AURA_PROC_TRIGGER_SPELL
);
5518 for(Unit::AuraList::const_iterator itr
= procTriggerAuras
.begin(); itr
!= procTriggerAuras
.end(); ++itr
)
5520 if ((*itr
)->GetEffIndex() != 0 || !IsSealSpell((*itr
)->GetSpellProto()))
5527 m_caster
->CastSpell(unitTarget
, spellId1
, true);
5529 m_caster
->CastSpell(unitTarget
, spellId2
, true);
5533 case SPELLFAMILY_POTION
:
5535 switch(m_spellInfo
->Id
)
5542 unitTarget
->CastSpell(unitTarget
, 28694, true);
5550 // 25% chance of casting a random buff
5551 if(roll_chance_i(75))
5554 // triggered spells are 28703 to 28707
5555 // Note: some sources say, that there was the possibility of
5556 // receiving a debuff. However, this seems to be removed by a patch.
5557 const uint32 spellid
= 28703;
5559 // don't overwrite an existing aura
5560 for(uint8 i
= 0; i
< 5; ++i
)
5561 if(unitTarget
->HasAura(spellid
+ i
, 0))
5563 unitTarget
->CastSpell(unitTarget
, spellid
+urand(0, 4), true);
5572 // 25% chance of casting Nightmare Pollen
5573 if(roll_chance_i(75))
5575 unitTarget
->CastSpell(unitTarget
, 28721, true);
5581 case SPELLFAMILY_DEATHKNIGHT
:
5583 switch(m_spellInfo
->Id
)
5591 Unit
* mainTarget
= m_targets
.getUnitTarget();
5595 // do only refresh diseases on main target if caster has Glyph of Disease
5596 if(mainTarget
== unitTarget
&& !m_caster
->HasAura(63334))
5600 if(mainTarget
->HasAura(55078))
5601 m_caster
->CastSpell(unitTarget
, 55078, true);
5604 if(mainTarget
->HasAura(55095))
5605 m_caster
->CastSpell(unitTarget
, 55095, true);
5614 // normal DB scripted effect
5618 sLog
.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect ", m_spellInfo
->Id
);
5619 m_caster
->GetMap()->ScriptsStart(sSpellScripts
, m_spellInfo
->Id
, m_caster
, unitTarget
);
5622 void Spell::EffectSanctuary(uint32
/*i*/)
5626 //unitTarget->CombatStop();
5628 unitTarget
->CombatStop();
5629 unitTarget
->getHostileRefManager().deleteReferences(); // stop all fighting
5630 // Vanish allows to remove all threat and cast regular stealth so other spells can be used
5631 if(m_spellInfo
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& (m_spellInfo
->SpellFamilyFlags
& SPELLFAMILYFLAG_ROGUE_VANISH
))
5633 ((Player
*)m_caster
)->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
5637 void Spell::EffectAddComboPoints(uint32
/*i*/)
5642 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5648 ((Player
*)m_caster
)->AddComboPoints(unitTarget
, damage
);
5651 void Spell::EffectDuel(uint32 i
)
5653 if(!m_caster
|| !unitTarget
|| m_caster
->GetTypeId() != TYPEID_PLAYER
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5656 Player
*caster
= (Player
*)m_caster
;
5657 Player
*target
= (Player
*)unitTarget
;
5659 // caster or target already have requested duel
5660 if( caster
->duel
|| target
->duel
|| !target
->GetSocial() || target
->GetSocial()->HasIgnore(caster
->GetGUIDLow()) )
5663 // Players can only fight a duel with each other outside (=not inside dungeons and not in capital cities)
5664 // Don't have to check the target's map since you cannot challenge someone across maps
5665 uint32 mapid
= caster
->GetMapId();
5666 if( mapid
!= 0 && mapid
!= 1 && mapid
!= 530 && mapid
!= 571 && mapid
!= 609)
5668 SendCastResult(SPELL_FAILED_NO_DUELING
); // Dueling isn't allowed here
5672 AreaTableEntry
const* casterAreaEntry
= GetAreaEntryByAreaID(caster
->GetZoneId());
5673 if(casterAreaEntry
&& (casterAreaEntry
->flags
& AREA_FLAG_CAPITAL
) )
5675 SendCastResult(SPELL_FAILED_NO_DUELING
); // Dueling isn't allowed here
5679 AreaTableEntry
const* targetAreaEntry
= GetAreaEntryByAreaID(target
->GetZoneId());
5680 if(targetAreaEntry
&& (targetAreaEntry
->flags
& AREA_FLAG_CAPITAL
) )
5682 SendCastResult(SPELL_FAILED_NO_DUELING
); // Dueling isn't allowed here
5686 //CREATE DUEL FLAG OBJECT
5687 GameObject
* pGameObj
= new GameObject
;
5689 uint32 gameobject_id
= m_spellInfo
->EffectMiscValue
[i
];
5691 Map
*map
= m_caster
->GetMap();
5692 if(!pGameObj
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), gameobject_id
,
5693 map
, m_caster
->GetPhaseMask(),
5694 m_caster
->GetPositionX()+(unitTarget
->GetPositionX()-m_caster
->GetPositionX())/2 ,
5695 m_caster
->GetPositionY()+(unitTarget
->GetPositionY()-m_caster
->GetPositionY())/2 ,
5696 m_caster
->GetPositionZ(),
5697 m_caster
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0, GO_STATE_READY
))
5703 pGameObj
->SetUInt32Value(GAMEOBJECT_FACTION
, m_caster
->getFaction() );
5704 pGameObj
->SetUInt32Value(GAMEOBJECT_LEVEL
, m_caster
->getLevel()+1 );
5705 int32 duration
= GetSpellDuration(m_spellInfo
);
5706 pGameObj
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
5707 pGameObj
->SetSpellId(m_spellInfo
->Id
);
5709 m_caster
->AddGameObject(pGameObj
);
5714 WorldPacket
data(SMSG_DUEL_REQUESTED
, 8 + 8);
5715 data
<< uint64(pGameObj
->GetGUID());
5716 data
<< uint64(caster
->GetGUID());
5717 caster
->GetSession()->SendPacket(&data
);
5718 target
->GetSession()->SendPacket(&data
);
5721 DuelInfo
*duel
= new DuelInfo
;
5722 duel
->initiator
= caster
;
5723 duel
->opponent
= target
;
5724 duel
->startTime
= 0;
5725 duel
->startTimer
= 0;
5726 caster
->duel
= duel
;
5728 DuelInfo
*duel2
= new DuelInfo
;
5729 duel2
->initiator
= caster
;
5730 duel2
->opponent
= caster
;
5731 duel2
->startTime
= 0;
5732 duel2
->startTimer
= 0;
5733 target
->duel
= duel2
;
5735 caster
->SetUInt64Value(PLAYER_DUEL_ARBITER
, pGameObj
->GetGUID());
5736 target
->SetUInt64Value(PLAYER_DUEL_ARBITER
, pGameObj
->GetGUID());
5739 void Spell::EffectStuck(uint32
/*i*/)
5741 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5744 if(!sWorld
.getConfig(CONFIG_CAST_UNSTUCK
))
5747 Player
* pTarget
= (Player
*)unitTarget
;
5749 sLog
.outDebug("Spell Effect: Stuck");
5750 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());
5752 if(pTarget
->isInFlight())
5755 // homebind location is loaded always
5756 pTarget
->TeleportToHomebind(unitTarget
==m_caster
? TELE_TO_SPELL
: 0);
5758 // Stuck spell trigger Hearthstone cooldown
5759 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(8690);
5762 Spell
spell(pTarget
, spellInfo
, true, 0);
5763 spell
.SendSpellCooldown();
5766 void Spell::EffectSummonPlayer(uint32
/*i*/)
5768 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5771 // Evil Twin (ignore player summon, but hide this for summoner)
5772 if(unitTarget
->GetDummyAura(23445))
5776 m_caster
->GetClosePoint(x
, y
, z
, unitTarget
->GetObjectSize());
5778 ((Player
*)unitTarget
)->SetSummonPoint(m_caster
->GetMapId(),x
,y
,z
);
5780 WorldPacket
data(SMSG_SUMMON_REQUEST
, 8+4+4);
5781 data
<< uint64(m_caster
->GetGUID()); // summoner guid
5782 data
<< uint32(m_caster
->GetZoneId()); // summoner zone
5783 data
<< uint32(MAX_PLAYER_SUMMON_DELAY
*IN_MILISECONDS
); // auto decline after msecs
5784 ((Player
*)unitTarget
)->GetSession()->SendPacket(&data
);
5787 static ScriptInfo
generateActivateCommand()
5790 si
.command
= SCRIPT_COMMAND_ACTIVATE_OBJECT
;
5794 void Spell::EffectActivateObject(uint32 effect_idx
)
5799 static ScriptInfo activateCommand
= generateActivateCommand();
5801 int32 delay_secs
= m_spellInfo
->EffectMiscValue
[effect_idx
];
5803 gameObjTarget
->GetMap()->ScriptCommandStart(activateCommand
, delay_secs
, m_caster
, gameObjTarget
);
5806 void Spell::EffectApplyGlyph(uint32 i
)
5808 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5811 Player
*player
= (Player
*)m_caster
;
5814 if(uint32 glyph
= m_spellInfo
->EffectMiscValue
[i
])
5816 if(GlyphPropertiesEntry
const *gp
= sGlyphPropertiesStore
.LookupEntry(glyph
))
5818 if(GlyphSlotEntry
const *gs
= sGlyphSlotStore
.LookupEntry(player
->GetGlyphSlot(m_glyphIndex
)))
5820 if(gp
->TypeFlags
!= gs
->TypeFlags
)
5822 SendCastResult(SPELL_FAILED_INVALID_GLYPH
);
5823 return; // glyph slot mismatch
5828 if(uint32 oldglyph
= player
->GetGlyph(m_glyphIndex
))
5830 if(GlyphPropertiesEntry
const *old_gp
= sGlyphPropertiesStore
.LookupEntry(oldglyph
))
5832 player
->RemoveAurasDueToSpell(old_gp
->SpellId
);
5833 player
->SetGlyph(m_glyphIndex
, 0);
5837 player
->CastSpell(m_caster
, gp
->SpellId
, true);
5838 player
->SetGlyph(m_glyphIndex
, glyph
);
5839 player
->SendTalentsInfoData(false);
5844 void Spell::EffectSummonTotem(uint32 i
, uint8 slot
)
5846 slot
= slot
? (slot
- 1): 255;
5848 if(slot
< MAX_TOTEM
)
5850 uint64 guid
= m_caster
->m_TotemSlot
[slot
];
5853 Creature
*OldTotem
= m_caster
->GetMap()->GetCreature(guid
);
5854 if(OldTotem
&& OldTotem
->isTotem())
5855 ((Totem
*)OldTotem
)->UnSummon();
5860 if (m_caster
->GetTypeId()==TYPEID_PLAYER
)
5861 team
= ((Player
*)m_caster
)->GetTeam();
5863 Totem
* pTotem
= new Totem
;
5865 if(!pTotem
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_UNIT
), m_caster
->GetMap(), m_caster
->GetPhaseMask(),
5866 m_spellInfo
->EffectMiscValue
[i
], team
))
5872 float angle
= slot
< MAX_TOTEM
? M_PI
/MAX_TOTEM
- (slot
*2*M_PI
/MAX_TOTEM
) : 0;
5875 m_caster
->GetClosePoint(x
, y
, z
, pTotem
->GetObjectSize(), 2.0f
, angle
);
5877 // totem must be at same Z in case swimming caster and etc.
5878 if( fabs( z
- m_caster
->GetPositionZ() ) > 5 )
5879 z
= m_caster
->GetPositionZ();
5881 pTotem
->Relocate(x
, y
, z
, m_caster
->GetOrientation());
5883 if(slot
< MAX_TOTEM
)
5884 m_caster
->m_TotemSlot
[slot
] = pTotem
->GetGUID();
5886 pTotem
->SetOwner(m_caster
->GetGUID());
5887 pTotem
->SetTypeBySummonSpell(m_spellInfo
); // must be after Create call where m_spells initilized
5889 int32 duration
=GetSpellDuration(m_spellInfo
);
5890 if(Player
* modOwner
= m_caster
->GetSpellModOwner())
5891 modOwner
->ApplySpellMod(m_spellInfo
->Id
, SPELLMOD_DURATION
, duration
);
5892 pTotem
->SetDuration(duration
);
5894 if (damage
) // if not spell info, DB values used
5896 pTotem
->SetMaxHealth(damage
);
5897 pTotem
->SetHealth(damage
);
5900 pTotem
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
5902 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
5903 pTotem
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PVP_ATTACKABLE
);
5905 if(m_caster
->IsPvP())
5906 pTotem
->SetPvP(true);
5908 pTotem
->Summon(m_caster
);
5910 if(slot
< MAX_TOTEM
&& m_caster
->GetTypeId() == TYPEID_PLAYER
)
5912 WorldPacket
data(SMSG_TOTEM_CREATED
, 1 + 8 + 4 + 4);
5913 data
<< uint8(slot
);
5914 data
<< uint64(pTotem
->GetGUID());
5915 data
<< uint32(duration
);
5916 data
<< uint32(m_spellInfo
->Id
);
5917 ((Player
*)m_caster
)->SendDirectMessage(&data
);
5921 void Spell::EffectEnchantHeldItem(uint32 i
)
5923 // this is only item spell effect applied to main-hand weapon of target player (players in area)
5924 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5927 Player
* item_owner
= (Player
*)unitTarget
;
5928 Item
* item
= item_owner
->GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_MAINHAND
);
5934 if(!item
->IsEquipped())
5937 if (m_spellInfo
->EffectMiscValue
[i
])
5939 uint32 enchant_id
= m_spellInfo
->EffectMiscValue
[i
];
5940 int32 duration
= GetSpellDuration(m_spellInfo
); //Try duration index first ..
5942 duration
= m_currentBasePoints
[i
]+1; //Base points after ..
5944 duration
= 10; //10 seconds for enchants which don't have listed duration
5946 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(enchant_id
);
5950 // Always go to temp enchantment slot
5951 EnchantmentSlot slot
= TEMP_ENCHANTMENT_SLOT
;
5953 // Enchantment will not be applied if a different one already exists
5954 if(item
->GetEnchantmentId(slot
) && item
->GetEnchantmentId(slot
) != enchant_id
)
5957 // Apply the temporary enchantment
5958 item
->SetEnchantment(slot
, enchant_id
, duration
*IN_MILISECONDS
, 0);
5959 item_owner
->ApplyEnchantment(item
, slot
, true);
5963 void Spell::EffectDisEnchant(uint32
/*i*/)
5965 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5968 Player
* p_caster
= (Player
*)m_caster
;
5969 if(!itemTarget
|| !itemTarget
->GetProto()->DisenchantID
)
5972 p_caster
->UpdateCraftSkill(m_spellInfo
->Id
);
5974 ((Player
*)m_caster
)->SendLoot(itemTarget
->GetGUID(),LOOT_DISENCHANTING
);
5976 // item will be removed at disenchanting end
5979 void Spell::EffectInebriate(uint32
/*i*/)
5981 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
5984 Player
*player
= (Player
*)unitTarget
;
5985 uint16 currentDrunk
= player
->GetDrunkValue();
5986 uint16 drunkMod
= damage
* 256;
5987 if (currentDrunk
+ drunkMod
> 0xFFFF)
5988 currentDrunk
= 0xFFFF;
5990 currentDrunk
+= drunkMod
;
5991 player
->SetDrunkValue(currentDrunk
, m_CastItem
? m_CastItem
->GetEntry() : 0);
5994 void Spell::EffectFeedPet(uint32 i
)
5996 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
5999 Player
*_player
= (Player
*)m_caster
;
6001 Item
* foodItem
= m_targets
.getItemTarget();
6005 Pet
*pet
= _player
->GetPet();
6012 int32 benefit
= pet
->GetCurrentFoodBenefitLevel(foodItem
->GetProto()->ItemLevel
);
6017 _player
->DestroyItemCount(foodItem
,count
,true);
6018 // TODO: fix crash when a spell has two effects, both pointed at the same item target
6020 m_caster
->CastCustomSpell(pet
, m_spellInfo
->EffectTriggerSpell
[i
], &benefit
, NULL
, NULL
, true);
6023 void Spell::EffectDismissPet(uint32
/*i*/)
6025 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6028 Pet
* pet
= m_caster
->GetPet();
6030 // not let dismiss dead pet
6031 if(!pet
||!pet
->isAlive())
6034 ((Player
*)m_caster
)->RemovePet(pet
, PET_SAVE_NOT_IN_SLOT
);
6037 void Spell::EffectSummonObject(uint32 i
)
6039 uint32 go_id
= m_spellInfo
->EffectMiscValue
[i
];
6042 switch(m_spellInfo
->Effect
[i
])
6044 case SPELL_EFFECT_SUMMON_OBJECT_SLOT1
: slot
= 0; break;
6045 case SPELL_EFFECT_SUMMON_OBJECT_SLOT2
: slot
= 1; break;
6046 case SPELL_EFFECT_SUMMON_OBJECT_SLOT3
: slot
= 2; break;
6047 case SPELL_EFFECT_SUMMON_OBJECT_SLOT4
: slot
= 3; break;
6051 if(uint64 guid
= m_caster
->m_ObjectSlot
[slot
])
6053 if(GameObject
* obj
= m_caster
? m_caster
->GetMap()->GetGameObject(guid
) : NULL
)
6054 obj
->SetLootState(GO_JUST_DEACTIVATED
);
6055 m_caster
->m_ObjectSlot
[slot
] = 0;
6058 GameObject
* pGameObj
= new GameObject
;
6061 // If dest location if present
6062 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
6064 x
= m_targets
.m_destX
;
6065 y
= m_targets
.m_destY
;
6066 z
= m_targets
.m_destZ
;
6068 // Summon in random point all other units if location present
6070 m_caster
->GetClosePoint(x
, y
, z
, DEFAULT_WORLD_OBJECT_SIZE
);
6072 Map
*map
= m_caster
->GetMap();
6073 if(!pGameObj
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), go_id
, map
,
6074 m_caster
->GetPhaseMask(), x
, y
, z
, m_caster
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0, GO_STATE_READY
))
6080 pGameObj
->SetUInt32Value(GAMEOBJECT_LEVEL
,m_caster
->getLevel());
6081 int32 duration
= GetSpellDuration(m_spellInfo
);
6082 pGameObj
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
6083 pGameObj
->SetSpellId(m_spellInfo
->Id
);
6084 m_caster
->AddGameObject(pGameObj
);
6088 m_caster
->m_ObjectSlot
[slot
] = pGameObj
->GetGUID();
6091 void Spell::EffectResurrect(uint32
/*effIndex*/)
6095 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6098 if(unitTarget
->isAlive())
6100 if(!unitTarget
->IsInWorld())
6103 switch (m_spellInfo
->Id
)
6105 // Defibrillate (Goblin Jumper Cables) have 33% chance on success
6107 if (roll_chance_i(67))
6109 m_caster
->CastSpell(m_caster
, 8338, true, m_CastItem
);
6113 // Defibrillate (Goblin Jumper Cables XL) have 50% chance on success
6115 if (roll_chance_i(50))
6117 m_caster
->CastSpell(m_caster
, 23055, true, m_CastItem
);
6125 Player
* pTarget
= ((Player
*)unitTarget
);
6127 if(pTarget
->isRessurectRequested()) // already have one active request
6130 uint32 health
= pTarget
->GetMaxHealth() * damage
/ 100;
6131 uint32 mana
= pTarget
->GetMaxPower(POWER_MANA
) * damage
/ 100;
6133 pTarget
->setResurrectRequestData(m_caster
->GetGUID(), m_caster
->GetMapId(), m_caster
->GetPositionX(), m_caster
->GetPositionY(), m_caster
->GetPositionZ(), health
, mana
);
6134 SendResurrectRequest(pTarget
);
6137 void Spell::EffectAddExtraAttacks(uint32
/*i*/)
6139 if(!unitTarget
|| !unitTarget
->isAlive())
6142 if( unitTarget
->m_extraAttacks
)
6145 unitTarget
->m_extraAttacks
= damage
;
6148 void Spell::EffectParry(uint32
/*i*/)
6150 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
6151 ((Player
*)unitTarget
)->SetCanParry(true);
6154 void Spell::EffectBlock(uint32
/*i*/)
6156 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
6157 ((Player
*)unitTarget
)->SetCanBlock(true);
6160 void Spell::EffectLeapForward(uint32 i
)
6162 if(unitTarget
->isInFlight())
6165 if( m_spellInfo
->rangeIndex
== 1) //self range
6167 float dis
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[i
]));
6171 unitTarget
->GetClosePoint(fx
, fy
, fz
, unitTarget
->GetObjectSize(), dis
);
6173 unitTarget
->GetPosition(ox
, oy
, oz
);
6175 float fx2
, fy2
, fz2
; // getObjectHitPos overwrite last args in any result case
6176 if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(unitTarget
->GetMapId(), ox
,oy
,oz
+0.5, fx
,fy
,oz
+0.5,fx2
,fy2
,fz2
, -0.5))
6181 unitTarget
->UpdateGroundPositionZ(fx
, fy
, fz
);
6184 unitTarget
->NearTeleportTo(fx
, fy
, fz
, unitTarget
->GetOrientation(), unitTarget
== m_caster
);
6188 void Spell::EffectLeapBack(uint32 i
)
6190 if(unitTarget
->isInFlight())
6193 m_caster
->KnockBackFrom(unitTarget
,float(m_spellInfo
->EffectMiscValue
[i
])/10,float(damage
)/10);
6196 void Spell::EffectReputation(uint32 i
)
6198 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6201 Player
*_player
= (Player
*)unitTarget
;
6203 int32 rep_change
= m_currentBasePoints
[i
]+1; // field store reputation change -1
6205 uint32 faction_id
= m_spellInfo
->EffectMiscValue
[i
];
6207 FactionEntry
const* factionEntry
= sFactionStore
.LookupEntry(faction_id
);
6212 _player
->GetReputationMgr().ModifyReputation(factionEntry
, rep_change
);
6215 void Spell::EffectQuestComplete(uint32 i
)
6217 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6220 Player
*_player
= (Player
*)m_caster
;
6222 uint32 quest_id
= m_spellInfo
->EffectMiscValue
[i
];
6223 _player
->AreaExploredOrEventHappens(quest_id
);
6226 void Spell::EffectSelfResurrect(uint32 i
)
6228 if(!unitTarget
|| unitTarget
->isAlive())
6230 if(unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6232 if(!unitTarget
->IsInWorld())
6241 health
= uint32(-damage
);
6242 mana
= m_spellInfo
->EffectMiscValue
[i
];
6247 health
= uint32(damage
/100.0f
*unitTarget
->GetMaxHealth());
6248 if(unitTarget
->GetMaxPower(POWER_MANA
) > 0)
6249 mana
= uint32(damage
/100.0f
*unitTarget
->GetMaxPower(POWER_MANA
));
6252 Player
*plr
= ((Player
*)unitTarget
);
6253 plr
->ResurrectPlayer(0.0f
);
6255 plr
->SetHealth( health
);
6256 plr
->SetPower(POWER_MANA
, mana
);
6257 plr
->SetPower(POWER_RAGE
, 0 );
6258 plr
->SetPower(POWER_ENERGY
, plr
->GetMaxPower(POWER_ENERGY
) );
6260 plr
->SpawnCorpseBones();
6263 void Spell::EffectSkinning(uint32
/*i*/)
6265 if(unitTarget
->GetTypeId() != TYPEID_UNIT
)
6267 if(!m_caster
|| m_caster
->GetTypeId() != TYPEID_PLAYER
)
6270 Creature
* creature
= (Creature
*) unitTarget
;
6271 int32 targetLevel
= creature
->getLevel();
6273 uint32 skill
= creature
->GetCreatureInfo()->GetRequiredLootSkill();
6275 ((Player
*)m_caster
)->SendLoot(creature
->GetGUID(),LOOT_SKINNING
);
6276 creature
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SKINNABLE
);
6278 int32 reqValue
= targetLevel
< 10 ? 0 : targetLevel
< 20 ? (targetLevel
-10)*10 : targetLevel
*5;
6280 int32 skillValue
= ((Player
*)m_caster
)->GetPureSkillValue(skill
);
6282 // Double chances for elites
6283 ((Player
*)m_caster
)->UpdateGatherSkill(skill
, skillValue
, reqValue
, creature
->isElite() ? 2 : 1 );
6286 void Spell::EffectCharge(uint32
/*i*/)
6291 //TODO: research more ContactPoint/attack distance.
6292 //3.666666 instead of ATTACK_DISTANCE(5.0f) in below seem to give more accurate result.
6294 unitTarget
->GetContactPoint(m_caster
, x
, y
, z
, 3.666666f
);
6296 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6297 ((Creature
*)unitTarget
)->StopMoving();
6299 // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags
6300 m_caster
->SendMonsterMove(x
, y
, z
, 0, m_caster
->GetTypeId()==TYPEID_PLAYER
? MONSTER_MOVE_WALK
: ((Creature
*)m_caster
)->GetMonsterMoveFlags(), 1);
6302 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
6303 m_caster
->GetMap()->CreatureRelocation((Creature
*)m_caster
,x
,y
,z
,m_caster
->GetOrientation());
6305 // not all charge effects used in negative spells
6306 if (unitTarget
!= m_caster
&& !IsPositiveSpell(m_spellInfo
->Id
))
6307 m_caster
->Attack(unitTarget
,true);
6310 void Spell::EffectCharge2(uint32
/*i*/)
6313 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
6315 x
= m_targets
.m_destX
;
6316 y
= m_targets
.m_destY
;
6317 z
= m_targets
.m_destZ
;
6319 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6320 ((Creature
*)unitTarget
)->StopMoving();
6322 else if (unitTarget
&& unitTarget
!= m_caster
)
6323 unitTarget
->GetContactPoint(m_caster
, x
, y
, z
, 3.666666f
);
6327 // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags
6328 m_caster
->SendMonsterMove(x
, y
, z
, 0, m_caster
->GetTypeId()==TYPEID_PLAYER
? MONSTER_MOVE_WALK
: ((Creature
*)m_caster
)->GetMonsterMoveFlags(), 1);
6330 if (m_caster
->GetTypeId() != TYPEID_PLAYER
)
6331 m_caster
->GetMap()->CreatureRelocation((Creature
*)m_caster
,x
,y
,z
,m_caster
->GetOrientation());
6333 // not all charge effects used in negative spells
6334 if (unitTarget
&& unitTarget
!= m_caster
&& !IsPositiveSpell(m_spellInfo
->Id
))
6335 m_caster
->Attack(unitTarget
,true);
6338 void Spell::EffectSummonCritter(uint32 i
, uint32 forceFaction
)
6340 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6342 Player
* player
= (Player
*)m_caster
;
6344 uint32 pet_entry
= m_spellInfo
->EffectMiscValue
[i
];
6348 Pet
* old_critter
= player
->GetMiniPet();
6350 // for same pet just despawn
6351 if(old_critter
&& old_critter
->GetEntry() == pet_entry
)
6353 player
->RemoveMiniPet();
6357 // despawn old pet before summon new
6359 player
->RemoveMiniPet();
6362 Pet
* critter
= new Pet(MINI_PET
);
6364 Map
*map
= m_caster
->GetMap();
6365 uint32 pet_number
= sObjectMgr
.GeneratePetNumber();
6366 if(!critter
->Create(map
->GenerateLocalLowGuid(HIGHGUID_PET
), map
, m_caster
->GetPhaseMask(),
6367 pet_entry
, pet_number
))
6369 sLog
.outError("Spell::EffectSummonCritter, spellid %u: no such creature entry %u", m_spellInfo
->Id
, pet_entry
);
6375 // If dest location if present
6376 if (m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
6378 x
= m_targets
.m_destX
;
6379 y
= m_targets
.m_destY
;
6380 z
= m_targets
.m_destZ
;
6382 // Summon if dest location not present near caster
6384 m_caster
->GetClosePoint(x
, y
, z
, critter
->GetObjectSize());
6386 critter
->Relocate(x
, y
, z
, m_caster
->GetOrientation());
6388 if(!critter
->IsPositionValid())
6390 sLog
.outError("Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
6391 critter
->GetGUIDLow(), critter
->GetEntry(), critter
->GetPositionX(), critter
->GetPositionY());
6396 critter
->SetOwnerGUID(m_caster
->GetGUID());
6397 critter
->SetCreatorGUID(m_caster
->GetGUID());
6399 critter
->SetUInt32Value(UNIT_CREATED_BY_SPELL
, m_spellInfo
->Id
);
6400 critter
->setFaction(forceFaction
? forceFaction
: m_caster
->getFaction());
6401 critter
->AIM_Initialize();
6402 critter
->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as critter...
6403 //critter->InitLevelupSpellsForLevel(); // none?
6404 critter
->SelectLevel(critter
->GetCreatureInfo()); // some summoned creaters have different from 1 DB data for level/hp
6405 critter
->SetUInt32Value(UNIT_NPC_FLAGS
, critter
->GetCreatureInfo()->npcflag
);
6406 // some mini-pets have quests
6408 // set timer for unsummon
6409 int32 duration
= GetSpellDuration(m_spellInfo
);
6411 critter
->SetDuration(duration
);
6413 std::string name
= player
->GetName();
6414 name
.append(petTypeSuffix
[critter
->getPetType()]);
6415 critter
->SetName( name
);
6416 player
->SetMiniPet(critter
);
6418 map
->Add((Creature
*)critter
);
6421 void Spell::EffectKnockBack(uint32 i
)
6426 unitTarget
->KnockBackFrom(m_caster
,float(m_spellInfo
->EffectMiscValue
[i
])/10,float(damage
)/10);
6429 void Spell::EffectSendTaxi(uint32 i
)
6431 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6434 ((Player
*)unitTarget
)->ActivateTaxiPathTo(m_spellInfo
->EffectMiscValue
[i
],m_spellInfo
->Id
);
6437 void Spell::EffectPlayerPull(uint32 i
)
6442 float dist
= unitTarget
->GetDistance2d(m_caster
);
6443 if (damage
&& dist
> damage
)
6446 unitTarget
->KnockBackFrom(m_caster
,-dist
,float(m_spellInfo
->EffectMiscValue
[i
])/10);
6449 void Spell::EffectDispelMechanic(uint32 i
)
6454 uint32 mechanic
= m_spellInfo
->EffectMiscValue
[i
];
6456 Unit::AuraMap
& Auras
= unitTarget
->GetAuras();
6457 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
6461 SpellEntry
const *spell
= sSpellStore
.LookupEntry(iter
->second
->GetSpellProto()->Id
);
6462 if(spell
->Mechanic
== mechanic
|| spell
->EffectMechanic
[iter
->second
->GetEffIndex()] == mechanic
)
6464 unitTarget
->RemoveAurasDueToSpell(spell
->Id
);
6468 next
= Auras
.begin();
6474 void Spell::EffectSummonDeadPet(uint32
/*i*/)
6476 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6478 Player
*_player
= (Player
*)m_caster
;
6479 Pet
*pet
= _player
->GetPet();
6486 pet
->SetUInt32Value(UNIT_DYNAMIC_FLAGS
, 0);
6487 pet
->RemoveFlag (UNIT_FIELD_FLAGS
, UNIT_FLAG_SKINNABLE
);
6488 pet
->setDeathState( ALIVE
);
6489 pet
->clearUnitState(UNIT_STAT_ALL_STATE
);
6490 pet
->SetHealth( uint32(pet
->GetMaxHealth()*(float(damage
)/100)));
6492 pet
->AIM_Initialize();
6494 // _player->PetSpellInitialize(); -- action bar not removed at death and not required send at revive
6495 pet
->SavePetToDB(PET_SAVE_AS_CURRENT
);
6498 void Spell::EffectDestroyAllTotems(uint32
/*i*/)
6501 for(int slot
= 0; slot
< MAX_TOTEM
; ++slot
)
6503 if(!m_caster
->m_TotemSlot
[slot
])
6506 Creature
* totem
= m_caster
->GetMap()->GetCreature(m_caster
->m_TotemSlot
[slot
]);
6507 if(totem
&& totem
->isTotem())
6509 uint32 spell_id
= totem
->GetUInt32Value(UNIT_CREATED_BY_SPELL
);
6510 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell_id
);
6513 uint32 manacost
= m_caster
->GetCreateMana() * spellInfo
->ManaCostPercentage
/ 100;
6514 mana
+= manacost
* damage
/ 100;
6516 ((Totem
*)totem
)->UnSummon();
6521 m_caster
->CastCustomSpell(m_caster
, 39104, &mana
, NULL
, NULL
, true);
6524 void Spell::EffectDurabilityDamage(uint32 i
)
6526 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6529 int32 slot
= m_spellInfo
->EffectMiscValue
[i
];
6531 // FIXME: some spells effects have value -1/-2
6532 // Possibly its mean -1 all player equipped items and -2 all items
6535 ((Player
*)unitTarget
)->DurabilityPointsLossAll(damage
, (slot
< -1));
6539 // invalid slot value
6540 if(slot
>= INVENTORY_SLOT_BAG_END
)
6543 if(Item
* item
= ((Player
*)unitTarget
)->GetItemByPos(INVENTORY_SLOT_BAG_0
, slot
))
6544 ((Player
*)unitTarget
)->DurabilityPointsLoss(item
, damage
);
6547 void Spell::EffectDurabilityDamagePCT(uint32 i
)
6549 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6552 int32 slot
= m_spellInfo
->EffectMiscValue
[i
];
6554 // FIXME: some spells effects have value -1/-2
6555 // Possibly its mean -1 all player equipped items and -2 all items
6558 ((Player
*)unitTarget
)->DurabilityLossAll(double(damage
)/100.0f
, (slot
< -1));
6562 // invalid slot value
6563 if(slot
>= INVENTORY_SLOT_BAG_END
)
6569 if(Item
* item
= ((Player
*)unitTarget
)->GetItemByPos(INVENTORY_SLOT_BAG_0
, slot
))
6570 ((Player
*)unitTarget
)->DurabilityLoss(item
, double(damage
)/100.0f
);
6573 void Spell::EffectModifyThreatPercent(uint32
/*effIndex*/)
6578 unitTarget
->getThreatManager().modifyThreatPercent(m_caster
, damage
);
6581 void Spell::EffectTransmitted(uint32 effIndex
)
6583 uint32 name_id
= m_spellInfo
->EffectMiscValue
[effIndex
];
6585 GameObjectInfo
const* goinfo
= ObjectMgr::GetGameObjectInfo(name_id
);
6589 sLog
.outErrorDb("Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast",name_id
, m_spellInfo
->Id
);
6595 if(m_targets
.m_targetMask
& TARGET_FLAG_DEST_LOCATION
)
6597 fx
= m_targets
.m_destX
;
6598 fy
= m_targets
.m_destY
;
6599 fz
= m_targets
.m_destZ
;
6601 //FIXME: this can be better check for most objects but still hack
6602 else if(m_spellInfo
->EffectRadiusIndex
[effIndex
] && m_spellInfo
->speed
==0)
6604 float dis
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellInfo
->EffectRadiusIndex
[effIndex
]));
6605 m_caster
->GetClosePoint(fx
, fy
, fz
, DEFAULT_WORLD_OBJECT_SIZE
, dis
);
6609 float min_dis
= GetSpellMinRange(sSpellRangeStore
.LookupEntry(m_spellInfo
->rangeIndex
));
6610 float max_dis
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(m_spellInfo
->rangeIndex
));
6611 float dis
= rand_norm() * (max_dis
- min_dis
) + min_dis
;
6613 m_caster
->GetClosePoint(fx
, fy
, fz
, DEFAULT_WORLD_OBJECT_SIZE
, dis
);
6616 Map
*cMap
= m_caster
->GetMap();
6618 if(goinfo
->type
==GAMEOBJECT_TYPE_FISHINGNODE
)
6620 if ( !cMap
->IsInWater(fx
, fy
, fz
-0.5f
)) // Hack to prevent fishing bobber from failing to land on fishing hole
6621 { // but this is not proper, we really need to ignore not materialized objects
6622 SendCastResult(SPELL_FAILED_NOT_HERE
);
6623 SendChannelUpdate(0);
6627 // replace by water level in this case
6628 fz
= cMap
->GetWaterLevel(fx
, fy
);
6630 // if gameobject is summoning object, it should be spawned right on caster's position
6631 else if(goinfo
->type
==GAMEOBJECT_TYPE_SUMMONING_RITUAL
)
6633 m_caster
->GetPosition(fx
, fy
, fz
);
6636 GameObject
* pGameObj
= new GameObject
;
6638 if(!pGameObj
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), name_id
, cMap
,
6639 m_caster
->GetPhaseMask(), fx
, fy
, fz
, m_caster
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
6645 int32 duration
= GetSpellDuration(m_spellInfo
);
6647 switch(goinfo
->type
)
6649 case GAMEOBJECT_TYPE_FISHINGNODE
:
6651 m_caster
->SetChannelObjectGUID(pGameObj
->GetGUID());
6652 m_caster
->AddGameObject(pGameObj
); // will removed at spell cancel
6654 // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
6655 // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME)
6659 case 0: lastSec
= 3; break;
6660 case 1: lastSec
= 7; break;
6661 case 2: lastSec
= 13; break;
6662 case 3: lastSec
= 17; break;
6665 duration
= duration
- lastSec
*IN_MILISECONDS
+ FISHING_BOBBER_READY_TIME
*IN_MILISECONDS
;
6668 case GAMEOBJECT_TYPE_SUMMONING_RITUAL
:
6670 if(m_caster
->GetTypeId() == TYPEID_PLAYER
)
6672 pGameObj
->AddUniqueUse((Player
*)m_caster
);
6673 m_caster
->AddGameObject(pGameObj
); // will removed at spell cancel
6677 case GAMEOBJECT_TYPE_FISHINGHOLE
:
6678 case GAMEOBJECT_TYPE_CHEST
:
6683 pGameObj
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
6685 pGameObj
->SetOwnerGUID(m_caster
->GetGUID());
6687 pGameObj
->SetUInt32Value(GAMEOBJECT_LEVEL
, m_caster
->getLevel());
6688 pGameObj
->SetSpellId(m_spellInfo
->Id
);
6690 DEBUG_LOG("AddObject at SpellEfects.cpp EffectTransmitted");
6691 //m_caster->AddGameObject(pGameObj);
6692 //m_ObjToDel.push_back(pGameObj);
6694 cMap
->Add(pGameObj
);
6696 if(uint32 linkedEntry
= pGameObj
->GetGOInfo()->GetLinkedGameObjectEntry())
6698 GameObject
* linkedGO
= new GameObject
;
6699 if(linkedGO
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), linkedEntry
, cMap
,
6700 m_caster
->GetPhaseMask(), fx
, fy
, fz
, m_caster
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
6702 linkedGO
->SetRespawnTime(duration
> 0 ? duration
/IN_MILISECONDS
: 0);
6703 linkedGO
->SetUInt32Value(GAMEOBJECT_LEVEL
, m_caster
->getLevel());
6704 linkedGO
->SetSpellId(m_spellInfo
->Id
);
6705 linkedGO
->SetOwnerGUID(m_caster
->GetGUID());
6707 linkedGO
->GetMap()->Add(linkedGO
);
6718 void Spell::EffectProspecting(uint32
/*i*/)
6720 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6723 Player
* p_caster
= (Player
*)m_caster
;
6724 if(!itemTarget
|| !(itemTarget
->GetProto()->BagFamily
& BAG_FAMILY_MASK_MINING_SUPP
))
6727 if(itemTarget
->GetCount() < 5)
6730 if( sWorld
.getConfig(CONFIG_SKILL_PROSPECTING
))
6732 uint32 SkillValue
= p_caster
->GetPureSkillValue(SKILL_JEWELCRAFTING
);
6733 uint32 reqSkillValue
= itemTarget
->GetProto()->RequiredSkillRank
;
6734 p_caster
->UpdateGatherSkill(SKILL_JEWELCRAFTING
, SkillValue
, reqSkillValue
);
6737 ((Player
*)m_caster
)->SendLoot(itemTarget
->GetGUID(), LOOT_PROSPECTING
);
6740 void Spell::EffectMilling(uint32
/*i*/)
6742 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6745 Player
* p_caster
= (Player
*)m_caster
;
6746 if(!itemTarget
|| !(itemTarget
->GetProto()->BagFamily
& BAG_FAMILY_MASK_HERBS
))
6749 if(itemTarget
->GetCount() < 5)
6752 if( sWorld
.getConfig(CONFIG_SKILL_MILLING
))
6754 uint32 SkillValue
= p_caster
->GetPureSkillValue(SKILL_INSCRIPTION
);
6755 uint32 reqSkillValue
= itemTarget
->GetProto()->RequiredSkillRank
;
6756 p_caster
->UpdateGatherSkill(SKILL_INSCRIPTION
, SkillValue
, reqSkillValue
);
6759 ((Player
*)m_caster
)->SendLoot(itemTarget
->GetGUID(), LOOT_MILLING
);
6762 void Spell::EffectSkill(uint32
/*i*/)
6764 sLog
.outDebug("WORLD: SkillEFFECT");
6767 void Spell::EffectSpiritHeal(uint32
/*i*/)
6769 // TODO player can't see the heal-animation - he should respawn some ticks later
6770 if (!unitTarget
|| unitTarget
->isAlive())
6772 if (unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6774 if (!unitTarget
->IsInWorld())
6776 if (m_spellInfo
->Id
== 22012 && !unitTarget
->HasAura(2584))
6779 ((Player
*)unitTarget
)->ResurrectPlayer(1.0f
);
6780 ((Player
*)unitTarget
)->SpawnCorpseBones();
6783 // remove insignia spell effect
6784 void Spell::EffectSkinPlayerCorpse(uint32
/*i*/)
6786 sLog
.outDebug("Effect: SkinPlayerCorpse");
6787 if ( (m_caster
->GetTypeId() != TYPEID_PLAYER
) || (unitTarget
->GetTypeId() != TYPEID_PLAYER
) || (unitTarget
->isAlive()) )
6790 ((Player
*)unitTarget
)->RemovedInsignia( (Player
*)m_caster
);
6793 void Spell::EffectStealBeneficialBuff(uint32 i
)
6795 sLog
.outDebug("Effect: StealBeneficialBuff");
6797 if(!unitTarget
|| unitTarget
==m_caster
) // can't steal from self
6800 std::vector
<Aura
*> steal_list
;
6801 // Create dispel mask by dispel type
6802 uint32 dispelMask
= GetDispellMask( DispelType(m_spellInfo
->EffectMiscValue
[i
]) );
6803 Unit::AuraMap
const& auras
= unitTarget
->GetAuras();
6804 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
6806 Aura
*aur
= (*itr
).second
;
6807 if (aur
&& (1<<aur
->GetSpellProto()->Dispel
) & dispelMask
)
6809 // Need check for passive? this
6810 if (aur
->IsPositive() && !aur
->IsPassive() && !(aur
->GetSpellProto()->AttributesEx4
& SPELL_ATTR_EX4_NOT_STEALABLE
))
6811 steal_list
.push_back(aur
);
6814 // Ok if exist some buffs for dispel try dispel it
6815 if (!steal_list
.empty())
6817 std::list
< std::pair
<uint32
,uint64
> > success_list
;
6818 int32 list_size
= steal_list
.size();
6819 // Dispell N = damage buffs (or while exist buffs for dispel)
6820 for (int32 count
=0; count
< damage
&& list_size
> 0; ++count
)
6822 // Random select buff for dispel
6823 Aura
*aur
= steal_list
[urand(0, list_size
-1)];
6824 // Not use chance for steal
6825 // TODO possible need do it
6826 success_list
.push_back( std::pair
<uint32
,uint64
>(aur
->GetId(),aur
->GetCasterGUID()));
6828 // Remove buff from list for prevent doubles
6829 for (std::vector
<Aura
*>::iterator j
= steal_list
.begin(); j
!= steal_list
.end(); )
6832 if (stealed
->GetId() == aur
->GetId() && stealed
->GetCasterGUID() == aur
->GetCasterGUID())
6834 j
= steal_list
.erase(j
);
6841 // Really try steal and send log
6842 if (!success_list
.empty())
6844 int32 count
= success_list
.size();
6845 WorldPacket
data(SMSG_SPELLSTEALLOG
, 8+8+4+1+4+count
*5);
6846 data
.append(unitTarget
->GetPackGUID()); // Victim GUID
6847 data
.append(m_caster
->GetPackGUID()); // Caster GUID
6848 data
<< uint32(m_spellInfo
->Id
); // Dispell spell id
6849 data
<< uint8(0); // not used
6850 data
<< uint32(count
); // count
6851 for (std::list
<std::pair
<uint32
,uint64
> >::iterator j
= success_list
.begin(); j
!= success_list
.end(); ++j
)
6853 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(j
->first
);
6854 data
<< uint32(spellInfo
->Id
); // Spell Id
6855 data
<< uint8(0); // 0 - steals !=0 transfers
6856 unitTarget
->RemoveAurasDueToSpellBySteal(spellInfo
->Id
, j
->second
, m_caster
);
6858 m_caster
->SendMessageToSet(&data
, true);
6863 void Spell::EffectKillCreditPersonal(uint32 i
)
6865 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6868 ((Player
*)unitTarget
)->KilledMonsterCredit(m_spellInfo
->EffectMiscValue
[i
], 0);
6871 void Spell::EffectKillCredit(uint32 i
)
6873 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6876 ((Player
*)unitTarget
)->RewardPlayerAndGroupAtEvent(m_spellInfo
->EffectMiscValue
[i
], unitTarget
);
6879 void Spell::EffectQuestFail(uint32 i
)
6881 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6884 ((Player
*)unitTarget
)->FailQuest(m_spellInfo
->EffectMiscValue
[i
]);
6887 void Spell::EffectActivateRune(uint32 eff_idx
)
6889 if(m_caster
->GetTypeId() != TYPEID_PLAYER
)
6892 Player
*plr
= (Player
*)m_caster
;
6894 if(plr
->getClass() != CLASS_DEATH_KNIGHT
)
6897 for(uint32 j
= 0; j
< MAX_RUNES
; ++j
)
6899 if(plr
->GetRuneCooldown(j
) && plr
->GetCurrentRune(j
) == RuneType(m_spellInfo
->EffectMiscValue
[eff_idx
]))
6901 plr
->SetRuneCooldown(j
, 0);
6906 void Spell::EffectTitanGrip(uint32
/*eff_idx*/)
6908 if (unitTarget
&& unitTarget
->GetTypeId() == TYPEID_PLAYER
)
6909 ((Player
*)unitTarget
)->SetCanTitanGrip(true);
6912 void Spell::EffectRenamePet(uint32
/*eff_idx*/)
6914 if (!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_UNIT
||
6915 !((Creature
*)unitTarget
)->isPet() || ((Pet
*)unitTarget
)->getPetType() != HUNTER_PET
)
6918 unitTarget
->SetByteValue(UNIT_FIELD_BYTES_2
, 2, UNIT_RENAME_ALLOWED
);
6921 void Spell::EffectPlayMusic(uint32 i
)
6923 if(!unitTarget
|| unitTarget
->GetTypeId() != TYPEID_PLAYER
)
6926 uint32 soundid
= m_spellInfo
->EffectMiscValue
[i
];
6928 if (!sSoundEntriesStore
.LookupEntry(soundid
))
6930 sLog
.outError("EffectPlayMusic: Sound (Id: %u) not exist in spell %u.",soundid
,m_spellInfo
->Id
);
6934 WorldPacket
data(SMSG_PLAY_MUSIC
, 4);
6935 data
<< uint32(soundid
);
6936 ((Player
*)unitTarget
)->GetSession()->SendPacket(&data
);