Core/Objects: Updated UpdateFields

This commit is contained in:
Shauren committed 2012-07-10 18:59:40 +02:00
1 parent 7c7915d526
commit d8ce0c8830
4 files changed
+691 -627

No files matched your search

File diff suppressed because it is too large. Load diff
+176 -128
View File
@@ -78,18 +78,6 @@
#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3))
#define PLAYER_SKILL_VALUE_INDEX(x) (PLAYER_SKILL_INDEX(x)+1)
#define PLAYER_SKILL_BONUS_INDEX(x) (PLAYER_SKILL_INDEX(x)+2)
#define SKILL_VALUE(x) PAIR32_LOPART(x)
#define SKILL_MAX(x) PAIR32_HIPART(x)
#define MAKE_SKILL_VALUE(v, m) MAKE_PAIR32(v, m)
#define SKILL_TEMP_BONUS(x) int16(PAIR32_LOPART(x))
#define SKILL_PERM_BONUS(x) int16(PAIR32_HIPART(x))
#define MAKE_SKILL_BONUS(t, p) MAKE_PAIR32(t, p)
enum CharacterFlags
{
CHARACTER_FLAG_NONE = 0x00000000,
@@ -6195,23 +6183,25 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step)
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return false;
uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos);
uint32 data = GetUInt32Value(valueIndex);
uint32 value = SKILL_VALUE(data);
uint32 max = SKILL_MAX(data);
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
if ((!max) || (!value) || (value >= max))
uint16 value = GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset);
uint16 max = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset);
if (!max || !value || value >= max)
return false;
if (value < max)
{
uint32 new_value = value+step;
uint16 new_value = value + step;
if (new_value > max)
new_value = max;
SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(new_value, max));
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, new_value);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
UpdateSkillEnchantments(skill_id, value, new_value);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, skill_id);
return true;
@@ -6326,36 +6316,38 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return false;
uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos);
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
uint32 data = GetUInt32Value(valueIndex);
uint16 SkillValue = SKILL_VALUE(data);
uint16 MaxValue = SKILL_MAX(data);
uint16 value = GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset);
uint16 max = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset);
if (!MaxValue || !SkillValue || SkillValue >= MaxValue)
if (!max || !value || value >= max)
return false;
int32 Roll = irand(1, 1000);
if (Roll <= Chance)
{
uint32 new_value = SkillValue+step;
if (new_value > MaxValue)
new_value = MaxValue;
uint16 new_value = value + step;
if (new_value > max)
new_value = max;
SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(new_value, MaxValue));
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, new_value);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
for (size_t i = 0; i < bonusSkillLevelsSize; ++i)
{
uint32 bsl = bonusSkillLevels[i];
if (SkillValue < bsl && new_value >= bsl)
if (value < bsl && new_value >= bsl)
{
learnSkillRewardedSpells(SkillId, new_value);
break;
}
}
UpdateSkillEnchantments(SkillId, SkillValue, new_value);
UpdateSkillEnchantments(SkillId, value, new_value);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, SkillId);
sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% taken", Chance / 10.0f);
return true;
@@ -6435,16 +6427,12 @@ void Player::ModifySkillBonus(uint32 skillid, int32 val, bool talent)
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return;
uint32 bonusIndex = PLAYER_SKILL_BONUS_INDEX(itr->second.pos);
uint16 field = itr->second.pos / 2 + (talent ? PLAYER_SKILL_TALENT_0 : PLAYER_SKILL_MODIFIER_0);
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
uint32 bonus_val = GetUInt32Value(bonusIndex);
int16 temp_bonus = SKILL_TEMP_BONUS(bonus_val);
int16 perm_bonus = SKILL_PERM_BONUS(bonus_val);
uint16 bonus = GetUInt16Value(field, offset);
if (talent) // permanent bonus stored in high part
SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus, perm_bonus+val));
else // temporary/item bonus stored in low part
SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus+val, perm_bonus));
SetUInt16Value(field, offset, bonus + val);
}
void Player::UpdateSkillsForLevel()
@@ -6467,10 +6455,11 @@ void Player::UpdateSkillsForLevel()
if (GetSkillRangeType(pSkill, false) != SKILL_RANGE_LEVEL)
continue;
uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos);
uint32 data = GetUInt32Value(valueIndex);
uint32 max = SKILL_MAX(data);
uint32 val = SKILL_VALUE(data);
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
uint16 val = GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset);
uint16 max = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset);
/// update only level dependent max skill values
if (max != 1)
@@ -6478,13 +6467,16 @@ void Player::UpdateSkillsForLevel()
/// maximize skill always
if (alwaysMaxSkill)
{
SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(maxSkill, maxSkill));
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, maxSkill);
SetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset, maxSkill);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
}
else if (max != maxconfskill) /// update max skill value if current max skill not maximized
{
SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(val, maxSkill));
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, val);
SetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset, maxSkill);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
}
@@ -6502,13 +6494,16 @@ void Player::UpdateSkillsToMaxSkillsForLevel()
uint32 pskill = itr->first;
if (IsProfessionOrRidingSkill(pskill))
continue;
uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos);
uint32 data = GetUInt32Value(valueIndex);
uint32 max = SKILL_MAX(data);
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
uint16 max = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset);
if (max > 1)
{
SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(max, max));
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, max);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
}
@@ -6530,22 +6525,29 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
//has skill
if (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED)
{
currVal = SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos)));
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
currVal = GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset);
if (newVal)
{
// if skill value is going down, update enchantments before setting the new value
if (newVal < currVal)
UpdateSkillEnchantments(id, currVal, newVal);
// update step
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_PAIR32(id, step));
SetUInt16Value(PLAYER_SKILL_STEP_0 + field, offset, step);
// update value
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_SKILL_VALUE(newVal, maxVal));
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, newVal);
SetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset, maxVal);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
learnSkillRewardedSpells(id, newVal);
// if skill value is going up, update enchantments after setting the new value
if (newVal > currVal)
UpdateSkillEnchantments(id, currVal, newVal);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id);
}
@@ -6554,9 +6556,12 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
//remove enchantments needing this skill
UpdateSkillEnchantments(id, currVal, 0);
// clear skill fields
SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), 0);
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), 0);
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos), 0);
SetUInt16Value(PLAYER_SKILL_LINEID_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_STEP_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_MODIFIER_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_TALENT_0 + field, offset, 0);
// mark as deleted or simply remove from map if not saved yet
if (itr->second.uState != SKILL_NEW)
@@ -6574,49 +6579,58 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
else if (newVal) //add
{
currVal = 0;
for (int i=0; i < PLAYER_MAX_SKILLS; ++i)
if (!GetUInt32Value(PLAYER_SKILL_INDEX(i)))
for (uint32 i = 0; i < PLAYER_MAX_SKILLS; ++i)
{
SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(id);
if (!pSkill)
uint16 field = i / 2;
uint8 offset = i & 1; // i % 2
if (!GetUInt16Value(PLAYER_SKILL_LINEID_0 + field, offset))
{
sLog->outError("Skill not found in SkillLineStore: skill #%u", id);
SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(id);
if (!pSkill)
{
sLog->outError("Skill not found in SkillLineStore: skill #%u", id);
return;
}
SetUInt16Value(PLAYER_SKILL_LINEID_0 + field, offset, id);
SetUInt16Value(PLAYER_SKILL_STEP_0 + field, offset, step);
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, newVal);
SetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset, maxVal);
UpdateSkillEnchantments(id, currVal, newVal);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id);
// insert new entry or update if not deleted old entry yet
if (itr != mSkillStatus.end())
{
itr->second.pos = i;
itr->second.uState = SKILL_CHANGED;
}
else
mSkillStatus.insert(SkillStatusMap::value_type(id, SkillStatusData(i, SKILL_NEW)));
// apply skill bonuses
SetUInt16Value(PLAYER_SKILL_MODIFIER_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_TALENT_0 + field, offset, 0);
// temporary bonuses
AuraEffectList const& mModSkill = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL);
for (AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
if ((*j)->GetMiscValue() == int32(id))
(*j)->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true);
// permanent bonuses
AuraEffectList const& mModSkillTalent = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL_TALENT);
for (AuraEffectList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j)
if ((*j)->GetMiscValue() == int32(id))
(*j)->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true);
// Learn all spells for skill
learnSkillRewardedSpells(id, newVal);
return;
}
SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id, step));
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i), MAKE_SKILL_VALUE(newVal, maxVal));
UpdateSkillEnchantments(id, currVal, newVal);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id);
// insert new entry or update if not deleted old entry yet
if (itr != mSkillStatus.end())
{
itr->second.pos = i;
itr->second.uState = SKILL_CHANGED;
}
else
mSkillStatus.insert(SkillStatusMap::value_type(id, SkillStatusData(i, SKILL_NEW)));
// apply skill bonuses
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i), 0);
// temporary bonuses
AuraEffectList const& mModSkill = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL);
for (AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
if ((*j)->GetMiscValue() == int32(id))
(*j)->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true);
// permanent bonuses
AuraEffectList const& mModSkillTalent = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL_TALENT);
for (AuraEffectList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j)
if ((*j)->GetMiscValue() == int32(id))
(*j)->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true);
// Learn all spells for skill
learnSkillRewardedSpells(id, newVal);
return;
}
}
}
@@ -6639,7 +6653,7 @@ uint16 Player::GetSkillStep(uint16 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
return PAIR32_HIPART(GetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos)));
return GetUInt16Value(PLAYER_SKILL_STEP_0 + itr->second.pos / 2, itr->second.pos & 1);
}
uint16 Player::GetSkillValue(uint32 skill) const
@@ -6651,11 +6665,12 @@ uint16 Player::GetSkillValue(uint32 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos));
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))));
result += SKILL_TEMP_BONUS(bonus);
result += SKILL_PERM_BONUS(bonus);
int32 result = int32(GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset));
result += int32(GetUInt16Value(PLAYER_SKILL_MODIFIER_0 + field, offset));
result += int32(GetUInt16Value(PLAYER_SKILL_TALENT_0 + field, offset));
return result < 0 ? 0 : result;
}
@@ -6668,11 +6683,12 @@ uint16 Player::GetMaxSkillValue(uint32 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos));
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
int32 result = int32(SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))));
result += SKILL_TEMP_BONUS(bonus);
result += SKILL_PERM_BONUS(bonus);
int32 result = int32(GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset));
result += int32(GetUInt16Value(PLAYER_SKILL_MODIFIER_0 + field, offset));
result += int32(GetUInt16Value(PLAYER_SKILL_TALENT_0 + field, offset));
return result < 0 ? 0 : result;
}
@@ -6685,7 +6701,10 @@ uint16 Player::GetPureMaxSkillValue(uint32 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
return SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos)));
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
return GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset);
}
uint16 Player::GetBaseSkillValue(uint32 skill) const
@@ -6697,8 +6716,11 @@ uint16 Player::GetBaseSkillValue(uint32 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))));
result += SKILL_PERM_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)));
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
int32 result = int32(GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset));
result += int32(GetUInt16Value(PLAYER_SKILL_TALENT_0 + field, offset));
return result < 0 ? 0 : result;
}
@@ -6711,7 +6733,10 @@ uint16 Player::GetPureSkillValue(uint32 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
return SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos)));
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
return GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset);
}
int16 Player::GetSkillPermBonusValue(uint32 skill) const
@@ -6723,7 +6748,10 @@ int16 Player::GetSkillPermBonusValue(uint32 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
return SKILL_PERM_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)));
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
return GetUInt16Value(PLAYER_SKILL_TALENT_0 + field, offset);
}
int16 Player::GetSkillTempBonusValue(uint32 skill) const
@@ -6735,7 +6763,10 @@ int16 Player::GetSkillTempBonusValue(uint32 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
return SKILL_TEMP_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)));
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
return GetUInt16Value(PLAYER_SKILL_MODIFIER_0 + field, offset);
}
void Player::SendActionButtons(uint32 state) const
@@ -14200,17 +14231,13 @@ void Player::UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16
void Player::SendEnchantmentDurations()
{
for (EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr)
{
GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(), itr->slot, uint32(itr->leftduration) / 1000);
}
}
void Player::SendItemDurations()
{
for (ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr)
{
(*itr)->SendTimeUpdate(this);
}
}
void Player::SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast)
@@ -19502,9 +19529,11 @@ void Player::_SaveSkills(SQLTransaction& trans)
continue;
}
uint32 valueData = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos));
uint16 value = SKILL_VALUE(valueData);
uint16 max = SKILL_MAX(valueData);
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
uint16 value = GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset);
uint16 max = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset);
switch (itr->second.uState)
{
@@ -19515,7 +19544,6 @@ void Player::_SaveSkills(SQLTransaction& trans)
stmt->setUInt16(2, value);
stmt->setUInt16(3, max);
trans->Append(stmt);
break;
case SKILL_CHANGED:
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_SKILLS);
@@ -19524,13 +19552,12 @@ void Player::_SaveSkills(SQLTransaction& trans)
stmt->setUInt32(2, GetGUIDLow());
stmt->setUInt16(3, uint16(itr->first));
trans->Append(stmt);
break;
default:
break;
}
itr->second.uState = SKILL_UNCHANGED;
itr->second.uState = SKILL_UNCHANGED;
++itr;
}
}
@@ -24074,6 +24101,7 @@ void Player::_LoadSkills(PreparedQueryResult result)
// SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid));
uint32 count = 0;
uint8 professionCount = 0;
if (result)
{
do
@@ -24116,14 +24144,28 @@ void Player::_LoadSkills(PreparedQueryResult result)
continue;
}
// enable unlearn button for primary professions only
if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION)
SetUInt32Value(PLAYER_SKILL_INDEX(count), MAKE_PAIR32(skill, 1));
else
SetUInt32Value(PLAYER_SKILL_INDEX(count), MAKE_PAIR32(skill, 0));
uint16 field = count / 2;
uint8 offset = count & 1;
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(count), MAKE_SKILL_VALUE(value, max));
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(count), 0);
SetUInt16Value(PLAYER_SKILL_LINEID_0 + field, offset, skill);
uint16 step = 0;
if (pSkill->categoryId == SKILL_CATEGORY_SECONDARY)
step = max / 75;
if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION)
{
step = max / 75;
if (professionCount < 2)
SetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1 + professionCount++, skill);
}
SetUInt16Value(PLAYER_SKILL_STEP_0 + field, offset, step);
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, value);
SetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset, max);
SetUInt16Value(PLAYER_SKILL_MODIFIER_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_TALENT_0 + field, offset, 0);
mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(count, SKILL_UNCHANGED)));
@@ -24142,9 +24184,15 @@ void Player::_LoadSkills(PreparedQueryResult result)
for (; count < PLAYER_MAX_SKILLS; ++count)
{
SetUInt32Value(PLAYER_SKILL_INDEX(count), 0);
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(count), 0);
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(count), 0);
uint16 field = count / 2;
uint8 offset = count & 1;
SetUInt16Value(PLAYER_SKILL_LINEID_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_STEP_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_MODIFIER_0 + field, offset, 0);
SetUInt16Value(PLAYER_SKILL_TALENT_0 + field, offset, 0);
}
// special settings
+1 -1
View File
@@ -57,7 +57,7 @@ class UpdateMask;
typedef std::deque<Mail*> PlayerMails;
#define PLAYER_MAX_SKILLS 127
#define PLAYER_MAX_SKILLS 128
#define PLAYER_MAX_DAILY_QUESTS 25
#define PLAYER_EXPLORED_ZONES_SIZE 128
@@ -2834,17 +2834,17 @@ void AuraEffect::HandleAuraModSkill(AuraApplication const* aurApp, uint8 mode, b
{
if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_SKILL)))
return;
Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER)
Player* target = aurApp->GetTarget()->ToPlayer();
if (!target)
return;
uint32 prot = GetMiscValue();
int32 points = GetAmount();
target->ToPlayer()->ModifySkillBonus(prot, ((apply) ? points: -points), GetAuraType() == SPELL_AURA_MOD_SKILL_TALENT);
target->ModifySkillBonus(prot, (apply ? points : -points), GetAuraType() == SPELL_AURA_MOD_SKILL_TALENT);
if (prot == SKILL_DEFENSE)
target->ToPlayer()->UpdateDefenseBonusesMod();
target->UpdateDefenseBonusesMod();
}
/****************************/