diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index 2efc7d92f75..78653733b58 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -535,20 +535,17 @@ function Player:onGainExperience(target, exp, rawExp) self:addCondition(soulCondition) end - -- XP Boost Bonus - useStaminaXpBoost(self) -- Use stamina XP boost (store or daily reward) + -- Apply XP Boost (Store or Daily Reward) + useStaminaXpBoost(self) local xpBoostTimeLeft = self:getXpBoostTime() - local stillHasXpBoost = xpBoostTimeLeft > 0 - local xpBoostPercent = stillHasXpBoost and self:getXpBoostPercent() or 0 - - self:setXpBoostPercent(xpBoostPercent) + local hasXpBoost = xpBoostTimeLeft > 0 + local xpBoostPercent = hasXpBoost and self:getXpBoostPercent() or 0 -- Stamina Bonus local staminaBonusXp = 1 - local isStaminaEnabled = configManager.getBoolean(configKeys.STAMINA_SYSTEM) - useStamina(self, isStaminaEnabled) - if isStaminaEnabled then + if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then + useStamina(self, true) staminaBonusXp = self:getFinalBonusStamina() self:setStaminaXpBoost(staminaBonusXp * 100) end @@ -556,12 +553,12 @@ function Player:onGainExperience(target, exp, rawExp) -- Concoction System useConcoctionTime(self) - -- Boosted creature - if target:getName():lower() == (Game.getBoostedCreature()):lower() then + -- Apply Boosted Creature Bonus + if target:getName():lower() == Game.getBoostedCreature():lower() then exp = exp * 2 end - -- Prey system + -- Prey System if configManager.getBoolean(configKeys.PREY_ENABLED) then local monsterType = target:getType() if monsterType and monsterType:raceId() > 0 then @@ -569,18 +566,20 @@ function Player:onGainExperience(target, exp, rawExp) end end + -- VIP Bonus Experience if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then local vipBonusExp = configManager.getNumber(configKeys.VIP_BONUS_EXP) if vipBonusExp > 0 and self:isVip() then - vipBonusExp = (vipBonusExp > 100 and 100) or vipBonusExp - exp = exp * (1 + (vipBonusExp / 100)) + exp = exp * (1 + math.min(vipBonusExp, 100) / 100) end end - local lowLevelBonuxExp = self:getFinalLowLevelBonus() - local baseRate = self:getFinalBaseRateExperience() + -- Final Adjustments: Low Level Bonus and Base Rate + local lowLevelBonusExp = self:getFinalLowLevelBonus() + local baseRateExp = self:getFinalBaseRateExperience() - return (exp + (exp * (xpBoostPercent / 100) + (exp * (lowLevelBonuxExp / 100)))) * staminaBonusXp * baseRate + -- Return final experience value + return (exp * (1 + xpBoostPercent / 100 + lowLevelBonusExp / 100)) * staminaBonusXp * baseRateExp end function Player:onLoseExperience(exp) @@ -592,42 +591,35 @@ function Player:onGainSkillTries(skill, tries) if IsRunningGlobalDatapack() and isSkillGrowthLimited(self, skill) then return 0 end + if not APPLY_SKILL_MULTIPLIER then return tries end - -- Event scheduler skill rate - local STAGES_DEFAULT = nil - if configManager.getBoolean(configKeys.RATE_USE_STAGES) then - STAGES_DEFAULT = skillsStages - end - local SKILL_DEFAULT = self:getSkillLevel(skill) - local RATE_DEFAULT = configManager.getNumber(configKeys.RATE_SKILL) + -- Default skill rate settings + local rateSkillStages = configManager.getBoolean(configKeys.RATE_USE_STAGES) and skillsStages or nil + local currentSkillLevel = self:getSkillLevel(skill) + local baseRate = configManager.getNumber(configKeys.RATE_SKILL) + -- Special case for magic level if skill == SKILL_MAGLEVEL then - -- Magic Level - if configManager.getBoolean(configKeys.RATE_USE_STAGES) then - STAGES_DEFAULT = magicLevelStages - end - SKILL_DEFAULT = self:getBaseMagicLevel() - RATE_DEFAULT = configManager.getNumber(configKeys.RATE_MAGIC) + rateSkillStages = configManager.getBoolean(configKeys.RATE_USE_STAGES) and magicLevelStages or nil + currentSkillLevel = self:getBaseMagicLevel() + baseRate = configManager.getNumber(configKeys.RATE_MAGIC) end - local skillOrMagicRate = getRateFromTable(STAGES_DEFAULT, SKILL_DEFAULT, RATE_DEFAULT) + -- Calculate skill rate from stages and schedule + local skillRate = getRateFromTable(rateSkillStages, currentSkillLevel, baseRate) + skillRate = (SCHEDULE_SKILL_RATE ~= 100) and (skillRate * SCHEDULE_SKILL_RATE / 100) or skillRate - if SCHEDULE_SKILL_RATE ~= 100 then - skillOrMagicRate = math.max(0, (skillOrMagicRate * SCHEDULE_SKILL_RATE) / 100) + -- Apply VIP boost if applicable + if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) and self:isVip() then + local vipBonusSkill = math.min(configManager.getNumber(configKeys.VIP_BONUS_SKILL), 100) + skillRate = skillRate + (skillRate * (vipBonusSkill / 100)) end - if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then - local vipBoost = configManager.getNumber(configKeys.VIP_BONUS_SKILL) - if vipBoost > 0 and self:isVip() then - vipBoost = (vipBoost > 100 and 100) or vipBoost - skillOrMagicRate = skillOrMagicRate + (skillOrMagicRate * (vipBoost / 100)) - end - end - - return tries / 100 * (skillOrMagicRate * 100) + -- Calculate and return the final experience gain + return tries * skillRate end function Player:onCombat(target, item, primaryDamage, primaryType, secondaryDamage, secondaryType) @@ -678,24 +670,3 @@ function Player:onChangeZone(zone) end function Player:onInventoryUpdate(item, slot, equip) end - -function Player:getURL() - local playerLink = string.gsub(self:getName(), "%s+", "+") - local serverURL = configManager.getString(configKeys.URL) - return serverURL .. "/characters/" .. playerLink -end - -function Player:getMarkdownLink() - local vocation = self:vocationAbbrev() - local emoji = ":school_satchel:" - if self:isKnight() then - emoji = ":crossed_swords:" - elseif self:isPaladin() then - emoji = ":bow_and_arrow:" - elseif self:isDruid() then - emoji = ":herb:" - elseif self:isSorcerer() then - emoji = ":crystal_ball:" - end - return "**[" .. self:getName() .. "](" .. self:getURL() .. ")** " .. emoji .. " [_" .. vocation .. "_]" -end diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index a8497b9bef1..3f7c8e17b75 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -987,3 +987,25 @@ function Player:canGetReward(rewardId, questName) return true end + +function Player.getURL(self) + local playerName = self:getName():gsub("%s+", "+") + local serverURL = configManager.getString(configKeys.URL) + + return serverURL .. "/characters/" .. playerName +end + +local emojiMap = { + ["knight"] = ":crossed_swords:", + ["paladin"] = ":bow_and_arrow:", + ["druid"] = ":herb:", + ["sorcerer"] = ":crystal_ball:", +} + +function Player.getMarkdownLink(self) + local vocation = self:vocationAbbrev() + local emoji = emojiMap[self:getVocation():getName():lower()] or ":school_satchel:" + local playerURL = self:getURL() + + return string.format("**[%s](%s)** %s [_%s_]", self:getName(), playerURL, emoji, vocation) +end diff --git a/data/scripts/actions/items/mystery_box.lua b/data/scripts/actions/items/mystery_box.lua deleted file mode 100644 index 6afdf3ca464..00000000000 --- a/data/scripts/actions/items/mystery_box.lua +++ /dev/null @@ -1,13 +0,0 @@ -local mysteryBox = Action() - -function mysteryBox.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local items = { 25361, 25360 } - local randomItem = items[math.random(#items)] - player:addItem(randomItem, 1) - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) - item:remove(1) - return true -end - -mysteryBox:id(26186) -mysteryBox:register() diff --git a/src/creatures/monsters/monster.hpp b/src/creatures/monsters/monster.hpp index c52a2a6de05..ed9a628159f 100644 --- a/src/creatures/monsters/monster.hpp +++ b/src/creatures/monsters/monster.hpp @@ -47,7 +47,6 @@ class Monster final : public Creature { const std::string &getTypeName() const override; const std::string &getNameDescription() const override; void setNameDescription(std::string_view nameDescription); - ; std::string getDescription(int32_t) override; CreatureType_t getType() const override; diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 99c8a960677..b8b67b6335f 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -4089,7 +4089,7 @@ void ProtocolGame::sendCyclopediaCharacterInspection() { continue; } - msg.add(imbuementInfo.imbuement->getID()); + msg.add(imbuementInfo.imbuement->getIconID()); itemImbuements++; }