Skip to content

Commit 17b856c

Browse files
fixed charge bot
1 parent 2ad8e8e commit 17b856c

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

A_Swing_Prediction.lua

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ local Menu = {
5858
Silent = true,
5959
AimbotFOV = 360,
6060
SwingTime = 13,
61-
AlwaysUseMaxSwingTime = true, -- Default to always use max for best experience
62-
MaxSwingTime = 13, -- Starting value, will be updated based on weapon
61+
AlwaysUseMaxSwingTime = false, -- Default to always use max for best experience
62+
MaxSwingTime = 11, -- Starting value, will be updated based on weapon
6363
ChargeBot = true, -- Moved to Charge tab in UI but kept here for backward compatibility
6464
},
6565

@@ -70,6 +70,7 @@ local Menu = {
7070
ChargeSensitivity = 1.0,
7171
ChargeReach = true,
7272
ChargeJump = true,
73+
LateCharge = true,
7374
},
7475

7576
-- Visuals settings
@@ -202,6 +203,8 @@ local function SafeInitMenu()
202203
-- Initialize other sections if needed
203204
Menu.Charge = Menu.Charge or {}
204205
Menu.Visuals = Menu.Visuals or {}
206+
-- LateCharge default
207+
Menu.Charge.LateCharge = Menu.Charge.LateCharge ~= nil and Menu.Charge.LateCharge or true
205208
end
206209

207210
-- Call the initialization function to ensure no nil values
@@ -237,6 +240,20 @@ local pLocalPath = {}
237240
local vPlayerPath = {}
238241
local drawVhitbox = {}
239242

243+
-- Track swing ticks after +attack is sent
244+
local swingTickCounter = 0
245+
246+
-- Helpers for charge-bot yaw clamping
247+
local function NormalizeYaw(y)
248+
return ((y + 180) % 360) - 180
249+
end
250+
local function Clamp(val, min, max)
251+
if val < min then return min
252+
elseif val > max then return max end
253+
return val
254+
end
255+
local MAX_CHARGE_BOT_TURN = 17
256+
240257
-- Variables to track attack and charge state
241258
local attackStarted = false
242259
local attackTickCount = 0
@@ -903,8 +920,7 @@ local function ChargeControl(pCmd)
903920
end
904921

905922
-- CRITICAL: Limit maximum turn per frame to 73.04 degrees
906-
turnAmount = math.max(-CHARGE_CONSTANTS.MAX_ROTATION_PER_FRAME,
907-
math.min(CHARGE_CONSTANTS.MAX_ROTATION_PER_FRAME, turnAmount))
923+
turnAmount = Clamp(turnAmount, -MAX_CHARGE_BOT_TURN, MAX_CHARGE_BOT_TURN)
908924

909925
-- Calculate new yaw angle
910926
local newYaw = currentAngles.yaw + turnAmount
@@ -1301,7 +1317,7 @@ local function OnCreateMove(pCmd)
13011317

13021318
-- If charge-reach exploit is READY (full meter, demo, exploit enabled) but we're **not yet charging**,
13031319
-- run a secondary prediction that simulates starting a charge right now.
1304-
local simulateCharge = (not isCurrentlyCharging) and isExploitReady
1320+
local simulateCharge = (not isCurrentlyCharging) and isExploitReady and (not Menu.Charge.LateCharge)
13051321
local fixedAngles = nil
13061322
if simulateCharge and CurrentTarget then
13071323
-- Use current target's position to define intended charge heading for prediction
@@ -1408,17 +1424,23 @@ local function OnCreateMove(pCmd)
14081424
if trace.fraction == 1 or trace.entity == CurrentTarget then
14091425
-- If the trace hit something, set the view angles to the position of the hit
14101426
aim_angles = Math.PositionAngles(pLocalOrigin, UpdateHomingMissile())
1411-
-- Set view angles based on the future position of the local player
1412-
engine.SetViewAngles(EulerAngles(engine.GetViewAngles().pitch, aim_angles.yaw, 0))
1427+
-- Limit yaw change to MAX_CHARGE_BOT_TURN per tick
1428+
local currentAng = engine.GetViewAngles()
1429+
local yawDiff = NormalizeYaw(aim_angles.yaw - currentAng.yaw)
1430+
local limitedYaw = currentAng.yaw + Clamp(yawDiff, -MAX_CHARGE_BOT_TURN, MAX_CHARGE_BOT_TURN)
1431+
engine.SetViewAngles(EulerAngles(currentAng.pitch, limitedYaw, 0))
14131432
end
14141433
elseif Menu.Aimbot.ChargeBot and chargeLeft == 100 and input.IsButtonDown(MOUSE_RIGHT) and not can_attack and fDistance < 750 then
14151434
local trace = engine.TraceHull(pLocalFuture, UpdateHomingMissile(), vHitbox[1], vHitbox[2],
14161435
MASK_PLAYERSOLID_BRUSHONLY)
14171436
if trace.fraction == 1 or trace.entity == CurrentTarget then
14181437
-- If the trace hit something, set the view angles to the position of the hit
14191438
aim_angles = Math.PositionAngles(pLocalOrigin, UpdateHomingMissile())
1420-
-- Set view angles based on the future position of the local player
1421-
engine.SetViewAngles(EulerAngles(engine.GetViewAngles().pitch, aim_angles.yaw, 0))
1439+
-- Limit yaw change to MAX_CHARGE_BOT_TURN per tick
1440+
local currentAng = engine.GetViewAngles()
1441+
local yawDiff = NormalizeYaw(aim_angles.yaw - currentAng.yaw)
1442+
local limitedYaw = currentAng.yaw + Clamp(yawDiff, -MAX_CHARGE_BOT_TURN, MAX_CHARGE_BOT_TURN)
1443+
engine.SetViewAngles(EulerAngles(currentAng.pitch, limitedYaw, 0))
14221444
end
14231445
elseif can_attack and aim_angles and aim_angles.pitch and aim_angles.yaw then
14241446
-- Use normal aimbot behavior regardless of charging state
@@ -2336,6 +2358,10 @@ local function doDraw()
23362358
if oldChargeReach ~= Menu.Charge.ChargeReach then
23372359
Menu.Misc.ChargeReach = Menu.Charge.ChargeReach
23382360
end
2361+
-- Late Charge option appears only if Charge Reach enabled
2362+
if Menu.Charge.ChargeReach then
2363+
Menu.Charge.LateCharge = ImMenu.Checkbox("Late Charge", Menu.Charge.LateCharge)
2364+
end
23392365
ImMenu.EndFrame()
23402366

23412367
ImMenu.BeginFrame(1)

0 commit comments

Comments
 (0)