function onSay(player, words, param)
player:setStoreXpBoost(30)
return false
end
function Player:onGainExperience(source, exp, rawExp)
if not source or source:isPlayer() then
return exp
end
exp = exp * configexp[os.date("%A")]
-- 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
self:setStoreXpBoost(50)
elseif staminaMinutes <= 840 then
exp = exp * 0.5
self:setStaminaXpBoost(50)
end
end
-- exp card
if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0 then
exp = exp * BONUS_EXP_MULT
self:setStoreXpBoost(30)
end
-- exp card
return exp
end
local BONUS_EXP_STORAGE = 61398
local BONUS_EXP_MULT = 1.2
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
-- BONUS EXP I WANT TO ADD HERE THE FUNCTION
if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0 then
exp = exp * BONUS_EXP_MULT -- 20%
end
return exp
end
if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0
{
msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*120); // base xp gain rate
}
else
{
msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100); // base xp gain rate
}
This exactly the reason as to why I uploaded the patch in the first place. You shouldn't have to resort to additional source modifications like that when you already got the opportunity to manipulate boost values in Lua.I tried this way:
C++:if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0 { msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*120); // base xp gain rate } else { msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100); // base xp gain rate }
registerMethod("Player", "getBaseXpGain", LuaScriptInterface::luaPlayerGetBaseXpGain);
registerMethod("Player", "setBaseXpGain", LuaScriptInterface::luaPlayerSetBaseXpGain);
registerMethod("Player", "getVoucherXpBoost", LuaScriptInterface::luaPlayerGetVoucherXpBoost);
registerMethod("Player", "setVoucherXpBoost", LuaScriptInterface::luaPlayerSetVoucherXpBoost);
registerMethod("Player", "getGrindingXpBoost", LuaScriptInterface::luaPlayerGetGrindingXpBoost);
registerMethod("Player", "setGrindingXpBoost", LuaScriptInterface::luaPlayerSetGrindingXpBoost);
registerMethod("Player", "getStoreXpBoost", LuaScriptInterface::luaPlayerGetStoreXpBoost);
registerMethod("Player", "setStoreXpBoost", LuaScriptInterface::luaPlayerSetStoreXpBoost);
registerMethod("Player", "getStaminaXpBoost", LuaScriptInterface::luaPlayerGetStaminaXpBoost);
registerMethod("Player", "setStaminaXpBoost", LuaScriptInterface::luaPlayerSetStaminaXpBoost);
player:setBaseXpGain(300) -- Base XP Gain set to 300% (Base value = 100)
player:setVoucherXpBoost(200) -- Voucher XP Boost set to 200% (Base value = 0)
player:setGrindingXpBoost(200) -- Grinding XP Boost set to 200% (Base value = 0)
player:setStoreXpBoost(200) -- Store XP Boost set to 200% (Base value = 0)
player:setStaminaXpBoost(150) -- Stamina XP Boost set to 50% (Base value = 100)
This exactly the reason as to why I uploaded the patch in the first place. You shouldn't have to resort to additional source modifications like that when you already got the opportunity to manipulate boost values in Lua.
Available methods:
C++:registerMethod("Player", "getBaseXpGain", LuaScriptInterface::luaPlayerGetBaseXpGain); registerMethod("Player", "setBaseXpGain", LuaScriptInterface::luaPlayerSetBaseXpGain); registerMethod("Player", "getVoucherXpBoost", LuaScriptInterface::luaPlayerGetVoucherXpBoost); registerMethod("Player", "setVoucherXpBoost", LuaScriptInterface::luaPlayerSetVoucherXpBoost); registerMethod("Player", "getGrindingXpBoost", LuaScriptInterface::luaPlayerGetGrindingXpBoost); registerMethod("Player", "setGrindingXpBoost", LuaScriptInterface::luaPlayerSetGrindingXpBoost); registerMethod("Player", "getStoreXpBoost", LuaScriptInterface::luaPlayerGetStoreXpBoost); registerMethod("Player", "setStoreXpBoost", LuaScriptInterface::luaPlayerSetStoreXpBoost); registerMethod("Player", "getStaminaXpBoost", LuaScriptInterface::luaPlayerGetStaminaXpBoost); registerMethod("Player", "setStaminaXpBoost", LuaScriptInterface::luaPlayerSetStaminaXpBoost);
Here is an example on how to alter the XP Gain Rate value in the skills window:
Lua:player:setBaseXpGain(300) -- Base XP Gain set to 300% (Base value = 100) player:setVoucherXpBoost(200) -- Voucher XP Boost set to 200% (Base value = 0) player:setGrindingXpBoost(200) -- Grinding XP Boost set to 200% (Base value = 0) player:setStoreXpBoost(200) -- Store XP Boost set to 200% (Base value = 0) player:setStaminaXpBoost(150) -- Stamina XP Boost set to 50% (Base value = 100)
You will just have to come up with a clever method to implement this to your server (as in updating a certain boost value dependent on a time-based storage value). Good luck!
if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0 then
self:setBaseXpGain(130)
self:setStoreXpBoost(120)
exp = exp * BONUS_EXP_MULT1
end
function onThink(creature, interval)
-- exp card
if creature:getStorageValue(61398) - os.time() > 0 then
BonusVaucherExpHearth = 30
else
BonusVaucherExpHearth = 0.0
end
-- exp card
local staminaMinutes = creature:getStamina()
staminaExpBonusClient = 0
if staminaMinutes > 2400 then
staminaExpBonusClient = 50
end
if os.date("%A") == "Saturday" or os.date("%A") == "Sunday" then
BonusExpDayClient = 100
else
BonusExpDayClient = 0
end
local daysvipclient = creature:getVipDays()
if daysvipclient > 0 then
vipClientExp = 30
else
vipClientExp = 0
end
creature:setStoreXpBoost(vipClientExp + BonusExpDayClient + staminaExpBonusClient + BonusVaucherExpHearth)
return true
end