@@ -126,9 +126,7 @@ void SummonInfo::HandlePreSummonActions()
126126 if (IsControlledBySummoner ())
127127 _summonedCreature->SetCreatorGUID (summoner->GetGUID ());
128128
129- // Pets are set to Assist by default (this does not apply for class pets which save their states)
130- if (_control == SummonPropertiesControl::Pet)
131- _summonedCreature->SetReactState (REACT_ASSIST);
129+ initializeReactState ();
132130
133131 // Totem slot summons always send the TotemCreated packet. Some non-Shaman classes use this
134132 // to display summon icons that can be canceled (Consecration, DK ghouls, Wild Mushrooms)
@@ -187,6 +185,10 @@ void SummonInfo::HandlePostSummonActions()
187185 }
188186 }
189187
188+ // Set the critter guid if the summoned creature is a companion
189+ if (_summonSlot == SummonPropertiesSlot::Critter)
190+ summoner->SetCritterGUID (_summonedCreature->GetGUID ());
191+
190192 // Infoke JustSummoned and IsSummonedBy AI hooks
191193 if (summoner->IsCreature () && summoner->IsAIEnabled ())
192194 summoner->ToCreature ()->AI ()->JustSummoned (_summonedCreature);
@@ -214,6 +216,10 @@ void SummonInfo::HandlePreUnsummonActions()
214216 player->SendRemoveControlBar ();
215217 }
216218
219+ // Clear the critter guid if the summoned creature was a companion
220+ if (_summonSlot == SummonPropertiesSlot::Critter && summoner->GetCritterGUID () == _summonedCreature->GetGUID ())
221+ summoner->SetCritterGUID (ObjectGuid::Empty);
222+
217223 if (summoner->IsCreature () && summoner->IsAIEnabled ())
218224 summoner->ToCreature ()->AI ()->SummonedCreatureDespawn (_summonedCreature);
219225}
@@ -353,3 +359,29 @@ void SummonInfo::castPassiveSpells()
353359 }
354360 }
355361}
362+ void SummonInfo::initializeReactState ()
363+ {
364+ switch (_control)
365+ {
366+ case SummonPropertiesControl::Guardian:
367+ if (_flags.HasFlag (SummonPropertiesFlags::GuardianActsLikePet))
368+ _summonedCreature->SetReactState (REACT_ASSIST);
369+ else
370+ _summonedCreature->SetReactState (REACT_AGGRESSIVE);
371+ break ;
372+ case SummonPropertiesControl::Pet:
373+ // Player pets default to assist while creature summons retain their original state
374+ if (!_hasBeenSummonedByCreature)
375+ _summonedCreature->SetReactState (REACT_ASSIST);
376+ else if (CharmInfo* charmInfo = _summonedCreature->GetCharmInfo ())
377+ charmInfo->RestoreState ();
378+ break ;
379+ case SummonPropertiesControl::Possessed:
380+ _summonedCreature->SetReactState (REACT_PASSIVE);
381+ break ;
382+ default :
383+ if (CharmInfo* charmInfo = _summonedCreature->GetCharmInfo ())
384+ charmInfo->RestoreState ();
385+ break ;
386+ }
387+ }
0 commit comments