|
53 | 53 | #include "SpellMgr.h" |
54 | 54 | #include "SummonInfo.h" |
55 | 55 | #include "TemporarySummon.h" |
| 56 | +#include "TotemPackets.h" |
56 | 57 | #include "Transport.h" |
57 | 58 | #include "Util.h" |
58 | 59 | #include "Vehicle.h" |
@@ -317,11 +318,15 @@ void Creature::AddToWorld() |
317 | 318 | if (IsVehicle()) |
318 | 319 | GetVehicleKit()->Install(); |
319 | 320 |
|
320 | | - // If the creature has been summoned, register it for the summoner |
321 | 321 | if (SummonInfo* summonInfo = GetSummonInfo()) |
| 322 | + { |
| 323 | + // If the creature has been summoned, register it for the summoner |
322 | 324 | if (Unit* summoner = summonInfo->GetUnitSummoner()) |
323 | 325 | summoner->RegisterSummon(summonInfo); |
324 | 326 |
|
| 327 | + HandlePostSummonActions(); |
| 328 | + } |
| 329 | + |
325 | 330 | if (GetZoneScript()) |
326 | 331 | GetZoneScript()->OnCreatureCreate(this); |
327 | 332 | } |
@@ -2808,6 +2813,45 @@ bool Creature::IsSummon() const |
2808 | 2813 | return _summonInfo != nullptr; |
2809 | 2814 | } |
2810 | 2815 |
|
| 2816 | +void Creature::HandlePostSummonActions() |
| 2817 | +{ |
| 2818 | + SummonInfo* summonInfo = ASSERT_NOTNULL(GetSummonInfo()); |
| 2819 | + |
| 2820 | + if (Unit* summoner = summonInfo->GetUnitSummoner()) |
| 2821 | + { |
| 2822 | + SummonPropertiesSlot slot = summonInfo->GetSummonSlot(); |
| 2823 | + |
| 2824 | + // Controlled summons always set their creator guid, which is being used to display summoner names in their title |
| 2825 | + if (summonInfo->IsControlledBySummoner()) |
| 2826 | + SetCreatorGUID(summoner->GetGUID()); |
| 2827 | + |
| 2828 | + // Totem slot summons always send the TotemCreated packet. Some non-Shaman classes use this |
| 2829 | + // to display summon icons that can be canceled (Consecration, DK ghouls, Wild Mushrooms) |
| 2830 | + switch (slot) |
| 2831 | + { |
| 2832 | + case SummonPropertiesSlot::Totem1: |
| 2833 | + case SummonPropertiesSlot::Totem2: |
| 2834 | + case SummonPropertiesSlot::Totem3: |
| 2835 | + case SummonPropertiesSlot::Totem4: |
| 2836 | + { |
| 2837 | + if (Player* playerSummoner = Object::ToPlayer(summoner)) |
| 2838 | + { |
| 2839 | + WorldPackets::Totem::TotemCreated totemCreated; |
| 2840 | + totemCreated.Totem = GetGUID(); |
| 2841 | + totemCreated.SpellID = GetUInt32Value(UNIT_CREATED_BY_SPELL); |
| 2842 | + totemCreated.Duration = summonInfo->GetRemainingDuration().value_or(0ms).count(); |
| 2843 | + totemCreated.Slot = AsUnderlyingType(summonInfo->GetSummonSlot()) - 1; |
| 2844 | + |
| 2845 | + playerSummoner->SendDirectMessage(totemCreated.Write()); |
| 2846 | + } |
| 2847 | + break; |
| 2848 | + } |
| 2849 | + default: |
| 2850 | + break; |
| 2851 | + } |
| 2852 | + } |
| 2853 | +} |
| 2854 | + |
2811 | 2855 | void Creature::AllLootRemovedFromCorpse() |
2812 | 2856 | { |
2813 | 2857 | if (loot.loot_type != LOOT_SKINNING && !IsPet() && GetCreatureTemplate()->SkinLootId && hasLootRecipient()) |
|
0 commit comments