Core/Trainers: Implemented learning battle pets from trainers
Port From (https://github.com/TrinityCore/TrinityCore/commit/b02f382ed78b784d547c68cdbbb681148708d7d0)
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
using System;
|
using Framework.Constants;
|
||||||
using System.Collections.Generic;
|
using Game.BattlePets;
|
||||||
using Framework.Constants;
|
|
||||||
using Game.Networking.Packets;
|
using Game.Networking.Packets;
|
||||||
using Game.Spells;
|
using Game.Spells;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Game.Entities
|
namespace Game.Entities
|
||||||
{
|
{
|
||||||
@@ -67,6 +68,19 @@ namespace Game.Entities
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sendSpellVisual = true;
|
||||||
|
var speciesEntry = Global.SpellMgr.GetBattlePetSpecies(trainerSpell.SpellId);
|
||||||
|
if (speciesEntry != null)
|
||||||
|
{
|
||||||
|
if (player.GetSession().GetBattlePetMgr().HasMaxPetCount(speciesEntry, player.GetGUID()))
|
||||||
|
{
|
||||||
|
// Don't send any error to client (intended)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendSpellVisual = false;
|
||||||
|
}
|
||||||
|
|
||||||
float reputationDiscount = player.GetReputationPriceDiscount(npc);
|
float reputationDiscount = player.GetReputationPriceDiscount(npc);
|
||||||
long moneyCost = (long)(trainerSpell.MoneyCost * reputationDiscount);
|
long moneyCost = (long)(trainerSpell.MoneyCost * reputationDiscount);
|
||||||
if (!player.HasEnoughMoney(moneyCost))
|
if (!player.HasEnoughMoney(moneyCost))
|
||||||
@@ -77,14 +91,29 @@ namespace Game.Entities
|
|||||||
|
|
||||||
player.ModifyMoney(-moneyCost);
|
player.ModifyMoney(-moneyCost);
|
||||||
|
|
||||||
npc.SendPlaySpellVisualKit(179, 0, 0); // 53 SpellCastDirected
|
if (sendSpellVisual)
|
||||||
player.SendPlaySpellVisualKit(362, 1, 0); // 113 EmoteSalute
|
{
|
||||||
|
npc.SendPlaySpellVisualKit(179, 0, 0); // 53 SpellCastDirected
|
||||||
|
player.SendPlaySpellVisualKit(362, 1, 0); // 113 EmoteSalute
|
||||||
|
}
|
||||||
|
|
||||||
// learn explicitly or cast explicitly
|
// learn explicitly or cast explicitly
|
||||||
if (trainerSpell.IsCastable())
|
if (trainerSpell.IsCastable())
|
||||||
player.CastSpell(player, trainerSpell.SpellId, true);
|
player.CastSpell(player, trainerSpell.SpellId, true);
|
||||||
else
|
else
|
||||||
player.LearnSpell(trainerSpell.SpellId, false);
|
{
|
||||||
|
bool dependent = false;
|
||||||
|
|
||||||
|
if (speciesEntry != null)
|
||||||
|
{
|
||||||
|
player.GetSession().GetBattlePetMgr().AddPet(speciesEntry.Id, BattlePetMgr.SelectPetDisplay(speciesEntry), BattlePetMgr.RollPetBreed(speciesEntry.Id), BattlePetMgr.GetDefaultPetQuality(speciesEntry.Id));
|
||||||
|
// If the spell summons a battle pet, we fake that it has been learned and the battle pet is added
|
||||||
|
// marking as dependent prevents saving the spell to database (intended)
|
||||||
|
dependent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.LearnSpell(trainerSpell.SpellId, dependent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TrainerSpell GetSpell(uint spellId)
|
TrainerSpell GetSpell(uint spellId)
|
||||||
|
|||||||
Reference in New Issue
Block a user