Código Lua:
local spell = Spell("instant")
local MAX_SUMMONS = 2 -- Límite máximo de summons por jugador
-- 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 tame 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 tame again.")
return false
end
local duration = 5 -- Duración en segundos
local effectId = 219 -- ID del efecto mágico (puedes personalizarlo)
local radius = 2 -- Radio del círculo alrededor del jugador
local interval = 200 -- Intervalo de tiempo entre los efectos en milisegundos
local angle = 0 -- Ángulo inicial
local summonChance = 10 -- Probabilidad en porcentaje de transformar a un monstruo en summon
local function moveEffect()
if duration > 0 then
local playerPosition = getCreaturePosition(playerId) -- Obtén la posición actual del jugador
-- Calcula las coordenadas en función del ángulo
local offsetX = math.cos(angle) * radius
local offsetY = math.sin(angle) * radius
local effectPosition = {
x = playerPosition.x + offsetX,
y = playerPosition.y + offsetY,
z = playerPosition.z
}
-- Verifica si hay un monstruo en la posición del efecto
local tile = Tile(effectPosition)
if tile then
local creatures = tile:getCreatures()
if creatures then
local playerSummons = 0 -- Contador de summons del jugador
for _, creature in ipairs(creatures) do
if isCreature(creature) and isMonster(creature) then
-- Verifica si el jugador ya es "master" de este summon
if creature:getMaster() ~= playerId then
-- Genera un número aleatorio entre 1 y 100
local randomNum = math.random(1, 100)
-- Si el número aleatorio está dentro del rango de probabilidad, transforma al monstruo en un summon
if randomNum <= summonChance then
if playerSummons < MAX_SUMMONS then
-- Transforma al monstruo en un summon del jugador durante 10 segundos
creature:setMaster(playerId)
addEvent(function()
if isCreature(creature) then
-- Elimina al jugador como "master" del summon después de 10 segundos
creature:setMaster(0) -- 0 para que vuelva a ser salvaje
end
end, 10 * 1000)
playerSummons = playerSummons + 1
end
end
end
end
end
end
end
doSendMagicEffect(effectPosition, effectId)
duration = duration - (interval / 1000) -- Actualiza la duración
angle = angle + math.rad(50) -- Aumenta el ángulo para mover el efecto
addEvent(moveEffect, interval)
end
end
moveEffect() -- Inicia el movimiento del efecto
playerCooldowns[playerId] = 5 -- 5 segundos de cooldown para este jugador
return true
end
spell:group("attack")
spell:id(247)
spell:name("Summoner's Control")
spell:words("exevo tame")
spell:level(300)
spell:mana(800)
spell:isPremium(true)
spell:groupCooldown(1 * 1000)
spell:needLearn(false)
spell:vocation("druid;true", "elder druid;true")
spell:register()