fix(Core/Player): Weapon skill gain (#5961)

This commit is contained in:
Kitzunu
2021-05-28 00:49:24 +02:00
committed by GitHub
parent d8911d816f
commit f1b43a8976
5 changed files with 35 additions and 12 deletions

View File

@@ -0,0 +1,6 @@
INSERT INTO `version_db_characters` (`sql_rev`) VALUES ('1622121508190340200');
-- Set fist weapon skill equal to current unarmed skill value
UPDATE `character_skills` `cs_unarmed` INNER JOIN `character_skills` `cs_fist` ON `cs_unarmed`.`guid` = `cs_fist`.`guid`
SET `cs_fist`.`value` = `cs_unarmed`.`value`, `cs_fist`.`max` = `cs_unarmed`.`max`
WHERE `cs_unarmed`.`skill` = 162 AND `cs_fist`.`skill` = 473;

View File

@@ -266,6 +266,7 @@ public:
// FG: some hacky helpers
void ForceValuesUpdateAtIndex(uint32);
[[nodiscard]] inline bool IsPlayer() const { return GetTypeId() == TYPEID_PLAYER; }
Player* ToPlayer() { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(this); else return nullptr; }
[[nodiscard]] Player const* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return (Player const*)((Player*)this); else return nullptr; }
Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return nullptr; }

View File

@@ -6511,29 +6511,40 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
return false;
}
void Player::UpdateWeaponSkill(WeaponAttackType attType)
void Player::UpdateWeaponSkill(Unit* victim, WeaponAttackType attType)
{
// no skill gain in pvp
Unit* victim = GetVictim();
if (victim && victim->GetTypeId() == TYPEID_PLAYER)
return;
if (IsInFeralForm())
return; // always maximized SKILL_FERAL_COMBAT in fact
if (GetShapeshiftForm() == FORM_TREE)
return; // use weapon but not skill up
if (victim && victim->GetTypeId() == TYPEID_UNIT && (victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILL_GAINS))
if (victim->GetTypeId() == TYPEID_UNIT && (victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILL_GAINS))
return;
uint32 weapon_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_WEAPON);
Item* tmpitem = GetWeaponForAttack(attType, true);
if (!tmpitem && attType == BASE_ATTACK)
{
// Keep unarmed & fist weapon skills in sync
UpdateSkill(SKILL_UNARMED, weapon_skill_gain);
else if (tmpitem && tmpitem->GetTemplate()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE)
UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain);
UpdateSkill(SKILL_FIST_WEAPONS, weapon_skill_gain);
}
else if (tmpitem)
{
switch (tmpitem->GetTemplate()->SubClass)
{
case ITEM_SUBCLASS_WEAPON_FISHING_POLE:
break;
case ITEM_SUBCLASS_WEAPON_FIST:
UpdateSkill(SKILL_UNARMED, weapon_skill_gain);
[[fallthrough]];
default:
UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain);
break;
}
}
UpdateAllCritPercentages();
}
@@ -6569,7 +6580,7 @@ void Player::UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool def
if (defence)
UpdateDefense();
else
UpdateWeaponSkill(attType);
UpdateWeaponSkill(victim, attType);
}
else
return;

View File

@@ -2067,7 +2067,7 @@ public:
void UpdateLocalChannels(uint32 newZone);
void UpdateDefense();
void UpdateWeaponSkill (WeaponAttackType attType);
void UpdateWeaponSkill(Unit* victim, WeaponAttackType attType);
void UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defence);
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal);

View File

@@ -15518,7 +15518,12 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
return;
// Update skills here for players
if (GetTypeId() == TYPEID_PLAYER)
// only when you are not fighting other players or their pets/totems (pvp)
if (GetTypeId() == TYPEID_PLAYER &&
target->GetTypeId() != TYPEID_PLAYER &&
!(target->IsTotem() && target->ToTotem()->GetOwner()->IsPlayer()) &&
!target->IsPet()
)
{
// On melee based hit/miss/resist need update skill (for victim and attacker)
if (procExtra & (PROC_EX_NORMAL_HIT | PROC_EX_MISS | PROC_EX_RESIST))