From 924182f692bde38d8fed85d5dbe7531a09790501 Mon Sep 17 00:00:00 2001 From: Meji Date: Sat, 25 Dec 2021 15:27:58 +0100 Subject: Core/BattlePets: Misc fixes (#27446) * Added script for "Summon Battle Pet" spell (118301). * Set the saved display of the battle pet when summoning it. * If a summon has SummonPropertiesFlags::SummonFromBattlePetJournal it will remove NpcFlag UNIT_NPC_FLAG_WILD_BATTLE_PET (Wild battle pets). * When a creature is summoned with SummonTitle::Companion, it will check to see if it has SummonPropertiesFlags::SummonFromBattlePetJournal before updating the battle pet's update fields. (If you have a summoned battle pet and summon a creature with that SummonTitle, it will incorrectly update the battle pet's update fields with the summoned battle pet's data). * Implemented SummonPropertiesFlags::UseCreatureLevel. If a summon has this flag, it will use the owner's level (If the summon doesn't have SummonProperties it will always use the selected level). --- src/server/scripts/Spells/spell_generic.cpp | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/server/scripts') diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 70a41f04a98..b0d1593e4f3 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -34,6 +34,7 @@ #include "LFGMgr.h" #include "Log.h" #include "NPCPackets.h" +#include "ObjectMgr.h" #include "Pet.h" #include "ReputationMgr.h" #include "SkillDiscovery.h" @@ -4586,6 +4587,34 @@ class spell_defender_of_azeroth_speak_with_mograine : public SpellScript } }; +// 118301 - Summon Battle Pet +class spell_summon_battle_pet : public SpellScript +{ + PrepareSpellScript(spell_summon_battle_pet); + + void HandleSummon(SpellEffIndex effIndex) + { + uint32 creatureId = uint32(GetSpellValue()->EffectBasePoints[effIndex]); + if (sObjectMgr->GetCreatureTemplate(creatureId)) + { + PreventHitDefaultEffect(effIndex); + + Unit* caster = GetCaster(); + SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetEffectInfo().MiscValueB)); + uint32 duration = uint32(GetSpellInfo()->CalcDuration(caster)); + Position pos = GetHitDest()->GetPosition(); + + if (Creature* summon = caster->GetMap()->SummonCreature(creatureId, pos, properties, duration, caster, GetSpellInfo()->Id)) + summon->SetImmuneToAll(true); + } + } + + void Register() override + { + OnEffectHit += SpellEffectFn(spell_summon_battle_pet::HandleSummon, EFFECT_0, SPELL_EFFECT_SUMMON); + } +}; + void AddSC_generic_spell_scripts() { RegisterAuraScript(spell_gen_absorb0_hitlimit1); @@ -4722,4 +4751,5 @@ void AddSC_generic_spell_scripts() RegisterAuraScript(spell_gen_impatient_mind); RegisterSpellScript(spell_defender_of_azeroth_death_gate_selector); RegisterSpellScript(spell_defender_of_azeroth_speak_with_mograine); + RegisterSpellScript(spell_summon_battle_pet); } -- cgit v1.2.3