Código Lua:
local spell = Spell("instant")
-- Tabla para almacenar los tiempos de reutilización de los jugadores
local playerCooldowns = {}
-- Función para actualizar los cooldowns de los jugadores
local function updateCooldowns()
for playerId, cooldown in pairs(playerCooldowns) do
if cooldown > 0 then
cooldown = cooldown - 1
playerCooldowns[playerId] = cooldown
-- Obtener al jugador por su ID
local player = Player(playerId)
if player then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Wait " .. cooldown .. " seconds before using exevo divine burst again.")
end
end
end
addEvent(updateCooldowns, 1000) -- Espera 1 segundo antes de actualizar nuevamente
end
-- Iniciar la función para descuento de cooldowns
updateCooldowns()
-- Modifica la función spell.onCastSpell para aplicar el cooldown
function spell.onCastSpell(creature, variant)
local playerId = creature:getId()
if playerCooldowns[playerId] and playerCooldowns[playerId] > 0 then
local player = Player(creature)
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Wait " .. playerCooldowns[playerId] .. " seconds before using exevo divine burst again.")
return false
end
local target = creature:getTarget()
if not target or not target:isCreature() then
creature:sendCancelMessage("You must select a valid target.")
return false
end
local playerPos = creature:getPosition()
local targetPos = target:getPosition()
local options = {
rangeX = 4,
rangeY = 4,
radius = 90,
effectID = 49,
delay = 100,
pattern = {
{40, 49, 40, 49, 49, 49, 40, 49, 40, 40, 49, 40},
{40, 49, 40, 40, 49, 40, 40, 49, 40, 49, 49, 40},
{40, 49, 40, 49, 49, 49, 40, 49, 40, 40, 49, 40},
{40, 49, 40, 40, 49, 40, 40, 49, 40, 49, 49, 40},
{40, 49, 40, 49, 49, 49, 40, 49, 40, 40, 49, 40},
{40, 49, 40, 40, 49, 40, 40, 49, 40, 49, 49, 40},
{40, 49, 40, 49, 49, 49, 40, 49, 40, 40, 49, 40},
{40, 49, 40, 40, 49, 40, 40, 49, 40, 49, 49, 40},
}
}
-- Variables locales para las opciones configurables
local rangeX = options.rangeX or 5
local rangeY = options.rangeY or 5
local radius = options.radius or 3
local effectID = options.effectID or 50
local delay = options.delay or 100
local pattern = options.pattern or {} -- Matriz bidimensional para el patrón
if playerPos and targetPos then
playerPos:sendDistanceEffect(targetPos, 31)
local function sendEffectToPosition(pos, effect)
pos:sendMagicEffect(effect)
end
local playerLevel = creature:getLevel()
local minDamage = playerLevel * 0.50 -- Ajusta el multiplicador para el daño mínimo
local maxDamage = playerLevel * 0.70 -- Ajusta el multiplicador para el daño máximo
local damage = math.random(minDamage, maxDamage) -- Daño aleatorio dentro del rango
-- Aplicar el daño al objetivo
target:addHealth(-damage, COMBAT_HOLYDAMAGE)
for i = -rangeX, rangeX do
for j = -rangeY, rangeY do
local x = i + rangeX + 1
local y = j + rangeY + 1
local patternEffect = pattern[y] and pattern[y][x]
if patternEffect then
local newPos = Position(targetPos.x + i, targetPos.y + j, targetPos.z)
addEvent(function()
local creatures = Game.getSpectators(newPos, false, false, -1, 1, 1, 1)
for _, creature in ipairs(creatures) do
if creature:isCreature() then
creature:addHealth(-damage, COMBAT_HOLYDAMAGE)
end
end
sendEffectToPosition(newPos, patternEffect)
end, (i * j * delay))
else
local newPos = Position(targetPos.x + i, targetPos.y + j, targetPos.z)
addEvent(sendEffectToPosition, (i * j * delay), newPos, effectID) -- Aplicar efecto predeterminado
end
end
end
-- Aplicar el radio de efecto al enemigo seleccionado
for k = 1, radius do
targetPos:sendMagicEffect(effectID)
end
playerCooldowns[playerId] = 5 -- 5 segundos de cooldown para este jugador
return true
else
creature:sendCancelMessage("The target is out of range.")
return false
end
end
spell:group("attack")
spell:id(249)
spell:name("divine burst")
spell:words("exevo divine burst")
spell:level(300)
spell:mana(400)
spell:isPremium(true)
spell:groupCooldown(1 * 1000)
spell:needLearn(false)
spell:vocation("paladin;true", "royal paladin;true")
spell:register()