-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadvancededgebug.lua
281 lines (239 loc) · 9.6 KB
/
advancededgebug.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
--name advancededgebug
--desc bug the edge. (advanced)
--author sekc, vampur
-- Settings
EDGEBUG_FOUND_SOUND = "common/warning"
EDGEBUG_SOUND = "buttons/blip1"
local ffi = require("ffi")
-- Get Globals
ffi.cdef([[
typedef struct {
float realtime;
int framecount;
float absoluteframetime;
float absoluteframestarttimestddev;
float curtime;
float frametime;
int maxClients;
int tickcount;
float tickInterval;
float interpolation_amount;
int simTicksThisFrame;
int network_protocol;
void* pSaveData;
bool m_bClient;
bool m_bRemoteClient;
} Globals;
]])
local hudUpdate = ffi.cast("void***", memory.getInterface("./csgo/bin/linux64/client_client.so", "VClient"))[0][11]
local globals = ffi.cast("Globals**", memory.getAbsoluteAddress(tonumber(ffi.cast("uintptr_t", hudUpdate)) + 13, 3, 7))
local lastTickVel = Vector(0, 0, 0)
local sv_gravity = eclipse.getConvar("sv_gravity")
local function detectEdgebug(localPlayer)
local edgebugZVel = sv_gravity:getFloat() * 0.5 * globals[0][0].tickInterval
return math.floor(math.abs(localPlayer:velocity().z)) == math.floor(math.abs(edgebugZVel)) and lastTickVel.z < -edgebugZVel
end
local successfulMove = {
found = false, forwardmove = 0, sidemove = 0, angle = QAngle(0, 0, 0), delta = QAngle(0, 0, 0), buttons = 0, edgebugTick = 0
}
local backupMove = {
forwardmove = 0, sidemove = 0, buttons = 0, angle = QAngle(0, 0, 0), delta = QAngle(0, 0, 0)
}
local binBrute = {
highestGround = -1337420, searchDir = 1, ticksToGround = 0
}
-- if edgebug found force cmd to follow this edgebug
local function forceEdgebug(cmd, localPlayer)
if successfulMove.found then
-- disable edgebug if past found edgebug tick
if cmd.tickcount > successfulMove.edgebugTick then
eclipse.clientCmd("play " .. EDGEBUG_SOUND)
successfulMove.found = false
return
end
-- if edgebug is already found then set buttons to the buttons to hit edgebug with (also set forwardmove+sidemove to 0)
cmd.buttons = successfulMove.buttons
successfulMove.angle = QAngle(0, successfulMove.angle.y + successfulMove.delta.y, 0)
--normalize dat yaw real kwik
while successfulMove.angle.y > 180 do
successfulMove.angle.y = successfulMove.angle.y - 360
end
while successfulMove.angle.y < -180 do
successfulMove.angle.y = successfulMove.angle.y + 360
end
cmd.viewangles = successfulMove.angle
cmd.forwardmove = successfulMove.forwardmove
cmd.sidemove = successfulMove.sidemove
eclipse.startMovementFix(cmd)
cmd.viewangles = backupMove.angle
eclipse.endMovementFix(cmd)
eclipse.setCmd(cmd)
return
end
end
local function onFoundEdgebug(edgebugRecord, tickFoundAt, cmd, localPlayer)
-- add 5 future ticks to record so you can see edgebug direction
for j=1,5 do
prediction.start(cmd)
prediction.end_()
edgebugRecord[tickFoundAt+j] = { ["origin"] = localPlayer:origin() }
end
-- draw edgebug trail
for i=0,#edgebugRecord - 1 do
if ui.getConfigBool("edgebug trail") then
beam.createBeam(edgebugRecord[i]["origin"], edgebugRecord[i+1]["origin"], "sprites/purplelaser1.vmt", ui.getConfigCol("edgebug trail color"), 10, 10, 0)
end
end
beam.ringBeam(edgebugRecord[tickFoundAt]["origin"], 300 * (tickFoundAt/64), -300 * (tickFoundAt/64), "sprites/purplelaser1.vmt", ui.getConfigCol("edgebug trail color"), (tickFoundAt/64) * 2, 10)
successfulMove.found = true
successfulMove.angle = backupMove.angle
cmd.viewangles = successfulMove.angle
successfulMove.delta = backupMove.delta
successfulMove.forwardmove = cmd.forwardmove
successfulMove.sidemove = cmd.sidemove
successfulMove.buttons = cmd.buttons
successfulMove.edgebugTick = cmd.tickcount + tickFoundAt
eclipse.clientCmd("play " .. EDGEBUG_FOUND_SOUND)
eclipse.setCmd(cmd)
end
local predCount = 0
local function predictEdgebug(cmd, localPlayer)
if successfulMove.found then return end
local commandsPredicted = prediction.commandsPredicted()
local edgebugRecord = {} -- table that holds records of position of found edgebug (for edgebug trail)
-- prediction loop
cmd.viewangles = backupMove.angle -- restore baseline viewangles
local curPredCount = 0
for i=0,ui.getConfigFloat("edgebug predict ticks") do
if(predCount >= ui.getConfigFloat("edgebug predict ticks")) then break end
lastTickVel = localPlayer:velocity()
prediction.start(cmd)
prediction.end_()
predCount = predCount + 1
curPredCount = curPredCount + 1
-- add current tick to edgebug record
edgebugRecord[i] = { ["origin"] = localPlayer:origin() }
-- if edgebug found save found edgebug and set cmd so our forwardmove and sidemove are 0
if detectEdgebug(localPlayer) then
onFoundEdgebug(edgebugRecord, i, cmd, localPlayer)
prediction.restoreToFrame(commandsPredicted - 1)
break
end
if localPlayer:onground() then
binBrute.ticksToGround = curPredCount
if localPlayer:origin().z > binBrute.highestGround then
binBrute.highestGround = localPlayer:origin().z
binBrute.searchDir = 1
end
break
end
if localPlayer:origin().z < binBrute.highestGround then
binBrute.searchDir = -1
end
cmd.viewangles = QAngle(0, cmd.viewangles.y + backupMove.delta.y, 0)
while cmd.viewangles.y > 180 do
cmd.viewangles.y = cmd.viewangles.y - 360
end
while cmd.viewangles.y < -180 do
cmd.viewangles.y = cmd.viewangles.y + 360
end
end
prediction.restoreToFrame(commandsPredicted - 1)
end
local edgebugLookupTable = {
[1] = function (cmd, localPlayer) -- standing/crouching/strafing edgebug
cmd.forwardmove = 0
cmd.sidemove = 0
predictEdgebug(cmd, localPlayer)
if successfulMove.found then return end
cmd.buttons = bit.bxor(cmd.buttons, 4) -- IN_DUCK = 4
predictEdgebug(cmd, localPlayer)
if successfulMove.found then return end
cmd.buttons = bit.bxor(cmd.buttons, 4) -- IN_DUCK = 4
-- anti-overshoot edgebug
cmd.forwardmove = -10
predictEdgebug(cmd, localPlayer)
if successfulMove.found then return end
cmd.forwardmove = -20
predictEdgebug(cmd, localPlayer)
if successfulMove.found then return end
cmd.forwardmove = -30
predictEdgebug(cmd, localPlayer)
end,
[2] = function (cmd, localPlayer) -- BiNaRy sEaRcH EdGeBuG
cmd.forwardmove = 0
predictEdgebug(cmd, localPlayer)
if successfulMove.found then return end
while predCount < ui.getConfigFloat("edgebug predict ticks") do
if predCount >= (binBrute.ticksToGround * 8) then break end
backupMove.delta.y = backupMove.delta.y + (backupMove.delta.y/2) * binBrute.searchDir
predictEdgebug(cmd, localPlayer)
if successfulMove.found then break end
end
end
}
local count = 0
local currentTick = 0
function onCreateMove(cmd)
currentTick = cmd.tickcount
local localPlayer = entitylist.getEntity(entitylist.getLocalPlayer())
if not (localPlayer:sane() and localPlayer:alive()) then return end
if not ui.isKeybinderDown("edgebug key") or localPlayer:onground() then
successfulMove.found = false
return
end
predCount = 0
backupMove.forwardmove = cmd.forwardmove
backupMove.sidemove = cmd.sidemove
backupMove.buttons = cmd.buttons
backupMove.delta = QAngle(0, cmd.viewangles.y - backupMove.angle.y, 0)
backupMove.angle = QAngle(cmd.viewangles.x, cmd.viewangles.y, 0)
binBrute.highestGround = -1337420
binBrute.searchDir = 1
forceEdgebug(cmd, localPlayer)
count = count + 1
if not successfulMove.found then
edgebugLookupTable[(count % #edgebugLookupTable) + 1](cmd, localPlayer)
end
if not successfulMove.found then
cmd.forwardmove = backupMove.forwardmove
cmd.sidemove = backupMove.sidemove
cmd.buttons = backupMove.buttons
cmd.viewangles = backupMove.angle
eclipse.setCmd(cmd)
end
-- do this so that other luas can stop doing things with cmd when going to
if successfulMove.found then ui.setConfigBool("lock cmd", true)
else ui.setConfigBool("lock cmd", false) end
end
function onUI()
ui.label("edgebug key")
ui.sameLine()
ui.keybinder("edgebug key")
ui.separator()
ui.label("edgebug settings")
ui.sliderInt("predict ticks", "edgebug predict ticks", 0, 256, "%d ticks")
ui.separator()
ui.label("trail")
ui.checkbox("edgebug trail", "edgebug trail")
if ui.getConfigBool("edgebug trail") then
ui.colorPicker("edgebug trail color", "edgebug trail color")
end
end
function onDraw()
if successfulMove.edgebugTick > currentTick - 64 or ui.isMenuOpen() then
ui.setNextWindowSize(Vec2(160, 80))
ui.beginWindow("edgebug info")
ui.label("edgebug found: " .. tostring(successfulMove.found))
ui.label("sidemove: " .. successfulMove.sidemove)
ui.label("forwardmove: " .. successfulMove.forwardmove)
if not (successfulMove.sidemove == 0) then ui.label("yaw delta: " .. successfulMove.delta.y) end
ui.endWindow()
end
end
if ui.getConfigFloat("edgebug predict ticks") == 0 then
ui.setConfigFloat("edgebug predict ticks", 64)
end
eclipse.registerHook("createMove", onCreateMove)
eclipse.registerHook("draw", onDraw)
eclipse.registerHook("UI", onUI)