From eddd539cfee6c92154c34728ac23e1b1b02a97e2 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 29 Jan 2024 15:33:16 -0500 Subject: [PATCH] Core/Players: Fixed learning riding spells Port From (https://github.com/TrinityCore/TrinityCore/commit/ae1dd8caf009b394cfc77592fdeff74809ab170b) --- Source/Framework/Constants/PlayerConst.cs | 2 ++ Source/Game/Entities/Player/Player.Spells.cs | 18 ++++++++++++------ Source/Game/Globals/ObjectManager.cs | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Source/Framework/Constants/PlayerConst.cs b/Source/Framework/Constants/PlayerConst.cs index c49879140..8ade8c77d 100644 --- a/Source/Framework/Constants/PlayerConst.cs +++ b/Source/Framework/Constants/PlayerConst.cs @@ -60,6 +60,8 @@ namespace Framework.Constants public const uint WarmodeEnlistedSpellOutside = 269083; public const uint SpellExperienceEliminated = 206662; + public const uint SpellApprenticeRiding = 33389; + public const uint SpellJourneymanRiding = 33391; public const uint CurrencyMaxCapAncientMana = 2000; diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index 4c26e53f1..59cb7a49f 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -1654,10 +1654,6 @@ namespace Game.Entities continue; } - // AcquireMethod == 2 && NumSkillUps == 1 -. automatically learn riding skill spell, else we skip it (client shows riding in spellbook as trainable). - if (skillId == (uint)SkillType.Riding && (ability.AcquireMethod != AbilityLearnType.OnSkillLearn || ability.NumSkillUps != 1)) - continue; - // Check race if set var raceMask = new RaceMask(ability.RaceMask); if (!raceMask.IsEmpty() && !raceMask.HasRace(race)) @@ -1667,8 +1663,18 @@ namespace Game.Entities if (ability.ClassMask != 0 && !Convert.ToBoolean(ability.ClassMask & classMask)) continue; - // check level, skip class spells if not high enough - if (GetLevel() < spellInfo.SpellLevel) + // Check level, skip class spells if not high enough + uint requiredLevel = Math.Max(spellInfo.SpellLevel, spellInfo.BaseLevel); + + // riding special cases + if (skillId == (uint)SkillType.Riding) + { + if ((GetClassMask() & ((1 << ((int)Class.Deathknight - 1)) | (1 << ((int)Class.DemonHunter - 1)))) != 0 + && (ability.Spell == PlayerConst.SpellApprenticeRiding || ability.Spell == PlayerConst.SpellJourneymanRiding)) + requiredLevel = 0; + } + + if (requiredLevel > GetLevel()) continue; // need unlearn spell diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index e04692121..78b1d3063 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -6083,11 +6083,11 @@ namespace Game var raceMask = new RaceMask(rcInfo.RaceMask); for (Race raceIndex = Race.Human; raceIndex < Race.Max; ++raceIndex) { - if (raceMask.HasRace(raceIndex)) + if (raceMask.IsEmpty() || raceMask.HasRace(raceIndex)) { for (Class classIndex = Class.Warrior; classIndex < Class.Max; ++classIndex) { - if (rcInfo.ClassMask == -1 || Convert.ToBoolean((1 << ((int)classIndex - 1)) & rcInfo.ClassMask)) + if (rcInfo.ClassMask == -1 || rcInfo.ClassMask == 0 || Convert.ToBoolean((1 << ((int)classIndex - 1)) & rcInfo.ClassMask)) { PlayerInfo info = _playerInfo.LookupByKey(Tuple.Create(raceIndex, classIndex)); if (info != null)