diff --git a/Source/Game/BattlePets/BattlePetManager.cs b/Source/Game/BattlePets/BattlePetManager.cs index 6c228acc6..bbd25f27b 100644 --- a/Source/Game/BattlePets/BattlePetManager.cs +++ b/Source/Game/BattlePets/BattlePetManager.cs @@ -31,7 +31,7 @@ namespace Game.BattlePets public BattlePetMgr(WorldSession owner) { _owner = owner; - for (byte i = 0; i < SharedConst.MaxPetBattleSlots; ++i) + for (byte i = 0; i < (int)BattlePetSlots.Count; ++i) { BattlePetSlot slot = new(); slot.Index = i; @@ -510,15 +510,19 @@ namespace Game.BattlePets return (uint)speciesIds.Count; } - public void UnlockSlot(byte slot) + public void UnlockSlot(BattlePetSlots slot) { - if (!_slots[slot].Locked) + if (slot >= BattlePetSlots.Count) return; - _slots[slot].Locked = false; + byte slotIndex = (byte)slot; + if (!_slots[slotIndex].Locked) + return; + + _slots[slotIndex].Locked = false; PetBattleSlotUpdates updates = new(); - updates.Slots.Add(_slots[slot]); + updates.Slots.Add(_slots[slotIndex]); updates.AutoSlotted = false; // what's this? updates.NewSlot = true; // causes the "new slot unlocked" bubble to appear _owner.SendPacket(updates); @@ -609,11 +613,11 @@ namespace Game.BattlePets if (speciesEntry == null) return; - // TODO: set proper CreatureID for spell DEFAULT_SUMMON_BATTLE_PET_SPELL (default EffectMiscValueA is 40721 - Murkimus the Gladiator) + // TODO: set proper CreatureID for spell SPELL_SUMMON_BATTLE_PET (default EffectMiscValueA is 40721 - Murkimus the Gladiator) Player player = _owner.GetPlayer(); player.SetSummonedBattlePetGUID(guid); player.SetCurrentBattlePetBreedQuality(pet.PacketInfo.Quality); - player.CastSpell(_owner.GetPlayer(), speciesEntry.SummonSpellID != 0 ? speciesEntry.SummonSpellID : SharedConst.DefaultSummonBattlePetSpell); + player.CastSpell(_owner.GetPlayer(), speciesEntry.SummonSpellID != 0 ? speciesEntry.SummonSpellID : SharedConst.SpellSummonBattlePet); } public void DismissPet() @@ -680,7 +684,7 @@ namespace Game.BattlePets return Global.WorldMgr.IsBattlePetJournalLockAcquired(_owner.GetBattlenetAccountGUID()); } - public BattlePetSlot GetSlot(byte slot) { return slot < _slots.Count ? _slots[slot] : null; } + public BattlePetSlot GetSlot(BattlePetSlots slot) { return slot < BattlePetSlots.Count ? _slots[(byte)slot] : null; } WorldSession GetOwner() { return _owner; } public ushort GetTrapLevel() { return _trapLevel; } @@ -688,7 +692,9 @@ namespace Game.BattlePets public bool HasJournalLock() { return _hasJournalLock; } public void ToggleJournalLock(bool on) { _hasJournalLock = on; } - + + public bool IsBattlePetSystemEnabled() { return GetSlot(BattlePetSlots.Slot0).Locked != true; } + WorldSession _owner; bool _hasJournalLock; ushort _trapLevel; diff --git a/Source/Game/Entities/Player/Player.DB.cs b/Source/Game/Entities/Player/Player.DB.cs index c50a520e3..de8106588 100644 --- a/Source/Game/Entities/Player/Player.DB.cs +++ b/Source/Game/Entities/Player/Player.DB.cs @@ -3332,6 +3332,10 @@ namespace Game.Entities _restMgr.AddRestBonus(RestTypes.XP, time_diff * _restMgr.CalcExtraPerSec(RestTypes.XP, bubble)); } + // Unlock battle pet system if it's enabled in bnet account + if (GetSession().GetBattlePetMgr().IsBattlePetSystemEnabled()) + LearnSpell(SharedConst.SpellBattlePetTraining, false); + m_achievementSys.CheckAllAchievementCriteria(this); m_questObjectiveCriteriaMgr.CheckAllQuestObjectiveCriteria(this); diff --git a/Source/Game/Handlers/BattlePetHandler.cs b/Source/Game/Handlers/BattlePetHandler.cs index 2e242349d..0572926c3 100644 --- a/Source/Game/Handlers/BattlePetHandler.cs +++ b/Source/Game/Handlers/BattlePetHandler.cs @@ -47,7 +47,7 @@ namespace Game BattlePetMgr.BattlePet pet = GetBattlePetMgr().GetPet(battlePetSetBattleSlot.PetGuid); if (pet != null) { - BattlePetSlot slot = GetBattlePetMgr().GetSlot(battlePetSetBattleSlot.Slot); + BattlePetSlot slot = GetBattlePetMgr().GetSlot((BattlePetSlots)battlePetSetBattleSlot.Slot); if (slot != null) slot.Pet = pet.PacketInfo; } diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index a3c83e829..a6e612ac7 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -5270,12 +5270,12 @@ namespace Game.Spells if (effectHandleMode != SpellEffectHandleMode.HitTarget) return; - if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player)) + if (unitTarget == null || !unitTarget.IsPlayer()) return; - Player plr = unitTarget.ToPlayer(); - plr.AddPlayerFlag(PlayerFlags.PetBattlesUnlocked); - plr.GetSession().GetBattlePetMgr().UnlockSlot(0); + Player player = unitTarget.ToPlayer(); + player.AddPlayerFlag(PlayerFlags.PetBattlesUnlocked); + player.GetSession().GetBattlePetMgr().UnlockSlot(BattlePetSlots.Slot0); } [SpellEffectHandler(SpellEffectName.LaunchQuestChoice)] diff --git a/sql/updates/world/master/2021_12_10_00_world.sql b/sql/updates/world/master/2021_12_10_00_world.sql new file mode 100644 index 000000000..e05d17609 --- /dev/null +++ b/sql/updates/world/master/2021_12_10_00_world.sql @@ -0,0 +1,5 @@ +DELETE FROM `spell_learn_spell` WHERE `entry` = 125610; +INSERT INTO `spell_learn_spell` (`entry`, `SpellID`, `Active`) VALUES +(125610,119467,1), +(125610,122026,1), +(125610,125439,1);