mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[9731] Cleanup in skil steps code.
* Move step arg in SetSkill to end for make possible for it default value. * Merge GetSkillStep function to SetSkill, base at fact that old GetSkillStep code can be != 0 only for already known spell, so at update
This commit is contained in:
parent
c64a2e8c84
commit
c7095fb3ed
7 changed files with 25 additions and 38 deletions
|
|
@ -4087,7 +4087,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args)
|
|||
HandleLearnSkillRecipesHelper(target,targetSkillInfo->id);
|
||||
|
||||
uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id);
|
||||
target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel);
|
||||
target->SetSkill(targetSkillInfo->id, maxLevel, maxLevel);
|
||||
PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str());
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1118,7 +1118,7 @@ bool ChatHandler::HandleSetSkillCommand(const char* args)
|
|||
if( level <= 0 || level > max || max <= 0 )
|
||||
return false;
|
||||
|
||||
target->SetSkill(skill, target->GetSkillStep(skill), level, max);
|
||||
target->SetSkill(skill, level, max);
|
||||
PSendSysMessage(LANG_SET_SKILL, skill, sl->name[GetSessionDbcLocale()], tNameLink.c_str(), level, max);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -3183,7 +3183,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
if (skill_max_value < new_skill_max_value)
|
||||
skill_max_value = new_skill_max_value;
|
||||
|
||||
SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value);
|
||||
SetSkill(spellLearnSkill->skill, skill_value, skill_max_value, spellLearnSkill->step);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3204,13 +3204,13 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
switch(GetSkillRangeType(pSkill, _spell_idx->second->racemask != 0))
|
||||
{
|
||||
case SKILL_RANGE_LANGUAGE:
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 300, 300 );
|
||||
SetSkill(pSkill->id, 300, 300 );
|
||||
break;
|
||||
case SKILL_RANGE_LEVEL:
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 1, GetMaxSkillValueForLevel() );
|
||||
SetSkill(pSkill->id, 1, GetMaxSkillValueForLevel() );
|
||||
break;
|
||||
case SKILL_RANGE_MONO:
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 1, 1 );
|
||||
SetSkill(pSkill->id, 1, 1 );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -3374,7 +3374,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
{
|
||||
uint32 prev_spell = sSpellMgr.GetPrevSpellInChain(spell_id);
|
||||
if(!prev_spell) // first rank, remove skill
|
||||
SetSkill(spellLearnSkill->skill, 0, 0, 0);
|
||||
SetSkill(spellLearnSkill->skill, 0, 0);
|
||||
else
|
||||
{
|
||||
// search prev. skill setting by spell ranks chain
|
||||
|
|
@ -3386,7 +3386,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
}
|
||||
|
||||
if (!prevSkill) // not found prev skill setting, remove skill
|
||||
SetSkill(spellLearnSkill->skill, 0, 0, 0);
|
||||
SetSkill(spellLearnSkill->skill, 0, 0);
|
||||
else // set to prev. skill setting values
|
||||
{
|
||||
uint32 skill_value = GetPureSkillValue(prevSkill->skill);
|
||||
|
|
@ -3400,7 +3400,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
if (skill_max_value > new_skill_max_value)
|
||||
skill_max_value = new_skill_max_value;
|
||||
|
||||
SetSkill(prevSkill->skill, prevSkill->step, skill_value, skill_max_value);
|
||||
SetSkill(prevSkill->skill, skill_value, skill_max_value, prevSkill->step);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3426,7 +3426,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
(IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask != 0))
|
||||
continue;
|
||||
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 0, 0);
|
||||
SetSkill(pSkill->id, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5518,7 +5518,7 @@ void Player::UpdateSkillsToMaxSkillsForLevel()
|
|||
|
||||
// This functions sets a skill line value (and adds if doesn't exist yet)
|
||||
// To "remove" a skill line, set it's values to zero
|
||||
void Player::SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
|
||||
void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0*/)
|
||||
{
|
||||
if(!id)
|
||||
return;
|
||||
|
|
@ -5530,8 +5530,8 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
|
|||
{
|
||||
if(currVal)
|
||||
{
|
||||
// update step
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), MAKE_PAIR32(id, step));
|
||||
if (step) // need update step
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), MAKE_PAIR32(id, step));
|
||||
// update value
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_SKILL_VALUE(currVal, maxVal));
|
||||
if(itr->second.uState != SKILL_NEW)
|
||||
|
|
@ -5619,18 +5619,6 @@ bool Player::HasSkill(uint32 skill) const
|
|||
return (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED);
|
||||
}
|
||||
|
||||
uint16 Player::GetSkillStep(uint16 skill) const
|
||||
{
|
||||
if(!skill)
|
||||
return 0;
|
||||
|
||||
SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
|
||||
if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
|
||||
return 0;
|
||||
|
||||
return PAIR32_HIPART(GetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos)));
|
||||
}
|
||||
|
||||
uint16 Player::GetSkillValue(uint32 skill) const
|
||||
{
|
||||
if(!skill)
|
||||
|
|
@ -20978,21 +20966,21 @@ void Player::_LoadSkills(QueryResult *result)
|
|||
base_skill = 1; // skill mast be known and then > 0 in any case
|
||||
|
||||
if(GetPureSkillValue (SKILL_FIRST_AID) < base_skill)
|
||||
SetSkill(SKILL_FIRST_AID, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_FIRST_AID, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_AXES) < base_skill)
|
||||
SetSkill(SKILL_AXES, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_AXES, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_DEFENSE) < base_skill)
|
||||
SetSkill(SKILL_DEFENSE, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_DEFENSE, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_POLEARMS) < base_skill)
|
||||
SetSkill(SKILL_POLEARMS, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_POLEARMS, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_SWORDS) < base_skill)
|
||||
SetSkill(SKILL_SWORDS, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_SWORDS, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_2H_AXES) < base_skill)
|
||||
SetSkill(SKILL_2H_AXES, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_2H_AXES, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_2H_SWORDS) < base_skill)
|
||||
SetSkill(SKILL_2H_SWORDS, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_2H_SWORDS, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_UNARMED) < base_skill)
|
||||
SetSkill(SKILL_UNARMED, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_UNARMED, base_skill, base_skill);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1871,7 +1871,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
void UpdateWeaponSkill (WeaponAttackType attType);
|
||||
void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence);
|
||||
|
||||
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal);
|
||||
void SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step = 0);
|
||||
uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
|
||||
uint16 GetPureMaxSkillValue(uint32 skill) const; // max
|
||||
uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
|
||||
|
|
@ -1879,7 +1879,6 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
uint16 GetPureSkillValue(uint32 skill) const; // skill value
|
||||
int16 GetSkillPermBonusValue(uint32 skill) const;
|
||||
int16 GetSkillTempBonusValue(uint32 skill) const;
|
||||
uint16 GetSkillStep(uint16 skill) const; // 0...6
|
||||
bool HasSkill(uint32 skill) const;
|
||||
void learnSkillRewardedSpells(uint32 id, uint32 value);
|
||||
|
||||
|
|
|
|||
|
|
@ -87,5 +87,5 @@ void WorldSession::HandleUnlearnSkillOpcode(WorldPacket & recv_data)
|
|||
{
|
||||
uint32 skill_id;
|
||||
recv_data >> skill_id;
|
||||
GetPlayer()->SetSkill(skill_id, 0, 0, 0);
|
||||
GetPlayer()->SetSkill(skill_id, 0, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4325,7 +4325,7 @@ void Spell::EffectLearnSkill(SpellEffectIndex eff_idx)
|
|||
|
||||
uint32 skillid = m_spellInfo->EffectMiscValue[eff_idx];
|
||||
uint16 skillval = ((Player*)unitTarget)->GetPureSkillValue(skillid);
|
||||
((Player*)unitTarget)->SetSkill(skillid, m_spellInfo->CalculateSimpleValue(eff_idx), skillval ? skillval : 1, damage * 75);
|
||||
((Player*)unitTarget)->SetSkill(skillid, skillval ? skillval : 1, damage * 75, damage);
|
||||
}
|
||||
|
||||
void Spell::EffectAddHonor(SpellEffectIndex /*eff_idx*/)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9730"
|
||||
#define REVISION_NR "9731"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue