• 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.2][SPELL] attempt to index local 'stun' and other issue

SixNine

Active Member
Joined
Dec 12, 2018
Messages
452
Reaction score
41
Using this script
Lua:
local combats = {}
local areas = {
    -- Area 1
    { arr = {{1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 3, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1}},
        effect = CONST_ME_POFF
    },
    -- Area 2
    { arr = {{1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 3, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1}},
        type = COMBAT_FIREDAMAGE,
        effect = CONST_ME_FIREAREA
    },
    -- Area 3
    { arr = {{0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 3, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0}},
        effect = CONST_ME_POFF
    },
    -- Area 4
    { arr = {{0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 3, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0},
             {1, 0, 1, 0, 1, 0, 1},
             {0, 1, 0, 1, 0, 1, 0}},
        type = COMBAT_FIREDAMAGE,
        effect = CONST_ME_FIREAREA
    }
}
 
for i, arr in pairs(areas) do
combats[i] = Combat()
if arr.effect then combats[i]:setParameter(COMBAT_PARAM_EFFECT, arr.effect) end
combats[i]:setArea(createCombatArea(arr.arr))
if arr.type then
    combats[i]:setParameter(COMBAT_PARAM_TYPE, arr.type)
    function onGetFormulaValues(player, level, magicLevel)
        local min = (level / 5) + (magicLevel * 8) + 50
        local max = (level / 5) + (magicLevel * 12) + 75
        return -min, -max
    end
 
    combats[i]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
    end
end
local function castSpell(creatureId, variant, combatIndex)
    local creature = Creature(creatureId)
    if creature then
        combats[combatIndex]:execute(creature, variant)
    end
end
 
function onCastSpell(creature, variant)
    for i = 2, #areas do
        addEvent(castSpell, 800 * i, creature:getId(), variant, i)
        -- Stun
        local stun = Condition(CONDITION_STUN)
        stun:setParameter(CONDITION_PARAM_TICKS, stunDuration)
        stunCreature:addCondition(stun)
    end
    return combats[1]:execute(creature, variant)
end

So issues im having is
1. attempt to index local stun (a nil value)
2. How can i make if i cast this spell once it executes this spell pattern
{ arr = {{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 3, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1}},

and if it casts second time it executes different pattern
{ arr = {{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 3, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0}},
and so on and on so patterns wont be the same because its easy to dodge you can just stand afk.
3. And last think before it casts the spell it would give warning for like 1or 2 seconds where the spell will appear example in this video
gif-20-11-2021-01-34-40-a-m-gif.63514
 
Still looking for these solutions
Code:
2. How can i make if i cast this spell once it executes this spell pattern
{ arr = {{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 3, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1}},

and if it casts second time it executes different pattern
{ arr = {{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 3, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 0}},
and so on and on so patterns wont be the same because its easy to dodge you can just stand afk.
3. And last think before it casts the spell it would give warning for like 1or 2 seconds where the spell will appear example in this video
 
Back
Top