SCRIPT DE STACK WASD


Teclas Para Uso: CTRL + WASD


 local Stack = {}

Stack.northPattern = [[
    11111
    11111
    11111
    11111
    11111
    11111
    11111
    11111
    00000
    00000
    00000
    00000
    00000
    00000
    00000
    00000
    00000
]];

Stack.southPattern = [[
    00000
    00000
    00000
    00000
    00000
    00000
    00000
    00000
    00000
    11111
    11111
    11111
    11111
    11111
    11111
    11111
    11111
]];

Stack.westPattern = [[
    1111111110000000000
    1111111110000000000
    1111111110000000000
    1111111110000000000
    1111111110000000000
]];

Stack.eastPattern = [[
    0000000000111111111
    0000000000111111111
    0000000000111111111
    0000000000111111111
    0000000000111111111
]];

local spell = "flash rasengan";
local maxDistance = 8;


Stack.icon = addIcon("Stack",  {item=816, text="Stack"}, macro(1, function() 
    local furthestMonster = nil;
    local pattern = nil;
    if (modules.corelib.g_keyboard.areKeysPressed("Ctrl+W")) then
        pattern = Stack.northPattern;
    elseif (modules.corelib.g_keyboard.areKeysPressed("Ctrl+S")) then
        pattern = Stack.southPattern;
    elseif (modules.corelib.g_keyboard.areKeysPressed("Ctrl+A")) then
        pattern = Stack.westPattern;
    elseif (modules.corelib.g_keyboard.areKeysPressed("Ctrl+D")) then
        pattern = Stack.eastPattern;
    end

    if (not pattern) then return; end

    local playerPos = pos();
    for _, creature in pairs(getSpectators(playerPos, pattern)) do
        if (not creature:isNpc() and creature:canShoot() and not creature:isPlayer()) then
            local monsterDistance = getDistanceBetween(playerPos, creature:getPosition())
            if (monsterDistance <= maxDistance and
                (
                    furthestMonster == nil or
                    monsterDistance > getDistanceBetween(playerPos, furthestMonster:getPosition())
                )
            ) then
                furthestMonster = creature;
            end
        end
    end

    if (not furthestMonster) then return; end

    keepTarget.isStacking = true
    g_game.stop();
    g_game.attack(furthestMonster);

    say(spell);
    
    schedule(600, function()
        keepTarget.isStacking = false;
        g_game.cancelAttack();
    end);
    delay(600); 
end));








1. Definindo o Feitiço e Distância Máxima


local spell = "flash rasengan"; local maxDistance = 8;
  • Explicação: O feitiço a ser lançado é definido como "flash rasengan". O valor maxDistance define a distância máxima até a qual os monstros podem ser atacados. Ou seja, o monstro deve estar dentro de 8 células de distância do jogador para ser considerado.

2. Criando o Ícone no Jogo





Stack.icon = addIcon("Stack", {item=816, text="Stack"}, macro(1, function()
  • Explicação: Um ícone é adicionado à interface do jogo (provavelmente no menu de habilidades ou hotbar) com o nome "Stack". Quando o ícone é clicado, o código abaixo é executado.



3. Detecção da Tecla Pressionada

Dentro da função associada ao ícone, o script verifica se o jogador pressionou uma combinação de teclas para determinar a direção do padrão:


if (modules.corelib.g_keyboard.areKeysPressed("Ctrl+W")) then pattern = Stack.northPattern; elseif (modules.corelib.g_keyboard.areKeysPressed("Ctrl+S")) then pattern = Stack.southPattern; elseif (modules.corelib.g_keyboard.areKeysPressed("Ctrl+A")) then pattern = Stack.westPattern; elseif (modules.corelib.g_keyboard.areKeysPressed("Ctrl+D")) then pattern = Stack.eastPattern; end
  • Explicação: Dependendo da tecla pressionada (Ctrl+W, Ctrl+S, Ctrl+A ou Ctrl+D), o script seleciona o padrão de direção correspondente (northPattern, southPattern, westPattern, eastPattern).

Comentários