mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 02:25:38 +01:00
Core/Spells: Implemented spell effect 225 (SPELL_EFFECT_GRANT_BATTLEPET_LEVEL) (#27506)
This commit is contained in:
@@ -748,6 +748,57 @@ void BattlePetMgr::GrantBattlePetExperience(ObjectGuid guid, uint16 xp, BattlePe
|
||||
}
|
||||
}
|
||||
|
||||
void BattlePetMgr::GrantBattlePetLevel(ObjectGuid guid, uint16 grantedLevels)
|
||||
{
|
||||
if (!HasJournalLock())
|
||||
return;
|
||||
|
||||
BattlePet* pet = GetPet(guid);
|
||||
if (!pet)
|
||||
return;
|
||||
|
||||
if (BattlePetSpeciesEntry const* battlePetSpecies = sBattlePetSpeciesStore.LookupEntry(pet->PacketInfo.Species))
|
||||
if (battlePetSpecies->GetFlags().HasFlag(BattlePetSpeciesFlags::CantBattle))
|
||||
return;
|
||||
|
||||
uint16 level = pet->PacketInfo.Level;
|
||||
if (level >= MAX_BATTLE_PET_LEVEL)
|
||||
return;
|
||||
|
||||
Player* player = _owner->GetPlayer();
|
||||
|
||||
while (grantedLevels > 0 && level < MAX_BATTLE_PET_LEVEL)
|
||||
{
|
||||
++level;
|
||||
--grantedLevels;
|
||||
|
||||
player->UpdateCriteria(CriteriaType::BattlePetReachLevel, pet->PacketInfo.Species, level);
|
||||
}
|
||||
|
||||
pet->PacketInfo.Level = level;
|
||||
if (level >= MAX_BATTLE_PET_LEVEL)
|
||||
pet->PacketInfo.Exp = 0;
|
||||
pet->CalculateStats();
|
||||
pet->PacketInfo.Health = pet->PacketInfo.MaxHealth;
|
||||
|
||||
if (pet->SaveInfo != BATTLE_PET_NEW)
|
||||
pet->SaveInfo = BATTLE_PET_CHANGED;
|
||||
|
||||
std::vector<std::reference_wrapper<BattlePet>> updates;
|
||||
updates.push_back(std::ref(*pet));
|
||||
SendUpdates(std::move(updates), false);
|
||||
|
||||
// Update battle pet related update fields
|
||||
if (Creature* summonedBattlePet = player->GetSummonedBattlePet())
|
||||
{
|
||||
if (summonedBattlePet->GetBattlePetCompanionGUID() == guid)
|
||||
{
|
||||
summonedBattlePet->SetWildBattlePetLevel(pet->PacketInfo.Level);
|
||||
player->SetBattlePetData(pet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BattlePetMgr::HealBattlePetsPct(uint8 pct)
|
||||
{
|
||||
// TODO: After each Pet Battle, any injured companion will automatically
|
||||
|
||||
@@ -181,6 +181,7 @@ public:
|
||||
void CageBattlePet(ObjectGuid guid);
|
||||
void ChangeBattlePetQuality(ObjectGuid guid, BattlePetBreedQuality quality);
|
||||
void GrantBattlePetExperience(ObjectGuid guid, uint16 xp, BattlePetXpSource xpSource);
|
||||
void GrantBattlePetLevel(ObjectGuid guid, uint16 grantedLevels);
|
||||
void HealBattlePetsPct(uint8 pct);
|
||||
|
||||
void SummonPet(ObjectGuid guid);
|
||||
|
||||
@@ -6044,6 +6044,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
|
||||
break;
|
||||
}
|
||||
case SPELL_EFFECT_CHANGE_BATTLEPET_QUALITY:
|
||||
case SPELL_EFFECT_GRANT_BATTLEPET_LEVEL:
|
||||
case SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE:
|
||||
{
|
||||
Player* playerCaster = m_caster->ToPlayer();
|
||||
@@ -6090,7 +6091,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
|
||||
return SPELL_FAILED_CANT_UPGRADE_BATTLE_PET;
|
||||
}
|
||||
|
||||
if (spellEffectInfo.Effect == SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE)
|
||||
if (spellEffectInfo.Effect == SPELL_EFFECT_GRANT_BATTLEPET_LEVEL || spellEffectInfo.Effect == SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE)
|
||||
if (battlePet->PacketInfo.Level >= BattlePets::MAX_BATTLE_PET_LEVEL)
|
||||
return GRANT_PET_LEVEL_FAIL;
|
||||
|
||||
|
||||
@@ -377,6 +377,7 @@ class TC_GAME_API Spell
|
||||
void EffectCancelConversation();
|
||||
void EffectAddGarrisonFollower();
|
||||
void EffectActivateGarrisonBuilding();
|
||||
void EffectGrantBattlePetLevel();
|
||||
void EffectHealBattlePetPct();
|
||||
void EffectEnableBattlePets();
|
||||
void EffectChangeBattlePetQuality();
|
||||
|
||||
@@ -306,7 +306,7 @@ NonDefaultConstructible<SpellEffectHandlerFn> SpellEffectHandlers[TOTAL_SPELL_EF
|
||||
&Spell::EffectCreateHeirloomItem, //222 SPELL_EFFECT_CREATE_HEIRLOOM_ITEM
|
||||
&Spell::EffectNULL, //223 SPELL_EFFECT_CHANGE_ITEM_BONUSES
|
||||
&Spell::EffectActivateGarrisonBuilding, //224 SPELL_EFFECT_ACTIVATE_GARRISON_BUILDING
|
||||
&Spell::EffectNULL, //225 SPELL_EFFECT_GRANT_BATTLEPET_LEVEL
|
||||
&Spell::EffectGrantBattlePetLevel, //225 SPELL_EFFECT_GRANT_BATTLEPET_LEVEL
|
||||
&Spell::EffectNULL, //226 SPELL_EFFECT_TRIGGER_ACTION_SET
|
||||
&Spell::EffectNULL, //227 SPELL_EFFECT_TELEPORT_TO_LFG_DUNGEON
|
||||
&Spell::EffectNULL, //228 SPELL_EFFECT_228
|
||||
@@ -5315,6 +5315,21 @@ void Spell::EffectActivateGarrisonBuilding()
|
||||
garrison->ActivateBuilding(effectInfo->MiscValue);
|
||||
}
|
||||
|
||||
void Spell::EffectGrantBattlePetLevel()
|
||||
{
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
Player* playerCaster = m_caster->ToPlayer();
|
||||
if (!playerCaster)
|
||||
return;
|
||||
|
||||
if (!unitTarget || !unitTarget->IsCreature())
|
||||
return;
|
||||
|
||||
playerCaster->GetSession()->GetBattlePetMgr()->GrantBattlePetLevel(unitTarget->GetBattlePetCompanionGUID(), damage);
|
||||
}
|
||||
|
||||
void Spell::EffectHealBattlePetPct()
|
||||
{
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
|
||||
Reference in New Issue
Block a user