Skip to content

Commit c0810f2

Browse files
Add files via upload
1 parent 0d18c92 commit c0810f2

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

Swing_Prediction.lua

+34-26
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ menu.Style.Outline = true -- Outline around the menu
3737
end, ItemFlags.FullWidth))]]
3838
local Swingpred = menu:AddComponent(MenuLib.Checkbox("Enable", true, ItemFlags.FullWidth))
3939
local Maimbot = menu:AddComponent(MenuLib.Checkbox("Aimbot(Rage)", true, ItemFlags.FullWidth))
40-
local mtime = menu:AddComponent(MenuLib.Slider("attack delay(ticks)",6 ,30 ,17 ))
40+
local mtime = menu:AddComponent(MenuLib.Slider("attack delay(ticks)",3 ,20 ,14 ))
4141
local mAutoRefill = menu:AddComponent(MenuLib.Checkbox("Crit Refill", true))
4242
local mAutoGarden = menu:AddComponent(MenuLib.Checkbox("Troldier assist", false))
4343
local mmVisuals = menu:AddComponent(MenuLib.Checkbox("Enable Visuals", false))
@@ -74,6 +74,7 @@ local vdistance
7474
local fDistance
7575
local vPlayerFuture
7676
local pLocalFuture
77+
local ping = 0
7778

7879
function GetClosestEnemy(pLocal, pLocalOrigin)
7980
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
@@ -153,7 +154,7 @@ function TargetPositionPrediction(targetLastPos, tickRate, time, targetEntity)
153154
end
154155

155156
--if time is more then 5 then expect ticks and convert ticks into decimal of time
156-
if time > 5 then
157+
if time > 2 then
157158
time = time / tickRate
158159
end
159160

@@ -220,8 +221,8 @@ local function OnCreateMove(pCmd)
220221
--[--if we are not existign then stop code--]
221222
pLocal = entities.GetLocalPlayer() -- Immediately set "pLocal" to the local player (entities.GetLocalPlayer)
222223
if not pLocal then return end -- Immediately check if the local player exists. If it doesn't, return.
223-
224-
--[--Check local player class if spy or none then stop code--]
224+
ping = entities.GetPlayerResources():GetPropDataTableInt("m_iPing")[pLocal:GetIndex()]
225+
--[--Check local player class if spy or none then stop code--]
225226

226227
pLocalClass = pLocal:GetPropInt("m_iClass") --getlocalclass
227228
if pLocalClass == nil then goto continue end --when local player did not chose class then skip code
@@ -282,31 +283,16 @@ local function OnCreateMove(pCmd)
282283
if closestPlayer == nil then
283284
if mAutoRefill:GetValue() and pWeapon:GetCritTokenBucket() <= 27 then
284285
pCmd:SetButtons(pCmd:GetButtons() | IN_ATTACK)
285-
end goto continue
286+
end goto continue
286287
end
287288

288289
vPlayerOrigin = closestPlayer:GetAbsOrigin()
289290

290-
--[--------------AutoAim-------------------]
291-
if Maimbot:GetValue() then
292-
--get hitbox of ennmy pelwis(jittery but works)
293-
local hitboxes = closestPlayer:GetHitboxes()
294-
local hitbox = hitboxes[4]
295-
local angles = (hitbox[1] + hitbox[2]) * 0.5
296-
-- Aim at the target
297-
angles = Math.PositionAngles(pLocalOrigin, angles)
298-
pCmd:SetViewAngles(angles:Unpack())
299-
--[[if not options.Silent then
300-
engine.SetViewAngles(angles)
301-
--end]]
302-
end
303-
304-
305291
--[--------------Prediction-------------------] -- predict both players position after swing
306292

307293
vPlayerFuture = TargetPositionPrediction(vPlayerOrigin, tickRate, time, closestPlayer)
308294
pLocalFuture = TargetPositionPrediction(pLocalOrigin, tickRate, time, pLocal)
309-
295+
310296
--[--------------Distance check-------------------]
311297
--get current distance between local player and closest player
312298
vdistance = (vPlayerOrigin - pLocalOrigin):Length()
@@ -319,7 +305,7 @@ end
319305
local stop = false
320306
swingrange = pWeapon:GetSwingRange()
321307

322-
-- bypass problem with prior attacking with shield not beeign able to reach target..
308+
--[bypass problem with prior attacking with shield not beeign able to reach target]..
323309
if (pLocal:InCond(17)) and pLocalClass == 4 or pLocalClass == 8 then -- If we are charging (17 is TF_COND_SHIELD_CHARGE)
324310
stop = true
325311
local dynamicstop = swingrange
@@ -331,10 +317,32 @@ end
331317
end
332318
end
333319

334-
--wall check
335-
local trace = engine.TraceLine(pLocalFuture, vPlayerFuture, MASK_SHOT_HULL)
336-
if (trace.entity:GetClass() == "CTFPlayer") and (trace.entity:GetTeamNumber() ~= pLocal:GetTeamNumber()) then
320+
--[--------------AimBot-------------------]
321+
if Maimbot:GetValue() and Helpers.VisPos(closestPlayer,vPlayerFuture + Vector3(0, 0, 150), pLocalFuture) then
322+
--get hitbox of ennmy pelwis(jittery but works)
323+
local hitboxes = closestPlayer:GetHitboxes()
324+
local hitbox = hitboxes[4]
325+
local aimpos = (hitbox[1] + hitbox[2]) * 0.5
326+
327+
if pLocal:InCond(17) then -- if can hit then aimbot
328+
-- change angles at target
329+
aimpos = Math.PositionAngles(pLocalOrigin, vPlayerFuture + Vector3(0, 0, 60))
330+
pCmd:SetViewAngles(aimpos:Unpack()) --engine.SetViewAngles(aimpos)
331+
332+
else -- if predicted position is visible then aim at it
333+
-- change angles at target
334+
aimpos = Math.PositionAngles(pLocalOrigin, aimpos)
335+
pCmd:SetViewAngles(aimpos:Unpack())
336+
end
337+
end
337338

339+
--[----------------wall check Future-------------]
340+
341+
--trace = engine.TraceLine(pLocalFuture, vPlayerFuture + Vector3(0, 0, 150), MASK_SHOT_HULL)
342+
--if (trace.entity:GetClass() == "CTFPlayer") and (trace.entity:GetTeamNumber() ~= pLocal:GetTeamNumber()) then
343+
-- Visiblity Check
344+
if Helpers.VisPos(closestPlayer,vPlayerFuture + Vector3(0, 0, 150), pLocalFuture) then
345+
--[[check if can hit after swing]]
338346
can_attack = isWithinHitbox(GetTriggerboxMin(swingrange, vPlayerFuture), GetTriggerboxMax(swingrange, vPlayerFuture), pLocalFuture, vPlayerFuture)
339347

340348
if fDistance <= (swingrange + 60) then
@@ -344,7 +352,7 @@ end
344352
elseif can_attack == false then
345353
can_attack = isWithinHitbox(GetTriggerboxMin(swingrange, vPlayerOrigin), GetTriggerboxMax(swingrange, vPlayerOrigin), pLocalOrigin, vPlayerOrigin)
346354
end
347-
end
355+
end
348356

349357

350358
--Attack when futere position is inside attack range triggerbox

0 commit comments

Comments
 (0)