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

Solved Berserk spell help

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
834
Solutions
123
Reaction score
675
Location
United States
Can't get effect to go in the area 1x1, it only is displaying on top of character. Feel like it's "getPosition():sendMagicEffect" but tried doSendMagicEffect instead and that didn't work either. What am I doing wrong?

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
    local level = getPlayerLevel(cid)

    local min = -((weaponSkill+weaponAttack)*0.5+(level/5))
    local max = -((weaponSkill+weaponAttack)*1.5+(level/5))

    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)

local config = {
    [0] = {combat_effect = 7},
    [1] = {combat_effect = 7},
    [2] = {combat_effect = 7},
    [3] = {combat_effect = 7},
    [4] = {combat_effect = 7},
    [5] = {combat_effect = 10},
    [6] = {combat_effect = 10},
    [7] = {combat_effect = 10},
    [8] = {combat_effect = 10},
    [9] = {combat_effect = 54},
    [10] = {combat_effect = 54},
    [11] = {combat_effect = 54},
    [12] = {combat_effect = 54},
    [13] = {combat_effect = 46},
    [14] = {combat_effect = 46},
    [15] = {combat_effect = 46},
    [16] = {combat_effect = 46},
    [17] = {combat_effect = 7},
    [18] = {combat_effect = 7},
    [19] = {combat_effect = 7},
    [20] = {combat_effect = 7},
    [21] = {combat_effect = 10},
    [22] = {combat_effect = 10},
    [23] = {combat_effect = 10},
    [24] = {combat_effect = 10},
    [25] = {combat_effect = 54},
    [26] = {combat_effect = 54},
    [27] = {combat_effect = 54},
    [28] = {combat_effect = 54},
    [29] = {combat_effect = 46},
    [30] = {combat_effect = 46},
    [31] = {combat_effect = 46},
    [32] = {combat_effect = 46}
}

function onCastSpell(cid, var)
    local vocation_id = cid:getVocation():getId()
    
    cid:getPosition():sendMagicEffect(config[vocation_id].combat_effect)
    return doCombat(cid, combat, var)
end
 
Solution
If you want different effect for different vocations, here's tested and working script. For advanced effects manipulations use onTargetTile + setArea option.

Code:
local config = {
    [0] = {combat_effect = 7},
    [1] = {combat_effect = 7},
    [2] = {combat_effect = 7},
    [3] = {combat_effect = 7},
    [4] = {combat_effect = 7},
    [5] = {combat_effect = 10},
    [6] = {combat_effect = 10},
    [7] = {combat_effect = 10},
    [8] = {combat_effect = 10},
    [9] = {combat_effect = 54},
    [10] = {combat_effect = 54},
    [11] = {combat_effect = 54},
    [12] = {combat_effect = 54},
    [13] = {combat_effect = 46},
    [14] = {combat_effect = 46},
    [15] = {combat_effect = 46},
    [16] =...
Np bro. ehhh just curious why does ur script contain this?
Code:
local config = {
    [0] = {combat_effect = 7},
    [1] = {combat_effect = 7},
    [2] = {combat_effect = 7},
    [3] = {combat_effect = 7},
    [4] = {combat_effect = 7},
    [5] = {combat_effect = 10},
    [6] = {combat_effect = 10},
    [7] = {combat_effect = 10},
    [8] = {combat_effect = 10},
    [9] = {combat_effect = 54},
    [10] = {combat_effect = 54},
    [11] = {combat_effect = 54},
    [12] = {combat_effect = 54},
    [13] = {combat_effect = 46},
    [14] = {combat_effect = 46},
    [15] = {combat_effect = 46},
    [16] = {combat_effect = 46},
    [17] = {combat_effect = 7},
    [18] = {combat_effect = 7},
    [19] = {combat_effect = 7},
    [20] = {combat_effect = 7},
    [21] = {combat_effect = 10},
    [22] = {combat_effect = 10},
    [23] = {combat_effect = 10},
    [24] = {combat_effect = 10},
    [25] = {combat_effect = 54},
    [26] = {combat_effect = 54},
    [27] = {combat_effect = 54},
    [28] = {combat_effect = 54},
    [29] = {combat_effect = 46},
    [30] = {combat_effect = 46},
    [31] = {combat_effect = 46},
    [32] = {combat_effect = 46}
}

function onCastSpell(cid, var)

Not that it looks bad just wondering cuz mine doesnt xD

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, 1)

local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)

function onGetFormulaValues(cid, skill, attack, factor)
    local skillTotal, levelTotal = skill * attack, getPlayerLevel(cid) / 5
    return -(((skillTotal * 0.03) + 7) + (levelTotal)), -(((skillTotal * 0.05) + 11) + (levelTotal))
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

anyways can you post your spells.xml the lines for berserk as well?
 
Last edited:
It's a vocation specific berserk spell, that displays different effects. The vocation part is working, it's just not sending the effect to the 1x1 area and only ontop of the character.
 
you haven't set a combat effect
like that guy posted above, he has this
Code:
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
 
Instead of this:
Code:
local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)

Use this:
Code:
local area = createCombatArea({
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 3, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}
})
setCombatArea(combat, area)
Number 3 is a center. If you wont use effect on center too, use 2 instead.
Nr 1 is where effect should appear relative to center, 0 means no effect at all.
If you still want to use AREA_SQUARE etc, look to your data/spells/lib/spells.lua
 
Updated to this:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

local area = createCombatArea({
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 3, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}
})
setCombatArea(combat, area)

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
    local level = getPlayerLevel(cid)

    local min = -((weaponSkill+weaponAttack)*0.5+(level/5))
    local max = -((weaponSkill+weaponAttack)*1.5+(level/5))

    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

local config = {
    [0] = {combat_effect = 7},
    [1] = {combat_effect = 7},
    [2] = {combat_effect = 7},
    [3] = {combat_effect = 7},
    [4] = {combat_effect = 7},
    [5] = {combat_effect = 10},
    [6] = {combat_effect = 10},
    [7] = {combat_effect = 10},
    [8] = {combat_effect = 10},
    [9] = {combat_effect = 54},
    [10] = {combat_effect = 54},
    [11] = {combat_effect = 54},
    [12] = {combat_effect = 54},
    [13] = {combat_effect = 46},
    [14] = {combat_effect = 46},
    [15] = {combat_effect = 46},
    [16] = {combat_effect = 46},
    [17] = {combat_effect = 7},
    [18] = {combat_effect = 7},
    [19] = {combat_effect = 7},
    [20] = {combat_effect = 7},
    [21] = {combat_effect = 10},
    [22] = {combat_effect = 10},
    [23] = {combat_effect = 10},
    [24] = {combat_effect = 10},
    [25] = {combat_effect = 54},
    [26] = {combat_effect = 54},
    [27] = {combat_effect = 54},
    [28] = {combat_effect = 54},
    [29] = {combat_effect = 46},
    [30] = {combat_effect = 46},
    [31] = {combat_effect = 46},
    [32] = {combat_effect = 46}
}

function onCastSpell(cid, var)
    local vocation_id = cid:getVocation():getId()
   
    cid:getPosition():sendMagicEffect(config[vocation_id].combat_effect)
    return doCombat(cid, combat, var)
end

Still getting this:

bug.png


Was thinking maybe there's a way to setCombatParam with a local config or something, but at least the way I set it up didn't work.
 
Code:
local area = createCombatArea({
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 3, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}
})

local config = {
    [0] = {combat_effect = 7},
    [1] = {combat_effect = 7},
    [2] = {combat_effect = 7},
    [3] = {combat_effect = 7},
    [4] = {combat_effect = 7},
    [5] = {combat_effect = 10},
    [6] = {combat_effect = 10},
    [7] = {combat_effect = 10},
    [8] = {combat_effect = 10},
    [9] = {combat_effect = 54},
    [10] = {combat_effect = 54},
    [11] = {combat_effect = 54},
    [12] = {combat_effect = 54},
    [13] = {combat_effect = 46},
    [14] = {combat_effect = 46},
    [15] = {combat_effect = 46},
    [16] = {combat_effect = 46},
    [17] = {combat_effect = 7},
    [18] = {combat_effect = 7},
    [19] = {combat_effect = 7},
    [20] = {combat_effect = 7},
    [21] = {combat_effect = 10},
    [22] = {combat_effect = 10},
    [23] = {combat_effect = 10},
    [24] = {combat_effect = 10},
    [25] = {combat_effect = 54},
    [26] = {combat_effect = 54},
    [27] = {combat_effect = 54},
    [28] = {combat_effect = 54},
    [29] = {combat_effect = 46},
    [30] = {combat_effect = 46},
    [31] = {combat_effect = 46},
    [32] = {combat_effect = 46}
}

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
    local level = getPlayerLevel(cid)
    local min = -((weaponSkill+weaponAttack)*0.5+(level/5))
    local max = -((weaponSkill+weaponAttack)*1.5+(level/5))
    return min, max
end

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setArea(area)
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

function onCastSpell(cid, var)
    local vocation_id = cid:getVocation():getId()
    local effect = config[vocation_id].combat_effect
    combat:setParameter(COMBAT_PARAM_EFFECT, effect)
    return doCombat(cid, combat, var)
end

Tested on TFS 1.2
 
Tried it but got:
Lua Script Error: [Test Interface]
data/spells/scripts/attack/berserk.lua
data/spells/scripts/attack/berserk.lua:54: attempt to index local 'combat' (a number value)
stack traceback:
[C]: in function '__index'
data/spells/scripts/attack/berserk.lua:54: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/attack/berserk.lua

Tried to change it to setCombatParam but can't use that function there.
Also tried to change to this:
Code:
local area = createCombatArea({
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 3, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}
})

local config = {
    [0] = {combat_effect = 7},
    [1] = {combat_effect = 7},
    [2] = {combat_effect = 7},
    [3] = {combat_effect = 7},
    [4] = {combat_effect = 7},
    [5] = {combat_effect = 10},
    [6] = {combat_effect = 10},
    [7] = {combat_effect = 10},
    [8] = {combat_effect = 10},
    [9] = {combat_effect = 54},
    [10] = {combat_effect = 54},
    [11] = {combat_effect = 54},
    [12] = {combat_effect = 54},
    [13] = {combat_effect = 46},
    [14] = {combat_effect = 46},
    [15] = {combat_effect = 46},
    [16] = {combat_effect = 46},
    [17] = {combat_effect = 7},
    [18] = {combat_effect = 7},
    [19] = {combat_effect = 7},
    [20] = {combat_effect = 7},
    [21] = {combat_effect = 10},
    [22] = {combat_effect = 10},
    [23] = {combat_effect = 10},
    [24] = {combat_effect = 10},
    [25] = {combat_effect = 54},
    [26] = {combat_effect = 54},
    [27] = {combat_effect = 54},
    [28] = {combat_effect = 54},
    [29] = {combat_effect = 46},
    [30] = {combat_effect = 46},
    [31] = {combat_effect = 46},
    [32] = {combat_effect = 46}
}

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
    local level = getPlayerLevel(cid)
    local min = -((weaponSkill+weaponAttack)*0.5+(level/5))
    local max = -((weaponSkill+weaponAttack)*1.5+(level/5))
    return min, max
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setArea(area)
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

function onCastSpell(cid, var)
    local vocation_id = cid:getVocation():getId()
    local effect = config[vocation_id].combat_effect
    combat:setParameter(COMBAT_PARAM_EFFECT, effect)
    return doCombat(cid, combat, var)
end

And in turn got this:
LuaScriptInterface::luaDoCombat(). Combat not found stack traceback: [C]: at 0x7ff729e89240
 
If you want different effect for different vocations, here's tested and working script. For advanced effects manipulations use onTargetTile + setArea option.

Code:
local config = {
    [0] = {combat_effect = 7},
    [1] = {combat_effect = 7},
    [2] = {combat_effect = 7},
    [3] = {combat_effect = 7},
    [4] = {combat_effect = 7},
    [5] = {combat_effect = 10},
    [6] = {combat_effect = 10},
    [7] = {combat_effect = 10},
    [8] = {combat_effect = 10},
    [9] = {combat_effect = 54},
    [10] = {combat_effect = 54},
    [11] = {combat_effect = 54},
    [12] = {combat_effect = 54},
    [13] = {combat_effect = 46},
    [14] = {combat_effect = 46},
    [15] = {combat_effect = 46},
    [16] = {combat_effect = 46},
    [17] = {combat_effect = 7},
    [18] = {combat_effect = 7},
    [19] = {combat_effect = 7},
    [20] = {combat_effect = 7},
    [21] = {combat_effect = 10},
    [22] = {combat_effect = 10},
    [23] = {combat_effect = 10},
    [24] = {combat_effect = 10},
    [25] = {combat_effect = 54},
    [26] = {combat_effect = 54},
    [27] = {combat_effect = 54},
    [28] = {combat_effect = 54},
    [29] = {combat_effect = 46},
    [30] = {combat_effect = 46},
    [31] = {combat_effect = 46},
    [32] = {combat_effect = 46}
}

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
    local level = getPlayerLevel(cid)

    local min = -((weaponSkill+weaponAttack)*0.5+(level/5))
    local max = -((weaponSkill+weaponAttack)*1.5+(level/5))

    return min, max
end

function onTargetTile(cid, position)
    return position:sendMagicEffect(config[cid:getVocation():getId()].combat_effect)
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setArea(createCombatArea({
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 3, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}
}))
combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

function onCastSpell(cid, var)
    return combat:execute(cid, var)
end
 
Solution
Back
Top