Skip to content

Commit dfb20e6

Browse files
v5.7.2
1 parent 9fb4803 commit dfb20e6

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

Swing_Prediction.lua

+37-27
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ local Swingpred = menu:AddComponent(MenuLib.Checkbox("Enable", true, ItemFla
4141
local Maimbot = menu:AddComponent(MenuLib.Checkbox("Aimbot(Silent)", true, ItemFlags.FullWidth))
4242
local Mchargebot = menu:AddComponent(MenuLib.Checkbox("Charge Controll", true, ItemFlags.FullWidth))
4343
--local mAutoMelee = menu:AddComponent(MenuLib.Checkbox("Auto Melee", true, ItemFlags.FullWidth))
44-
local mFov = menu:AddComponent(MenuLib.Slider("Aimbot FOV",10 ,360 ,180 ))
44+
local mFov = menu:AddComponent(MenuLib.Slider("Aimbot FOV",10 ,360 ,360 ))
4545
local mAutoRefill = menu:AddComponent(MenuLib.Checkbox("Crit Refill", true))
4646
local Achargebot = menu:AddComponent(MenuLib.Checkbox("Charge Reach", true, ItemFlags.FullWidth))
4747
local mAutoGarden = menu:AddComponent(MenuLib.Checkbox("Troldier assist", false))
@@ -144,51 +144,62 @@ end
144144
---@param me WPlayer
145145
---@return AimTarget? target
146146
local function GetBestTarget(me)
147-
settings = {
148-
MinDistance = 200,
147+
-- Define settings for target selection
148+
local settings = {
149+
MinDistance = 150,
149150
MaxDistance = 1000,
150-
MinHealth = 10,
151+
MinHealth = 17,
151152
MaxHealth = 100,
152153
MinFOV = 0,
153154
MaxFOV = mFov:GetValue(),
154155
}
155156

157+
-- Get all players in the game
156158
local players = entities.FindByClass("CTFPlayer")
157159
local localPlayer = entities.GetLocalPlayer()
158160
if not localPlayer then return end
159161

160-
---@type Target[]
162+
-- Create a table to store target factors for each player
161163
local targetList = {}
164+
for i = 1, #players do
165+
targetList[i] = nil
166+
end
162167

163-
-- Calculate target factors
168+
-- Calculate target factors for each player
164169
for i, player in pairs(players) do
165-
if not Helpers.VisPos(player, pLocalOrigin, player:GetAbsOrigin()) then goto continue end
166-
if player == localPlayer or player:GetTeamNumber() == localPlayer:GetTeamNumber() then goto continue end
167-
if player == nil or not player:IsAlive() then goto continue end
168-
if gui.GetValue("ignore cloaked") == 1 and (player:InCond(4)) then goto continue end
169-
if player:IsDormant() then goto continue end
170-
171-
local distance = (player:GetAbsOrigin() - localPlayer:GetAbsOrigin()):Length()
172-
local height_diff = math.floor(math.abs(player:GetAbsOrigin().z - localPlayer:GetAbsOrigin().z))
170+
-- Skip invalid players
171+
if player == nil
172+
or player:IsDormant()
173+
or player == localPlayer
174+
or player:GetTeamNumber() == localPlayer:GetTeamNumber()
175+
or not player:IsAlive()
176+
or gui.GetValue("ignore cloaked") == 1 and player:InCond(4)
177+
or not Helpers.VisPos(player, pLocalOrigin, player:GetAbsOrigin())
178+
then
179+
goto continue
180+
end
181+
182+
-- Calculate distance and height difference to player
183+
local distance = (player:GetAbsOrigin() - localPlayer:GetAbsOrigin()):Length()
184+
local height_diff = math.floor(math.abs(player:GetAbsOrigin().z - localPlayer:GetAbsOrigin().z))
173185

174-
if height_diff > 180
175-
or distance > 700 then goto continue end
176-
-- Visibility Check
177-
local angles = Math.PositionAngles(localPlayer:GetAbsOrigin(), player:GetAbsOrigin())
178-
local fov = Math.AngleFov(engine.GetViewAngles(), angles)
186+
-- Skip players that are too far away or too high
187+
if height_diff > 180 or distance > 700 then goto continue end
188+
189+
-- Calculate player's FOV and skip if it's too high
190+
local angles = Math.PositionAngles(localPlayer:GetAbsOrigin(), player:GetAbsOrigin())
191+
local fov = Math.AngleFov(engine.GetViewAngles(), angles)
179192
if fov > settings.MaxFOV then goto continue end
180193

181-
local health = player:GetHealth()
182-
--pLocal:InCond(17)
183-
184-
185-
194+
-- Calculate player's health factor
195+
local health = player:GetHealth()
186196
local distanceFactor = Math.RemapValClamped(distance, settings.MinDistance, settings.MaxDistance, 1, 0.1)
187197
local healthFactor = Math.RemapValClamped(health, settings.MinHealth, settings.MaxHealth, 1, 0.5)
188198
local fovFactor = Math.RemapValClamped(fov, settings.MinFOV, settings.MaxFOV, 1, 0.5)
189199

200+
-- Calculate overall factor for player
190201
local factor = distanceFactor * healthFactor * fovFactor
191-
table.insert(targetList, { player = player, factor = factor})
202+
targetList[i] = { player = player, factor = factor}
192203
::continue::
193204
end
194205

@@ -197,8 +208,8 @@ local function GetBestTarget(me)
197208
return a.factor > b.factor
198209
end)
199210

211+
-- Select the best target
200212
local bestTarget = nil
201-
202213
for _, target in ipairs(targetList) do
203214
local player = target.player
204215
local aimPos = player:GetAbsOrigin()
@@ -208,7 +219,6 @@ local function GetBestTarget(me)
208219
-- Set as best target
209220
bestTarget = { entity = player, pos = aimPos, angles = angles, factor = target.factor }
210221
break
211-
212222
::continue::
213223
end
214224

0 commit comments

Comments
 (0)