I did this spell, but i don't know how decrease damage for each iteration
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
function onGetFormulaValues(cid, level, maglevel)
local levelTotal = level / 5
local min = levelTotal + (maglevel * 8)
local max = levelTotal + (maglevel * 12)
return -min, -max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local function choose(...)
local arg = {...}
return arg[math.random(1,#arg)]
end
local function check_pos(fromPos, toPos)
x = fromPos.x - toPos.x
y = fromPos.y - toPos.y
if (x == -1) and (y == -1) then
return choose({-1, -1}, {-1, 0}, {0, -1})
elseif (x == 0) and (y == -1) then
return choose({-1, -1}, {0, -1}, {1, -1})
elseif (x == 1) and (y == -1) then
return choose({0, -1}, {1, -1}, {1, 0})
elseif (x == -1) and (y == 0) then
return choose({-1, -1}, {-1, 0}, {-1, 1})
elseif (x == 1) and (y == 0) then
return choose({1, -1}, {1, 0}, {1, 1})
elseif (x == -1) and (y == 1) then
return choose({-1, 0}, {-1, 1}, {0, 1})
elseif (x == 0) and (y == 1) then
return choose({-1, 1}, {0, 1}, {1, 1})
elseif (x == 1) and (y == 1) then
return choose({0, 1}, {1, 0}, {1, 1})
else
return choose({-1, -1}, {-1, 0}, {0, -1}, {-1, -1}, {0, -1}, {1, -1}, {0, -1}, {1, -1}, {1, 0}, {-1, -1}, {-1, 0}, {-1, 1}, {1, -1}, {1, 0}, {1, 1}, {-1, 0}, {-1, 1}, {0, 1}, {-1, 1}, {0, 1}, {1, 1}, {0, 1}, {1, 0}, {1, 1})
end
end
local function distEffect(cid)
player_pos = getCreaturePosition(cid)
target_pos = getCreaturePosition(getCreatureTarget(cid))
var = check_pos(player_pos, target_pos)
start_pos = {x = player_pos.x+var[1], y = player_pos.y+var[2], z = player_pos.z}
final_pos = target_pos
doSendDistanceShoot(start_pos, final_pos, 28)
end
function onCastSpell(cid, var)
max_atk = math.floor(getPlayerMagLevel(cid) / 25)
for i = 1, max_atk do
addEvent(function()
if isCreature(getCreatureTarget(cid)) then
distEffect(cid)
doCombat(cid, combat, var)
end
end, i * 100)
end
return true
end