Skip to content

Commit

Permalink
Merge branch 'main' into phacUFPE/fix_speed_and_conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Nov 6, 2024
2 parents 75b0b33 + 3bef034 commit a76a230
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 78 deletions.
97 changes: 34 additions & 63 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -535,52 +535,51 @@ 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

-- 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
exp = math.ceil((exp * self:getPreyExperiencePercentage(monsterType:raceId())) / 100)
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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
22 changes: 22 additions & 0 deletions data/libs/functions/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 0 additions & 13 deletions data/scripts/actions/items/mystery_box.lua

This file was deleted.

1 change: 0 additions & 1 deletion src/creatures/monsters/monster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4089,7 +4089,7 @@ void ProtocolGame::sendCyclopediaCharacterInspection() {
continue;
}

msg.add<uint16_t>(imbuementInfo.imbuement->getID());
msg.add<uint16_t>(imbuementInfo.imbuement->getIconID());
itemImbuements++;
}

Expand Down

0 comments on commit a76a230

Please sign in to comment.