• 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 Spell TFS 1.3

zika12345

New Member
Joined
Aug 29, 2016
Messages
13
Solutions
1
Reaction score
0
Location
Cascavel - PR - Brasil
Guys I'm passing a spell from 8.6 to version 10.98 can anyone tell me what's wrong with it?

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GIANTICE)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -4.5, -400, -4.0, -400)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat2:setFormula(COMBAT_FORMULA_LEVELMAGIC, -4.5, -400, -4.0, -400)

local combat3 = Combat()
combat3:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat3:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GIANTICE)
combat3:setFormula(COMBAT_FORMULA_LEVELMAGIC, -4.5, -400, -4.0, -400)

combat:setArea(createCombatArea(arr1))
combat2:setArea(createCombatArea(arr2))
combat3:setArea(createCombatArea(arr3))

local function onCastSpell2(param)
    if getTilePzInfo(getPlayerPosition(param.cid)) == TRUE or isPlayer(param.cid) == FALSE then -- não continua a magia se o jogador entrar em PZ ou morrer
        return false
    end
   
    if param.skill == TRUE then -- se no teste anterior ele tinha a skill de upgrade, a magia é melhor
        combat:execute(param.cid, param.combat3, param.var)
    else
        combat:execute(param.cid, param.combat2, param.var)
    end
end

function onCastSpell(creature, variant)
    local player = Player(creature)
    if player:getExhaustion(51001) < 0 then -- testa se o jogador já pode usar a magia novamente (exhausted)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendCancelMessage("Você precisa aguardar "..player:getExhaustion(51001).." segundos.")
        return false
    end

    if player:getMana() < 2400 then -- testa se tem mana pra usar a skill
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendCancelMessage("You do not have enough mana.")
        return false
    end
    player:addMana(-2400, false)
    player:addManaSpent(2400)
    player:setExhaustion(51001, 10) -- seta o exhaust
   
    combat:execute(creature, variant)
    if player:getStorageValue(30021) == 1 then -- testa se tem a skill de aprimoramento
        local param = {cid = cid, var = var, combat2 = combat2, combat3 = combat3, skill = TRUE}
        addEvent(onCastSpell2, 500, param)
    else
        local param = {cid = cid, var = var, combat2 = combat2, skill = FALSE}
        addEvent(onCastSpell2, 800, param)
    end
    return true
end
 
Lines 17-19 are calling on arr1 2 and 3 which don't exist in the script. Try adding something like:

Lua:
local arr1 = {
        {0, 0, 0, 1, 0, 0, 0},
        {0, 0, 1, 1, 1, 0, 0},
        {0, 1, 1, 1, 1, 1, 0},
        {1, 1, 1, 3, 1, 1, 1},
        {0, 1, 1, 1, 1, 1, 0},
        {0, 0, 1, 1, 1, 0, 0},
        {0, 0, 0, 1, 0, 0, 0}
    }

and the same for arr2 and arr3.

Also im not sure if its needed, but i always change TRUE and FALSE to true and false.
 
Well I didn't receive any errors after fixing those issues in 1.1 so it should work for you. Do you have an error appearing at all?
If no one else helps, I can tweak it later after work. Maybe try using legacy and a callback parameter.
 
Last edited:
Back
Top