Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
SpellAuraMisc.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Battlefield.h"
7#include "BattlefieldMgr.h"
8#include "Battleground.h"
9#include "CellImpl.h"
10#include "Common.h"
11#include "Formulas.h"
12#include "GridNotifiers.h"
13#include "GridNotifiersImpl.h"
14#include "Log.h"
15#include "ObjectAccessor.h"
16#include "ObjectMgr.h"
17#include "Opcodes.h"
18#include "OutdoorPvPMgr.h"
19#include "Pet.h"
20#include "Player.h"
21#include "ReputationMgr.h"
22#include "ScriptMgr.h"
23#include "Spell.h"
24#include "SpellAuraEffects.h"
25#include "SpellAuraMetadata.h"
26#include "SpellMgr.h"
27#include "SpellValidation.h"
28#include "Unit.h"
29#include "Util.h"
30#include "Vehicle.h"
31#include "WeatherMgr.h"
32#include "WorldPacket.h"
33
34class Aura;
35
36void AuraEffect::HandleArenaPreparation(AuraApplication const* aurApp, uint8 mode, bool apply) const
37{
38 if (!(mode & AURA_EFFECT_HANDLE_REAL))
39 return;
40
41 Unit* target = aurApp->GetTarget();
42
43 if (apply)
45 else
46 {
47 // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
48 if (target->HasAuraType(GetAuraType()))
49 return;
51 }
52}
53
54void AuraEffect::HandleAuraRetainComboPoints(AuraApplication const* aurApp, uint8 mode, bool apply) const
55{
56 if (!(mode & AURA_EFFECT_HANDLE_REAL))
57 return;
58
59 Unit* target = aurApp->GetTarget();
60
61 if (target->GetTypeId() != TypeID::TYPEID_PLAYER)
62 return;
63
64 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
65 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
66 if (!(apply) && GetBase()->GetDuration() == 0 && target->ToPlayer()->GetComboTarget())
67 if (Unit* unit = ObjectAccessor::GetUnit(*target, target->ToPlayer()->GetComboTarget()))
68 target->ToPlayer()->AddComboPoints(unit, -GetAmount());
69}
70
71/*********************************************************/
72/*** OTHERS ***/
73/*********************************************************/
74
75void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool apply) const
76{
78 return;
79
80 Unit* target = aurApp->GetTarget();
81
82 Unit* caster = GetCaster();
83
84 if (mode & AURA_EFFECT_HANDLE_REAL)
85 {
86 // pet auras
87 if (PetAura const* petSpell = sSpellMgr->GetPetAura(GetId(), m_effIndex))
88 {
89 if (apply)
90 target->AddPetAura(petSpell);
91 else
92 target->RemovePetAura(petSpell);
93 }
94 }
95
97 {
98 // AT APPLY
99 if (apply)
100 {
101 switch (GetId())
102 {
103 case 1515: // Tame beast
104 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
105 if (caster && target->CanHaveThreatList())
106 target->AddThreat(caster, 10.0f);
107 break;
108 case 13139: // net-o-matic
109 // root to self part of (root_target->charge->root_self sequence
110 if (caster)
111 caster->CastSpell(caster, Skyfire::Spells::GetNetOMaticRootSelfSpellId(), true, NULL, this);
112 break;
113 case 34026: // kill command
114 {
115 Unit* pet = target->GetGuardianPet();
116 if (!pet)
117 break;
118
119 target->CastSpell(target, Skyfire::Spells::GetKillCommandOwnerAuraSpellId(), true, NULL, this);
120
121 // set 3 stacks and 3 charges (to make all auras not disappear at once)
124 if (owner_aura)
125 {
126 owner_aura->SetStackAmount(owner_aura->GetSpellInfo()->StackAmount);
127 if (pet_aura)
128 {
129 pet_aura->SetCharges(0);
130 pet_aura->SetStackAmount(owner_aura->GetSpellInfo()->StackAmount);
131 }
132 }
133 break;
134 }
135 case 37096: // Blood Elf Illusion
136 {
137 if (caster)
138 {
139 uint32 disguiseSpellId =
141 if (disguiseSpellId)
142 caster->CastSpell(target, disguiseSpellId, true, NULL, this);
143 }
144 break;
145 }
146 case 39850: // Rocket Blast
147 if (roll_chance_i(20)) // backfire stun
148 target->CastSpell(target, Skyfire::Spells::GetAuraDummyTriggeredSpellId(GetId()), true, NULL, this);
149 break;
150 case 43873: // Headless Horseman Laugh
151 target->PlayDistanceSound(11965, target->ToPlayer());
152 break;
153 case 46354: // Blood Elf Illusion
154 if (caster)
155 {
156 uint32 disguiseSpellId =
158 if (disguiseSpellId)
159 caster->CastSpell(target, disguiseSpellId, true, NULL, this);
160 }
161 break;
162 case 46361: // Reinforced Net
163 if (caster)
164 target->GetMotionMaster()->MoveFall();
165 break;
166 case 51701: // Honor Among Thieves
167 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
168 if (Unit* spellTarget = ObjectAccessor::GetUnit(*target, target->ToPlayer()->GetComboTarget()))
170 break;
171 case 71563:
172 if (Aura* newAura = target->AddAura(Skyfire::Spells::GetAuraDummyTriggeredSpellId(GetId()), target))
173 newAura->SetStackAmount(newAura->GetSpellInfo()->StackAmount);
174 break;
175 }
176 }
177 // AT REMOVE
178 else
179 {
180 if ((GetSpellInfo()->IsQuestTame()) && caster && caster->IsAlive() && target->IsAlive())
181 {
183
184 if (finalSpellId)
185 caster->CastSpell(target, finalSpellId, true, NULL, this);
186 }
187
188 switch (m_spellInfo->SpellFamilyName)
189 {
191 switch (GetId())
192 {
193 case 2584: // Waiting to Resurrect
194 // Waiting to resurrect spell cancel, we must remove player from resurrect queue
195 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
196 {
197 if (Battleground* bg = target->ToPlayer()->GetBattleground())
198 bg->RemovePlayerFromResurrectQueue(target->GetGUID());
199 if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(target->GetZoneId()))
200 bf->RemovePlayerFromResurrectQueue(target->GetGUID());
201 }
202 break;
203 case 36730: // Flame Strike
204 {
205 target->CastSpell(target,
207 true, NULL, this);
208 break;
209 }
210 case 44191: // Flame Strike
211 {
212 if (target->GetMap()->IsInstance())
213 {
215 target->GetMap()->IsHeroic());
216
217 target->CastSpell(target, spellId, true, NULL, this);
218 }
219 break;
220 }
221 case 43681: // Inactive
222 {
224 return;
225
226 if (target->GetMap()->IsBattleground())
227 target->ToPlayer()->LeaveBattleground();
228 break;
229 }
230 case 42783: // Wrath of the Astromancer
231 target->CastSpell(target, GetAmount(), true, NULL, this);
232 break;
233 case 46308: // Burning Winds casted only at creatures at spawn
234 target->CastSpell(target,
236 true, NULL, this);
237 break;
238 case 52172: // Coyote Spirit Despawn Aura
239 case 60244: // Blood Parrot Despawn Aura
240 case 130067: // Terracotta Warrior Despawn Aura
241 case 130070: // Whirlwind of Blades Despawn Aura
242 case 130108: // Martar Despawn Aura
243 case 130112: // Feverbite Despawn Aura
244 case 130119: // Kidnapped Puppies Despawn Aura
245 case 130156: // Tranquil Sprout Despawn Aura
246 case 130484: // Quilen Statuette Despawn Aura
247 case 148596: // Barnacle Crew Despawn Aura
249 target->CastSpell((Unit*)NULL, GetAmount(), true, NULL, this);
250 break;
251 case 91604: // Restricted Flight Area
252 if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE)
253 target->CastSpell(target,
255 true);
256 break;
257 }
258 break;
260 // Summon Gargoyle (Dismiss Gargoyle at remove)
261 if (GetId() == 61777)
262 target->CastSpell(target, GetAmount(), true);
263 break;
264 default:
265 break;
266 }
267 }
268 }
269
270 // AT APPLY & REMOVE
271
272 switch (m_spellInfo->SpellFamilyName)
273 {
275 {
276 if (!(mode & AURA_EFFECT_HANDLE_REAL))
277 break;
278 switch (GetId())
279 {
280 // Recently Bandaged
281 case 11196:
283 break;
284 // Unstable Power
285 case 24658:
286 {
288 if (apply && caster)
289 {
290 SpellInfo const* spell = sSpellMgr->GetSpellInfo(spellId);
291
292 for (uint32 i = 0; i < spell->StackAmount; ++i)
293 caster->CastSpell(target, spell->Id, true, NULL, NULL, GetCasterGUID());
294 break;
295 }
296 target->RemoveAurasDueToSpell(spellId);
297 break;
298 }
299 // Restless Strength
300 case 24661:
301 {
303 if (apply && caster)
304 {
305 SpellInfo const* spell = sSpellMgr->GetSpellInfo(spellId);
306 for (uint32 i = 0; i < spell->StackAmount; ++i)
307 caster->CastSpell(target, spell->Id, true, NULL, NULL, GetCasterGUID());
308 break;
309 }
310 target->RemoveAurasDueToSpell(spellId);
311 break;
312 }
313 // Tag Murloc
314 case 30877:
315 {
316 // Tag/untag Blacksilt Scout
318 break;
319 }
320 // LK Intro VO (1)
321 case 58204:
322 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
323 {
324 // Play part 1
325 if (apply)
327 // continue in 58205
328 else
330 }
331 break;
332 // LK Intro VO (2)
333 case 58205:
334 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
335 {
336 // Play part 2
337 if (apply)
339 // Play part 3
340 else
342 }
343 break;
344 case 62061: // Festive Holiday Mount
345 if (target->HasAuraType(SPELL_AURA_MOUNTED))
346 {
347 uint32 creatureEntry = 0;
348 if (apply)
349 {
352 else
354 }
355 else
356 creatureEntry = target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).front()->GetMiscValue();
357
358 if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry))
359 {
360 uint32 displayID = ObjectMgr::ChooseDisplayId(creatureInfo);
361 sObjectMgr->GetCreatureModelRandomGender(&displayID);
362
364 }
365 }
366 break;
367 default:
368 {
369 Skyfire::Spells::ChampioningAuraInfo const* championingAura =
371 if (!championingAura || !caster || caster->GetTypeId() != TypeID::TYPEID_PLAYER)
372 break;
373
374 uint32 factionId = apply ? championingAura->FactionId : 0;
375 uint8 championingType = apply ? championingAura->ChampioningType : 0;
376 caster->ToPlayer()->SetChampioningFaction(factionId);
377 caster->ToPlayer()->SetChampioningType(championingType);
378 break;
379 }
380 }
381 break;
382 }
383 default:
384 break;
385 }
386}
387
388void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mode, bool apply) const
389{
390 if (!(mode & AURA_EFFECT_HANDLE_REAL))
391 return;
392
393 if (apply || aurApp->GetRemoveMode() != AURA_REMOVE_BY_DEATH)
394 return;
395
396 Unit* caster = GetCaster();
397
398 if (!caster || caster->GetTypeId() != TypeID::TYPEID_PLAYER)
399 return;
400
401 Player* plCaster = caster->ToPlayer();
402
403 // Item amount
404 if (GetAmount() <= 0)
405 return;
406
407 if (GetSpellInfo()->Effects[m_effIndex].ItemType == 0)
408 return;
409
410 //Adding items
411 uint32 noSpaceForCount = 0;
412 uint32 count = m_amount;
413
414 ItemPosCountVec dest;
415 InventoryResult msg = plCaster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellInfo()->Effects[m_effIndex].ItemType, count, &noSpaceForCount);
416 if (msg != EQUIP_ERR_OK)
417 {
418 count -= noSpaceForCount;
419 plCaster->SendEquipError(msg, NULL, NULL, GetSpellInfo()->Effects[m_effIndex].ItemType);
420 if (count == 0)
421 return;
422 }
423
424 Item* newitem = plCaster->StoreNewItem(dest, GetSpellInfo()->Effects[m_effIndex].ItemType, true);
425 if (!newitem)
426 {
427 plCaster->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
428 return;
429 }
430 plCaster->SendNewItem(newitem, count, true, true);
431}
432
433void AuraEffect::HandleBindSight(AuraApplication const* aurApp, uint8 mode, bool apply) const
434{
435 if (!(mode & AURA_EFFECT_HANDLE_REAL))
436 return;
437
438 Unit* target = aurApp->GetTarget();
439
440 Unit* caster = GetCaster();
441
442 if (!caster || caster->GetTypeId() != TypeID::TYPEID_PLAYER)
443 return;
444
445 caster->ToPlayer()->SetViewpoint(target, apply);
446}
447
448void AuraEffect::HandleForceReaction(AuraApplication const* aurApp, uint8 mode, bool apply) const
449{
451 return;
452
453 Unit* target = aurApp->GetTarget();
454
455 Player* player = target->ToPlayer();
456 if (!player)
457 return;
458
459 uint32 factionId = GetMiscValue();
461
462 player->GetReputationMgr().ApplyForceReaction(factionId, factionRank, apply);
464
465 // stop fighting if at apply forced rank friendly or at remove real rank friendly
466 if ((apply && factionRank >= REP_FRIENDLY) || (!apply && player->GetReputationRank(factionId) >= REP_FRIENDLY))
467 player->StopAttackFaction(factionId);
468}
469
470void AuraEffect::HandleAuraEmpathy(AuraApplication const* aurApp, uint8 mode, bool apply) const
471{
472 if (!(mode & AURA_EFFECT_HANDLE_REAL))
473 return;
474
475 Unit* target = aurApp->GetTarget();
476 if (!apply)
477 {
478 // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
479 if (target->HasAuraType(GetAuraType()))
480 return;
481 }
482
483 if (target->GetCreatureType() == CREATURE_TYPE_BEAST)
485}
486
487void AuraEffect::HandleAuraModFaction(AuraApplication const* aurApp, uint8 mode, bool apply) const
488{
489 if (!(mode & AURA_EFFECT_HANDLE_REAL))
490 return;
491
492 Unit* target = aurApp->GetTarget();
493
494 if (apply)
495 {
496 target->setFaction(GetMiscValue());
497 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
499 }
500 else
501 {
502 target->RestoreFaction();
503 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
505 }
506}
507
508void AuraEffect::HandleComprehendLanguage(AuraApplication const* aurApp, uint8 mode, bool apply) const
509{
511 return;
512
513 Unit* target = aurApp->GetTarget();
514
515 if (apply)
517 else
518 {
519 if (target->HasAuraType(GetAuraType()))
520 return;
521
523 }
524}
525
526void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode, bool apply) const
527{
528 if (!(mode & AURA_EFFECT_HANDLE_REAL))
529 return;
530
531 Unit* target = aurApp->GetTarget();
532
533 Player* player = target->ToPlayer();
534 if (!player)
535 return;
536
537 if (player->getClass() != CLASS_DEATH_KNIGHT)
538 return;
539
540 uint32 runes = m_amount;
541 // convert number of runes specified in aura amount of rune type in miscvalue to runetype in miscvalueb
542 if (apply)
543 {
544 for (uint32 i = 0; i < MAX_RUNES && runes; ++i)
545 {
546 if (RuneType(GetMiscValue()) != player->GetCurrentRune(i))
547 continue;
548 if (!player->GetRuneCooldown(i))
549 {
550 player->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this);
551 --runes;
552 }
553 }
554 }
555 else
556 player->RemoveRunesByAuraEffect(this);
557}
558
559void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, bool apply) const
560{
561 Unit* target = aurApp->GetTarget();
562
563 uint32 triggeredSpellId = sSpellMgr->GetSpellIdForDifficulty(m_spellInfo->Effects[m_effIndex].TriggerSpell, target);
564 SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggeredSpellId);
565 if (!triggeredSpellInfo)
566 return;
567
568 if (mode & AURA_EFFECT_HANDLE_REAL)
569 {
570 if (apply)
571 {
572 Unit* caster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCaster() : target;
573
574 if (!caster)
575 return;
576 // If amount avalible cast with basepoints (Crypt Fever for example)
577 if (GetAmount())
578 caster->CastCustomSpell(target, triggeredSpellId, &m_amount, NULL, NULL, true, NULL, this);
579 else
580 caster->CastSpell(target, triggeredSpellId, true, NULL, this);
581 }
582 else
583 {
584 uint64 casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCasterGUID() : target->GetGUID();
585 target->RemoveAura(triggeredSpellId, casterGUID, 0, aurApp->GetRemoveMode());
586 }
587 }
588 else if (mode & AURA_EFFECT_HANDLE_REAPPLY && apply)
589 {
590 uint64 casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCasterGUID() : target->GetGUID();
591 // change the stack amount to be equal to stack amount of our aura
592 if (Aura* triggeredAura = target->GetAura(triggeredSpellId, casterGUID))
593 triggeredAura->ModStackAmount(GetBase()->GetStackAmount() - triggeredAura->GetStackAmount());
594 }
595}
596
597void AuraEffect::HandleAuraModFakeInebriation(AuraApplication const* aurApp, uint8 mode, bool apply) const
598{
600 return;
601
602 Unit* target = aurApp->GetTarget();
603
604 if (apply)
605 {
608
609 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
610 {
613 }
614 }
615 else
616 {
617 bool removeDetect = !target->HasAuraType(SPELL_AURA_MOD_FAKE_INEBRIATE);
618
620
621 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
622 {
625
626 if (removeDetect)
627 removeDetect = !target->ToPlayer()->GetDrunkValue();
628 }
629
630 if (removeDetect)
632 }
633
634 // call functions which may have additional effects after chainging state of unit
635 target->UpdateObjectVisibility();
636}
637
638void AuraEffect::HandleAuraOverrideSpells(AuraApplication const* aurApp, uint8 mode, bool apply) const
639{
640 if (!(mode & AURA_EFFECT_HANDLE_REAL))
641 return;
642
643 Player* target = aurApp->GetTarget()->ToPlayer();
644
645 if (!target || !target->IsInWorld())
646 return;
647
648 uint32 overrideId = uint32(GetMiscValue());
649
650 if (apply)
651 {
652 //target->SetUInt16Value(PLAYER_FIELD_LIFETIME_MAX_RANK2, 0, overrideId);
653 if (OverrideSpellDataEntry const* overrideSpells = sOverrideSpellDataStore.LookupEntry(overrideId))
654 for (uint8 i = 0; i < MAX_OVERRIDE_SPELL; ++i)
655 if (uint32 spellId = overrideSpells->spellId[i])
656 target->AddTemporarySpell(spellId);
657 }
658 else
659 {
660 //target->SetUInt16Value(PLAYER_FIELD_LIFETIME_MAX_RANK2, 0, 0);
661 if (OverrideSpellDataEntry const* overrideSpells = sOverrideSpellDataStore.LookupEntry(overrideId))
662 for (uint8 i = 0; i < MAX_OVERRIDE_SPELL; ++i)
663 if (uint32 spellId = overrideSpells->spellId[i])
664 target->RemoveTemporarySpell(spellId);
665 }
666}
667
668void AuraEffect::HandleAuraSetVehicle(AuraApplication const* aurApp, uint8 mode, bool apply) const
669{
670 if (!(mode & AURA_EFFECT_HANDLE_REAL))
671 return;
672
673 Unit* target = aurApp->GetTarget();
674
675 if (!target->IsInWorld())
676 return;
677
678 uint32 vehicleId = GetMiscValue();
679
680 if (apply)
681 {
682 if (!target->CreateVehicleKit(vehicleId, 0))
683 return;
684 }
685 else if (target->GetVehicleKit())
686 target->RemoveVehicleKit();
687
688 if (target->GetTypeId() != TypeID::TYPEID_PLAYER)
689 return;
690
691 if (apply)
693}
694
695void AuraEffect::HandlePreventResurrection(AuraApplication const* aurApp, uint8 mode, bool apply) const
696{
697 if (!(mode & AURA_EFFECT_HANDLE_REAL))
698 return;
699
700 if (aurApp->GetTarget()->GetTypeId() != TypeID::TYPEID_PLAYER)
701 return;
702
703 if (apply)
705 else if (!aurApp->GetTarget()->GetBaseMap()->Instanceable())
707}
708
709void AuraEffect::HandleAuraMastery(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const
710{
711 if (!(mode & AURA_EFFECT_HANDLE_REAL))
712 return;
713
714 Player* target = aurApp->GetTarget()->ToPlayer();
715 if (!target)
716 return;
717
718 target->UpdateMastery();
719}
720
721void AuraEffect::HandleAuraForceWeather(AuraApplication const* aurApp, uint8 mode, bool apply) const
722{
723 if (!(mode & AURA_EFFECT_HANDLE_REAL))
724 return;
725
726 Player* target = aurApp->GetTarget()->ToPlayer();
727
728 if (!target)
729 return;
730
731 if (apply)
732 {
733 WorldPacket data(SMSG_WEATHER, 4 + 4 + 1);
734 data << uint32(GetMiscValue()); // WeatherID
735 data << float(1.0f); // Intensity
736 data.WriteBit(false); // Abrupt
737 data.FlushBits();
738 target->GetSession()->SendPacket(&data);
739 }
740 else
741 {
742 // send weather for current zone
743 if (Weather* weather = WeatherMgr::FindWeather(target->GetZoneId()))
744 weather->SendWeatherUpdateToPlayer(target);
745 else
746 {
747 if (!WeatherMgr::AddWeather(target->GetZoneId()))
748 {
749 // send fine weather packet to remove old weather
751 }
752 }
753 }
754}
755
756void AuraEffect::HandleEnableAltPower(AuraApplication const* aurApp, uint8 mode, bool apply) const
757{
758 if (!(mode & AURA_EFFECT_HANDLE_REAL))
759 return;
760
761 uint32 altPowerId = GetMiscValue();
762 UnitPowerBarEntry const* powerEntry = sUnitPowerBarStore.LookupEntry(altPowerId);
763 if (!powerEntry)
764 return;
765
766 if (apply)
767 aurApp->GetTarget()->SetMaxPower(POWER_ALTERNATE_POWER, powerEntry->MaxPower);
768 else
770}
771
773{
775 return;
776
777 Player* target = aurApp->GetTarget()->ToPlayer();
778 if (!target)
779 return;
780
783}
784
786{
787 if (!(mode & AURA_EFFECT_HANDLE_REAL))
788 return;
789
790 Unit* target = aurApp->GetTarget();
791
792 if (apply)
793 {
794 SpellInfo const* overrideSpell = sSpellMgr->GetSpellInfo(m_spellInfo->Effects[GetEffIndex()].TriggerSpell);
795 target->SetAutoattackOverrideRange(overrideSpell->GetMaxRange());
796 target->SetAutoattackOverrideSpell(overrideSpell);
797 }
798 else
799 {
802 }
803}
804
806{
808 return;
809
810 Player* target = aurApp->GetTarget()->ToPlayer();
811 if (!target)
812 return;
813
816 target->UpdateAttackPowerAndDamage(true);
817}
818
819void AuraEffect::HandlePlayScene(AuraApplication const* aurApp, uint8 mode, bool apply) const
820{
821 if (!(mode & AURA_EFFECT_HANDLE_REAL))
822 return;
823
824 Player* target = aurApp->GetTarget()->ToPlayer();
825 if (!target)
826 return;
827
828 SceneTemplate const* sceneTemplate = sObjectMgr->GetSceneTemplate(GetMiscValue());
829 if (!sceneTemplate)
830 {
831 SF_LOG_ERROR("spells", "SceneTemplate: %u does not exist in database.", GetMiscValue());
832 return;
833 }
834
835 // check db2 if packageid exists
836 SceneScriptPackageEntry const* entry = sSceneScriptPackageStore.LookupEntry(sceneTemplate->ScenePackageId);
837 if (!entry)
838 {
839 SF_LOG_ERROR("spells", "ScenePackageID: %u does not exist in db2.", sceneTemplate->ScenePackageId);
840 return;
841 }
842
843 ObjectGuid transportGUID = target->GetTransGUID();
844 float PositionX = target->GetPositionX();
845 float PositionY = target->GetPositionY();
846 float PositionZ = target->GetPositionZ();
847 float PositionO = target->GetOrientation();
848 bool hasSceneID = sceneTemplate->SceneId;
849 bool hasSceneFlags = sceneTemplate->PlaybackFlags;
850 bool hasSceneScriptPackageID = sceneTemplate->ScenePackageId;
851 uint32 sceneInstanceID = 0;
852 if (!sceneInstanceID)
853 ++sceneInstanceID;
854 if (apply)
855 {
856 WorldPacket data(SMSG_PLAY_SCENE, 4 + 4 + 4 + 1 + 8 + 4 + 4 + 4 + 4 + 4);
857 data << float(PositionY);
858 data << float(PositionZ);
859 data << float(PositionX);
860
861 data.WriteBit(!hasSceneFlags);
862 data.WriteBit(!sceneInstanceID);
863 data.WriteBit(!PositionO);
864 data.WriteBit(!hasSceneID);
865 data.WriteBit(!hasSceneScriptPackageID);
866 data.WriteBit(true);
867
868 data.WriteGuidMask(transportGUID, 3, 2, 6, 4, 7, 1, 5, 0);
869 data.FlushBits();
870 data.WriteGuidBytes(transportGUID, 6, 3, 5, 4, 1, 2, 0, 7);
871
872 if (hasSceneFlags)
873 data << uint32(sceneTemplate->PlaybackFlags);
874 if (PositionO)
875 data << float(PositionO);
876 if (hasSceneID)
877 data << uint32(sceneTemplate->SceneId);
878 if (sceneInstanceID)
879 data << uint32(sceneInstanceID);
880 if (hasSceneScriptPackageID)
881 data << uint32(sceneTemplate->ScenePackageId);
882
883 target->GetSession()->SendPacket(&data);
884 }
885 else
886 {
887 WorldPacket data(SMSG_CANCEL_SCENE, 4 + 1);
888 data.WriteBit(!sceneInstanceID);
889 data.FlushBits();
890 data << uint32(sceneInstanceID); // SceneInstanceID
891 target->GetSession()->SendPacket(&data);
892 }
893}
#define sBattlefieldMgr
DB2Storage< SceneScriptPackageEntry > sSceneScriptPackageStore(SceneScriptPackagefmt)
DBCStorage< UnitPowerBarEntry > sUnitPowerBarStore(UnitPowerBarfmt)
DBCStorage< OverrideSpellDataEntry > sOverrideSpellDataStore(OverrideSpellDatafmt)
#define MAX_OVERRIDE_SPELL
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::uint64_t uint64
Definition Define.h:76
InventoryResult
Definition Item.h:27
@ EQUIP_ERR_ITEM_NOT_FOUND
Definition Item.h:51
@ EQUIP_ERR_OK
Definition Item.h:28
#define SF_LOG_ERROR(filterType__,...)
Definition Log.h:143
@ TYPEID_PLAYER
Definition Object.h:55
#define sObjectMgr
Definition ObjectMgr.h:1617
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:777
RuneType
Definition Player.h:485
#define MAX_RUNES
Definition Player.h:476
@ PLAYER_FIELD_BYTE_RELEASE_TIMER
Definition Player.h:578
@ POWER_ALTERNATE_POWER
@ CREATURE_TYPE_BEAST
@ INVISIBILITY_DRUNK
@ UNIT_DYNFLAG_SPECIALINFO
@ CLASS_DEATH_KNIGHT
@ IMMUNITY_MECHANIC
@ SPELLFAMILY_GENERIC
@ SPELLFAMILY_DEATHKNIGHT
ReputationRank
@ REP_FRIENDLY
@ SPELL_AURA_MOD_FAKE_INEBRIATE
@ SPELL_AURA_MOUNTED
@ SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED
@ AURA_EFFECT_HANDLE_STAT
@ AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK
@ AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK
@ AURA_EFFECT_HANDLE_REAPPLY
@ AURA_EFFECT_HANDLE_REAL
#define sSpellMgr
Definition SpellMgr.h:744
@ AURA_REMOVE_BY_DEATH
Definition Unit.h:411
@ AURA_REMOVE_BY_EXPIRE
Definition Unit.h:410
@ NULL_BAG
Definition Unit.h:336
@ NULL_SLOT
Definition Unit.h:337
@ UNIT_FLAG_PREPARATION
Definition Unit.h:630
@ UNIT_FLAG_PVP_ATTACKABLE
Definition Unit.h:628
@ UNIT_FLAG2_COMPREHEND_LANG
Definition Unit.h:666
@ UNIT_FIELD_FLAGS2
@ UNIT_FIELD_MOUNT_DISPLAY_ID
@ UNIT_FIELD_FLAGS
@ OBJECT_FIELD_DYNAMIC_FLAGS
@ PLAYER_FIELD_OVERRIDE_APBY_SPELL_POWER_PERCENT
@ PLAYER_FIELD_LIFETIME_MAX_RANK
@ PLAYER_FIELD_OVERRIDE_SPELL_POWER_BY_APPERCENT
@ PLAYER_FIELD_FAKE_INEBRIATION
bool roll_chance_i(int chance)
Definition Util.h:89
Unit * GetTarget() const
Definition SpellAuras.h:54
AuraRemoveMode GetRemoveMode() const
Definition SpellAuras.h:66
void HandleEnableAltPower(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleAuraRetainComboPoints(AuraApplication const *aurApp, uint8 mode, bool apply) const
SpellInfo const * GetSpellInfo() const
AuraType GetAuraType() const
void HandleAuraEmpathy(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleOverrideAttackPowerBySpellPower(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleAuraModFaction(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleAuraSetVehicle(AuraApplication const *aurApp, uint8 mode, bool apply) const
uint8 const m_effIndex
void HandleForceReaction(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleArenaPreparation(AuraApplication const *aurApp, uint8 mode, bool apply) const
uint32 GetId() const
void HandlePreventResurrection(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleAuraModFakeInebriation(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandlePlayScene(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleAuraMastery(AuraApplication const *aurApp, uint8 mode, bool apply) const
int32 GetMiscValueB() const
void HandleComprehendLanguage(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleOverrideSpellPowerByAttackPower(AuraApplication const *aurApp, uint8 mode, bool apply) const
Unit * GetCaster() const
int32 GetMiscValue() const
void HandleAuraConvertRune(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleChannelDeathItem(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleAuraOverrideAutoattackWithSpell(AuraApplication const *aurApp, uint8 mode, bool apply) const
Aura * GetBase() const
void HandleAuraDummy(AuraApplication const *aurApp, uint8 mode, bool apply) const
uint32 GetEffIndex() const
SpellInfo const *const m_spellInfo
void HandleAuraForceWeather(AuraApplication const *aurApp, uint8 mode, bool apply) const
uint64 GetCasterGUID() const
void HandleBindSight(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleAuraOverrideSpells(AuraApplication const *aurApp, uint8 mode, bool apply) const
void HandleAuraLinked(AuraApplication const *aurApp, uint8 mode, bool apply) const
int32 GetAmount() const
void SetStackAmount(uint8 num)
void SetCharges(uint8 charges)
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:87
void WriteGuidBytes(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:264
bool WriteBit(uint32 bit)
Definition ByteBuffer.h:164
void WriteGuidMask(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:248
void FlushBits()
Definition ByteBuffer.h:154
void AddFlag(FLAG_TYPE flag)
Definition Object.h:575
void DelFlag(FLAG_TYPE flag)
Definition Object.h:576
void AddValue(FLAG_TYPE flag, T_VALUES value)
Definition Object.h:580
Definition Item.h:202
bool IsBattleground() const
Definition Map.h:376
bool Instanceable() const
Definition Map.h:367
bool IsHeroic() const
Definition Map.cpp:3044
bool IsInstance() const
Definition Map.h:368
void MoveFall(uint32 id=0)
static Unit * GetUnit(WorldObject const &, uint64 guid)
void ApplyModSignedFloatValue(uint16 index, float val, bool apply)
Definition Object.cpp:1238
int32 GetInt32Value(uint16 index) const
Definition Object.cpp:319
void SetInt32Value(uint16 index, int32 value)
Definition Object.cpp:1021
uint64 GetGUID() const
Definition Object.h:119
Player * ToPlayer()
Definition Object.h:204
bool IsInWorld() const
Definition Object.h:114
TypeID GetTypeId() const
Definition Object.h:131
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:1261
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:1280
void ApplyModUInt32Value(uint16 index, int32 val, bool apply)
Definition Object.cpp:1222
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition Object.cpp:1345
void SetEntry(uint32 entry)
Definition Object.h:126
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:1038
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition Object.cpp:1322
static uint32 ChooseDisplayId(CreatureTemplate const *cinfo, CreatureData const *data=NULL)
void UpdateMastery()
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=NULL, uint32 itemid=0)
void RemoveRunesByAuraEffect(AuraEffect const *aura)
Definition Player.cpp:20552
void SetChampioningType(uint8 type)
Definition Player.h:3134
uint8 GetDrunkValue() const
Definition Player.h:2594
void AddComboPoints(Unit *target, int8 count, Spell *spell=NULL)
Definition Player.cpp:18439
void AddTemporarySpell(uint32 spellId)
Definition Player.cpp:3971
void LeaveBattleground(bool teleportToEntryPoint=true)
Definition Player.cpp:17984
void SendOnCancelExpectedVehicleRideAura()
Definition Player.cpp:15878
void RemoveTemporarySpell(uint32 spellId)
Definition Player.cpp:3985
WorldSession * GetSession() const
Definition Player.h:2417
void SetViewpoint(WorldObject *target, bool apply)
Definition Player.cpp:20275
uint32 GetRuneCooldown(uint8 index) const
Definition Player.h:3065
Battleground * GetBattleground() const
Definition Player.cpp:19212
void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const *aura)
Definition Player.cpp:20547
void SetChampioningFaction(uint32 faction)
Definition Player.h:3126
void UpdateSpellDamageAndHealingBonus()
RuneType GetCurrentRune(uint8 index) const
Definition Player.h:3061
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=NULL) const
ReputationRank GetReputationRank(uint32 faction_id) const
Definition Player.cpp:7098
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0, AllowedLooterSet const &allowedLooters=AllowedLooterSet())
uint64 GetComboTarget() const
Definition Player.h:1983
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast=false)
Definition Player.cpp:11604
void UpdateAttackPowerAndDamage(bool ranged=false) override
ReputationMgr & GetReputationMgr()
Definition Player.h:2555
void ApplyForceReaction(uint32 faction_id, ReputationRank rank, bool apply)
void SendForceReactions()
uint32 StackAmount
Definition SpellInfo.h:211
uint32 Id
Definition SpellInfo.h:160
bool NeedsToBeTriggeredByCaster(SpellInfo const *triggeringSpell) const
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Definition Unit.h:1367
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:2243
uint8 getGender() const
Definition Unit.h:1551
void setFaction(uint32 faction)
Definition Unit.h:1699
void RemovePetAura(PetAura const *petSpell)
Definition Unit.cpp:6245
bool CanHaveThreatList() const
Definition Unit.cpp:4424
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
void UpdateObjectVisibility(bool forced=true) override
Definition Unit.cpp:7567
void RestoreFaction()
Definition Unit.cpp:7135
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void AddPetAura(PetAura const *petSpell)
Definition Unit.cpp:6235
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
void RemoveVehicleKit(bool remove=false)
Definition Unit.cpp:7179
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition Unit.cpp:4463
Aura * GetAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
MotionMaster * GetMotionMaster()
Definition Unit.h:2605
Aura * AddAura(uint32 spellId, Unit *target)
uint8 getClass() const
Definition Unit.h:1543
bool IsAlive() const
Definition Unit.h:2032
uint32 GetCreatureType() const
Definition Unit.cpp:4910
uint64 GetTransGUID() const override
Definition Unit.cpp:7217
void SetAutoattackOverrideRange(uint32 range)
Definition Unit.h:2857
void SetAutoattackOverrideSpell(SpellInfo const *spellInfo)
Definition Unit.h:2853
bool HasAuraType(AuraType auraType) const
void StopAttackFaction(uint32 faction_id)
Definition Unit.cpp:8939
bool CreateVehicleKit(uint32 id, uint32 creatureEntry, bool loading=false)
Definition Unit.cpp:7163
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition Unit.cpp:3580
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void SetMaxPower(Powers power, int32 val)
Definition Unit.cpp:5317
Vehicle * GetVehicleKit() const
Definition Unit.h:2739
Guardian * GetGuardianPet() const
Definition Unit.cpp:2390
Weather for one zone.
Definition Weather.h:53
Map * GetMap() const
Definition Object.h:740
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibilityDetect
Definition Object.h:730
Map const * GetBaseMap() const
Definition Object.cpp:2544
void PlayDistanceSound(uint32 sound_id, Player *target)
Definition Object.cpp:3417
uint32 GetZoneId() const
Definition Object.cpp:1597
void PlayDirectSound(uint32 sound_id, Player *target=NULL)
Definition Object.cpp:3442
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
@ SMSG_PLAY_SCENE
Definition Opcodes.h:882
@ SMSG_CANCEL_SCENE
Definition Opcodes.h:594
@ SMSG_WEATHER
Definition Opcodes.h:1065
Weather * AddWeather(uint32 zone_id)
Add a Weather object to the list.
void SendFineWeatherUpdateToPlayer(Player *player)
Weather * FindWeather(uint32 id)
Find a Weather object by the given zoneid.
uint32 GetBloodElfIllusionDisguiseSpellId(uint32 auraSpellId, uint8 gender)
uint32 GetKillCommandOwnerAuraSpellId()
ChampioningAuraInfo const * GetChampioningAuraInfo(uint32 auraSpellId)
uint32 GetLichKingIntroRemoveSoundId(uint32 auraSpellId)
uint32 GetLichKingIntroContinueSpellId(uint32 auraSpellId)
uint32 GetAuraDummyTriggeredSpellId(uint32 auraSpellId)
uint32 GetTaggedMurlocEntry(bool apply)
uint32 GetStackingAuraTriggerSpellId(uint32 auraSpellId)
uint32 GetKillCommandPetAuraSpellId()
uint32 GetQuestTameFinalSpellId(uint32 auraSpellId)
uint32 GetFestiveHolidayMountCreatureEntry(bool flying)
uint32 GetNetOMaticRootSelfSpellId()
uint32 GetLichKingIntroApplySoundId(uint32 auraSpellId)
uint32 GetAuraRemoveTriggeredSpellId(uint32 auraSpellId, bool heroic)
bool IsDespawnOnRemoveAura(uint32 auraSpellId)
float GetPositionZ() const
Definition Object.h:330
float GetOrientation() const
Definition Object.h:331
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329
uint32 SceneId
Definition ObjectMgr.h:587
uint32 PlaybackFlags
Definition ObjectMgr.h:588
uint32 ScenePackageId
Definition ObjectMgr.h:589
uint32 MaxPower