Vê se isso aí dá certo, fiz de cabeça e não tenho como testar no trabalho
local arrow_storm = {
[2544] = {
[0] = COMBAT_PHYSICALDAMAGE, -- Tipo de dano
[1] = CONST_ME_HITAREA, -- Efeito de área
[2] = CONST_ANI_ARROW, -- Efeito do tiro da flecha
[3] = 2, -- Área de alcance dos danos
[4] = {-1.3, -1.5, -30, -45, 5, 5, 2, 3}, -- Fórmula
},
}
local storage = {78881, 78882}
function onCastSpell(cid, var)
local arrow = getPlayerSlotItem(cid, CONST_SLOT_AMMO)
if not arrow then
doPlayerSendCancel(cid, "You need to equip an arrow type in ammo slot.")
return false
end
if not arrow_storm[arrow.itemid] then
doPlayerSendCancel(cid, "Sorry, you can't use Arrow Storm with this arrow.")
return false
end
local tmp = arrow_storm[arrow.itemid]
local isShooting = true
doCreatureSetStorage(cid, storage[1], os.time() + 2)
while isShooting do
local fromPosition = getCreaturePosition(cid)
local toPosition = fromPosition
toPosition.y = toPosition.y - 8
addEvent(doSendDistanceShoot, 55, fromPosition, toPosition, tmp[2])
if os.time() > getCreatureStorage(cid, storage[1]) then
isShooting = false
end
end
if isShooting == false then
local fallingArrows = true
doCreatureSetStorage(cid, storage[2], os.time() + 2)
while fallingArrows do
local playerPosition = getCreaturePosition(cid)
local toPosition = {x = math.random(playerPosition.x - tmp[3], playerPosition.x + tmp[3]), y = math.random(playerPosition.y - tmp[3], playerPosition.y + tmp[3]), z = playerPosition.z}
local fromPosition = toPosition
fromPosition.y = fromPosition.y - 8
local level = getPlayerLevel(cid)
local skill = getPlayerSkillLevel(cid, SKILL_DISTANCE)
local min = (level / tmp[4][5] + skill * tmp[4][7]) * tmp[4][1] + tmp[4][3]
local max = (level / tmp[4][6] + skill * tmp[4][8]) * tmp[4][2] + tmp[4][4]
doSendDistanceShoot(fromPosition, toPosition, tmp[2]
addEvent(doAreaCombatHealth, 55, cid, tmp[0], toPosition, 0, min, max, tmp[1])
if os.time() > getCreatureStorage(cid, storage[2]) then
fallingArrows = false
end
end
end
return true
end