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
@@ -0,0 +1,3 @@
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_summon_battle_pet';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(118301,'spell_summon_battle_pet');
+9 -2
View File
@@ -707,10 +707,17 @@ void BattlePetMgr::SummonPet(ObjectGuid guid)
if (!speciesEntry)
return;
// TODO: set proper CreatureID for spell SPELL_SUMMON_BATTLE_PET (default EffectMiscValueA is 40721 - Murkimus the Gladiator)
Player* player = _owner->GetPlayer();
player->SetBattlePetData(pet);
player->CastSpell(player, speciesEntry->SummonSpellID ? speciesEntry->SummonSpellID : uint32(SPELL_SUMMON_BATTLE_PET));
CastSpellExtraArgs args;
uint32 summonSpellId = speciesEntry->SummonSpellID;
if (!summonSpellId)
{
summonSpellId = uint32(SPELL_SUMMON_BATTLE_PET);
args.AddSpellBP0(speciesEntry->CreatureID);
}
player->CastSpell(_owner->GetPlayer(), summonSpellId, args);
}
void BattlePetMgr::DismissPet()
+2 -2
View File
@@ -1552,7 +1552,7 @@ enum class SummonPropertiesFlags : uint32
CannotDismissPet = 0x00000020, // NYI
UseDemonTimeout = 0x00000040, // NYI
UnlimitedSummons = 0x00000080, // NYI
UseCreatureLevel = 0x00000100, // NYI
UseCreatureLevel = 0x00000100,
JoinSummonerSpawnGroup = 0x00000200, // NYI
DoNotToggle = 0x00000400, // NYI
DespawnWhenExpired = 0x00000800, // NYI
@@ -1565,7 +1565,7 @@ enum class SummonPropertiesFlags : uint32
CastRideVehicleSpellOnSummoner = 0x00040000, // NYI
GuardianActsLikePet = 0x00080000, // NYI
DontSnapSessileToGround = 0x00100000, // NYI
SummonFromBattlePetJournal = 0x00200000, // NYI
SummonFromBattlePetJournal = 0x00200000,
UnitClutter = 0x00400000, // NYI
DefaultNameColor = 0x00800000, // NYI
UseOwnInvisibilityDetection = 0x01000000, // NYI. Ignore Owner's Invisibility Detection
@@ -187,11 +187,8 @@ void TempSummon::InitStats(uint32 duration)
Unit* owner = GetSummonerUnit();
if (owner && IsTrigger() && m_spells[0])
{
SetLevel(owner->GetLevel());
if (owner->GetTypeId() == TYPEID_PLAYER)
m_ControlledByPlayer = true;
}
if (!m_Properties)
return;
@@ -209,15 +206,20 @@ void TempSummon::InitStats(uint32 duration)
}
owner->m_SummonSlot[slot] = GetGUID();
}
if (!m_Properties->GetFlags().HasFlag(SummonPropertiesFlags::UseCreatureLevel))
SetLevel(owner->GetLevel());
}
uint32 faction = m_Properties->Faction;
if (m_Properties->GetFlags().HasFlag(SummonPropertiesFlags::UseSummonerFaction)) // TODO: Determine priority between faction and flag
if (owner)
faction = owner->GetFaction();
if (owner && m_Properties->GetFlags().HasFlag(SummonPropertiesFlags::UseSummonerFaction)) // TODO: Determine priority between faction and flag
faction = owner->GetFaction();
if (faction)
SetFaction(faction);
SetFaction(faction);
if (m_Properties->GetFlags().HasFlag(SummonPropertiesFlags::SummonFromBattlePetJournal))
RemoveNpcFlag(UNIT_NPC_FLAG_WILD_BATTLE_PET);
}
void TempSummon::InitSummon()
@@ -434,7 +436,6 @@ Puppet::Puppet(SummonPropertiesEntry const* properties, Unit* owner)
void Puppet::InitStats(uint32 duration)
{
Minion::InitStats(duration);
SetLevel(GetOwner()->GetLevel());
SetReactState(REACT_PASSIVE);
}
-2
View File
@@ -82,8 +82,6 @@ void Totem::InitStats(uint32 duration)
m_type = TOTEM_ACTIVE;
m_duration = duration;
SetLevel(GetOwner()->GetLevel());
}
void Totem::InitSummon()
+15 -5
View File
@@ -5827,16 +5827,26 @@ void Unit::SetMinion(Minion *minion, bool apply)
SetMinionGUID(minion->GetGUID());
}
if (minion->m_Properties && SummonTitle(minion->m_Properties->Title) == SummonTitle::Companion)
SummonPropertiesEntry const* properties = minion->m_Properties;
if (properties && SummonTitle(properties->Title) == SummonTitle::Companion)
{
SetCritterGUID(minion->GetGUID());
if (Player const* thisPlayer = ToPlayer())
{
if (BattlePets::BattlePet const* pet = thisPlayer->GetSession()->GetBattlePetMgr()->GetPet(thisPlayer->GetSummonedBattlePetGUID()))
if (properties->GetFlags().HasFlag(SummonPropertiesFlags::SummonFromBattlePetJournal))
{
minion->SetBattlePetCompanionGUID(thisPlayer->GetSummonedBattlePetGUID());
minion->SetBattlePetCompanionNameTimestamp(pet->NameTimestamp);
minion->SetWildBattlePetLevel(pet->PacketInfo.Level);
if (BattlePets::BattlePet const* pet = thisPlayer->GetSession()->GetBattlePetMgr()->GetPet(thisPlayer->GetSummonedBattlePetGUID()))
{
minion->SetBattlePetCompanionGUID(thisPlayer->GetSummonedBattlePetGUID());
minion->SetBattlePetCompanionNameTimestamp(pet->NameTimestamp);
minion->SetWildBattlePetLevel(pet->PacketInfo.Level);
if (uint32 display = pet->PacketInfo.DisplayID)
{
minion->SetDisplayId(display);
minion->SetNativeDisplayId(display);
}
}
}
}
}
+1 -1
View File
@@ -6009,7 +6009,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
Creature* creature = m_targets.GetUnitTarget()->ToCreature();
if (creature)
{
if (!playerCaster->GetSummonedBattlePetGUID() || !creature->GetBattlePetCompanionGUID())
if (playerCaster->GetSummonedBattlePetGUID().IsEmpty() || creature->GetBattlePetCompanionGUID().IsEmpty())
return SPELL_FAILED_NO_PET;
if (playerCaster->GetSummonedBattlePetGUID() != creature->GetBattlePetCompanionGUID())
+13 -12
View File
@@ -1924,9 +1924,6 @@ void Spell::EffectSummonType()
if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
return;
summon->SelectLevel(); // some summoned creaters have different from 1 DB data for level/hp
summon->SetNpcFlags(NPCFlags(summon->GetCreatureTemplate()->npcflag & 0xFFFFFFFF));
summon->SetNpcFlags2(NPCFlags2(summon->GetCreatureTemplate()->npcflag >> 32));
summon->SetImmuneToAll(true);
break;
}
@@ -4763,15 +4760,6 @@ void Spell::SummonGuardian(SpellEffectInfo const* effect, uint32 entry, SummonPr
unitCaster = unitCaster->ToTotem()->GetOwner();
// in another case summon new
uint8 level = unitCaster->GetLevel();
// level of pet summoned using engineering item based at engineering skill level
if (m_CastItem && unitCaster->GetTypeId() == TYPEID_PLAYER)
if (ItemTemplate const* proto = m_CastItem->GetTemplate())
if (proto->GetRequiredSkill() == SKILL_ENGINEERING)
if (uint16 skill202 = unitCaster->ToPlayer()->GetSkillValue(SKILL_ENGINEERING))
level = skill202 / 5;
float radius = 5.0f;
int32 duration = m_spellInfo->CalcDuration(m_originalCaster);
@@ -4791,7 +4779,20 @@ void Spell::SummonGuardian(SpellEffectInfo const* effect, uint32 entry, SummonPr
return;
if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
{
uint8 level = summon->GetLevel();
if (properties && !properties->GetFlags().HasFlag(SummonPropertiesFlags::UseCreatureLevel))
level = unitCaster->GetLevel();
// level of pet summoned using engineering item based at engineering skill level
if (m_CastItem && unitCaster->GetTypeId() == TYPEID_PLAYER)
if (ItemTemplate const* proto = m_CastItem->GetTemplate())
if (proto->GetRequiredSkill() == SKILL_ENGINEERING)
if (uint16 skill202 = unitCaster->ToPlayer()->GetSkillValue(SKILL_ENGINEERING))
level = skill202 / 5;
((Guardian*)summon)->InitStatsForLevel(level);
}
if (summon->HasUnitTypeMask(UNIT_MASK_MINION) && m_targets.HasDst())
((Minion*)summon)->SetFollowAngle(unitCaster->GetAbsoluteAngle(summon));
@@ -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);
}