mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
feat(Core/Scripting): Add Player skill based hook (#21273)
Co-authored-by: IntelligentQuantum <IntelligentQuantum@ProtonMail.Com> Co-authored-by: Ludwig <sudlud@users.noreply.github.com>
This commit is contained in:
@@ -708,7 +708,7 @@ void Player::UpdateAllRatings()
|
||||
// skill+step, checking for max value
|
||||
bool Player::UpdateSkill(uint32 skill_id, uint32 step)
|
||||
{
|
||||
if (!skill_id)
|
||||
if (!skill_id || !sScriptMgr->CanPlayerUpdateSkill(this, skill_id))
|
||||
return false;
|
||||
|
||||
SkillStatusMap::iterator itr = mSkillStatus.find(skill_id);
|
||||
@@ -720,6 +720,8 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step)
|
||||
uint32 value = SKILL_VALUE(data);
|
||||
uint32 max = SKILL_MAX(data);
|
||||
|
||||
sScriptMgr->OnBeforePlayerUpdateSkill(this, skill_id, value, max, step);
|
||||
|
||||
if ((!max) || (!value) || (value >= max))
|
||||
return false;
|
||||
|
||||
@@ -736,6 +738,8 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step)
|
||||
UpdateSkillEnchantments(skill_id, value, new_value);
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,
|
||||
skill_id);
|
||||
|
||||
sScriptMgr->OnPlayerUpdateSkill(this, skill_id, value, max, step, new_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -911,7 +915,7 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
|
||||
LOG_DEBUG("entities.player.skills",
|
||||
"UpdateSkillPro(SkillId {}, Chance {:3.1f}%)", SkillId,
|
||||
Chance / 10.0f);
|
||||
if (!SkillId)
|
||||
if (!SkillId || !sScriptMgr->CanPlayerUpdateSkill(this, SkillId))
|
||||
return false;
|
||||
|
||||
if (Chance <= 0) // speedup in 0 chance case
|
||||
@@ -929,8 +933,10 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
|
||||
uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos);
|
||||
|
||||
uint32 data = GetUInt32Value(valueIndex);
|
||||
uint16 SkillValue = SKILL_VALUE(data);
|
||||
uint16 MaxValue = SKILL_MAX(data);
|
||||
uint32 SkillValue = SKILL_VALUE(data);
|
||||
uint32 MaxValue = SKILL_MAX(data);
|
||||
|
||||
sScriptMgr->OnBeforePlayerUpdateSkill(this, SkillId, SkillValue, MaxValue, step);
|
||||
|
||||
if (!MaxValue || !SkillValue || SkillValue >= MaxValue)
|
||||
return false;
|
||||
@@ -962,6 +968,8 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
|
||||
LOG_DEBUG("entities.player.skills",
|
||||
"Player::UpdateSkillPro Chance={:3.1f}% taken",
|
||||
Chance / 10.0f);
|
||||
|
||||
sScriptMgr->OnPlayerUpdateSkill(this, SkillId, SkillValue, MaxValue, step, new_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user