• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

item casting spells

lazarus321

Member
Joined
May 8, 2017
Messages
222
Reaction score
23
Does anyone know how I can make an item cast spells.

Ex. A sword when clicked to use, would cast a spell death_strike on target plus normal attack damage. Remembering that it is not to be automatic is only when you click on the sword.

It would have range 4 and would have spent 150 mana. I use TFS 1.2.
 
One way is to script it as action, another is to make something like player:castSpell() function, but this one requires source edits.
Anyway, weapons are usually 'Use with...' items, so i guess you'll have to use them on something first to make it work.
 
hastebin
this is the code. Work perfect using spell... i dont know how put isso on weapon.

local primeiroCombat = Combat()
primeiroCombat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
primeiroCombat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)
primeiroCombat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
primeiroCombat:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)


local segundoCombat = Combat()
segundoCombat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
segundoCombat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
segundoCombat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
segundoCombat:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)

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

local area2 = createCombatArea( {
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 0, 1, 1, 0},
{1, 0, 0, 3, 0, 0, 1},
{0, 1, 1, 0, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0} } )

primeiroCombat:setArea (area)
segundoCombat:setArea (area2)

function onGetFormulaValues(player, skill, attack, factor)
local min = (player:getLevel() / 1) + (skill * attack * 0.03) + 50
local max = (player:getLevel() / 1) + (skill * attack * 0.08) + 50
return -min, -max
end

primeiroCombat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onGetFormulaValues(player, skill, attack, factor)
local min = (player:getLevel() / 1) + (skill * attack * 0.01) + 50
local max = (player:getLevel() / 1) + (skill * attack * 0.02) + 50
return -min, -max
end
segundoCombat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")


function onUse(creature, variant)
primeiroCombat:execute(creature, variant)
segundoCombat:execute(creature, variant)

return true
end
 
Last edited:
Back
Top