Core/BattlePets: Improvements when enabling battle pets
Port From (https://github.com/TrinityCore/TrinityCore/commit/0a8f79ad5ad5afbf6a6aedc9ad46c3b774877b31)
This commit is contained in:
@@ -31,7 +31,7 @@ namespace Game.BattlePets
|
|||||||
public BattlePetMgr(WorldSession owner)
|
public BattlePetMgr(WorldSession owner)
|
||||||
{
|
{
|
||||||
_owner = owner;
|
_owner = owner;
|
||||||
for (byte i = 0; i < SharedConst.MaxPetBattleSlots; ++i)
|
for (byte i = 0; i < (int)BattlePetSlots.Count; ++i)
|
||||||
{
|
{
|
||||||
BattlePetSlot slot = new();
|
BattlePetSlot slot = new();
|
||||||
slot.Index = i;
|
slot.Index = i;
|
||||||
@@ -510,15 +510,19 @@ namespace Game.BattlePets
|
|||||||
return (uint)speciesIds.Count;
|
return (uint)speciesIds.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnlockSlot(byte slot)
|
public void UnlockSlot(BattlePetSlots slot)
|
||||||
{
|
{
|
||||||
if (!_slots[slot].Locked)
|
if (slot >= BattlePetSlots.Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_slots[slot].Locked = false;
|
byte slotIndex = (byte)slot;
|
||||||
|
if (!_slots[slotIndex].Locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_slots[slotIndex].Locked = false;
|
||||||
|
|
||||||
PetBattleSlotUpdates updates = new();
|
PetBattleSlotUpdates updates = new();
|
||||||
updates.Slots.Add(_slots[slot]);
|
updates.Slots.Add(_slots[slotIndex]);
|
||||||
updates.AutoSlotted = false; // what's this?
|
updates.AutoSlotted = false; // what's this?
|
||||||
updates.NewSlot = true; // causes the "new slot unlocked" bubble to appear
|
updates.NewSlot = true; // causes the "new slot unlocked" bubble to appear
|
||||||
_owner.SendPacket(updates);
|
_owner.SendPacket(updates);
|
||||||
@@ -609,11 +613,11 @@ namespace Game.BattlePets
|
|||||||
if (speciesEntry == null)
|
if (speciesEntry == null)
|
||||||
return;
|
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 player = _owner.GetPlayer();
|
||||||
player.SetSummonedBattlePetGUID(guid);
|
player.SetSummonedBattlePetGUID(guid);
|
||||||
player.SetCurrentBattlePetBreedQuality(pet.PacketInfo.Quality);
|
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()
|
public void DismissPet()
|
||||||
@@ -680,7 +684,7 @@ namespace Game.BattlePets
|
|||||||
return Global.WorldMgr.IsBattlePetJournalLockAcquired(_owner.GetBattlenetAccountGUID());
|
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; }
|
WorldSession GetOwner() { return _owner; }
|
||||||
|
|
||||||
public ushort GetTrapLevel() { return _trapLevel; }
|
public ushort GetTrapLevel() { return _trapLevel; }
|
||||||
@@ -689,6 +693,8 @@ namespace Game.BattlePets
|
|||||||
public bool HasJournalLock() { return _hasJournalLock; }
|
public bool HasJournalLock() { return _hasJournalLock; }
|
||||||
public void ToggleJournalLock(bool on) { _hasJournalLock = on; }
|
public void ToggleJournalLock(bool on) { _hasJournalLock = on; }
|
||||||
|
|
||||||
|
public bool IsBattlePetSystemEnabled() { return GetSlot(BattlePetSlots.Slot0).Locked != true; }
|
||||||
|
|
||||||
WorldSession _owner;
|
WorldSession _owner;
|
||||||
bool _hasJournalLock;
|
bool _hasJournalLock;
|
||||||
ushort _trapLevel;
|
ushort _trapLevel;
|
||||||
|
|||||||
@@ -3332,6 +3332,10 @@ namespace Game.Entities
|
|||||||
_restMgr.AddRestBonus(RestTypes.XP, time_diff * _restMgr.CalcExtraPerSec(RestTypes.XP, bubble));
|
_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_achievementSys.CheckAllAchievementCriteria(this);
|
||||||
m_questObjectiveCriteriaMgr.CheckAllQuestObjectiveCriteria(this);
|
m_questObjectiveCriteriaMgr.CheckAllQuestObjectiveCriteria(this);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Game
|
|||||||
BattlePetMgr.BattlePet pet = GetBattlePetMgr().GetPet(battlePetSetBattleSlot.PetGuid);
|
BattlePetMgr.BattlePet pet = GetBattlePetMgr().GetPet(battlePetSetBattleSlot.PetGuid);
|
||||||
if (pet != null)
|
if (pet != null)
|
||||||
{
|
{
|
||||||
BattlePetSlot slot = GetBattlePetMgr().GetSlot(battlePetSetBattleSlot.Slot);
|
BattlePetSlot slot = GetBattlePetMgr().GetSlot((BattlePetSlots)battlePetSetBattleSlot.Slot);
|
||||||
if (slot != null)
|
if (slot != null)
|
||||||
slot.Pet = pet.PacketInfo;
|
slot.Pet = pet.PacketInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5270,12 +5270,12 @@ namespace Game.Spells
|
|||||||
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
|
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
|
if (unitTarget == null || !unitTarget.IsPlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player plr = unitTarget.ToPlayer();
|
Player player = unitTarget.ToPlayer();
|
||||||
plr.AddPlayerFlag(PlayerFlags.PetBattlesUnlocked);
|
player.AddPlayerFlag(PlayerFlags.PetBattlesUnlocked);
|
||||||
plr.GetSession().GetBattlePetMgr().UnlockSlot(0);
|
player.GetSession().GetBattlePetMgr().UnlockSlot(BattlePetSlots.Slot0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.LaunchQuestChoice)]
|
[SpellEffectHandler(SpellEffectName.LaunchQuestChoice)]
|
||||||
|
|||||||
@@ -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);
|
||||||
Reference in New Issue
Block a user