mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[7160] Implement (un-)learning skill level dependent spells at skill level change.
Signed-off-by: VladimirMangos <vladimir@getmangos.com> Some related cleanups using new functionality.
This commit is contained in:
parent
bbf8fd0742
commit
94d064be6f
3 changed files with 30 additions and 28 deletions
|
|
@ -4866,6 +4866,11 @@ bool Player::UpdateFishingSkill()
|
|||
return UpdateSkillPro(SKILL_FISHING,chance*10,gathering_skill_gain);
|
||||
}
|
||||
|
||||
// levels sync. with spell requirement for skill levels to learn
|
||||
// bonus abilities in sSkillLineAbilityStore
|
||||
// Used only to avoid scan DBC at each skill grow
|
||||
static uint32 bonusSkillLevels[] = {75,150,225,300,375,450};
|
||||
|
||||
bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
|
||||
{
|
||||
sLog.outDebug("UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance/10.0);
|
||||
|
|
@ -4900,6 +4905,14 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
|
|||
new_value = MaxValue;
|
||||
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(new_value,MaxValue));
|
||||
for(uint32* bsl = &bonusSkillLevels[0]; *bsl; ++bsl)
|
||||
{
|
||||
if((SkillValue < *bsl && new_value >= *bsl))
|
||||
{
|
||||
learnSkillRewardedSpells( SkillId, new_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL);
|
||||
sLog.outDebug("Player::UpdateSkillPro Chance=%3.1f%% taken", Chance/10.0);
|
||||
return true;
|
||||
|
|
@ -5076,6 +5089,7 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
|
|||
if(currVal)
|
||||
{
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal,maxVal));
|
||||
learnSkillRewardedSpells(id, currVal);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL);
|
||||
}
|
||||
else //remove
|
||||
|
|
@ -5086,26 +5100,7 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
|
|||
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0);
|
||||
|
||||
// remove spells that depend on this skill when removing the skill
|
||||
for (PlayerSpellMap::const_iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end(); itr = next)
|
||||
{
|
||||
++next;
|
||||
if(itr->second->state == PLAYERSPELL_REMOVED)
|
||||
continue;
|
||||
|
||||
SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(itr->first);
|
||||
SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(itr->first);
|
||||
|
||||
for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx)
|
||||
{
|
||||
if (_spell_idx->second->skillId == id)
|
||||
{
|
||||
// this may remove more than one spell (dependents)
|
||||
removeSpell(itr->first);
|
||||
next = m_spells.begin();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
learnSkillRewardedSpells(id, 0);
|
||||
}
|
||||
}
|
||||
else if(currVal) //add
|
||||
|
|
@ -5143,7 +5138,7 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
|
|||
(*i)->ApplyModifier(true);
|
||||
|
||||
// Learn all spells for skill
|
||||
learnSkillRewardedSpells(id);
|
||||
learnSkillRewardedSpells(id, currVal);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -18327,7 +18322,7 @@ void Player::learnQuestRewardedSpells()
|
|||
}
|
||||
}
|
||||
|
||||
void Player::learnSkillRewardedSpells(uint32 skill_id )
|
||||
void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value )
|
||||
{
|
||||
uint32 raceMask = getRaceMask();
|
||||
uint32 classMask = getClassMask();
|
||||
|
|
@ -18345,8 +18340,14 @@ void Player::learnSkillRewardedSpells(uint32 skill_id )
|
|||
|
||||
if (sSpellStore.LookupEntry(pAbility->spellId))
|
||||
{
|
||||
// Ok need learn dependent spell
|
||||
learnSpell(pAbility->spellId,true);
|
||||
// need unlearn spell
|
||||
if (skill_value < pAbility->req_skill_value)
|
||||
removeSpell(pAbility->spellId);
|
||||
// need learn
|
||||
else if (!IsInWorld())
|
||||
addSpell(pAbility->spellId,true,true,true,false);
|
||||
else
|
||||
learnSpell(pAbility->spellId,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18358,9 +18359,10 @@ void Player::learnSkillRewardedSpells()
|
|||
if(!GetUInt32Value(PLAYER_SKILL_INDEX(i)))
|
||||
continue;
|
||||
|
||||
uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF;
|
||||
uint32 pskill = SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_INDEX(i)));
|
||||
uint32 vskill = SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)));
|
||||
|
||||
learnSkillRewardedSpells(pskill);
|
||||
learnSkillRewardedSpells(pskill, vskill);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue