forked from sapphyrus/gamesense-lua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fakelag_indicator.lua
188 lines (154 loc) · 8.77 KB
/
fakelag_indicator.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
--local variables for API. Automatically generated by https://github.com/simpleavaster/gslua/blob/master/authors/sapphyrus/generate_api.lua
local client_latency, client_log, client_draw_rectangle, client_draw_circle_outline, client_userid_to_entindex, client_draw_gradient, client_set_event_callback, client_screen_size, client_draw_indicator, client_eye_position = client.latency, client.log, client.draw_rectangle, client.draw_circle_outline, client.userid_to_entindex, client.draw_gradient, client.set_event_callback, client.screen_size, client.draw_indicator, client.eye_position
local client_color_log, client_draw_circle, client_draw_text, client_visible, client_exec, client_delay_call, client_trace_line, client_world_to_screen = client.color_log, client.draw_circle, client.draw_text, client.visible, client.exec, client.delay_call, client.trace_line, client.world_to_screen
local client_draw_hitboxes, client_get_cvar, client_draw_line, client_camera_angles, client_draw_debug_text, client_random_int, client_random_float = client.draw_hitboxes, client.get_cvar, client.draw_line, client.camera_angles, client.draw_debug_text, client.random_int, client.random_float
local entity_get_local_player, entity_is_enemy, entity_get_player_name, entity_get_all, entity_set_prop, entity_get_player_weapon, entity_hitbox_position, entity_get_prop, entity_get_players, entity_get_classname = entity.get_local_player, entity.is_enemy, entity.get_player_name, entity.get_all, entity.set_prop, entity.get_player_weapon, entity.hitbox_position, entity.get_prop, entity.get_players, entity.get_classname
local globals_mapname, globals_tickcount, globals_realtime, globals_absoluteframetime, globals_tickinterval, globals_curtime, globals_frametime, globals_maxplayers = globals.mapname, globals.tickcount, globals.realtime, globals.absoluteframetime, globals.tickinterval, globals.curtime, globals.frametime, globals.maxplayers
local ui_new_slider, ui_new_combobox, ui_reference, ui_set_visible, ui_new_color_picker, ui_set_callback, ui_set, ui_new_checkbox, ui_new_hotkey, ui_new_button, ui_new_multiselect, ui_get = ui.new_slider, ui.new_combobox, ui.reference, ui.set_visible, ui.new_color_picker, ui.set_callback, ui.set, ui.new_checkbox, ui.new_hotkey, ui.new_button, ui.new_multiselect, ui.get
local math_ceil, math_tan, math_log10, math_randomseed, math_cos, math_sinh, math_random, math_huge, math_pi, math_max, math_atan2, math_ldexp, math_floor, math_sqrt, math_deg, math_atan, math_fmod = math.ceil, math.tan, math.log10, math.randomseed, math.cos, math.sinh, math.random, math.huge, math.pi, math.max, math.atan2, math.ldexp, math.floor, math.sqrt, math.deg, math.atan, math.fmod
local math_acos, math_pow, math_abs, math_min, math_sin, math_frexp, math_log, math_tanh, math_exp, math_modf, math_cosh, math_asin, math_rad = math.acos, math.pow, math.abs, math.min, math.sin, math.frexp, math.log, math.tanh, math.exp, math.modf, math.cosh, math.asin, math.rad
local table_maxn, table_foreach, table_sort, table_remove, table_foreachi, table_move, table_getn, table_concat, table_insert = table.maxn, table.foreach, table.sort, table.remove, table.foreachi, table.move, table.getn, table.concat, table.insert
local string_find, string_format, string_rep, string_gsub, string_len, string_gmatch, string_dump, string_match, string_reverse, string_byte, string_char, string_upper, string_lower, string_sub = string.find, string.format, string.rep, string.gsub, string.len, string.gmatch, string.dump, string.match, string.reverse, string.byte, string.char, string.upper, string.lower, string.sub
--end of local variables
local fakelag_ref, fakelag_hotkey_ref = ui.reference("AA", "Fake lag", "Enabled")
local indicator_enabled_reference = ui.new_checkbox("AA", "Fake lag", "Indicator")
local indicator_color_reference = ui.new_color_picker("AA", "Fake lag", "Indicator", 60, 120, 180, 255)
local indicator_combined_reference = ui.new_checkbox("AA", "Fake lag", "Combined FL / LC indicator")
local position_enabled_reference = ui.new_combobox("AA", "Fake lag", "Show position", "Off", "Hitboxes", "Point")
local position_color_reference = ui.new_color_picker("AA", "Fake lag", "Show position", 64, 73, 83, 255)
local fakelag_maximum = 14
local choked_ticks = 0
local choked_ticks_max = 0
local choked_ticks_prev = 0
local cross_size = 4
local hitbox_duration = 0.5
local in_third_person = false
local pos_x, pos_y, pos_z
local function is_thirdperson(ctx)
local x, y, z = client_eye_position()
local pitch, yaw = client_camera_angles()
yaw = yaw - 180
pitch, yaw = math_rad(pitch), math_rad(yaw)
x = x + math_cos(yaw)*4
y = y + math_sin(yaw)*4
z = z + math_sin(pitch)*4
local wx, wy = client_world_to_screen(ctx, x, y, z)
return wx ~= nil
end
local function draw_indicator_circle(ctx, x, y, r, g, b, a, percentage, outline)
local outline = outline == nil and true or outline
local radius = 9
local start_degrees = 0
-- draw outline
if outline then
client_draw_circle_outline(ctx, x, y, 0, 0, 0, 200, radius, start_degrees, 1.0, 5)
end
-- draw inner circle
client_draw_circle_outline(ctx, x, y, r, g, b, a, radius-1, start_degrees, percentage, 3)
end
local function lc_indicator_drawn()
local local_player = entity_get_local_player()
local vel_x, vel_y = entity_get_prop(local_player, "m_vecVelocity")
if vel_x then
local vel = math_sqrt(vel_x*vel_x + vel_y*vel_y)
if vel > 280 then
return true
end
end
return false
end
local function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math_floor(num * mult + 0.5) / mult
end
local function on_indicator_enabled_changed()
ui_set_visible(indicator_combined_reference, ui_get(indicator_enabled_reference))
end
ui.set_callback(indicator_enabled_reference, on_indicator_enabled_changed)
on_indicator_enabled_changed()
local function on_run_command(e)
choked_ticks = e.chokedcommands
if choked_ticks_prev >= choked_ticks or choked_ticks == 0 then
if choked_ticks_prev > 1 then
local position_enabled = ui_get(position_enabled_reference)
if position_enabled ~= "Off" then
local r, g, b, a = ui_get(position_color_reference)
--bsendpacket is true
local local_player = entity_get_local_player()
pos_x, pos_y, pos_z = entity_get_prop(local_player, "m_vecOrigin")
if position_enabled == "Hitboxes" then
if in_third_person then
client_draw_hitboxes(local_player, hitbox_duration, 19, r, g, b)
end
end
end
end
choked_ticks_max = choked_ticks_prev
end
choked_ticks_prev = choked_ticks
end
client.set_event_callback("run_command", on_run_command)
local function on_paint(ctx)
local local_player = entity_get_local_player()
if local_player == nil or entity_get_prop(local_player, "m_lifeState") ~= 0 then
return
end
local game_rules_proxy = entity_get_all("CCSGameRulesProxy")[1]
if game_rules_proxy == nil then
return
end
if entity_get_prop(game_rules_proxy, "m_bFreezePeriod") == 1 then
return
end
local game_rules_proxy = entity_get_all("CCSGameRulesProxy")[1]
local round_over = entity_get_prop(game_rules_proxy, "m_iRoundWinStatus") ~= 0
if round_over and (#entity_get_players(true) == 0) then
return
end
if ui_get(indicator_enabled_reference) then
local x = 55
local y
local r, g, b, a = ui_get(indicator_color_reference)
if ui_get(indicator_combined_reference) then
if lc_indicator_drawn() then
else
client_draw_indicator(ctx, 255, 0, 0, 255, "LC")
end
local screen_width, screen_height = client_screen_size()
y = screen_height-56
else
x = 89
y = client_draw_indicator(ctx, r, g, b, a, "FL ", choked_ticks_max > 9 and "" or " ", math_max(1, choked_ticks_max))
--client.log(y)
y = 0
y = y + 14
end
draw_indicator_circle(ctx, x, y, r, g, b, a/4, choked_ticks_max/fakelag_maximum)
draw_indicator_circle(ctx, x, y, r, g, b, a, choked_ticks/fakelag_maximum, false)
end
local position_enabled = ui_get(position_enabled_reference)
if position_enabled ~= "Off" then
in_third_person = is_thirdperson(ctx)
if in_third_person and position_enabled == "Point" then
if pos_x == nil then
return
end
local r, g, b, a = ui_get(position_color_reference)
local wx1, wy1 = client_world_to_screen(ctx, pos_x-cross_size, pos_y, pos_z)
local wx2, wy2 = client_world_to_screen(ctx, pos_x+cross_size, pos_y, pos_z)
if wx1 ~= nil and wx2 ~= nil then
client_draw_line(ctx, wx1, wy1, wx2, wy2, r, g, b, a)
end
wx1, wy1 = client_world_to_screen(ctx, pos_x, pos_y-cross_size, pos_z)
wx2, wy2 = client_world_to_screen(ctx, pos_x, pos_y+cross_size, pos_z)
if wx1 ~= nil and wx2 ~= nil then
client_draw_line(ctx, wx1, wy1, wx2, wy2, r, g, b, a)
end
local wx, wy = client_world_to_screen(ctx, pos_x, pos_y, pos_z)
if wx ~= nil then
client_draw_circle(ctx, wx, wy, 16, 16, 16, 255, 2, 0, 1)
end
end
end
end
client.set_event_callback("paint", on_paint)