• 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+ Why area/wave spells are not working but target spells works fine

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
876
Solutions
2
Reaction score
49
So i tried to add area/wave spells to my server but i have no idea why it doesnt work. Like example one of my wave spells
Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 87)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr1 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{1, 2, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area1 = createCombatArea(arr1)

setCombatArea(combat1, area1)

local combat10 = createCombatObject()
setCombatParam(combat10, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat10, COMBAT_PARAM_EFFECT, 88)
setCombatFormula(combat10, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr10 = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 0, 2},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area10 = createCombatArea(arr10)

setCombatArea(combat10, area10)

local combat100 = createCombatObject()
setCombatParam(combat100, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat100, COMBAT_PARAM_EFFECT, 89)
setCombatFormula(combat100, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr100 = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 2},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area100 = createCombatArea(arr100)

setCombatArea(combat100, area100)


local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 89)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr2 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{2, 1, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area2 = createCombatArea(arr2)

setCombatArea(combat2, area2)



local combat20 = createCombatObject()
setCombatParam(combat20, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat20, COMBAT_PARAM_EFFECT, 88)
setCombatFormula(combat20, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr20 = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 2, 0, 1, 1, 1},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area20 = createCombatArea(arr20)

setCombatArea(combat20, area20)

local combat200 = createCombatObject()
setCombatParam(combat200, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat200, COMBAT_PARAM_EFFECT, 87)
setCombatFormula(combat200, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr200 = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{2, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area200 = createCombatArea(arr200)

setCombatArea(combat200, area200)



local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, 92)
setCombatFormula(combat3, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)


local arr3 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 2, 0},
{0, 0, 0, 1, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area3 = createCombatArea(arr3)

setCombatArea(combat3, area3)

local combat30 = createCombatObject()
setCombatParam(combat30, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat30, COMBAT_PARAM_EFFECT, 91)
setCombatFormula(combat30, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr30 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 2, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area30 = createCombatArea(arr30)

setCombatArea(combat30, area30)


local combat300 = createCombatObject()
setCombatParam(combat300, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat300, COMBAT_PARAM_EFFECT, 90)
setCombatFormula(combat300, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr300 = {
{0, 0, 2, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area300 = createCombatArea(arr300)

setCombatArea(combat300, area300)




local combat4 = createCombatObject()
setCombatParam(combat4, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat4, COMBAT_PARAM_EFFECT, 90)
setCombatFormula(combat4, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr4 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 1, 0},
{0, 0, 0, 2, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area4 = createCombatArea(arr4)

setCombatArea(combat4, area4)



local combat40 = createCombatObject()
setCombatParam(combat40, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat40, COMBAT_PARAM_EFFECT, 91)
setCombatFormula(combat40, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr40 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 2, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}


local area40 = createCombatArea(arr40)

setCombatArea(combat40, area40)


local combat400 = createCombatObject()
setCombatParam(combat400, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat400, COMBAT_PARAM_EFFECT, 92)
setCombatFormula(combat400, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr400 = {
{0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 2, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area400 = createCombatArea(arr400)

setCombatArea(combat400, area400)


function onCastSpell(cid, var)
if isCreature(cid) == 1 then
      addEvent(ka,0,cid)
 end
end
Console is not giving any errors, so i'm pretty confused what could be wrong. So i would like to know where is the problem so that next time i could fix by my own.
Code:
    <instant name="wave" words="test" lvl="300" maglv="100" mana="2000" prem="0" exhaustion="1" direction="1" enabled="1" script="LvL300/wave.lua"></instant>
 
Solution
Spell is one line wave. Example in paint
dgdfgdfg.png

I was thinking to use original tibia wave spell but what if i want to use different effect ids if he turns to the other side lets say if he truns north wave has 1id if he turns south spell has 2id. I think u get it what i mean. Thats why that code has so much functions because of directions.
Im not to familiar whit TFS 1.x but i think this should work, and you should get different dmg type and spell effect depending on your direction. Whitout the use of events

Lua:
local combatNorth = Combat()
combatNorth:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combatNorth:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)...
So i tried to add area/wave spells to my server but i have no idea why it doesnt work. Like example one of my wave spells
Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 87)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr1 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{1, 2, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area1 = createCombatArea(arr1)

setCombatArea(combat1, area1)

local combat10 = createCombatObject()
setCombatParam(combat10, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat10, COMBAT_PARAM_EFFECT, 88)
setCombatFormula(combat10, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr10 = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 0, 2},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area10 = createCombatArea(arr10)

setCombatArea(combat10, area10)

local combat100 = createCombatObject()
setCombatParam(combat100, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat100, COMBAT_PARAM_EFFECT, 89)
setCombatFormula(combat100, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr100 = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 2},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area100 = createCombatArea(arr100)

setCombatArea(combat100, area100)


local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 89)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr2 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{2, 1, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area2 = createCombatArea(arr2)

setCombatArea(combat2, area2)



local combat20 = createCombatObject()
setCombatParam(combat20, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat20, COMBAT_PARAM_EFFECT, 88)
setCombatFormula(combat20, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr20 = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 2, 0, 1, 1, 1},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area20 = createCombatArea(arr20)

setCombatArea(combat20, area20)

local combat200 = createCombatObject()
setCombatParam(combat200, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat200, COMBAT_PARAM_EFFECT, 87)
setCombatFormula(combat200, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr200 = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{2, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area200 = createCombatArea(arr200)

setCombatArea(combat200, area200)



local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, 92)
setCombatFormula(combat3, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)


local arr3 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 2, 0},
{0, 0, 0, 1, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area3 = createCombatArea(arr3)

setCombatArea(combat3, area3)

local combat30 = createCombatObject()
setCombatParam(combat30, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat30, COMBAT_PARAM_EFFECT, 91)
setCombatFormula(combat30, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr30 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 2, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area30 = createCombatArea(arr30)

setCombatArea(combat30, area30)


local combat300 = createCombatObject()
setCombatParam(combat300, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat300, COMBAT_PARAM_EFFECT, 90)
setCombatFormula(combat300, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr300 = {
{0, 0, 2, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area300 = createCombatArea(arr300)

setCombatArea(combat300, area300)




local combat4 = createCombatObject()
setCombatParam(combat4, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat4, COMBAT_PARAM_EFFECT, 90)
setCombatFormula(combat4, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr4 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 1, 0},
{0, 0, 0, 2, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}

local area4 = createCombatArea(arr4)

setCombatArea(combat4, area4)



local combat40 = createCombatObject()
setCombatParam(combat40, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat40, COMBAT_PARAM_EFFECT, 91)
setCombatFormula(combat40, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr40 = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 2, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}


local area40 = createCombatArea(arr40)

setCombatArea(combat40, area40)


local combat400 = createCombatObject()
setCombatParam(combat400, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat400, COMBAT_PARAM_EFFECT, 92)
setCombatFormula(combat400, COMBAT_FORMULA_LEVELMAGIC, -4.0, 0, -4.1, 0)

local arr400 = {
{0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 2, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
}

local area400 = createCombatArea(arr400)

setCombatArea(combat400, area400)


function onCastSpell(cid, var)
if isCreature(cid) == 1 then
      addEvent(ka,0,cid)
 end
end
Console is not giving any errors, so i'm pretty confused what could be wrong. So i would like to know where is the problem so that next time i could fix by my own.
Code:
    <instant name="wave" words="test" lvl="300" maglv="100" mana="2000" prem="0" exhaustion="1" direction="1" enabled="1" script="LvL300/wave.lua"></instant>

addEvent is trying to execute function that is not in the script called ka

If you want someone to help, do post the other function as well as it really helps with fixing bugs

More on addEvents here: [How-to] Using addEvent()
 
The reason is that the onCastSpell function is incomplete.

Lua:
function onCastSpell(cid, var)
if isCreature(cid) == 1 then
      addEvent(ka,0,cid)
end
end

You are making an event out of it, and that event use "ka" (function) thats why mackerel asked for the other function but since you say you dont have one you need to redo the onCastSpell function to cast the spell.
So can you provide what TFS version you are using and what the wave spell is supposed to do?
Since you have alot of spell constructed in the script but none of them are put to use.

Edit:
I did see now that you are using TFS 1.x+ so no need to tell me what version you use, but i still like to know what the spell is supposed to do, like is the spell some kind of event spell? like an wave that change shape when a player cast it?

Here is an example how you can make an fire wave spell from real tibia. Use this as an template and edit it the way you want.
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
combat:setArea(createCombatArea(area))

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

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
 
Last edited:
The reason is that the onCastSpell function is incomplete.

Lua:
function onCastSpell(cid, var)
if isCreature(cid) == 1 then
      addEvent(ka,0,cid)
end
end

You are making an event out of it, and that event use "ka" (function) thats why mackerel asked for the other function but since you say you dont have one you need to redo the onCastSpell function to cast the spell.
So can you provide what TFS version you are using and what the wave spell is supposed to do?
Since you have alot of spell constructed in the script but none of them are put to use.

Edit:
I did see now that you are using TFS 1.x+ so no need to tell me what version you use, but i still like to know what the spell is supposed to do, like is the spell some kind of event spell? like an wave that change shape when a player cast it?

Here is an example how you can make an fire wave spell from real tibia. Use this as an template and edit it the way you want.
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
combat:setArea(createCombatArea(area))

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

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
Spell is one line wave. Example in paint
dgdfgdfg.png

I was thinking to use original tibia wave spell but what if i want to use different effect ids if he turns to the other side lets say if he truns north wave has 1id if he turns south spell has 2id. I think u get it what i mean. Thats why that code has so much functions because of directions.
 
Spell is one line wave. Example in paint
dgdfgdfg.png

I was thinking to use original tibia wave spell but what if i want to use different effect ids if he turns to the other side lets say if he truns north wave has 1id if he turns south spell has 2id. I think u get it what i mean. Thats why that code has so much functions because of directions.
Im not to familiar whit TFS 1.x but i think this should work, and you should get different dmg type and spell effect depending on your direction. Whitout the use of events

Lua:
local combatNorth = Combat()
combatNorth:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combatNorth:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
combatNorth:setArea(createCombatArea(area))

local combatSouth = Combat()
combatSouth:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combatSouth:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combatSouth:setArea(createCombatArea(area))

local combatWest = Combat()
combatWest:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combatWest:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BIGCLOUDS)
combatWest:setArea(createCombatArea(area))

local combatEast = Combat()
combatEast:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combatEast:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BIGPLANTS)
combatEast:setArea(createCombatArea(area))

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

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2) + 12
    return -min, -max
end

combatNorth:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combatSouth:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combatWest:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combatEast:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if creature:getDirection() == NORTH then
        combatNorth:execute(creature, variant)
    elseif creature:getDirection() == SOUTH then
        combatSouth:execute(creature, variant)
    elseif creature:getDirection() == WEST then
        combatWest:execute(creature, variant)
    elseif creature:getDirection() == EAST then
        combatEast:execute(creature, variant)
    end
    return true
end

Edit:
updated script
 
Last edited:
Solution
Im not to familiar whit TFS 1.x but i think this should work, and you should get different dmg type and spell effect depending on your direction. Whitout the use of events

Lua:
local combatNorth = Combat()
combatNorth:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combatNorth:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
combatNorth:setArea(createCombatArea(area))

local combatSouth = Combat()
combatSouth:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combatSouth:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combatSouth:setArea(createCombatArea(area))

local combatWest = Combat()
combatWest:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combatWest:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BIGCLOUDS)
combatWest:setArea(createCombatArea(area))

local combatEast = Combat()
combatEast:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combatEast:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BIGPLANTS)
combatEast:setArea(createCombatArea(area))

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

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2) + 12
    return -min, -max
end

combatNorth:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combatSouth:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combatWest:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combatEast:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if creature:getDirection() == NORTH then
        local doDamage = combatNorth:execute(creature, variant)
    elseif creature:getDirection() == SOUTH then
        local doDamage = combatSouth:execute(creature, variant)
    elseif creature:getDirection() == WEST then
        local doDamage = combatWest:execute(creature, variant)
    elseif creature:getDirection() == EAST then
        local doDamage = combatEast:execute(creature, variant)
    end
    return doDamage
end

Here is a more configurable spell for direction :)
Lua:
local dir = {
    [0] = {type = COMBAT_FIREDAMAGE, effect = CONST_ME_HITBYFIRE}, -- north
    [1] = {type = COMBAT_EARTHDAMAGE, effect = CONST_ME_BIGPLANTS}, -- east
    [2] = {type = COMBAT_ICEDAMAGE, effect = CONST_ME_ICEAREA}, -- south
    [3] = {type = COMBAT_ENERGYDAMAGE, effect = CONST_ME_BIGCLOUDS} -- west
}

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

local combat = {}

for direction, const in pairs(dir) do
    combat[direction] = Combat()
    combat[direction]:setParameter(COMBAT_PARAM_TYPE, const.type)
    combat[direction]:setParameter(COMBAT_PARAM_EFFECT, const.effect)
    combat[direction]:setArea(createCombatArea(area))
  
    _G['onGetFormulaValues'..direction] = function(player, level, magicLevel)
        local min = (level / 5) + (magicLevel * 1.2) + 7
        local max = (level / 5) + (magicLevel * 2) + 12
        return -min, -max
    end
  
    combat[direction]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues"..direction)
end

function onCastSpell(creature, variant)
    return combat[creature:getDirection()]:execute(creature, variant)
end
 
Here is a more configurable spell for direction :)
Lua:
local dir = {
    [0] = {type = COMBAT_FIREDAMAGE, effect = CONST_ME_HITBYFIRE}, -- north
    [1] = {type = COMBAT_EARTHDAMAGE, effect = CONST_ME_BIGPLANTS}, -- east
    [2] = {type = COMBAT_ICEDAMAGE, effect = CONST_ME_ICEAREA}, -- south
    [3] = {type = COMBAT_ENERGYDAMAGE, effect = CONST_ME_BIGCLOUDS} -- west
}

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

local combat = {}

for direction, const in pairs(dir) do
    combat[direction] = Combat()
    combat[direction]:setParameter(COMBAT_PARAM_TYPE, const.type)
    combat[direction]:setParameter(COMBAT_PARAM_EFFECT, const.effect)
    combat[direction]:setArea(createCombatArea(area))
 
    _G['onGetFormulaValues'..direction] = function(player, level, magicLevel)
        local min = (level / 5) + (magicLevel * 1.2) + 7
        local max = (level / 5) + (magicLevel * 2) + 12
        return -min, -max
    end
 
    combat[direction]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues"..direction)
end

function onCastSpell(creature, variant)
    return combat[creature:getDirection()]:execute(creature, variant)
end
I dont know if its more configurable, but it sure is less repetive and clean code :)
 
So i'm using @bayview version because @Mummrik version has problem with segmentation and my console wont run it. But bayview script seems to be working fine but has some gliches, i'm not sure where is problem but it seems that its multiplies the effects and it cause this glichy look. And second think that south and east effect seems to be out of location its kinda on the vocation it should be one step more further, but i think its possible to fix with getPlayerPosition, not sure. Does anyone know solutions for these two problems?
Untitled.png
 
So i'm using @bayview version because @Mummrik version has problem with segmentation and my console wont run it. But bayview script seems to be working fine but has some gliches, i'm not sure where is problem but it seems that its multiplies the effects and it cause this glichy look. And second think that south and east effect seems to be out of location its kinda on the vocation it should be one step more further, but i think its possible to fix with getPlayerPosition, not sure. Does anyone know solutions for these two problems?
Untitled.png
You should use @bayview 's script as its better constructed code.
Its hard to tell by the screenshot whats happening, but it might be that the for loop is running all the time and construct the combat table as fast as it can?
Test whit an print("test") inside the for loop, then check the consol.
It should only construct the combat table once (4 different elements)

Edit:
I did update my script i provided, i did remove the doDamage part. I dont know why i even did add that :p
 
So i'm using @bayview version because @Mummrik version has problem with segmentation and my console wont run it. But bayview script seems to be working fine but has some gliches, i'm not sure where is problem but it seems that its multiplies the effects and it cause this glichy look. And second think that south and east effect seems to be out of location its kinda on the vocation it should be one step more further, but i think its possible to fix with getPlayerPosition, not sure. Does anyone know solutions for these two problems?
Untitled.png

That's because the sprite for that effect is actually that big :p. If you try different effect with single square then you will see that it's working perfectly for Tibia spells.

If you want to solve this issue then you have to send only one magic effect per use
 
That's because the sprite for that effect is actually that big :p. If you try different effect with single square then you will see that it's working perfectly for Tibia spells.

If you want to solve this issue then you have to send only one magic effect per use
That explains alot of my confusion, since the script is sending the effect to 4 tiles infront of the player.
And also revoke my suspicion of the for loop doing something fishy.
 
That explains alot of my confusion, since the script is sending the effect to 4 tiles infront of the player.
And also revoke my suspicion of the for loop doing something fishy.
The for loop doesn't execute when you cast the spell, it only executes when the server starts up and loads everything.

The combat table it's index based on the return value of the direction of the player & the accompany callback function are the only things that execute when you cast the spell.
 
The for loop doesn't execute when you cast the spell, it only executes when the server starts up and loads everything.
Thats why i thought it was running for infinty. But it make sense it should not get stuck in a infinty loop since it only got 4 elements in the dir table. Anyways it help me improve my coding seeing your code, and studying it. :D
 
You should use @bayview 's script as its better constructed code.
Its hard to tell by the screenshot whats happening, but it might be that the for loop is running all the time and construct the combat table as fast as it can?
Test whit an print("test") inside the for loop, then check the consol.
It should only construct the combat table once (4 different elements)

Edit:
I did update my script i provided, i did remove the doDamage part. I dont know why i even did add that :p
I'm using @bayview script because i tried yours but it crash my console it seems that combat area must be invalid not sure so thats why it crash my console if use your script.
That's because the sprite for that effect is actually that big :p. If you try different effect with single square then you will see that it's working perfectly for Tibia spells.

If you want to solve this issue then you have to send only one magic effect per use
Send one effect per use. how?
 
Ask your friend have to make it :D :D

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setArea(createCombatArea(AREA_BEAM5))

function onGetFormulaValues(cid, level, maglevel)
    min = -((level / 5) + (maglevel * 1.8) + 11)
    max = -((level / 5) + (maglevel * 3) + 19)
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    local player = Player(cid)
    local playerPos = player:getPosition()
    local playerDir = player:getDirection()

    if playerDir == NORTH then
        Position(playerPos.x, playerPos.y - 1, playerPos.z):sendMagicEffect(15)
    elseif playerDir == SOUTH then
        Position(playerPos.x, playerPos.y + 1, playerPos.z):sendMagicEffect(16)
    elseif playerDir == WEST then
        Position(playerPos.x - 1, playerPos.y, playerPos.z):sendMagicEffect(17)
    elseif playerDir == EAST then
        Position(playerPos.x + 1, playerPos.y, playerPos.z):sendMagicEffect(18)
    end

    return combat:execute(cid, var)
end

15, 16, 17, 18 should correspond to the effect you want to send. Ugly if statements though so I guess it can be written better
 
Back
Top