• 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!

TFS 1.X+ TFS 1.2 Add timer on spell

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
873
Solutions
2
Reaction score
49
Is it possible to add timer on this spell so it would count when it will be casted. Basically this spell is not created in spells lua but direcetly in monster file, but basically what it does it casts wave spell that one shots everyone

<attacks>
<attack name="lifedrain" interval="2000" chance="85" length="15" spread="0" min="-3000000" max="-5000000">
<attribute key="areaEffect" value="purpleenergy"/>
</attack>
 
Hes talking about something like this as example


Lua:
local area = {
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}

local combatArea = createCombatArea(area)

local combat = Combat()

combat:setArea(combatArea)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)

local timeToKill = 5

local function countdown(cid, var, timeToKill)
    local creature = Creature(cid)
    if not creature then
        return true
    end

    if timeToKill > 0 then
        creature:say(timeToKill, TALKTYPE_MONSTER_SAY, false, nil, creature:getPosition())
        timeToKill = timeToKill - 1
        addEvent(countdown, 1000, creature, var, timeToKill)
    else
        combat:execute(creature, var)
    end
end

function onCastSpell(creature, var)
    creature:say("You have " .. timeToKill .. " seconds to kill me, mohaha!", TALKTYPE_MONSTER_SAY)
    countdown(creature:getId(), var, timeToKill)
    return false
end
 

Attachments

Lua:
local area = {
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}

local combatArea = createCombatArea(area)

local combat = Combat()
combat:setArea(combatArea)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)

local timeToKill = 5

local function countdown(cid, var, timeToKill)
    local creature = Creature(cid)
    if not creature then
        return true
    end

    if timeToKill > 0 then
        creature:say(timeToKill, TALKTYPE_MONSTER_SAY, false, nil, creature:getPosition())
        timeToKill = timeToKill - 1
        addEvent(countdown, 1000, cid, var, timeToKill)  -- Fixed this line, just pass cid instead of creature
    else
        combat:execute(creature, var)
    end
end

function onCastSpell(creature, var)
    creature:say("You have " .. timeToKill .. " seconds to kill me, mohaha!", TALKTYPE_MONSTER_SAY)
    countdown(creature:getId(), var, timeToKill)
    return false
end
 
Lua:
local area = {
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}

local combatArea = createCombatArea(area)

local combat = Combat()
combat:setArea(combatArea)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)

local timeToKill = 5

local function countdown(cid, var, timeToKill)
    local creature = Creature(cid)
    if not creature then
        return true
    end

    if timeToKill > 0 then
        creature:say(timeToKill, TALKTYPE_MONSTER_SAY, false, nil, creature:getPosition())
        timeToKill = timeToKill - 1
        addEvent(countdown, 1000, cid, var, timeToKill)  -- Fixed this line, just pass cid instead of creature
    else
        combat:execute(creature, var)
    end
end

function onCastSpell(creature, var)
    creature:say("You have " .. timeToKill .. " seconds to kill me, mohaha!", TALKTYPE_MONSTER_SAY)
    countdown(creature:getId(), var, timeToKill)
    return false
end
Spell does zero damage its not one shotting
 
you mean <attack name="lifedrain" interval="2000" chance="85" length="15" spread="0" min="-3000000" max="-5000000">?
 
Back
Top