Codex NG
Recurrent Flamer
- Joined
- Jul 24, 2015
- Messages
- 2,994
- Solutions
- 12
- Reaction score
- 1,657
These functions were originally written by someone named @Athern.
All I did was adapt it to the Player metatable and apply it to spells, but these functions could be applied to anything even items.
Using haste as an example, you would need to apply your own formula's whether to increase the damage, speed, effects etc.. as I am not building your server for you.
All I did was adapt it to the Player metatable and apply it to spells, but these functions could be applied to anything even items.
Code:
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
Using haste as an example, you would need to apply your own formula's whether to increase the damage, speed, effects etc.. as I am not building your server for you.
Code:
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
Code:
22:08 You advanced to haste level 11.
22:09 You advanced to haste level 12.