diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/BattlePets/BattlePetMgr.cpp | 11 | ||||
-rw-r--r-- | src/server/game/DataStores/DBCEnums.h | 4 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/TemporarySummon.cpp | 17 | ||||
-rw-r--r-- | src/server/game/Entities/Totem/Totem.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 20 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 25 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 30 |
8 files changed, 79 insertions, 32 deletions
diff --git a/src/server/game/BattlePets/BattlePetMgr.cpp b/src/server/game/BattlePets/BattlePetMgr.cpp index 5f5ad43154d..85ab36ef132 100644 --- a/src/server/game/BattlePets/BattlePetMgr.cpp +++ b/src/server/game/BattlePets/BattlePetMgr.cpp @@ -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() diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h index 627e716137a..e7d58467943 100644 --- a/src/server/game/DataStores/DBCEnums.h +++ b/src/server/game/DataStores/DBCEnums.h @@ -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 diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 27409d0209c..666145e0b04 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -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); } diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index a0ccd833b37..d649a2a6be6 100644 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -82,8 +82,6 @@ void Totem::InitStats(uint32 duration) m_type = TOTEM_ACTIVE; m_duration = duration; - - SetLevel(GetOwner()->GetLevel()); } void Totem::InitSummon() diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 76dadac3885..ad6ed3ec293 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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); + } + } } } } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 8b430ff7714..6e7dc569cc1 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -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()) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 6004dc11ac7..f862ee5e717 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -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)); 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); } |