aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShocker <shocker@freakz.ro>2018-05-14 00:35:50 +0300
committerShocker <shocker@freakz.ro>2018-05-14 00:40:05 +0300
commit3ad5df1bd1b7835c0cc9aa33e4fa7fd5cfdd5250 (patch)
treebcf5ce3b548a0b82099e253949e405ef44a51a6b
parentf05dbf814a42a8ea86b1ee532456dea2809a4d19 (diff)
Core/Spells: Implement aura #428 (SPELL_AURA_LINKED_SUMMON)
-rw-r--r--src/server/game/Spells/Auras/SpellAuraDefines.h2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp51
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h1
3 files changed, 52 insertions, 2 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h
index 8bfd4fb2f42..857243309f3 100644
--- a/src/server/game/Spells/Auras/SpellAuraDefines.h
+++ b/src/server/game/Spells/Auras/SpellAuraDefines.h
@@ -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
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 99555e216e0..3f0c5c33a41 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -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;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index 3c113156329..b46a499dc8b 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -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;