Skip to content

Commit be5f7f5

Browse files
v5.2.0
1 parent 0f10279 commit be5f7f5

File tree

1 file changed

+111
-79
lines changed

1 file changed

+111
-79
lines changed

Swing_Prediction.lua

+111-79
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ end, ItemFlags.FullWidth))]]
4040
local Swingpred = menu:AddComponent(MenuLib.Checkbox("Enable", true, ItemFlags.FullWidth))
4141
local Maimbot = menu:AddComponent(MenuLib.Checkbox("Aimbot(Silent)", true, ItemFlags.FullWidth))
4242
local Mchargebot = menu:AddComponent(MenuLib.Checkbox("charge steer", true, ItemFlags.FullWidth))
43-
local mFov = menu:AddComponent(MenuLib.Slider("Aimbot FOV",10 ,360 ,180 ))
43+
local mFov = menu:AddComponent(MenuLib.Slider("Aimbot FOV",10 ,180 ,180 ))
4444
local mAutoRefill = menu:AddComponent(MenuLib.Checkbox("Crit Refill", true))
4545
local Achargebot = menu:AddComponent(MenuLib.Checkbox("Charge Reach", true, ItemFlags.FullWidth))
4646
local mAutoGarden = menu:AddComponent(MenuLib.Checkbox("Troldier assist", false))
@@ -76,6 +76,7 @@ local vdistance
7676
local vPlayerFuture
7777
local vPlayerOrigin
7878
local vPlayerOriginLast
79+
local chargeLeft
7980

8081
local pivot
8182
local can_charge = false
@@ -116,6 +117,7 @@ local function GetBestTarget(me)
116117

117118
local angles = Math.PositionAngles(localPlayer:GetAbsOrigin(), player:GetAbsOrigin())
118119
local fov = Math.AngleFov(engine.GetViewAngles(), angles)
120+
if fov > settings.MaxFOV then goto continue end
119121

120122
local distanceFactor = Math.RemapValClamped(distance, settings.MinDistance, settings.MaxDistance, 1, 0.1)
121123
local healthFactor = Math.RemapValClamped(health, settings.MinHealth, settings.MaxHealth, 1, 0.5)
@@ -139,11 +141,11 @@ local function GetBestTarget(me)
139141
local aimPos = player:GetAbsOrigin()
140142
local angles = Math.PositionAngles(localPlayer:GetAbsOrigin(), aimPos)
141143
local fov = Math.AngleFov(angles, engine.GetViewAngles())
142-
if fov > settings.MaxFOV then goto continue end
143144
if gui.GetValue("ignore cloaked") == 1 and (target.player:InCond(4)) then goto continue end
144145

145146
-- Visibility Check
146147
if not Helpers.VisPos(player, pLocalOrigin, aimPos) then goto continue end
148+
147149
if target.player == nil or not target.player:IsAlive() or target.player:GetTeamNumber() == pLocal:GetTeamNumber() then goto continue end
148150

149151
-- Set as best target
@@ -247,7 +249,7 @@ local function OnCreateMove(pCmd)
247249
pLocal = entities.GetLocalPlayer() -- Immediately set "pLocal" to the local player (entities.GetLocalPlayer)
248250
if not pLocal then return end -- Immediately check if the local player exists. If it doesn't, return.
249251
ping = entities.GetPlayerResources():GetPropDataTableInt("m_iPing")[pLocal:GetIndex()]
250-
local chargeLeft = pLocal:GetPropFloat( "m_flChargeMeter" )
252+
chargeLeft = pLocal:GetPropFloat( "m_flChargeMeter" )
251253
--[--Check local player class if spy or none then stop code--]
252254

253255
pLocalClass = pLocal:GetPropInt("m_iClass") --getlocalclass
@@ -362,11 +364,6 @@ end
362364
local stop = false
363365
swingrange = pWeapon:GetSwingRange()
364366

365-
--[----------------wall check Future-------------]
366-
367-
-- Visiblity Check
368-
if not Helpers.VisPos(closestPlayer,vPlayerFuture + Vector3(0, 0, 150), pLocalFuture) then goto continue end-- Visiblity Check
369-
370367
--[[check if can hit after swing]]
371368
-- Simulate swing and return result
372369
local collisionPoint
@@ -386,10 +383,11 @@ if not Helpers.VisPos(closestPlayer,vPlayerFuture + Vector3(0, 0, 150), pLocalFu
386383

387384
if Achargebot:GetValue() and chargeLeft >= 100.0 then
388385
collision, collisionPoint = checkCollision(vPlayerFuture, pLocalOrigin, (swingrange * 1.5)) --increased range when in charge
386+
local Tolerance1 = time - 16
389387
if collision then
390388
can_attack = true
391389
tick_count = tick_count + 1
392-
if tick_count % 6 == 0 then
390+
if tick_count % Tolerance1 == 0 then
393391
can_charge = true
394392
end
395393
end
@@ -591,77 +589,111 @@ if not mmVisuals:GetValue() then return end
591589
end
592590
end
593591

594-
if mVisuals:IsSelected("Range Circle") == false then return end
595-
if vPlayerFuture == nil then return end
596-
if not isMelee then return end
597-
598-
-- Define the two colors to interpolate between
599-
local color_close = {r = 255, g = 0, b = 0, a = 255} -- red
600-
local color_far = {r = 0, g = 0, b = 255, a = 255} -- blue
601-
602-
-- Calculate the target distance for the color to be completely at the close color
603-
local target_distance = swingrange
604-
605-
-- Calculate the vertex positions around the circle
606-
local center = pLocalFuture + Vector3(0, 0, -70) -- center of the circle
607-
local radius = swingrange -- radius of the circle
608-
local segments = 64 -- number of segments to use for the circle
609-
vertices = {} -- table to store circle vertices
610-
local colors = {} -- table to store colors for each vertex
611-
612-
for i = 1, segments do
613-
local angle = math.rad(i * (360 / segments))
614-
local direction = Vector3(math.cos(angle), math.sin(angle), 0)
615-
local endpos = center + direction * radius
616-
local trace = engine.TraceLine(vPlayerFuture, endpos, MASK_SHOT_HULL)
617-
618-
local distance_to_hit = (trace.endpos - center):Length()
619-
if distance_to_hit > radius then
620-
distance_to_hit = radius
621-
end
622-
623-
local x = center.x + math.cos(angle) * distance_to_hit
624-
local y = center.y + math.sin(angle) * distance_to_hit
625-
local z = center.z + 1
626-
627-
-- adjust the height based on distance to trace hit point
628-
if distance_to_hit > 0 then
629-
local max_height_adjustment = mTHeightt -- adjust as needed
630-
local height_adjustment = (1 - distance_to_hit / radius) * max_height_adjustment
631-
z = z + height_adjustment
632-
end
633-
634-
vertices[i] = client.WorldToScreen(Vector3(x, y, z))
635-
636-
-- calculate the color for this line based on the height of the point
637-
local t = (z - center.z - target_distance) / (mTHeightt - target_distance)
638-
if t < 0 then
639-
t = 0
640-
elseif t > 1 then
641-
t = 1
642-
end
643-
local color = {}
644-
for key, value in pairs(color_close) do
645-
color[key] = math.floor((1 - t) * value + t * color_far[key])
646-
end
647-
colors[i] = color
648-
end
592+
-- Check if the range circle is selected, the player future is not nil, and the player is melee
593+
if not mVisuals:IsSelected("Range Circle") or not vPlayerFuture or not isMelee then
594+
return
595+
end
649596

650-
-- Calculate the top vertex position
651-
local top_height = mTHeightt -- adjust as needed
652-
local top_vertex = client.WorldToScreen(Vector3(center.x, center.y, center.z + top_height))
653-
654-
-- Draw the circle and connect all the vertices to the top point
655-
for i = 1, segments do
656-
local j = i + 1
657-
if j > segments then j = 1 end
658-
if vertices[i] ~= nil and vertices[j] ~= nil then
659-
draw.Color(colors[i].r, colors[i].g, colors[i].b, colors[i].a)
660-
draw.Line(vertices[i][1], vertices[i][2], vertices[j][1], vertices[j][2])
661-
--draw.Line(vertices[i][1], vertices[i][2], top_vertex[1], top_vertex[2])
662-
663-
end
664-
end
597+
-- Define the two colors to interpolate between
598+
local color_close = {r = 255, g = 0, b = 0, a = 255} -- red
599+
local color_far = {r = 0, g = 0, b = 255, a = 255} -- blue
600+
601+
-- Calculate the target distance for the color to be completely at the close color
602+
local target_distance = swingrange
603+
604+
-- Calculate the vertex positions around the circle
605+
local center = pLocalFuture + Vector3(0, 0, -70) -- center of the circle
606+
local radius = swingrange -- radius of the circle
607+
local segments = 64 -- number of segments to use for the circle
608+
local vertices = {} -- table to store circle vertices
609+
local colors = {} -- table to store colors for each vertex
610+
611+
for i = 1, segments do
612+
local angle = math.rad(i * (360 / segments))
613+
local direction = Vector3(math.cos(angle), math.sin(angle), 0)
614+
local endpos = center + direction * radius
615+
local trace = engine.TraceLine(vPlayerFuture, endpos, MASK_SHOT_HULL)
616+
617+
local distance_to_hit = math.min((trace.endpos - center):Length(), radius)
618+
619+
local x = center.x + math.cos(angle) * distance_to_hit
620+
local y = center.y + math.sin(angle) * distance_to_hit
621+
local z = center.z + 1
622+
623+
-- adjust the height based on distance to trace hit point
624+
if distance_to_hit > 0 then
625+
local max_height_adjustment = mTHeightt -- adjust as needed
626+
local height_adjustment = (1 - distance_to_hit / radius) * max_height_adjustment
627+
z = z + height_adjustment
628+
end
629+
630+
vertices[i] = client.WorldToScreen(Vector3(x, y, z))
631+
632+
-- calculate the color for this line based on the height of the point
633+
local t = math.max(math.min((z - center.z - target_distance) / (mTHeightt - target_distance), 1), 0)
634+
local color = {}
635+
for key, value in pairs(color_close) do
636+
color[key] = math.floor((1 - t) * value + t * color_far[key])
637+
end
638+
colors[i] = color
639+
end
640+
641+
-- Calculate the top vertex position
642+
local top_height = mTHeightt -- adjust as needed
643+
local top_vertex = client.WorldToScreen(Vector3(center.x, center.y, center.z + top_height))
644+
645+
-- Draw the circle and connect all the vertices to the top point
646+
for i = 1, segments do
647+
local j = i + 1
648+
if j > segments then j = 1 end
649+
if vertices[i] and vertices[j] then
650+
draw.Color(colors[i].r, colors[i].g, colors[i].b, colors[i].a)
651+
draw.Line(vertices[i][1], vertices[i][2], vertices[j][1], vertices[j][2])
652+
end
653+
end
654+
655+
-- Draw a second circle if Achargebot is enabled
656+
if Achargebot:GetValue() and chargeLeft >= 100 then
657+
-- Define the color for the second circle
658+
local color = {r = 0, g = 0, b = 255, a = 255} -- blue
659+
660+
-- Calculate the radius for the second circle
661+
local radius2 = radius * 1.5
662+
663+
-- Calculate the vertex positions around the second circle
664+
local vertices2 = {} -- table to store circle vertices
665+
for i = 1, segments do
666+
local angle = math.rad(i * (360 / segments))
667+
local direction = Vector3(math.cos(angle), math.sin(angle), 0)
668+
local endpos = center + direction * radius2
669+
local trace = engine.TraceLine(vPlayerFuture, endpos, MASK_SHOT_HULL)
670+
671+
local distance_to_hit = math.min((trace.endpos - center):Length(), radius2)
672+
673+
local x = center.x + math.cos(angle) * distance_to_hit
674+
local y = center.y + math.sin(angle) * distance_to_hit
675+
local z = center.z + 1
676+
677+
-- adjust the height based on distance to trace hit point
678+
if distance_to_hit > 0 then
679+
local max_height_adjustment = mTHeightt -- adjust as needed
680+
local height_adjustment = (1 - distance_to_hit / radius2) * max_height_adjustment
681+
z = z + height_adjustment
682+
end
683+
684+
vertices2[i] = client.WorldToScreen(Vector3(x, y, z))
685+
end
686+
687+
-- Draw the second circle and connect all the vertices to the top point
688+
for i = 1, segments do
689+
local j = i + 1
690+
if j > segments then j = 1 end
691+
if vertices2[i] and vertices2[j] then
692+
draw.Color(color.r, color.g, color.b, color.a)
693+
draw.Line(vertices2[i][1], vertices2[i][2], vertices2[j][1], vertices2[j][2])
694+
end
695+
end
696+
end
665697
end
666698

667699
--[[ Remove the menu when unloaded ]]--

0 commit comments

Comments
 (0)