• 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!

Convert Spell Chain Lightning to TFS 1.3

kyouxyz

New Member
Joined
Aug 10, 2018
Messages
1
Reaction score
0
Hello, I wish someone could help me with this spell, because my server is TFS 1.3 and two functions of these scripts are giving error, they would be '' Do blast "and" getPlayerSkillLevel "if anyone can help I would be forever grateful.

Link of the Spell: Chain Lightning (https://tibiaking.com/forums/topic/47069-chain-lightning/)

Script used:
Lua:
local config = {
    effectx = 35, --- efeito de distancia
    effectz = 11, --- efeito ao acertar o player
    percent = 100, --- porcentagem de ir pra outro target apos hitar
    delay = 300 --- velocidade com que se move (milisegundos)
}

function onCastSpell(cid, var)
local maglevel, level, mana = getPlayerMagLevel(cid), getPlayerLevel(cid), getCreatureMana(cid)
local axe, sword, club, distance = getPlayerSkillLevel(cid, 3), getPlayerSkillLevel(cid, 2), getPlayerSkillLevel(cid, 1), getPlayerSkillLevel(cid, 4)
local shield, health = getPlayerSkillLevel(cid, 5), getCreatureHealth(cid)

    local formula = {
    min = ((level + maglevel)/5 + axe + sword + club + shield + (mana/1000))/3, --- formula de dano minimo
    max = ((level + maglevel)/5 + axe + sword + club + shield + ((mana + health)/1000))/3 --- formula de dano maximo
    }
    
local pos = getCreaturePosition(cid)
doCreatureSay(cid, "Chain Lightning", 20, false, 0, pos)
hits = math.ceil(getPlayerMagLevel(cid)/10) - (math.random(0, (math.floor(getPlayerMagLevel(cid)/10))) - 1)
target = getCreatureTarget(cid)
doBlast(cid, target, config.delay, config.effectx, config.effectz, config.percent, formula.min, formula.max, 2, hits, getCreaturePosition(cid), nil)
return true
end
 
Did you read the full post? Not fixed yet, but you are missing some code:
Code:
local config = {
    effectx = 35, --- efeito de distancia
    effectz = 11, --- efeito ao acertar o player
    percent = 70, --- porcentagem de ir pra outro target apos hitar
    delay = 150 --- velocidade com que se move (milisegundos)
}

function doBlast(uid, target, delay, effectx, effectz, percent, min, max, type, hits, fromPos, n)
    if fromPos ~= nil and (fromPos.x ~= getCreaturePosition(target).x or fromPos.y ~= getCreaturePosition(target).y) then
        doSendDistanceShoot(fromPos, getCreaturePosition(target), effectx)
        fromPos = (fromPos.x ~= getCreaturePosition(target).x or fromPos.y ~= getCreaturePosition(target).y) and getCreaturePosition(target) or nil
    else
        fromPos = getCreaturePosition(target)
    end    
doTargetCombatHealth(uid, target, type, -min, -max, effectz)
n = n or 1
if math.random(1, 10) <= (percent/10) then
    possible = {}
    for j = -3, 3 do
    for k = -3, 3 do
        middlePos = {x = getCreaturePosition(target).x + j, y = getCreaturePosition(target).y + k, z = getCreaturePosition(target).z, stackpos = 253}
        if isWalkable(middlePos, false, true, true) then
            creature = getTopCreature(middlePos).uid        
            if creature > 0 then
                table.insert(possible, creature)
            end
        end
    end
    end        
    target = #possible > 0 and possible[math.random(#possible)] or target
end        
if n < hits then
    addEvent(function()
    if isCreature(uid) and isCreature(target) then
        doBlast(uid, target, delay, effectx, effectz, percent, min, max, type, hits, fromPos, (n + 1))
    end
    end, delay)
end
return true
end

function onCastSpell(cid, var)
local maglevel, level, mana = getPlayerMagLevel(cid), getPlayerLevel(cid), getCreatureMana(cid)
local axe, sword, club, distance = getPlayerSkillLevel(cid, 3), getPlayerSkillLevel(cid, 2), getPlayerSkillLevel(cid, 1), getPlayerSkillLevel(cid, 4)
local shield, health = getPlayerSkillLevel(cid, 5), getCreatureHealth(cid)

    local formula = {
    min = ((level + maglevel)/5 + axe + sword + club + shield + (mana/1000))/3, --- formula de dano minimo
    max = ((level + maglevel)/5 + axe + sword + club + shield + ((mana + health)/1000))/3 --- formula de dano maximo
    }
   
local pos = getCreaturePosition(cid)
doCreatureSay(cid, "Chain Lightning", 20, false, 0, pos)
hits = math.ceil(getPlayerMagLevel(cid)/10) - (math.random(0, (math.floor(getPlayerMagLevel(cid)/10))) - 1) 
target = getCreatureTarget(cid)
doBlast(cid, target, config.delay, config.effectx, config.effectz, config.percent, formula.min, formula.max, 2, hits, getCreaturePosition(cid), nil)
return true
end

For getPlayerSkill level, use instead https://github.com/otland/forgotten...14ad72710b7b46b4141fd/src/luascript.cpp#L2309 player:getSkillLevel(skillType)
 
Back
Top