Core/BattlePets: Misc fixes
This commit is contained in:
@@ -333,9 +333,14 @@ namespace Game.BattlePets
|
|||||||
_owner.SendPacket(updates);
|
_owner.SendPacket(updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BattlePet> GetLearnedPets()
|
public ushort GetMaxPetLevel()
|
||||||
{
|
{
|
||||||
return _pets.Values.Where(p => p.SaveInfo != BattlePetSaveInfo.Removed).ToList();
|
ushort level = 0;
|
||||||
|
foreach (var pet in _pets)
|
||||||
|
if (pet.Value.SaveInfo != BattlePetSaveInfo.Removed)
|
||||||
|
level = Math.Max(level, pet.Value.PacketInfo.Level);
|
||||||
|
|
||||||
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CageBattlePet(ObjectGuid guid)
|
public void CageBattlePet(ObjectGuid guid)
|
||||||
@@ -359,7 +364,7 @@ namespace Game.BattlePets
|
|||||||
item.SetModifier(ItemModifier.BattlePetDisplayId, pet.PacketInfo.CreatureID);
|
item.SetModifier(ItemModifier.BattlePetDisplayId, pet.PacketInfo.CreatureID);
|
||||||
|
|
||||||
// FIXME: "You create: ." - item name missing in chat
|
// FIXME: "You create: ." - item name missing in chat
|
||||||
_owner.GetPlayer().SendNewItem(item, 1, true, true);
|
_owner.GetPlayer().SendNewItem(item, 1, true, false);
|
||||||
|
|
||||||
RemovePet(guid);
|
RemovePet(guid);
|
||||||
|
|
||||||
@@ -401,11 +406,36 @@ namespace Game.BattlePets
|
|||||||
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 DEFAULT_SUMMON_BATTLE_PET_SPELL (default EffectMiscValueA is 40721 - Murkimus the Gladiator)
|
||||||
|
_owner.GetPlayer().SetGuidValue(PlayerFields.SummonedBattlePetId, guid);
|
||||||
_owner.GetPlayer().CastSpell(_owner.GetPlayer(), speciesEntry.SummonSpellID != 0 ? speciesEntry.SummonSpellID : SharedConst.DefaultSummonBattlePetSpell);
|
_owner.GetPlayer().CastSpell(_owner.GetPlayer(), speciesEntry.SummonSpellID != 0 ? speciesEntry.SummonSpellID : SharedConst.DefaultSummonBattlePetSpell);
|
||||||
|
|
||||||
// TODO: set pet level, quality... update fields
|
// TODO: set pet level, quality... update fields
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DismissPet()
|
||||||
|
{
|
||||||
|
Player ownerPlayer = _owner.GetPlayer();
|
||||||
|
Creature pet = ObjectAccessor.GetCreatureOrPetOrVehicle(ownerPlayer, ownerPlayer.GetCritterGUID());
|
||||||
|
if (pet && ownerPlayer.GetGuidValue(PlayerFields.SummonedBattlePetId) == pet.GetGuidValue(UnitFields.BattlePetCompanionGuid))
|
||||||
|
{
|
||||||
|
pet.DespawnOrUnsummon();
|
||||||
|
ownerPlayer.SetGuidValue(PlayerFields.SummonedBattlePetId, ObjectGuid.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendJournal()
|
||||||
|
{
|
||||||
|
BattlePetJournal battlePetJournal = new BattlePetJournal();
|
||||||
|
battlePetJournal.Trap = _trapLevel;
|
||||||
|
|
||||||
|
foreach (var pet in _pets)
|
||||||
|
if (pet.Value.SaveInfo != BattlePetSaveInfo.Removed)
|
||||||
|
battlePetJournal.Pets.Add(pet.Value.PacketInfo);
|
||||||
|
|
||||||
|
battlePetJournal.Slots = _slots;
|
||||||
|
_owner.SendPacket(battlePetJournal);
|
||||||
|
}
|
||||||
|
|
||||||
void SendUpdates(List<BattlePet> pets, bool petAdded)
|
void SendUpdates(List<BattlePet> pets, bool petAdded)
|
||||||
{
|
{
|
||||||
BattlePetUpdates updates = new BattlePetUpdates();
|
BattlePetUpdates updates = new BattlePetUpdates();
|
||||||
|
|||||||
@@ -2565,10 +2565,10 @@ namespace Game.Entities
|
|||||||
//packet.QuestLogItemID;
|
//packet.QuestLogItemID;
|
||||||
packet.Quantity = quantity;
|
packet.Quantity = quantity;
|
||||||
packet.QuantityInInventory = GetItemCount(item.GetEntry());
|
packet.QuantityInInventory = GetItemCount(item.GetEntry());
|
||||||
//packet.DungeonEncounterID;
|
//packet.DungeonEncounterID;
|
||||||
|
packet.BattlePetSpeciesID = (int)item.GetModifier(ItemModifier.BattlePetSpeciesId);
|
||||||
packet.BattlePetBreedID = (int)item.GetModifier(ItemModifier.BattlePetBreedData) & 0xFFFFFF;
|
packet.BattlePetBreedID = (int)item.GetModifier(ItemModifier.BattlePetBreedData) & 0xFFFFFF;
|
||||||
packet.BattlePetBreedQuality = (item.GetModifier(ItemModifier.BattlePetBreedData) >> 24) & 0xFF;
|
packet.BattlePetBreedQuality = (item.GetModifier(ItemModifier.BattlePetBreedData) >> 24) & 0xFF;
|
||||||
packet.BattlePetSpeciesID = (int)item.GetModifier(ItemModifier.BattlePetSpeciesId);
|
|
||||||
packet.BattlePetLevel = (int)item.GetModifier(ItemModifier.BattlePetLevel);
|
packet.BattlePetLevel = (int)item.GetModifier(ItemModifier.BattlePetLevel);
|
||||||
|
|
||||||
packet.ItemGUID = item.GetGUID();
|
packet.ItemGUID = item.GetGUID();
|
||||||
|
|||||||
@@ -199,7 +199,11 @@ namespace Game.Entities
|
|||||||
AddGuidValue(UnitFields.Summon, minion.GetGUID());
|
AddGuidValue(UnitFields.Summon, minion.GetGUID());
|
||||||
|
|
||||||
if (minion.m_Properties != null && minion.m_Properties.Type == SummonType.Minipet)
|
if (minion.m_Properties != null && minion.m_Properties.Type == SummonType.Minipet)
|
||||||
|
{
|
||||||
SetCritterGUID(minion.GetGUID());
|
SetCritterGUID(minion.GetGUID());
|
||||||
|
if (GetTypeId() == TypeId.Player)
|
||||||
|
minion.SetGuidValue(UnitFields.BattlePetCompanionGuid, GetGuidValue(PlayerFields.SummonedBattlePetId));
|
||||||
|
}
|
||||||
|
|
||||||
// PvP, FFAPvP
|
// PvP, FFAPvP
|
||||||
minion.SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, GetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag));
|
minion.SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, GetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag));
|
||||||
|
|||||||
@@ -27,15 +27,7 @@ namespace Game
|
|||||||
[WorldPacketHandler(ClientOpcodes.BattlePetRequestJournal)]
|
[WorldPacketHandler(ClientOpcodes.BattlePetRequestJournal)]
|
||||||
void HandleBattlePetRequestJournal(BattlePetRequestJournal battlePetRequestJournal)
|
void HandleBattlePetRequestJournal(BattlePetRequestJournal battlePetRequestJournal)
|
||||||
{
|
{
|
||||||
// TODO: Move this to BattlePetMgr::SendJournal() just to have all packets in one file
|
GetBattlePetMgr().SendJournal();
|
||||||
BattlePetJournal battlePetJournal = new BattlePetJournal();
|
|
||||||
battlePetJournal.Trap = GetBattlePetMgr().GetTrapLevel();
|
|
||||||
|
|
||||||
foreach (var battlePet in GetBattlePetMgr().GetLearnedPets())
|
|
||||||
battlePetJournal.Pets.Add(battlePet.PacketInfo);
|
|
||||||
|
|
||||||
battlePetJournal.Slots = GetBattlePetMgr().GetSlots();
|
|
||||||
SendPacket(battlePetJournal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[WorldPacketHandler(ClientOpcodes.BattlePetSetBattleSlot)]
|
[WorldPacketHandler(ClientOpcodes.BattlePetSetBattleSlot)]
|
||||||
@@ -90,7 +82,10 @@ namespace Game
|
|||||||
[WorldPacketHandler(ClientOpcodes.BattlePetSummon, Processing = PacketProcessing.Inplace)]
|
[WorldPacketHandler(ClientOpcodes.BattlePetSummon, Processing = PacketProcessing.Inplace)]
|
||||||
void HandleBattlePetSummon(BattlePetSummon battlePetSummon)
|
void HandleBattlePetSummon(BattlePetSummon battlePetSummon)
|
||||||
{
|
{
|
||||||
GetBattlePetMgr().SummonPet(battlePetSummon.PetGuid);
|
if (_player.GetGuidValue(PlayerFields.SummonedBattlePetId) != battlePetSummon.PetGuid)
|
||||||
|
GetBattlePetMgr().SummonPet(battlePetSummon.PetGuid);
|
||||||
|
else
|
||||||
|
GetBattlePetMgr().DismissPet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ namespace Game.Network.Packets
|
|||||||
public ObjectGuid Guid;
|
public ObjectGuid Guid;
|
||||||
public uint Species;
|
public uint Species;
|
||||||
public uint CreatureID;
|
public uint CreatureID;
|
||||||
public uint CollarID; // what's this?
|
public uint CollarID;
|
||||||
public ushort Breed;
|
public ushort Breed;
|
||||||
public ushort Level;
|
public ushort Level;
|
||||||
public ushort Exp;
|
public ushort Exp;
|
||||||
@@ -294,7 +294,7 @@ namespace Game.Network.Packets
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BattlePetStruct Pet;
|
public BattlePetStruct Pet;
|
||||||
public uint CollarID; // what's this?
|
public uint CollarID;
|
||||||
public byte Index;
|
public byte Index;
|
||||||
public bool Locked = true;
|
public bool Locked = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,9 +424,9 @@ namespace Game.Network.Packets
|
|||||||
_worldPacket.WriteUInt32(Quantity);
|
_worldPacket.WriteUInt32(Quantity);
|
||||||
_worldPacket.WriteUInt32(QuantityInInventory);
|
_worldPacket.WriteUInt32(QuantityInInventory);
|
||||||
_worldPacket.WriteUInt32(DungeonEncounterID);
|
_worldPacket.WriteUInt32(DungeonEncounterID);
|
||||||
|
_worldPacket.WriteInt32(BattlePetSpeciesID);
|
||||||
_worldPacket.WriteInt32(BattlePetBreedID);
|
_worldPacket.WriteInt32(BattlePetBreedID);
|
||||||
_worldPacket.WriteUInt32(BattlePetBreedQuality);
|
_worldPacket.WriteUInt32(BattlePetBreedQuality);
|
||||||
_worldPacket.WriteInt32(BattlePetSpeciesID);
|
|
||||||
_worldPacket.WriteInt32(BattlePetLevel);
|
_worldPacket.WriteInt32(BattlePetLevel);
|
||||||
_worldPacket.WritePackedGuid(ItemGUID);
|
_worldPacket.WritePackedGuid(ItemGUID);
|
||||||
_worldPacket.WriteBit(Pushed);
|
_worldPacket.WriteBit(Pushed);
|
||||||
@@ -448,9 +448,9 @@ namespace Game.Network.Packets
|
|||||||
public uint Quantity;
|
public uint Quantity;
|
||||||
public uint QuantityInInventory;
|
public uint QuantityInInventory;
|
||||||
public int DungeonEncounterID;
|
public int DungeonEncounterID;
|
||||||
|
public int BattlePetSpeciesID;
|
||||||
public int BattlePetBreedID;
|
public int BattlePetBreedID;
|
||||||
public uint BattlePetBreedQuality;
|
public uint BattlePetBreedQuality;
|
||||||
public int BattlePetSpeciesID;
|
|
||||||
public int BattlePetLevel;
|
public int BattlePetLevel;
|
||||||
public ObjectGuid ItemGUID;
|
public ObjectGuid ItemGUID;
|
||||||
public bool Pushed;
|
public bool Pushed;
|
||||||
|
|||||||
@@ -1900,23 +1900,6 @@ namespace Game.Spells
|
|||||||
uint spellToLearn = (m_spellInfo.Id == 483 || m_spellInfo.Id == 55884) ? (uint)damage : effectInfo.TriggerSpell;
|
uint spellToLearn = (m_spellInfo.Id == 483 || m_spellInfo.Id == 55884) ? (uint)damage : effectInfo.TriggerSpell;
|
||||||
player.LearnSpell(spellToLearn, false);
|
player.LearnSpell(spellToLearn, false);
|
||||||
|
|
||||||
if (m_spellInfo.Id == 55884)
|
|
||||||
{
|
|
||||||
BattlePetMgr battlePetMgr = player.GetSession().GetBattlePetMgr();
|
|
||||||
if (battlePetMgr != null)
|
|
||||||
{
|
|
||||||
foreach (var entry in CliDB.BattlePetSpeciesStorage.Values)
|
|
||||||
{
|
|
||||||
if (entry.SummonSpellID == spellToLearn)
|
|
||||||
{
|
|
||||||
battlePetMgr.AddPet(entry.Id, entry.CreatureID);
|
|
||||||
player.UpdateCriteria(CriteriaTypes.OwnBattlePetCount);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.outDebug(LogFilter.Spells, "Spell: Player {0} has learned spell {1} from NpcGUID={2}", player.GetGUID().ToString(), spellToLearn, m_caster.GetGUID().ToString());
|
Log.outDebug(LogFilter.Spells, "Spell: Player {0} has learned spell {1} from NpcGUID={2}", player.GetGUID().ToString(), spellToLearn, m_caster.GetGUID().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5634,14 +5617,9 @@ namespace Game.Spells
|
|||||||
if (battlePetMgr == null)
|
if (battlePetMgr == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ushort maxLearnedLevel = 0;
|
|
||||||
|
|
||||||
foreach (var pet in battlePetMgr.GetLearnedPets())
|
|
||||||
maxLearnedLevel = Math.Max(pet.PacketInfo.Level, maxLearnedLevel);
|
|
||||||
|
|
||||||
// TODO: This means if you put your highest lvl pet into cage, you won't be able to uncage it again which is probably wrong.
|
// TODO: This means if you put your highest lvl pet into cage, you won't be able to uncage it again which is probably wrong.
|
||||||
// We will need to store maxLearnedLevel somewhere to avoid this behaviour.
|
// We will need to store maxLearnedLevel somewhere to avoid this behaviour.
|
||||||
if (maxLearnedLevel < level)
|
if (battlePetMgr.GetMaxPetLevel() < level)
|
||||||
{
|
{
|
||||||
battlePetMgr.SendError(BattlePetError.TooHighLevelToUncage, creatureId); // or speciesEntry.CreatureID
|
battlePetMgr.SendError(BattlePetError.TooHighLevelToUncage, creatureId); // or speciesEntry.CreatureID
|
||||||
SendCastResult(SpellCastResult.CantAddBattlePet);
|
SendCastResult(SpellCastResult.CantAddBattlePet);
|
||||||
@@ -5655,10 +5633,11 @@ namespace Game.Spells
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
battlePetMgr.AddPet(speciesId, creatureId, breed, quality, level);
|
||||||
|
|
||||||
if (!plr.HasSpell(speciesEntry.SummonSpellID))
|
if (!plr.HasSpell(speciesEntry.SummonSpellID))
|
||||||
plr.LearnSpell(speciesEntry.SummonSpellID, false);
|
plr.LearnSpell(speciesEntry.SummonSpellID, false);
|
||||||
|
|
||||||
battlePetMgr.AddPet(speciesId, creatureId, breed, quality, level);
|
|
||||||
plr.DestroyItem(m_CastItem.GetBagSlot(), m_CastItem.GetSlot(), true);
|
plr.DestroyItem(m_CastItem.GetBagSlot(), m_CastItem.GetSlot(), true);
|
||||||
m_CastItem = null;
|
m_CastItem = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user