local Players = game:GetService("Players") local UIS = game:GetService("UserInputService") local PFS = game:GetService("PathfindingService") local VIM = game:GetService("VirtualInputManager") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local env = getgenv and getgenv() or _G local previousBot = env.PillarChaseBot or env.PercyAuto if previousBot and previousBot.Stop then previousBot.Stop() end local config = { ProfileMode = env.PillarBotProfile or "Auto", ActiveProfile = "Generic", DetectedProfile = nil, AbilityScanInterval = 1, AbilitySelectionDelay = 0.2, AbilityGap = 1.1, AbilityFailedRetry = 2, AntiLoop = true, ChaseSampleInterval = 0.4, ChaseHistorySeconds = 10, ChaseProgressTimeout = 6, ChaseCutoffSeconds = 3, BrutumLeapWindup = 0.9, BrutumLeapPitchMin = 12, BrutumLeapPitchMax = 30, AutoAgentSize = true, NormalJumping = true, JumpRetryInterval = 0.9, BackgroundMode = true, BackgroundCameraAim = true, BackgroundCameraResponse = 10, IncludeNPCs = true, AutoDetectBlockDummies = true, MinionNameFragments = {"minion", "roachi", "lanki", "bruti", "opti", "tamaterror", "tamapercy", "palpercy"}, PracticeDummyNames = { dummy = true, trainingdummy = true, practicedummy = true, testdummy = true, }, RespectTeams = true, TargetRadius = 2500, TargetLockSeconds = 1.5, SwitchDistanceRatio = 0.7, PredictionSeconds = 0.3, MaxPrediction = 6, AttackRange = 7, StopDistance = 2.5, SprintDuringChase = true, RepathInterval = 0.55, MaxPathAge = 1.6, RepathTargetMovement = 5, PathTimeout = 3, AgentRadius = 2, AgentHeight = 6, WaypointReach = 2, MaxDirectDistance = 26, AttackInterval = 0.8, TurboInterval = 18, TogetherInterval = 12, WireInterval = 7, TurboMode = "Minions", TurboSelectionDelay = 0.2, MouseGain = 0.3, MouseMaxStep = 24, MouseDeadzone = 2, MousePixelsPerRadian = 350, TurboMinDistance = 15, TogetherMaxDistance = 18, WireMaxDistance = 12, TrapTriggerRange = 6, TrapActivationInterval = 1.5, TrapMinSpacing = 10, TrapPlacementRange = 30, TrapPlacementLifetime = 20, TrapConfirmWindow = 3, TrapMaxCount = 2, MinionCoordination = true, Containment = true, ContainmentScanInterval = 0.6, ContainmentSideProbe = 8, ContainmentMaxWidth = 12, ContainmentPlanLifetime = 2, } local abilityProfiles = { Generic = {AttackInterval = 0.8, Abilities = {}}, PalPercy = {AttackInterval = 0.8, Abilities = { {Name="Turbo Time", Cooldown=18}, {Name="Together Forever", Cooldown=12}, {Name="Wire Terror", Cooldown=7}, }}, Vapor = {AttackInterval = 1, Abilities = { {Name="Scorching Grip", Cooldown=18, Min=5, Max=24, Hold=0.8}, {Name="Blazing Cage", Cooldown=18, Max=22}, {Name="Demonic Shift", Cooldown=4, Min=18, Max=100, Confirm=0}, }}, Rosemary = {AttackInterval = 0.7, Abilities = { {Name="Demonic Essence", Cooldown=28, Max=30}, {Name="Demonic Shriek", Cooldown=12, Min=5, Max=60, Recast=0.15}, {Name="Soul Traversal", Cooldown=14, Max=9, Recast=0.8}, }}, Valem = {AttackInterval = 1.7, Abilities = { {Name="Execution", Cooldown=2, Min=5, Max=18}, {Name="Truth Bind", Cooldown=12, Max=24, Recast=2}, {Name="Trickery", Cooldown=8, Min=8, Max=80}, {Name="Demonic Warp", Cooldown=10, Min=12, Max=70}, }}, AoOni = {AttackInterval = 1.3, Abilities = { {Name="Infestation", Cooldown=2, Min=6, Max=60}, {Name="Brute Strength", Cooldown=10, Min=7, Max=40, Confirm=0}, {Name="Oni Vision", Cooldown=3, Min=9, Max=150}, }}, Fogborn = {AttackInterval = 0.9, Abilities = { {Name="Paralyzing Gaze", Cooldown=15, Max=40}, {Name="Staticbiosis", Cooldown=12, Min=14, Max=70, Recast=0.2}, {Name="Stalking Stance", Cooldown=3, Min=8, Max=24, Recast=1}, }}, Agatha = {AttackInterval = 1, Abilities = { {Name="Childish Rage", Cooldown=20, Max=50}, {Name="You're It", Aliases={"Youre It"}, Cooldown=12, Min=6, Max=24}, {Name="Peekaboo", Cooldown=17, Min=8, Max=35, Recast=0.8}, {Name="Telekinesis", Cooldown=7, Max=25, Confirm=0}, }}, Brutum = {AttackInterval = 0.85, Abilities = { {Name="Goliathan Leap", Cooldown=12, Min=4, Max=45, AimLeap=true}, {Name="Charging Demise", Cooldown=10, Min=8, Max=35, Recast=0.8}, {Name="Crumbling Route", Cooldown=14, Min=8, Max=40, Confirm=0}, }}, } local profileOrder = {"Auto", "Generic", "Vapor", "Rosemary", "Valem", "AoOni", "Fogborn", "Agatha", "Brutum", "PalPercy"} local abilityRoles = { ["Scorching Grip"]="Mobility", ["Blazing Cage"]="Control", ["Demonic Shift"]="Mobility", ["Demonic Essence"]="Buff", ["Demonic Shriek"]="Control", ["Soul Traversal"]="Control", ["Execution"]="Mobility", ["Truth Bind"]="Control", ["Trickery"]="Control", ["Demonic Warp"]="Mobility", ["Infestation"]="Control", ["Brute Strength"]="Control", ["Oni Vision"]="Buff", ["Paralyzing Gaze"]="Control", ["Staticbiosis"]="Mobility", ["Stalking Stance"]="Mobility", ["Childish Rage"]="Buff", ["You're It"]="Mobility", ["Peekaboo"]="Control", ["Telekinesis"]="Control", ["Goliathan Leap"]="Mobility", ["Charging Demise"]="Mobility", ["Crumbling Route"]="Control", ["Turbo Time"]="Buff", ["Together Forever"]="Control", ["Wire Terror"]="Control", } local profileAliases = {vapor="Vapor", rosemary="Rosemary", valem="Valem", aooni="AoOni", fogborn="Fogborn", thefogborn="Fogborn", agatha="Agatha", brutum="Brutum", palpercy="PalPercy", tamapercy="PalPercy"} local state = { Enabled = false, Running = true, Sprinting = false, Generation = 0, InputMode = "Auto", Testing = false, Focused = false, MouseAim = true, } if type(isrbxactive) == "function" then local ok, active = pcall(isrbxactive) if ok then state.Focused = active == true end end env.PercyAuto = state env.PillarChaseBot = state local connection local extraConnections = {} local gui local panel local finishGuiDrag local mouseAimButton local mouseAimStatus = "waiting for target" local nativeMouseMove = mousemoverel local virtualMouse local triedVirtualMouse = false local nextMouseUpdate = 0 local backgroundCamera local statusLabel local toggleButton local profileButton local abilityKeyBox local profileCharacter local cachedNPCs = {} local markedDummies = {} local nextNPCScan = 0 local route = {} local routeIndex = 1 local computing = false local nextPath = 0 local currentTarget local last = {} local hudBindings, nextAbilityScan = {}, 0 local abilityStatus = "scanning HUD" local pendingAbilityRecast local leapAim local abilityMemory = {} local chaseMemory = {} local actionBusy, actionSerial = false, 0 local combatStatus = "ready" local combatRetryAt = 0 local movementRetryAt = 0 local trapCache, nextTrapScan = {}, 0 local activatedTraps = setmetatable({}, {__mode = "k"}) local trapPlacements = {} local seenTrapObjects = {} local trapStatus = "waiting for wire piles" local trapDecision = "waiting for target" local trapFCount, trapCCount = 0, 0 local alliedMinions, nextMinionScan = {}, 0 local containmentGoal local nextContainmentScan = 0 local targetChosenAt = 0 local eligiblePlayerCount = 0 local playerObservations = setmetatable({}, {__mode = "k"}) local targetCooldowns = setmetatable({}, {__mode = "k"}) local nav = {Path = nil, Blocked = nil, Serial = 0, LastGoal = nil, BuiltAt = 0, Force = true, Status = "idle", Stalls = 0, Failures = 0, RecoveryGoal = nil, RecoveryUntil = 0} local nativeDown = keypress local nativeUp = keyrelease local nativeM1 = mouse1click local nativeM2 = mouse2click local virtualKeys = { [Enum.KeyCode.Space] = 0x20, [Enum.KeyCode.LeftShift] = 0xA0, [Enum.KeyCode.Q] = 0x51, [Enum.KeyCode.F] = 0x46, [Enum.KeyCode.C] = 0x43, [Enum.KeyCode.W] = 0x57, [Enum.KeyCode.A] = 0x41, [Enum.KeyCode.S] = 0x53, [Enum.KeyCode.D] = 0x44, } local activeKeyBackends = {} local lastBackend = "not tested" local autoPreferred = "VIM" local heldMouse = {} local function releaseMouseButtons() for button, press in pairs(heldMouse) do local ok = pcall(function() VIM:SendMouseButtonEvent(press.X, press.Y, button, false, game, 0) end) if ok then heldMouse[button] = nil end end end local function sendKey(backend, code, down) if backend == "VIM" then VIM:SendKeyEvent(down, code, false, game) return end if down and not state.Focused then error("Native keyboard presses require Roblox focus") end if type(nativeDown) ~= "function" or type(nativeUp) ~= "function" then error("Native keypress/keyrelease are unavailable") end local vk = virtualKeys[code] if not vk and #code.Name == 1 then vk = string.byte(code.Name) end if not vk then error("No native key mapping for " .. code.Name) end local result if down then result = nativeDown(vk) else result = nativeUp(vk) end if result == false then error("Native input returned failure") end end local function key(code, down) local pinned = activeKeyBackends[code] local backends = pinned and {pinned} or (not state.Focused and {"VIM"}) or (state.InputMode == "Auto" and {autoPreferred, autoPreferred == "VIM" and "Native" or "VIM"} or {state.InputMode}) local errors = {} for _, backend in ipairs(backends) do local ok, err = pcall(sendKey, backend, code, down) if ok then activeKeyBackends[code] = down and backend or nil lastBackend = backend return end table.insert(errors, backend .. ": " .. tostring(err)) end error("Keyboard input failed: " .. table.concat(errors, " | ")) end local movementKeys = {Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D} local heldMovement = {} local steeringRoot, steeringGoal local steeringExpires = 0 local monitorPosition, monitorTime local autoSwitched = false local function selectMovementKeys(forward, right) return { [Enum.KeyCode.W] = forward > 0.38, [Enum.KeyCode.S] = forward < -0.38, [Enum.KeyCode.D] = right > 0.38, [Enum.KeyCode.A] = right < -0.38, } end local function releaseMovement() steeringRoot, steeringGoal = nil, nil for _, code in ipairs(movementKeys) do if heldMovement[code] then local ok = pcall(key, code, false) if ok then heldMovement[code] = nil end end end end local function releaseAllKeys() releaseMovement() releaseMouseButtons() local pending = {} for code in pairs(activeKeyBackends) do table.insert(pending, code) end for _, code in ipairs(pending) do pcall(key, code, false) end for _, code in ipairs(movementKeys) do if not activeKeyBackends[code] then heldMovement[code] = nil end end state.Sprinting = activeKeyBackends[Enum.KeyCode.LeftShift] ~= nil end local function applyWASD(root, destination) local camera = workspace.CurrentCamera if not destination or not camera then releaseMovement() return end local delta = destination - root.Position local flat = Vector3.new(delta.X, 0, delta.Z) if flat.Magnitude < 0.5 then releaseMovement() return end local look = camera.CFrame.LookVector local forward = Vector3.new(look.X, 0, look.Z) if forward.Magnitude < 0.01 then local cameraRight = camera.CFrame.RightVector forward = Vector3.new(cameraRight.Z, 0, -cameraRight.X) end forward = forward.Unit local right = Vector3.new(-forward.Z, 0, forward.X) local direction = flat.Unit local wanted = selectMovementKeys(direction:Dot(forward), direction:Dot(right)) for _, code in ipairs(movementKeys) do if heldMovement[code] and not wanted[code] then key(code, false) heldMovement[code] = nil end end for _, code in ipairs(movementKeys) do if wanted[code] and not heldMovement[code] then heldMovement[code] = true key(code, true) end end end local function moveTowards(root, destination) steeringRoot, steeringGoal = root, destination steeringExpires = os.clock() + 0.75 end local function tap(code) local generation = state.Generation key(code, true) task.wait(0.06) if state.Running and generation == state.Generation then key(code, false) return true end return false end local function click(button) local camera = workspace.CurrentCamera if not camera then return false end local size = camera.ViewportSize local x, y = size.X / 2, size.Y / 2 if not state.Focused or state.InputMode ~= "Native" then local press = {X = x, Y = y} heldMouse[button] = press local ok = pcall(function() VIM:SendMouseButtonEvent(x, y, button, true, game, 0) end) if ok then task.wait(0.06) if heldMouse[button] ~= press then return false end VIM:SendMouseButtonEvent(x, y, button, false, game, 0) heldMouse[button] = nil combatStatus = button == 0 and "M1 sent (Roblox input)" or "M2 sent (Roblox input)" return true end releaseMouseButtons() if not state.Focused or state.InputMode == "VIM" then error("Roblox mouse input is unavailable") end end local native if button == 0 then native = nativeM1 else native = nativeM2 end if type(native) == "function" then if native() == false then error("Native mouse input returned failure") end combatStatus = button == 0 and "M1 sent (native input)" or "M2 sent (native input)" return true end error("No supported mouse button input is available") end local function characterParts(model) if not model then return end local humanoid = model:FindFirstChildOfClass("Humanoid") local root = model:FindFirstChild("HumanoidRootPart") or model:FindFirstChild("UpperTorso") or model:FindFirstChild("Torso") or model.PrimaryPart if humanoid and root and root:IsA("BasePart") and humanoid.Health > 0 then return humanoid, root end end local function resolveKillerProfile(model, owner, mode) if abilityProfiles[mode] then return mode end local names = {} if model then for _, attribute in ipairs({"MonsterName", "KillerName", "CurrentMonster", "CharacterName"}) do local value = model:GetAttribute(attribute) if type(value) == "string" then table.insert(names, value) end end table.insert(names, model.Name) end local current = owner:GetAttribute("CurrentMonster") if type(current) == "string" then table.insert(names, current) end for _, name in ipairs(names) do local normalized = string.lower(name):gsub("[^%w]", "") if profileAliases[normalized] then return profileAliases[normalized] end end return config.DetectedProfile or "Generic" end local function normalizeAbility(text) return (string.lower((text:gsub("<[^>]->", ""))):gsub("[^%w]", "")) end local function parseAbilityInput(text) local name = normalizeAbility(text) if name == "space" or name == "spacebar" then return {Key=Enum.KeyCode.Space} end if name == "mousebutton2" or name == "mouse2" or name == "m2" or name == "rmb" then return {Mouse=1} end if name == "mousebutton1" or name == "mouse1" or name == "m1" or name == "lmb" then return {Mouse=0} end if #name == 1 and name:match("%a") then local code = Enum.KeyCode[string.upper(name)] if code then return {Key=code} end end return nil end local function parseAbilityOverrides(text, profile) local bindings = {} for entry in text:gmatch("[^;]+") do if entry:match("^%s*$") then continue end local name, keyName = entry:match("^%s*(.-)%s*=%s*(.-)%s*$") if not name then return nil,"Use Ability Name=Key; Other Ability=Key" end local wanted, matched = normalizeAbility(name) for _, ability in ipairs((abilityProfiles[profile] or abilityProfiles.Generic).Abilities) do if normalizeAbility(ability.Name)==wanted then matched=ability.Name break end end local input = parseAbilityInput(keyName) if not matched then return nil,"Unknown ability for "..profile..": "..name end if not input then return nil,"Unknown key for "..name..": "..keyName end bindings[matched] = input end return bindings end local function savedAbilityOverrides() local saved = env.PillarBotAbilityInputs local text = type(saved)=="table" and saved[config.ActiveProfile] return type(text)=="string" and text or "" end local function hudVisible(item) local node = item while node and node ~= player.PlayerGui do if node:IsA("GuiObject") and not node.Visible then return false end if node:IsA("ScreenGui") and not node.Enabled then return false end node = node.Parent end return true end local function scanAbilityHUD() if os.clock() < nextAbilityScan then return end nextAbilityScan = os.clock() + config.AbilityScanInterval local playerGui = player:FindFirstChildOfClass("PlayerGui") if not playerGui then return end local labels, keys = {}, {} for _, item in ipairs(playerGui:GetDescendants()) do if item:IsDescendantOf(gui) or not (item:IsA("TextLabel") or item:IsA("TextButton") or item:IsA("ImageLabel") or item:IsA("ImageButton")) then continue end if not hudVisible(item) or item.AbsoluteSize.X <= 0 or item.AbsoluteSize.Y <= 0 then continue end local text = (item:IsA("TextLabel") or item:IsA("TextButton")) and item.Text or "" local entry = {Object=item, Name=normalizeAbility(text), ObjectName=normalizeAbility(item.Name or ""), X=item.AbsolutePosition.X+item.AbsoluteSize.X/2, Y=item.AbsolutePosition.Y+item.AbsoluteSize.Y/2} table.insert(labels, entry) local input = parseAbilityInput(text) if input then entry.Input=input table.insert(keys, entry) end end local bindings, votes, usedKeycaps = {}, {}, {} for profile, data in pairs(abilityProfiles) do usedKeycaps[profile] = {} for _, ability in ipairs(data.Abilities) do local wanted = normalizeAbility(ability.Name) for _, label in ipairs(labels) do local matches = label.Name == wanted or label.ObjectName == wanted or label.ObjectName == wanted.."icon" for _, alias in ipairs(ability.Aliases or {}) do if label.Name == normalizeAbility(alias) then matches = true end end if not matches then continue end local best, bestDistance for _, keycap in ipairs(keys) do if usedKeycaps[profile][keycap.Object] then continue end local dx, dy = label.X-keycap.X, label.Y-keycap.Y local distance = math.sqrt(dx*dx+dy*dy) if math.abs(dx) <= 180 and math.abs(dy) <= 320 and distance <= 340 and (not bestDistance or distance < bestDistance) then best,bestDistance=keycap,distance end end if best then bindings[profile..":"..ability.Name] = best.Input usedKeycaps[profile][best.Object] = true end votes[profile] = votes[profile] or {} votes[profile][ability.Name] = true end end end local manualLeap = type(env.PillarBotLeapInput) == "string" and parseAbilityInput(env.PillarBotLeapInput) bindings["Brutum:Goliathan Leap"] = manualLeap or {Key=Enum.KeyCode.Space} local overrides = parseAbilityOverrides(savedAbilityOverrides(),config.ActiveProfile) for name, input in pairs(overrides or {}) do bindings[config.ActiveProfile..":"..name] = input end hudBindings = bindings local detected, bestVotes = nil, 0 for profile, abilities in pairs(votes) do local count = 0 for _ in pairs(abilities) do count += 1 end if count > bestVotes then detected,bestVotes=profile,count end end config.DetectedProfile = bestVotes >= 2 and detected or nil local count = 0 for name in pairs(bindings) do if name:sub(1,#config.ActiveProfile+1) == config.ActiveProfile..":" then count += 1 end end abilityStatus = count > 0 and (count.." ability inputs mapped") or "no ability keycaps detected" if config.ActiveProfile == "Brutum" then local leap = bindings["Brutum:Goliathan Leap"] local keyName = leap.Key and tostring(leap.Key):match("[^.]+$") or (leap.Mouse==1 and "RMB" or "LMB") abilityStatus ..= " | Leap: "..keyName end local missing = {} for _, ability in ipairs((abilityProfiles[config.ActiveProfile] or abilityProfiles.Generic).Abilities) do if not bindings[config.ActiveProfile..":"..ability.Name] then table.insert(missing,ability.Name) end end if #missing>0 then abilityStatus ..= " | Missing controls: "..table.concat(missing,", ") end end local function applyAgentSize(humanoid, root) if not config.AutoAgentSize then return end config.AgentRadius = math.clamp(root.Size.X * 0.5 + 0.5, 1.5, 4) local head = root.Parent:FindFirstChild("Head") local headHeight = head and head:IsA("BasePart") and head.Size.Y or 1 config.AgentHeight = math.clamp(humanoid.HipHeight + root.Size.Y + headHeight, 4, 12) end local function restoreBackgroundCamera() if not backgroundCamera then return end local saved = backgroundCamera backgroundCamera = nil pcall(function() if saved.Camera.CameraType == Enum.CameraType.Scriptable then saved.Camera.CameraType = saved.Type saved.Camera.Focus = saved.Focus end end) end local function updateBackgroundCamera(camera, target) local _, root = characterParts(player.Character) if not root then restoreBackgroundCamera() return end if backgroundCamera and backgroundCamera.Camera ~= camera then restoreBackgroundCamera() end local now = os.clock() if not backgroundCamera then local offset = camera.CFrame.Position - root.Position if offset.Magnitude > 24 then offset = offset.Unit * 24 end backgroundCamera = {Camera = camera, Type = camera.CameraType, Focus = camera.Focus, Offset = offset, UpdatedAt = now} end local saved = backgroundCamera local position = root.Position + saved.Offset local aim = target.Position if (aim - position).Magnitude < 0.05 then return end local dt = math.clamp(now - saved.UpdatedAt, 1 / 120, 0.15) local alpha = 1 - math.exp(-config.BackgroundCameraResponse * dt) camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = camera.CFrame:Lerp(CFrame.lookAt(position, aim), alpha) camera.Focus = CFrame.new(aim) saved.UpdatedAt = now mouseAimStatus = "background camera tracking (no desktop mouse)" end local function updateLeapCamera(camera) if not leapAim then return false end if not state.Running or not state.Enabled or leapAim.Generation ~= state.Generation or os.clock() >= leapAim.Until or currentTarget ~= leapAim.Target.Parent then leapAim = nil return false end updateBackgroundCamera(camera, leapAim.Target) local position = camera.CFrame.Position camera.CFrame = CFrame.lookAt(position, position + leapAim.Direction) mouseAimStatus = "aiming Goliathan Leap" return true end local function smoothMouseStep(dx, dy) local function axis(value) if math.abs(value) <= config.MouseDeadzone then return 0 end local scaled = math.clamp(value * config.MouseGain, -config.MouseMaxStep, config.MouseMaxStep) return math.sign(scaled) * math.floor(math.abs(scaled) + 0.5) end return axis(dx), axis(dy) end local function sendMouseMovement(dx, dy, locked) if state.Focused and type(nativeMouseMove) == "function" then local ok, result = pcall(nativeMouseMove, dx, dy) if ok and result ~= false then return "native mouse" end end if not triedVirtualMouse then triedVirtualMouse = true local ok, result = pcall(function() return UIS:CreateVirtualInput() end) if ok then virtualMouse = result end end if not virtualMouse then error("No supported mouse movement input is available") end if locked then virtualMouse:SendMouseDelta(Vector2.new(dx, dy)) else local cursor = UIS:GetMouseLocation() virtualMouse:SendMousePosition(Vector2.new(cursor.X + dx, cursor.Y + dy)) end return "Roblox virtual mouse" end local function updateMouseAim() if state.GuiDragging then mouseAimStatus = "paused while moving menu" return end local leapCamera = workspace.CurrentCamera if leapCamera and updateLeapCamera(leapCamera) then return end if not state.MouseAim then restoreBackgroundCamera() mouseAimStatus = "OFF (H)" return end if os.clock() < nextMouseUpdate then return end nextMouseUpdate = os.clock() + 1 / 30 local _, target = characterParts(currentTarget) local camera = workspace.CurrentCamera if not target or not camera then restoreBackgroundCamera() mouseAimStatus = "waiting for target" return end if not state.Focused and config.BackgroundMode and config.BackgroundCameraAim then updateBackgroundCamera(camera, target) return end restoreBackgroundCamera() local locked = UIS.MouseBehavior ~= Enum.MouseBehavior.Default local dx, dy if locked then local relative = camera.CFrame:PointToObjectSpace(target.Position) local horizontal = math.sqrt(relative.X * relative.X + relative.Z * relative.Z) if horizontal < 0.001 and math.abs(relative.Y) < 0.001 then return end dx = math.atan2(relative.X, -relative.Z) * config.MousePixelsPerRadian dy = -math.atan2(relative.Y, horizontal) * config.MousePixelsPerRadian else local point, onScreen = camera:WorldToScreenPoint(target.Position) if not onScreen or point.Z <= 0 then mouseAimStatus = "target off screen; lock mouse for camera aiming" return end local cursor = UIS:GetMouseLocation() if panel and panel.Visible then local p, size = panel.AbsolutePosition, panel.AbsoluteSize if cursor.X >= p.X and cursor.X <= p.X + size.X and cursor.Y >= p.Y and cursor.Y <= p.Y + size.Y then mouseAimStatus = "paused over menu (H toggles)" return end end dx, dy = point.X - cursor.X, point.Y - cursor.Y end dx, dy = smoothMouseStep(dx, dy) if dx == 0 and dy == 0 then mouseAimStatus = "aligned" return end local backend = sendMouseMovement(dx, dy, locked) mouseAimStatus = backend .. (locked and " | camera aiming" or " | cursor aiming") end local function setStatus(message) if statusLabel then local held = {} for _, code in ipairs(movementKeys) do if heldMovement[code] then table.insert(held, code.Name) end end statusLabel.Text = message .. "\nInput: " .. lastBackend .. " | Held: " .. (#held > 0 and table.concat(held, "+") or "none") .. "\nMouse: " .. mouseAimStatus .. " | Traps: " .. trapStatus .. string.format(" (F:%d C:%d; %s)", trapFCount, trapCCount, trapDecision) .. "\nCombat: " .. combatStatus .. " | " .. abilityStatus end end local function isPracticeDummy(model) if not model or not model:IsA("Model") then return false end local ancestor = model while ancestor and ancestor ~= workspace do local name = string.lower(ancestor.Name):gsub("[^%w]", "") if ancestor == model then for _, fragment in ipairs(config.MinionNameFragments) do if string.find(name, fragment, 1, true) then return false end end elseif name == "minions" or name == "tamaterrors" or name == "summons" then return false end ancestor = ancestor.Parent end if markedDummies[model] then return true end local normalizedName = string.lower(model.Name):gsub("[^%w]", "") if config.PracticeDummyNames[normalizedName] then return true end if not config.AutoDetectBlockDummies then return false end local head = model:FindFirstChild("Head") if not head or not head:IsA("BasePart") then return false end for _, name in ipairs({"Torso", "Left Arm", "Right Arm", "Left Leg", "Right Leg"}) do local part = model:FindFirstChild(name) if not part or not part:IsA("Part") or part.Shape ~= Enum.PartType.Block or part:FindFirstChildOfClass("SpecialMesh") then return false end end return true end local function clearPath() if nav.Blocked then nav.Blocked:Disconnect() nav.Blocked = nil end if nav.Path then nav.Path:Destroy() nav.Path = nil end route, routeIndex = {}, 1 end local function invalidateNavigation() nav.Serial += 1 computing = false clearPath() nextPath = 0 nav.Force, nav.LastGoal, nav.RecoveryGoal = true, nil, nil nav.BuiltAt, nav.Stalls, nav.RecoveryUntil = 0, 0, 0 nav.Failures = 0 nav.Status = "waiting for route" end local function resetMovement() state.Generation += 1 state.Testing = false pendingAbilityRecast = nil leapAim = nil table.clear(chaseMemory) table.clear(abilityMemory) restoreBackgroundCamera() containmentGoal = nil actionSerial += 1 actionBusy = false invalidateNavigation() currentTarget = nil monitorPosition, monitorTime = nil, nil autoSwitched = false releaseAllKeys() end function state.Stop() if finishGuiDrag then finishGuiDrag() end state.Enabled = false state.Running = false state.Testing = false resetMovement() releaseAllKeys() if connection then connection:Disconnect() end for _, other in ipairs(extraConnections) do other:Disconnect() end if gui then gui:Destroy() end if env.PercyAuto == state then env.PercyAuto = nil end if env.PillarChaseBot == state then env.PillarChaseBot = nil end print("[Percy] Unloaded") end local function scanMinionSupport() if config.ActiveProfile ~= "PalPercy" or not config.MinionCoordination or os.clock() < nextMinionScan then return end nextMinionScan = os.clock() + 1 alliedMinions = {} for _, instance in ipairs(workspace:GetDescendants()) do if instance:IsA("Model") then local name = string.lower(instance.Name):gsub("[^%w]", "") local kind for _, candidate in ipairs({"roachi", "bruti", "lanki", "opti"}) do if string.find(name, candidate, 1, true) then kind = candidate break end end local ownerId = instance:GetAttribute("OwnerUserId") if kind and (ownerId == nil or tostring(ownerId) == tostring(player.UserId)) then local root = instance.PrimaryPart or instance:FindFirstChild("HumanoidRootPart") or instance:FindFirstChildWhichIsA("BasePart", true) if root then table.insert(alliedMinions, {Model = instance, Root = root, Kind = kind}) end end end end end local function minionSupportFactor(position, origin) if config.ActiveProfile ~= "PalPercy" or not config.MinionCoordination then return 1 end local factor = 1 for _, minion in ipairs(alliedMinions) do if not minion.Model:IsDescendantOf(workspace) or not minion.Root.Parent then continue end local status = minion.Model:GetAttribute("Status") local statusValue = minion.Model:FindFirstChild("Status") if status == nil and statusValue and statusValue:IsA("StringValue") then status = statusValue.Value end status = string.upper(tostring(status or "")) if status == "STUNNED" or status == "INACTIVE" or status == "DISABLED" then continue end local proximity = (minion.Root.Position - position).Magnitude if proximity <= 10 and status == "ATTACK" then factor = math.min(factor, minion.Kind == "lanki" and 0.5 or 0.65) elseif proximity <= 12 and (status == "PURSUE" or status == "PURSUING") then factor = math.min(factor, 0.8) elseif status == "" and proximity <= 5 and (minion.Root.Position - origin).Magnitude > 10 then factor = math.min(factor, 0.85) end end return factor end local function shouldKeepTarget(currentDistance, challengerDistance, lockAge) return lockAge < config.TargetLockSeconds or challengerDistance >= currentDistance * config.SwitchDistanceRatio end local function nearestTarget(origin) scanMinionSupport() local bestModel, bestRoot, lockedRoot, lockedDistance local bestDistance = config.TargetRadius local bestScore = math.huge eligiblePlayerCount = 0 for _, other in ipairs(Players:GetPlayers()) do if other ~= player then local friendly = config.RespectTeams and player.Team ~= nil and other.Team == player.Team and not player.Neutral and not other.Neutral if not friendly then local _, root = characterParts(other.Character) if root then local distance = (root.Position - origin).Magnitude playerObservations[other.Character] = {Position = root.Position, Velocity = root.AssemblyLinearVelocity, Time = os.clock()} if distance <= config.TargetRadius then eligiblePlayerCount += 1 end local available = os.clock() >= (targetCooldowns[other.Character] or 0) if available and other.Character == currentTarget and distance <= config.TargetRadius then lockedRoot, lockedDistance = root, distance end local score = distance * minionSupportFactor(root.Position, origin) if available and distance <= config.TargetRadius and score < bestScore then bestScore = score bestDistance = distance bestModel = other.Character bestRoot = root end end end end end if lockedRoot and shouldKeepTarget(lockedDistance * minionSupportFactor(lockedRoot.Position, origin), bestScore, os.clock() - targetChosenAt) then return currentTarget, lockedRoot, lockedDistance end if bestRoot then return bestModel, bestRoot, bestDistance end if config.IncludeNPCs then if os.clock() >= nextNPCScan then nextNPCScan = os.clock() + 2 cachedNPCs = {} for _, descendant in ipairs(workspace:GetDescendants()) do if descendant:IsA("Humanoid") then local model = descendant.Parent if model and model:IsA("Model") and isPracticeDummy(model) and not Players:GetPlayerFromCharacter(model) and not (player.Character and model:IsDescendantOf(player.Character)) then table.insert(cachedNPCs, model) end end end end for _, model in ipairs(cachedNPCs) do if model:IsDescendantOf(workspace) and isPracticeDummy(model) then local _, root = characterParts(model) if root then local distance = (root.Position - origin).Magnitude local available = os.clock() >= (targetCooldowns[model] or 0) if available and model == currentTarget and distance <= config.TargetRadius then lockedRoot, lockedDistance = root, distance end if available and distance < bestDistance then bestDistance = distance bestModel, bestRoot = model, root end end end end end if lockedRoot and shouldKeepTarget(lockedDistance, bestDistance, os.clock() - targetChosenAt) then return currentTarget, lockedRoot, lockedDistance end return bestModel, bestRoot, bestDistance end local function visible(root, target) local params = RaycastParams.new() params.FilterType = Enum.RaycastFilterType.Exclude local ignored = {player.Character} params.RespectCanCollide = true for _ = 1, 8 do params.FilterDescendantsInstances = ignored local result = workspace:Raycast(root.Position, target.Position - root.Position, params) if not result or result.Instance:IsDescendantOf(target.Parent) then return true end local node, minion = result.Instance, nil while node and node ~= workspace do if node:IsA("Model") then local name = string.lower(node.Name):gsub("[^%w]", "") if string.find(name, "roachi", 1, true) or string.find(name, "bruti", 1, true) or string.find(name, "lanki", 1, true) or string.find(name, "opti", 1, true) then minion = node break end end node = node.Parent end if not minion then return false end table.insert(ignored, minion) end return false end local function canNormalJump() if config.ActiveProfile == "Brutum" then return false end if not config.NormalJumping then return false end local humanoid = characterParts(player.Character) if not humanoid or humanoid.Health <= 0 or humanoid.Sit or humanoid.PlatformStand then return false end if not humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping) then return false end return (humanoid.UseJumpPower and humanoid.JumpPower or humanoid.JumpHeight) > 0 end local function requestNormalJump() if leapAim and leapAim.Generation == state.Generation and os.clock() < leapAim.Until then return false end if not state.Running or not state.Enabled or state.GuiDragging or not canNormalJump() or os.clock() < (nav.NextJump or 0) then return false end local humanoid = characterParts(player.Character) if humanoid.FloorMaterial == Enum.Material.Air then return false end local ok, err = pcall(key, Enum.KeyCode.Space, true) if not ok then nav.Status = "jump input unavailable: " .. tostring(err) return false end local token = {} nav.JumpToken, nav.NextJump = token, os.clock() + config.JumpRetryInterval task.delay(0.12, function() if nav.JumpToken ~= token then return end local released = pcall(key, Enum.KeyCode.Space, false) if released then nav.JumpToken = nil end end) return true end local function navigationParams() local ignored = {} for _, other in ipairs(Players:GetPlayers()) do if other.Character then table.insert(ignored, other.Character) end end if currentTarget then table.insert(ignored, currentTarget) end local params = RaycastParams.new() params.FilterType = Enum.RaycastFilterType.Exclude params.FilterDescendantsInstances = ignored params.RespectCanCollide = true return params end local function groundAt(position, params) return workspace:Raycast(position + Vector3.new(0, 0.5, 0), Vector3.new(0, -20, 0), params) end local function predictedGoal(target) local observation = playerObservations[target.Parent] local velocity = observation and observation.Velocity or target.AssemblyLinearVelocity local lead = Vector3.new(velocity.X, 0, velocity.Z) * config.PredictionSeconds if lead.Magnitude > config.MaxPrediction then lead = lead.Unit * config.MaxPrediction end local candidate = target.Position + lead local params = navigationParams() if lead.Magnitude > 0.01 and workspace:Raycast(target.Position, lead, params) then candidate = target.Position end local ground = groundAt(candidate, params) local base = groundAt(target.Position, params) if ground and base and math.abs(ground.Position.Y - base.Position.Y) < 3 then return ground.Position + Vector3.new(0, 0.5, 0) end return target.Position end local function clearCorridor(root, destination) local params = navigationParams() local startGround, endGround = groundAt(root.Position, params), groundAt(destination, params) if not startGround or not endGround then return false end local delta = endGround.Position - startGround.Position local horizontal = Vector3.new(delta.X, 0, delta.Z) local distance = horizontal.Magnitude if distance > config.MaxDirectDistance then return false end if distance < 0.1 then return math.abs(delta.Y) < 2.5 end local forward = horizontal.Unit local right = Vector3.new(-forward.Z, 0, forward.X) local hip = math.clamp(root.Position.Y - startGround.Position.Y, 2, 4) local from = startGround.Position + Vector3.new(0, hip, 0) local finish = endGround.Position + Vector3.new(0, hip, 0) for _, side in ipairs({-config.AgentRadius, 0, config.AgentRadius}) do for _, height in ipairs({0, 1.5}) do local offset = right * side + Vector3.new(0, height, 0) if workspace:Raycast(from + offset, finish - from, params) then return false end end end local previousY = startGround.Position.Y local steps = math.max(1, math.ceil(distance / 3)) for step = 1, steps do local sample = from:Lerp(finish, step / steps) local ground = groundAt(sample, params) if not ground or ground.Normal.Y < 0.55 or math.abs(ground.Position.Y - previousY) > 2.5 then return false end previousY = ground.Position.Y end return true end local function waypointReached(position, waypoint) local delta = waypoint - position return Vector3.new(delta.X, 0, delta.Z).Magnitude <= config.WaypointReach and math.abs(delta.Y) < 5 end local function needsRepath(goal, now) return nav.Force or #route == 0 or routeIndex > #route or not nav.LastGoal or (goal - nav.LastGoal).Magnitude >= config.RepathTargetMovement or now - nav.BuiltAt >= config.MaxPathAge end local function updateChaseTactics(root, target, distance) local now = os.clock() local memory = chaseMemory if memory.Target ~= target.Parent then table.clear(memory) memory.Target, memory.Samples, memory.BestDistance, memory.ProgressAt = target.Parent, {}, distance, now memory.NextDecision, memory.Breaks = now + config.ChaseProgressTimeout, 0 end if not config.AntiLoop or distance <= config.AttackRange then memory.Goal, memory.Until, memory.LoopUntil = nil, nil, nil memory.BestDistance, memory.ProgressAt, memory.Breaks = distance, now, 0 table.clear(memory.Samples) return end if distance < memory.BestDistance - 2.5 then memory.BestDistance, memory.ProgressAt, memory.Breaks = distance, now, 0 memory.Goal, memory.LoopUntil = nil, nil end if now >= (memory.NextSample or 0) then memory.NextSample = now + config.ChaseSampleInterval table.insert(memory.Samples, {At=now, Bot=root.Position, Survivor=target.Position, Distance=distance}) while memory.Samples[1] and now-memory.Samples[1].At > config.ChaseHistorySeconds do table.remove(memory.Samples, 1) end end if memory.Goal and now < memory.Until then if waypointReached(root.Position, memory.Goal) then memory.Goal=nil else return memory.Goal end end memory.Goal = nil if now < memory.NextDecision or now-memory.ProgressAt < config.ChaseProgressTimeout then return end local samples = memory.Samples if #samples < 5 or now-samples[1].At < config.ChaseProgressTimeout-0.5 then return end local botTravel, targetTravel, revisited = 0, 0, false for index, sample in ipairs(samples) do if index > 1 then botTravel += (sample.Bot-samples[index-1].Bot).Magnitude targetTravel += (sample.Survivor-samples[index-1].Survivor).Magnitude end if now-sample.At >= 3 and (sample.Survivor-target.Position).Magnitude < 6 then revisited=true end end if botTravel < 16 or targetTravel < 16 then return end memory.Breaks += 1 memory.NextDecision, memory.LoopUntil = now+config.ChaseProgressTimeout, now+config.ChaseProgressTimeout memory.Reason = revisited and "repeated loop" or "chase not closing" local alternativeAvailable = false if memory.Breaks >= 3 and eligiblePlayerCount > 1 then for _, other in ipairs(Players:GetPlayers()) do local friendly = config.RespectTeams and player.Team ~= nil and other.Team==player.Team and not player.Neutral and not other.Neutral local _, alternate = characterParts(other.Character) if other~=player and other.Character~=target.Parent and not friendly and alternate and (alternate.Position-root.Position).Magnitude<=config.TargetRadius and now>=(targetCooldowns[other.Character] or 0) then alternativeAvailable=true break end end end if alternativeAvailable then targetCooldowns[target.Parent] = now + 5 memory.Reason = "changing target after repeated failed cutoffs" invalidateNavigation() releaseMovement() return end local velocity = target.AssemblyLinearVelocity local direction = Vector3.new(velocity.X, 0, velocity.Z) if direction.Magnitude < 1 then local previous = samples[math.max(1,#samples-2)] direction = target.Position-previous.Survivor direction = Vector3.new(direction.X,0,direction.Z) end if direction.Magnitude < 0.1 then return end direction = direction.Unit local side = Vector3.new(-direction.Z,0,direction.X) local sign = memory.Breaks % 2 == 1 and 1 or -1 local params = navigationParams() local targetFloor = groundAt(target.Position, params) if not targetFloor then return end local best, bestScore, fallback, fallbackScore for _, offset in ipairs({direction*12, direction*8+side*(10*sign), side*(12*sign), direction*8-side*(10*sign), direction*(-6)+side*(12*sign)}) do local candidate = target.Position+offset local floor = groundAt(candidate,params) if not floor or floor.Normal.Y < 0.55 or math.abs(floor.Position.Y-targetFloor.Position.Y)>3 then continue end local goal = floor.Position+Vector3.new(0,0.5,0) local recentlyVisited = 0 for _, sample in ipairs(samples) do if (sample.Bot-goal).Magnitude < 6 then recentlyVisited += 1 end end local score = (goal-root.Position).Magnitude + recentlyVisited*3 - offset:Dot(direction)*0.8 if memory.LastGoal and (goal-memory.LastGoal).Magnitude<8 then score += 25 end if not fallbackScore or score 0 and "updating route" or "computing route" task.delay(config.PathTimeout, function() if state.Running and computing and nav.Serial == serial then nav.Serial += 1 computing, nav.Force = false, true nav.Status = "path request timed out; retrying" end end) task.spawn(function() local path local ok, err = pcall(function() path = PFS:CreatePath({AgentRadius = config.AgentRadius, AgentHeight = config.AgentHeight, AgentCanJump = canNormalJump(), AgentCanClimb = false, WaypointSpacing = 3}) path:ComputeAsync(startPosition, goal) end) local current = state.Running and state.Enabled and generation == state.Generation and nav.Serial == serial and currentTarget == targetModel if not current then if path then path:Destroy() end return end computing = false local _, liveTarget = characterParts(targetModel) if not liveTarget or (liveTarget.Position - targetPosition).Magnitude > config.RepathTargetMovement * 3 then if path then path:Destroy() end nav.Force, nextPath = true, os.clock() + 0.1 return end if ok and path.Status == Enum.PathStatus.Success then local points = path:GetWaypoints() clearPath() nav.Path, route, routeIndex = path, points, 1 nav.LastGoal, nav.BuiltAt, nav.Force = goal, os.clock(), false nav.Failures = 0 local _, liveRoot = characterParts(player.Character) if liveRoot then while route[routeIndex] and route[routeIndex].Action ~= Enum.PathWaypointAction.Jump and waypointReached(liveRoot.Position, route[routeIndex].Position) do routeIndex += 1 end end nav.Blocked = path.Blocked:Connect(function(index) if nav.Path == path and index >= routeIndex then nav.Force, nextPath = true, 0 nav.Status = "route blocked; replanning" clearPath() releaseMovement() end end) nav.Status = "following route" else if path then path:Destroy() end nav.Force = true nav.Failures += 1 if nav.Failures >= 2 and #route == 0 then targetCooldowns[targetModel] = os.clock() + 5 end nav.Status = ok and "no walkable route; retrying" or ("path error: " .. tostring(err)) nextPath = os.clock() + 1 end end) end local function recoverFromStall(root, goal) nav.Serial += 1 computing = false clearPath() releaseMovement() nav.Force, nextPath = true, 0 nav.RecoveryGoal, nav.RecoveryUntil = nil, 0 nav.Stalls += 1 if nav.Stalls >= 3 and currentTarget then targetCooldowns[currentTarget] = os.clock() + 5 end local delta = goal - root.Position local flat = Vector3.new(delta.X, 0, delta.Z) if flat.Magnitude < 0.5 then return end local forward = flat.Unit local right = Vector3.new(-forward.Z, 0, forward.X) local params = navigationParams() local floor = groundAt(root.Position, params) local landing = groundAt(root.Position + forward * 4, params) if nav.Stalls < 3 and floor and landing and math.abs(landing.Position.Y - floor.Position.Y) <= 2.5 and workspace:Raycast(floor.Position + Vector3.new(0, 1, 0), forward * 3, params) and not workspace:Raycast(root.Position, Vector3.new(0, config.AgentHeight, 0), params) and requestNormalJump() then nav.RecoveryGoal, nav.RecoveryUntil = root.Position + forward * 4, os.clock() + 0.65 nav.Status = "jumping over low obstruction" moveTowards(root, nav.RecoveryGoal) return end local firstSide = nav.Stalls % 2 == 1 and 1 or -1 for _, side in ipairs({firstSide, -firstSide}) do local detour = root.Position + right * (5 * side) + forward * 2 if clearCorridor(root, detour) then nav.RecoveryGoal, nav.RecoveryUntil = detour, os.clock() + 0.65 nav.Status = "stepping around obstruction" moveTowards(root, detour) return end end nav.Status = "stuck; requesting a new route" end local function navigate(root, target, overrideGoal) local goal = overrideGoal or predictedGoal(target) if nav.RecoveryGoal and os.clock() < nav.RecoveryUntil then moveTowards(root, nav.RecoveryGoal) return end nav.RecoveryGoal = nil if clearCorridor(root, goal) then nav.Status = chaseMemory.Goal == goal and (chaseMemory.Reason.."; cutting off") or "clear route; intercepting" moveTowards(root, goal) return end requestPath(root, target, goal) local waypoint = route[routeIndex] while waypoint and (waypoint.Action ~= Enum.PathWaypointAction.Jump or nav.JumpedWaypoint == waypoint) and waypointReached(root.Position, waypoint.Position) do routeIndex += 1 waypoint = route[routeIndex] end local lookahead = math.min(#route, routeIndex + 2) for index = routeIndex, lookahead do if route[index].Action == Enum.PathWaypointAction.Jump then lookahead = index - 1 break end end for index = lookahead, routeIndex + 1, -1 do if clearCorridor(root, route[index].Position) then routeIndex, waypoint = index, route[index] break end end if waypoint and waypoint.Action == Enum.PathWaypointAction.Jump then local delta = waypoint.Position - root.Position if Vector3.new(delta.X, 0, delta.Z).Magnitude <= math.max(4, config.WaypointReach) and requestNormalJump() then nav.JumpedWaypoint = waypoint nav.Status = "jumping at route obstacle" end end moveTowards(root, waypoint and waypoint.Position or nil) end local function updateSprint(distance, sight) local wanted = config.SprintDuringChase and state.Enabled and state.Running if wanted ~= state.Sprinting or (wanted and not activeKeyBackends[Enum.KeyCode.LeftShift]) then key(Enum.KeyCode.LeftShift, wanted) state.Sprinting = wanted end end local function updateChaseMovement(root, target, distance, sight, goal) local velocity = target.AssemblyLinearVelocity local targetMoving = Vector3.new(velocity.X,0,velocity.Z).Magnitude > 1 if distance <= config.StopDistance and sight and not targetMoving then releaseMovement() nav.Status = "holding melee position" elseif distance <= config.AttackRange and sight then moveTowards(root,target.Position) nav.Status = "sprinting in melee range" else navigate(root,target,goal) end end local function attempt(name, interval, action) local now = os.clock() if now - (last[name] or -math.huge) < interval then return false end if action() == false then return false end last[name] = os.clock() return true end local function useTurbo() if config.ActiveProfile ~= "PalPercy" then return false end local generation = state.Generation tap(Enum.KeyCode.Q) if not state.Running or not state.Enabled or state.Generation ~= generation then return false end task.wait(config.TurboSelectionDelay) if not state.Running or not state.Enabled or state.Generation ~= generation then return false end return click(config.TurboMode == "Self" and 0 or 1) ~= false end local function trapOwnership(instance) local node = instance for _ = 1, 4 do if not node or node == workspace then break end local ownerId = node:GetAttribute("OwnerUserId") if ownerId ~= nil then return tostring(ownerId) == tostring(player.UserId) end local owner = node:FindFirstChild("Owner") if owner and owner:IsA("ObjectValue") then return owner.Value == player or owner.Value == player.Character end node = node.Parent end return nil end local function trapPart(trap) return trap:IsA("BasePart") and trap or trap.PrimaryPart or trap:FindFirstChildWhichIsA("BasePart", true) end local function isWirePile(instance) local name = string.lower(instance.Name):gsub("[^%w]", ""):gsub("%d+$", "") return (name == "wirepile" or name == "wirepiles" or name == "wiretrap") and instance:GetAttribute("Activated") ~= true and instance:GetAttribute("Active") ~= true end local function refreshTraps(force) local now = os.clock() if not force and now < nextTrapScan then return end nextTrapScan = now + 0.35 local candidates, observed = {}, {} for _, instance in ipairs(workspace:GetDescendants()) do if (instance:IsA("Model") or instance:IsA("BasePart")) and isWirePile(instance) then local trap = instance if instance.Parent and instance.Parent:IsA("Model") and isWirePile(instance.Parent) then trap = instance.Parent end if not observed[trap] then observed[trap] = true table.insert(candidates, trap) end end end trapCache = {} for _, trap in ipairs(candidates) do local ownership = trapOwnership(trap) local part = trapPart(trap) local ours = ownership == true for _, placement in ipairs(trapPlacements) do if part and not placement.Model and now - placement.SentAt <= config.TrapConfirmWindow and not placement.Before[trap] and ownership ~= false and (part.Position - placement.Position).Magnitude <= 8 then placement.Model = trap placement.Correlated = ownership == nil end if placement.Model == trap and ownership ~= false then ours = true end end if ours then table.insert(trapCache, trap) end end seenTrapObjects = observed for index = #trapPlacements, 1, -1 do local placement = trapPlacements[index] if placement.Model and not placement.Model:IsDescendantOf(workspace) then table.remove(trapPlacements, index) elseif not placement.Model and now - placement.SentAt > config.TrapPlacementLifetime then table.remove(trapPlacements, index) end end trapStatus = tostring(#trapCache) .. " observed" for _, placement in ipairs(trapPlacements) do if not placement.Model then trapStatus ..= now - placement.SentAt <= config.TrapConfirmWindow and "; waiting for spawn" or "; placement unconfirmed" break end end end local function trapNearTarget(target) if not target or not target.Parent then return end refreshTraps(false) local nearest, bestDistance = nil, config.TrapTriggerRange for _, trap in ipairs(trapCache) do if trap:IsDescendantOf(workspace) and not activatedTraps[trap] and trapOwnership(trap) ~= false and isWirePile(trap) then local part = trapPart(trap) if part then local distance = (part.Position - target.Position).Magnitude if distance <= bestDistance then nearest, bestDistance = trap, distance end end end end return nearest end local function activateNearbyTrap(target) if config.ActiveProfile ~= "PalPercy" then return false end local trap = trapNearTarget(target) if trap and attempt("ActivateTraps", config.TrapActivationInterval, function() if not tap(Enum.KeyCode.C) then return false end activatedTraps[trap] = true trapCCount += 1 trapDecision = "C submitted near target" trapStatus = "C sent; activation unconfirmed" end) then return true end return false end local function canPlaceTrap(root, target, distance) if config.ActiveProfile ~= "PalPercy" then return false, "not a Percy profile" end if not root or not target then return false, "no live target" end if distance > config.TrapPlacementRange then return false, "target outside placement range" end if math.abs(root.Position.Y - target.Position.Y) > 5 then return false, "target on another floor" end refreshTraps(false) if #trapCache >= config.TrapMaxCount then return false, "two observed piles already present" end for _, trap in ipairs(trapCache) do local part = trapPart(trap) if part and (part.Position - root.Position).Magnitude < config.TrapMinSpacing then return false, "too close to an observed pile" end end for _, placement in ipairs(trapPlacements) do local blockTime = placement.Model and config.TrapPlacementLifetime or config.WireInterval + 0.2 if os.clock() - placement.SentAt < blockTime and (placement.Position - root.Position).Magnitude < config.TrapMinSpacing then return false, "recent placement in this spot" end end if not groundAt(root.Position, navigationParams()) then return false, "ground not detected" end if containmentGoal and containmentGoal.Target == target.Parent then if (root.Position - containmentGoal.Position).Magnitude <= 4 then return true end if distance > config.WireMaxDistance then return false, "moving to containment position" end end return true end local function placeTrap(root) if config.ActiveProfile ~= "PalPercy" then return false end refreshTraps(true) local placement = {Position = root.Position, SentAt = os.clock(), Before = seenTrapObjects} if not tap(Enum.KeyCode.F) then return false end table.insert(trapPlacements, placement) trapFCount += 1 trapDecision = "F submitted; checking scene" containmentGoal = nil nextTrapScan = 0 trapStatus = "F sent; waiting for wire pile" return true end local function tryPlaceTrap(root, target, distance) local remaining = config.WireInterval - (os.clock() - (last.Wire or -math.huge)) if remaining > 0 then trapDecision = string.format("F cooldown %.1fs", remaining) return false end local allowed, reason = canPlaceTrap(root, target, distance) if not allowed then trapDecision = reason return false end return attempt("Wire", config.WireInterval, function() return placeTrap(root) end) end local function planContainment(root, target, distance) local now = os.clock() if config.ActiveProfile ~= "PalPercy" or not config.Containment or distance <= config.AttackRange or distance > config.TrapPlacementRange or now - (last.Wire or -math.huge) < config.WireInterval then containmentGoal = nil return end refreshTraps(false) if #trapCache >= config.TrapMaxCount then containmentGoal = nil return end if containmentGoal and containmentGoal.Target == target.Parent and containmentGoal.Expires > now then return containmentGoal.Position end containmentGoal = nil if now < nextContainmentScan then return end nextContainmentScan = now + config.ContainmentScanInterval local velocity = target.AssemblyLinearVelocity local flat = Vector3.new(velocity.X, 0, velocity.Z) if flat.Magnitude < 2 then return end local forward = flat.Unit local right = Vector3.new(-forward.Z, 0, forward.X) local params = navigationParams() local best, bestScore for _, ahead in ipairs({6, 10}) do local candidate = target.Position + forward * ahead local ground = groundAt(candidate, params) if not ground then continue end local spot = ground.Position + Vector3.new(0, 0.5, 0) if math.abs(spot.Y - root.Position.Y) > 5 then continue end local probe = ground.Position + Vector3.new(0, 3, 0) local left = workspace:Raycast(probe, right * -config.ContainmentSideProbe, params) local rightHit = workspace:Raycast(probe, right * config.ContainmentSideProbe, params) if not left or not rightHit then continue end local width = left.Distance + rightHit.Distance if width < config.AgentRadius * 2 + 1 or width > config.ContainmentMaxWidth then continue end local travel = (spot - root.Position).Magnitude if travel / 21 > (ahead / flat.Magnitude) * 1.2 then continue end local spaced = true for _, placement in ipairs(trapPlacements) do if now - placement.SentAt < config.TrapPlacementLifetime and (placement.Position - spot).Magnitude < config.TrapMinSpacing then spaced = false break end end for _, trap in ipairs(trapCache) do local part = trapPart(trap) if part and (part.Position - spot).Magnitude < config.TrapMinSpacing then spaced = false break end end if not spaced or not clearCorridor(root, spot) then continue end local score = travel + width * 2 if not bestScore or score < bestScore then best, bestScore = spot, score end end if best then containmentGoal = {Position = best, Target = target.Parent, Expires = now + config.ContainmentPlanLifetime} trapStatus = "moving to narrow exit" end return best end local function getAbilityMemory() local memory = abilityMemory[config.ActiveProfile] if not memory then memory = {Uses={}, RetryUntil={}, LastAt=-math.huge} abilityMemory[config.ActiveProfile] = memory end return memory end local function abilityPriority(name, cooldown, distance) local memory, now = getAbilityMemory(), os.clock() local usedAt = memory.Uses[name] local score = usedAt and (10+math.min((now-usedAt)/math.max(cooldown,1),2)*6) or 40 if memory.LastName == name then score -= 30 end local role = abilityRoles[name] if role == "Mobility" then score += distance > config.AttackRange*1.5 and 10 or -8 end if role == "Control" then score += 6 end if chaseMemory.LoopUntil and now < chaseMemory.LoopUntil then score += role == "Control" and 20 or (role == "Mobility" and 10 or 0) end return score end local function recordAbility(name) local memory = getAbilityMemory() memory.Uses[name], memory.LastAt, memory.LastName = os.clock(), os.clock(), name end local function pressAbility(binding, hold) if binding.Mouse ~= nil then return click(binding.Mouse) end if not binding.Key then return false end if not hold then return tap(binding.Key) end local generation = state.Generation key(binding.Key, true) task.wait(hold) if not state.Running or not state.Enabled or state.Generation ~= generation then return false end key(binding.Key, false) return true end local function prepareBrutumLeap(target, distance) local humanoid, root = characterParts(player.Character) local camera = workspace.CurrentCamera if not humanoid or not root or not target or not camera then return false end if humanoid.FloorMaterial == Enum.Material.Air or humanoid.Sit or humanoid.PlatformStand then return false end local delta = target.Position - root.Position local flat = Vector3.new(delta.X, 0, delta.Z) if flat.Magnitude < 0.1 then return false end local pitch = math.rad(config.BrutumLeapPitchMin + (config.BrutumLeapPitchMax-config.BrutumLeapPitchMin) * math.clamp((distance-4)/41, 0, 1)) leapAim = {Target=target, Generation=state.Generation, Until=os.clock()+config.BrutumLeapWindup, Direction=flat.Unit*math.cos(pitch)+Vector3.new(0,math.sin(pitch),0)} return updateLeapCamera(camera) end local function useHUDAbility(distance, target) local executionGeneration = state.Generation local profile = abilityProfiles[config.ActiveProfile] if not profile then return false end if pendingAbilityRecast then local pending = pendingAbilityRecast if pending.Profile ~= config.ActiveProfile or pending.Generation ~= state.Generation then pendingAbilityRecast = nil elseif os.clock() >= pending.Due then pendingAbilityRecast = nil combatStatus = "Ending " .. pending.Name local sent = pressAbility(pending.Binding) if sent then getAbilityMemory().LastAt=os.clock() end return sent else return false end end local memory, now = getAbilityMemory(), os.clock() if now-memory.LastAt < config.AbilityGap then return false end local candidates = {} for index, ability in ipairs(profile.Abilities) do local binding = hudBindings[config.ActiveProfile..":"..ability.Name] if not binding or distance < (ability.Min or 0) or distance > (ability.Max or math.huge) then continue end if now-(last["Ability:"..config.ActiveProfile..":"..ability.Name] or -math.huge)b.Score end) for _, candidate in ipairs(candidates) do local ability, binding = candidate.Ability, candidate.Binding local ok, used = pcall(function() return attempt("Ability:"..config.ActiveProfile..":"..ability.Name, ability.Cooldown, function() local generation = state.Generation if ability.AimLeap then if not prepareBrutumLeap(target, distance) then return false end task.wait(0.1) if not state.Running or not state.Enabled or generation ~= state.Generation then leapAim=nil return false end end if not pressAbility(binding, ability.Hold) then if ability.AimLeap then leapAim=nil end return false end if ability.Confirm ~= nil then task.wait(config.AbilitySelectionDelay) if not state.Running or not state.Enabled or state.Generation ~= generation then return false end if click(ability.Confirm) == false then return false end end if ability.Recast then pendingAbilityRecast = {Binding=binding, Profile=config.ActiveProfile, Name=ability.Name, Due=os.clock()+ability.Recast, Generation=state.Generation} end combatStatus = ability.Name .. " input sent" return true end) end) if ok and used then recordAbility(ability.Name) return true end memory.RetryUntil[ability.Name] = os.clock()+config.AbilityFailedRetry if not ok then releaseMouseButtons() if binding.Key then pcall(key,binding.Key,false) end leapAim=nil combatStatus = ability.Name.." failed; trying another ability" end if not state.Running or not state.Enabled or state.Generation ~= executionGeneration then return false end end return false end local function chooseAction(distance, target) if leapAim and leapAim.Generation == state.Generation and os.clock() < leapAim.Until then return end local profile = abilityProfiles[config.ActiveProfile] or abilityProfiles.Generic if distance <= config.AttackRange and attempt("Attack", profile.AttackInterval, function() return click(0) end) then return end if config.ActiveProfile ~= "PalPercy" then useHUDAbility(distance, target) return end if activateNearbyTrap(target) then return end local memory = getAbilityMemory() if os.clock()-memory.LastAt < config.AbilityGap then return end local _, root = characterParts(player.Character) local candidates = { {Name="Wire Terror", Cooldown=config.WireInterval, Key="Wire", Index=1, Run=function() return tryPlaceTrap(root,target,distance) end}, {Name="Turbo Time", Cooldown=config.TurboInterval, Key="Turbo", Index=2, Run=function() return (config.TurboMode=="Minions" or distance>=config.TurboMinDistance) and attempt("Turbo",config.TurboInterval,useTurbo) end}, {Name="Together Forever", Cooldown=config.TogetherInterval, Key="Together", Index=3, Run=function() return distance<=config.TogetherMaxDistance and attempt("Together",config.TogetherInterval,function() return click(1) end) end}, } for _, candidate in ipairs(candidates) do candidate.Score=abilityPriority(candidate.Name,candidate.Cooldown,distance) end table.sort(candidates,function(a,b) return a.Score==b.Score and a.Indexb.Score end) for _, candidate in ipairs(candidates) do if os.clock()-(last[candidate.Key] or -math.huge)>=candidate.Cooldown and candidate.Run() then recordAbility(candidate.Name) return end end end local function scheduleCombat(target) if actionBusy or state.GuiDragging or os.clock() < combatRetryAt then return end actionBusy = true actionSerial += 1 local serial, generation = actionSerial, state.Generation task.spawn(function() local ok, err = pcall(function() if not state.Running or not state.Enabled or state.GuiDragging or (not state.Focused and not config.BackgroundMode) or state.Generation ~= generation or actionSerial ~= serial or UIS:GetFocusedTextBox() then return end local _, root = characterParts(player.Character) local _, liveTarget = characterParts(target.Parent) if not root or liveTarget ~= target or currentTarget ~= target.Parent then return end local distance = (target.Position - root.Position).Magnitude if visible(root, target) then chooseAction(distance, target) else if activateNearbyTrap(target) then return end if containmentGoal and canPlaceTrap(root, target, distance) then tryPlaceTrap(root, target, distance) end end end) if serial ~= actionSerial then return end actionBusy = false if not ok then releaseMouseButtons() combatStatus = "input error: " .. tostring(err) combatRetryAt = os.clock() + 1 warn("[Percy] Combat: " .. tostring(err)) end end) end local function toggle() if not state.Running then return end if state.Testing then setStatus("Wait for the W input test to finish.") return end state.Enabled = not state.Enabled resetMovement() toggleButton.Text = state.Enabled and "Disable (F8)" or "Enable (F8)" setStatus(state.Enabled and "Automatically looking for players and block-style dummies..." or "Disabled. Click Enable for automatic target detection.") print("[Percy] " .. (state.Enabled and "Enabled" or "Disabled")) end gui = Instance.new("ScreenGui") gui.Name = "PillarChaseUniversalBot" gui.ResetOnSpawn = false gui.DisplayOrder = 100 gui.Parent = player:WaitForChild("PlayerGui") panel = Instance.new("Frame") panel.Size = UDim2.fromOffset(390, 385) panel.Position = UDim2.new(0, 20, 0, 100) panel.BackgroundColor3 = Color3.fromRGB(24, 24, 30) panel.Parent = gui statusLabel = Instance.new("TextLabel") statusLabel.Size = UDim2.new(1, -20, 0, 125) statusLabel.Position = UDim2.fromOffset(10, 5) statusLabel.BackgroundTransparency = 1 statusLabel.TextColor3 = Color3.new(1, 1, 1) statusLabel.TextSize = 14 statusLabel.TextWrapped = true statusLabel.Text = "Eight killer ability profiles. Reads visible HUD keycaps. K selects killer if Auto cannot identify it." statusLabel.Parent = panel toggleButton = Instance.new("TextButton") toggleButton.Size = UDim2.fromOffset(190, 36) toggleButton.Position = UDim2.fromOffset(10, 135) toggleButton.Text = "Enable (F8)" toggleButton.TextSize = 16 toggleButton.Parent = panel toggleButton.Activated:Connect(toggle) local stopButton = Instance.new("TextButton") stopButton.Size = UDim2.fromOffset(110, 36) stopButton.Position = UDim2.fromOffset(210, 135) stopButton.Text = "Unload (F9)" stopButton.TextSize = 16 stopButton.Parent = panel stopButton.Activated:Connect(state.Stop) local backendButton = Instance.new("TextButton") backendButton.Size = UDim2.fromOffset(190, 36) backendButton.Position = UDim2.fromOffset(10, 178) backendButton.Text = "Input: Auto (VIM first)" backendButton.TextSize = 14 backendButton.Parent = panel backendButton.Activated:Connect(function() state.Testing = false resetMovement() local nextMode = {Auto = "VIM", VIM = "Native", Native = "Auto"} state.InputMode = nextMode[state.InputMode] backendButton.Text = "Input: " .. state.InputMode setStatus("Input mode changed. Test W checks movement without needing a target.") end) local testButton = Instance.new("TextButton") testButton.Size = UDim2.fromOffset(160, 36) testButton.Position = UDim2.fromOffset(210, 178) testButton.Text = "Test W (1 second)" testButton.TextSize = 14 testButton.Parent = panel mouseAimButton = Instance.new("TextButton") mouseAimButton.Size = UDim2.fromOffset(360, 32) mouseAimButton.Position = UDim2.fromOffset(10, 222) mouseAimButton.Text = "Mouse aim: ON (H)" mouseAimButton.TextSize = 14 mouseAimButton.Parent = panel local function toggleMouseAim() state.MouseAim = not state.MouseAim if not state.MouseAim then restoreBackgroundCamera() end if state.MouseAim and not virtualMouse then triedVirtualMouse = false end mouseAimStatus = state.MouseAim and "waiting for target" or "OFF (H)" mouseAimButton.Text = "Mouse aim: " .. (state.MouseAim and "ON" or "OFF") .. " (H)" end mouseAimButton.Activated:Connect(toggleMouseAim) profileButton = Instance.new("TextButton") profileButton.Size = UDim2.fromOffset(360, 32) profileButton.Position = UDim2.fromOffset(10, 262) profileButton.Text = "Profile: " .. config.ProfileMode .. " (K)" profileButton.TextSize = 14 profileButton.Parent = panel local function cycleProfile() local index = table.find(profileOrder, config.ProfileMode) or 0 config.ProfileMode = profileOrder[index % #profileOrder + 1] env.PillarBotProfile = config.ProfileMode config.ActiveProfile = resolveKillerProfile(player.Character, player, config.ProfileMode) resetMovement() table.clear(last) table.clear(trapPlacements) table.clear(trapCache) table.clear(alliedMinions) nextMinionScan, nextTrapScan = 0, 0 profileButton.Text = "Profile: " .. config.ProfileMode .. " / " .. config.ActiveProfile .. " (K)" if abilityKeyBox then abilityKeyBox.Text=savedAbilityOverrides() end setStatus("Profile selected. Abilities use detected HUD controls; Generic uses M1 only.") end profileButton.Activated:Connect(cycleProfile) local leapKeyBox = Instance.new("TextBox") leapKeyBox.Size = UDim2.fromOffset(360, 32) leapKeyBox.Position = UDim2.fromOffset(10, 302) leapKeyBox.Text = type(env.PillarBotLeapInput) == "string" and env.PillarBotLeapInput or "" leapKeyBox.PlaceholderText = "Leap key: Space (blank = Space)" leapKeyBox.ClearTextOnFocus = false leapKeyBox.TextSize = 14 leapKeyBox.Parent = panel leapKeyBox.FocusLost:Connect(function() local value = leapKeyBox.Text:match("^%s*(.-)%s*$") if value ~= "" and not parseAbilityInput(value) then setStatus("Leap key must be Space, a letter, or RMB / MouseButton2. Blank uses Space.") return end env.PillarBotLeapInput = value ~= "" and value or nil nextAbilityScan = 0 scanAbilityHUD() setStatus(value == "" and "Leap uses Space." or "Leap key saved: " .. value) end) abilityKeyBox = Instance.new("TextBox") abilityKeyBox.Size = UDim2.fromOffset(360,32) abilityKeyBox.Position = UDim2.fromOffset(10,342) abilityKeyBox.Text = savedAbilityOverrides() abilityKeyBox.PlaceholderText = "Ability keys: Name=Q; Other Name=RMB" abilityKeyBox.ClearTextOnFocus = false abilityKeyBox.TextSize = 13 abilityKeyBox.Parent = panel abilityKeyBox.FocusLost:Connect(function() local text = abilityKeyBox.Text local parsed, reason = parseAbilityOverrides(text,config.ActiveProfile) if not parsed then setStatus(reason) return end if type(env.PillarBotAbilityInputs)~="table" then env.PillarBotAbilityInputs={} end env.PillarBotAbilityInputs[config.ActiveProfile] = text nextAbilityScan=0 scanAbilityHUD() setStatus("Ability controls saved for "..config.ActiveProfile..". Blank uses detected controls.") end) testButton.Activated:Connect(function() if state.Testing or not state.Running then return end state.Enabled = false toggleButton.Text = "Enable (F8)" resetMovement() local _, root = characterParts(player.Character) if not root then setStatus("No living character available for the W test.") return end state.Testing = true local generation = state.Generation local initialPosition = root.Position task.spawn(function() local ok, err = pcall(function() heldMovement[Enum.KeyCode.W] = true key(Enum.KeyCode.W, true) setStatus("Testing W. Your character should walk forward for one second.") local deadline = os.clock() + 1 repeat task.wait(0.05) until os.clock() >= deadline or not state.Running or not state.Testing or not state.Focused or generation ~= state.Generation end) if generation ~= state.Generation or not state.Running then return end releaseMovement() state.Testing = false if not ok then setStatus("W test error: " .. tostring(err)) return end if root.Parent then local displacement = root.Position - initialPosition local distance = Vector3.new(displacement.X, 0, displacement.Z).Magnitude setStatus(string.format("W test: moved %.1f studs. %s", distance, distance > 0.5 and "Input produced movement. Click Enable." or "No movement observed. Try another input mode, or check for an obstacle/stun.")) end end) end) local dragHandle = Instance.new("TextLabel") dragHandle.Name = "DragHandle" dragHandle.Size = UDim2.new(1, 0, 0, 30) dragHandle.BackgroundColor3 = Color3.fromRGB(45, 49, 65) dragHandle.TextColor3 = Color3.new(1, 1, 1) dragHandle.TextSize = 14 dragHandle.Text = "PILLAR CHASE BOT | Drag here to move" dragHandle.Active = true dragHandle.Parent = panel for _, child in ipairs(panel:GetChildren()) do if child ~= dragHandle and child:IsA("GuiObject") then child.Position = child.Position + UDim2.fromOffset(0, 32) end end panel.Size = panel.Size + UDim2.fromOffset(0, 32) local dragInput, dragOrigin, panelOrigin local function movePanel(x, y) local camera = workspace.CurrentCamera if camera then local viewport, size = camera.ViewportSize, panel.AbsoluteSize x = math.clamp(x, 0, math.max(0, viewport.X - size.X)) y = math.clamp(y, 0, math.max(0, viewport.Y - size.Y - 36)) end panel.Position = UDim2.fromOffset(x, y) end finishGuiDrag = function() if state.GuiDragging then env.PillarBotGuiPosition = {X = panel.Position.X.Offset, Y = panel.Position.Y.Offset} end state.GuiDragging = false dragInput, dragOrigin, panelOrigin = nil, nil, nil end local savedPosition = env.PillarBotGuiPosition if type(savedPosition) == "table" and type(savedPosition.X) == "number" and type(savedPosition.Y) == "number" and savedPosition.X == savedPosition.X and savedPosition.Y == savedPosition.Y then movePanel(savedPosition.X, savedPosition.Y) end table.insert(extraConnections, dragHandle.InputBegan:Connect(function(input) if not state.Running then return end if input.UserInputType ~= Enum.UserInputType.MouseButton1 and input.UserInputType ~= Enum.UserInputType.Touch then return end if state.GuiDragging then return end state.GuiDragging = true dragInput, dragOrigin, panelOrigin = input, input.Position, panel.Position end)) table.insert(extraConnections, UIS.InputChanged:Connect(function(input) if not state.GuiDragging then return end local isMouse = dragInput.UserInputType == Enum.UserInputType.MouseButton1 and input.UserInputType == Enum.UserInputType.MouseMovement if not isMouse and input ~= dragInput then return end local delta = input.Position - dragOrigin movePanel(panelOrigin.X.Offset + delta.X, panelOrigin.Y.Offset + delta.Y) end)) table.insert(extraConnections, UIS.InputEnded:Connect(function(input) if not state.GuiDragging then return end if input == dragInput or (dragInput.UserInputType == Enum.UserInputType.MouseButton1 and input.UserInputType == Enum.UserInputType.MouseButton1) then finishGuiDrag() end end)) table.insert(extraConnections, UIS.WindowFocusReleased:Connect(function() finishGuiDrag() state.Focused = false nextMouseUpdate = 0 state.Testing = false state.Generation += 1 actionSerial += 1 actionBusy = false releaseAllKeys() invalidateNavigation() monitorPosition, monitorTime = nil, nil if not config.BackgroundMode then resetMovement() end setStatus(config.BackgroundMode and "Background mode: Roblox input only; tracking continues." or "Paused: focus the Roblox window to continue.") end)) table.insert(extraConnections, UIS.WindowFocused:Connect(function() state.Focused = true nextMouseUpdate = 0 restoreBackgroundCamera() end)) table.insert(extraConnections, UIS.TextBoxFocused:Connect(function() state.Testing = false resetMovement() end)) table.insert(extraConnections, player.CharacterRemoving:Connect(function() state.Testing = false resetMovement() end)) table.insert(extraConnections, RunService.Heartbeat:Connect(function() if not state.Running or state.Testing then return end if not state.Enabled or (not state.Focused and not config.BackgroundMode) or UIS:GetFocusedTextBox() then restoreBackgroundCamera() releaseAllKeys() monitorPosition, monitorTime = nil, nil return end local mouseOK, mouseError = pcall(updateMouseAim) if not mouseOK then restoreBackgroundCamera() nextMouseUpdate = os.clock() + 2 mouseAimStatus = tostring(mouseError) mouseAimButton.Text = "Mouse input retrying; background camera enabled (H)" warn("[Percy] Mouse aim: " .. tostring(mouseError)) end if os.clock() < movementRetryAt then return end local root, goal = steeringRoot, steeringGoal if not root or not root.Parent or not goal or os.clock() > steeringExpires then releaseMovement() monitorPosition, monitorTime = nil, nil return end local ok, err = pcall(function() applyWASD(root, goal) if next(heldMovement) == nil then monitorPosition, monitorTime = nil, nil return end local now = os.clock() if not monitorPosition then monitorPosition, monitorTime = root.Position, now elseif now - monitorTime >= 1.5 then local displacement = root.Position - monitorPosition local moved = Vector3.new(displacement.X, 0, displacement.Z).Magnitude monitorPosition, monitorTime = root.Position, now if moved < 0.5 and state.InputMode == "Auto" and not autoSwitched then local movementBackend = autoPreferred for _, code in ipairs(movementKeys) do if activeKeyBackends[code] then movementBackend = activeKeyBackends[code] break end end releaseAllKeys() autoPreferred = movementBackend == "VIM" and "Native" or "VIM" autoSwitched = true steeringRoot, steeringGoal = root, goal steeringExpires = now + 0.4 applyWASD(root, goal) nav.Force, nextPath = true, 0 elseif moved < 0.5 then recoverFromStall(root, goal) else nav.Stalls = 0 end end end) if not ok then releaseAllKeys() if not state.Focused and config.BackgroundMode then movementRetryAt = os.clock() + 1.5 combatStatus = "Background movement unavailable: " .. tostring(err) else state.Enabled = false resetMovement() toggleButton.Text = "Enable (F8)" setStatus("W/A/S/D input error: " .. tostring(err)) end warn("[Percy] W/A/S/D input: " .. tostring(err)) end end)) connection = UIS.InputBegan:Connect(function(input) if UIS:GetFocusedTextBox() then return end if input.KeyCode == Enum.KeyCode.F9 then state.Stop() elseif input.KeyCode == Enum.KeyCode.H then toggleMouseAim() elseif input.KeyCode == Enum.KeyCode.J then config.Containment = not config.Containment containmentGoal = nil setStatus("Chokepoint containment: " .. (config.Containment and "ON" or "OFF")) elseif input.KeyCode == Enum.KeyCode.K then cycleProfile() elseif input.KeyCode == Enum.KeyCode.P then local part = player:GetMouse().Target local model = part while model and model ~= workspace do if model:IsA("Model") and model:FindFirstChildOfClass("Humanoid") then break end model = model.Parent end if not model or model == workspace or model == player.Character or (player.Character and model:IsDescendantOf(player.Character)) or Players:GetPlayerFromCharacter(model) then setStatus("Point at the practice dummy's body, then press P. Press L to unlock your mouse if needed.") return end local humanoid, root = characterParts(model) if not humanoid or not root then setStatus("That model has no living Humanoid or supported root part.") return end markedDummies[model] = true nextNPCScan = 0 setStatus("Marked dummy: " .. model.Name .. ". Click Enable if disabled.") print("[Percy] Manually marked dummy: " .. model:GetFullName()) elseif input.KeyCode == Enum.KeyCode.O then markedDummies = {} nextNPCScan = 0 resetMovement() setStatus("Manual marks cleared. Aim at a dummy and press P to mark it again.") elseif input.KeyCode == Enum.KeyCode.F8 then toggle() end end) task.spawn(function() while state.Running do task.wait(0.1) if not state.Running then break end if not state.Enabled then continue end local ok, err = pcall(function() if not state.Focused and not config.BackgroundMode then resetMovement() setStatus("Paused: Roblox window is unfocused.") return end if UIS:GetFocusedTextBox() then resetMovement() setStatus("Paused while typing") return end local humanoid, root = characterParts(player.Character) if not humanoid then resetMovement() setStatus("Waiting for your character's living Humanoid and root part") return end scanAbilityHUD() local detected = resolveKillerProfile(player.Character, player, config.ProfileMode) if config.ActiveProfile ~= detected or profileCharacter ~= player.Character then resetMovement() table.clear(last) table.clear(trapPlacements) table.clear(trapCache) table.clear(alliedMinions) nextMinionScan, nextTrapScan = 0, 0 config.ActiveProfile, profileCharacter = detected, player.Character applyAgentSize(humanoid, root) profileButton.Text = "Profile: " .. config.ProfileMode .. " / " .. detected .. " (K)" if abilityKeyBox then abilityKeyBox.Text=savedAbilityOverrides() end end local model, target, distance = nearestTarget(root.Position) if not target then resetMovement() setStatus("No player or recognized dummy within " .. config.TargetRadius .. " studs. Unknown NPC rigs are ignored; P can manually mark a dummy.") return end if currentTarget ~= model then state.Generation += 1 invalidateNavigation() releaseMovement() currentTarget = model targetChosenAt = os.clock() monitorPosition, monitorTime = nil, nil autoSwitched = false actionSerial += 1 actionBusy = false containmentGoal = nil table.clear(chaseMemory) releaseMouseButtons() end local sight = visible(root, target) local cutoffPosition = updateChaseTactics(root,target,distance) if os.clock()<(targetCooldowns[model] or 0) then setStatus("Changing target after repeated unsuccessful approaches.") return end local containmentPosition = not cutoffPosition and planContainment(root, target, distance) or nil if not state.Focused then local sprintOK, sprintError = pcall(updateSprint, distance, sight) if not sprintOK then combatStatus = "Background sprint unavailable: " .. tostring(sprintError) end else updateSprint(distance, sight) end updateChaseMovement(root,target,distance,sight,cutoffPosition or containmentPosition) setStatus(string.format("Players located: %d | Target: %s (%.0f studs)\nXYZ: %.0f, %.0f, %.0f | %s", eligiblePlayerCount, model.Name, distance, target.Position.X, target.Position.Y, target.Position.Z, nav.Status)) scheduleCombat(target) end) if not ok then state.Enabled = false resetMovement() toggleButton.Text = "Enable (F8)" setStatus("Error: " .. tostring(err)) warn("[Percy] Disabled: " .. tostring(err)) end end end) print("[Percy] Loaded. F8 toggles; F9 unloads.")