Hello, its been a while since I haven't contributed anything for open tibia community. So, since I am feeling pretty much active these days in open tibia development and having my own server so I am going to contribute a little of things that I do for my own server because open tibia community gives me back a lot too.
data\talkactions\scripts\global_rate_boost.lua
data\events\scripts\player.lua (Custom Lines comment is the place where the changes have been applied)
Type /globalboost exp,100,5 to active double exp boost for 5 hours.
data\talkactions\scripts\global_rate_boost.lua
Lua:
local config = {
['exp'] = {skillKey = 17585, timeKey = 17589},
['skill'] = {skillKey = 17586, timeKey = 17590},
['magic'] = {skillKey = 17587, timeKey = 17591}
}
function onSay(player, words, param)
if not player:getGroup():getAccess() then
return true
end
if player:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end
local split = param:split(",")
if split[3] == nil then
player:sendCancelMessage("Insufficient parameters [(exp,skill,magic),percentage,hours].")
return false
end
local skillName = split[1]
local percentage = tonumber(split[2])
local hours = tonumber(split[3])
local globalStorage = config[skillName]
if not globalStorage then
player:sendCancelMessage("Skill name value must be one of the following: exp, skill, magic.")
return false
end
if percentage <= 0 then
player:sendCancelMessage("Percentage value must be higher than 0. For example, 50% means 1.5x higher rate.")
return false
end
if hours <= 0 then
player:sendCancelMessage("Hours value must be higher than 0.")
return false
end
setGlobalStorageValue(globalStorage.skillKey, percentage)
setGlobalStorageValue(globalStorage.timeKey, os.time() + hours * 60 * 60)
broadcastMessage(player:getName() .. " have activated the global " .. percentage .. "% " .. skillName .. " rate boost for next " .. hours .. " " .. (hours == 1 and "hour" or "hours") .. ".", MESSAGE_STATUS_WARNING)
return false
end
XML:
<talkaction words="/globalboost" separator=" " script="global_rate_boost.lua" />
data\events\scripts\player.lua (Custom Lines comment is the place where the changes have been applied)
Lua:
function Player:onGainExperience(source, exp, rawExp)
if not source or source:isPlayer() then
return exp
end
-- Soul regeneration
local vocation = self:getVocation()
if self:getSoul() < vocation:getMaxSoul() and exp >= self:getLevel() then
soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
self:addCondition(soulCondition)
end
-- Apply experience stage multiplier
exp = exp * Game.getExperienceStage(self:getLevel())
-- Stamina modifier
if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
useStamina(self)
local staminaMinutes = self:getStamina()
if staminaMinutes > 2400 and self:isPremium() then
exp = exp * 1.5
elseif staminaMinutes <= 840 then
exp = exp * 0.5
end
end
-- Custom Lines
if getGlobalStorageValue(17589) > os.time() then
exp = exp * (1 + getGlobalStorageValue(17585) / 100)
end
-- Custom Lines
return exp
end
Lua:
function Player:onGainSkillTries(skill, tries)
if APPLY_SKILL_MULTIPLIER == false then
return tries
end
if skill == SKILL_MAGLEVEL then
tries = tries * configManager.getNumber(configKeys.RATE_MAGIC)
-- Custom Lines
if getGlobalStorageValue(17591) > os.time() then
tries = tries * (1 + getGlobalStorageValue(17587) / 100)
end
-- Custom Lines
return tries
end
tries = tries * configManager.getNumber(configKeys.RATE_SKILL)
-- Custom Lines
if getGlobalStorageValue(17590) > os.time() then
tries = tries * (1 + getGlobalStorageValue(17586) / 100)
end
-- Custom Lines
return tries
end
Type /globalboost exp,100,5 to active double exp boost for 5 hours.