Skip to content

Commit f34b43b

Browse files
v2.5.1
1 parent be009ad commit f34b43b

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

Swing_Prediction.lua

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ function isWithinHitbox(hitbox_min_trigger, hitbox_max_trigger, pLocalFuture, vP
231231
local hitbox_min_trigger_x, hitbox_min_trigger_y, hitbox_min_trigger_z = hitbox_min_trigger:Unpack()
232232
local hitbox_max_trigger_x, hitbox_max_trigger_y, hitbox_max_trigger_z = hitbox_max_trigger:Unpack()
233233

234-
235-
vdistance = (vPlayerFuture - pLocalFuture):Length() > 200
236234
-- Check if pLocalFuture is within the hitbox
237235
if pLocalFuture.x < hitbox_min_trigger_x or pLocalFuture.x > hitbox_max_trigger_x then
238236
return false
@@ -266,21 +264,17 @@ local function OnCreateMove(pCmd, gameData)
266264
local pLocal, pWeapon, swingrange, viewheight, pLocalOrigin, pLocalClass, tickRate
267265
= gameData.pLocal, gameData.pWeapon, gameData.swingrange, gameData.viewheight, gameData.pLocalOrigin, gameData.pLocalClass, gameData.tickRate
268266
-- Use pLocal, pWeapon, pWeaponDefIndex, etc. as needed
269-
270267
if not pLocal then return end -- Immediately check if the local player exists. If it doesn't, return.
268+
if pLocalClass == nil then goto continue end
269+
if pLocalClass == 8 then return end
270+
271271
-- Initialize closest distance and closest player
272272
isMelee = pWeapon:IsMeleeWeapon() -- check if using melee weapon
273273
local closestDistance = 1200
274274
local maxDistance = 1000
275275
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
276-
if not isMelee then return end
277-
278276

279-
if pLocalClass == nil then goto continue end
280-
281-
if pLocalClass == 8 then
282-
return
283-
end
277+
if not isMelee then return end
284278

285279
-- find clsoest enemy
286280
for _, vPlayer in ipairs(players) do
@@ -298,21 +292,23 @@ if not isMelee then return end
298292
if closestDistance == 1200 then goto continue end
299293
vPlayerOrigin = closestPlayer:GetAbsOrigin()
300294

295+
301296
--[[position prediction]]--
302297
vPlayerFuture = TargetPositionPrediction(vPlayerOrigin, vPlayerOriginLast, tickRate, time)
303298
pLocalFuture = TargetPositionPrediction(pLocalOrigin, pLocalOriginLast, tickRate, time)
304299
targetFuture, targetVelocityTable = TargetPositionPrediction(pLocalOrigin, pLocalOriginLast, tickRate, time)
305-
--[[-----------------------------Swing Prediction--------------------------------]]
300+
--[[-----------------------------Swing Prediction------------------------------------------------------------------------]]
306301

307302
-- bypass problem with prior attacking with shield not beeign able to reach target..
308303
local stop = false
309304
if (pLocal:InCond(17)) and pLocalClass == 4 or pLocalClass == 8 then -- If we are charging (17 is TF_COND_SHIELD_CHARGE)
310305
stop = true
311-
dynamicstop = 150
312-
print(closestDistance)
313-
if (pCmd.forwardmove == 0) then dynamicstop = 100 end -- case if you dont hold w when charging
306+
dynamicstop = swingrange + 15
307+
if (pCmd.forwardmove == 0) then dynamicstop = swingrange + 10 end -- case if you dont hold w when charging
314308

315-
if vdistance <= dynamicstop and pLocalClass == 4 then
309+
vdistance = (vPlayerFuture - pLocalOrigin):Length()
310+
print(vdistance)
311+
if pLocalClass == 4 and vdistance <= dynamicstop then
316312
pCmd:SetButtons(pCmd:GetButtons() | IN_ATTACK)
317313
end
318314
end

0 commit comments

Comments
 (0)