OpenTibia SpellCreator: A graphical spell creation enviroment

erikbs

New Member
Joined
Jul 15, 2010
Messages
13
Best answers
0
Reaction score
0
Hi there. Great tool!
The only problem I have is getting the spells to work without crashing the client.
Iam running a 8.6 client on tfs1.3.
I have done the changes needed to be done in "spells.xml", like changing value to script etc.

Here is what I got. Can someone help me out? :) Thanks

The LUA file:

Lua:
-- SpellCreator generated.

-- =============== COMBAT VARS ===============
-- Areas/Combat for 0ms
local combat0_Brush = createCombatObject()
setCombatParam(combat0_Brush, COMBAT_PARAM_EFFECT, CONST_ME_POFF)
setCombatParam(combat0_Brush, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WHIRLWINDSWORD)
setCombatParam(combat0_Brush, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatArea(combat0_Brush,createCombatArea({{1, 1, 1},
{1, 2, 1},
{1, 1, 1}}))
function getDmg_Brush(cid, level, maglevel)
    return (10)*-1,(20)*-1
end
setCombatCallback(combat0_Brush, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush")

-- Areas/Combat for 300ms
local combat3_Brush_2 = createCombatObject()
setCombatParam(combat3_Brush_2, COMBAT_PARAM_EFFECT, CONST_ME_DRAWBLOOD)
setCombatParam(combat3_Brush_2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatArea(combat3_Brush_2,createCombatArea({{1, 1, 1},
{1, 2, 1},
{1, 1, 1}}))
function getDmg_Brush_2(cid, level, maglevel)
    return (10)*-1,(20)*-1
end
setCombatCallback(combat3_Brush_2, CALLBACK_PARAM_LEVELMAGICVALUE, "getDmg_Brush_2")

local con_Bleed__combat3_Brush_2 = createConditionObject(0+CONDITION_BLEEDING)
addDamageCondition(con_Bleed__combat3_Brush_2, 3, 1000, -10)
setCombatCondition(combat3_Brush_2, con_Bleed__combat3_Brush_2)

-- =============== 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,cid,var)
    addEvent(RunPart,300,combat3_Brush_2,cid,var)
    return true
end
The XLM file:

XML:
<instant group="attack" spellid="500" name="test" words="test" lvl="1" maglv="1" mana="1" exhaustion="1000" prem="0" needlearn="0" blockwalls="0" aggressive="1" script="attack/test.lua">
    <vocation id="9"/>
    </instant>
(and yes I have a vocation 9) :D hehe

This is a screenshot of the error message after crash:
(It may be very obvious what the issue is, but right now I cant figure it out)
I have also tried to make very simple spells, but run into the same issue. I have a feeling it has to do with that the SpellCreator is built for earlier version of TFS, and that the code has change abit, and it may be a very simple solution to it.
 

Attachments

Last edited:

Red

Cyntara Admin
Staff member
Global Moderator
Premium User
Joined
Aug 9, 2008
Messages
4,399
Best answers
1
Reaction score
811
Location
United States
You’re receiving a warning in your console because the SpellCreator was made for 0.3 and 0.3 passes cid into onCastSpell. 1.3 passes creature userdata into onCastSpell and you’re passing the userdata into an addEvent loop - if the creature userdata becomes nonexistent while this loop attempts to execute, your server will crash.

Replace:
Lua:
function onCastSpell(cid, var)
    local startPos = getCreaturePosition(cid)
    RunPart(combat0_Brush,cid,var)
    addEvent(RunPart,300,combat3_Brush_2,cid,var)
    return true
end
With:
Lua:
function onCastSpell(creature, var)
    local cid = creature:getId()
    RunPart(combat0_Brush,cid,var)
    addEvent(RunPart,300,combat3_Brush_2,cid,var)
    return true
end
Posting from my phone, sorry if my formatting sucks.

Red
 
Top