Kava4 / PUBG-LOGITECH-NO-RECOIL-SEASON-31

PUBG recoil Script
83 stars 18 forks source link

Simpler recoil code + minor bugfix #10

Open 9382 opened 10 months ago

9382 commented 10 months ago

Not sure why I've landed here, but whatever. The script is still frankly quite a mess of weirdly formatted code but this removes about 9400(!?) lines while keeping identical functionality (and formatting, kinda), so its at least a bit nicer.

I don't own pubg myself so I couldn't actually test if the recoil is properly stopped, but the mouse movement part itself appears to work fine in testing

Also fixes a minor bug where the GROZAA wouldn't have its function defined until after the first OnEvent call happened due to a mis-placed end

Mostly made by using the below lua code on the original text:

local AntiRecoilSection = InputString:sub(InputString:find("THIS IS THE ANTI RECOIL SECTION"), -1)
-- print(AntiRecoilSection)

local function MakeSequence(t)
    local out = "{"
    for _,v in next,t do
        out = out .. "{"..v[1]..","..v[2].."},"
    end
    return out:sub(1, -2) .. "}"
end

local NewVersion = {}
local CurrentStorage = {}
for line in AntiRecoilSection:gmatch("(.-)\n") do
    if line:find("function ") then
        -- new function!
        print("New function", line)
        CurrentStorage = {}
        NewVersion[#NewVersion+1] = line
    elseif line:find("MoveMouseRelative%(0%*mult, 0%)") then
        -- sequence end
        print("Sequence end")
        -- create stuff here
        NewVersion[#NewVersion+1] = "local sequence = " .. MakeSequence(CurrentStorage)
        NewVersion[#NewVersion+1] = "for i = 1, #sequence do"
        NewVersion[#NewVersion+1] = "MoveMouseRelative(sequence[i][1]*mult, sequence[i][2]*mult)"
        NewVersion[#NewVersion+1] = "if i == #sequence then Sleep(1400) elseif i == #sequence-1 then Sleep(100) else Sleep(17) end"
        NewVersion[#NewVersion+1] = "if not IsMouseButtonPressed(1) then break end"
        NewVersion[#NewVersion+1] = "end"

        local changed = line:gsub("MoveMouseRelative%(0%*mult, 0%) ?", "")
        if changed ~= "" then
            NewVersion[#NewVersion+1] = changed
        end
    elseif line:find("%)Sleep%(%d+%) if not IsMouseButtonPressed") then
        -- sequence step
        if not line:match("(%-?%d+)%*mult,  ?(%-?%d+)%*mult") then
            print("DONT LIKE", line)
        end
        CurrentStorage[#CurrentStorage+1] = {line:match("(%-?%d+)%*mult,  ?(%-?%d+)%*mult")}
    else
        NewVersion[#NewVersion+1] = line:gsub("^ *", "")
    end
end

io.open("done.lua", "w+"):write(table.concat(NewVersion, "\n"))
MinhKhanh693 commented 2 weeks ago

@9382 Hey bro, I hold the right mouse to Aim. Is there a way to "Setting" for that?