local combat = Combat() combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) combat:setParameter(COMBAT_PARAM_EFFECT, 1) -- Configura��es do cr�tico local criticalChance = 50 -- Chance de cr�tico em % local criticalMultiplier = 2.5 -- Multiplicador do dano cr�tico local isCritical = false -- Vari�vel para rastrear se ser� cr�tico -- Fun��o para definir os valores do dano function onGetFormulaValues(player, level, magicLevel) local min = 50 local max = 100 -- Se for cr�tico, aplica o multiplicador if isCritical then min = min * criticalMultiplier max = max * criticalMultiplier player:say("Cr�tico!", TALKTYPE_MONSTER_SAY) -- Mensagem indicando dano cr�tico end return -min, -max end combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues") -- Efeitos visuais para diferentes dire��es local effects = { [NORTH] = 110, [EAST] = 106, [SOUTH] = 104, [WEST] = 109 } -- Fun��o para aplicar dano nas 3 SQMs horizontais na frente do conjurador local function applyDamage(creature, startPos, distance) local dir = creature:getDirection() local currentPos = startPos local targetFound = false -- Itera sobre a �rea de dano for i = 0, distance - 1 do addEvent(function() if not creature or creature:isRemoved() then return end for offset = -1, 1 do local tilePos if dir == NORTH then tilePos = Position(currentPos.x + offset, currentPos.y - 1, currentPos.z) elseif dir == SOUTH then tilePos = Position(currentPos.x + offset, currentPos.y + 1, currentPos.z) elseif dir == EAST then tilePos = Position(currentPos.x + 1, currentPos.y + offset, currentPos.z) elseif dir == WEST then tilePos = Position(currentPos.x - 1, currentPos.y + offset, currentPos.z) end local tile = Tile(tilePos) if tile then local target = tile:getTopCreature() if target and (target:isMonster() or target:isPlayer()) and target:getId() ~= creature:getId() then targetFound = true -- Aplica o efeito 173 se for cr�tico if isCritical then target:getPosition():sendMagicEffect(173) end combat:execute(creature, Variant(target:getPosition())) end end end -- Move para a pr�xima posi��o de dano if dir == NORTH then currentPos.y = currentPos.y - 1 elseif dir == SOUTH then currentPos.y = currentPos.y + 1 elseif dir == EAST then currentPos.x = currentPos.x + 1 elseif dir == WEST then currentPos.x = currentPos.x - 1 end end, i * 100) end -- Se n�o encontrar nenhum alvo, usa a sequ�ncia 51, 52, 53 addEvent(function() if not targetFound then creature:setStorageValue(99917, 0) end end, distance * 100) end -- Fun��o para mostrar os efeitos visuais local function showEffectInFront(creature) local dir = creature:getDirection() local pos = creature:getPosition() pos.x = pos.x + 1 pos.y = pos.y + 1 local effect = effects[dir] or CONST_ME_ENERGYAREA pos:sendMagicEffect(effect) end -- Fun��o principal para lan�ar a magia function onCastSpell(creature, var) local waittime = 0 local storage = 99916 if creature:getStorageValue(storage) > os.time() then creature:sendCancelMessage("Voc� s� pode usar esta magia novamente em [" .. (creature:getStorageValue(storage) - os.time()) .. "] segundos.") return false end creature:setStorageValue(storage, os.time() + waittime) local originalOutfit = creature:getOutfit() -- Calcula se ser� um ataque cr�tico antes de lan�ar a magia isCritical = math.random(1, 100) <= criticalChance -- Define a sequ�ncia de outfits com base no cr�tico local outfits if isCritical then outfits = {{lookType = 70}, {lookType = 71}, {lookType = 72}} -- Sequ�ncia de cr�tico else outfits = {{lookType = 51}, {lookType = 52}, {lookType = 53}} -- Sequ�ncia padr�o end -- Troca o lookType durante a execu��o da magia for i = 1, #outfits do addEvent(function() if creature and not creature:isRemoved() then creature:setOutfit(outfits[i]) end end, (i - 1) * 80) end -- Executa os efeitos visuais e o dano ap�s 500ms addEvent(function() if not creature or creature:isRemoved() then return end playSound(creature, "rat_attack.ogg") local startPos = creature:getPosition() local distance = 1 showEffectInFront(creature) applyDamage(creature, startPos, distance) end, 200) -- Restaura o outfit original ap�s o t�rmino da magia addEvent(function() if creature and not creature:isRemoved() then creature:setOutfit(originalOutfit) end end, (#outfits * 80) + 100) return false end