Créditos:
Codex NG
Athern
function Player:getCustomSkill(storage)
return self:getStorageValue(storage)
end
function Player:addCustomSkill(skillName, storage)
local skillStorage = math.max(10, self:getStorageValue(storage))
local skillTries = math.max(0, self:getStorageValue(storage + 1))
self:setStorageValue(storage, skillStorage + 1)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You advanced to " .. string.lower(skillName) .. " level "..self:getCustomSkill(storage)..".")
self:setStorageValue(storage + 1, 0)
end
function Player:addCustomSkillTry(skillName, storage)
local skillStorage = math.max(10, self:getStorageValue(storage))
local skillTries = math.max(0, self:getStorageValue(storage + 1))
self:setStorageValue(storage + 1, skillTries + 1)
if skillTries > math.floor(20 * math.pow(1.1, (skillStorage - 11)) / 10) then
self:addCustomSkill(skillName, storage)
end
end
function Player:getCustomSkillPercent(storage)
local skillStorage = math.max(10, self:getStorageValue(storage))
local skillTries = math.max(0, self:getStorageValue(storage + 1))
local triesNeeded = math.floor(20 * math.pow(1.1, (skillStorage - 11)) / 10)
local percent = math.floor(100 * (1 - skillTries / triesNeeded))
if percent > 1 and percent <= 100 then
return percent
else
percent = 1
return percent
end
end
Usando a magia "Haste" como um exemplo, você vai ter que aplicar sua própria formula de aumento de dano, velocidade, etc...
local name = "haste"
local storage = 15000
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
local function x(creature, var)
local condition = Condition(CONDITION_HASTE)
condition:setParameter(CONDITION_PARAM_TICKS, 33000)
condition:setFormula(0.3, -24, 0.3, -24)
combat:setCondition(condition)
creature:addCustomSkillTry(name, storage)
return combat:execute(creature, var)
end
function onCastSpell(creature, var)
return x(creature, var)
end
22:08 You advanced to haste level 11. 22:09 You advanced to haste level 12.