-- Configurações da animação local FRAME_DURATION = 100 -- Duração de cada frame em milissegundos local ANIMATION_FRAMES = { 73, -- Frame (substitua pelos IDs corretos das outfits) 74, -- Frame 75, -- Frame 76, -- Frame 77, -- Frame 78, 45 -- Frame } -- Configurações do item temporário local tempItemId = 9078 -- ID do item temporário local tempItemDuration = 600 -- Tempo que o item fica no chão (230ms) -- Função que troca a outfit frame por frame local function changeOutfit(cid, originalOutfit, currentFrame) local creature = Player(cid) if not creature or not creature:isPlayer() then return end if currentFrame <= #ANIMATION_FRAMES then local newOutfit = { lookType = ANIMATION_FRAMES[currentFrame], lookHead = originalOutfit.lookHead, lookBody = originalOutfit.lookBody, lookLegs = originalOutfit.lookLegs, lookFeet = originalOutfit.lookFeet, lookAddons = originalOutfit.lookAddons, lookMount = originalOutfit.lookMount } creature:setOutfit(newOutfit) -- Agenda o próximo frame da animação addEvent(changeOutfit, FRAME_DURATION, cid, originalOutfit, currentFrame + 1) end -- A restauração da outfit original será feita somente ao sair da magia. end -- Funções do efeito mágico local function targetEffect(cid) local player = Player(cid) if not player then return end local effect = 237 -- Efeito elétrico azul local orig = player:getPosition() local d1, d2 = {z = orig.z}, {z = orig.z} d1.x = orig.x - 5 d2.x = orig.x + 5 for i = -2, 2 do d1.y = orig.y + i d2.y = d1.y orig:sendDistanceEffect(d1, effect) orig:sendDistanceEffect(d2, effect) end d1.y = orig.y - 3 d2.y = orig.y + 3 for i = -4, 4 do d1.x = orig.x + i d2.x = d1.x orig:sendDistanceEffect(d1, effect) orig:sendDistanceEffect(d2, effect) end end -- Função que retorna o jogador para a posição original, desativa ghost mode e restaura a outfit original local function backOldPosition(cid, oldPosition, originalOutfit) local player = Player(cid) if not player then return end player:teleportTo(oldPosition) player:setGhostMode(false) player:setOutfit(originalOutfit) -- Removido: player:setMovementBlocked(false) end local function jumpEffect(cid, target) local player = Player(cid) if not player then return end local targetCreature = Creature(target) if targetCreature then player:getPosition():sendDistanceEffect(targetCreature:getPosition(), 237) end end local function extractRandomValuesFromTable(tbl) if #tbl == 0 then return false end return table.remove(tbl, math.random(#tbl)) end -- Modificada para receber originalOutfit e exibir o effect 237 enquanto pula, -- além de criar e remover o item temporário no alvo atingido. local function jumpOnTarget(cid, target, targetCount, oldPosition, originalOutfit) local player = Player(cid) if not player then return end local targetCreature = Creature(target) if targetCreature then addEvent(targetEffect, 100, cid) player:teleportTo(targetCreature:getPosition()) player:setGhostMode(true) -- Exibe o effect 237 enquanto pula para o novo alvo player:getPosition():sendMagicEffect(237) targetCreature:getPosition():sendMagicEffect(237) doTargetCombatHealth(cid, targetCreature, COMBAT_ENERGYDAMAGE, -50, -150, CONST_ME_ENERGYHIT) -- Cria o item temporário no local do alvo atingido e agenda sua remoção local tempItem = Game.createItem(tempItemId, 1, targetCreature:getPosition()) if tempItem then addEvent(function(pos) local tile = Tile(pos) if tile then local item = tile:getItemById(tempItemId) if item then item:remove() end end end, tempItemDuration, targetCreature:getPosition()) end if targetCount == 0 then addEvent(backOldPosition, 400, cid, oldPosition, originalOutfit) end end end -- Função principal do feitiço function onCastSpell(creature, var) local cid = creature:getId() local originalPos = creature:getPosition() local originalOutfit = creature:getOutfit() -- Removida: Bloqueia o movimento do jogador enquanto durar a magia -- creature:setMovementBlocked(true) -- Ajusta o eixo para o efeito 192 antes da animação (exemplo, ajuste conforme necessário) local pos = creature:getPosition() pos.x = pos.x + 1 pos.y = pos.y pos:sendMagicEffect(191) -- Inicia a animação de troca de outfit frame por frame changeOutfit(cid, originalOutfit, 1) -- Agenda a execução do feitiço após o término da animação addEvent(function() local targets = {} local playerPos = creature:getPosition() -- Efeitos ao ativar a magia playerPos:sendMagicEffect(236) -- Obtém os espectadores dentro de um raio de 5x5 local spectators = Game.getSpectators(playerPos, false, false, 5, 5, 5, 5) for i = 1, #spectators do local specs = spectators[i] if specs ~= creature and not specs:isNpc() and playerPos:getDistance(specs:getPosition()) <= 5 then targets[#targets + 1] = specs end end if #targets == 0 then creature:sendCancelMessage('There are no targets in range (5x5).') playerPos:sendMagicEffect(CONST_ME_POFF) -- Removida: creature:setMovementBlocked(false) return false end local targetCount = #targets for i = 1, #targets do local randTarget = extractRandomValuesFromTable(targets) addEvent(jumpOnTarget, i * 200, cid, randTarget:getId(), targetCount - i, originalPos, originalOutfit) addEvent(jumpEffect, i * 400, cid, randTarget:getId()) end end, (#ANIMATION_FRAMES + 1) * FRAME_DURATION) playSound(creature, "energy.ogg") return false end