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

Help with the spell (tfs 1.2)

Edroniasty

New Member
Joined
Oct 2, 2015
Messages
84
Reaction score
1
Hello! I have my old spell from tfs 1.0, but now Im using tfs 1.2+ and this spell not working - can someone help?

Code:
local acombat1 = createCombatObject()
local acombat2 = createCombatObject()
local acombat3 = createCombatObject()
local acombat4 = createCombatObject()

local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_POFF)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_THROWINGSTAR)
function onGetFormulaValues(player, level, maglevel)
min = -((level / 5) + (maglevel * 1.8) + 11)
max = -((level / 5) + (maglevel * 3) + 19)
return min, max
end


local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_POFF)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_GREENSTAR)
function onGetFormulaValues(player, level, maglevel)
min = -((level / 5) + (maglevel * 1.8) + 11)
max = -((level / 5) + (maglevel * 3) + 19)
return min, max
end

local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, CONST_ME_POFF)
setCombatParam(combat3, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_REDSTAR)
function onGetFormulaValues(player, level, maglevel)
min = -((level / 5) + (maglevel * 1.8) + 11)
max = -((level / 5) + (maglevel * 3) + 19)
return min, max
end

local combat4 = createCombatObject()
setCombatParam(combat4, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat4, COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
setCombatParam(combat4, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
function onGetFormulaValues(player, level, maglevel)
min = -((level / 5) + (maglevel * 1.8) + 11)
max = -((level / 5) + (maglevel * 3) + 19)
return min, max
end



arr1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 2, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

arr2 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 2, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

arr3 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 2, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

arr4 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 2, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

local area1 = createCombatArea(arr1)
local area2 = createCombatArea(arr2)
local area3 = createCombatArea(arr3)
local area4 = createCombatArea(arr4)
setCombatArea(acombat1, area1)
setCombatArea(acombat2, area2)
setCombatArea(acombat3, area3)
setCombatArea(acombat4, area4)

function onTargetTile(cid, pos)
doCombat(cid,combat1,positionToVariant(pos))
end

function onTargetTile2(cid, pos)
doCombat(cid,combat2,positionToVariant(pos))
end

function onTargetTile3(cid, pos)
doCombat(cid,combat3,positionToVariant(pos))
end

function onTargetTile4(cid, pos)
doCombat(cid,combat4,positionToVariant(pos))
end

function onTargetCreature3(cid, target) return doChallengeCreature(cid, target) end
function onTargetCreature4(cid, target) return doChallengeCreature(cid, target) end

setCombatCallback(acombat1, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatCallback(acombat2, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")
setCombatCallback(acombat3, CALLBACK_PARAM_TARGETTILE, "onTargetTile3")
setCombatCallback(acombat4, CALLBACK_PARAM_TARGETTILE, "onTargetTile4")

setCombatCallback(combat3, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature3")
setCombatCallback(combat4, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature4")

local function onCastSpell1(parameters)
doCombat(parameters.cid, acombat1, parameters.var)
end

local function onCastSpell2(parameters)
doCombat(parameters.cid, acombat2, parameters.var)
end

local function onCastSpell3(parameters)
doCombat(parameters.cid, acombat3, parameters.var)
end

local function onCastSpell4(parameters)
doCombat(parameters.cid, acombat4, parameters.var)
end

function onCastSpell(cid, var)
local parameters = { cid = cid, var = var}
addEvent(onCastSpell1, 0, parameters)
addEvent(onCastSpell2, 300, parameters)
addEvent(onCastSpell3, 600, parameters)
addEvent(onCastSpell4, 900, parameters)
return true
end




rep++ for help!
 
What should the spell do? Asfar i see, it challenge creature 4x and the area of spells and combat are the same.
 
Yes, The spell must attack on the same area 4x times, like in code, the damage counts be like this "
function onGetFormulaValues(player, level, maglevel)
min = -((level / 5) + (maglevel * 1.8) + 11)
max = -((level / 5) + (maglevel * 3) + 19)"

I do not know that I understood you correctly.. (my bad English..)

errors from console in lines 1, 7 (
createCombatObject)
 
It is sad that you cannot use the same CALLBACK_PARAM instead of creating duplicate of the same one:

Code:
local combatConfig = {
    [0] = {type = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_THROWINGSTAR},
    [1] = {type = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_GREENSTAR},
    [2] = {type = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_REDSTAR},
    [3] = {type = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_HOLYAREA, distanceEffect = CONST_ANI_SMALLHOLY},
}

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

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

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

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

function onTargetTile0(creature, position)
    creature:getPosition():sendDistanceEffect(position, combatConfig[0].distanceEffect)
end

function onTargetTile1(creature, position)
    creature:getPosition():sendDistanceEffect(position, combatConfig[1].distanceEffect)
end

function onTargetTile2(creature, position)
    creature:getPosition():sendDistanceEffect(position, combatConfig[2].distanceEffect)
end

function onTargetTile3(creature, position)
    creature:getPosition():sendDistanceEffect(position, combatConfig[3].distanceEffect)
end

function onTargetCreature0(creature, target)
    return doChallengeCreature(creature, target)
end

function onTargetCreature1(creature, target)
    return doChallengeCreature(creature, target)
end

function onTargetCreature2(creature, target)
    return doChallengeCreature(creature, target)
end

function onTargetCreature3(creature, target)
    return doChallengeCreature(creature, target)
end

local combat = {}
for i = 0, 3 do 
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, combatConfig[i].type)
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, combatConfig[i].effect)
    combat[i]:setArea(createCombatArea(AREA_CROSS6X6))
    combat[i]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues"..i)
    combat[i]:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile"..i)
    combat[i]:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature"..i)
end

local function combatCallBack(cid, id, variant)
    local player = Player(cid)
    if not player then
        return false
    end

    return combat[id]:execute(player, variant)
end

function onCastSpell(creature, variant)
    local cid = creature:getId()
    for i = 0, 3 do
        addEvent(combatCallBack, i * 500, cid, i, variant)
    end

    return true
end
 
Last edited:
Well it is an area spell, so it should not be any distance effect. Did it show on your old script?
 
Recopy the code, hopefully the CALLBACK_PARAM is not intended to by duplicated. Since the code could be alot shorter. I've created a issue in the github page. Hopefully we got answer soon.
 
Back
Top