Core/Spells: Implemented spell effect 225 (SPELL_EFFECT_GRANT_BATTLEPET_LEVEL)
Port From (https://github.com/TrinityCore/TrinityCore/commit/ddc71206de653d05aed479b82260bcf55dd72445)
This commit is contained in:
@@ -700,6 +700,59 @@ namespace Game.BattlePets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GrantBattlePetLevel(ObjectGuid guid, ushort grantedLevels)
|
||||||
|
{
|
||||||
|
if (!HasJournalLock())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var pet = GetPet(guid);
|
||||||
|
if (pet == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var battlePetSpecies = CliDB.BattlePetSpeciesStorage.LookupByKey(pet.PacketInfo.Species);
|
||||||
|
if (battlePetSpecies != null)
|
||||||
|
if (battlePetSpecies.GetFlags().HasFlag(BattlePetSpeciesFlags.CantBattle))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ushort level = pet.PacketInfo.Level;
|
||||||
|
if (level >= SharedConst.MaxBattlePetLevel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = _owner.GetPlayer();
|
||||||
|
|
||||||
|
while (grantedLevels > 0 && level < SharedConst.MaxBattlePetLevel)
|
||||||
|
{
|
||||||
|
++level;
|
||||||
|
--grantedLevels;
|
||||||
|
|
||||||
|
player.UpdateCriteria(CriteriaType.BattlePetReachLevel, pet.PacketInfo.Species, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
pet.PacketInfo.Level = level;
|
||||||
|
if (level >= SharedConst.MaxBattlePetLevel)
|
||||||
|
pet.PacketInfo.Exp = 0;
|
||||||
|
pet.CalculateStats();
|
||||||
|
pet.PacketInfo.Health = pet.PacketInfo.MaxHealth;
|
||||||
|
|
||||||
|
if (pet.SaveInfo != BattlePetSaveInfo.New)
|
||||||
|
pet.SaveInfo = BattlePetSaveInfo.Changed;
|
||||||
|
|
||||||
|
List<BattlePet> updates = new List<BattlePet>();
|
||||||
|
updates.Add(pet);
|
||||||
|
SendUpdates(updates, false);
|
||||||
|
|
||||||
|
// Update battle pet related update fields
|
||||||
|
Creature summonedBattlePet = player.GetSummonedBattlePet();
|
||||||
|
if (summonedBattlePet != null)
|
||||||
|
{
|
||||||
|
if (summonedBattlePet.GetBattlePetCompanionGUID() == guid)
|
||||||
|
{
|
||||||
|
summonedBattlePet.SetWildBattlePetLevel(pet.PacketInfo.Level);
|
||||||
|
player.SetBattlePetData(pet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void HealBattlePetsPct(byte pct)
|
public void HealBattlePetsPct(byte pct)
|
||||||
{
|
{
|
||||||
// TODO: After each Pet Battle, any injured companion will automatically
|
// TODO: After each Pet Battle, any injured companion will automatically
|
||||||
|
|||||||
@@ -5313,6 +5313,7 @@ namespace Game.Spells
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SpellEffectName.ChangeBattlepetQuality:
|
case SpellEffectName.ChangeBattlepetQuality:
|
||||||
|
case SpellEffectName.GrantBattlepetLevel:
|
||||||
case SpellEffectName.GrantBattlepetExperience:
|
case SpellEffectName.GrantBattlepetExperience:
|
||||||
{
|
{
|
||||||
Player playerCaster = m_caster.ToPlayer();
|
Player playerCaster = m_caster.ToPlayer();
|
||||||
@@ -5362,7 +5363,7 @@ namespace Game.Spells
|
|||||||
return SpellCastResult.CantUpgradeBattlePet;
|
return SpellCastResult.CantUpgradeBattlePet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spellEffectInfo.Effect == SpellEffectName.GrantBattlepetExperience)
|
if (spellEffectInfo.Effect == SpellEffectName.GrantBattlepetLevel || spellEffectInfo.Effect == SpellEffectName.GrantBattlepetExperience)
|
||||||
if (battlePet.PacketInfo.Level >= SharedConst.MaxBattlePetLevel)
|
if (battlePet.PacketInfo.Level >= SharedConst.MaxBattlePetLevel)
|
||||||
return SpellCastResult.GrantPetLevelFail;
|
return SpellCastResult.GrantPetLevelFail;
|
||||||
|
|
||||||
|
|||||||
@@ -5101,6 +5101,22 @@ namespace Game.Spells
|
|||||||
garrison.ActivateBuilding((uint)effectInfo.MiscValue);
|
garrison.ActivateBuilding((uint)effectInfo.MiscValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SpellEffectHandler(SpellEffectName.GrantBattlepetLevel)]
|
||||||
|
void EffectGrantBattlePetLevel()
|
||||||
|
{
|
||||||
|
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player playerCaster = m_caster.ToPlayer();
|
||||||
|
if (playerCaster == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (unitTarget == null || !unitTarget.IsCreature())
|
||||||
|
return;
|
||||||
|
|
||||||
|
playerCaster.GetSession().GetBattlePetMgr().GrantBattlePetLevel(unitTarget.GetBattlePetCompanionGUID(), (ushort)damage);
|
||||||
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.HealBattlepetPct)]
|
[SpellEffectHandler(SpellEffectName.HealBattlepetPct)]
|
||||||
void EffectHealBattlePetPct()
|
void EffectHealBattlePetPct()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user