Core/Creatures: further refine react state initialization within SummonInfo API and fixed dismissing companions
This commit is contained in:
1 parent
0e5489a9da
commit
cf8bbd68b9
2 files changed
+37
-3
No files matched your search
@@ -126,9 +126,7 @@ void SummonInfo::HandlePreSummonActions()
|
||||
if (IsControlledBySummoner())
|
||||
_summonedCreature->SetCreatorGUID(summoner->GetGUID());
|
||||
|
||||
// Pets are set to Assist by default (this does not apply for class pets which save their states)
|
||||
if (_control == SummonPropertiesControl::Pet)
|
||||
_summonedCreature->SetReactState(REACT_ASSIST);
|
||||
initializeReactState();
|
||||
|
||||
// Totem slot summons always send the TotemCreated packet. Some non-Shaman classes use this
|
||||
// to display summon icons that can be canceled (Consecration, DK ghouls, Wild Mushrooms)
|
||||
@@ -187,6 +185,10 @@ void SummonInfo::HandlePostSummonActions()
|
||||
}
|
||||
}
|
||||
|
||||
// Set the critter guid if the summoned creature is a companion
|
||||
if (_summonSlot == SummonPropertiesSlot::Critter)
|
||||
summoner->SetCritterGUID(_summonedCreature->GetGUID());
|
||||
|
||||
// Infoke JustSummoned and IsSummonedBy AI hooks
|
||||
if (summoner->IsCreature() && summoner->IsAIEnabled())
|
||||
summoner->ToCreature()->AI()->JustSummoned(_summonedCreature);
|
||||
@@ -214,6 +216,10 @@ void SummonInfo::HandlePreUnsummonActions()
|
||||
player->SendRemoveControlBar();
|
||||
}
|
||||
|
||||
// Clear the critter guid if the summoned creature was a companion
|
||||
if (_summonSlot == SummonPropertiesSlot::Critter && summoner->GetCritterGUID() == _summonedCreature->GetGUID())
|
||||
summoner->SetCritterGUID(ObjectGuid::Empty);
|
||||
|
||||
if (summoner->IsCreature() && summoner->IsAIEnabled())
|
||||
summoner->ToCreature()->AI()->SummonedCreatureDespawn(_summonedCreature);
|
||||
}
|
||||
@@ -353,3 +359,29 @@ void SummonInfo::castPassiveSpells()
|
||||
}
|
||||
}
|
||||
}
|
||||
void SummonInfo::initializeReactState()
|
||||
{
|
||||
switch (_control)
|
||||
{
|
||||
case SummonPropertiesControl::Guardian:
|
||||
if (_flags.HasFlag(SummonPropertiesFlags::GuardianActsLikePet))
|
||||
_summonedCreature->SetReactState(REACT_ASSIST);
|
||||
else
|
||||
_summonedCreature->SetReactState(REACT_AGGRESSIVE);
|
||||
break;
|
||||
case SummonPropertiesControl::Pet:
|
||||
// Player pets default to assist while creature summons retain their original state
|
||||
if (!_hasBeenSummonedByCreature)
|
||||
_summonedCreature->SetReactState(REACT_ASSIST);
|
||||
else if (CharmInfo* charmInfo = _summonedCreature->GetCharmInfo())
|
||||
charmInfo->RestoreState();
|
||||
break;
|
||||
case SummonPropertiesControl::Possessed:
|
||||
_summonedCreature->SetReactState(REACT_PASSIVE);
|
||||
break;
|
||||
default:
|
||||
if (CharmInfo* charmInfo = _summonedCreature->GetCharmInfo())
|
||||
charmInfo->RestoreState();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,8 @@ public:
|
||||
private:
|
||||
// Looks up and casts all passive spells of the creature summon. Often used for scaling auras.
|
||||
void castPassiveSpells();
|
||||
// Initializes the react state of the summon
|
||||
void initializeReactState();
|
||||
|
||||
Creature* _summonedCreature;
|
||||
ObjectGuid _summonerGUID;
|
||||
|
||||
Reference in new issue
Block a user