Código Lua:
local function applyDamage(creature, damage, damageType)
creature:addHealth(-damage, damageType, true)
end
local function applyEffect(position, effect)
position:sendMagicEffect(effect)
end
local function applyDamageByElement(position, damage, damageType)
local tile = Tile(position)
if tile then
local creatures = tile:getCreatures()
if creatures then
for _, creature in ipairs(creatures) do
if creature:isMonster() then
applyDamage(creature, damage, damageType)
end
end
end
end
end
local function moveEffectToTarget(player, target, position, targetPosition, effect, damage, damageType)
local dx = targetPosition.x - position.x
local dy = targetPosition.y - position.y
local distance = math.max(math.abs(dx), math.abs(dy))
local stepX = dx / distance
local stepY = dy / distance
for i = 0, distance do
local newPosition = Position(position.x + stepX * i, position.y + stepY * i, position.z)
addEvent(function()
applyEffect(newPosition, effect)
applyDamageByElement(newPosition, damage, damageType)
end, 200 * i)
end
end
local function applyScorcherDamage(player)
local target = player:getTarget()
if not target or not target:isMonster() then
player:sendCancelMessage("You can only use this item on monsters.")
return false
end
local position = player:getPosition()
local targetPosition = target:getPosition()
local effects = {
{ effect = 244, minDamage = 1000, maxDamage = 5000, damageType = COMBAT_PHYSICALDAMAGE }
}
local totalEffects = #effects
local totalPositions = totalEffects
local index = 1
for i = 1, totalPositions do
local effectData = effects[index]
local effect = effectData.effect
local minDamage = effectData.minDamage
local maxDamage = effectData.maxDamage
local damageType = effectData.damageType
moveEffectToTarget(player, target, position, targetPosition, effect, math.random(minDamage, maxDamage), damageType)
index = index + 1
if index > totalEffects then
index = 1
end
end
end
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 exori follow ico 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 exori follow ico again.")
return false
end
applyScorcherDamage(creature)
playerCooldowns[playerId] = 5 -- 5 segundos de cooldown para este jugador
return true
end
spell:group("attack")
spell:id(6200)
spell:name("follow knight")
spell:words("exori follow ico")
spell:level(250)
spell:mana(300)
spell:isPremium(true)
spell:range(6)
spell:needTarget(true)
spell:blockWalls(true)
spell:groupCooldown(1 * 1000)
spell:needLearn(false)
spell:vocation("knight;true", "elite knight;true")
spell:register()
Última edición: