Core/Spells: Implement aura #428 (SPELL_AURA_LINKED_SUMMON)

This commit is contained in:
Shocker
2018-05-14 00:35:50 +03:00
parent f05dbf814a
commit 3ad5df1bd1
3 changed files with 52 additions and 2 deletions

View File

@@ -497,7 +497,7 @@ enum AuraType : uint32
SPELL_AURA_425 = 425,
SPELL_AURA_426 = 426,
SPELL_AURA_SCALE_PLAYER_LEVEL = 427, // NYI
SPELL_AURA_428 = 428,
SPELL_AURA_LINKED_SUMMON = 428,
SPELL_AURA_429 = 429,
SPELL_AURA_PLAY_SCENE = 430,
SPELL_AURA_MOD_OVERRIDE_ZONE_PVP_TYPE = 431, // NYI

View File

@@ -494,7 +494,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNULL, //425
&AuraEffect::HandleNULL, //426
&AuraEffect::HandleNULL, //427 SPELL_AURA_SCALE_PLAYER_LEVEL
&AuraEffect::HandleNULL, //428
&AuraEffect::HandleLinkedSummon, //428 SPELL_AURA_LINKED_SUMMON
&AuraEffect::HandleNULL, //429
&AuraEffect::HandlePlayScene, //430 SPELL_AURA_PLAY_SCENE
&AuraEffect::HandleNULL, //431
@@ -6212,3 +6212,52 @@ void AuraEffect::HandleAuraPvpTalents(AuraApplication const* auraApp, uint8 mode
target->TogglePvpTalents(false);
}
}
void AuraEffect::HandleLinkedSummon(AuraApplication const* aurApp, uint8 mode, bool apply) const
{
if (!(mode & AURA_EFFECT_HANDLE_REAL))
return;
Unit* target = aurApp->GetTarget();
SpellInfo const* triggerSpellInfo = sSpellMgr->GetSpellInfo(GetSpellEffectInfo()->TriggerSpell);
if (!triggerSpellInfo)
return;
// on apply cast summon spell
if (apply)
target->CastSpell(target, triggerSpellInfo, true, nullptr, this);
// on unapply we need to search for and remove the summoned creature
else
{
std::vector<uint32> summonedEntries;
for (auto spellEffect : triggerSpellInfo->GetEffectsForDifficulty(target->FindMap()->GetDifficultyID()))
if (spellEffect && spellEffect->Effect == SPELL_EFFECT_SUMMON)
if (uint32 summonEntry = spellEffect->MiscValue)
if (std::find(summonedEntries.begin(), summonedEntries.end(), summonEntry) == summonedEntries.end())
summonedEntries.push_back(summonEntry);
// we don't know if there can be multiple summons for the same effect, so consider only 1 summon for each effect
// most of the spells have multiple effects with the same summon spell id for multiple spawns, so right now it's safe to assume there's only 1 spawn per effect
for (uint32 summonEntry : summonedEntries)
{
std::list<Creature*> nearbyEntries;
target->GetCreatureListWithEntryInGrid(nearbyEntries, summonEntry);
for (auto creature : nearbyEntries)
{
if (creature->GetOwner() == target)
{
creature->DespawnOrUnsummon();
break;
}
else if (TempSummon* tempSummon = creature->ToTempSummon())
{
if (tempSummon->GetSummoner() == target)
{
tempSummon->DespawnOrUnsummon();
break;
}
}
}
}
}
}

View File

@@ -315,6 +315,7 @@ class TC_GAME_API AuraEffect
void HandleAllowUsingGameobjectsWhileMounted(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandlePlayScene(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleCreateAreaTrigger(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleLinkedSummon(AuraApplication const* aurApp, uint8 mode, bool apply) const;
// aura effect periodic tick handlers
void HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const;