From 7319e839373d19d58fa61356af3347b5fae07844 Mon Sep 17 00:00:00 2001 From: Ruan Santos Date: Wed, 23 Aug 2023 16:41:59 -0300 Subject: [PATCH 1/3] Fix to show vip xp bonus on exp rate at skills --- data-canary/scripts/creaturescripts/login.lua | 11 ++++++++++- .../scripts/creaturescripts/others/login.lua | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/data-canary/scripts/creaturescripts/login.lua b/data-canary/scripts/creaturescripts/login.lua index d783f106872..f5afa98d3b1 100644 --- a/data-canary/scripts/creaturescripts/login.lua +++ b/data-canary/scripts/creaturescripts/login.lua @@ -97,7 +97,16 @@ function login.onLogin(player) -- Set Client XP Gain Rate -- if configManager.getBoolean(configKeys.XP_DISPLAY_MODE) then local baseRate = player:getFinalBaseRateExperience() - player:setBaseXpGain(baseRate * 100) + baseRate = baseRate * 100 + if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then + local vipBonusExp = configManager.getNumber(configKeys.VIP_BONUS_EXP) + if (vipBonusExp > 0 and player:isPremium()) then + vipBonusExp = (vipBonusExp > 100 and 100) or vipBonusExp + baseRate = baseRate * (1 + (vipBonusExp / 100)) + player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Normal base xp is: " .. baseRate .. " because you VIP bonus of " ..vipBonusExp) + end + end + player:setBaseXpGain(baseRate) end local staminaBonus = player:getFinalBonusStamina() diff --git a/data-otservbr-global/scripts/creaturescripts/others/login.lua b/data-otservbr-global/scripts/creaturescripts/others/login.lua index cc81da4370f..e38d995a8c2 100644 --- a/data-otservbr-global/scripts/creaturescripts/others/login.lua +++ b/data-otservbr-global/scripts/creaturescripts/others/login.lua @@ -235,7 +235,15 @@ function playerLogin.onLogin(player) -- Set Client XP Gain Rate -- if configManager.getBoolean(configKeys.XP_DISPLAY_MODE) then local baseRate = player:getFinalBaseRateExperience() - player:setBaseXpGain(baseRate * 100) + baseRate = baseRate * 100 + if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then + local vipBonusExp = configManager.getNumber(configKeys.VIP_BONUS_EXP) + if (vipBonusExp > 0 and player:isPremium()) then + vipBonusExp = (vipBonusExp > 100 and 100) or vipBonusExp + baseRate = baseRate * (1 + (vipBonusExp / 100)) + end + end + player:setBaseXpGain(baseRate) end local staminaBonus = player:getFinalBonusStamina() From fc460b63e575533f25fc51003209164cc2563202 Mon Sep 17 00:00:00 2001 From: Ruan Santos Date: Wed, 23 Aug 2023 17:20:43 -0300 Subject: [PATCH 2/3] improvements requested on PR --- data-canary/scripts/creaturescripts/login.lua | 4 ++-- data-otservbr-global/scripts/creaturescripts/others/login.lua | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data-canary/scripts/creaturescripts/login.lua b/data-canary/scripts/creaturescripts/login.lua index f5afa98d3b1..13974cb0e36 100644 --- a/data-canary/scripts/creaturescripts/login.lua +++ b/data-canary/scripts/creaturescripts/login.lua @@ -100,10 +100,10 @@ function login.onLogin(player) baseRate = baseRate * 100 if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then local vipBonusExp = configManager.getNumber(configKeys.VIP_BONUS_EXP) - if (vipBonusExp > 0 and player:isPremium()) then + if (vipBonusExp > 0 and player:isVip()) then vipBonusExp = (vipBonusExp > 100 and 100) or vipBonusExp baseRate = baseRate * (1 + (vipBonusExp / 100)) - player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Normal base xp is: " .. baseRate .. " because you VIP bonus of " ..vipBonusExp) + player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Normal base xp is: " .. baseRate .. "%, because you are VIP, bonus of " ..vipBonusExp .."%") end end player:setBaseXpGain(baseRate) diff --git a/data-otservbr-global/scripts/creaturescripts/others/login.lua b/data-otservbr-global/scripts/creaturescripts/others/login.lua index e38d995a8c2..1ab8137c72b 100644 --- a/data-otservbr-global/scripts/creaturescripts/others/login.lua +++ b/data-otservbr-global/scripts/creaturescripts/others/login.lua @@ -238,9 +238,10 @@ function playerLogin.onLogin(player) baseRate = baseRate * 100 if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then local vipBonusExp = configManager.getNumber(configKeys.VIP_BONUS_EXP) - if (vipBonusExp > 0 and player:isPremium()) then + if (vipBonusExp > 0 and player:isVip()) then vipBonusExp = (vipBonusExp > 100 and 100) or vipBonusExp baseRate = baseRate * (1 + (vipBonusExp / 100)) + player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Normal base xp is: " .. baseRate .. "%, because you are VIP, bonus of " ..vipBonusExp .."%") end end player:setBaseXpGain(baseRate) From a2486a53ecaa4c8a0a23c7afdd4d6ede2f5313aa Mon Sep 17 00:00:00 2001 From: Luan Santos Date: Sat, 26 Aug 2023 11:42:47 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Eduardo Dantas --- data-canary/scripts/creaturescripts/login.lua | 2 +- data-otservbr-global/scripts/creaturescripts/others/login.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data-canary/scripts/creaturescripts/login.lua b/data-canary/scripts/creaturescripts/login.lua index 13974cb0e36..88bdaeefb64 100644 --- a/data-canary/scripts/creaturescripts/login.lua +++ b/data-canary/scripts/creaturescripts/login.lua @@ -100,7 +100,7 @@ function login.onLogin(player) baseRate = baseRate * 100 if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then local vipBonusExp = configManager.getNumber(configKeys.VIP_BONUS_EXP) - if (vipBonusExp > 0 and player:isVip()) then + if vipBonusExp > 0 and player:isVip() then vipBonusExp = (vipBonusExp > 100 and 100) or vipBonusExp baseRate = baseRate * (1 + (vipBonusExp / 100)) player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Normal base xp is: " .. baseRate .. "%, because you are VIP, bonus of " ..vipBonusExp .."%") diff --git a/data-otservbr-global/scripts/creaturescripts/others/login.lua b/data-otservbr-global/scripts/creaturescripts/others/login.lua index 1ab8137c72b..9408c364371 100644 --- a/data-otservbr-global/scripts/creaturescripts/others/login.lua +++ b/data-otservbr-global/scripts/creaturescripts/others/login.lua @@ -238,7 +238,7 @@ function playerLogin.onLogin(player) baseRate = baseRate * 100 if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then local vipBonusExp = configManager.getNumber(configKeys.VIP_BONUS_EXP) - if (vipBonusExp > 0 and player:isVip()) then + if vipBonusExp > 0 and player:isVip() then vipBonusExp = (vipBonusExp > 100 and 100) or vipBonusExp baseRate = baseRate * (1 + (vipBonusExp / 100)) player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Normal base xp is: " .. baseRate .. "%, because you are VIP, bonus of " ..vipBonusExp .."%")