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).
This commit is contained in:
Meji
2021-12-25 15:27:58 +01:00
committed by GitHub
parent 8ac0388870
commit 924182f692
9 changed files with 82 additions and 32 deletions

View File

@@ -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);
}