• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Spell that will drain 20 mana every second.

marek12

Available for sprite works
Joined
Apr 8, 2020
Messages
398
Solutions
4
Reaction score
394
Hi guys,
as the tile says, I am looking for a function to drain 20 mana every second on cast spell, and it will last 1 minute.
example:

Player say the words "exori muego" or whatever, and for 1 minute it will drain 20 mana every sec.

just looking for a function (the mana part), not the whole script.
thanks in advance! :D
 
Solution
Lua:
local function drain_mana(cid, interval, ticks, amount)
    -- if creature no longer exists, end function
    if not isCreature(cid) then
        return true
    end
    -- if creature does not have the full amount, then adjust the amount to remove as much as possible
    local temp_amount = getCreatureMana(cid)
    if amount > temp_amount then
        temp_amount = amount
    end
    -- remove the mana (true means that it's 'aggressive')
    doCreatureAddMana(cid, -temp_amount, true)
    -- loop the function x amount of times
    if ticks > 0 then
        addEvent(drain_mana, interval, cid, interval, ticks - 1, amount)
    end
end

--[[ - Below is the function/command to to start the mana drain

    - addEvent to start and loop the...
Lua:
local function drain_mana(cid, interval, ticks, amount)
    -- if creature no longer exists, end function
    if not isCreature(cid) then
        return true
    end
    -- if creature does not have the full amount, then adjust the amount to remove as much as possible
    local temp_amount = getCreatureMana(cid)
    if amount > temp_amount then
        temp_amount = amount
    end
    -- remove the mana (true means that it's 'aggressive')
    doCreatureAddMana(cid, -temp_amount, true)
    -- loop the function x amount of times
    if ticks > 0 then
        addEvent(drain_mana, interval, cid, interval, ticks - 1, amount)
    end
end

--[[ - Below is the function/command to to start the mana drain

    - addEvent to start and loop the fuction
    - addEventTimer to show how long to wait until executing the function for the first time
    - cid is the creature that it will be targetting
    - interval to show how fast/slow it 'ticks'
    - ticks for how many times it will drain
    - amount for the amount of mana to drain
--]]
addEvent(drain_mana, addEventTimer, cid, interval, ticks, amount)

-- start immediately, draining 20 mana every second, 60 times. (aka: 1 minute)
addEvent(drain_mana, 0, cid, 1000, 60, 20)
 
Last edited:
Solution
Lua:
local function drain_mana(cid, interval, ticks, amount)
    -- if creature no longer exists, end function
    if not isCreature(cid) then
        return true
    end
    -- if creature does not have the full amount, then adjust the amount to remove as much as possible
    local temp_amount = getCreatureMana(cid)
    if amount > temp_amount then
        temp_amount = amount
    end
    -- remove the mana (true means that it's 'aggressive')
    doCreatureAddMana(cid, -temp_amount, true)
    -- loop the function x amount of times
    if ticks > 0 then
        addEvent(drain_mana, interval, cid, interval, ticks - 1, amount)
    end
end

--[[ - Below is the function/command to to start the mana drain

    - addEvent to start and loop the fuction
    - addEventTimer to show how long to wait until executing the function for the first time
    - cid is the creature that it will be targetting
    - interval to show how fast/slow it 'ticks'
    - ticks for how many times it will drain
    - amount for the amount of mana to drain
--]]
addEvent(drain_mana, addEventTimer, cid, interval, ticks, amount)

-- start immediately, draining 20 mana every second, 60 times. (aka: 1 minute)
addEvent(drain_mana, 0, cid, 1000, 60, 20)
thanks :)
 
Back
Top