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

Spell doing Multihits:

Derlexy

Intermediate OT User
Joined
Jun 29, 2011
Messages
219
Reaction score
101
Hello guys...
I have this spell, for example:
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
    local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal + attack / 3500) * 0.35) + (levelTotal) + 0), -(((skillTotal + attack / 3125) * 0.5) + (levelTotal) + 5)
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
And i want that this spell hit the target twice...
 
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
    local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal + attack / 3500) * 0.35) + (levelTotal) + 0), -(((skillTotal + attack / 3125) * 0.5) + (levelTotal) + 5)
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    return combat:execute(creature, var)
end
 
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
    local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal + attack / 3500) * 0.35) + (levelTotal) + 0), -(((skillTotal + attack / 3125) * 0.5) + (levelTotal) + 5)
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    return combat:execute(creature, var)
end

KKKK, i've tried just add one more combat:execute(creature, var) too, but it doesnt works =///
 
KKKK, i've tried just add one more combat:execute(creature, var) too, but it doesnt works =///
My bad, I've never got used to spells.
Try this
Code:
local combat = Combat()
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat2:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
    local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal + attack / 3500) * 0.35) + (levelTotal) + 0), -(((skillTotal + attack / 3125) * 0.5) + (levelTotal) + 5)
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(creature, var)
    combat2:execute(creature, var)
    return combat:execute(creature, var)
end
 
My bad, I've never got used to spells.
Try this
Code:
local combat = Combat()
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat2:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
    local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal + attack / 3500) * 0.35) + (levelTotal) + 0), -(((skillTotal + attack / 3125) * 0.5) + (levelTotal) + 5)
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(creature, var)
    combat2:execute(creature, var)
    return combat:execute(creature, var)
end
It doesnt work too =///
 
Code:
local combat = Combat()
local time_between_hits = 1 --seconds
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
  local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
  local levelTotal = player:getLevel() / 5
  return -(((skillTotal + attack / 3500) * 0.35) + (levelTotal) + 0), -(((skillTotal + attack / 3125) * 0.5) + (levelTotal) + 5)
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(creature, var)
   combat:execute(creature, var)
  addEvent(function()  combat:execute(creature, var) end, time_between_hits * 1000)
  return true
end
 
Last edited:
Still doing one hit, and that:
Sem%20tiacutetulo_zpsyv4gwzel.png
 
Hello! I've been trying to modify it by myself to make it hit more than twice, but i've been totally unsuccessfull... Any help please? I really need it! thanks for your time!
 
My advice is don't use spells.xml for anything.
instead make spells in onSay(), onUse() or onThink()
And to make combat we have a nice function called doTargetCombatHealth()
 
I dont really know the difference.. and since i dont have any scripting skills, i cant really change it by myself! But thanks for the advice. Still need help tho..! Thanks for your time!
 
I dont really know the difference.. and since i dont have any scripting skills, i cant really change it by myself! But thanks for the advice. Still need help tho..! Thanks for your time!
Tables.. People.. Tables..
Try this
Code:
local hits = 2 -- amount of times it will hit
local combat = {} -- an empty table to hold all the combat objects
local time_ = 100 -- time between hits in this case 0.1

for i = 1, hits do
    -- create a new combat object and assign it to the index of i
    combat[i] = Combat()
    -- set each index with its param
    combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
    combat[i]:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
    combat[i]:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)
end

function onGetFormulaValues(player, attack, factor)
    local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal + attack / 3500) * 0.35) + (levelTotal) + 0), -(((skillTotal + attack / 3125) * 0.5) + (levelTotal) + 5)
end

for n = 1, hits do
    -- using the same table, set each objects callback at the index of n
    combat[n]:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
end
---------------------------------------------------------------------
-- the section above is all loaded 1st
---------------------------------------------------------------------
function onCastSpell(creature, var)
    for x = 1, hits do
        -- execute each object at the index of x,
        addEvent(
        function(combat, cid, var)
            local creature = Creature(cid)
            if creature then
                combat:execute(creature, var)
            end
        end,
        time_ * x, combat[x], creature:getId(), var
        )
    end
    return true
end
 
Back
Top