Advertisement
Zulkin

Funky Friday Autoplay NO GUI [Linoria Lib Bug Fix]

Jan 15th, 2023 (edited)
2,186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.64 KB | None | 0 0
  1. -- Rex. E#0001
  2. -- Removed Linoria Lib because it's tweeking bro fr!
  3. -- This support is so annoyi
  4. local start = tick()
  5. local client = game:GetService('Players').LocalPlayer;
  6. local set_identity = (type(syn) == 'table' and syn.set_thread_identity) or setidentity or setthreadcontext
  7. local executor = identifyexecutor and identifyexecutor() or 'Unknown'
  8. local Autoplayer = true
  9. local AutoClaimRings = true
  10. local AutoPlayerMode = true
  11. local Options = {
  12. SickChance = {Value = 98},
  13. GoodChance = {Value = 2},
  14. OkChance = {Value = 0},
  15. BadChance = {Value = 0},
  16. MissChance = {Value = 0},
  17. PressMode = {Value = "firesignal"},
  18. DelayMode = {Value = "Random"},
  19. ScoreModifier = {Value = "Increase score on miss"},
  20. HeldDelayMin = {Value = 0},
  21. HeldDelayMax = {Value = 20},
  22. NoteDelayMin = {Value = 0},
  23. NoteDelayMax = {Value = 20},
  24. HeldDelay = {Value = 0},
  25. ReleaseDelay = {Value = 20},
  26. }
  27.  
  28. local function fail(r) return client:Kick(r) end
  29.  
  30. -- gracefully handle errors when loading external scripts
  31. -- added a cache to make hot reloading a bit faster
  32. local usedCache = shared.__urlcache and next(shared.__urlcache) ~= nil
  33.  
  34. shared.__urlcache = shared.__urlcache or {}
  35. local function urlLoad(url)
  36.     local success, result
  37.  
  38.     if shared.__urlcache[url] then
  39.         success, result = true, shared.__urlcache[url]
  40.     else
  41.         success, result = pcall(game.HttpGet, game, url)
  42.     end
  43.  
  44.     if (not success) then
  45.         return fail(string.format('Failed to GET url %q for reason: %q', url, tostring(result)))
  46.     end
  47.  
  48.     local fn, err = loadstring(result)
  49.     if (type(fn) ~= 'function') then
  50.         return fail(string.format('Failed to loadstring url %q for reason: %q', url, tostring(err)))
  51.     end
  52.  
  53.     local results = { pcall(fn) }
  54.     if (not results[1]) then
  55.         return fail(string.format('Failed to initialize url %q for reason: %q', url, tostring(results[2])))
  56.     end
  57.  
  58.     shared.__urlcache[url] = result
  59.     return unpack(results, 2)
  60. end
  61.  
  62. -- attempt to block imcompatible exploits
  63. -- rewrote because old checks literally did not work
  64. if type(set_identity) ~= 'function' then return fail('Unsupported exploit (missing "set_thread_identity")') end
  65. if type(getconnections) ~= 'function' then return fail('Unsupported exploit (missing "getconnections")') end
  66. if type(getloadedmodules) ~= 'function' then return fail('Unsupported exploit (misssing "getloadedmodules")') end
  67. if type(getgc) ~= 'function' then   return fail('Unsupported exploit (misssing "getgc")') end
  68.  
  69. local getinfo = debug.getinfo or getinfo;
  70. local getupvalue = debug.getupvalue or getupvalue;
  71. local getupvalues = debug.getupvalues or getupvalues;
  72. local setupvalue = debug.setupvalue or setupvalue;
  73.  
  74. if type(setupvalue) ~= 'function' then return fail('Unsupported exploit (misssing "debug.setupvalue")') end
  75. if type(getupvalue) ~= 'function' then return fail('Unsupported exploit (misssing "debug.getupvalue")') end
  76. if type(getupvalues) ~= 'function' then return fail('Unsupported exploit (missing "debug.getupvalues")') end
  77.  
  78. -- free exploit bandaid fix
  79. if type(getinfo) ~= 'function' then
  80.     local debug_info = debug.info;
  81.     if type(debug_info) ~= 'function' then
  82.         -- if your exploit doesnt have getrenv you have no hope
  83.         if type(getrenv) ~= 'function' then return fail('Unsupported exploit (missing "getrenv")') end
  84.         debug_info = getrenv().debug.info
  85.     end
  86.     getinfo = function(f)
  87.         assert(type(f) == 'function', string.format('Invalid argument #1 to debug.getinfo (expected %s got %s', 'function', type(f)))
  88.         local results = { debug.info(f, 'slnfa') }
  89.         local _, upvalues = pcall(getupvalues, f)
  90.         if type(upvalues) ~= 'table' then
  91.             upvalues = {}
  92.         end
  93.         local nups = 0
  94.         for k in next, upvalues do
  95.             nups = nups + 1
  96.         end
  97.         -- winning code
  98.         return {
  99.             source      = '@' .. results[1],
  100.             short_src   = results[1],
  101.             what        = results[1] == '[C]' and 'C' or 'Lua',
  102.             currentline = results[2],
  103.             name        = results[3],
  104.             func        = results[4],
  105.             numparams   = results[5],
  106.             is_vararg   = results[6], -- 'a' argument returns 2 values :)
  107.             nups        = nups,    
  108.         }
  109.     end
  110. end
  111.  
  112. local httpService = game:GetService('HttpService')
  113.  
  114. local framework, scrollHandler, network
  115. local counter = 0
  116.  
  117. while true do
  118.     for _, obj in next, getgc(true) do
  119.         if type(obj) == 'table' then
  120.             if rawget(obj, 'GameUI') then
  121.                 framework = obj;
  122.             elseif type(rawget(obj, 'Server')) == 'table' then
  123.                 network = obj;    
  124.             end
  125.         end
  126.  
  127.         if network and framework then break end
  128.     end
  129.  
  130.     for _, module in next, getloadedmodules() do
  131.         if module.Name == 'ScrollHandler' then
  132.             scrollHandler = module;
  133.             break;
  134.         end
  135.     end
  136.  
  137.     if (type(framework) == 'table' and typeof(scrollHandler) == 'Instance' and type(network) == 'table') then
  138.         break
  139.     end
  140.  
  141.     counter = counter + 1
  142.     if counter > 6 then
  143.         fail(string.format('Failed to load game dependencies. Details: %s, %s, %s', type(framework), typeof(scrollHandler), type(network)))
  144.     end
  145.     wait(1)
  146. end
  147.  
  148. local runService = game:GetService('RunService')
  149. local userInputService = game:GetService('UserInputService')
  150. local virtualInputManager = game:GetService('VirtualInputManager')
  151.  
  152. local random = Random.new()
  153.  
  154. local task = task or getrenv().task;
  155. local fastWait, fastSpawn = task.wait, task.spawn;
  156.  
  157. -- firesignal implementation
  158. -- hitchance rolling
  159. local fireSignal, rollChance do
  160.     -- updated for script-ware or whatever
  161.     -- attempted to update for krnl
  162.  
  163.     function fireSignal(target, signal, ...)
  164.         -- getconnections with InputBegan / InputEnded does not work without setting Synapse to the game's context level
  165.         set_identity(2)
  166.         local didFire = false
  167.         for _, signal in next, getconnections(signal) do
  168.             if type(signal.Function) == 'function' and islclosure(signal.Function) then
  169.                 local scr = rawget(getfenv(signal.Function), 'script')
  170.                 if scr == target then
  171.                     didFire = true
  172.                     pcall(signal.Function, ...)
  173.                 end
  174.             end
  175.         end
  176.         -- if not didFire then fail"couldnt fire input signal" end
  177.         set_identity(7)
  178.     end
  179.  
  180.     -- uses a weighted random system
  181.     -- its a bit scuffed rn but it works good enough
  182.  
  183.     function rollChance()
  184.         local chances = {
  185.             { 'Sick', Options.SickChance.Value },
  186.             { 'Good', Options.GoodChance.Value },
  187.             { 'Ok', Options.OkChance.Value },
  188.             { 'Bad', Options.BadChance.Value },
  189.             { 'Miss' , Options.MissChance.Value },
  190.         }
  191.  
  192.         table.sort(chances, function(a, b)
  193.             return a[2] > b[2]
  194.         end)
  195.  
  196.         local sum = 0;
  197.         for i = 1, #chances do
  198.             sum += chances[i][2]
  199.         end
  200.  
  201.         if sum == 0 then
  202.             return chances[random:NextInteger(1, #chances)][1]
  203.         end
  204.  
  205.         local initialWeight = random:NextInteger(0, sum)
  206.         local weight = 0;
  207.  
  208.         for i = 1, #chances do
  209.             weight = weight + chances[i][2]
  210.  
  211.             if weight > initialWeight then
  212.                 return chances[i][1]
  213.             end
  214.         end
  215.  
  216.         return 'Sick'
  217.     end
  218. end
  219.  
  220. -- autoplayer
  221. local chanceValues do
  222.     chanceValues = {
  223.         Sick = 98,
  224.         Good = 2,
  225.         Ok = 0,
  226.         Bad = 0,
  227.     }
  228.  
  229.     local keyCodeMap = {}
  230.     for _, enum in next, Enum.KeyCode:GetEnumItems() do
  231.         keyCodeMap[enum.Value] = enum
  232.     end
  233.  
  234.     if shared._unload then
  235.         pcall(shared._unload)
  236.     end
  237.  
  238.     function shared._unload()
  239.         if shared._id then
  240.             pcall(runService.UnbindFromRenderStep, runService, shared._id)
  241.         end
  242.  
  243.         for i = 1, #shared.threads do
  244.             coroutine.close(shared.threads[i])
  245.         end
  246.  
  247.         for i = 1, #shared.callbacks do
  248.             task.spawn(shared.callbacks[i])
  249.         end
  250.     end
  251.  
  252.     shared.threads = {}
  253.     shared.callbacks = {}
  254.  
  255.     shared._id = httpService:GenerateGUID(false)
  256.  
  257.     local function pressKey(keyCode, state)
  258.         if Options.PressMode.Value == 'virtual input' then
  259.             virtualInputManager:SendKeyEvent(state, keyCode, false, nil)
  260.         else
  261.             fireSignal(scrollHandler, userInputService[state and 'InputBegan' or 'InputEnded'], { KeyCode = keyCode, UserInputType = Enum.UserInputType.Keyboard }, false)
  262.         end
  263.     end
  264.  
  265.     local rng = Random.new()
  266.     runService:BindToRenderStep(shared._id, 1, function()
  267.         --if (not library.flags.autoPlayer) then return end
  268.        
  269.         if (not Autoplayer) then
  270.             return
  271.         end
  272.  
  273.         local currentlyPlaying = framework.SongPlayer.CurrentlyPlaying
  274.  
  275.         if typeof(currentlyPlaying) ~= 'Instance' or not currentlyPlaying:IsA('Sound') then
  276.             return
  277.         end
  278.  
  279.         local arrows = framework.UI:GetNotes()
  280.         local count = framework.SongPlayer:GetKeyCount()
  281.         local mode = count .. 'Key'
  282.  
  283.         local arrowData = framework.ArrowData[mode].Arrows
  284.         for i, arrow in next, arrows do
  285.             -- todo: switch to this (https://i.imgur.com/pEVe6Tx.png)
  286.             local ignoredNoteTypes = { Death = true, Mechanic = true, Poison = true }
  287.  
  288.             if type(arrow.NoteDataConfigs) == 'table' then
  289.                 if ignoredNoteTypes[arrow.NoteDataConfigs.Type] then
  290.                     continue
  291.                 end
  292.             end
  293.  
  294.             if (arrow.Side == framework.UI.CurrentSide) and (not arrow.Marked) and currentlyPlaying.TimePosition > 0 then
  295.                 local position = (arrow.Data.Position % count) .. ''
  296.  
  297.                 local hitboxOffset = 0
  298.                 do
  299.                     local settings = framework.Settings;
  300.                     local offset = type(settings) == 'table' and settings.HitboxOffset;
  301.                     local value = type(offset) == 'table' and offset.Value;
  302.  
  303.                     if type(value) == 'number' then
  304.                         hitboxOffset = value;
  305.                     end
  306.  
  307.                     hitboxOffset = hitboxOffset / 1000
  308.                 end
  309.  
  310.                 local songTime = framework.SongPlayer.CurrentTime
  311.                 do
  312.                     local configs = framework.SongPlayer.CurrentSongConfigs
  313.                     local playbackSpeed = type(configs) == 'table' and configs.PlaybackSpeed
  314.  
  315.                     if type(playbackSpeed) ~= 'number' then
  316.                         playbackSpeed = 1
  317.                     end
  318.  
  319.                     songTime = songTime /  playbackSpeed
  320.                 end
  321.  
  322.                 local noteTime = math.clamp((1 - math.abs(arrow.Data.Time - (songTime + hitboxOffset))) * 100, 0, 100)
  323.  
  324.                 local result = rollChance()
  325.                 arrow._hitChance = arrow._hitChance or result;
  326.  
  327.                 local hitChance = (AutoplayerMode == 'Manual' and result or arrow._hitChance)
  328.                 if hitChance ~= "Miss" and noteTime >= chanceValues[arrow._hitChance] then
  329.                     fastSpawn(function()
  330.                         arrow.Marked = true;
  331.                         local keyCode = keyCodeMap[arrowData[position].Keybinds.Keyboard[1]]
  332.  
  333.                         pressKey(keyCode, true)
  334.  
  335.                         local arrowLength = arrow.Data.Length or 0
  336.                         local isHeld = arrowLength > 0
  337.  
  338.                         local delayMode = Options.DelayMode.Value
  339.  
  340.                         local minDelay = isHeld and Options.HeldDelayMin or Options.NoteDelayMin;
  341.                         local maxDelay = isHeld and Options.HeldDelayMax or Options.NoteDelayMax;
  342.                         local noteDelay = isHeld and Options.HeldDelay or Options.ReleaseDelay
  343.  
  344.                         local delay = delayMode == 'Random' and rng:NextNumber(minDelay.Value, maxDelay.Value) or noteDelay.Value
  345.                         task.wait(arrowLength + (delay / 1000))
  346.  
  347.                         pressKey(keyCode, false)
  348.                         arrow.Marked = nil;
  349.                     end)
  350.                 end
  351.             end
  352.         end
  353.     end)
  354. end
  355.  
  356. local ActivateUnlockables do
  357.     -- Note: I know you can do this with UserId but it only works if you run it before opening the notes menu
  358.     -- My script should work no matter the order of which you run things :)
  359.  
  360.     local loadStyle = nil
  361.     local function loadStyleProxy(...)
  362.         -- This forces the styles to reload every time
  363.            
  364.         local upvalues = getupvalues(loadStyle)
  365.         for i, upvalue in next, upvalues do
  366.             if type(upvalue) == 'table' and rawget(upvalue, 'Style') then
  367.                 rawset(upvalue, 'Style', nil);
  368.                 setupvalue(loadStyle, i, upvalue)
  369.             end
  370.         end
  371.  
  372.         return loadStyle(...)
  373.     end
  374.  
  375.     local function applyLoadStyleProxy(...)
  376.         local gc = getgc()
  377.         for i = 1, #gc do
  378.             local obj = gc[i]
  379.             if type(obj) == 'function' then
  380.                 -- goodbye nups numeric loop because script-ware is weird
  381.                 local upvalues = getupvalues(obj)
  382.                 for i, upv in next, upvalues do
  383.                     if type(upv) == 'function' and getinfo(upv).name == 'LoadStyle' then
  384.                         -- ugly but it works, we don't know every name for is_synapse_function and similar
  385.                         local function isGameFunction(fn)
  386.                             return getinfo(fn).source:match('%.ArrowSelector%.Customize$')
  387.                         end
  388.  
  389.                         if isGameFunction(obj) and isGameFunction(upv) then
  390.                             -- avoid non-game functions :)
  391.                             loadStyle = loadStyle or upv
  392.                             setupvalue(obj, i, loadStyleProxy)
  393.  
  394.                             table.insert(shared.callbacks, function()
  395.                                 assert(pcall(setupvalue, obj, i, loadStyle))
  396.                             end)
  397.                         end
  398.                     end
  399.                 end
  400.             end
  401.         end
  402.     end
  403.  
  404.     local success, error = pcall(applyLoadStyleProxy)
  405.     if not success then
  406.         return fail(string.format('Failed to hook LoadStyle function. Error(%q)\nExecutor(%q)\n', error, executor))
  407.     end
  408.  
  409.     function ActivateUnlockables()
  410.         local idx = table.find(framework.SongsWhitelist, client.UserId)
  411.         if idx then return end
  412.  
  413.         table.insert(framework.SongsWhitelist, client.UserId)
  414.     end
  415. end
  416.  
  417. ActivateUnlockables()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement