1 | /* |
---|
2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
3 | * |
---|
4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | |
---|
21 | #include "SpellMgr.h" |
---|
22 | #include "ObjectMgr.h" |
---|
23 | #include "SpellAuraDefines.h" |
---|
24 | #include "ProgressBar.h" |
---|
25 | #include "Database/DBCStores.h" |
---|
26 | #include "World.h" |
---|
27 | #include "Chat.h" |
---|
28 | #include "Spell.h" |
---|
29 | |
---|
30 | SpellMgr::SpellMgr() |
---|
31 | { |
---|
32 | } |
---|
33 | |
---|
34 | SpellMgr::~SpellMgr() |
---|
35 | { |
---|
36 | } |
---|
37 | |
---|
38 | SpellMgr& SpellMgr::Instance() |
---|
39 | { |
---|
40 | static SpellMgr spellMgr; |
---|
41 | return spellMgr; |
---|
42 | } |
---|
43 | |
---|
44 | int32 GetSpellDuration(SpellEntry const *spellInfo) |
---|
45 | { |
---|
46 | if(!spellInfo) |
---|
47 | return 0; |
---|
48 | SpellDurationEntry const *du = sSpellDurationStore.LookupEntry(spellInfo->DurationIndex); |
---|
49 | if(!du) |
---|
50 | return 0; |
---|
51 | return (du->Duration[0] == -1) ? -1 : abs(du->Duration[0]); |
---|
52 | } |
---|
53 | |
---|
54 | int32 GetSpellMaxDuration(SpellEntry const *spellInfo) |
---|
55 | { |
---|
56 | if(!spellInfo) |
---|
57 | return 0; |
---|
58 | SpellDurationEntry const *du = sSpellDurationStore.LookupEntry(spellInfo->DurationIndex); |
---|
59 | if(!du) |
---|
60 | return 0; |
---|
61 | return (du->Duration[2] == -1) ? -1 : abs(du->Duration[2]); |
---|
62 | } |
---|
63 | |
---|
64 | uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell) |
---|
65 | { |
---|
66 | SpellCastTimesEntry const *spellCastTimeEntry = sSpellCastTimesStore.LookupEntry(spellInfo->CastingTimeIndex); |
---|
67 | |
---|
68 | // not all spells have cast time index and this is all is pasiive abilities |
---|
69 | if(!spellCastTimeEntry) |
---|
70 | return 0; |
---|
71 | |
---|
72 | int32 castTime = spellCastTimeEntry->CastTime; |
---|
73 | |
---|
74 | if (spell) |
---|
75 | { |
---|
76 | if(Player* modOwner = spell->GetCaster()->GetSpellModOwner()) |
---|
77 | modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, castTime, spell); |
---|
78 | |
---|
79 | if( !(spellInfo->Attributes & (SPELL_ATTR_UNK4|SPELL_ATTR_UNK5)) ) |
---|
80 | castTime = int32(castTime * spell->GetCaster()->GetFloatValue(UNIT_MOD_CAST_SPEED)); |
---|
81 | else |
---|
82 | { |
---|
83 | if (spell->IsRangedSpell() && !spell->IsAutoRepeat()) |
---|
84 | castTime = int32(castTime * spell->GetCaster()->m_modAttackSpeedPct[RANGED_ATTACK]); |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | if (spellInfo->Attributes & SPELL_ATTR_RANGED && (!spell || !(spell->IsAutoRepeat()))) |
---|
89 | castTime += 500; |
---|
90 | |
---|
91 | return (castTime > 0) ? uint32(castTime) : 0; |
---|
92 | } |
---|
93 | |
---|
94 | bool IsPassiveSpell(uint32 spellId) |
---|
95 | { |
---|
96 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); |
---|
97 | if (!spellInfo) |
---|
98 | return false; |
---|
99 | return (spellInfo->Attributes & SPELL_ATTR_PASSIVE) != 0; |
---|
100 | } |
---|
101 | |
---|
102 | bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) |
---|
103 | { |
---|
104 | SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); |
---|
105 | SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); |
---|
106 | if(!spellInfo_1 || !spellInfo_2) return false; |
---|
107 | if(spellInfo_1->Id == spellId_2) return false; |
---|
108 | |
---|
109 | if (spellInfo_1->Effect[effIndex_1] != spellInfo_2->Effect[effIndex_2] || |
---|
110 | spellInfo_1->EffectItemType[effIndex_1] != spellInfo_2->EffectItemType[effIndex_2] || |
---|
111 | spellInfo_1->EffectMiscValue[effIndex_1] != spellInfo_2->EffectMiscValue[effIndex_2] || |
---|
112 | spellInfo_1->EffectApplyAuraName[effIndex_1] != spellInfo_2->EffectApplyAuraName[effIndex_2]) |
---|
113 | return false; |
---|
114 | |
---|
115 | return true; |
---|
116 | } |
---|
117 | |
---|
118 | int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) |
---|
119 | { |
---|
120 | SpellEntry const*spellInfo_1 = sSpellStore.LookupEntry(spellId_1); |
---|
121 | SpellEntry const*spellInfo_2 = sSpellStore.LookupEntry(spellId_2); |
---|
122 | if(!spellInfo_1 || !spellInfo_2) return 0; |
---|
123 | if (spellId_1 == spellId_2) return 0; |
---|
124 | |
---|
125 | int32 diff = spellInfo_1->EffectBasePoints[effIndex_1] - spellInfo_2->EffectBasePoints[effIndex_2]; |
---|
126 | if (spellInfo_1->EffectBasePoints[effIndex_1]+1 < 0 && spellInfo_2->EffectBasePoints[effIndex_2]+1 < 0) return -diff; |
---|
127 | else return diff; |
---|
128 | } |
---|
129 | |
---|
130 | SpellSpecific GetSpellSpecific(uint32 spellId) |
---|
131 | { |
---|
132 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); |
---|
133 | if(!spellInfo) |
---|
134 | return SPELL_NORMAL; |
---|
135 | |
---|
136 | switch(spellInfo->SpellFamilyName) |
---|
137 | { |
---|
138 | case SPELLFAMILY_MAGE: |
---|
139 | { |
---|
140 | // family flags 18(Molten), 25(Frost/Ice), 28(Mage) |
---|
141 | if (spellInfo->SpellFamilyFlags & 0x12040000) |
---|
142 | return SPELL_MAGE_ARMOR; |
---|
143 | |
---|
144 | if ((spellInfo->SpellFamilyFlags & 0x1000000) && spellInfo->EffectApplyAuraName[0]==SPELL_AURA_MOD_CONFUSE) |
---|
145 | return SPELL_MAGE_POLYMORPH; |
---|
146 | |
---|
147 | break; |
---|
148 | } |
---|
149 | case SPELLFAMILY_WARRIOR: |
---|
150 | { |
---|
151 | if (spellInfo->SpellFamilyFlags & 0x00008000010000LL) |
---|
152 | return SPELL_POSITIVE_SHOUT; |
---|
153 | |
---|
154 | break; |
---|
155 | } |
---|
156 | case SPELLFAMILY_WARLOCK: |
---|
157 | { |
---|
158 | // only warlock curses have this |
---|
159 | if (spellInfo->Dispel == DISPEL_CURSE) |
---|
160 | return SPELL_CURSE; |
---|
161 | |
---|
162 | // family flag 37 (only part spells have family name) |
---|
163 | if (spellInfo->SpellFamilyFlags & 0x2000000000LL) |
---|
164 | return SPELL_WARLOCK_ARMOR; |
---|
165 | |
---|
166 | break; |
---|
167 | } |
---|
168 | case SPELLFAMILY_HUNTER: |
---|
169 | { |
---|
170 | // only hunter stings have this |
---|
171 | if (spellInfo->Dispel == DISPEL_POISON) |
---|
172 | return SPELL_STING; |
---|
173 | |
---|
174 | break; |
---|
175 | } |
---|
176 | case SPELLFAMILY_PALADIN: |
---|
177 | { |
---|
178 | if (IsSealSpell(spellInfo)) |
---|
179 | return SPELL_SEAL; |
---|
180 | |
---|
181 | if (spellInfo->SpellFamilyFlags & 0x10000100LL) |
---|
182 | return SPELL_BLESSING; |
---|
183 | |
---|
184 | if ((spellInfo->SpellFamilyFlags & 0x00000820180400LL) && (spellInfo->AttributesEx3 & 0x200)) |
---|
185 | return SPELL_JUDGEMENT; |
---|
186 | |
---|
187 | for (int i = 0; i < 3; i++) |
---|
188 | { |
---|
189 | // only paladin auras have this |
---|
190 | if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY) |
---|
191 | return SPELL_AURA; |
---|
192 | } |
---|
193 | break; |
---|
194 | } |
---|
195 | case SPELLFAMILY_SHAMAN: |
---|
196 | { |
---|
197 | if (IsElementalShield(spellInfo)) |
---|
198 | return SPELL_ELEMENTAL_SHIELD; |
---|
199 | |
---|
200 | break; |
---|
201 | } |
---|
202 | |
---|
203 | case SPELLFAMILY_POTION: |
---|
204 | return spellmgr.GetSpellElixirSpecific(spellInfo->Id); |
---|
205 | } |
---|
206 | |
---|
207 | // only warlock armor/skin have this (in additional to family cases) |
---|
208 | if( spellInfo->SpellVisual == 130 && spellInfo->SpellIconID == 89) |
---|
209 | { |
---|
210 | return SPELL_WARLOCK_ARMOR; |
---|
211 | } |
---|
212 | |
---|
213 | // only hunter aspects have this (but not all aspects in hunter family) |
---|
214 | if( spellInfo->activeIconID == 122 && (GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NATURE) && |
---|
215 | (spellInfo->Attributes & 0x50000) != 0 && (spellInfo->Attributes & 0x9000010) == 0) |
---|
216 | { |
---|
217 | return SPELL_ASPECT; |
---|
218 | } |
---|
219 | |
---|
220 | for(int i = 0; i < 3; i++) |
---|
221 | if( spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && ( |
---|
222 | spellInfo->EffectApplyAuraName[i] == SPELL_AURA_TRACK_CREATURES || |
---|
223 | spellInfo->EffectApplyAuraName[i] == SPELL_AURA_TRACK_RESOURCES || |
---|
224 | spellInfo->EffectApplyAuraName[i] == SPELL_AURA_TRACK_STEALTHED ) ) |
---|
225 | return SPELL_TRACKER; |
---|
226 | |
---|
227 | // elixirs can have different families, but potion most ofc. |
---|
228 | if(SpellSpecific sp = spellmgr.GetSpellElixirSpecific(spellInfo->Id)) |
---|
229 | return sp; |
---|
230 | |
---|
231 | return SPELL_NORMAL; |
---|
232 | } |
---|
233 | |
---|
234 | bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2) |
---|
235 | { |
---|
236 | switch(spellSpec1) |
---|
237 | { |
---|
238 | case SPELL_SEAL: |
---|
239 | case SPELL_BLESSING: |
---|
240 | case SPELL_AURA: |
---|
241 | case SPELL_STING: |
---|
242 | case SPELL_CURSE: |
---|
243 | case SPELL_ASPECT: |
---|
244 | case SPELL_TRACKER: |
---|
245 | case SPELL_WARLOCK_ARMOR: |
---|
246 | case SPELL_MAGE_ARMOR: |
---|
247 | case SPELL_MAGE_POLYMORPH: |
---|
248 | case SPELL_POSITIVE_SHOUT: |
---|
249 | case SPELL_JUDGEMENT: |
---|
250 | return spellSpec1==spellSpec2; |
---|
251 | case SPELL_BATTLE_ELIXIR: |
---|
252 | return spellSpec2==SPELL_BATTLE_ELIXIR |
---|
253 | || spellSpec2==SPELL_FLASK_ELIXIR; |
---|
254 | case SPELL_GUARDIAN_ELIXIR: |
---|
255 | return spellSpec2==SPELL_GUARDIAN_ELIXIR |
---|
256 | || spellSpec2==SPELL_FLASK_ELIXIR; |
---|
257 | case SPELL_FLASK_ELIXIR: |
---|
258 | return spellSpec2==SPELL_BATTLE_ELIXIR |
---|
259 | || spellSpec2==SPELL_GUARDIAN_ELIXIR |
---|
260 | || spellSpec2==SPELL_FLASK_ELIXIR; |
---|
261 | default: |
---|
262 | return false; |
---|
263 | } |
---|
264 | } |
---|
265 | |
---|
266 | bool IsPositiveTarget(uint32 targetA, uint32 targetB) |
---|
267 | { |
---|
268 | // non-positive targets |
---|
269 | switch(targetA) |
---|
270 | { |
---|
271 | case TARGET_CHAIN_DAMAGE: |
---|
272 | case TARGET_ALL_ENEMY_IN_AREA: |
---|
273 | case TARGET_ALL_ENEMY_IN_AREA_INSTANT: |
---|
274 | case TARGET_IN_FRONT_OF_CASTER: |
---|
275 | case TARGET_ALL_ENEMY_IN_AREA_CHANNELED: |
---|
276 | case TARGET_CURRENT_ENEMY_COORDINATES: |
---|
277 | case TARGET_SINGLE_ENEMY: |
---|
278 | return false; |
---|
279 | case TARGET_ALL_AROUND_CASTER: |
---|
280 | return (targetB == TARGET_ALL_PARTY || targetB == TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER); |
---|
281 | default: |
---|
282 | break; |
---|
283 | } |
---|
284 | if (targetB) |
---|
285 | return IsPositiveTarget(targetB, 0); |
---|
286 | return true; |
---|
287 | } |
---|
288 | |
---|
289 | bool IsPositiveEffect(uint32 spellId, uint32 effIndex) |
---|
290 | { |
---|
291 | SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId); |
---|
292 | if (!spellproto) return false; |
---|
293 | |
---|
294 | switch(spellId) |
---|
295 | { |
---|
296 | case 23333: // BG spell |
---|
297 | case 23335: // BG spell |
---|
298 | case 34976: // BG spell |
---|
299 | return true; |
---|
300 | case 28441: // not positive dummy spell |
---|
301 | case 37675: // Chaos Blast |
---|
302 | return false; |
---|
303 | } |
---|
304 | |
---|
305 | switch(spellproto->Effect[effIndex]) |
---|
306 | { |
---|
307 | // always positive effects (check before target checks that provided non-positive result in some case for positive effects) |
---|
308 | case SPELL_EFFECT_HEAL: |
---|
309 | case SPELL_EFFECT_LEARN_SPELL: |
---|
310 | case SPELL_EFFECT_SKILL_STEP: |
---|
311 | case SPELL_EFFECT_HEAL_PCT: |
---|
312 | case SPELL_EFFECT_ENERGIZE_PCT: |
---|
313 | return true; |
---|
314 | |
---|
315 | // non-positive aura use |
---|
316 | case SPELL_EFFECT_APPLY_AURA: |
---|
317 | case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: |
---|
318 | { |
---|
319 | switch(spellproto->EffectApplyAuraName[effIndex]) |
---|
320 | { |
---|
321 | case SPELL_AURA_DUMMY: |
---|
322 | { |
---|
323 | // dummy aura can be positive or negative dependent from casted spell |
---|
324 | switch(spellproto->Id) |
---|
325 | { |
---|
326 | case 13139: // net-o-matic special effect |
---|
327 | case 23445: // evil twin |
---|
328 | return false; |
---|
329 | default: |
---|
330 | break; |
---|
331 | } |
---|
332 | } break; |
---|
333 | case SPELL_AURA_MOD_STAT: |
---|
334 | case SPELL_AURA_MOD_DAMAGE_DONE: // dependent from bas point sign (negative -> negative) |
---|
335 | case SPELL_AURA_MOD_HEALING_DONE: |
---|
336 | { |
---|
337 | if(spellproto->EffectBasePoints[effIndex]+int32(spellproto->EffectBaseDice[effIndex]) < 0) |
---|
338 | return false; |
---|
339 | break; |
---|
340 | } |
---|
341 | case SPELL_AURA_ADD_TARGET_TRIGGER: |
---|
342 | return true; |
---|
343 | case SPELL_AURA_PERIODIC_TRIGGER_SPELL: |
---|
344 | if(spellId != spellproto->EffectTriggerSpell[effIndex]) |
---|
345 | { |
---|
346 | uint32 spellTriggeredId = spellproto->EffectTriggerSpell[effIndex]; |
---|
347 | SpellEntry const *spellTriggeredProto = sSpellStore.LookupEntry(spellTriggeredId); |
---|
348 | |
---|
349 | if(spellTriggeredProto) |
---|
350 | { |
---|
351 | // non-positive targets of main spell return early |
---|
352 | for(int i = 0; i < 3; ++i) |
---|
353 | { |
---|
354 | // if non-positive trigger cast targeted to positive target this main cast is non-positive |
---|
355 | // this will place this spell auras as debuffs |
---|
356 | if(IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[effIndex],spellTriggeredProto->EffectImplicitTargetB[effIndex]) && !IsPositiveEffect(spellTriggeredId,i)) |
---|
357 | return false; |
---|
358 | } |
---|
359 | } |
---|
360 | } |
---|
361 | break; |
---|
362 | case SPELL_AURA_PROC_TRIGGER_SPELL: |
---|
363 | // many positive auras have negative triggered spells at damage for example and this not make it negative (it can be canceled for example) |
---|
364 | break; |
---|
365 | case SPELL_AURA_MOD_STUN: //have positive and negative spells, we can't sort its correctly at this moment. |
---|
366 | if(effIndex==0 && spellproto->Effect[1]==0 && spellproto->Effect[2]==0) |
---|
367 | return false; // but all single stun aura spells is negative |
---|
368 | |
---|
369 | // Petrification |
---|
370 | if(spellproto->Id == 17624) |
---|
371 | return false; |
---|
372 | break; |
---|
373 | case SPELL_AURA_MOD_ROOT: |
---|
374 | case SPELL_AURA_MOD_SILENCE: |
---|
375 | case SPELL_AURA_GHOST: |
---|
376 | case SPELL_AURA_PERIODIC_LEECH: |
---|
377 | case SPELL_AURA_MOD_PACIFY_SILENCE: |
---|
378 | case SPELL_AURA_MOD_STALKED: |
---|
379 | case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: |
---|
380 | return false; |
---|
381 | case SPELL_AURA_PERIODIC_DAMAGE: // used in positive spells also. |
---|
382 | // part of negative spell if casted at self (prevent cancel) |
---|
383 | if(spellproto->EffectImplicitTargetA[effIndex] == TARGET_SELF) |
---|
384 | return false; |
---|
385 | break; |
---|
386 | case SPELL_AURA_MOD_DECREASE_SPEED: // used in positive spells also |
---|
387 | // part of positive spell if casted at self |
---|
388 | if(spellproto->EffectImplicitTargetA[effIndex] != TARGET_SELF) |
---|
389 | return false; |
---|
390 | // but not this if this first effect (don't found batter check) |
---|
391 | if(spellproto->Attributes & 0x4000000 && effIndex==0) |
---|
392 | return false; |
---|
393 | break; |
---|
394 | case SPELL_AURA_TRANSFORM: |
---|
395 | // some spells negative |
---|
396 | switch(spellproto->Id) |
---|
397 | { |
---|
398 | case 36897: // Transporter Malfunction (race mutation to horde) |
---|
399 | case 36899: // Transporter Malfunction (race mutation to alliance) |
---|
400 | return false; |
---|
401 | } |
---|
402 | break; |
---|
403 | case SPELL_AURA_MOD_SCALE: |
---|
404 | // some spells negative |
---|
405 | switch(spellproto->Id) |
---|
406 | { |
---|
407 | case 36900: // Soul Split: Evil! |
---|
408 | case 36901: // Soul Split: Good |
---|
409 | case 36893: // Transporter Malfunction (decrease size case) |
---|
410 | case 36895: // Transporter Malfunction (increase size case) |
---|
411 | return false; |
---|
412 | } |
---|
413 | break; |
---|
414 | case SPELL_AURA_MECHANIC_IMMUNITY: |
---|
415 | { |
---|
416 | // non-positive immunities |
---|
417 | switch(spellproto->EffectMiscValue[effIndex]) |
---|
418 | { |
---|
419 | case MECHANIC_BANDAGE: |
---|
420 | case MECHANIC_SHIELD: |
---|
421 | case MECHANIC_MOUNT: |
---|
422 | case MECHANIC_INVULNERABILITY: |
---|
423 | return false; |
---|
424 | default: |
---|
425 | break; |
---|
426 | } |
---|
427 | } break; |
---|
428 | case SPELL_AURA_ADD_FLAT_MODIFIER: // mods |
---|
429 | case SPELL_AURA_ADD_PCT_MODIFIER: |
---|
430 | { |
---|
431 | // non-positive mods |
---|
432 | switch(spellproto->EffectMiscValue[effIndex]) |
---|
433 | { |
---|
434 | case SPELLMOD_COST: // dependent from bas point sign (negative -> positive) |
---|
435 | if(spellproto->EffectBasePoints[effIndex]+int32(spellproto->EffectBaseDice[effIndex]) > 0) |
---|
436 | return false; |
---|
437 | break; |
---|
438 | default: |
---|
439 | break; |
---|
440 | } |
---|
441 | } break; |
---|
442 | case SPELL_AURA_MOD_HEALING_PCT: |
---|
443 | if(spellproto->EffectBasePoints[effIndex]+int32(spellproto->EffectBaseDice[effIndex]) < 0) |
---|
444 | return false; |
---|
445 | break; |
---|
446 | case SPELL_AURA_MOD_SKILL: |
---|
447 | if(spellproto->EffectBasePoints[effIndex]+int32(spellproto->EffectBaseDice[effIndex]) < 0) |
---|
448 | return false; |
---|
449 | break; |
---|
450 | case SPELL_AURA_FORCE_REACTION: |
---|
451 | if(spellproto->Id==42792) // Recently Dropped Flag (prevent cancel) |
---|
452 | return false; |
---|
453 | break; |
---|
454 | default: |
---|
455 | break; |
---|
456 | } |
---|
457 | break; |
---|
458 | } |
---|
459 | default: |
---|
460 | break; |
---|
461 | } |
---|
462 | |
---|
463 | // non-positive targets |
---|
464 | if(!IsPositiveTarget(spellproto->EffectImplicitTargetA[effIndex],spellproto->EffectImplicitTargetB[effIndex])) |
---|
465 | return false; |
---|
466 | |
---|
467 | // AttributesEx check |
---|
468 | if(spellproto->AttributesEx & (1<<7)) |
---|
469 | return false; |
---|
470 | |
---|
471 | // ok, positive |
---|
472 | return true; |
---|
473 | } |
---|
474 | |
---|
475 | bool IsPositiveSpell(uint32 spellId) |
---|
476 | { |
---|
477 | SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId); |
---|
478 | if (!spellproto) return false; |
---|
479 | |
---|
480 | // spells with atleast one negative effect are considered negative |
---|
481 | // some self-applied spells have negative effects but in self casting case negative check ignored. |
---|
482 | for (int i = 0; i < 3; i++) |
---|
483 | if (!IsPositiveEffect(spellId, i)) |
---|
484 | return false; |
---|
485 | return true; |
---|
486 | } |
---|
487 | |
---|
488 | bool IsSingleTargetSpell(SpellEntry const *spellInfo) |
---|
489 | { |
---|
490 | // all other single target spells have if it has AttributesEx5 |
---|
491 | if ( spellInfo->AttributesEx5 & SPELL_ATTR_EX5_SINGLE_TARGET_SPELL ) |
---|
492 | return true; |
---|
493 | |
---|
494 | // TODO - need found Judgements rule |
---|
495 | switch(GetSpellSpecific(spellInfo->Id)) |
---|
496 | { |
---|
497 | case SPELL_JUDGEMENT: |
---|
498 | return true; |
---|
499 | } |
---|
500 | |
---|
501 | // single target triggered spell. |
---|
502 | // Not real client side single target spell, but it' not triggered until prev. aura expired. |
---|
503 | // This is allow store it in single target spells list for caster for spell proc checking |
---|
504 | if(spellInfo->Id==38324) // Regeneration (triggered by 38299 (HoTs on Heals)) |
---|
505 | return true; |
---|
506 | |
---|
507 | return false; |
---|
508 | } |
---|
509 | |
---|
510 | bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellInfo2) |
---|
511 | { |
---|
512 | // TODO - need better check |
---|
513 | // Equal icon and spellfamily |
---|
514 | if( spellInfo1->SpellFamilyName == spellInfo2->SpellFamilyName && |
---|
515 | spellInfo1->SpellIconID == spellInfo2->SpellIconID ) |
---|
516 | return true; |
---|
517 | |
---|
518 | // TODO - need found Judgements rule |
---|
519 | SpellSpecific spec1 = GetSpellSpecific(spellInfo1->Id); |
---|
520 | // spell with single target specific types |
---|
521 | switch(spec1) |
---|
522 | { |
---|
523 | case SPELL_JUDGEMENT: |
---|
524 | if(GetSpellSpecific(spellInfo2->Id) == spec1) |
---|
525 | return true; |
---|
526 | break; |
---|
527 | } |
---|
528 | |
---|
529 | return false; |
---|
530 | } |
---|
531 | |
---|
532 | uint8 GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form) |
---|
533 | { |
---|
534 | // talents that learn spells can have stance requirements that need ignore |
---|
535 | // (this requirement only for client-side stance show in talent description) |
---|
536 | if( GetTalentSpellCost(spellInfo->Id) > 0 && |
---|
537 | (spellInfo->Effect[0]==SPELL_EFFECT_LEARN_SPELL || spellInfo->Effect[1]==SPELL_EFFECT_LEARN_SPELL || spellInfo->Effect[2]==SPELL_EFFECT_LEARN_SPELL) ) |
---|
538 | return 0; |
---|
539 | |
---|
540 | uint32 stanceMask = (form ? 1 << (form - 1) : 0); |
---|
541 | |
---|
542 | if (stanceMask & spellInfo->StancesNot) // can explicitly not be casted in this stance |
---|
543 | return SPELL_FAILED_NOT_SHAPESHIFT; |
---|
544 | |
---|
545 | if (stanceMask & spellInfo->Stances) // can explicitly be casted in this stance |
---|
546 | return 0; |
---|
547 | |
---|
548 | bool actAsShifted = false; |
---|
549 | if (form > 0) |
---|
550 | { |
---|
551 | SpellShapeshiftEntry const *shapeInfo = sSpellShapeshiftStore.LookupEntry(form); |
---|
552 | if (!shapeInfo) |
---|
553 | { |
---|
554 | sLog.outError("GetErrorAtShapeshiftedCast: unknown shapeshift %u", form); |
---|
555 | return 0; |
---|
556 | } |
---|
557 | actAsShifted = !(shapeInfo->flags1 & 1); // shapeshift acts as normal form for spells |
---|
558 | } |
---|
559 | |
---|
560 | if(actAsShifted) |
---|
561 | { |
---|
562 | if (spellInfo->Attributes & SPELL_ATTR_NOT_SHAPESHIFT) // not while shapeshifted |
---|
563 | return SPELL_FAILED_NOT_SHAPESHIFT; |
---|
564 | else if (spellInfo->Stances != 0) // needs other shapeshift |
---|
565 | return SPELL_FAILED_ONLY_SHAPESHIFT; |
---|
566 | } |
---|
567 | else |
---|
568 | { |
---|
569 | // needs shapeshift |
---|
570 | if(!(spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) && spellInfo->Stances != 0) |
---|
571 | return SPELL_FAILED_ONLY_SHAPESHIFT; |
---|
572 | } |
---|
573 | |
---|
574 | return 0; |
---|
575 | } |
---|
576 | |
---|
577 | void SpellMgr::LoadSpellTargetPositions() |
---|
578 | { |
---|
579 | mSpellTargetPositions.clear(); // need for reload case |
---|
580 | |
---|
581 | uint32 count = 0; |
---|
582 | |
---|
583 | // 0 1 2 3 4 5 |
---|
584 | QueryResult *result = WorldDatabase.Query("SELECT id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM spell_target_position"); |
---|
585 | if( !result ) |
---|
586 | { |
---|
587 | |
---|
588 | barGoLink bar( 1 ); |
---|
589 | |
---|
590 | bar.step(); |
---|
591 | |
---|
592 | sLog.outString(); |
---|
593 | sLog.outString( ">> Loaded %u spell target coordinates", count ); |
---|
594 | return; |
---|
595 | } |
---|
596 | |
---|
597 | barGoLink bar( result->GetRowCount() ); |
---|
598 | |
---|
599 | do |
---|
600 | { |
---|
601 | Field *fields = result->Fetch(); |
---|
602 | |
---|
603 | bar.step(); |
---|
604 | |
---|
605 | ++count; |
---|
606 | |
---|
607 | uint32 Spell_ID = fields[0].GetUInt32(); |
---|
608 | |
---|
609 | SpellTargetPosition st; |
---|
610 | |
---|
611 | st.target_mapId = fields[1].GetUInt32(); |
---|
612 | st.target_X = fields[2].GetFloat(); |
---|
613 | st.target_Y = fields[3].GetFloat(); |
---|
614 | st.target_Z = fields[4].GetFloat(); |
---|
615 | st.target_Orientation = fields[5].GetFloat(); |
---|
616 | |
---|
617 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(Spell_ID); |
---|
618 | if(!spellInfo) |
---|
619 | { |
---|
620 | sLog.outErrorDb("Spell (ID:%u) listed in `spell_target_position` does not exist.",Spell_ID); |
---|
621 | continue; |
---|
622 | } |
---|
623 | |
---|
624 | bool found = false; |
---|
625 | for(int i = 0; i < 3; ++i) |
---|
626 | { |
---|
627 | if( spellInfo->EffectImplicitTargetA[i]==TARGET_TABLE_X_Y_Z_COORDINATES || spellInfo->EffectImplicitTargetB[i]==TARGET_TABLE_X_Y_Z_COORDINATES ) |
---|
628 | { |
---|
629 | found = true; |
---|
630 | break; |
---|
631 | } |
---|
632 | } |
---|
633 | if(!found) |
---|
634 | { |
---|
635 | sLog.outErrorDb("Spell (Id: %u) listed in `spell_target_position` does not have target TARGET_TABLE_X_Y_Z_COORDINATES (17).",Spell_ID); |
---|
636 | continue; |
---|
637 | } |
---|
638 | |
---|
639 | MapEntry const* mapEntry = sMapStore.LookupEntry(st.target_mapId); |
---|
640 | if(!mapEntry) |
---|
641 | { |
---|
642 | sLog.outErrorDb("Spell (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Spell_ID,st.target_mapId); |
---|
643 | continue; |
---|
644 | } |
---|
645 | |
---|
646 | if(st.target_X==0 && st.target_Y==0 && st.target_Z==0) |
---|
647 | { |
---|
648 | sLog.outErrorDb("Spell (ID:%u) target coordinates not provided.",Spell_ID); |
---|
649 | continue; |
---|
650 | } |
---|
651 | |
---|
652 | mSpellTargetPositions[Spell_ID] = st; |
---|
653 | |
---|
654 | } while( result->NextRow() ); |
---|
655 | |
---|
656 | delete result; |
---|
657 | |
---|
658 | sLog.outString(); |
---|
659 | sLog.outString( ">> Loaded %u spell teleport coordinates", count ); |
---|
660 | } |
---|
661 | |
---|
662 | void SpellMgr::LoadSpellAffects() |
---|
663 | { |
---|
664 | mSpellAffectMap.clear(); // need for reload case |
---|
665 | |
---|
666 | uint32 count = 0; |
---|
667 | |
---|
668 | // 0 1 2 |
---|
669 | QueryResult *result = WorldDatabase.Query("SELECT entry, effectId, SpellFamilyMask FROM spell_affect"); |
---|
670 | if( !result ) |
---|
671 | { |
---|
672 | |
---|
673 | barGoLink bar( 1 ); |
---|
674 | |
---|
675 | bar.step(); |
---|
676 | |
---|
677 | sLog.outString(); |
---|
678 | sLog.outString( ">> Loaded %u spell affect definitions", count ); |
---|
679 | return; |
---|
680 | } |
---|
681 | |
---|
682 | barGoLink bar( result->GetRowCount() ); |
---|
683 | |
---|
684 | do |
---|
685 | { |
---|
686 | Field *fields = result->Fetch(); |
---|
687 | |
---|
688 | bar.step(); |
---|
689 | |
---|
690 | uint16 entry = fields[0].GetUInt16(); |
---|
691 | uint8 effectId = fields[1].GetUInt8(); |
---|
692 | |
---|
693 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(entry); |
---|
694 | |
---|
695 | if (!spellInfo) |
---|
696 | { |
---|
697 | sLog.outErrorDb("Spell %u listed in `spell_affect` does not exist", entry); |
---|
698 | continue; |
---|
699 | } |
---|
700 | |
---|
701 | if (effectId >= 3) |
---|
702 | { |
---|
703 | sLog.outErrorDb("Spell %u listed in `spell_affect` have invalid effect index (%u)", entry,effectId); |
---|
704 | continue; |
---|
705 | } |
---|
706 | |
---|
707 | if( spellInfo->Effect[effectId] != SPELL_EFFECT_APPLY_AURA || |
---|
708 | spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_FLAT_MODIFIER && |
---|
709 | spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_PCT_MODIFIER && |
---|
710 | spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_TARGET_TRIGGER ) |
---|
711 | { |
---|
712 | sLog.outErrorDb("Spell %u listed in `spell_affect` have not SPELL_AURA_ADD_FLAT_MODIFIER (%u) or SPELL_AURA_ADD_PCT_MODIFIER (%u) or SPELL_AURA_ADD_TARGET_TRIGGER (%u) for effect index (%u)", entry,SPELL_AURA_ADD_FLAT_MODIFIER,SPELL_AURA_ADD_PCT_MODIFIER,SPELL_AURA_ADD_TARGET_TRIGGER,effectId); |
---|
713 | continue; |
---|
714 | } |
---|
715 | |
---|
716 | uint64 spellAffectMask = fields[2].GetUInt64(); |
---|
717 | |
---|
718 | // Spell.dbc have own data for low part of SpellFamilyMask |
---|
719 | if( spellInfo->EffectItemType[effectId]) |
---|
720 | { |
---|
721 | if(spellInfo->EffectItemType[effectId] == spellAffectMask) |
---|
722 | { |
---|
723 | sLog.outErrorDb("Spell %u listed in `spell_affect` have redundant (same with EffectItemType%d) data for effect index (%u) and not needed, skipped.", entry,effectId+1,effectId); |
---|
724 | continue; |
---|
725 | } |
---|
726 | |
---|
727 | // 24429 have wrong data in EffectItemType and overwrites by DB, possible bug in client |
---|
728 | if(spellInfo->Id!=24429 && spellInfo->EffectItemType[effectId] != spellAffectMask) |
---|
729 | { |
---|
730 | sLog.outErrorDb("Spell %u listed in `spell_affect` have different low part from EffectItemType%d for effect index (%u) and not needed, skipped.", entry,effectId+1,effectId); |
---|
731 | continue; |
---|
732 | } |
---|
733 | } |
---|
734 | |
---|
735 | mSpellAffectMap.insert(SpellAffectMap::value_type((entry<<8) + effectId,spellAffectMask)); |
---|
736 | |
---|
737 | ++count; |
---|
738 | } while( result->NextRow() ); |
---|
739 | |
---|
740 | delete result; |
---|
741 | |
---|
742 | sLog.outString(); |
---|
743 | sLog.outString( ">> Loaded %u spell affect definitions", count ); |
---|
744 | |
---|
745 | for (uint32 id = 0; id < sSpellStore.GetNumRows(); ++id) |
---|
746 | { |
---|
747 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(id); |
---|
748 | if (!spellInfo) |
---|
749 | continue; |
---|
750 | |
---|
751 | for (int effectId = 0; effectId < 3; ++effectId) |
---|
752 | { |
---|
753 | if( spellInfo->Effect[effectId] != SPELL_EFFECT_APPLY_AURA || |
---|
754 | (spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_FLAT_MODIFIER && |
---|
755 | spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_PCT_MODIFIER && |
---|
756 | spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_TARGET_TRIGGER) ) |
---|
757 | continue; |
---|
758 | |
---|
759 | if(spellInfo->EffectItemType[effectId] != 0) |
---|
760 | continue; |
---|
761 | |
---|
762 | if(mSpellAffectMap.find((id<<8) + effectId) != mSpellAffectMap.end()) |
---|
763 | continue; |
---|
764 | |
---|
765 | sLog.outErrorDb("Spell %u (%s) misses spell_affect for effect %u",id,spellInfo->SpellName[sWorld.GetDefaultDbcLocale()], effectId); |
---|
766 | } |
---|
767 | } |
---|
768 | } |
---|
769 | |
---|
770 | bool SpellMgr::IsAffectedBySpell(SpellEntry const *spellInfo, uint32 spellId, uint8 effectId, uint64 familyFlags) const |
---|
771 | { |
---|
772 | // false for spellInfo == NULL |
---|
773 | if (!spellInfo) |
---|
774 | return false; |
---|
775 | |
---|
776 | SpellEntry const *affect_spell = sSpellStore.LookupEntry(spellId); |
---|
777 | // false for affect_spell == NULL |
---|
778 | if (!affect_spell) |
---|
779 | return false; |
---|
780 | |
---|
781 | // False if spellFamily not equal |
---|
782 | if (affect_spell->SpellFamilyName != spellInfo->SpellFamilyName) |
---|
783 | return false; |
---|
784 | |
---|
785 | // If familyFlags == 0 |
---|
786 | if (!familyFlags) |
---|
787 | { |
---|
788 | // Get it from spellAffect table |
---|
789 | familyFlags = GetSpellAffectMask(spellId,effectId); |
---|
790 | // false if familyFlags == 0 |
---|
791 | if (!familyFlags) |
---|
792 | return false; |
---|
793 | } |
---|
794 | |
---|
795 | // true |
---|
796 | if (familyFlags & spellInfo->SpellFamilyFlags) |
---|
797 | return true; |
---|
798 | |
---|
799 | return false; |
---|
800 | } |
---|
801 | |
---|
802 | void SpellMgr::LoadSpellProcEvents() |
---|
803 | { |
---|
804 | mSpellProcEventMap.clear(); // need for reload case |
---|
805 | |
---|
806 | uint32 count = 0; |
---|
807 | |
---|
808 | // 0 1 2 3 4 5 6 7 8 |
---|
809 | QueryResult *result = WorldDatabase.Query("SELECT entry, SchoolMask, Category, SkillID, SpellFamilyName, SpellFamilyMask, procFlags, ppmRate, cooldown FROM spell_proc_event"); |
---|
810 | if( !result ) |
---|
811 | { |
---|
812 | |
---|
813 | barGoLink bar( 1 ); |
---|
814 | |
---|
815 | bar.step(); |
---|
816 | |
---|
817 | sLog.outString(); |
---|
818 | sLog.outString( ">> Loaded %u spell proc event conditions", count ); |
---|
819 | return; |
---|
820 | } |
---|
821 | |
---|
822 | barGoLink bar( result->GetRowCount() ); |
---|
823 | |
---|
824 | do |
---|
825 | { |
---|
826 | Field *fields = result->Fetch(); |
---|
827 | |
---|
828 | bar.step(); |
---|
829 | |
---|
830 | uint16 entry = fields[0].GetUInt16(); |
---|
831 | |
---|
832 | if (!sSpellStore.LookupEntry(entry)) |
---|
833 | { |
---|
834 | sLog.outErrorDb("Spell %u listed in `spell_proc_event` does not exist", entry); |
---|
835 | continue; |
---|
836 | } |
---|
837 | |
---|
838 | SpellProcEventEntry spe; |
---|
839 | |
---|
840 | spe.schoolMask = fields[1].GetUInt32(); |
---|
841 | spe.category = fields[2].GetUInt32(); |
---|
842 | spe.skillId = fields[3].GetUInt32(); |
---|
843 | spe.spellFamilyName = fields[4].GetUInt32(); |
---|
844 | spe.spellFamilyMask = fields[5].GetUInt64(); |
---|
845 | spe.procFlags = fields[6].GetUInt32(); |
---|
846 | spe.ppmRate = fields[7].GetFloat(); |
---|
847 | spe.cooldown = fields[8].GetUInt32(); |
---|
848 | |
---|
849 | mSpellProcEventMap[entry] = spe; |
---|
850 | |
---|
851 | ++count; |
---|
852 | } while( result->NextRow() ); |
---|
853 | |
---|
854 | delete result; |
---|
855 | |
---|
856 | sLog.outString(); |
---|
857 | sLog.outString( ">> Loaded %u spell proc event conditions", count ); |
---|
858 | |
---|
859 | /* |
---|
860 | // Commented for now, as it still produces many errors (still quite many spells miss spell_proc_event) |
---|
861 | for (uint32 id = 0; id < sSpellStore.GetNumRows(); ++id) |
---|
862 | { |
---|
863 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(id); |
---|
864 | if (!spellInfo) |
---|
865 | continue; |
---|
866 | |
---|
867 | bool found = false; |
---|
868 | for (int effectId = 0; effectId < 3; ++effectId) |
---|
869 | { |
---|
870 | // at this moment check only SPELL_AURA_PROC_TRIGGER_SPELL |
---|
871 | if( spellInfo->EffectApplyAuraName[effectId] == SPELL_AURA_PROC_TRIGGER_SPELL ) |
---|
872 | { |
---|
873 | found = true; |
---|
874 | break; |
---|
875 | } |
---|
876 | } |
---|
877 | |
---|
878 | if(!found) |
---|
879 | continue; |
---|
880 | |
---|
881 | if(GetSpellProcEvent(id)) |
---|
882 | continue; |
---|
883 | |
---|
884 | sLog.outErrorDb("Spell %u (%s) misses spell_proc_event",id,spellInfo->SpellName[sWorld.GetDBClang()]); |
---|
885 | } |
---|
886 | */ |
---|
887 | } |
---|
888 | |
---|
889 | bool SpellMgr::IsSpellProcEventCanTriggeredBy( SpellProcEventEntry const * spellProcEvent, SpellEntry const * procSpell, uint32 procFlags ) |
---|
890 | { |
---|
891 | if((procFlags & spellProcEvent->procFlags) == 0) |
---|
892 | return false; |
---|
893 | |
---|
894 | // Additional checks in case spell cast/hit/crit is the event |
---|
895 | // Check (if set) school, category, skill line, spell talent mask |
---|
896 | if(spellProcEvent->schoolMask && (!procSpell || (GetSpellSchoolMask(procSpell) & spellProcEvent->schoolMask) == 0)) |
---|
897 | return false; |
---|
898 | if(spellProcEvent->category && (!procSpell || procSpell->Category != spellProcEvent->category)) |
---|
899 | return false; |
---|
900 | if(spellProcEvent->skillId) |
---|
901 | { |
---|
902 | if (!procSpell) |
---|
903 | return false; |
---|
904 | |
---|
905 | SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(procSpell->Id); |
---|
906 | SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(procSpell->Id); |
---|
907 | |
---|
908 | bool found = false; |
---|
909 | for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) |
---|
910 | { |
---|
911 | if(_spell_idx->second->skillId == spellProcEvent->skillId) |
---|
912 | { |
---|
913 | found = true; |
---|
914 | break; |
---|
915 | } |
---|
916 | } |
---|
917 | if (!found) |
---|
918 | return false; |
---|
919 | } |
---|
920 | if(spellProcEvent->spellFamilyName && (!procSpell || spellProcEvent->spellFamilyName != procSpell->SpellFamilyName)) |
---|
921 | return false; |
---|
922 | if(spellProcEvent->spellFamilyMask && (!procSpell || (spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags) == 0)) |
---|
923 | return false; |
---|
924 | |
---|
925 | return true; |
---|
926 | } |
---|
927 | |
---|
928 | void SpellMgr::LoadSpellElixirs() |
---|
929 | { |
---|
930 | mSpellElixirs.clear(); // need for reload case |
---|
931 | |
---|
932 | uint32 count = 0; |
---|
933 | |
---|
934 | // 0 1 |
---|
935 | QueryResult *result = WorldDatabase.Query("SELECT entry, mask FROM spell_elixir"); |
---|
936 | if( !result ) |
---|
937 | { |
---|
938 | |
---|
939 | barGoLink bar( 1 ); |
---|
940 | |
---|
941 | bar.step(); |
---|
942 | |
---|
943 | sLog.outString(); |
---|
944 | sLog.outString( ">> Loaded %u spell elixir definitions", count ); |
---|
945 | return; |
---|
946 | } |
---|
947 | |
---|
948 | barGoLink bar( result->GetRowCount() ); |
---|
949 | |
---|
950 | do |
---|
951 | { |
---|
952 | Field *fields = result->Fetch(); |
---|
953 | |
---|
954 | bar.step(); |
---|
955 | |
---|
956 | uint16 entry = fields[0].GetUInt16(); |
---|
957 | uint8 mask = fields[1].GetUInt8(); |
---|
958 | |
---|
959 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(entry); |
---|
960 | |
---|
961 | if (!spellInfo) |
---|
962 | { |
---|
963 | sLog.outErrorDb("Spell %u listed in `spell_elixir` does not exist", entry); |
---|
964 | continue; |
---|
965 | } |
---|
966 | |
---|
967 | mSpellElixirs[entry] = mask; |
---|
968 | |
---|
969 | ++count; |
---|
970 | } while( result->NextRow() ); |
---|
971 | |
---|
972 | delete result; |
---|
973 | |
---|
974 | sLog.outString(); |
---|
975 | sLog.outString( ">> Loaded %u spell elixir definitions", count ); |
---|
976 | } |
---|
977 | |
---|
978 | void SpellMgr::LoadSpellThreats() |
---|
979 | { |
---|
980 | sSpellThreatStore.Free(); // for reload |
---|
981 | |
---|
982 | sSpellThreatStore.Load(); |
---|
983 | |
---|
984 | sLog.outString( ">> Loaded %u aggro generating spells", sSpellThreatStore.RecordCount ); |
---|
985 | sLog.outString(); |
---|
986 | } |
---|
987 | |
---|
988 | bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const |
---|
989 | { |
---|
990 | SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); |
---|
991 | if(!spellInfo_1 || !spellInfo_2) return false; |
---|
992 | if(spellInfo_1->Id == spellId_2) return false; |
---|
993 | |
---|
994 | return GetFirstSpellInChain(spellInfo_1->Id)==GetFirstSpellInChain(spellId_2); |
---|
995 | } |
---|
996 | |
---|
997 | bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo) |
---|
998 | { |
---|
999 | if(spellInfo->powerType != POWER_MANA && spellInfo->powerType != POWER_HEALTH) |
---|
1000 | return false; |
---|
1001 | if(IsProfessionSpell(spellInfo->Id)) |
---|
1002 | return false; |
---|
1003 | |
---|
1004 | // All stance spells. if any better way, change it. |
---|
1005 | for (int i = 0; i < 3; i++) |
---|
1006 | { |
---|
1007 | // Paladin aura Spell |
---|
1008 | if(spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN |
---|
1009 | && spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AREA_AURA_PARTY) |
---|
1010 | return false; |
---|
1011 | // Druid form Spell |
---|
1012 | if(spellInfo->SpellFamilyName == SPELLFAMILY_DRUID |
---|
1013 | && spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AURA |
---|
1014 | && spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT) |
---|
1015 | return false; |
---|
1016 | // Rogue Stealth |
---|
1017 | if(spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE |
---|
1018 | && spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AURA |
---|
1019 | && spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT) |
---|
1020 | return false; |
---|
1021 | } |
---|
1022 | return true; |
---|
1023 | } |
---|
1024 | |
---|
1025 | bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const |
---|
1026 | { |
---|
1027 | SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); |
---|
1028 | SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); |
---|
1029 | |
---|
1030 | if(!spellInfo_1 || !spellInfo_2) |
---|
1031 | return false; |
---|
1032 | |
---|
1033 | if(spellInfo_1->Id == spellId_2) |
---|
1034 | return false; |
---|
1035 | |
---|
1036 | //I think we don't check this correctly because i need a exception for spell: |
---|
1037 | //72,11327,18461...(called from 1856,1857...) Call Aura 16,31, after trigger another spell who call aura 77 and 77 remove 16 and 31, this should not happen. |
---|
1038 | if(spellInfo_2->SpellFamilyFlags == 2048) |
---|
1039 | return false; |
---|
1040 | |
---|
1041 | // Resurrection sickness |
---|
1042 | if((spellInfo_1->Id == SPELL_ID_PASSIVE_RESURRECTION_SICKNESS) != (spellInfo_2->Id==SPELL_ID_PASSIVE_RESURRECTION_SICKNESS)) |
---|
1043 | return false; |
---|
1044 | |
---|
1045 | // Specific spell family spells |
---|
1046 | switch(spellInfo_1->SpellFamilyName) |
---|
1047 | { |
---|
1048 | case SPELLFAMILY_GENERIC: |
---|
1049 | switch(spellInfo_2->SpellFamilyName) |
---|
1050 | { |
---|
1051 | case SPELLFAMILY_GENERIC: // same family case |
---|
1052 | { |
---|
1053 | // Thunderfury |
---|
1054 | if( spellInfo_1->Id == 21992 && spellInfo_2->Id == 27648 || spellInfo_2->Id == 21992 && spellInfo_1->Id == 27648 ) |
---|
1055 | return false; |
---|
1056 | |
---|
1057 | // Lightning Speed (Mongoose) and Fury of the Crashing Waves (Tsunami Talisman) |
---|
1058 | if( spellInfo_1->Id == 28093 && spellInfo_2->Id == 42084 || |
---|
1059 | spellInfo_2->Id == 28093 && spellInfo_1->Id == 42084 ) |
---|
1060 | return false; |
---|
1061 | |
---|
1062 | // Soulstone Resurrection and Twisting Nether (resurrector) |
---|
1063 | if( spellInfo_1->SpellIconID == 92 && spellInfo_2->SpellIconID == 92 && ( |
---|
1064 | spellInfo_1->SpellVisual == 99 && spellInfo_2->SpellVisual == 0 || |
---|
1065 | spellInfo_2->SpellVisual == 99 && spellInfo_1->SpellVisual == 0 ) ) |
---|
1066 | return false; |
---|
1067 | |
---|
1068 | // Heart of the Wild and (Primal Instinct (Idol of Terror) triggering spell or Agility) |
---|
1069 | if( spellInfo_1->SpellIconID == 240 && spellInfo_2->SpellIconID == 240 && ( |
---|
1070 | spellInfo_1->SpellVisual == 0 && spellInfo_2->SpellVisual == 78 || |
---|
1071 | spellInfo_2->SpellVisual == 0 && spellInfo_1->SpellVisual == 78 ) ) |
---|
1072 | return false; |
---|
1073 | |
---|
1074 | // Personalized Weather (thunder effect should overwrite rainy aura) |
---|
1075 | if(spellInfo_1->SpellIconID == 2606 && spellInfo_2->SpellIconID == 2606) |
---|
1076 | return false; |
---|
1077 | |
---|
1078 | // Brood Affliction: Bronze |
---|
1079 | if( (spellInfo_1->Id == 23170 && spellInfo_2->Id == 23171) || |
---|
1080 | (spellInfo_2->Id == 23170 && spellInfo_1->Id == 23171) ) |
---|
1081 | return false; |
---|
1082 | |
---|
1083 | break; |
---|
1084 | } |
---|
1085 | case SPELLFAMILY_WARRIOR: |
---|
1086 | { |
---|
1087 | // Scroll of Protection and Defensive Stance (multi-family check) |
---|
1088 | if( spellInfo_1->SpellIconID == 276 && spellInfo_1->SpellVisual == 196 && spellInfo_2->Id == 71) |
---|
1089 | return false; |
---|
1090 | |
---|
1091 | // Improved Hamstring -> Hamstring (multi-family check) |
---|
1092 | if( (spellInfo_2->SpellFamilyFlags & 2) && spellInfo_1->Id == 23694 ) |
---|
1093 | return false; |
---|
1094 | |
---|
1095 | break; |
---|
1096 | } |
---|
1097 | case SPELLFAMILY_DRUID: |
---|
1098 | { |
---|
1099 | // Scroll of Stamina and Leader of the Pack (multi-family check) |
---|
1100 | if( spellInfo_1->SpellIconID == 312 && spellInfo_1->SpellVisual == 216 && spellInfo_2->Id == 24932 ) |
---|
1101 | return false; |
---|
1102 | |
---|
1103 | // Dragonmaw Illusion (multi-family check) |
---|
1104 | if (spellId_1 == 40216 && spellId_2 == 42016 ) |
---|
1105 | return false; |
---|
1106 | |
---|
1107 | break; |
---|
1108 | } |
---|
1109 | case SPELLFAMILY_ROGUE: |
---|
1110 | { |
---|
1111 | // Garrote-Silence -> Garrote (multi-family check) |
---|
1112 | if( spellInfo_1->SpellIconID == 498 && spellInfo_1->SpellVisual == 0 && spellInfo_2->SpellIconID == 498 ) |
---|
1113 | return false; |
---|
1114 | |
---|
1115 | break; |
---|
1116 | } |
---|
1117 | case SPELLFAMILY_HUNTER: |
---|
1118 | { |
---|
1119 | // Concussive Shot and Imp. Concussive Shot (multi-family check) |
---|
1120 | if( spellInfo_1->Id == 19410 && spellInfo_2->Id == 5116 ) |
---|
1121 | return false; |
---|
1122 | |
---|
1123 | // Improved Wing Clip -> Wing Clip (multi-family check) |
---|
1124 | if( (spellInfo_2->SpellFamilyFlags & 0x40) && spellInfo_1->Id == 19229 ) |
---|
1125 | return false; |
---|
1126 | break; |
---|
1127 | } |
---|
1128 | case SPELLFAMILY_PALADIN: |
---|
1129 | { |
---|
1130 | // Unstable Currents and other -> *Sanctity Aura (multi-family check) |
---|
1131 | if( spellInfo_2->SpellIconID==502 && spellInfo_1->SpellIconID==502 && spellInfo_1->SpellVisual==969 ) |
---|
1132 | return false; |
---|
1133 | |
---|
1134 | // *Band of Eternal Champion and Seal of Command(multi-family check) |
---|
1135 | if( spellId_1 == 35081 && spellInfo_2->SpellIconID==561 && spellInfo_2->SpellVisual==7992) |
---|
1136 | return false; |
---|
1137 | |
---|
1138 | break; |
---|
1139 | } |
---|
1140 | } |
---|
1141 | break; |
---|
1142 | case SPELLFAMILY_MAGE: |
---|
1143 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_MAGE ) |
---|
1144 | { |
---|
1145 | // Blizzard & Chilled (and some other stacked with blizzard spells |
---|
1146 | if( (spellInfo_1->SpellFamilyFlags & 0x80) && (spellInfo_2->SpellFamilyFlags & 0x100000) || |
---|
1147 | (spellInfo_2->SpellFamilyFlags & 0x80) && (spellInfo_1->SpellFamilyFlags & 0x100000) ) |
---|
1148 | return false; |
---|
1149 | |
---|
1150 | // Blink & Improved Blink |
---|
1151 | if( (spellInfo_1->SpellFamilyFlags & 0x0000000000010000LL) && (spellInfo_2->SpellVisual == 72 && spellInfo_2->SpellIconID == 1499) || |
---|
1152 | (spellInfo_2->SpellFamilyFlags & 0x0000000000010000LL) && (spellInfo_1->SpellVisual == 72 && spellInfo_1->SpellIconID == 1499) ) |
---|
1153 | return false; |
---|
1154 | } |
---|
1155 | // Detect Invisibility and Mana Shield (multi-family check) |
---|
1156 | if( spellInfo_2->Id == 132 && spellInfo_1->SpellIconID == 209 && spellInfo_1->SpellVisual == 968 ) |
---|
1157 | return false; |
---|
1158 | |
---|
1159 | // Combustion and Fire Protection Aura (multi-family check) |
---|
1160 | if( spellInfo_1->Id == 11129 && spellInfo_2->SpellIconID == 33 && spellInfo_2->SpellVisual == 321 ) |
---|
1161 | return false; |
---|
1162 | |
---|
1163 | break; |
---|
1164 | case SPELLFAMILY_WARLOCK: |
---|
1165 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_WARLOCK ) |
---|
1166 | { |
---|
1167 | // Siphon Life and Drain Life |
---|
1168 | if( spellInfo_1->SpellIconID == 152 && spellInfo_2->SpellIconID == 546 || |
---|
1169 | spellInfo_2->SpellIconID == 152 && spellInfo_1->SpellIconID == 546 ) |
---|
1170 | return false; |
---|
1171 | |
---|
1172 | //Corruption & Seed of corruption |
---|
1173 | if( spellInfo_1->SpellIconID == 313 && spellInfo_2->SpellIconID == 1932 || |
---|
1174 | spellInfo_2->SpellIconID == 313 && spellInfo_1->SpellIconID == 1932 ) |
---|
1175 | if(spellInfo_1->SpellVisual != 0 && spellInfo_2->SpellVisual != 0) |
---|
1176 | return true; // can't be stacked |
---|
1177 | |
---|
1178 | // Corruption and Unstable Affliction |
---|
1179 | if( spellInfo_1->SpellIconID == 313 && spellInfo_2->SpellIconID == 2039 || |
---|
1180 | spellInfo_2->SpellIconID == 313 && spellInfo_1->SpellIconID == 2039 ) |
---|
1181 | return false; |
---|
1182 | |
---|
1183 | // (Corruption or Unstable Affliction) and (Curse of Agony or Curse of Doom) |
---|
1184 | if( (spellInfo_1->SpellIconID == 313 || spellInfo_1->SpellIconID == 2039) && (spellInfo_2->SpellIconID == 544 || spellInfo_2->SpellIconID == 91) || |
---|
1185 | (spellInfo_2->SpellIconID == 313 || spellInfo_2->SpellIconID == 2039) && (spellInfo_1->SpellIconID == 544 || spellInfo_1->SpellIconID == 91) ) |
---|
1186 | return false; |
---|
1187 | } |
---|
1188 | // Detect Invisibility and Mana Shield (multi-family check) |
---|
1189 | if( spellInfo_1->Id == 132 && spellInfo_2->SpellIconID == 209 && spellInfo_2->SpellVisual == 968 ) |
---|
1190 | return false; |
---|
1191 | break; |
---|
1192 | case SPELLFAMILY_WARRIOR: |
---|
1193 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_WARRIOR ) |
---|
1194 | { |
---|
1195 | // Rend and Deep Wound |
---|
1196 | if( (spellInfo_1->SpellFamilyFlags & 0x20) && (spellInfo_2->SpellFamilyFlags & 0x1000000000LL) || |
---|
1197 | (spellInfo_2->SpellFamilyFlags & 0x20) && (spellInfo_1->SpellFamilyFlags & 0x1000000000LL) ) |
---|
1198 | return false; |
---|
1199 | |
---|
1200 | // Battle Shout and Rampage |
---|
1201 | if( (spellInfo_1->SpellIconID == 456 && spellInfo_2->SpellIconID == 2006) || |
---|
1202 | (spellInfo_2->SpellIconID == 456 && spellInfo_1->SpellIconID == 2006) ) |
---|
1203 | return false; |
---|
1204 | } |
---|
1205 | |
---|
1206 | // Hamstring -> Improved Hamstring (multi-family check) |
---|
1207 | if( (spellInfo_1->SpellFamilyFlags & 2) && spellInfo_2->Id == 23694 ) |
---|
1208 | return false; |
---|
1209 | |
---|
1210 | // Defensive Stance and Scroll of Protection (multi-family check) |
---|
1211 | if( spellInfo_1->Id == 71 && spellInfo_2->SpellIconID == 276 && spellInfo_2->SpellVisual == 196 ) |
---|
1212 | return false; |
---|
1213 | |
---|
1214 | // Bloodlust and Bloodthirst (multi-family check) |
---|
1215 | if( spellInfo_2->Id == 2825 && spellInfo_1->SpellIconID == 38 && spellInfo_1->SpellVisual == 0 ) |
---|
1216 | return false; |
---|
1217 | |
---|
1218 | break; |
---|
1219 | case SPELLFAMILY_PRIEST: |
---|
1220 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_PRIEST ) |
---|
1221 | { |
---|
1222 | //Devouring Plague and Shadow Vulnerability |
---|
1223 | if( (spellInfo_1->SpellFamilyFlags & 0x2000000) && (spellInfo_2->SpellFamilyFlags & 0x800000000LL) || |
---|
1224 | (spellInfo_2->SpellFamilyFlags & 0x2000000) && (spellInfo_1->SpellFamilyFlags & 0x800000000LL) ) |
---|
1225 | return false; |
---|
1226 | |
---|
1227 | //StarShards and Shadow Word: Pain |
---|
1228 | if( (spellInfo_1->SpellFamilyFlags & 0x200000) && (spellInfo_2->SpellFamilyFlags & 0x8000) || |
---|
1229 | (spellInfo_2->SpellFamilyFlags & 0x200000) && (spellInfo_1->SpellFamilyFlags & 0x8000) ) |
---|
1230 | return false; |
---|
1231 | } |
---|
1232 | break; |
---|
1233 | case SPELLFAMILY_DRUID: |
---|
1234 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_DRUID ) |
---|
1235 | { |
---|
1236 | //Omen of Clarity and Blood Frenzy |
---|
1237 | if( (spellInfo_1->SpellFamilyFlags == 0x0 && spellInfo_1->SpellIconID == 108) && (spellInfo_2->SpellFamilyFlags & 0x20000000000000LL) || |
---|
1238 | (spellInfo_2->SpellFamilyFlags == 0x0 && spellInfo_2->SpellIconID == 108) && (spellInfo_1->SpellFamilyFlags & 0x20000000000000LL) ) |
---|
1239 | return false; |
---|
1240 | |
---|
1241 | // Tree of Life (Shapeshift) and 34123 Tree of Life (Passive) |
---|
1242 | if ((spellId_1 == 33891 && spellId_2 == 34123) || |
---|
1243 | (spellId_2 == 33891 && spellId_1 == 34123)) |
---|
1244 | return false; |
---|
1245 | |
---|
1246 | // Wrath of Elune and Nature's Grace |
---|
1247 | if( spellInfo_1->Id == 16886 && spellInfo_2->Id == 46833 || spellInfo_2->Id == 16886 && spellInfo_1->Id == 46833 ) |
---|
1248 | return false; |
---|
1249 | |
---|
1250 | // Bear Rage (Feral T4 (2)) and Omen of Clarity |
---|
1251 | if( spellInfo_1->Id == 16864 && spellInfo_2->Id == 37306 || spellInfo_2->Id == 16864 && spellInfo_1->Id == 37306 ) |
---|
1252 | return false; |
---|
1253 | |
---|
1254 | // Cat Energy (Feral T4 (2)) and Omen of Clarity |
---|
1255 | if( spellInfo_1->Id == 16864 && spellInfo_2->Id == 37311 || spellInfo_2->Id == 16864 && spellInfo_1->Id == 37311 ) |
---|
1256 | return false; |
---|
1257 | } |
---|
1258 | |
---|
1259 | // Leader of the Pack and Scroll of Stamina (multi-family check) |
---|
1260 | if( spellInfo_1->Id == 24932 && spellInfo_2->SpellIconID == 312 && spellInfo_2->SpellVisual == 216 ) |
---|
1261 | return false; |
---|
1262 | |
---|
1263 | // Dragonmaw Illusion (multi-family check) |
---|
1264 | if (spellId_1 == 42016 && spellId_2 == 40216 ) |
---|
1265 | return false; |
---|
1266 | |
---|
1267 | break; |
---|
1268 | case SPELLFAMILY_ROGUE: |
---|
1269 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_ROGUE ) |
---|
1270 | { |
---|
1271 | // Master of Subtlety |
---|
1272 | if (spellId_1 == 31665 && spellId_2 == 31666 || spellId_1 == 31666 && spellId_2 == 31665 ) |
---|
1273 | return false; |
---|
1274 | } |
---|
1275 | |
---|
1276 | // Garrote -> Garrote-Silence (multi-family check) |
---|
1277 | if( spellInfo_1->SpellIconID == 498 && spellInfo_2->SpellIconID == 498 && spellInfo_2->SpellVisual == 0 ) |
---|
1278 | return false; |
---|
1279 | break; |
---|
1280 | case SPELLFAMILY_HUNTER: |
---|
1281 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_HUNTER ) |
---|
1282 | { |
---|
1283 | // Rapid Fire & Quick Shots |
---|
1284 | if( (spellInfo_1->SpellFamilyFlags & 0x20) && (spellInfo_2->SpellFamilyFlags & 0x20000000000LL) || |
---|
1285 | (spellInfo_2->SpellFamilyFlags & 0x20) && (spellInfo_1->SpellFamilyFlags & 0x20000000000LL) ) |
---|
1286 | return false; |
---|
1287 | |
---|
1288 | // Serpent Sting & (Immolation/Explosive Trap Effect) |
---|
1289 | if( (spellInfo_1->SpellFamilyFlags & 0x4) && (spellInfo_2->SpellFamilyFlags & 0x00000004000LL) || |
---|
1290 | (spellInfo_2->SpellFamilyFlags & 0x4) && (spellInfo_1->SpellFamilyFlags & 0x00000004000LL) ) |
---|
1291 | return false; |
---|
1292 | |
---|
1293 | // Bestial Wrath |
---|
1294 | if( spellInfo_1->SpellIconID == 1680 && spellInfo_2->SpellIconID == 1680 ) |
---|
1295 | return false; |
---|
1296 | } |
---|
1297 | |
---|
1298 | // Wing Clip -> Improved Wing Clip (multi-family check) |
---|
1299 | if( (spellInfo_1->SpellFamilyFlags & 0x40) && spellInfo_2->Id == 19229 ) |
---|
1300 | return false; |
---|
1301 | |
---|
1302 | // Concussive Shot and Imp. Concussive Shot (multi-family check) |
---|
1303 | if( spellInfo_2->Id == 19410 && spellInfo_1->Id == 5116 ) |
---|
1304 | return false; |
---|
1305 | break; |
---|
1306 | case SPELLFAMILY_PALADIN: |
---|
1307 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_PALADIN ) |
---|
1308 | { |
---|
1309 | // Paladin Seals |
---|
1310 | if( IsSealSpell(spellInfo_1) && IsSealSpell(spellInfo_2) ) |
---|
1311 | return true; |
---|
1312 | } |
---|
1313 | // Combustion and Fire Protection Aura (multi-family check) |
---|
1314 | if( spellInfo_2->Id == 11129 && spellInfo_1->SpellIconID == 33 && spellInfo_1->SpellVisual == 321 ) |
---|
1315 | return false; |
---|
1316 | |
---|
1317 | // *Sanctity Aura -> Unstable Currents and other (multi-family check) |
---|
1318 | if( spellInfo_1->SpellIconID==502 && spellInfo_2->SpellFamilyName == SPELLFAMILY_GENERIC && spellInfo_2->SpellIconID==502 && spellInfo_2->SpellVisual==969 ) |
---|
1319 | return false; |
---|
1320 | |
---|
1321 | // *Seal of Command and Band of Eternal Champion (multi-family check) |
---|
1322 | if( spellInfo_1->SpellIconID==561 && spellInfo_1->SpellVisual==7992 && spellId_2 == 35081) |
---|
1323 | return false; |
---|
1324 | break; |
---|
1325 | case SPELLFAMILY_SHAMAN: |
---|
1326 | if( spellInfo_2->SpellFamilyName == SPELLFAMILY_SHAMAN ) |
---|
1327 | { |
---|
1328 | // shaman shields |
---|
1329 | if( IsElementalShield(spellInfo_1) && IsElementalShield(spellInfo_2) ) |
---|
1330 | return true; |
---|
1331 | |
---|
1332 | // Windfury weapon |
---|
1333 | if( spellInfo_1->SpellIconID==220 && spellInfo_2->SpellIconID==220 && |
---|
1334 | spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags ) |
---|
1335 | return false; |
---|
1336 | } |
---|
1337 | // Bloodlust and Bloodthirst (multi-family check) |
---|
1338 | if( spellInfo_1->Id == 2825 && spellInfo_2->SpellIconID == 38 && spellInfo_2->SpellVisual == 0 ) |
---|
1339 | return false; |
---|
1340 | break; |
---|
1341 | default: |
---|
1342 | break; |
---|
1343 | } |
---|
1344 | |
---|
1345 | if (IsRankSpellDueToSpell(spellInfo_1, spellId_2)) |
---|
1346 | return true; |
---|
1347 | |
---|
1348 | if (spellInfo_1->SpellIconID != spellInfo_2->SpellIconID || |
---|
1349 | !spellInfo_1->SpellIconID) |
---|
1350 | return false; |
---|
1351 | |
---|
1352 | if (spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName) |
---|
1353 | return false; |
---|
1354 | |
---|
1355 | for (int i = 0; i < 3; ++i) |
---|
1356 | if (spellInfo_1->Effect[i] != spellInfo_2->Effect[i] || |
---|
1357 | spellInfo_1->EffectItemType[i] != spellInfo_2->EffectItemType[i] || |
---|
1358 | spellInfo_1->EffectMiscValue[i] != spellInfo_2->EffectMiscValue[i] || |
---|
1359 | spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]) |
---|
1360 | return false; |
---|
1361 | |
---|
1362 | return true; |
---|
1363 | } |
---|
1364 | |
---|
1365 | bool SpellMgr::IsProfessionSpell(uint32 spellId) |
---|
1366 | { |
---|
1367 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); |
---|
1368 | if(!spellInfo) |
---|
1369 | return false; |
---|
1370 | |
---|
1371 | if(spellInfo->Effect[1] != SPELL_EFFECT_SKILL) |
---|
1372 | return false; |
---|
1373 | |
---|
1374 | uint32 skill = spellInfo->EffectMiscValue[1]; |
---|
1375 | |
---|
1376 | return IsProfessionSkill(skill); |
---|
1377 | } |
---|
1378 | |
---|
1379 | bool SpellMgr::IsPrimaryProfessionSpell(uint32 spellId) |
---|
1380 | { |
---|
1381 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); |
---|
1382 | if(!spellInfo) |
---|
1383 | return false; |
---|
1384 | |
---|
1385 | if(spellInfo->Effect[1] != SPELL_EFFECT_SKILL) |
---|
1386 | return false; |
---|
1387 | |
---|
1388 | uint32 skill = spellInfo->EffectMiscValue[1]; |
---|
1389 | |
---|
1390 | return IsPrimaryProfessionSkill(skill); |
---|
1391 | } |
---|
1392 | |
---|
1393 | bool SpellMgr::IsPrimaryProfessionFirstRankSpell(uint32 spellId) const |
---|
1394 | { |
---|
1395 | return IsPrimaryProfessionSpell(spellId) && GetSpellRank(spellId)==1; |
---|
1396 | } |
---|
1397 | |
---|
1398 | SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const |
---|
1399 | { |
---|
1400 | // ignore passive spells |
---|
1401 | if(IsPassiveSpell(spellInfo->Id)) |
---|
1402 | return spellInfo; |
---|
1403 | |
---|
1404 | bool needRankSelection = false; |
---|
1405 | for(int i=0;i<3;i++) |
---|
1406 | { |
---|
1407 | if( IsPositiveEffect(spellInfo->Id, i) && ( |
---|
1408 | spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || |
---|
1409 | spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY |
---|
1410 | ) ) |
---|
1411 | { |
---|
1412 | needRankSelection = true; |
---|
1413 | break; |
---|
1414 | } |
---|
1415 | } |
---|
1416 | |
---|
1417 | // not required |
---|
1418 | if(!needRankSelection) |
---|
1419 | return spellInfo; |
---|
1420 | |
---|
1421 | for(uint32 nextSpellId = spellInfo->Id; nextSpellId != 0; nextSpellId = GetPrevSpellInChain(nextSpellId)) |
---|
1422 | { |
---|
1423 | SpellEntry const *nextSpellInfo = sSpellStore.LookupEntry(nextSpellId); |
---|
1424 | if(!nextSpellInfo) |
---|
1425 | break; |
---|
1426 | |
---|
1427 | // if found appropriate level |
---|
1428 | if(playerLevel + 10 >= nextSpellInfo->spellLevel) |
---|
1429 | return nextSpellInfo; |
---|
1430 | |
---|
1431 | // one rank less then |
---|
1432 | } |
---|
1433 | |
---|
1434 | // not found |
---|
1435 | return NULL; |
---|
1436 | } |
---|
1437 | |
---|
1438 | void SpellMgr::LoadSpellChains() |
---|
1439 | { |
---|
1440 | mSpellChains.clear(); // need for reload case |
---|
1441 | mSpellChainsNext.clear(); // need for reload case |
---|
1442 | |
---|
1443 | QueryResult *result = WorldDatabase.PQuery("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain"); |
---|
1444 | if(result == NULL) |
---|
1445 | { |
---|
1446 | barGoLink bar( 1 ); |
---|
1447 | bar.step(); |
---|
1448 | |
---|
1449 | sLog.outString(); |
---|
1450 | sLog.outString( ">> Loaded 0 spell chain records" ); |
---|
1451 | sLog.outErrorDb("`spell_chains` table is empty!"); |
---|
1452 | return; |
---|
1453 | } |
---|
1454 | |
---|
1455 | uint32 count = 0; |
---|
1456 | |
---|
1457 | barGoLink bar( result->GetRowCount() ); |
---|
1458 | do |
---|
1459 | { |
---|
1460 | bar.step(); |
---|
1461 | Field *fields = result->Fetch(); |
---|
1462 | |
---|
1463 | uint32 spell_id = fields[0].GetUInt32(); |
---|
1464 | |
---|
1465 | SpellChainNode node; |
---|
1466 | node.prev = fields[1].GetUInt32(); |
---|
1467 | node.first = fields[2].GetUInt32(); |
---|
1468 | node.rank = fields[3].GetUInt8(); |
---|
1469 | node.req = fields[4].GetUInt32(); |
---|
1470 | |
---|
1471 | if(!sSpellStore.LookupEntry(spell_id)) |
---|
1472 | { |
---|
1473 | sLog.outErrorDb("Spell %u listed in `spell_chain` does not exist",spell_id); |
---|
1474 | continue; |
---|
1475 | } |
---|
1476 | |
---|
1477 | if(node.prev!=0 && !sSpellStore.LookupEntry(node.prev)) |
---|
1478 | { |
---|
1479 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existed previous rank spell.", |
---|
1480 | spell_id,node.prev,node.first,node.rank,node.req); |
---|
1481 | continue; |
---|
1482 | } |
---|
1483 | |
---|
1484 | if(!sSpellStore.LookupEntry(node.first)) |
---|
1485 | { |
---|
1486 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing first rank spell.", |
---|
1487 | spell_id,node.prev,node.first,node.rank,node.req); |
---|
1488 | continue; |
---|
1489 | } |
---|
1490 | |
---|
1491 | // check basic spell chain data integrity (note: rank can be equal 0 or 1 for first/single spell) |
---|
1492 | if( (spell_id == node.first) != (node.rank <= 1) || |
---|
1493 | (spell_id == node.first) != (node.prev == 0) || |
---|
1494 | (node.rank <= 1) != (node.prev == 0) ) |
---|
1495 | { |
---|
1496 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not compatible chain data.", |
---|
1497 | spell_id,node.prev,node.first,node.rank,node.req); |
---|
1498 | continue; |
---|
1499 | } |
---|
1500 | |
---|
1501 | if(node.req!=0 && !sSpellStore.LookupEntry(node.req)) |
---|
1502 | { |
---|
1503 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing required spell.", |
---|
1504 | spell_id,node.prev,node.first,node.rank,node.req); |
---|
1505 | continue; |
---|
1506 | } |
---|
1507 | |
---|
1508 | // talents not required data in spell chain for work, but must be checked if present for intergrity |
---|
1509 | if(TalentSpellPos const* pos = GetTalentSpellPos(spell_id)) |
---|
1510 | { |
---|
1511 | if(node.rank!=pos->rank+1) |
---|
1512 | { |
---|
1513 | sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong rank.", |
---|
1514 | spell_id,node.prev,node.first,node.rank,node.req); |
---|
1515 | continue; |
---|
1516 | } |
---|
1517 | |
---|
1518 | if(TalentEntry const* talentEntry = sTalentStore.LookupEntry(pos->talent_id)) |
---|
1519 | { |
---|
1520 | if(node.first!=talentEntry->RankID[0]) |
---|
1521 | { |
---|
1522 | sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong first rank spell.", |
---|
1523 | spell_id,node.prev,node.first,node.rank,node.req); |
---|
1524 | continue; |
---|
1525 | } |
---|
1526 | |
---|
1527 | if(node.rank > 1 && node.prev != talentEntry->RankID[node.rank-1-1]) |
---|
1528 | { |
---|
1529 | sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong prev rank spell.", |
---|
1530 | spell_id,node.prev,node.first,node.rank,node.req); |
---|
1531 | continue; |
---|
1532 | } |
---|
1533 | |
---|
1534 | if(node.req!=talentEntry->DependsOnSpell) |
---|
1535 | { |
---|
1536 | sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong required spell.", |
---|
1537 | spell_id,node.prev,node.first,node.rank,node.req); |
---|
1538 | continue; |
---|
1539 | } |
---|
1540 | } |
---|
1541 | } |
---|
1542 | |
---|
1543 | mSpellChains[spell_id] = node; |
---|
1544 | |
---|
1545 | if(node.prev) |
---|
1546 | mSpellChainsNext.insert(SpellChainMapNext::value_type(node.prev,spell_id)); |
---|
1547 | |
---|
1548 | if(node.req) |
---|
1549 | mSpellChainsNext.insert(SpellChainMapNext::value_type(node.req,spell_id)); |
---|
1550 | |
---|
1551 | ++count; |
---|
1552 | } while( result->NextRow() ); |
---|
1553 | |
---|
1554 | // additional integrity checks |
---|
1555 | for(SpellChainMap::iterator i = mSpellChains.begin(); i != mSpellChains.end(); ++i) |
---|
1556 | { |
---|
1557 | if(i->second.prev) |
---|
1558 | { |
---|
1559 | SpellChainMap::iterator i_prev = mSpellChains.find(i->second.prev); |
---|
1560 | if(i_prev == mSpellChains.end()) |
---|
1561 | { |
---|
1562 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found previous rank spell in table.", |
---|
1563 | i->first,i->second.prev,i->second.first,i->second.rank,i->second.req); |
---|
1564 | } |
---|
1565 | else if( i_prev->second.first != i->second.first ) |
---|
1566 | { |
---|
1567 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has different first spell in chain compared to previous rank spell (prev: %u, first: %u, rank: %d, req: %u).", |
---|
1568 | i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, |
---|
1569 | i_prev->second.prev,i_prev->second.first,i_prev->second.rank,i_prev->second.req); |
---|
1570 | } |
---|
1571 | else if( i_prev->second.rank+1 != i->second.rank ) |
---|
1572 | { |
---|
1573 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has different rank compared to previous rank spell (prev: %u, first: %u, rank: %d, req: %u).", |
---|
1574 | i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, |
---|
1575 | i_prev->second.prev,i_prev->second.first,i_prev->second.rank,i_prev->second.req); |
---|
1576 | } |
---|
1577 | } |
---|
1578 | |
---|
1579 | if(i->second.req) |
---|
1580 | { |
---|
1581 | SpellChainMap::iterator i_req = mSpellChains.find(i->second.req); |
---|
1582 | if(i_req == mSpellChains.end()) |
---|
1583 | { |
---|
1584 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found required rank spell in table.", |
---|
1585 | i->first,i->second.prev,i->second.first,i->second.rank,i->second.req); |
---|
1586 | } |
---|
1587 | else if( i_req->second.first == i->second.first ) |
---|
1588 | { |
---|
1589 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has required rank spell from same spell chain (prev: %u, first: %u, rank: %d, req: %u).", |
---|
1590 | i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, |
---|
1591 | i_req->second.prev,i_req->second.first,i_req->second.rank,i_req->second.req); |
---|
1592 | } |
---|
1593 | else if( i_req->second.req ) |
---|
1594 | { |
---|
1595 | sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has required rank spell with required spell (prev: %u, first: %u, rank: %d, req: %u).", |
---|
1596 | i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, |
---|
1597 | i_req->second.prev,i_req->second.first,i_req->second.rank,i_req->second.req); |
---|
1598 | } |
---|
1599 | } |
---|
1600 | } |
---|
1601 | |
---|
1602 | delete result; |
---|
1603 | |
---|
1604 | sLog.outString(); |
---|
1605 | sLog.outString( ">> Loaded %u spell chain records", count ); |
---|
1606 | } |
---|
1607 | |
---|
1608 | void SpellMgr::LoadSpellLearnSkills() |
---|
1609 | { |
---|
1610 | mSpellLearnSkills.clear(); // need for reload case |
---|
1611 | |
---|
1612 | // search auto-learned skills and add its to map also for use in unlearn spells/talents |
---|
1613 | uint32 dbc_count = 0; |
---|
1614 | for(uint32 spell = 0; spell < sSpellStore.GetNumRows(); ++spell) |
---|
1615 | { |
---|
1616 | SpellEntry const* entry = sSpellStore.LookupEntry(spell); |
---|
1617 | |
---|
1618 | if(!entry) |
---|
1619 | continue; |
---|
1620 | |
---|
1621 | for(int i = 0; i < 3; ++i) |
---|
1622 | { |
---|
1623 | if(entry->Effect[i]==SPELL_EFFECT_SKILL) |
---|
1624 | { |
---|
1625 | SpellLearnSkillNode dbc_node; |
---|
1626 | dbc_node.skill = entry->EffectMiscValue[i]; |
---|
1627 | if ( dbc_node.skill != SKILL_RIDING ) |
---|
1628 | dbc_node.value = 1; |
---|
1629 | else |
---|
1630 | dbc_node.value = (entry->EffectBasePoints[i]+1)*75; |
---|
1631 | dbc_node.maxvalue = (entry->EffectBasePoints[i]+1)*75; |
---|
1632 | |
---|
1633 | SpellLearnSkillNode const* db_node = GetSpellLearnSkill(spell); |
---|
1634 | |
---|
1635 | mSpellLearnSkills[spell] = dbc_node; |
---|
1636 | ++dbc_count; |
---|
1637 | break; |
---|
1638 | } |
---|
1639 | } |
---|
1640 | } |
---|
1641 | |
---|
1642 | sLog.outString(); |
---|
1643 | sLog.outString( ">> Loaded %u Spell Learn Skills from DBC", dbc_count ); |
---|
1644 | } |
---|
1645 | |
---|
1646 | void SpellMgr::LoadSpellLearnSpells() |
---|
1647 | { |
---|
1648 | mSpellLearnSpells.clear(); // need for reload case |
---|
1649 | |
---|
1650 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, SpellID FROM spell_learn_spell"); |
---|
1651 | if(!result) |
---|
1652 | { |
---|
1653 | barGoLink bar( 1 ); |
---|
1654 | bar.step(); |
---|
1655 | |
---|
1656 | sLog.outString(); |
---|
1657 | sLog.outString( ">> Loaded 0 spell learn spells" ); |
---|
1658 | sLog.outErrorDb("`spell_learn_spell` table is empty!"); |
---|
1659 | return; |
---|
1660 | } |
---|
1661 | |
---|
1662 | uint32 count = 0; |
---|
1663 | |
---|
1664 | barGoLink bar( result->GetRowCount() ); |
---|
1665 | do |
---|
1666 | { |
---|
1667 | bar.step(); |
---|
1668 | Field *fields = result->Fetch(); |
---|
1669 | |
---|
1670 | uint32 spell_id = fields[0].GetUInt32(); |
---|
1671 | |
---|
1672 | SpellLearnSpellNode node; |
---|
1673 | node.spell = fields[1].GetUInt32(); |
---|
1674 | node.autoLearned= false; |
---|
1675 | |
---|
1676 | if(!sSpellStore.LookupEntry(spell_id)) |
---|
1677 | { |
---|
1678 | sLog.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",spell_id); |
---|
1679 | continue; |
---|
1680 | } |
---|
1681 | |
---|
1682 | if(!sSpellStore.LookupEntry(node.spell)) |
---|
1683 | { |
---|
1684 | sLog.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",node.spell); |
---|
1685 | continue; |
---|
1686 | } |
---|
1687 | |
---|
1688 | mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell_id,node)); |
---|
1689 | |
---|
1690 | ++count; |
---|
1691 | } while( result->NextRow() ); |
---|
1692 | |
---|
1693 | delete result; |
---|
1694 | |
---|
1695 | // search auto-learned spells and add its to map also for use in unlearn spells/talents |
---|
1696 | uint32 dbc_count = 0; |
---|
1697 | for(uint32 spell = 0; spell < sSpellStore.GetNumRows(); ++spell) |
---|
1698 | { |
---|
1699 | SpellEntry const* entry = sSpellStore.LookupEntry(spell); |
---|
1700 | |
---|
1701 | if(!entry) |
---|
1702 | continue; |
---|
1703 | |
---|
1704 | for(int i = 0; i < 3; ++i) |
---|
1705 | { |
---|
1706 | if(entry->Effect[i]==SPELL_EFFECT_LEARN_SPELL) |
---|
1707 | { |
---|
1708 | SpellLearnSpellNode dbc_node; |
---|
1709 | dbc_node.spell = entry->EffectTriggerSpell[i]; |
---|
1710 | dbc_node.autoLearned = true; |
---|
1711 | |
---|
1712 | SpellLearnSpellMap::const_iterator db_node_begin = GetBeginSpellLearnSpell(spell); |
---|
1713 | SpellLearnSpellMap::const_iterator db_node_end = GetEndSpellLearnSpell(spell); |
---|
1714 | |
---|
1715 | bool found = false; |
---|
1716 | for(SpellLearnSpellMap::const_iterator itr = db_node_begin; itr != db_node_end; ++itr) |
---|
1717 | { |
---|
1718 | if(itr->second.spell == dbc_node.spell) |
---|
1719 | { |
---|
1720 | sLog.outErrorDb("Spell %u auto-learn spell %u in spell.dbc then the record in `spell_learn_spell` is redundant, please fix DB.", |
---|
1721 | spell,dbc_node.spell); |
---|
1722 | found = true; |
---|
1723 | break; |
---|
1724 | } |
---|
1725 | } |
---|
1726 | |
---|
1727 | if(!found) // add new spell-spell pair if not found |
---|
1728 | { |
---|
1729 | mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell,dbc_node)); |
---|
1730 | ++dbc_count; |
---|
1731 | } |
---|
1732 | } |
---|
1733 | } |
---|
1734 | } |
---|
1735 | |
---|
1736 | sLog.outString(); |
---|
1737 | sLog.outString( ">> Loaded %u spell learn spells + %u found in DBC", count, dbc_count ); |
---|
1738 | } |
---|
1739 | |
---|
1740 | void SpellMgr::LoadSpellScriptTarget() |
---|
1741 | { |
---|
1742 | mSpellScriptTarget.clear(); // need for reload case |
---|
1743 | |
---|
1744 | uint32 count = 0; |
---|
1745 | |
---|
1746 | QueryResult *result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM spell_script_target"); |
---|
1747 | |
---|
1748 | if(!result) |
---|
1749 | { |
---|
1750 | barGoLink bar(1); |
---|
1751 | |
---|
1752 | bar.step(); |
---|
1753 | |
---|
1754 | sLog.outString(); |
---|
1755 | sLog.outErrorDb(">> Loaded 0 SpellScriptTarget. DB table `spell_script_target` is empty."); |
---|
1756 | return; |
---|
1757 | } |
---|
1758 | |
---|
1759 | barGoLink bar(result->GetRowCount()); |
---|
1760 | |
---|
1761 | do |
---|
1762 | { |
---|
1763 | Field *fields = result->Fetch(); |
---|
1764 | bar.step(); |
---|
1765 | |
---|
1766 | uint32 spellId = fields[0].GetUInt32(); |
---|
1767 | uint32 type = fields[1].GetUInt32(); |
---|
1768 | uint32 targetEntry = fields[2].GetUInt32(); |
---|
1769 | |
---|
1770 | SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId); |
---|
1771 | |
---|
1772 | if(!spellProto) |
---|
1773 | { |
---|
1774 | sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not exist.",spellId,targetEntry); |
---|
1775 | continue; |
---|
1776 | } |
---|
1777 | |
---|
1778 | bool targetfound = false; |
---|
1779 | for(int i = 0; i <3; ++i) |
---|
1780 | { |
---|
1781 | if( spellProto->EffectImplicitTargetA[i]==TARGET_SCRIPT || |
---|
1782 | spellProto->EffectImplicitTargetB[i]==TARGET_SCRIPT || |
---|
1783 | spellProto->EffectImplicitTargetA[i]==TARGET_SCRIPT_COORDINATES || |
---|
1784 | spellProto->EffectImplicitTargetB[i]==TARGET_SCRIPT_COORDINATES ) |
---|
1785 | { |
---|
1786 | targetfound = true; |
---|
1787 | break; |
---|
1788 | } |
---|
1789 | } |
---|
1790 | if(!targetfound) |
---|
1791 | { |
---|
1792 | sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not have any implicit target TARGET_SCRIPT(38) or TARGET_SCRIPT_COORDINATES (46).",spellId,targetEntry); |
---|
1793 | continue; |
---|
1794 | } |
---|
1795 | |
---|
1796 | if( type >= MAX_SPELL_TARGET_TYPE ) |
---|
1797 | { |
---|
1798 | sLog.outErrorDb("Table `spell_script_target`: target type %u for TargetEntry %u is incorrect.",type,targetEntry); |
---|
1799 | continue; |
---|
1800 | } |
---|
1801 | |
---|
1802 | switch(type) |
---|
1803 | { |
---|
1804 | case SPELL_TARGET_TYPE_GAMEOBJECT: |
---|
1805 | { |
---|
1806 | if( targetEntry==0 ) |
---|
1807 | break; |
---|
1808 | |
---|
1809 | if(!sGOStorage.LookupEntry<GameObjectInfo>(targetEntry)) |
---|
1810 | { |
---|
1811 | sLog.outErrorDb("Table `spell_script_target`: gameobject template entry %u does not exist.",targetEntry); |
---|
1812 | continue; |
---|
1813 | } |
---|
1814 | break; |
---|
1815 | } |
---|
1816 | default: |
---|
1817 | { |
---|
1818 | if( targetEntry==0 ) |
---|
1819 | { |
---|
1820 | sLog.outErrorDb("Table `spell_script_target`: target entry == 0 for not GO target type (%u).",type); |
---|
1821 | continue; |
---|
1822 | } |
---|
1823 | if(!sCreatureStorage.LookupEntry<CreatureInfo>(targetEntry)) |
---|
1824 | { |
---|
1825 | sLog.outErrorDb("Table `spell_script_target`: creature template entry %u does not exist.",targetEntry); |
---|
1826 | continue; |
---|
1827 | } |
---|
1828 | const CreatureInfo* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(targetEntry); |
---|
1829 | |
---|
1830 | if(spellId == 30427 && !cInfo->SkinLootId) |
---|
1831 | { |
---|
1832 | sLog.outErrorDb("Table `spell_script_target` has creature %u as a target of spellid 30427, but this creature has no skinlootid. Gas extraction will not work!", cInfo->Entry); |
---|
1833 | continue; |
---|
1834 | } |
---|
1835 | break; |
---|
1836 | } |
---|
1837 | } |
---|
1838 | |
---|
1839 | mSpellScriptTarget.insert(SpellScriptTarget::value_type(spellId,SpellTargetEntry(SpellTargetType(type),targetEntry))); |
---|
1840 | |
---|
1841 | ++count; |
---|
1842 | } while (result->NextRow()); |
---|
1843 | |
---|
1844 | delete result; |
---|
1845 | |
---|
1846 | // Check all spells |
---|
1847 | /* Disabled (lot errors at this moment) |
---|
1848 | for(uint32 i = 1; i < sSpellStore.nCount; ++i) |
---|
1849 | { |
---|
1850 | SpellEntry const * spellInfo = sSpellStore.LookupEntry(i); |
---|
1851 | if(!spellInfo) |
---|
1852 | continue; |
---|
1853 | |
---|
1854 | bool found = false; |
---|
1855 | for(int j=0; j<3; ++j) |
---|
1856 | { |
---|
1857 | if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT ) |
---|
1858 | { |
---|
1859 | SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(spellInfo->Id); |
---|
1860 | SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(spellInfo->Id); |
---|
1861 | if(lower==upper) |
---|
1862 | { |
---|
1863 | sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = %u (TARGET_SCRIPT), but does not have record in `spell_script_target`",spellInfo->Id,TARGET_SCRIPT); |
---|
1864 | break; // effects of spell |
---|
1865 | } |
---|
1866 | } |
---|
1867 | } |
---|
1868 | } |
---|
1869 | */ |
---|
1870 | |
---|
1871 | sLog.outString(); |
---|
1872 | sLog.outString(">> Loaded %u Spell Script Targets", count); |
---|
1873 | } |
---|
1874 | |
---|
1875 | void SpellMgr::LoadSpellPetAuras() |
---|
1876 | { |
---|
1877 | mSpellPetAuraMap.clear(); // need for reload case |
---|
1878 | |
---|
1879 | uint32 count = 0; |
---|
1880 | |
---|
1881 | // 0 1 2 |
---|
1882 | QueryResult *result = WorldDatabase.Query("SELECT spell, pet, aura FROM spell_pet_auras"); |
---|
1883 | if( !result ) |
---|
1884 | { |
---|
1885 | |
---|
1886 | barGoLink bar( 1 ); |
---|
1887 | |
---|
1888 | bar.step(); |
---|
1889 | |
---|
1890 | sLog.outString(); |
---|
1891 | sLog.outString( ">> Loaded %u spell pet auras", count ); |
---|
1892 | return; |
---|
1893 | } |
---|
1894 | |
---|
1895 | barGoLink bar( result->GetRowCount() ); |
---|
1896 | |
---|
1897 | do |
---|
1898 | { |
---|
1899 | Field *fields = result->Fetch(); |
---|
1900 | |
---|
1901 | bar.step(); |
---|
1902 | |
---|
1903 | uint16 spell = fields[0].GetUInt16(); |
---|
1904 | uint16 pet = fields[1].GetUInt16(); |
---|
1905 | uint16 aura = fields[2].GetUInt16(); |
---|
1906 | |
---|
1907 | SpellPetAuraMap::iterator itr = mSpellPetAuraMap.find(spell); |
---|
1908 | if(itr != mSpellPetAuraMap.end()) |
---|
1909 | { |
---|
1910 | itr->second.AddAura(pet, aura); |
---|
1911 | } |
---|
1912 | else |
---|
1913 | { |
---|
1914 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
1915 | if (!spellInfo) |
---|
1916 | { |
---|
1917 | sLog.outErrorDb("Spell %u listed in `spell_pet_auras` does not exist", spell); |
---|
1918 | continue; |
---|
1919 | } |
---|
1920 | int i = 0; |
---|
1921 | for(; i < 3; ++i) |
---|
1922 | if((spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && |
---|
1923 | spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DUMMY) || |
---|
1924 | spellInfo->Effect[i] == SPELL_EFFECT_DUMMY) |
---|
1925 | break; |
---|
1926 | |
---|
1927 | if(i == 3) |
---|
1928 | { |
---|
1929 | sLog.outError("Spell %u listed in `spell_pet_auras` does not have dummy aura or dummy effect", spell); |
---|
1930 | continue; |
---|
1931 | } |
---|
1932 | |
---|
1933 | SpellEntry const* spellInfo2 = sSpellStore.LookupEntry(aura); |
---|
1934 | if (!spellInfo2) |
---|
1935 | { |
---|
1936 | sLog.outErrorDb("Aura %u listed in `spell_pet_auras` does not exist", aura); |
---|
1937 | continue; |
---|
1938 | } |
---|
1939 | |
---|
1940 | PetAura pa(pet, aura, spellInfo->EffectImplicitTargetA[i] == TARGET_PET, spellInfo->EffectBasePoints[i] + spellInfo->EffectBaseDice[i]); |
---|
1941 | mSpellPetAuraMap[spell] = pa; |
---|
1942 | } |
---|
1943 | |
---|
1944 | ++count; |
---|
1945 | } while( result->NextRow() ); |
---|
1946 | |
---|
1947 | delete result; |
---|
1948 | |
---|
1949 | sLog.outString(); |
---|
1950 | sLog.outString( ">> Loaded %u spell pet auras", count ); |
---|
1951 | } |
---|
1952 | |
---|
1953 | /// Some checks for spells, to prevent adding depricated/broken spells for trainers, spell book, etc |
---|
1954 | bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) |
---|
1955 | { |
---|
1956 | // not exist |
---|
1957 | if(!spellInfo) |
---|
1958 | return false; |
---|
1959 | |
---|
1960 | bool need_check_reagents = false; |
---|
1961 | |
---|
1962 | // check effects |
---|
1963 | for(int i=0; i<3; ++i) |
---|
1964 | { |
---|
1965 | switch(spellInfo->Effect[i]) |
---|
1966 | { |
---|
1967 | case 0: |
---|
1968 | continue; |
---|
1969 | |
---|
1970 | // craft spell for crafting non-existed item (break client recipes list show) |
---|
1971 | case SPELL_EFFECT_CREATE_ITEM: |
---|
1972 | { |
---|
1973 | if(!ObjectMgr::GetItemPrototype( spellInfo->EffectItemType[i] )) |
---|
1974 | { |
---|
1975 | if(msg) |
---|
1976 | { |
---|
1977 | if(pl) |
---|
1978 | ChatHandler(pl).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...",spellInfo->Id,spellInfo->EffectItemType[i]); |
---|
1979 | else |
---|
1980 | sLog.outErrorDb("Craft spell %u create not-exist in DB item (Entry: %u) and then...",spellInfo->Id,spellInfo->EffectItemType[i]); |
---|
1981 | } |
---|
1982 | return false; |
---|
1983 | } |
---|
1984 | |
---|
1985 | need_check_reagents = true; |
---|
1986 | break; |
---|
1987 | } |
---|
1988 | case SPELL_EFFECT_LEARN_SPELL: |
---|
1989 | { |
---|
1990 | SpellEntry const* spellInfo2 = sSpellStore.LookupEntry(spellInfo->EffectTriggerSpell[0]); |
---|
1991 | if( !IsSpellValid(spellInfo2,pl,msg) ) |
---|
1992 | { |
---|
1993 | if(msg) |
---|
1994 | { |
---|
1995 | if(pl) |
---|
1996 | ChatHandler(pl).PSendSysMessage("Spell %u learn to broken spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[0]); |
---|
1997 | else |
---|
1998 | sLog.outErrorDb("Spell %u learn to invalid spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[0]); |
---|
1999 | } |
---|
2000 | return false; |
---|
2001 | } |
---|
2002 | break; |
---|
2003 | } |
---|
2004 | } |
---|
2005 | } |
---|
2006 | |
---|
2007 | if(need_check_reagents) |
---|
2008 | { |
---|
2009 | for(int j = 0; j < 8; ++j) |
---|
2010 | { |
---|
2011 | if(spellInfo->Reagent[j] > 0 && !ObjectMgr::GetItemPrototype( spellInfo->Reagent[j] )) |
---|
2012 | { |
---|
2013 | if(msg) |
---|
2014 | { |
---|
2015 | if(pl) |
---|
2016 | ChatHandler(pl).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...",spellInfo->Id,spellInfo->Reagent[j]); |
---|
2017 | else |
---|
2018 | sLog.outErrorDb("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...",spellInfo->Id,spellInfo->Reagent[j]); |
---|
2019 | } |
---|
2020 | return false; |
---|
2021 | } |
---|
2022 | } |
---|
2023 | } |
---|
2024 | |
---|
2025 | return true; |
---|
2026 | } |
---|
2027 | |
---|
2028 | bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 zone_id,uint32 area_id) |
---|
2029 | { |
---|
2030 | // normal case |
---|
2031 | if( spellInfo->AreaId && spellInfo->AreaId != zone_id && spellInfo->AreaId != area_id ) |
---|
2032 | return false; |
---|
2033 | |
---|
2034 | // elixirs (all area dependent elixirs have family SPELLFAMILY_POTION, use this for speedup) |
---|
2035 | if(spellInfo->SpellFamilyName==SPELLFAMILY_POTION) |
---|
2036 | { |
---|
2037 | if(uint32 mask = spellmgr.GetSpellElixirMask(spellInfo->Id)) |
---|
2038 | { |
---|
2039 | if(mask & ELIXIR_UNSTABLE_MASK) |
---|
2040 | { |
---|
2041 | // in the Blade's Edge Mountains Plateaus and Gruul's Lair. |
---|
2042 | return zone_id ==3522 || map_id==565; |
---|
2043 | } |
---|
2044 | if(mask & ELIXIR_UNSTABLE_MASK) |
---|
2045 | { |
---|
2046 | // in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple |
---|
2047 | // TODO: and the Sunwell Plateau |
---|
2048 | if(zone_id ==3607 || map_id==534 || map_id==564) |
---|
2049 | return true; |
---|
2050 | |
---|
2051 | MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); |
---|
2052 | if(!mapEntry) |
---|
2053 | return false; |
---|
2054 | |
---|
2055 | return mapEntry->multimap_id==206; |
---|
2056 | } |
---|
2057 | |
---|
2058 | // elixirs not have another limitations |
---|
2059 | return true; |
---|
2060 | } |
---|
2061 | } |
---|
2062 | |
---|
2063 | // special cases zone check (maps checked by multimap common id) |
---|
2064 | switch(spellInfo->Id) |
---|
2065 | { |
---|
2066 | case 41618: |
---|
2067 | case 41620: |
---|
2068 | { |
---|
2069 | MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); |
---|
2070 | if(!mapEntry) |
---|
2071 | return false; |
---|
2072 | |
---|
2073 | return mapEntry->multimap_id==206; |
---|
2074 | } |
---|
2075 | |
---|
2076 | case 41617: |
---|
2077 | case 41619: |
---|
2078 | { |
---|
2079 | MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); |
---|
2080 | if(!mapEntry) |
---|
2081 | return false; |
---|
2082 | |
---|
2083 | return mapEntry->multimap_id==207; |
---|
2084 | } |
---|
2085 | // Dragonmaw Illusion |
---|
2086 | case 40216: |
---|
2087 | case 42016: |
---|
2088 | { |
---|
2089 | if ( area_id != 3759 && area_id != 3966 && area_id != 3939 ) |
---|
2090 | return false; |
---|
2091 | break; |
---|
2092 | } |
---|
2093 | } |
---|
2094 | |
---|
2095 | return true; |
---|
2096 | } |
---|
2097 | |
---|
2098 | void SpellMgr::LoadSkillLineAbilityMap() |
---|
2099 | { |
---|
2100 | mSkillLineAbilityMap.clear(); |
---|
2101 | |
---|
2102 | uint32 count = 0; |
---|
2103 | |
---|
2104 | for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); i++) |
---|
2105 | { |
---|
2106 | SkillLineAbilityEntry const *SkillInfo = sSkillLineAbilityStore.LookupEntry(i); |
---|
2107 | if(!SkillInfo) |
---|
2108 | continue; |
---|
2109 | |
---|
2110 | mSkillLineAbilityMap.insert(SkillLineAbilityMap::value_type(SkillInfo->spellId,SkillInfo)); |
---|
2111 | ++count; |
---|
2112 | } |
---|
2113 | |
---|
2114 | sLog.outString(); |
---|
2115 | sLog.outString(">> Loaded %u SkillLineAbility MultiMap", count); |
---|
2116 | } |
---|
2117 | |
---|
2118 | DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto, bool triggered) |
---|
2119 | { |
---|
2120 | // Explicit Diminishing Groups |
---|
2121 | switch(spellproto->SpellFamilyName) |
---|
2122 | { |
---|
2123 | case SPELLFAMILY_MAGE: |
---|
2124 | { |
---|
2125 | // Polymorph |
---|
2126 | if ((spellproto->SpellFamilyFlags & 0x00001000000LL) && spellproto->EffectApplyAuraName[0]==SPELL_AURA_MOD_CONFUSE) |
---|
2127 | return DIMINISHING_POLYMORPH; |
---|
2128 | break; |
---|
2129 | } |
---|
2130 | case SPELLFAMILY_ROGUE: |
---|
2131 | { |
---|
2132 | // Kidney Shot |
---|
2133 | if (spellproto->SpellFamilyFlags & 0x00000200000LL) |
---|
2134 | return DIMINISHING_KIDNEYSHOT; |
---|
2135 | // Blind |
---|
2136 | else if (spellproto->SpellFamilyFlags & 0x00001000000LL) |
---|
2137 | return DIMINISHING_BLIND_CYCLONE; |
---|
2138 | break; |
---|
2139 | } |
---|
2140 | case SPELLFAMILY_WARLOCK: |
---|
2141 | { |
---|
2142 | // Death Coil |
---|
2143 | if (spellproto->SpellFamilyFlags & 0x00000080000LL) |
---|
2144 | return DIMINISHING_DEATHCOIL; |
---|
2145 | // Fear |
---|
2146 | else if (spellproto->SpellFamilyFlags & 0x40840000000LL) |
---|
2147 | return DIMINISHING_WARLOCK_FEAR; |
---|
2148 | // Curses/etc |
---|
2149 | else if (spellproto->SpellFamilyFlags & 0x00080000000LL) |
---|
2150 | return DIMINISHING_LIMITONLY; |
---|
2151 | break; |
---|
2152 | } |
---|
2153 | case SPELLFAMILY_DRUID: |
---|
2154 | { |
---|
2155 | // Cyclone |
---|
2156 | if (spellproto->SpellFamilyFlags & 0x02000000000LL) |
---|
2157 | return DIMINISHING_BLIND_CYCLONE; |
---|
2158 | break; |
---|
2159 | } |
---|
2160 | case SPELLFAMILY_WARRIOR: |
---|
2161 | { |
---|
2162 | // Hamstring - limit duration to 10s in PvP |
---|
2163 | if (spellproto->SpellFamilyFlags & 0x00000000002LL) |
---|
2164 | return DIMINISHING_LIMITONLY; |
---|
2165 | break; |
---|
2166 | } |
---|
2167 | default: |
---|
2168 | break; |
---|
2169 | } |
---|
2170 | |
---|
2171 | // Get by mechanic |
---|
2172 | for (uint8 i=0;i<3;++i) |
---|
2173 | { |
---|
2174 | if (spellproto->Mechanic == MECHANIC_STUN || spellproto->EffectMechanic[i] == MECHANIC_STUN) |
---|
2175 | return triggered ? DIMINISHING_TRIGGER_STUN : DIMINISHING_CONTROL_STUN; |
---|
2176 | else if (spellproto->Mechanic == MECHANIC_SLEEP || spellproto->EffectMechanic[i] == MECHANIC_SLEEP) |
---|
2177 | return DIMINISHING_SLEEP; |
---|
2178 | else if (spellproto->Mechanic == MECHANIC_ROOT || spellproto->EffectMechanic[i] == MECHANIC_ROOT) |
---|
2179 | return triggered ? DIMINISHING_TRIGGER_ROOT : DIMINISHING_CONTROL_ROOT; |
---|
2180 | else if (spellproto->Mechanic == MECHANIC_FEAR || spellproto->EffectMechanic[i] == MECHANIC_FEAR) |
---|
2181 | return DIMINISHING_FEAR; |
---|
2182 | else if (spellproto->Mechanic == MECHANIC_CHARM || spellproto->EffectMechanic[i] == MECHANIC_CHARM) |
---|
2183 | return DIMINISHING_CHARM; |
---|
2184 | else if (spellproto->Mechanic == MECHANIC_SILENCE || spellproto->EffectMechanic[i] == MECHANIC_SILENCE) |
---|
2185 | return DIMINISHING_SILENCE; |
---|
2186 | else if (spellproto->Mechanic == MECHANIC_DISARM || spellproto->EffectMechanic[i] == MECHANIC_DISARM) |
---|
2187 | return DIMINISHING_DISARM; |
---|
2188 | else if (spellproto->Mechanic == MECHANIC_FREEZE || spellproto->EffectMechanic[i] == MECHANIC_FREEZE) |
---|
2189 | return DIMINISHING_FREEZE; |
---|
2190 | else if (spellproto->Mechanic == MECHANIC_KNOCKOUT|| spellproto->EffectMechanic[i] == MECHANIC_KNOCKOUT || |
---|
2191 | spellproto->Mechanic == MECHANIC_SAPPED || spellproto->EffectMechanic[i] == MECHANIC_SAPPED) |
---|
2192 | return DIMINISHING_KNOCKOUT; |
---|
2193 | else if (spellproto->Mechanic == MECHANIC_BANISH || spellproto->EffectMechanic[i] == MECHANIC_BANISH) |
---|
2194 | return DIMINISHING_BANISH; |
---|
2195 | } |
---|
2196 | |
---|
2197 | return DIMINISHING_NONE; |
---|
2198 | } |
---|
2199 | |
---|
2200 | bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group) |
---|
2201 | { |
---|
2202 | switch(group) |
---|
2203 | { |
---|
2204 | case DIMINISHING_CONTROL_STUN: |
---|
2205 | case DIMINISHING_TRIGGER_STUN: |
---|
2206 | case DIMINISHING_KIDNEYSHOT: |
---|
2207 | case DIMINISHING_SLEEP: |
---|
2208 | case DIMINISHING_CONTROL_ROOT: |
---|
2209 | case DIMINISHING_TRIGGER_ROOT: |
---|
2210 | case DIMINISHING_FEAR: |
---|
2211 | case DIMINISHING_WARLOCK_FEAR: |
---|
2212 | case DIMINISHING_CHARM: |
---|
2213 | case DIMINISHING_POLYMORPH: |
---|
2214 | case DIMINISHING_FREEZE: |
---|
2215 | case DIMINISHING_KNOCKOUT: |
---|
2216 | case DIMINISHING_BLIND_CYCLONE: |
---|
2217 | case DIMINISHING_BANISH: |
---|
2218 | case DIMINISHING_LIMITONLY: |
---|
2219 | return true; |
---|
2220 | } |
---|
2221 | return false; |
---|
2222 | } |
---|
2223 | |
---|
2224 | DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group) |
---|
2225 | { |
---|
2226 | switch(group) |
---|
2227 | { |
---|
2228 | case DIMINISHING_BLIND_CYCLONE: |
---|
2229 | case DIMINISHING_CONTROL_STUN: |
---|
2230 | case DIMINISHING_TRIGGER_STUN: |
---|
2231 | case DIMINISHING_KIDNEYSHOT: |
---|
2232 | return DRTYPE_ALL; |
---|
2233 | case DIMINISHING_SLEEP: |
---|
2234 | case DIMINISHING_CONTROL_ROOT: |
---|
2235 | case DIMINISHING_TRIGGER_ROOT: |
---|
2236 | case DIMINISHING_FEAR: |
---|
2237 | case DIMINISHING_CHARM: |
---|
2238 | case DIMINISHING_POLYMORPH: |
---|
2239 | case DIMINISHING_SILENCE: |
---|
2240 | case DIMINISHING_DISARM: |
---|
2241 | case DIMINISHING_DEATHCOIL: |
---|
2242 | case DIMINISHING_FREEZE: |
---|
2243 | case DIMINISHING_BANISH: |
---|
2244 | case DIMINISHING_WARLOCK_FEAR: |
---|
2245 | case DIMINISHING_KNOCKOUT: |
---|
2246 | return DRTYPE_PLAYER; |
---|
2247 | } |
---|
2248 | |
---|
2249 | return DRTYPE_NONE; |
---|
2250 | } |
---|