Last active
January 6, 2016 16:58
-
-
Save dbjorkholm/fd5ea0d2ca5ab8c93000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local config = { | |
time = 2, | |
storage = 200011 | |
} | |
function onUse(player, item, fromPosition, target, toPosition, isHotkey) | |
if player:getStorageValue(config.storage) >= os.time() then | |
player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have extra experience time left.") | |
return true | |
end | |
player:setStorageValue(config.storage, os.time() + config.time * 3600) | |
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have activated %d hour%s of double experience.", config.time, config.time ~= 1 and "s" or "")) | |
item:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) | |
item:remove(1) | |
return true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local config = { | |
rate = 2, | |
storage = 200011, | |
} | |
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 | |
-- Apply Extra Experience | |
if self:getStorageValue(config.storage) >= os.time() then | |
exp = exp * config.rate | |
end | |
return exp | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment