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

Lua spell - script that hits twice within a delay and shows some magic effects

Status
Not open for further replies.

dantexd

Member
Joined
Sep 1, 2010
Messages
97
Reaction score
23
Can someone help me here. I`ve been trying to edit this to understand more from it and to recreate this script on other spells but im stuck.
So basicly its a script that hits twice within a delay and shows some magic effects.

The problem is when hitting only showing the same effect after each hit. (Instead of nr of effects)

Lua:
local config = {
efecto1 = 64, -- efeito q ira aparacer a cada teleport.
efecto2 = 72, -- efeito q ira aparecer ao hitar no alvo
hits = 2, -- quantos hits vai dar
delay = 1200, -- intervalo de tempo a cada hit
mindmg = 11000,
maxdmg = 12000,
damage = COMBAT_PHYSICALDAMAGE -- tipo do dano
}


spell1 = {
start1 = function (cid, target, markpos, hits)
    if not isCreature(cid) then return true end
    if not isCreature(target) or hits < 1 then
                 return true
    end
    posAv = validPos(getThingPos(target))
    rand = #posAv == 1 and 1 or #posAv - 1

    doAreaCombatHealth(cid, config.damage, getThingPos(target), 0, -config.mindmg, -config.maxdmg, config.efecto1)
    addEvent(spell1.start1, config.delay, cid, target, markpos, hits - 1)
   end
  
}

spell2 = {
start2 = function (cid, target, markpos, hits)
    if not isCreature(cid) then return true end
    if not isCreature(target) or hits < 2 then
                 return true
    end    
    posAv = validPos(getThingPos(target))
    rand = #posAv == 1 and 1 or #posAv - 1
   
    doAreaCombatHealth(cid, config.damage, getThingPos(target), 0, -config.mindmg, -config.maxdmg, config.efecto2)
    addEvent(spell2.start2, 100, cid, target, markpos, hits - 1)        
   end
  
}

function onCastSpell(cid)
local position1 = {x=getThingPosition(getCreatureTarget(cid)).x, y=getThingPosition(getCreatureTarget(cid)).y, z=getThingPosition(getCreatureTarget(cid)).z}
local position2 = {x=getCreaturePosition(cid).x, y=getCreaturePosition(cid).y, z=getCreaturePosition(cid).z}
target = getCreatureTarget(cid)
if target then
  spell1.start1(cid, target, getThingPos(cid), config.hits)
doSendMagicEffect(position1, 180)
doSendMagicEffect(position1, 212)
spell2.start2(cid, target, getThingPos(cid), config.hits)



end
return true
end


I am trying to edit position of the different effects with this.

Lua:
local position1 = {x=getThingPosition(getCreatureTarget(cid)).x, y=getThingPosition(getCreatureTarget(cid)).y, z=getThingPosition(getCreatureTarget(cid)).z}
 
Last edited:
Solution
Give this a try. Not tested and I rushed making it.

Lua:
local canUseDistanceEffect = false --You can enable this if your server supports doSendDistanceEffect(pos1, pos2)

local spellHits = {
    [1] = {delay = 0, combat = COMBAT_DEATH_DAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_DEATH},
    [2] = {delay = 1000, combat = COMBAT_DEATH_DAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_DEATH}
}

[[--
delay = time in miliseconds to delay the spell.
combat = The type of damage. (Death, Fire, Poison, ect.)
effect = The effect that will appear under the player when they are damaged.
distanceEffect = The effect that will go from the caster to the target. (like a wand shooting)

--]]

function onCastSpell(cid, var)...
I managed to figure it out how it works but still is showing me the 1st sprite twice and I would like to edit the positions of the effects.
 
Give this a try. Not tested and I rushed making it.

Lua:
local canUseDistanceEffect = false --You can enable this if your server supports doSendDistanceEffect(pos1, pos2)

local spellHits = {
    [1] = {delay = 0, combat = COMBAT_DEATH_DAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_DEATH},
    [2] = {delay = 1000, combat = COMBAT_DEATH_DAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_DEATH}
}

[[--
delay = time in miliseconds to delay the spell.
combat = The type of damage. (Death, Fire, Poison, ect.)
effect = The effect that will appear under the player when they are damaged.
distanceEffect = The effect that will go from the caster to the target. (like a wand shooting)

--]]

function onCastSpell(cid, var)
    local varNumber = variantToNumber(var)
   
    if not varNumber then return false end
   
    local minDmg = -((getPlayerLevel(cid) / 2) * (getPlayerMagLevel(cid) / 10))
    local maxDmg = -((getPlayerLevel(cid) / 1) * (getPlayerMagLevel(cid) / 10))
    local name = getPlayerName(cid)
   
    for i = 1, #spellHits do
        if canUseDistanceEffect then
            local hitAmount = math.floor(math.random(minDmg, maxDmg))
            addEvent(castSpell, spellHits[i].delay, name, varNumber, hitAmount, spellHits[i].combat, spellHits[i].effect, spellHits[i].distanceEffect)
        else
            local hitAmount = math.floor(math.random(minDmg, maxDmg))
            addEvent(castSpell, spellHits[i].delay, name, varNumber, hitAmount, spellHits[i].combat, spellHits[i].effect)
        end
    end
   
    doAreaCombatHealth(cid, )
return true
end

function castSpell(name, targetNumber, damage, combat, effect, distanceEffect)
    local player = getPlayerByNameWildcard(name)
    local targetPos = getThingPos(targetNumber)
   
    if not player then return false end
    if not targetPos then return false end
   
    if distanceEffect then
        doSendDistanceEffect(distanceEffect, getPlayerPosition(player), targetPos)
    end
       
    doAreaCombatHealth(player, combat, targetPos, damage, damage, effect)
return true
end
 
Solution
Looks more confusing but better ill give it a reading cause i cant comprehend yet what to do there xd but seems totally better than the one im using thx for the support though i`ve spent some hours on this still cant figure it out xd

Give this a try. Not tested and I rushed making it.

Code:
local canUseDistanceEffect = false --You can enable this if your server supports doSendDistanceEffect(pos1, pos2)

local spellHits = {
    [1] = {delay = 0, combat = COMBAT_DEATH_DAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_DEATH},
    [2] = {delay = 1000, combat = COMBAT_DEATH_DAMAGE, effect = CONST_ME_POFF, distanceEffect = CONST_ANI_DEATH}
}

[[--
delay = time in miliseconds to delay the spell.
combat = The type of damage. (Death, Fire, Poison, ect.)
effect = The effect that will appear under the player when they are damaged.
distanceEffect = The effect that will go from the caster to the target. (like a wand shooting)

--]]

function onCastSpell(cid, var)
    local varNumber = variantToNumber(var)

    if not varNumber then return false end

    local minDmg = -((getPlayerLevel(cid) / 2) * (getPlayerMagLevel(cid) / 10))
    local maxDmg = -((getPlayerLevel(cid) / 1) * (getPlayerMagLevel(cid) / 10))
    local name = getPlayerName(cid)

    for i = 1, #spellHits do
        if canUseDistanceEffect then
            local hitAmount = math.floor(math.random(minDmg, maxDmg))
            addEvent(castSpell, spellHits[i].delay, name, varNumber, hitAmount, spellHits[i].combat, spellHits[i].effect, spellHits[i].distanceEffect)
        else
            local hitAmount = math.floor(math.random(minDmg, maxDmg))
            addEvent(castSpell, spellHits[i].delay, name, varNumber, hitAmount, spellHits[i].combat, spellHits[i].effect)
        end
    end

    doAreaCombatHealth(cid, )
return true
end

function castSpell(name, targetNumber, damage, combat, effect, distanceEffect)
    local player = getPlayerByNameWildcard(name)
    local targetPos = getThingPos(targetNumber)

    if not player then return false end
    if not targetPos then return false end

    if distanceEffect then
        doSendDistanceEffect(distanceEffect, getPlayerPosition(player), targetPos)
    end
   
    doAreaCombatHealth(player, combat, targetPos, damage, damage, effect)
return true
end
 
Status
Not open for further replies.
Back
Top