• 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 0.X Exori with wand element

sabodden

Member
Joined
Sep 27, 2019
Messages
138
Reaction score
18
I wanna make a spell that element is based in wand element
How to do it?

I tried:
Code:
local combat = createCombatObject()
function onGetFormulaValues(cid, level, maglevel)
    min = ( (((maglevel) * (5) ) * 0.5 ) + (50) ) * -1
    max = ( (((maglevel) * (5) ) * 1.0 ) + (100) ) * -1
    return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function GetWandElement(item1, item2)
    -- holy
    if item1 == 2437 or item1 == 7424 or item1 == 7735 or item1 == 2184 or item1 == 7410 or item1 == 12327 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
        return true
    -- poison
    elseif item1 == 2182 or item1 == 2181 or item1 == 8912 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, 9)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 14)
        return true
    -- ice
    elseif item1 == 2186 or item1 == 8911 or item1 == 2183 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
        return true
    -- death
    elseif item1 == 2185 or item1 == 2188 or item1 == 8910 or item1 == 8922 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
        return true
    -- energy
    elseif item1 == 2190 or item1 == 2189 or item1 == 8920 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
        return true
    -- fire
    elseif item1 == 2191 or item1 == 8921 or item1 == 2187 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
        return true
    end


    -- holy
    if item2 == 2437 or item2 == 7424 or item2 == 7735 or item2 == 2184 or item2 == 7410 or item2 == 12327 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
        return true
    -- poison
    elseif item2 == 2182 or item2 == 2181 or item2 == 8912 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, 9)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 14)
        return true
    -- ice
    elseif item2 == 2186 or item2 == 8911 or item2 == 2183 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
        return true
    -- death
    elseif item2 == 2185 or item2 == 2188 or item2 == 8910 or item2 == 8922 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
        return true
    -- energy
    elseif item2 == 2190 or item2 == 2189 or item2 == 8920 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
        return true
    -- fire
    elseif item2 == 2191 or item2 == 8921 or item2 == 2187 then
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
        setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
        return true
    end



    -- default holy
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
    return true
end

function onCastSpell(cid, var)
    local item1 = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    local item2 = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    GetWandElement(item1.itemid, item2.itemid)
    return doCombat(cid, combat, var)
end

But with no success :(
What i did wrong?
 
Solution
What i did wrong?
Lua:
GetWandElement(item1.itemid, item2.itemid)

I don't know if .itemid works in this scenario. A better/ more proper way would be to do item1:getId()
In both cases, you should confirm that the item exists before attempting to grab information from it though. xP

--
Anyway none of this will work, because combat objects can only be created upon server start-up.

You'd have to create all of the combat objects manually, and then choose which combat you want to use.

Example..
Lua:
if wand == fire then
    return doCombat(cid, combatFire, var)
elseif wand == ice then
    return doCombat(cid, combatIce, var)
end
What i did wrong?
Lua:
GetWandElement(item1.itemid, item2.itemid)

I don't know if .itemid works in this scenario. A better/ more proper way would be to do item1:getId()
In both cases, you should confirm that the item exists before attempting to grab information from it though. xP

--
Anyway none of this will work, because combat objects can only be created upon server start-up.

You'd have to create all of the combat objects manually, and then choose which combat you want to use.

Example..
Lua:
if wand == fire then
    return doCombat(cid, combatFire, var)
elseif wand == ice then
    return doCombat(cid, combatIce, var)
end
 
Solution
Back
Top