Skip to content

Commit

Permalink
Core/Spells: fixed learning skills via spells and removed the unneede…
Browse files Browse the repository at this point in the history
…d implementation for automatically learning riding spells (they are being taught by quest reward spells or level up autolearn spell effects)
  • Loading branch information
Ovahlord committed Jan 29, 2024
1 parent f33f8e0 commit 693329a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
17 changes: 5 additions & 12 deletions src/server/game/Entities/Player/Player.cpp
Expand Up @@ -140,9 +140,7 @@

enum PlayerSpells
{
SPELL_EXPERIENCE_ELIMINATED = 206662,
SPELL_APPRENTICE_RIDING = 33389,
SPELL_JOURNEYMAN_RIDING = 33391
SPELL_EXPERIENCE_ELIMINATED = 206662
};

static uint32 copseReclaimDelay[MAX_DEATH_COUNT] = { 30, 60, 120 };
Expand Down Expand Up @@ -23910,6 +23908,10 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue, Races r
continue;
}

// AcquireMethod == 2 && NumSkillUps == 1 --> automatically learn riding skill spell, else we skip it (client shows riding in spellbook as trainable).
if (skillId == SKILL_RIDING && (ability->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN || ability->NumSkillUps != 1))
continue;

// Check race if set
if (!ability->RaceMask.IsEmpty() && !ability->RaceMask.HasRace(race))
continue;
Expand All @@ -23920,15 +23922,6 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue, Races r

// Check level, skip class spells if not high enough
uint32 requiredLevel = std::max(spellInfo->SpellLevel, spellInfo->BaseLevel);

// riding special cases
if (skillId == SKILL_RIDING)
{
if (GetClassMask() & ((1 << (CLASS_DEATH_KNIGHT - 1)) | (1 << (CLASS_DEMON_HUNTER - 1)))
&& (ability->Spell == SPELL_APPRENTICE_RIDING || ability->Spell == SPELL_JOURNEYMAN_RIDING))
requiredLevel = 0;
}

if (requiredLevel > GetLevel())
continue;

Expand Down
14 changes: 7 additions & 7 deletions src/server/game/Spells/SpellEffects.cpp
Expand Up @@ -2286,7 +2286,7 @@ void Spell::EffectLearnSkill()
if (!playerTarget)
return;

if (damage < 1)
if (damage < 0)
return;

uint32 skillid = effectInfo->MiscValue;
Expand All @@ -2299,12 +2299,12 @@ void Spell::EffectLearnSkill()
return;

uint16 skillval = std::max<uint16>(1, playerTarget->GetPureSkillValue(skillid));
uint16 maxSkillVal = tier->GetValueForTierIndex(damage - 1);
uint16 maxSkillVal = tier->GetValueForTierIndex(damage);

if (rcEntry->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE)
skillval = maxSkillVal;

playerTarget->SetSkill(skillid, damage, skillval, maxSkillVal);
playerTarget->SetSkill(skillid, (damage + 1), skillval, maxSkillVal);
}

void Spell::EffectPlayMovie()
Expand Down Expand Up @@ -4550,11 +4550,11 @@ void Spell::EffectSkill()
if (!playerTarget)
return;

if (damage < 1)
if (damage < 0)
return;

uint32 skillid = effectInfo->MiscValue;
if (playerTarget->GetSkillStep(skillid) >= damage)
if (playerTarget->GetSkillStep(skillid) >= (damage + 1))
return;

SkillRaceClassInfoEntry const* rcEntry = sDB2Manager.GetSkillRaceClassInfo(skillid, playerTarget->GetRace(), playerTarget->GetClass());
Expand All @@ -4566,12 +4566,12 @@ void Spell::EffectSkill()
return;

uint16 skillval = std::max<uint16>(1, playerTarget->GetPureSkillValue(skillid));
uint16 maxSkillVal = tier->GetValueForTierIndex(damage - 1);
uint16 maxSkillVal = tier->GetValueForTierIndex(damage);

if (rcEntry->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE)
skillval = maxSkillVal;

playerTarget->SetSkill(skillid, damage, skillval, maxSkillVal);
playerTarget->SetSkill(skillid, (damage + 1), skillval, maxSkillVal);
}

void Spell::EffectSpiritHeal()
Expand Down

0 comments on commit 693329a

Please sign in to comment.