From 2a601a16598fd56fcfa131a3d88bbd7715317358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20Costa?= <54484196+claudiodfc@users.noreply.github.com> Date: Sun, 28 Mar 2021 19:20:25 +0100 Subject: [PATCH] fix(Core): Implement retail-like fishing skill-up functionality (#4809) --- src/server/game/Entities/Player/Player.cpp | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 9a8a61e57..5729798d4 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -6383,6 +6383,24 @@ bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLeve return false; } +float getProbabilityOfLevelUp(uint32 SkillValue) +{ + /* According to El's Extreme Angling page, from 1 to 115 the probability of a skill + * level up is 100% since 100/1 = 100. From 115 - 135 should average 2 catches per + * skill up so that means 100/2 = 50%. + * This returns the probability depending on the player's SkillValue. + */ + if (!SkillValue) + { + return 0.0f; + } + + std::array bounds{ 115, 135, 160, 190, 215, 295, 315, 355, 425, 450 }; + std::array dens{ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 9.0f, 10.0f, 11.0f, 12.0f, 1.0f }; + auto it = std::lower_bound(std::begin(bounds), std::end(bounds), SkillValue); + return 100 / dens[std::distance(std::begin(bounds), it)]; +} + bool Player::UpdateFishingSkill() { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) @@ -6391,11 +6409,15 @@ bool Player::UpdateFishingSkill() uint32 SkillValue = GetPureSkillValue(SKILL_FISHING); - int32 chance = SkillValue < 75 ? 100 : 2500 / (SkillValue - 50); + if (SkillValue >= GetMaxSkillValue(SKILL_FISHING)) + { + return false; + } - uint32 gathering_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_GATHERING); - - return UpdateSkillPro(SKILL_FISHING, chance * 10, gathering_skill_gain); + /* Whenever the player clicks on the fishing gameobject the + * core will decide based on a probability if the skill raises or not. + */ + return UpdateSkillPro(SKILL_FISHING, static_cast(getProbabilityOfLevelUp(SkillValue)) * 10, sWorld->getIntConfig(CONFIG_SKILL_GAIN_GATHERING)); } // levels sync. with spell requirement for skill levels to learn