summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-06 16:21:27 +0100
committersalmonik <salmonik@tuta.io>2026-11-06 16:21:27 +0100
commit3c27e7ce262e612fa75c6e6f090e04041a688861 (patch)
tree1c2bfd6accea27904dc9d81a61624905b220a8a0
parentHooks: central vtable install with restore support (diff)
downloadhl2h-3c27e7ce262e612fa75c6e6f090e04041a688861.tar.gz
hl2h-3c27e7ce262e612fa75c6e6f090e04041a688861.zip
Headers: split the shared header by declaration group
hl2h.h becomes an umbrella over core.h (logging, init stage, module snapshots, interfaces, netvars, CUserCmd, engine constants, vector math), settings.h (feature ids, feature state, user settings) and features.h (cross-module declarations). Translation units keep including hl2h.h, so this only moves declarations.
-rw-r--r--FIX_PLAN.md10
-rw-r--r--src/core.h205
-rw-r--r--src/features.h136
-rw-r--r--src/hl2h.h445
-rw-r--r--src/settings.h117
5 files changed, 477 insertions, 436 deletions
diff --git a/FIX_PLAN.md b/FIX_PLAN.md
index 3ebbd17..f2dec60 100644
--- a/FIX_PLAN.md
+++ b/FIX_PLAN.md
@@ -796,6 +796,14 @@ installs happen from the setup, game and paint threads. `hooks_restore_all()`
796puts every interface back, which previously was impossible. Client, CInput, 796puts every interface back, which previously was impossible. Client, CInput,
797IVModelRender, IStudioRender and ISurface all go through it now. 797IVModelRender, IStudioRender and ISurface all go through it now.
798 798
799### Batch 7 — header split
800
801`hl2h.h` is now an umbrella over `core.h` (logging, init stage, module
802snapshots, interfaces, netvars, CUserCmd, engine constants, vector math),
803`settings.h` (feature ids, feature state, every user setting) and `features.h`
804(cross-module declarations), plus `overlay.h` and `hooks.h`. Translation units
805still include `hl2h.h`, so this is a declaration-organisation change only.
806
799### Known remaining work 807### Known remaining work
800 808
801Deliberately deferred, with reasons: 809Deliberately deferred, with reasons:
@@ -808,7 +816,7 @@ Deliberately deferred, with reasons:
808- **P3-2 declarative settings table** — large rewrite of `config_save`, 816- **P3-2 declarative settings table** — large rewrite of `config_save`,
809 `config_load`, `config_reset_defaults` and `build_cards`. It can regress 817 `config_load`, `config_reset_defaults` and `build_cards`. It can regress
810 config persistence, so it should follow an in-game pass. 818 config persistence, so it should follow an in-game pass.
811- **P3-3 `esp.cpp` split**, **P3-5 header split** — 819- **P3-3 `esp.cpp` split** —
812 behaviour-neutral moves with a large diff; best done after the current build 820 behaviour-neutral moves with a large diff; best done after the current build
813 has been validated in-game so a regression is easy to bisect. 821 has been validated in-game so a regression is easy to bisect.
814 822
diff --git a/src/core.h b/src/core.h
new file mode 100644
index 0000000..320b62b
--- /dev/null
+++ b/src/core.h
@@ -0,0 +1,205 @@
1#ifndef HL2H_CORE_H
2#define HL2H_CORE_H
3
4#include <cstdint>
5#include <cstdio>
6#include <cstring>
7#include <string>
8#include <vector>
9
10#include <dlfcn.h>
11#include <pthread.h>
12#include <unistd.h>
13
14// Shared float-precision constant. More digits than a float can hold are
15// rounded at compile time and have no runtime cost; a coarse value would only
16// hurt angular accuracy, never performance.
17constexpr float PI_F = 3.14159265f;
18
19// ---------------------------------------------------------------------------
20// logging
21// ---------------------------------------------------------------------------
22
23void logf(const char *fmt, ...);
24void logd(const char *fmt, ...); // debug-only (HL2H_DEBUG=1)
25
26// ---------------------------------------------------------------------------
27// init readiness
28// ---------------------------------------------------------------------------
29//
30// setup_thread runs detached while the game threads are already live, and some
31// hooks are installed lazily from the game thread. Hooks therefore always stay
32// installed but pass straight through to the original until setup reaches
33// INIT_LIVE, so the game can never observe half-initialised state. INIT_FAILED
34// is terminal: the cheat stays inert instead of half-working.
35enum {
36 INIT_FAILED = -1,
37 INIT_NONE = 0,
38 INIT_INTERFACES = 1, // modules + interfaces + netvars resolved
39 INIT_READY = 2, // config loaded, ISurface/fonts resolved
40 INIT_LIVE = 3 // hooks may run their bodies
41};
42void init_set_stage(int stage);
43int init_stage(); // acquire load
44inline bool init_live() { return init_stage() == INIT_LIVE; }
45
46// Clone a vtable into a new array, preserving the Itanium ABI header at
47// [-2]/[-1] (offset-to-top and typeinfo) so RTTI on the hooked object still
48// works. Returns the slot-0 pointer to install (i.e. the clone + 2).
49void **vtable_clone(void *iface, size_t slots);
50
51// ---------------------------------------------------------------------------
52// on-screen toasts
53// ---------------------------------------------------------------------------
54
55enum ToastLevel { TOAST_INFO = 0, TOAST_WARN, TOAST_ERROR };
56void toastf(int level, const char *fmt, ...);
57bool gui_toasts_active();
58void gui_draw_toasts();
59
60// ---------------------------------------------------------------------------
61// module discovery
62// ---------------------------------------------------------------------------
63
64struct Module {
65 struct Range {
66 uintptr_t lo, hi;
67 bool file;
68 };
69 std::vector<Range> ranges;
70 std::string path;
71 bool valid() const { return !ranges.empty(); }
72 bool contains(uintptr_t p) const {
73 for (auto &r : ranges)
74 if (p >= r.lo && p < r.hi)
75 return true;
76 return false;
77 }
78};
79// Immutable module snapshots. A reader gets a reference that stays valid for
80// the whole process: find_modules() publishes a new snapshot instead of
81// mutating the old one, and retired snapshots are intentionally never freed, so
82// a concurrent refresh can never invalidate a reference already in use.
83const Module &mod_client();
84const Module &mod_engine();
85const Module &mod_server();
86
87// True only when the whole byte range [p, p+n) lies inside one known module
88// range. Use before dereferencing pointers read out of engine memory.
89bool module_range(uintptr_t p, size_t n);
90
91// ---------------------------------------------------------------------------
92// game interfaces
93// ---------------------------------------------------------------------------
94
95using CreateInterfaceFn = void *(*)(const char *, int *);
96
97struct GameInterfaces {
98 void *client = nullptr;
99 void *entitylist = nullptr;
100 void *engine = nullptr;
101 void *modelinfo = nullptr; // IVModelInfoClient006 (model index -> model name)
102 void *engineserver = nullptr; // IVEngineServer021 (edict access, incl. server entities)
103 void *debugoverlay = nullptr; // IVDebugOverlay003 (engine-accurate world->screen)
104 void *enginetrace = nullptr; // EngineTraceClient003 (world vischeck)
105 void *cvar = nullptr; // VEngineCvar004 (mat_fullbright etc.)
106 void *modelrender = nullptr; // VEngineModel016 (chams)
107 void *renderview = nullptr; // VEngineRenderView014 (alpha/color modulation)
108};
109extern GameInterfaces g_iface;
110
111#define VTABLE(obj) (*(void ***)(obj))
112template <typename Fn> inline Fn vfunc(void *obj, size_t idx) {
113 return reinterpret_cast<Fn>(VTABLE(obj)[idx]);
114}
115
116// ---------------------------------------------------------------------------
117// netvars
118// ---------------------------------------------------------------------------
119struct NetVars {
120 int flags = -1;
121 int velocity = -1;
122 int movetype = -1;
123 int health = -1;
124 int maxhealth = -1;
125 int teamnum = -1;
126 int origin = -1;
127 int viewoffset = -1;
128 int mins = -1;
129 int maxs = -1;
130 int lifestate = -1;
131 int modelindex = -1;
132 int absvelocity = -1; // client C_BaseEntity::m_vecAbsVelocity (prediction)
133 int activeweapon = -1; // client m_hActiveWeapon handle
134 int owner = -1; // client m_hOwnerEntity handle
135 int weapon_owner = -1; // client m_hOwner handle (C_BaseCombatWeapon)
136 int clr_render = -1; // client m_clrRender (entity render colour)
137 int punch = -1; // client m_vecPunchAngle (aim punch)
138 int default_fov = -1; // client m_iDefaultFOV (camera fov)
139 int dmg_radius = -1; // client C_BaseGrenade::m_DmgRadius
140 int my_weapons = -1; // client m_hMyWeapons[48] array base
141 int ammo = -1; // client m_iAmmo[] array base
142 // ponytail: mins/maxs may be absent from some HL2 netvar tables; esp.cpp falls back to h=72
143 bool ok() const { return flags >= 0 && velocity >= 0 && movetype >= 0; }
144 // ponytail: m_iMaxHealth isn't a netvar in HL2 SP; esp.cpp falls back to 100.
145 // m_iHealth only ever updates for players — NPCs are detected via m_lifeState.
146 bool esp_ok() const { return ok() && health >= 0 && teamnum >= 0 && origin >= 0 && viewoffset >= 0; }
147};
148extern NetVars g_net;
149
150// ---------------------------------------------------------------------------
151// CInput
152// ---------------------------------------------------------------------------
153
154extern uintptr_t g_input;
155
156// ---------------------------------------------------------------------------
157// console output
158// ---------------------------------------------------------------------------
159
160extern void (*g_conmsg)(const char *, ...);
161
162// ---------------------------------------------------------------------------
163// CUserCmd
164// ---------------------------------------------------------------------------
165
166struct CUserCmd {
167 void *vtable;
168 int command_number;
169 int tick_count;
170 float viewangles[3];
171 float forwardmove;
172 float sidemove;
173 float upmove;
174 int buttons;
175 uint8_t impulse;
176 int weaponselect;
177 int weaponsubtype;
178 int random_seed;
179 short mousedx;
180 short mousedy;
181 bool hasbeenpredicted;
182};
183
184// ---------------------------------------------------------------------------
185// engine constants
186// ---------------------------------------------------------------------------
187
188enum { IN_ATTACK = 1 << 0, IN_JUMP = 1 << 1, IN_DUCK = 1 << 2, IN_USE = 1 << 5, IN_ATTACK2 = 1 << 11, IN_SPEED = 1 << 17 };
189enum { FL_ONGROUND = 1 << 0, FL_DUCKING = 1 << 1, FL_INWATER = 1 << 9 };
190enum { MOVETYPE_WALK = 2, MOVETYPE_NOCLIP = 8, MOVETYPE_LADDER = 9 };
191
192// ---------------------------------------------------------------------------
193// vector math
194// ---------------------------------------------------------------------------
195
196struct Vector { float x, y, z; };
197struct QAngle { float x, y, z; };
198// camera state captured each CreateMove (used by ESP / future aimbot)
199extern Vector g_cam_eye;
200extern Vector g_cam_view;
201QAngle vector_angles(const Vector &forward);
202Vector angle_forward_vector(const QAngle &angles);
203float getfov(const QAngle &my_view, const QAngle &aim_ang);
204
205#endif
diff --git a/src/features.h b/src/features.h
new file mode 100644
index 0000000..6890aa6
--- /dev/null
+++ b/src/features.h
@@ -0,0 +1,136 @@
1#ifndef HL2H_FEATURES_H
2#define HL2H_FEATURES_H
3
4#include "core.h"
5#include "settings.h"
6
7// ---------------------------------------------------------------------------
8// combat
9// ---------------------------------------------------------------------------
10bool aimbot_apply(CUserCmd *cmd);
11bool triggerbot_apply(CUserCmd *cmd);
12bool silent_aim_apply(CUserCmd *cmd);
13bool melee_weapon_active(void *local_ent);
14bool gravity_gun_active(void *local_ent);
15bool melee_aimbot_apply(CUserCmd *cmd, bool gravity);
16bool spread_control_apply(CUserCmd *cmd, void *local_ent);
17int spread_best_seed(int pellets);
18
19// ---------------------------------------------------------------------------
20// cross-file declarations
21// ---------------------------------------------------------------------------
22void note_modified(const CUserCmd *cmd, int flags, const float *vel);
23CUserCmd *get_usercmd(int seq);
24void input_clear_mouse_states();
25void fix_verified_crc(int seq, uint32_t crc);
26uint32_t usercmd_checksum(const CUserCmd *c);
27bool find_input_global();
28void resolve_netvars();
29bool console_cmd(const char *cmd);
30bool cvar_set_int(const char *name, int value);
31void fullbright_update();
32void fullbright_invalidate();
33void world_tint_update();
34void world_tint_invalidate();
35void fog_update();
36void fog_invalidate();
37void skybox_update();
38void skybox_invalidate();
39void skybox_reload_image();
40bool resolve_server_netvars();
41int server_entity_health(int idx, int *maxhealth, int *lifestate, void **base_out);
42// Authoritative server velocity; client-side m_vecVelocity is not networked for
43// NPCs. Returns false when the server interface or datamap field is missing.
44bool server_entity_velocity(int idx, Vector *out);
45bool server_set_velocity_z(int idx, float vz);
46int server_active_weapon(int idx);
47int server_npc_relation(int idx, int local_idx);
48bool server_npc_has_follow_target(int idx);
49int server_npc_state(int idx);
50int server_npc_takedamage(int idx);
51int server_player_armor(int idx);
52int server_player_ammo(int idx, int type);
53uint32_t server_player_weapon(int idx, int slot);
54float server_grenade_detonate(int idx);
55float server_grenade_radius(int idx);
56int server_grenade_thrower(int idx);
57int server_item_juice(int idx);
58int server_entity_count();
59void *server_entity_base(int idx);
60const char *server_entity_classname(int idx);
61bool server_trigger_info(int idx, char *map, size_t mapn, Vector &mins,
62 Vector &maxs);
63int server_npc_turret_flags(int idx);
64int server_model_index(void *base);
65void find_modules();
66bool module_jump_slot(const char *path, const char *name, uintptr_t *vaddr,
67 uintptr_t *bias);
68void init_conmsg();
69bool feature_active(int feature); // enabled AND bind held (or unbound)
70bool feature_enabled(int feature); // enabled, regardless of bind
71bool feature_has_bind(int feature);
72bool feature_bind_held(int feature);
73bool esp_option(int opt);
74bool bhop_autostrafe_enabled();
75bool jumpbug_assist_enabled();
76bool spread_no_spread_enabled();
77bool spread_engine_enabled();
78bool aim_punch_enabled();
79unsigned aimbot_bone_mask();
80int aimbot_smooth_step();
81bool aimbot_vischeck_enabled();
82int aimbot_fov();
83bool aimbot_fov_circle();
84void aimbot_reset_lock();
85void silentaim_reset_lock();
86void *entitylist_get(int idx);
87bool esp_is_npc_index(int idx);
88bool esp_is_viewmodel_index(int idx);
89int esp_npc_relation(int idx);
90void *world_find_material(const char *name);
91void chams_init();
92void chams_preload();
93int engine_get_local_player();
94void draw_text_col(int x, int y, const char *s, int r, int g, int b);
95void draw_text_small_col(int x, int y, const char *s, int r, int g, int b);
96void esp_draw();
97void esp_draw_fov_circle(); // aimbot cone, independent of the ESP toggle
98void esp_reset_session(); // map change / respawn: clear per-map latches
99void esp_draw_items();
100void esp_draw_projectiles();
101void prop_tint_update();
102void studio_props_init();
103bool world_to_screen(const Vector &w, float &sx, float &sy);
104void set_silent_restore(const QAngle &angles);
105bool is_visible(const Vector &eye, const Vector &point,
106 void *self = nullptr, void *target = nullptr);
107void *trace_entity(const Vector &start, const Vector &end, void *ignore);
108bool trace_solid_segment(const Vector &start, const Vector &end, void *ignore,
109 Vector &out_end, Vector &out_normal);
110float ground_distance(const Vector &origin, void *ignore, float max_dist);
111bool point_ground(const Vector &point, void *ignore);
112
113// bones.cpp — client-side animated skeleton / hitbox access (see there)
114bool bones_update(int idx, void *ent);
115int bones_count(int idx);
116int bone_find(int idx, const char *name);
117int bone_parent(int idx, int bone);
118bool bone_pos(int idx, int bone, Vector &out);
119bool bone_is_skeleton_core(int idx, int bone);
120int bone_nearest_core_parent(int idx, int bone);
121bool bones_is_humanoid(int idx);
122bool hitbox_center(int idx, const char *hitbox_name, Vector &out);
123void bones_clear();
124bool head_position(int idx, Vector &out);
125int aim_points(int idx, unsigned group_mask, Vector *out, int max);
126
127void outer_draw();
128void gui_handle_input();
129void gui_draw();
130bool gui_is_open();
131bool gui_bind_capture_active();
132QAngle gui_frozen_view();
133void gui_config_init();
134void gui_config_write(FILE *f);
135
136#endif
diff --git a/src/hl2h.h b/src/hl2h.h
index 541b31b..32d6463 100644
--- a/src/hl2h.h
+++ b/src/hl2h.h
@@ -1,442 +1,17 @@
1#ifndef HL2H_H 1#ifndef HL2H_H
2#define HL2H_H 2#define HL2H_H
3 3
4#include <cstdint> 4// Umbrella header. Declaration groups live in:
5#include <cstdio> 5// core.h — logging, init stage, module snapshots, interfaces, netvars,
6#include <cstring> 6// CUserCmd, engine constants, vector math
7#include <string> 7// settings.h — feature ids, feature state and every user setting
8#include <vector> 8// features.h — cross-module function declarations
9 9// overlay.h — the single ISurface access layer
10#include <dlfcn.h> 10// hooks.h — vtable install/restore
11#include <pthread.h> 11#include "core.h"
12#include <unistd.h> 12#include "features.h"
13
14#include "hooks.h" 13#include "hooks.h"
15#include "overlay.h" 14#include "overlay.h"
15#include "settings.h"
16 16
17// Shared float-precision constant. More digits than a float can hold are
18// rounded at compile time and have no runtime cost; a coarse value would only
19// hurt angular accuracy, never performance.
20constexpr float PI_F = 3.14159265f;
21
22// ---------------------------------------------------------------------------
23// logging
24// ---------------------------------------------------------------------------
25
26void logf(const char *fmt, ...);
27void logd(const char *fmt, ...); // debug-only (HL2H_DEBUG=1)
28
29// ---------------------------------------------------------------------------
30// init readiness
31// ---------------------------------------------------------------------------
32//
33// setup_thread runs detached while the game threads are already live, and some
34// hooks are installed lazily from the game thread. Hooks therefore always stay
35// installed but pass straight through to the original until setup reaches
36// INIT_LIVE, so the game can never observe half-initialised state. INIT_FAILED
37// is terminal: the cheat stays inert instead of half-working.
38enum {
39 INIT_FAILED = -1,
40 INIT_NONE = 0,
41 INIT_INTERFACES = 1, // modules + interfaces + netvars resolved
42 INIT_READY = 2, // config loaded, ISurface/fonts resolved
43 INIT_LIVE = 3 // hooks may run their bodies
44};
45void init_set_stage(int stage);
46int init_stage(); // acquire load
47inline bool init_live() { return init_stage() == INIT_LIVE; }
48
49// Clone a vtable into a new array, preserving the Itanium ABI header at
50// [-2]/[-1] (offset-to-top and typeinfo) so RTTI on the hooked object still
51// works. Returns the slot-0 pointer to install (i.e. the clone + 2).
52void **vtable_clone(void *iface, size_t slots);
53
54// ---------------------------------------------------------------------------
55// on-screen toasts
56// ---------------------------------------------------------------------------
57
58enum ToastLevel { TOAST_INFO = 0, TOAST_WARN, TOAST_ERROR };
59void toastf(int level, const char *fmt, ...);
60bool gui_toasts_active();
61void gui_draw_toasts();
62
63// ---------------------------------------------------------------------------
64// module discovery
65// ---------------------------------------------------------------------------
66
67struct Module {
68 struct Range {
69 uintptr_t lo, hi;
70 bool file;
71 };
72 std::vector<Range> ranges;
73 std::string path;
74 bool valid() const { return !ranges.empty(); }
75 bool contains(uintptr_t p) const {
76 for (auto &r : ranges)
77 if (p >= r.lo && p < r.hi)
78 return true;
79 return false;
80 }
81};
82// Immutable module snapshots. A reader gets a reference that stays valid for
83// the whole process: find_modules() publishes a new snapshot instead of
84// mutating the old one, and retired snapshots are intentionally never freed, so
85// a concurrent refresh can never invalidate a reference already in use.
86const Module &mod_client();
87const Module &mod_engine();
88const Module &mod_server();
89
90// True only when the whole byte range [p, p+n) lies inside one known module
91// range. Use before dereferencing pointers read out of engine memory.
92bool module_range(uintptr_t p, size_t n);
93
94// ---------------------------------------------------------------------------
95// game interfaces
96// ---------------------------------------------------------------------------
97
98using CreateInterfaceFn = void *(*)(const char *, int *);
99
100struct GameInterfaces {
101 void *client = nullptr;
102 void *entitylist = nullptr;
103 void *engine = nullptr;
104 void *modelinfo = nullptr; // IVModelInfoClient006 (model index -> model name)
105 void *engineserver = nullptr; // IVEngineServer021 (edict access, incl. server entities)
106 void *debugoverlay = nullptr; // IVDebugOverlay003 (engine-accurate world->screen)
107 void *enginetrace = nullptr; // EngineTraceClient003 (world vischeck)
108 void *cvar = nullptr; // VEngineCvar004 (mat_fullbright etc.)
109 void *modelrender = nullptr; // VEngineModel016 (chams)
110 void *renderview = nullptr; // VEngineRenderView014 (alpha/color modulation)
111};
112extern GameInterfaces g_iface;
113
114#define VTABLE(obj) (*(void ***)(obj))
115template <typename Fn> inline Fn vfunc(void *obj, size_t idx) {
116 return reinterpret_cast<Fn>(VTABLE(obj)[idx]);
117}
118
119// ---------------------------------------------------------------------------
120// netvars
121// ---------------------------------------------------------------------------
122struct NetVars {
123 int flags = -1;
124 int velocity = -1;
125 int movetype = -1;
126 int health = -1;
127 int maxhealth = -1;
128 int teamnum = -1;
129 int origin = -1;
130 int viewoffset = -1;
131 int mins = -1;
132 int maxs = -1;
133 int lifestate = -1;
134 int modelindex = -1;
135 int absvelocity = -1; // client C_BaseEntity::m_vecAbsVelocity (prediction)
136 int activeweapon = -1; // client m_hActiveWeapon handle
137 int owner = -1; // client m_hOwnerEntity handle
138 int weapon_owner = -1; // client m_hOwner handle (C_BaseCombatWeapon)
139 int clr_render = -1; // client m_clrRender (entity render colour)
140 int punch = -1; // client m_vecPunchAngle (aim punch)
141 int default_fov = -1; // client m_iDefaultFOV (camera fov)
142 int dmg_radius = -1; // client C_BaseGrenade::m_DmgRadius
143 int my_weapons = -1; // client m_hMyWeapons[48] array base
144 int ammo = -1; // client m_iAmmo[] array base
145 // ponytail: mins/maxs may be absent from some HL2 netvar tables; esp.cpp falls back to h=72
146 bool ok() const { return flags >= 0 && velocity >= 0 && movetype >= 0; }
147 // ponytail: m_iMaxHealth isn't a netvar in HL2 SP; esp.cpp falls back to 100.
148 // m_iHealth only ever updates for players — NPCs are detected via m_lifeState.
149 bool esp_ok() const { return ok() && health >= 0 && teamnum >= 0 && origin >= 0 && viewoffset >= 0; }
150};
151extern NetVars g_net;
152
153// ---------------------------------------------------------------------------
154// CInput
155// ---------------------------------------------------------------------------
156
157extern uintptr_t g_input;
158
159// ---------------------------------------------------------------------------
160// console output
161// ---------------------------------------------------------------------------
162
163extern void (*g_conmsg)(const char *, ...);
164
165// ---------------------------------------------------------------------------
166// CUserCmd
167// ---------------------------------------------------------------------------
168
169struct CUserCmd {
170 void *vtable;
171 int command_number;
172 int tick_count;
173 float viewangles[3];
174 float forwardmove;
175 float sidemove;
176 float upmove;
177 int buttons;
178 uint8_t impulse;
179 int weaponselect;
180 int weaponsubtype;
181 int random_seed;
182 short mousedx;
183 short mousedy;
184 bool hasbeenpredicted;
185};
186
187// ---------------------------------------------------------------------------
188// engine constants
189// ---------------------------------------------------------------------------
190
191enum { IN_ATTACK = 1 << 0, IN_JUMP = 1 << 1, IN_DUCK = 1 << 2, IN_USE = 1 << 5, IN_ATTACK2 = 1 << 11, IN_SPEED = 1 << 17 };
192enum { FL_ONGROUND = 1 << 0, FL_DUCKING = 1 << 1, FL_INWATER = 1 << 9 };
193enum { MOVETYPE_WALK = 2, MOVETYPE_NOCLIP = 8, MOVETYPE_LADDER = 9 };
194
195// ---------------------------------------------------------------------------
196// vector math
197// ---------------------------------------------------------------------------
198
199struct Vector { float x, y, z; };
200struct QAngle { float x, y, z; };
201// camera state captured each CreateMove (used by ESP / future aimbot)
202extern Vector g_cam_eye;
203extern Vector g_cam_view;
204QAngle vector_angles(const Vector &forward);
205Vector angle_forward_vector(const QAngle &angles);
206float getfov(const QAngle &my_view, const QAngle &aim_ang);
207bool aimbot_apply(CUserCmd *cmd);
208bool triggerbot_apply(CUserCmd *cmd);
209bool silent_aim_apply(CUserCmd *cmd);
210bool melee_weapon_active(void *local_ent);
211bool gravity_gun_active(void *local_ent);
212bool melee_aimbot_apply(CUserCmd *cmd, bool gravity);
213bool spread_control_apply(CUserCmd *cmd, void *local_ent);
214int spread_best_seed(int pellets);
215extern int g_spread_pellets;
216enum FeatureId {
217 FEAT_BHOP = 0,
218 FEAT_ABH = 1,
219 FEAT_ESP = 2,
220 FEAT_AIMBOT = 3,
221 FEAT_TRIGGERBOT = 4,
222 FEAT_SILENTAIM = 5,
223 FEAT_JUMPBUG = 6,
224 FEAT_MELEE = 7,
225 FEAT_SPREAD = 8,
226 FEAT_ITEM_ESP = 9,
227 FEAT_FULLBRIGHT = 10,
228 FEAT_WORLD_TINT = 11,
229 FEAT_FOG = 12,
230 FEAT_SKYBOX = 13,
231 FEAT_PROJECTILES = 14,
232 FEAT_CHAMS = 15,
233 FEAT_COUNT = 16
234};
235enum EspOption {
236 ESP_OPT_SHOW_NEUTRAL = 0,
237 ESP_OPT_SHOW_HEALTHBAR = 1,
238 ESP_OPT_SHOW_HEALTHNUM = 2,
239 ESP_OPT_SHOW_NAME = 3,
240 ESP_OPT_SHOW_SKELETON = 4,
241 ESP_OPT_SHOW_BOX = 5,
242 ESP_OPT_SHOW_SPEEDGRAPH = 6,
243 ESP_OPT_DAMAGE_TAGS = 7,
244 ESP_OPT_ALERT = 8,
245 ESP_OPT_WEAPON = 9,
246 ESP_OPT_ARROWS = 10,
247 ESP_OPT_COUNT = 11
248};
249enum AimBone {
250 AIM_BONE_HEAD = 0,
251 AIM_BONE_TORSO,
252 AIM_BONE_LARM,
253 AIM_BONE_RARM,
254 AIM_BONE_LLEG,
255 AIM_BONE_RLEG,
256 AIM_BONE_COUNT
257};
258
259// ---------------------------------------------------------------------------
260// feature state / settings (owned by menu.cpp alongside config)
261// ---------------------------------------------------------------------------
262
263struct FeatureState {
264 bool active;
265 int bind; // SDL scancode, 0 = none (always-on)
266};
267
268extern FeatureState g_bhop, g_abh, g_jumpbug, g_melee, g_spread, g_esp,
269 g_aimbot, g_triggerbot, g_silentaim, g_item_esp, g_fullbright,
270 g_world_tint, g_fog, g_skybox, g_projectiles, g_chams;
271extern bool g_proj_fuse, g_proj_radius, g_proj_traj;
272
273// Chams settings per relationship, and separate visible / through-wall
274// (invisible) material and colour. The viewmodel has a single style.
275struct ChamsGroup {
276 bool vis_on;
277 int vis_mat;
278 int vis_rgb[4]; // r, g, b, a (0..255)
279 bool inv_on;
280 int inv_mat;
281 int inv_rgb[4];
282};
283extern ChamsGroup g_chams_hostile, g_chams_neutral, g_chams_friendly;
284extern bool g_chams_viewmodel;
285extern int g_chams_vm_mat;
286extern int g_chams_vm_rgb[4];
287extern bool g_tint_world_on, g_tint_sky_on, g_tint_prop_on;
288extern int g_tint_world_rgb[3], g_tint_sky_rgb[3], g_tint_prop_rgb[3];
289extern bool g_fog_skybox, g_fog_disable;
290extern int g_fog_rgb[3], g_fog_start, g_fog_end;
291const char *config_file_cstr(const char *name);
292extern bool g_bhop_autostrafe;
293extern bool g_jumpbug_assist;
294extern bool g_spread_no_spread;
295extern bool g_item_health;
296extern bool g_item_ammo;
297extern bool g_item_armor;
298extern bool g_item_weapons;
299extern bool g_item_crates;
300extern bool g_item_distance;
301extern bool g_item_usable;
302extern int g_item_max_dist;
303extern bool g_aim_bones[AIM_BONE_COUNT];
304extern int g_aim_smooth;
305extern bool g_aim_vischeck;
306extern int g_aim_fov;
307extern bool g_aim_fov_circle;
308extern bool g_aim_punch;
309extern bool g_spread_engine;
310extern bool g_auto_crouchjump;
311extern bool g_edge_jump;
312extern int g_fov_camera;
313extern int g_fov_viewmodel;
314extern int g_tonemap;
315extern int g_esp_col_hostile[3];
316extern int g_esp_col_neutral[3];
317extern int g_esp_col_friendly[3];
318extern bool g_esp_opt[ESP_OPT_COUNT];
319
320const char *scancode_name(int sc);
321void config_save();
322void config_reload();
323void config_reset_defaults();
324const char *config_path_cstr();
325
326// ---------------------------------------------------------------------------
327// cross-file declarations
328// ---------------------------------------------------------------------------
329void note_modified(const CUserCmd *cmd, int flags, const float *vel);
330CUserCmd *get_usercmd(int seq);
331void input_clear_mouse_states();
332void fix_verified_crc(int seq, uint32_t crc);
333uint32_t usercmd_checksum(const CUserCmd *c);
334bool find_input_global();
335void resolve_netvars();
336bool console_cmd(const char *cmd);
337bool cvar_set_int(const char *name, int value);
338void fullbright_update();
339void fullbright_invalidate();
340void world_tint_update();
341void world_tint_invalidate();
342void fog_update();
343void fog_invalidate();
344void skybox_update();
345void skybox_invalidate();
346void skybox_reload_image();
347bool resolve_server_netvars();
348int server_entity_health(int idx, int *maxhealth, int *lifestate, void **base_out);
349// Authoritative server velocity; client-side m_vecVelocity is not networked for
350// NPCs. Returns false when the server interface or datamap field is missing.
351bool server_entity_velocity(int idx, Vector *out);
352bool server_set_velocity_z(int idx, float vz);
353int server_active_weapon(int idx);
354int server_npc_relation(int idx, int local_idx);
355bool server_npc_has_follow_target(int idx);
356int server_npc_state(int idx);
357int server_npc_takedamage(int idx);
358int server_player_armor(int idx);
359int server_player_ammo(int idx, int type);
360uint32_t server_player_weapon(int idx, int slot);
361float server_grenade_detonate(int idx);
362float server_grenade_radius(int idx);
363int server_grenade_thrower(int idx);
364int server_item_juice(int idx);
365int server_entity_count();
366void *server_entity_base(int idx);
367const char *server_entity_classname(int idx);
368bool server_trigger_info(int idx, char *map, size_t mapn, Vector &mins,
369 Vector &maxs);
370int server_npc_turret_flags(int idx);
371int server_model_index(void *base);
372void find_modules();
373bool module_jump_slot(const char *path, const char *name, uintptr_t *vaddr,
374 uintptr_t *bias);
375void init_conmsg();
376bool feature_active(int feature); // enabled AND bind held (or unbound)
377bool feature_enabled(int feature); // enabled, regardless of bind
378bool feature_has_bind(int feature);
379bool feature_bind_held(int feature);
380bool esp_option(int opt);
381bool bhop_autostrafe_enabled();
382bool jumpbug_assist_enabled();
383bool spread_no_spread_enabled();
384bool spread_engine_enabled();
385bool aim_punch_enabled();
386unsigned aimbot_bone_mask();
387int aimbot_smooth_step();
388bool aimbot_vischeck_enabled();
389int aimbot_fov();
390bool aimbot_fov_circle();
391void aimbot_reset_lock();
392void silentaim_reset_lock();
393void *entitylist_get(int idx);
394bool esp_is_npc_index(int idx);
395bool esp_is_viewmodel_index(int idx);
396int esp_npc_relation(int idx);
397void *world_find_material(const char *name);
398void chams_init();
399void chams_preload();
400int engine_get_local_player();
401void draw_text_col(int x, int y, const char *s, int r, int g, int b);
402void draw_text_small_col(int x, int y, const char *s, int r, int g, int b);
403void esp_draw();
404void esp_draw_fov_circle(); // aimbot cone, independent of the ESP toggle
405void esp_reset_session(); // map change / respawn: clear per-map latches
406void esp_draw_items();
407void esp_draw_projectiles();
408void prop_tint_update();
409void studio_props_init();
410bool world_to_screen(const Vector &w, float &sx, float &sy);
411void set_silent_restore(const QAngle &angles);
412bool is_visible(const Vector &eye, const Vector &point,
413 void *self = nullptr, void *target = nullptr);
414void *trace_entity(const Vector &start, const Vector &end, void *ignore);
415bool trace_solid_segment(const Vector &start, const Vector &end, void *ignore,
416 Vector &out_end, Vector &out_normal);
417float ground_distance(const Vector &origin, void *ignore, float max_dist);
418bool point_ground(const Vector &point, void *ignore);
419
420// bones.cpp — client-side animated skeleton / hitbox access (see there)
421bool bones_update(int idx, void *ent);
422int bones_count(int idx);
423int bone_find(int idx, const char *name);
424int bone_parent(int idx, int bone);
425bool bone_pos(int idx, int bone, Vector &out);
426bool bone_is_skeleton_core(int idx, int bone);
427int bone_nearest_core_parent(int idx, int bone);
428bool bones_is_humanoid(int idx);
429bool hitbox_center(int idx, const char *hitbox_name, Vector &out);
430void bones_clear();
431bool head_position(int idx, Vector &out);
432int aim_points(int idx, unsigned group_mask, Vector *out, int max);
433
434void outer_draw();
435void gui_handle_input();
436void gui_draw();
437bool gui_is_open();
438bool gui_bind_capture_active();
439QAngle gui_frozen_view();
440void gui_config_init();
441void gui_config_write(FILE *f);
442#endif 17#endif
diff --git a/src/settings.h b/src/settings.h
new file mode 100644
index 0000000..67c82ae
--- /dev/null
+++ b/src/settings.h
@@ -0,0 +1,117 @@
1#ifndef HL2H_SETTINGS_H
2#define HL2H_SETTINGS_H
3
4#include "core.h"
5
6enum FeatureId {
7 FEAT_BHOP = 0,
8 FEAT_ABH = 1,
9 FEAT_ESP = 2,
10 FEAT_AIMBOT = 3,
11 FEAT_TRIGGERBOT = 4,
12 FEAT_SILENTAIM = 5,
13 FEAT_JUMPBUG = 6,
14 FEAT_MELEE = 7,
15 FEAT_SPREAD = 8,
16 FEAT_ITEM_ESP = 9,
17 FEAT_FULLBRIGHT = 10,
18 FEAT_WORLD_TINT = 11,
19 FEAT_FOG = 12,
20 FEAT_SKYBOX = 13,
21 FEAT_PROJECTILES = 14,
22 FEAT_CHAMS = 15,
23 FEAT_COUNT = 16
24};
25enum EspOption {
26 ESP_OPT_SHOW_NEUTRAL = 0,
27 ESP_OPT_SHOW_HEALTHBAR = 1,
28 ESP_OPT_SHOW_HEALTHNUM = 2,
29 ESP_OPT_SHOW_NAME = 3,
30 ESP_OPT_SHOW_SKELETON = 4,
31 ESP_OPT_SHOW_BOX = 5,
32 ESP_OPT_SHOW_SPEEDGRAPH = 6,
33 ESP_OPT_DAMAGE_TAGS = 7,
34 ESP_OPT_ALERT = 8,
35 ESP_OPT_WEAPON = 9,
36 ESP_OPT_ARROWS = 10,
37 ESP_OPT_COUNT = 11
38};
39enum AimBone {
40 AIM_BONE_HEAD = 0,
41 AIM_BONE_TORSO,
42 AIM_BONE_LARM,
43 AIM_BONE_RARM,
44 AIM_BONE_LLEG,
45 AIM_BONE_RLEG,
46 AIM_BONE_COUNT
47};
48
49// ---------------------------------------------------------------------------
50// feature state / settings (owned by menu.cpp alongside config)
51// ---------------------------------------------------------------------------
52
53struct FeatureState {
54 bool active;
55 int bind; // SDL scancode, 0 = none (always-on)
56};
57
58extern FeatureState g_bhop, g_abh, g_jumpbug, g_melee, g_spread, g_esp,
59 g_aimbot, g_triggerbot, g_silentaim, g_item_esp, g_fullbright,
60 g_world_tint, g_fog, g_skybox, g_projectiles, g_chams;
61extern bool g_proj_fuse, g_proj_radius, g_proj_traj;
62
63// Chams settings per relationship, and separate visible / through-wall
64// (invisible) material and colour. The viewmodel has a single style.
65struct ChamsGroup {
66 bool vis_on;
67 int vis_mat;
68 int vis_rgb[4]; // r, g, b, a (0..255)
69 bool inv_on;
70 int inv_mat;
71 int inv_rgb[4];
72};
73extern ChamsGroup g_chams_hostile, g_chams_neutral, g_chams_friendly;
74extern bool g_chams_viewmodel;
75extern int g_chams_vm_mat;
76extern int g_chams_vm_rgb[4];
77extern bool g_tint_world_on, g_tint_sky_on, g_tint_prop_on;
78extern int g_tint_world_rgb[3], g_tint_sky_rgb[3], g_tint_prop_rgb[3];
79extern bool g_fog_skybox, g_fog_disable;
80extern int g_fog_rgb[3], g_fog_start, g_fog_end;
81extern bool g_bhop_autostrafe;
82extern bool g_jumpbug_assist;
83extern bool g_spread_no_spread;
84extern bool g_item_health;
85extern bool g_item_ammo;
86extern bool g_item_armor;
87extern bool g_item_weapons;
88extern bool g_item_crates;
89extern bool g_item_distance;
90extern bool g_item_usable;
91extern int g_item_max_dist;
92extern bool g_aim_bones[AIM_BONE_COUNT];
93extern int g_aim_smooth;
94extern bool g_aim_vischeck;
95extern int g_aim_fov;
96extern bool g_aim_fov_circle;
97extern bool g_aim_punch;
98extern bool g_spread_engine;
99extern bool g_auto_crouchjump;
100extern bool g_edge_jump;
101extern int g_fov_camera;
102extern int g_fov_viewmodel;
103extern int g_tonemap;
104extern int g_esp_col_hostile[3];
105extern int g_esp_col_neutral[3];
106extern int g_esp_col_friendly[3];
107extern bool g_esp_opt[ESP_OPT_COUNT];
108extern int g_spread_pellets;
109
110const char *scancode_name(int sc);
111void config_save();
112void config_reload();
113void config_reset_defaults();
114const char *config_path_cstr();
115const char *config_file_cstr(const char *name);
116
117#endif