introduce global rate boost talkaction

This commit is contained in:
ErikasKontenis 2020-02-23 16:57:24 +02:00
parent f22ca79046
commit 3ae18f0c5f
5 changed files with 75 additions and 7 deletions

View File

@ -1 +1 @@
next: 17585
next: 17593

View File

@ -191,6 +191,10 @@ function Player:onGainExperience(source, exp, rawExp)
end
end
if getGlobalStorageValue(17589) > os.time() then
exp = exp * (1 + getGlobalStorageValue(17585) / 100)
end
return exp
end
@ -204,7 +208,20 @@ function Player:onGainSkillTries(skill, tries)
end
if skill == SKILL_MAGLEVEL then
return tries * configManager.getNumber(configKeys.RATE_MAGIC)
tries = tries * configManager.getNumber(configKeys.RATE_MAGIC)
if getGlobalStorageValue(17591) > os.time() then
tries = tries * (1 + getGlobalStorageValue(17587) / 100)
end
return tries * configManager.getNumber(configKeys.RATE_SKILL)
return tries
end
tries = tries * configManager.getNumber(configKeys.RATE_SKILL)
if getGlobalStorageValue(17590) > os.time() then
tries = tries * (1 + getGlobalStorageValue(17586) / 100)
end
return tries
end

View File

@ -207,6 +207,8 @@
<vocation name="Druid" />
<vocation name="Master Sorcerer" />
<vocation name="Elder Druid" />
<vocation name="Paladin" />
<vocation name="Royal Paladin" />
</instant>
<!-- Attack Rune Spells -->

View File

@ -0,0 +1,48 @@
local config = {
['exp'] = {skillKey = 17585, timeKey = 17589},
['skill'] = {skillKey = 17586, timeKey = 17590},
['magic'] = {skillKey = 17587, timeKey = 17591},
['loot'] = {skillKey = 17588, timeKey = 17592} -- TODO
}
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,loot,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, loot, 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

View File

@ -38,6 +38,7 @@
<talkaction words="/storagevalue" separator=" " script="storagevalue.lua" />
<talkaction words="/minimap" separator=" " script="minimap_scan.lua" />
<talkaction words="/removehouse" separator=" " script="remove_house.lua" />
<talkaction words="/globalboost" separator=" " script="global_rate_boost.lua" />
<!-- player talkactions -->
<talkaction words="!buypremium" script="buyprem.lua"/>