local config = {
lvlReq = 1,
cooldown = 2000,
combatType = COMBAT_PHYSICALDAMAGE,
magicEffect = CONST_ME_HITAREA,
distEffect = CONST_ANI_ARROW,
dmg = {min = 100, max = 200},
rounds = 10, -- Amount of rounds
delay = 200, -- Delay between rounds
density = 10, -- How dense the area of effect will be (1 = full area)
}
local area = {
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 3, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0}
}
local combat = Combat()
combat:setArea(createCombatArea(area))
function onTargetTile(creature, position)
local fromPos = Position(position.x - 7, position.y - 7, position.z)
if math.random(config.density) == 1 then
fromPos:sendDistanceEffect(position, config.distEffect)
addEvent(function()
local player = Player(creature:getId())
if not player then
return
end
doAreaCombat(player, config.combatType, position, position, -config.dmg.min, -config.dmg.max, config.magicEffect)
end, 400)
end
end
combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
local spell = Spell(SPELL_INSTANT)
function spell.onCastSpell(creature, variant)
for i = 1, config.rounds do
addEvent(function()
local player = Player(creature:getId())
if not player then
return
end
combat:execute(player, variant)
end, config.delay * (i-1))
end
return true
end
spell:name("Rain of Arrows")
spell:words("Rain of Arrows")
spell:id(51)
spell:group("attack")
spell:cooldown(config.cooldown)
spell:groupCooldown(config.cooldown)
spell:isAggressive(true)
spell:needTarget(true)
spell:level(config.lvlReq)
spell:needLearn(true)
spell:vocation("paladin")
spell:register()