Need Help converting two old spells to tfs 1.2

Lopaskurwa

Member
Joined
Oct 6, 2017
Messages
593
Reaction score
20

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Joined
Mar 16, 2017
Messages
332
Reaction score
157
Location
London
Spell 1
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 10)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 3)
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 5.5) + 25
    local max = (level / 5) + (maglevel * 11) + 50
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local repeatCombats = 5
local executeSpell = function(cid, variant)
    local creature = Creature(cid)
    if creature then
        combat:execute(creature, variant)
    end
end

function onCastSpell(creature, variant)
    local ret = combat:execute(creature, variant)
    if ret then
        for current = 1, (repeatCombats-1) do
            addEvent(executeSpell, 300 * current, creature:getId(), variant)
        end
    end
    return ret
end
 
Last edited:

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,192
Reaction score
736
Location
Arica - Chile
Spell 1
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 10)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 3)
combat:setParameter(COMBAT_FORMULA_LEVELMAGIC, -0.2, 0, -0.2, 0)

local repeatCombats = 5

function onCastSpell(creature, variant)
    local ret = true
    for current = 1, repeatCombats do
        ret = combat:execute(creature, variant)
        if not ret then
            break
        end
    end
    return ret
end
this will only execute it one time or nay? maybe I do not understand spells at all
 
OP
L

Lopaskurwa

Member
Joined
Oct 6, 2017
Messages
593
Reaction score
20
Spell 1
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 10)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 3)
combat:setParameter(COMBAT_FORMULA_LEVELMAGIC, -0.2, 0, -0.2, 0)

local repeatCombats = 5
local executeSpell = function(cid, variant)
    local creature = Creature(cid)
    if creature then
        combat:execute(creature, variant)
    end
end

function onCastSpell(creature, variant)
    local ret = combat:execute(creature, variant)
    if ret then
        for current = 1, (repeatCombats-1) do
            addEvent(executeSpell, 300 * current, creature:getId(), variant)
        end
    end
    return ret
end
Works fine but doesnt do any dmg tho ;D
 
OP
L

Lopaskurwa

Member
Joined
Oct 6, 2017
Messages
593
Reaction score
20
After a lot of tutorial i managed to understand spells. So i finally made it.
If you want to use it.
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setArea(createCombatArea(AREA_BEAMFOUR))

function onGetFormulaValues(cid, level, maglevel)
    min = -((level / 5) + (maglevel * 1.8) + 11)
    max = -((level / 5) + (maglevel * 3) + 19)
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    local player = Player(cid)
    local playerPos = player:getPosition()
    local playerDir = player:getDirection()

    if playerDir == NORTH then
        Position(playerPos.x + 2, playerPos.y - 1, playerPos.z):sendMagicEffect(243)
    elseif playerDir == SOUTH then
        Position(playerPos.x + 2, playerPos.y + 5, playerPos.z):sendMagicEffect(243)
    elseif playerDir == WEST then
        Position(playerPos.x - 1, playerPos.y + 2, playerPos.z):sendMagicEffect(243)
    elseif playerDir == EAST then
        Position(playerPos.x + 5, playerPos.y + 2, playerPos.z):sendMagicEffect(243)
    end

    return combat:execute(cid, var)
end
data/spells/lib/spells.lua add
Lua:
AREA_BEAMFOUR = {
{1,1,1},
{1,1,1},
{1,1,1},
{1,3,1}
}
 
Top