• 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 Add Second Effect to spells

Taurus

Texass
Joined
Jan 11, 2009
Messages
616
Solutions
2
Reaction score
30
Location
United States
I started to think about how terrible druid spells look today, and I'd really like to spruce them up a bit.

I was interested in how I can add another effect to the spell. The damage should not change, it should simply show two effects simultaneously when cast.

TFS 1.3 (OTX)
Here is current spell script:

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat:setArea(createCombatArea(AREA_CROSS6X6))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end

Thank you in advance for your help.
 
Lua:
local spell = {
    {
    COMBAT_EARTHDAMAGE, -- index 1
    CONST_ME_STONES, -- index 2
    function(player, level, maglevel) -- index 3
        local min = (level / 5) + (maglevel * 3) + 32
        local max = (level / 5) + (maglevel * 9) + 40
        return -min, -max
    end,
    AREA_CROSS6X6 -- index 4
    },
    {
        COMBAT_EARTHDAMAGE, -- index 1
        CONST_ME_BIGPLANTS, -- index 2
        function(player, level, maglevel) -- index 3
            return 0, 0
    end,
        AREA_CROSS6X6 -- index 4
    }
}

local combat = {}
for i = 1, #spell do
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, spell[i][1])
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, spell[i][2]) ""
    combat[i]:setArea(createCombatArea(spell[i][4]))
    _G['onGetFormulaValues'..i] = spell[i][3](player, level, maglevel)
    combat[i]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues"..i)
end

function onCastSpell(creature, var)
    for x = 1, #spell do
        combat[x]:execute(creature, var)
    end
    return true
end
 
Lua:
local spell = {
    {
    COMBAT_EARTHDAMAGE, -- index 1
    CONST_ME_STONES, -- index 2
    function(player, level, maglevel) -- index 3
        local min = (level / 5) + (maglevel * 3) + 32
        local max = (level / 5) + (maglevel * 9) + 40
        return -min, -max
    end,
    AREA_CROSS6X6 -- index 4
    },
    {
        COMBAT_EARTHDAMAGE, -- index 1
        CONST_ME_BIGPLANTS, -- index 2
        function(player, level, maglevel) -- index 3
            return 0, 0
    end,
        AREA_CROSS6X6 -- index 4
    }
}

local combat = {}
for i = 1, #spell do
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, spell[i][1])
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, spell[i][2]) ""
    combat[i]:setArea(createCombatArea(spell[i][4]))
    _G['onGetFormulaValues'..i] = spell[i][3](player, level, maglevel)
    combat[i]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues"..i)
end

function onCastSpell(creature, var)
    for x = 1, #spell do
        combat[x]:execute(creature, var)
    end
    return true
end

Thanks, this looks like it would work. I don't know what to make of this error though. I don't even see ";" in the script! lol
6qJu89T.png
 
Thanks, this looks like it would work. I don't know what to make of this error though. I don't even see ";" in the script! lol
6qJu89T.png
You can't be that clueless?
Don't you see the double quotes in the script... where there shouldn't be any.. for christ sakes get your head out of your own ass...
Line 26
Lua:
combat[i]:setParameter(COMBAT_PARAM_EFFECT, spell[i][2]) ""
Please do us all a favor and don't bother launching a server.. you don't have what it takes.
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat:setArea(createCombatArea(AREA_CROSS6X6))

--Second spell------------------------
local function castSecondSpell(creature, var)
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat2:setArea(createCombatArea(AREA_CROSS6X6))
return combat2:execute(creature, var)
end
 ------------------------------------
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    addEvent(castSecondSpell, 1000, creature, var) --execute second spell effect
    return true
end

ez...
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat:setArea(createCombatArea(AREA_CROSS6X6))

--Second spell------------------------
local function castSecondSpell(creature, var)
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat2:setArea(createCombatArea(AREA_CROSS6X6))
return combat2:execute(creature, var)
end
 ------------------------------------
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    addEvent(castSecondSpell, 1000, creature, var) --execute second spell effect
    return true
end

ez...
this might crash
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat:setArea(createCombatArea(AREA_CROSS6X6))

--Second spell------------------------
local function castSecondSpell(creature, var)
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat2:setArea(createCombatArea(AREA_CROSS6X6))
return combat2:execute(creature, var)
end
 ------------------------------------
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    addEvent(castSecondSpell, 1000, creature, var) --execute second spell effect
    return true
end
ez...
Please just stop... after all these years you still have no idea what the hell you are doing... Its not completely your fault.. its this poison community of nitwits...
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat:setArea(createCombatArea(AREA_CROSS6X6))

--Second spell------------------------
local function castSecondSpell(creature, var)
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES) -- I'd like to also use "CONST_ME_BIGPLANTS"
combat2:setArea(createCombatArea(AREA_CROSS6X6))
return combat2:execute(creature, var)
end
 ------------------------------------
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    addEvent(castSecondSpell, 1000, creature, var) --execute second spell effect
    return true
end

ez...
vSE6wnM.png

might crash
For educational purposes, I'll share: It didn't
 
Please just stop... after all these years you still have no idea what the hell you are doing... Its not completely your fault.. its this poison community of nitwits...

Piss off. I help here when I have time. Sometimes I mess up how I create the code because im in a rush. To put it in a way you can understand. SMD and dont comment on support threads if your aren't actually helping. You are the one of the people that make this community trash. Literally made an account to come onto the support thread and bash the community. What a fucking no-lifer.

This code should work.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES)
combat:setArea(createCombatArea(AREA_CROSS6X6))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BIGPLANTS)
combat2:setArea(createCombatArea(AREA_CROSS6X6))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    addEvent(combat2:execute, 1000, creature, var) --execute second spell effect
    return true
end
 
Last edited:
Piss off. I help here when I have time. Sometimes I mess up how I create the code because im in a rush. To put it in a way you can understand. SMD and dont comment on support threads if your aren't actually helping. You are the one of the people that make this community trash. Literally made an account to come onto the support thread and bash the community. What a fucking no-lifer.

This code should work.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_STONES)
combat:setArea(createCombatArea(AREA_CROSS6X6))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BIGPLANTS)
combat2:setArea(createCombatArea(AREA_CROSS6X6))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")


local function castSecondSpell(creature, var)
return combat2:execute(creature, var)
end

function onCastSpell(creature, var)
    combat:execute(creature, var)
    addEvent(castSecondSpell, 1000, creature, var) --execute second spell effect
    return true
end
that can also crash
 
that can also crash
I appreciate you looking out for this.

What about these codes can cause a crash?
Will it crash every time because of this?
Is it likely to pass "testing" and crash when being used in combat?

I'm interested to know more about these questions and possibly any others u can foresee an intelligent person arriving at.
 
He is saying it may crash because if the spell tries to use the second effect and the variant is no longer there it might crash. That can be fixed with a simple check that the variant is still able to be casted on. In this case your spell is self targeting.

The problem would be this:

You cast the spell first effect is used
You die
The second effect tries to send but you are no longer in the game
It will cause an error or possibly a crash.
 
He is saying it may crash because if the spell tries to use the second effect and the variant is no longer there it might crash. That can be fixed with a simple check that the variant is still able to be casted on. In this case your spell is self targeting.

The problem would be this:

You cast the spell first effect is used
You die
The second effect tries to send but you are no longer in the game
It will cause an error or possibly a crash.
Fascinating, thank you so much. This is something I might not have otherwise learned.

Not really worth it in the grand scheme.

Thanks to all and for the future, anyone who can solve the aforementioned problem. Show us your stuff! Thanks.
 
Back
Top