diff options
author | Shauren <shauren.trinity@gmail.com> | 2015-09-29 00:11:26 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2015-10-31 18:57:59 +0100 |
commit | 635dc9c02a4462ea8879f9019acdb23430dbc663 (patch) | |
tree | 20e9493fc5b72d1d391f418f224e91b792f83636 /src | |
parent | 3a4f33d007f3898f9fd1be5a0ccfda3b0451c979 (diff) |
Core/Players: Fixed automatic learning skills gained from learning spells when leveling
Closes #15391
(cherry picked from commit 3fceabfa113983549b5784dfd3f42259a53c258b)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 51 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 4 |
2 files changed, 29 insertions, 26 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 0bc9eba6538..232f7cb58df 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -3551,7 +3551,7 @@ bool Player::AddTalent(uint32 spellId, uint8 spec, bool learning) return false; } -bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, bool fromSkill /*= false*/) +bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, uint32 fromSkill /*= 0*/) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) @@ -3809,10 +3809,10 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent SkillLineAbilityMapBounds skill_bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellId); - // add dependent skills if this spell is not learned from adding skill already - if (!fromSkill) + if (SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId)) { - if (SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId)) + // add dependent skills if this spell is not learned from adding skill already + if (spellLearnSkill->skill != fromSkill) { uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill); uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill); @@ -3827,26 +3827,29 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value); } - else + } + else + { + // not ranked skills + for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) { - // not ranked skills - for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) - { - SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); - if (!pSkill) - continue; + SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); + if (!pSkill) + continue; - ///@todo: confirm if rogues start with lockpicking skill at level 1 but only receive the spell to use it at level 16 - // Also added for runeforging. It's already confirmed this happens upon learning for Death Knights, not from character creation. - if ((_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id)) || ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0)) - LearnDefaultSkill(pSkill->id, 0); + if (pSkill->id == fromSkill) + continue; - if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false)) - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && - spellInfo->Effects[i].CalcValue() == 310) - SetHas310Flyer(true); - } + ///@todo: confirm if rogues start with lockpicking skill at level 1 but only receive the spell to use it at level 16 + // Also added for runeforging. It's already confirmed this happens upon learning for Death Knights, not from character creation. + if ((_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id)) || ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0)) + LearnDefaultSkill(pSkill->id, 0); + + if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false)) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && + spellInfo->Effects[i].CalcValue() == 310) + SetHas310Flyer(true); } } @@ -3919,7 +3922,7 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraStateType(spellInfo->CasterAuraState))); } -void Player::LearnSpell(uint32 spell_id, bool dependent, bool fromSkill /*= false*/) +void Player::LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill /*= 0*/) { PlayerSpellMap::iterator itr = m_spells.find(spell_id); @@ -22997,9 +23000,9 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue) RemoveSpell(ability->spellId); // need learn else if (!IsInWorld()) - AddSpell(ability->spellId, true, true, true, false, false, true); + AddSpell(ability->spellId, true, true, true, false, false, ability->skillId); else - LearnSpell(ability->spellId, true, true); + LearnSpell(ability->spellId, true, ability->skillId); } } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 0fc8e716ad8..75f04cb0d7b 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1595,8 +1595,8 @@ class Player : public Unit, public GridObject<Player> void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask); void SendInitialSpells(); - bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, bool fromSkill = false); - void LearnSpell(uint32 spell_id, bool dependent, bool fromSkill = false); + bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, uint32 fromSkill = 0); + void LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill = 0); void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true); void ResetSpells(bool myClassOnly = false); void LearnCustomSpells(); |