• 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 Multiframe spells

Doitforthegains

Well-Known Member
Joined
Aug 30, 2014
Messages
231
Reaction score
74
So spellcreator is outdated and wont support TFS 1.1 which is what I use; all the spell tutorials I've read are just about how to change effects/animations/etc so they aren't relevant for me. I was wondering if I posted the spell I made on spellcreator, could someone with knowledge of TFS 1.1 edit the script so that it will be compatable?
Code:
local combat0_Brush_2 = createCombatObject()
setCombatParam(combat0_Brush_2, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
setCombatParam(combat0_Brush_2, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat0_Brush_2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
function getDmg_Brush_2(cid, level, maglevel)
    return (10)*-1,(20)*-1 
end
setCombatCallback(combat0_Brush_2, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush_2")
local dfcombat0_Brush_2 = {CONST_ANI_ENERGYBALL,0,1}

-- Areas/Combat for 100ms
local combat1_Brush = createCombatObject()
setCombatParam(combat1_Brush, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat1_Brush, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat1_Brush, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function getDmg_Brush(cid, level, maglevel)
    return (10)*-1,(20)*-1 
end
setCombatCallback(combat1_Brush, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush")
local dfcombat1_Brush = {CONST_ANI_FIRE,0,1}

-- Areas/Combat for 200ms
local combat2_Brush_3 = createCombatObject()
setCombatParam(combat2_Brush_3, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat2_Brush_3, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat2_Brush_3, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
function getDmg_Brush_3(cid, level, maglevel)
    return (10)*-1,(20)*-1 
end
setCombatCallback(combat2_Brush_3, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush_3")
local dfcombat2_Brush_3 = {CONST_ANI_ICE,0,1}

-- =============== CORE FUNCTIONS ===============
local function RunPart(c,cid,var,dirList,dirEmitPos) -- Part
    if (isCreature(cid)) then
        doCombat(cid, c, var)
        if (dirList ~= nil) then -- Emit distance effects
            local i = 2;
            while (i < #dirList) do
                doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
                i = i + 2
            end       
        end
    end
end

function onCastSpell(cid, var)
    local startPos = getCreaturePosition(cid)
    RunPart(combat0_Brush_2,cid,var,dfcombat0_Brush_2,startPos)
    addEvent(RunPart,100,combat1_Brush,cid,var,dfcombat1_Brush,startPos)
    addEvent(RunPart,200,combat2_Brush_3,cid,var,dfcombat2_Brush_3,startPos)
    return true
end


This is the error I'm currently getting:
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/custom/elemental strike.lua:onCastSpell
data/spells/scripts/custom/elemental strike.lua:52: attempt to call global 'getC
reaturePosition' (a nil value)
stack traceback:
        [C]: in function 'getCreaturePosition'
        data/spells/scripts/custom/elemental strike.lua:52: in function <data/sp
ells/scripts/custom/elemental strike.lua:51>


I'm hoping that if someone will edit this for me that it will give me a reliable source to look at to understand how to write the script myself for future references. Thanks in advance!
 
Last edited:
I'm not sure how this didn't come up when I searched addevent, it's a pretty good tutorial on how to use it but I'm still unsure of what functions to use
 
Last edited:
I didn't check the rest of the code, I only fixed the error
Code:
local combat0_Brush_2 = createCombatObject()
setCombatParam(combat0_Brush_2, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
setCombatParam(combat0_Brush_2, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat0_Brush_2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
function getDmg_Brush_2(cid, level, maglevel)
    return (10)*-1,(20)*-1
end
setCombatCallback(combat0_Brush_2, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush_2")
local dfcombat0_Brush_2 = {CONST_ANI_ENERGYBALL,0,1}

-- Areas/Combat for 100ms
local combat1_Brush = createCombatObject()
setCombatParam(combat1_Brush, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat1_Brush, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat1_Brush, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function getDmg_Brush(cid, level, maglevel)
    return (10)*-1,(20)*-1
end
setCombatCallback(combat1_Brush, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush")
local dfcombat1_Brush = {CONST_ANI_FIRE,0,1}

-- Areas/Combat for 200ms
local combat2_Brush_3 = createCombatObject()
setCombatParam(combat2_Brush_3, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat2_Brush_3, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat2_Brush_3, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
function getDmg_Brush_3(cid, level, maglevel)
    return (10)*-1,(20)*-1
end
setCombatCallback(combat2_Brush_3, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush_3")
local dfcombat2_Brush_3 = {CONST_ANI_ICE,0,1}

-- =============== CORE FUNCTIONS ===============
local function RunPart(c,cid,var,dirList,dirEmitPos) -- Part
    if (isCreature(cid)) then
        doCombat(cid, c, var)
        if (dirList ~= nil) then -- Emit distance effects
            local i = 2;
            while (i < #dirList) do
                doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
                i = i + 2
            end     
        end
    end
end

function onCastSpell(cid, var)
    local startPos = Player(cid):getTarget():getPosition()
    RunPart(combat0_Brush_2,cid,var,dfcombat0_Brush_2,startPos)
    addEvent(RunPart,100,combat1_Brush,cid,var,dfcombat1_Brush,startPos)
    addEvent(RunPart,200,combat2_Brush_3,cid,var,dfcombat2_Brush_3,startPos)
    return true
end
 
Thank you for the help, I changed my script to the one @Breed edited and I added the file @Evil Puncker posted to my data folder as "compat".
Now this is the error I'm getting:
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/custom/elemental strike.lua:onCastSpell
data/spells/scripts/custom/elemental strike.lua:48: attempt to index a nil value

stack traceback:
        [C]: in function '__index'
        data/spells/scripts/custom/elemental strike.lua:48: in function <data/sp
ells/scripts/custom/elemental strike.lua:47>
Thanks again for the help guys!
 
Last edited:
BUMP. If someone could please help me fix this spell! This (animated spells) is the last thing holding me back from finishing the base of my server! :)
 
BUMP. If someone could please help me fix this spell! This (animated spells) is the last thing holding me back from finishing the base of my server! :)
Here is some "help"
Code:
data/spells/scripts/custom/elemental strike.lua:onCastSpell
data/spells/scripts/custom/elemental strike.lua:48: attempt to index a nil value
See what it says notice the number? strike.lua:48 <-- is the line the error is on
attempt to index a nil value <-- this is the error

This is line 48
Code:
local startPos = Player(cid):getTarget():getPosition()
Your halfway there.. I can help you no more..
 
So I just changed a few things and removed some lines but it seems to be working now... this is the script I have now. Let me know if you see anything wrong with it?
Code:
local combat0_Brush_2 = createCombatObject()
setCombatParam(combat0_Brush_2, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
setCombatParam(combat0_Brush_2, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat0_Brush_2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
function getDmg_Brush_2(cid, level, maglevel)
    return (10)*-1,(20)*-1
end
setCombatCallback(combat0_Brush_2, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush_2")
local dfcombat0_Brush_2 = {CONST_ANI_ENERGYBALL,0,1}

-- Areas/Combat for 100ms
local combat1_Brush = createCombatObject()
setCombatParam(combat1_Brush, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat1_Brush, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat1_Brush, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function getDmg_Brush(cid, level, maglevel)
    return (10)*-1,(20)*-1
end
setCombatCallback(combat1_Brush, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush")
local dfcombat1_Brush = {CONST_ANI_FIRE,0,1}

-- Areas/Combat for 200ms
local combat2_Brush_3 = createCombatObject()
setCombatParam(combat2_Brush_3, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat2_Brush_3, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat2_Brush_3, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
function getDmg_Brush_3(cid, level, maglevel)
    return (10)*-1,(20)*-1
end
setCombatCallback(combat2_Brush_3, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush_3")
local dfcombat2_Brush_3 = {CONST_ANI_ICE,0,1}

-- =============== CORE FUNCTIONS ===============
local function RunPart(c,cid,var,dirList,dirEmitPos) -- Part
    if (Creature(cid)) then
        doCombat(cid, c, var) 
    end
end

function onCastSpell(cid, var)
    local startPos = Player(cid):getTarget():getPosition()
    addEvent(RunPart,50,combat0_Brush_2,cid,var,dfcombat0_Brush_2,startPos)
    addEvent(RunPart,100,combat1_Brush,cid,var,dfcombat1_Brush,startPos)
    addEvent(RunPart,200,combat2_Brush_3,cid,var,dfcombat2_Brush_3,startPos)
    return true
end
And sorry I'm asking for so much help, I have no experience in scripting so I'm very limited in what I can do.

EDIT: One problem noted was that since I removed the sendDirectionshoottype and the other direction lines I get a console error when I cast the spell with no target selected. I changed the spell to require a target to patch this error for now..
 
Last edited:
It's no problem bro, most of us have been there too ^^
if you used the compat of Evil Puncker, u should be able to use the spell file you first used.
I guess thats what evil puncker gave it for in the first place :)
 
It's no problem bro, most of us have been there too ^^
if you used the compat of Evil Puncker, u should be able to use the spell file you first used.
I guess thats what evil puncker gave it for in the first place :)
I added the compat but do I also need to reference it somewhere? Because I feel as if it didn't register and therefore didn't fix the compatability :/
 
I added the compat but do I also need to reference it somewhere? Because I feel as if it didn't register and therefore didn't fix the compatability :/
im no TFS 1.1 expert but I'm pretty sure you don't have to register anything if its a global

He is correct. Go into your global.lua file and add the line dofile("data/compat.lua") somewhere (usually at the top), and make sure it is in appropriate directory, in the example I used it would be in the data folder. If you wanted to do a sub folder you could do it like this dofile("data/libs/compat.lua").
 
Back
Top