@@ -41,7 +41,7 @@ local Swingpred = menu:AddComponent(MenuLib.Checkbox("Enable", true, ItemFla
41
41
local Maimbot = menu :AddComponent (MenuLib .Checkbox (" Aimbot(Silent)" , true , ItemFlags .FullWidth ))
42
42
local Mchargebot = menu :AddComponent (MenuLib .Checkbox (" Charge Controll" , true , ItemFlags .FullWidth ))
43
43
-- 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 ))
45
45
local mAutoRefill = menu :AddComponent (MenuLib .Checkbox (" Crit Refill" , true ))
46
46
local Achargebot = menu :AddComponent (MenuLib .Checkbox (" Charge Reach" , true , ItemFlags .FullWidth ))
47
47
local mAutoGarden = menu :AddComponent (MenuLib .Checkbox (" Troldier assist" , false ))
@@ -144,51 +144,62 @@ end
144
144
--- @param me WPlayer
145
145
--- @return AimTarget ? target
146
146
local function GetBestTarget (me )
147
- settings = {
148
- MinDistance = 200 ,
147
+ -- Define settings for target selection
148
+ local settings = {
149
+ MinDistance = 150 ,
149
150
MaxDistance = 1000 ,
150
- MinHealth = 10 ,
151
+ MinHealth = 17 ,
151
152
MaxHealth = 100 ,
152
153
MinFOV = 0 ,
153
154
MaxFOV = mFov :GetValue (),
154
155
}
155
156
157
+ -- Get all players in the game
156
158
local players = entities .FindByClass (" CTFPlayer" )
157
159
local localPlayer = entities .GetLocalPlayer ()
158
160
if not localPlayer then return end
159
161
160
- --- @type Target[]
162
+ -- Create a table to store target factors for each player
161
163
local targetList = {}
164
+ for i = 1 , # players do
165
+ targetList [i ] = nil
166
+ end
162
167
163
- -- Calculate target factors
168
+ -- Calculate target factors for each player
164
169
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 ))
173
185
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 )
179
192
if fov > settings .MaxFOV then goto continue end
180
193
181
- local health = player :GetHealth ()
182
- -- pLocal:InCond(17)
183
-
184
-
185
-
194
+ -- Calculate player's health factor
195
+ local health = player :GetHealth ()
186
196
local distanceFactor = Math .RemapValClamped (distance , settings .MinDistance , settings .MaxDistance , 1 , 0.1 )
187
197
local healthFactor = Math .RemapValClamped (health , settings .MinHealth , settings .MaxHealth , 1 , 0.5 )
188
198
local fovFactor = Math .RemapValClamped (fov , settings .MinFOV , settings .MaxFOV , 1 , 0.5 )
189
199
200
+ -- Calculate overall factor for player
190
201
local factor = distanceFactor * healthFactor * fovFactor
191
- table.insert ( targetList , { player = player , factor = factor })
202
+ targetList [ i ] = { player = player , factor = factor }
192
203
:: continue::
193
204
end
194
205
@@ -197,8 +208,8 @@ local function GetBestTarget(me)
197
208
return a .factor > b .factor
198
209
end )
199
210
211
+ -- Select the best target
200
212
local bestTarget = nil
201
-
202
213
for _ , target in ipairs (targetList ) do
203
214
local player = target .player
204
215
local aimPos = player :GetAbsOrigin ()
@@ -208,7 +219,6 @@ local function GetBestTarget(me)
208
219
-- Set as best target
209
220
bestTarget = { entity = player , pos = aimPos , angles = angles , factor = target .factor }
210
221
break
211
-
212
222
:: continue::
213
223
end
214
224
0 commit comments