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

Spell [TFS 1.2/1.3] Unnamed spell (looks cool tho)

make more spells like this?

  • yes

    Votes: 74 94.9%
  • no

    Votes: 4 5.1%

  • Total voters
    78

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,643
Solutions
559
Reaction score
3,946
got bored and wanted to try to make my first non-utility spell
only works on monsters, fully configurable (config is at the bottom)
demonstration: http://xera.s-ul.eu/C95HkX4x
Lua:
--[[#######################################################################################]]--
function doAreaCombatDamage(cid, attacker, combatType, position, min, max, effect)
   --// Incase the creature disappears within 120-250ms time window
   local creature = Creature(cid)
   if not creature then
       return
   end
   doAreaCombatHealth(attacker, combatType, position, 0, min, max, effect)
end

local running = {}

local function runSpell(cid, i, j, delay, radius, damage, damageType, areaEffect, distanceEffect)
   local player = Player(cid)
   --// Player doesn't exist anymore
   if not player or Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) and bit.band(player:getGroup():getFlags(), PlayerFlag_IgnoreProtectionZone) == 0 then
       stopEvent(running[cid])
       running[cid] = nil
       return
   end
   --// Maximum rounds complete
   if i > j then
       stopEvent(running[cid])
       running[cid] = nil
       return
   end
   local center = player:getPosition()
   local specs = Game.getSpectators(center, false, false, radius.x, radius.x, radius.y, radius.y)
   --// Send effects and damage creatures within radius
   local args = {nil, cid, damageType, nil, damage.min, damage.max, areaEffect}
   for i = 1, #specs do
       if specs[i]:isMonster() then
           local specPos = specs[i]:getPosition()
           args[1] = specs[i]:getId()
           args[4] = specPos
           center:sendDistanceEffect(specPos, distanceEffect)
           addEvent(doAreaCombatDamage, 120 + (center:getDistance(specPos) * 7), unpack(args))
       end
   end
   addEvent(runSpell, delay, cid, i+1, j, delay, radius, damage, damageType, areaEffect, distanceEffect)
end

local offsets = {DIRECTION_WEST, DIRECTION_NORTH, DIRECTION_EAST, DIRECTION_SOUTH}

local function sendEffects(cid, delay, areaEffect, distanceEffect)
   local player = Player(cid)
   if not player or Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) and bit.band(player:getGroup():getFlags(), PlayerFlag_IgnoreProtectionZone) == 0 then
       stopEvent(running[cid])
       running[cid] = nil
       return
   end
   local pos = player:getPosition()
   --// Send distance effects (N/E/S/W) & area effect on player
   for i = 1, #offsets do
       local fromPos = pos:setDirectionOffset(offsets[i])
       local toPos = pos:setDirectionOffset(offsets[i+1] or offsets[1])
       fromPos:sendDistanceEffect(toPos, distanceEffect)
   end
   pos:sendMagicEffect(areaEffect)
   running[cid] = addEvent(sendEffects, delay, cid, delay, areaEffect, distanceEffect)
end
--[[#######################################################################################]]--
local config = {
   damage = {min = -10, max = -15},
   rounds = 80, -- number of times the spell loops (effects & damage)
   delay = 160, -- ms
   radius = {x = 3, y = 3}, -- sqm radius
   damageType = COMBAT_DEATHDAMAGE,
   areaEffect = CONST_ME_MORTAREA,
   distanceEffect = CONST_ANI_SUDDENDEATH,
}

function onCastSpell(creature, variant)
   local player = creature:getPlayer()
   if not player then
       return false
   end
   sendEffects(player:getId(), config.delay, config.areaEffect, config.distanceEffect)
   runSpell(player:getId(), 0, config.rounds, config.delay, config.radius, config.damage, config.damageType, config.areaEffect, config.distanceEffect)
   return true
end
 
This spell for example for moba/tibia server :D
 
Haha it looks pretty awesome, with 1 radius, and just for 2-3 seconds this spell can be called Death whirlwind. Knights only, would be cool if it made the player dance aswell haha!
awesome spell however.
 
Haha it looks pretty awesome, with 1 radius, and just for 2-3 seconds this spell can be called Death whirlwind. Knights only, would be cool if it made the player dance aswell haha!
awesome spell however.
good thing you can configure it that way and have a spell called death whirlwind for yourself :]
 
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/Necromancer/Ultimate_Death.lua:onCastSpell
data/spells/scripts/Necromancer/Ultimate_Death.lua:55: attempt to call method 'setDirectionOffset' (a nil value)
stack traceback:
        [C]: in function 'setDirectionOffset'
        data/spells/scripts/Necromancer/Ultimate_Death.lua:55: in function 'sendEffects'
        data/spells/scripts/Necromancer/Ultimate_Death.lua:78: in function <data/spells/scripts/Necromancer/Ultimate_Death.lua:73>

any idea of what it might be?
just copied the code and inserted it :) tfs 1.2
 
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/Necromancer/Ultimate_Death.lua:onCastSpell
data/spells/scripts/Necromancer/Ultimate_Death.lua:55: attempt to call method 'setDirectionOffset' (a nil value)
stack traceback:
        [C]: in function 'setDirectionOffset'
        data/spells/scripts/Necromancer/Ultimate_Death.lua:55: in function 'sendEffects'
        data/spells/scripts/Necromancer/Ultimate_Death.lua:78: in function <data/spells/scripts/Necromancer/Ultimate_Death.lua:73>

any idea of what it might be?
just copied the code and inserted it :) tfs 1.2
must have been something i added a long time ago
position.lua in lib
Lua:
Position.directionOffset = {
    [DIRECTION_NORTH] = {x = 0, y = -1},
    [DIRECTION_EAST] = {x = 1, y = 0},
    [DIRECTION_SOUTH] = {x = 0, y = 1},
    [DIRECTION_WEST] = {x = -1, y = 0},
    [DIRECTION_SOUTHWEST] = {x = -1, y = 1},
    [DIRECTION_SOUTHEAST] = {x = 1, y = 1},
    [DIRECTION_NORTHWEST] = {x = -1, y = -1},
    [DIRECTION_NORTHEAST] = {x = 1, y = -1}
}

function Position:setDirectionOffset(dir)
    local tmp = Position.directionOffset[dir]
    if not tmp then
        return self
    end
    return Position(self.x + tmp.x, self.y + tmp.y, self.z)
end
 
am i the only one thats shocked how lucky he got and looted MPA from a wolf? Kappa
 
got bored and wanted to try to make my first non-utility spell
only works on monsters, fully configurable (config is at the bottom)
demonstration: http://xera.s-ul.eu/C95HkX4x
Lua:
--[[#######################################################################################]]--
function doAreaCombatDamage(cid, attacker, combatType, position, min, max, effect)
    --// Incase the creature disappears within 120-250ms time window
    local creature = Creature(cid)
    if not creature then
        return
    end
    doAreaCombatHealth(attacker, combatType, position, 0, min, max, effect)
end

local running = {}

local function runSpell(cid, i, j, delay, radius, damage, damageType, areaEffect, distanceEffect)
    local player = Player(cid)
    --// Player doesn't exist anymore
    if not player then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    --// Maximum rounds complete
    if i > j then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    local center = player:getPosition()
    local specs = Game.getSpectators(center, false, false, radius.x, radius.x, radius.y, radius.y)
    --// Send effects and damage creatures within radius
    local args = {nil, cid, damageType, nil, damage.min, damage.max, areaEffect}
    for i = 1, #specs do
        if specs[i]:isMonster() then
            local specPos = specs[i]:getPosition()
            args[1] = specs[i]:getId()
            args[4] = specPos
            center:sendDistanceEffect(specPos, distanceEffect)
            addEvent(doAreaCombatDamage, 120 + (center:getDistance(specPos) * 7), unpack(args))
        end
    end
    addEvent(runSpell, delay, cid, i+1, j, delay, radius, damage, damageType, areaEffect, distanceEffect)
end

local offsets = {DIRECTION_WEST, DIRECTION_NORTH, DIRECTION_EAST, DIRECTION_SOUTH}

local function sendEffects(cid, delay, areaEffect, distanceEffect)
    local player = Player(cid)
    if not player then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    local pos = player:getPosition()
    --// Send distance effects (N/E/S/W) & area effect on player
    for i = 1, #offsets do
        local fromPos = pos:setDirectionOffset(offsets[i])
        local toPos = pos:setDirectionOffset(offsets[i+1] or offsets[1])
        fromPos:sendDistanceEffect(toPos, distanceEffect)
    end
    pos:sendMagicEffect(areaEffect)
    running[cid] = addEvent(sendEffects, delay, cid, delay, areaEffect, distanceEffect)
end
--[[#######################################################################################]]--
local config = {
    damage = {min = -10, max = -15},
    rounds = 80, -- number of times the spell loops (effects & damage)
    delay = 160, -- ms
    radius = {x = 3, y = 3}, -- sqm radius
    damageType = COMBAT_DEATHDAMAGE,
    areaEffect = CONST_ME_MORTAREA,
    distanceEffect = CONST_ANI_SUDDENDEATH,
}

function onCastSpell(creature, variant)
    local player = creature:getPlayer()
    if not player then
        return false
    end
    sendEffects(player:getId(), config.delay, config.areaEffect, config.distanceEffect)
    runSpell(player:getId(), 0, config.rounds, config.delay, config.radius, config.damage, config.damageType, config.areaEffect, config.distanceEffect)
    return true
end

How i put a formula attacker???
 
i dont want MIN & MAX attack, i want put formula like :
function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4) + 225
local max = (level / 5) + (maglevel * 10) + 300
return -min, -max
end
 
i dont want MIN & MAX attack, i want put formula like :
function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4) + 225
local max = (level / 5) + (maglevel * 10) + 300
return -min, -max
end
you can remove damage from config and do this at the top of onCastSpell:
Lua:
local level = player:getLevel()
local maglevel = player:getMagLevel()
local damage = {(level / 5) + (maglevel * 4) + 225, (level / 5) + (maglevel * 10) + 300}
then you can replace config.damage in runSpell with damage
 
I try like that :
Code:
--[[#######################################################################################]]--
function doAreaCombatDamage(cid, attacker, combatType, position, min, max, effect)
    --// Incase the creature disappears within 120-250ms time window
    local creature = Creature(cid)
    if not creature then
        return
    end
    doAreaCombatHealth(attacker, combatType, position, 0, min, max, effect)
end
local running = {}
local function runSpell(cid, i, j, delay, radius, damage, damageType, areaEffect, distanceEffect)
    local player = Player(cid)
    --// Player doesn't exist anymore
    if not player then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    --// Maximum rounds complete
    if i > j then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    local center = player:getPosition()
    local specs = Game.getSpectators(center, false, false, radius.x, radius.x, radius.y, radius.y)
    --// Send effects and damage creatures within radius
    local args = {nil, cid, damageType, nil, damage.min, damage.max, areaEffect}
    for i = 1, #specs do
        if specs[i]:isMonster() then
            local specPos = specs[i]:getPosition()
            args[1] = specs[i]:getId()
            args[4] = specPos
            center:sendDistanceEffect(specPos, distanceEffect)
            addEvent(doAreaCombatDamage, 120 + (center:getDistance(specPos) * 7), unpack(args))
        end
    end
    addEvent(runSpell, delay, cid, i+1, j, delay, radius, damage, damageType, areaEffect, distanceEffect)
end
local offsets = {DIRECTION_WEST, DIRECTION_NORTH, DIRECTION_EAST, DIRECTION_SOUTH}
local function sendEffects(cid, delay, areaEffect, distanceEffect)
    local player = Player(cid)
    if not player then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    local pos = player:getPosition()
    --// Send distance effects (N/E/S/W) & area effect on player
    for i = 1, #offsets do
        local fromPos = pos:setDirectionOffset(offsets[i])
        local toPos = pos:setDirectionOffset(offsets[i+1] or offsets[1])
        fromPos:sendDistanceEffect(toPos, distanceEffect)
    end
    pos:sendMagicEffect(areaEffect)
    running[cid] = addEvent(sendEffects, delay, cid, delay, areaEffect, distanceEffect)
end
--[[#######################################################################################]]--
local config = {
    rounds = 80, -- number of times the spell loops (effects & damage)
    delay = 160, -- ms
    radius = {x = 3, y = 3}, -- sqm radius
    damageType = COMBAT_DEATHDAMAGE,
    areaEffect = CONST_ME_MORTAREA,
    distanceEffect = CONST_ANI_SUDDENDEATH,
}
function onCastSpell(cid, creature, variant)
local level = player:getLevel()
local maglevel = player:getMagicLevel()
local damage = {(level / 5) + (maglevel * 4) + 225, (level / 5) + (maglevel * 10) + 300}
    local player = creature:getPlayer()
    if not player then
        return false
    end
    sendEffects(player:getId(), config.delay, config.areaEffect, config.distanceEffect)
    runSpell(player:getId(), 0, config.rounds, config.delay, config.radius, config.damage, config.damageType, config.areaEffect, config.distanceEffect)
    return true
end

I have this error :
 

Attachments

I try like that :
Code:
--[[#######################################################################################]]--
function doAreaCombatDamage(cid, attacker, combatType, position, min, max, effect)
    --// Incase the creature disappears within 120-250ms time window
    local creature = Creature(cid)
    if not creature then
        return
    end
    doAreaCombatHealth(attacker, combatType, position, 0, min, max, effect)
end
local running = {}
local function runSpell(cid, i, j, delay, radius, damage, damageType, areaEffect, distanceEffect)
    local player = Player(cid)
    --// Player doesn't exist anymore
    if not player then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    --// Maximum rounds complete
    if i > j then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    local center = player:getPosition()
    local specs = Game.getSpectators(center, false, false, radius.x, radius.x, radius.y, radius.y)
    --// Send effects and damage creatures within radius
    local args = {nil, cid, damageType, nil, damage.min, damage.max, areaEffect}
    for i = 1, #specs do
        if specs[i]:isMonster() then
            local specPos = specs[i]:getPosition()
            args[1] = specs[i]:getId()
            args[4] = specPos
            center:sendDistanceEffect(specPos, distanceEffect)
            addEvent(doAreaCombatDamage, 120 + (center:getDistance(specPos) * 7), unpack(args))
        end
    end
    addEvent(runSpell, delay, cid, i+1, j, delay, radius, damage, damageType, areaEffect, distanceEffect)
end
local offsets = {DIRECTION_WEST, DIRECTION_NORTH, DIRECTION_EAST, DIRECTION_SOUTH}
local function sendEffects(cid, delay, areaEffect, distanceEffect)
    local player = Player(cid)
    if not player then
        stopEvent(running[cid])
        running[cid] = nil
        return
    end
    local pos = player:getPosition()
    --// Send distance effects (N/E/S/W) & area effect on player
    for i = 1, #offsets do
        local fromPos = pos:setDirectionOffset(offsets[i])
        local toPos = pos:setDirectionOffset(offsets[i+1] or offsets[1])
        fromPos:sendDistanceEffect(toPos, distanceEffect)
    end
    pos:sendMagicEffect(areaEffect)
    running[cid] = addEvent(sendEffects, delay, cid, delay, areaEffect, distanceEffect)
end
--[[#######################################################################################]]--
local config = {
    rounds = 80, -- number of times the spell loops (effects & damage)
    delay = 160, -- ms
    radius = {x = 3, y = 3}, -- sqm radius
    damageType = COMBAT_DEATHDAMAGE,
    areaEffect = CONST_ME_MORTAREA,
    distanceEffect = CONST_ANI_SUDDENDEATH,
}
function onCastSpell(cid, creature, variant)
local level = player:getLevel()
local maglevel = player:getMagicLevel()
local damage = {(level / 5) + (maglevel * 4) + 225, (level / 5) + (maglevel * 10) + 300}
    local player = creature:getPlayer()
    if not player then
        return false
    end
    sendEffects(player:getId(), config.delay, config.areaEffect, config.distanceEffect)
    runSpell(player:getId(), 0, config.rounds, config.delay, config.radius, config.damage, config.damageType, config.areaEffect, config.distanceEffect)
    return true
end

I have this error :
Lua:
function onCastSpell(cid, creature, variant)
    local player = creature:getPlayer()
    if not player then
        return false
    end
    local level = player:getLevel()
    local maglevel = player:getMagicLevel()
    local damage = {(level / 5) + (maglevel * 4) + 225, (level / 5) + (maglevel * 10) + 300}
    sendEffects(player:getId(), config.delay, config.areaEffect, config.distanceEffect)
    runSpell(player:getId(), 0, config.rounds, config.delay, config.radius, damage, config.damageType, config.areaEffect, config.distanceEffect)
    return true
end
 
Back
Top