@@ -231,8 +231,6 @@ function isWithinHitbox(hitbox_min_trigger, hitbox_max_trigger, pLocalFuture, vP
231
231
local hitbox_min_trigger_x , hitbox_min_trigger_y , hitbox_min_trigger_z = hitbox_min_trigger :Unpack ()
232
232
local hitbox_max_trigger_x , hitbox_max_trigger_y , hitbox_max_trigger_z = hitbox_max_trigger :Unpack ()
233
233
234
-
235
- vdistance = (vPlayerFuture - pLocalFuture ):Length () > 200
236
234
-- Check if pLocalFuture is within the hitbox
237
235
if pLocalFuture .x < hitbox_min_trigger_x or pLocalFuture .x > hitbox_max_trigger_x then
238
236
return false
@@ -266,21 +264,17 @@ local function OnCreateMove(pCmd, gameData)
266
264
local pLocal , pWeapon , swingrange , viewheight , pLocalOrigin , pLocalClass , tickRate
267
265
= gameData .pLocal , gameData .pWeapon , gameData .swingrange , gameData .viewheight , gameData .pLocalOrigin , gameData .pLocalClass , gameData .tickRate
268
266
-- Use pLocal, pWeapon, pWeaponDefIndex, etc. as needed
269
-
270
267
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
+
271
271
-- Initialize closest distance and closest player
272
272
isMelee = pWeapon :IsMeleeWeapon () -- check if using melee weapon
273
273
local closestDistance = 1200
274
274
local maxDistance = 1000
275
275
local players = entities .FindByClass (" CTFPlayer" ) -- Create a table of all players in the game
276
- if not isMelee then return end
277
-
278
276
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
284
278
285
279
-- find clsoest enemy
286
280
for _ , vPlayer in ipairs (players ) do
@@ -298,21 +292,23 @@ if not isMelee then return end
298
292
if closestDistance == 1200 then goto continue end
299
293
vPlayerOrigin = closestPlayer :GetAbsOrigin ()
300
294
295
+
301
296
--[[ position prediction]] --
302
297
vPlayerFuture = TargetPositionPrediction (vPlayerOrigin , vPlayerOriginLast , tickRate , time )
303
298
pLocalFuture = TargetPositionPrediction (pLocalOrigin , pLocalOriginLast , tickRate , time )
304
299
targetFuture , targetVelocityTable = TargetPositionPrediction (pLocalOrigin , pLocalOriginLast , tickRate , time )
305
- --[[ -----------------------------Swing Prediction--------------------------------]]
300
+ --[[ -----------------------------Swing Prediction---------------------------------------- --------------------------------]]
306
301
307
302
-- bypass problem with prior attacking with shield not beeign able to reach target..
308
303
local stop = false
309
304
if (pLocal :InCond (17 )) and pLocalClass == 4 or pLocalClass == 8 then -- If we are charging (17 is TF_COND_SHIELD_CHARGE)
310
305
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
314
308
315
- if vdistance <= dynamicstop and pLocalClass == 4 then
309
+ vdistance = (vPlayerFuture - pLocalOrigin ):Length ()
310
+ print (vdistance )
311
+ if pLocalClass == 4 and vdistance <= dynamicstop then
316
312
pCmd :SetButtons (pCmd :GetButtons () | IN_ATTACK )
317
313
end
318
314
end
0 commit comments