Skip to content

Commit 5fc9f44

Browse files
v4.0.3
made code more readable
1 parent f89d1b8 commit 5fc9f44

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

Swing_Prediction.lua

+26-30
Original file line numberDiff line numberDiff line change
@@ -214,38 +214,26 @@ local Hitbox = {
214214
Chest = 7
215215
}
216216

217-
local options = {
218-
AutoShoot = true,
219-
Silent = false,
220-
AimPos = Hitbox.Pelvis,
221-
AimFov = 360
222-
}
223-
224-
local currentTarget = nil
225-
226-
local function CalculateAngle(fromPos, toPos)
227-
local delta = toPos - fromPos
228-
local angle = math.atan(delta.y, delta.x) * 180 / math.pi
229-
return angle
230-
end
231-
232217
--[[ Code needed to run 66 times a second ]]--
233218
local function OnCreateMove(pCmd)
234219
if not Swingpred:GetValue() then goto continue end -- enable or distable script
235-
220+
--[--if we are not existign then stop code--]
236221
pLocal = entities.GetLocalPlayer() -- Immediately set "pLocal" to the local player (entities.GetLocalPlayer)
237222
if not pLocal then return end -- Immediately check if the local player exists. If it doesn't, return.
238223

239-
pLocalClass = pLocal:GetPropInt("m_iClass") --getlocalclass
224+
--[--Check local player class if spy or none then stop code--]
225+
226+
pLocalClass = pLocal:GetPropInt("m_iClass") --getlocalclass
240227
if pLocalClass == nil then goto continue end --when local player did not chose class then skip code
241228
if pLocalClass == 8 then goto continue end --when local player is spy then skip code
242-
local pWeapon = pLocal:GetPropEntity("m_hActiveWeapon")
243-
244-
local flags = pLocal:GetPropInt( "m_fFlags" )
245-
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
246-
local time = mtime:GetValue()
247229

230+
--[--obtain secondary information after confirming we need it for fps boost whe nnot using script]
231+
local pWeapon = pLocal:GetPropEntity("m_hActiveWeapon")
232+
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
233+
local time = mtime:GetValue()
234+
--[--if we enabled trodlier assist run auto weapon script]
248235
if mAutoGarden:GetValue() == true then
236+
local flags = pLocal:GetPropInt( "m_fFlags" )
249237
local bhopping = false
250238
local state = ""
251239
local downheight = Vector3(0, 0, -250)
@@ -268,11 +256,14 @@ local function OnCreateMove(pCmd)
268256
pCmd:SetButtons(pCmd.buttons & (~IN_DUCK))
269257
end
270258
end
259+
260+
--[-Don`t run script below when not usign melee--]
271261

272-
-- Initialize closest distance and closest player
273262
isMelee = pWeapon:IsMeleeWeapon() -- check if using melee weapon
274263
if not isMelee then goto continue end -- if not melee then skip code
275-
--try get vierwhegiht without crash
264+
265+
--[-------get vierwhegiht Optymised--------]
266+
276267
if pLocalClass ~= pLocalClasslast then
277268
if pLocal == nil then pLocalOrigin = pLocal:GetAbsOrigin() return pLocalOrigin end
278269
--get pLocal eye level and set vector at our eye level to ensure we cehck distance from eyes
@@ -284,8 +275,10 @@ local function OnCreateMove(pCmd)
284275
pLocalOrigin = (pLocal:GetAbsOrigin() + Vheight)
285276
end
286277

278+
--[-----Get closestPlayer------------------]
287279
closestPlayer = GetClosestEnemy(pLocal, pLocalOrigin, players)
288-
-- handle lack of enemies
280+
--[-----Refil and skip code when alone-----]
281+
289282
if closestPlayer == nil then
290283
if mAutoRefill:GetValue() and pWeapon:GetCritTokenBucket() <= 27 then
291284
pCmd:SetButtons(pCmd:GetButtons() | IN_ATTACK)
@@ -294,7 +287,7 @@ end
294287

295288
vPlayerOrigin = closestPlayer:GetAbsOrigin()
296289

297-
--[--------------AutoAim-------------------]
290+
--[--------------AutoAim-------------------]
298291
if Maimbot:GetValue() then
299292
--get hitbox of ennmy pelwis(jittery but works)
300293
local hitboxes = closestPlayer:GetHitboxes()
@@ -308,15 +301,18 @@ end
308301
--end]]
309302
end
310303

311-
--get current distance between local player and closest player
312-
vdistance = (vPlayerOrigin - pLocalOrigin):Length()
313304

314-
-- predict both players position after swing
305+
--[--------------Prediction-------------------] -- predict both players position after swing
306+
315307
vPlayerFuture = TargetPositionPrediction(vPlayerOrigin, tickRate, time, closestPlayer)
316308
pLocalFuture = TargetPositionPrediction(pLocalOrigin, tickRate, time, pLocal)
317309

310+
--[--------------Distance check-------------------]
311+
--get current distance between local player and closest player
312+
vdistance = (vPlayerOrigin - pLocalOrigin):Length()
313+
318314
-- get distance between local player and closest player after swing
319-
fDistance = (vPlayerFuture - pLocalFuture):Length()
315+
fDistance = (vPlayerFuture - pLocalFuture):Length()
320316

321317
--[[-----------------------------Swing Prediction------------------------------------------------------------------------]]
322318
local can_attack = false

0 commit comments

Comments
 (0)