• 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
yes its possible just like any other spell, however this only searches for monsters to hit, not players
you'd have to change the code to look for players in spectators instead of monsters
 
Xeraphus, help me put hit like HELLS CORE for LEVEL AND MAGIC LEVEL type : combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -10.2, -1046, -10.4, -2073)
 
Xeraphus, help me put hit like HELLS CORE for LEVEL AND MAGIC LEVEL type : combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -10.2, -1046, -10.4, -2073)
Spell - [TFS 1.2/1.3] Unnamed spell (looks cool tho)
you have an outdated source, if you want to fix that error you had you have to define a function in creature.lua in your lib
Lua:
function Creature.getPlayer(self)
    return Player(self)
end
 
When i use that :
Code:
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
No have hitpoint.
 
When i use that :
Code:
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
No have hitpoint.
make the values negative in damage
 
I have this erro
errp-png.29728
 
Very nice spell! Only thing, It will attack your summoned monsters D:
 
I rework code for FORMULA, u can change scalling here:

function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4.3) + 32
local max = (level / 5) + (maglevel * 7.4) + 48
return -min, -max
end

BUT I HAVE PROBLEM script dot send distance effekts to PLAYER, monsters yes but no players i dontknow why :(



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 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 combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setArea(createCombatArea(AREA_CIRCLE6X6))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 4.3) + 32
    local max = (level / 5) + (maglevel * 7.4) + 48
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")


--[[#######################################################################################]]--
local config = {
   damage = {min = -0, max = -0},
   rounds = 11, -- number of times the spell loops (effects & damage)
   delay = 333, -- ms
   radius = {x = 6, y = 6}, -- sqm radius
   damageType = COMBAT_PHYSICALDAMAGE,
   areaEffect = 1,
   distanceEffect = CONST_ANI_THROWINGSTAR,
}
function onCastSpell(creature, var)

   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)
    combat:execute(creature, var)

for i = 1, 11 do
    addEvent(function()  combat:execute(creature, var) end, i * 333)
end


return true
end
 
I rework code for FORMULA, u can change scalling here:

function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4.3) + 32
local max = (level / 5) + (maglevel * 7.4) + 48
return -min, -max
end

For PLAYERS and MONSTERS attack change this line:

if specs:isMonster() then

for this:

if specs:isPlayer() then




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 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 combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setArea(createCombatArea(AREA_CIRCLE6X6))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 4.3) + 32
    local max = (level / 5) + (maglevel * 7.4) + 48
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")


--[[#######################################################################################]]--
local config = {
   damage = {min = -0, max = -0},
   rounds = 11, -- number of times the spell loops (effects & damage)
   delay = 333, -- ms
   radius = {x = 6, y = 6}, -- sqm radius
   damageType = COMBAT_PHYSICALDAMAGE,
   areaEffect = 1,
   distanceEffect = CONST_ANI_THROWINGSTAR,
}
function onCastSpell(creature, var)

   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)
    combat:execute(creature, var)

for i = 1, 11 do
    addEvent(function()  combat:execute(creature, var) end, i * 333)
end


return true
end
 
I rework code for FORMULA, u can change scalling here:

function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4.3) + 32
local max = (level / 5) + (maglevel * 7.4) + 48
return -min, -max
end

BUT I HAVE PROBLEM script dot send distance effekts to PLAYER, monsters yes but no players i dontknow why :(



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 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 combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setArea(createCombatArea(AREA_CIRCLE6X6))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 4.3) + 32
    local max = (level / 5) + (maglevel * 7.4) + 48
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")


--[[#######################################################################################]]--
local config = {
   damage = {min = -0, max = -0},
   rounds = 11, -- number of times the spell loops (effects & damage)
   delay = 333, -- ms
   radius = {x = 6, y = 6}, -- sqm radius
   damageType = COMBAT_PHYSICALDAMAGE,
   areaEffect = 1,
   distanceEffect = CONST_ANI_THROWINGSTAR,
}
function onCastSpell(creature, var)

   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)
    combat:execute(creature, var)

for i = 1, 11 do
    addEvent(function()  combat:execute(creature, var) end, i * 333)
end


return true
end
please don't queue 11 events at the same time if you aren't 1000000000000000000000000000000000000000% sure they will all execute.
also it only checks if the spectator is a monster in line 34.
 
I was trying to make spells like this for all vocations and I ran into a few issues. With my god account, almost all variations work fine. The client crashed when I tried to use the spell I made for knights, but the other 5 variations worked. When I tried to use it on a normal account, the client crashed regardless of the vocation using it. The weird thing is, when I logged in with a second account to watch the first account, I saw the animation from the account that cast the spell even though the client crashed. Any ideas? I can upload the scripts if it helps.
 
Back
Top