mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 14:46:24 +00:00
Merge branch 'azerothcore:master' into Playerbot
This commit is contained in:
@@ -982,42 +982,56 @@ void Player::UpdateWeaponSkill(Unit* victim, WeaponAttackType attType, Item* ite
|
||||
|
||||
void Player::UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defence, Item* item /*= nullptr*/)
|
||||
{
|
||||
uint8 plevel = getLevel(); // if defense than victim == attacker
|
||||
uint8 greylevel = Acore::XP::GetGrayLevel(plevel);
|
||||
uint8 moblevel = victim->getLevelForTarget(this);
|
||||
uint8 playerLevel = getLevel();
|
||||
uint16 currentSkillValue = defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType);
|
||||
uint16 currentSkillMax = 5 * playerLevel;
|
||||
int32 skillDiff = currentSkillMax - currentSkillValue;
|
||||
|
||||
// Max skill reached for level.
|
||||
// Can in some cases be less than 0: having max skill and then .level -1 as example.
|
||||
if (skillDiff <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 greylevel = Acore::XP::GetGrayLevel(playerLevel);
|
||||
uint8 moblevel = defence ? victim->getLevelForTarget(this) : victim->getLevel(); // if defense than victim == attacker
|
||||
/*if (moblevel < greylevel)
|
||||
return;*/
|
||||
// Patch 3.0.8 (2009-01-20): You can no longer skill up weapons on mobs that are immune to damage.
|
||||
|
||||
if (moblevel > plevel + 5)
|
||||
moblevel = plevel + 5;
|
||||
if (moblevel > playerLevel + 5)
|
||||
{
|
||||
moblevel = playerLevel + 5;
|
||||
}
|
||||
|
||||
uint8 lvldif = moblevel - greylevel;
|
||||
int16 lvldif = moblevel - greylevel;
|
||||
if (lvldif < 3)
|
||||
{
|
||||
lvldif = 3;
|
||||
}
|
||||
|
||||
uint32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue()
|
||||
: GetBaseWeaponSkillValue(attType));
|
||||
if (skilldif <= 0)
|
||||
return;
|
||||
|
||||
float chance = float(3 * lvldif * skilldif) / plevel;
|
||||
float chance = float(3 * lvldif * skillDiff) / playerLevel;
|
||||
if (!defence)
|
||||
if (getClass() == CLASS_WARRIOR || getClass() == CLASS_ROGUE)
|
||||
chance += chance * 0.02f * GetStat(STAT_INTELLECT);
|
||||
{
|
||||
chance += chance * 0.02f * GetStat(STAT_INTELLECT);
|
||||
}
|
||||
|
||||
chance =
|
||||
chance < 1.0f ? 1.0f : chance; // minimum chance to increase skill is 1%
|
||||
chance = chance < 1.0f ? 1.0f : chance; // minimum chance to increase skill is 1%
|
||||
|
||||
LOG_DEBUG("entities.player", "Player::UpdateCombatSkills(defence:{}, playerLevel:{}, moblevel:{}) -> ({}/{}) chance to increase skill is {}\%", defence, playerLevel, moblevel, currentSkillValue, currentSkillMax, chance);
|
||||
|
||||
if (roll_chance_f(chance))
|
||||
{
|
||||
if (defence)
|
||||
{
|
||||
UpdateDefense();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateWeaponSkill(victim, attType, item);
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
void Player::UpdateSkillsForLevel()
|
||||
@@ -1403,6 +1417,7 @@ void Player::UpdateFFAPvPState(bool reset /*= true*/)
|
||||
{
|
||||
if (!IsFFAPvP())
|
||||
{
|
||||
sScriptMgr->OnFfaPvpStateUpdate(this, true);
|
||||
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||
for (ControlSet::iterator itr = m_Controlled.begin();
|
||||
itr != m_Controlled.end(); ++itr)
|
||||
@@ -1421,8 +1436,11 @@ void Player::UpdateFFAPvPState(bool reset /*= true*/)
|
||||
!pvpInfo.EndTimer)
|
||||
{
|
||||
pvpInfo.FFAPvPEndTimer = time_t(0);
|
||||
|
||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||
{
|
||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||
sScriptMgr->OnFfaPvpStateUpdate(this, false);
|
||||
}
|
||||
for (ControlSet::iterator itr = m_Controlled.begin();
|
||||
itr != m_Controlled.end(); ++itr)
|
||||
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1,
|
||||
|
||||
Reference in New Issue
Block a user