Skip to content

Commit 8131726

Browse files
v5.8.0
1 parent b7071dd commit 8131726

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

Swing_Prediction.lua

+35-19
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ local Mchargebot = menu:AddComponent(MenuLib.Checkbox("Charge Controll", true
4343
--local mAutoMelee = menu:AddComponent(MenuLib.Checkbox("Auto Melee", true, ItemFlags.FullWidth))
4444
local mFov = menu:AddComponent(MenuLib.Slider("Aimbot FOV",10 ,360 ,360 ))
4545
local mAutoRefill = menu:AddComponent(MenuLib.Checkbox("Crit Refill", true))
46-
local Achargebot = menu:AddComponent(MenuLib.Checkbox("Charge Reach", true, ItemFlags.FullWidth))
46+
local AchargeRange = menu:AddComponent(MenuLib.Checkbox("Charge Reach", true, ItemFlags.FullWidth))
4747
local mAutoGarden = menu:AddComponent(MenuLib.Checkbox("Troldier assist", false))
4848
local mmVisuals = menu:AddComponent(MenuLib.Checkbox("Enable Visuals", false))
4949
local mKeyOverrite = menu:AddComponent(MenuLib.Keybind("Manual overide", key))
@@ -67,9 +67,13 @@ local pLocal = entities.GetLocalPlayer()
6767
local vdistance = 1
6868
local ping = 0
6969
local swingrange = 70
70-
local time = 16
7170
local tickRate = 66
7271
local tick_count = 0
72+
local in_attack
73+
74+
local time = 17
75+
local last_time = time
76+
local swing_delay = time
7377

7478
local pLocalClass = nil
7579
local pLocalFuture = nil
@@ -187,6 +191,7 @@ local function GetBestTarget(me)
187191

188192
local factor = distanceFactor * healthFactor * fovFactor
189193
targetCount = targetCount + 1
194+
190195
targetList[targetCount] = { player = player, factor = factor }
191196

192197
::continue::
@@ -216,7 +221,7 @@ end
216221

217222
-- Predicts player position after set amount of ticks
218223
---@param targetLastPos Vector3
219-
---@param time integer
224+
---@param Ltime integer
220225
---@param targetEntity number
221226
---@param strafeAngle number
222227
---@return Vector3?
@@ -310,7 +315,7 @@ local Hitbox = {
310315
Chest = 7
311316
}
312317

313-
function UpdateViewAngles(pCmd)
318+
local function ChargeControll(pCmd)
314319
-- Get the current view angles
315320
local sensetivity = client.GetConVar("sensitivity") + 2 --mSensetivity:GetValue() / 10 --0.4
316321
local currentAngles = engine.GetViewAngles()
@@ -335,7 +340,8 @@ local function OnCreateMove(pCmd)
335340
end
336341
local flags = pLocal:GetPropInt("m_fFlags")
337342
--[[ping = entities.GetPlayerResources():GetPropDataTableInt("m_iPing")[pLocal:GetIndex()]]
338-
chargeLeft = pLocal:GetPropInt("m_flChargeMeter")
343+
chargeLeft = pLocal:GetPropFloat("m_flChargeMeter")
344+
chargeLeft = math.floor(chargeLeft)
339345

340346
--[--Check local player class if spy or none then stop code--]
341347

@@ -357,6 +363,7 @@ local function OnCreateMove(pCmd)
357363
-- Convert the delay to ticks
358364
Latency = math.floor(Latency * tickRate + 1)
359365

366+
360367
-- Add the ticks to the current time
361368
--time = time + Latency - Tolerances
362369

@@ -369,12 +376,11 @@ local function OnCreateMove(pCmd)
369376
if not pWeapon then
370377
return
371378
end
372-
379+
local pWeaponData = pWeapon:GetWeaponData()
373380
local pWeaponDefIndex = pWeapon:GetPropInt("m_iItemDefinitionIndex") -- Set "pWeaponDefIndex" to the "pWeapon"'s item definition index
374381
local pWeaponDef = itemschema.GetItemDefinitionByID(pWeaponDefIndex) -- Set "pWeaponDef" to the local "pWeapon"'s item definition
375382
local pWeaponName = pWeaponDef:GetName()
376383
swingrange = pWeapon:GetSwingRange()
377-
378384
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
379385
if #players == 0 then
380386
return -- Immediately check if there are any players in the game. If there aren't, return.
@@ -452,7 +458,7 @@ end]]--
452458
-- Manual charge control
453459

454460
if Mchargebot:GetValue() and pLocal:InCond(17) then
455-
UpdateViewAngles(pCmd)
461+
ChargeControll(pCmd)
456462
end
457463

458464
--[-----Get best target------------------]
@@ -554,7 +560,9 @@ collision, collisionPoint = checkCollision(vPlayerFuture, pLocalFuture, swingran
554560

555561
end
556562

557-
if pLocalClass == 4 and Achargebot:GetValue() and chargeLeft >= 100 then -- Check for collision during charge
563+
-- Check for charge range
564+
print(chargeLeft)
565+
if pLocalClass == 4 and AchargeRange:GetValue() and chargeLeft == 100 then -- Check for collision during charge
558566
collision = checkCollision(vPlayerFuture, pLocalOrigin, (swingrange * 1.5))
559567
if collision then
560568
can_attack = true
@@ -598,38 +606,46 @@ collision, collisionPoint = checkCollision(vPlayerFuture, pLocalFuture, swingran
598606

599607
elseif not inAttackAim and Mchargebot:GetValue() and pLocal:InCond(17) then --manual charge controll
600608
-- Calculate the source and destination vectors
601-
UpdateViewAngles(pCmd)
609+
ChargeControll(pCmd)
602610
end
603611

604612
--[shield bashing strat]
605613

606614
if pLocalClass == 4 and (pLocal:InCond(17)) then -- If we are charging (17 is TF_COND_SHIELD_CHARGE)
607-
local collision1 = checkCollision(vPlayerFuture, pLocalOrigin, 18)
615+
local Bashed = checkCollision(vPlayerFuture, pLocalOrigin, 18)
608616

609-
if not collision1 then -- if demoknight bashed on enemy
617+
if not Bashed then -- if demoknight bashed on enemy
610618
can_attack = false
611619
goto continue
612620
end
613621
end
614622

615623
--Check if attack simulation was succesfull
616-
if can_attack then
617-
624+
if can_attack == true then
625+
--remove tick
626+
time = time - 1
627+
618628
pCmd:SetButtons(pCmd:GetButtons() | IN_ATTACK)-- attack
619629

620-
elseif mAutoRefill:GetValue() then
621-
if pWeapon:GetCritTokenBucket() <= 27 and fDistance > 400 then
630+
elseif mAutoRefill:GetValue() == true then
631+
if pWeapon:GetCritTokenBucket() <= 27 and fDistance > 350 then
622632
pCmd:SetButtons(pCmd:GetButtons() | IN_ATTACK)--refill
623633
end
634+
else
635+
time = swing_delay
624636
end
625637

626638
if can_charge then
627639
pCmd:SetButtons(pCmd:GetButtons() | IN_ATTACK2)-- charge
628640
end
629-
641+
642+
if time % swing_delay == 0 or time == last_time then
643+
time = swing_delay
644+
end
630645

631646

632647
-- Update last variables
648+
last_time = time
633649
Safe_Strafe = false -- reset safe strafe
634650
::continue::
635651
end
@@ -815,8 +831,8 @@ if not mmVisuals:GetValue() or not pWeapon:IsMeleeWeapon() then return end
815831
end
816832
end
817833

818-
-- Draw a second circle if Achargebot is enabled
819-
if pLocalClass == 4 and Achargebot:GetValue() and chargeLeft >= 100 then
834+
-- Draw a second circle if AchargeRange is enabled
835+
if pLocalClass == 4 and AchargeRange:GetValue() and chargeLeft >= 100 then
820836
-- Define the color for the second circle
821837
local color = {r = 0, g = 0, b = 255, a = 255} -- blue
822838

0 commit comments

Comments
 (0)