Skip to content

Commit 10756f1

Browse files
committed
Entity structures improved
1 parent 9866768 commit 10756f1

File tree

3 files changed

+73
-64
lines changed

3 files changed

+73
-64
lines changed

include/entity.h

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef _ENTITY_H
2-
#define _ENTITY_H
1+
#ifndef ENTITY_HEADER
2+
#define ENTITY_HEADER
33

44
#ifndef TYPE
55
#define TYPE(x) ((uintptr_t)x)
@@ -37,46 +37,42 @@ typedef struct PlayerVtable
3737
void (__stdcall * func_25_1092AFB0)(void); // To Reverse Engineer
3838
void (__stdcall * func_26_1092AFC0)(void); // To Reverse Engineer
3939
void (__stdcall * func_27_1092AFD0)(void); // To Reverse Engineer
40-
void (__thiscall * func_28_10B852D0)(void * unknown); // No fucking clue but its huge
40+
void (__thiscall * func_28_10B852D0)(void * unknown); // No fucking clue but its huge
4141
} PlayerVtable;
4242

43-
typedef struct Entity
43+
typedef struct _Entity
4444
{
45-
PlayerVtable* lpVtable; // + 0x0000
46-
char _0xE8[0xE4];
47-
float x; // + 0x00E8
48-
float y; // + 0x00EC
49-
float z; // + 0x00F0
50-
char _0x420[0x32C];
51-
int health; // + 0x0420
45+
PlayerVtable* lpVtable; // + 0x0000
46+
char __0x0E8__[0x0E4]; // [ padding ]
47+
float x; // + 0x00E8
48+
float y; // + 0x00EC
49+
float z; // + 0x00F0
50+
char __0x420__[0x32C]; // [ padding ]
51+
int health; // + 0x0420
5252
} Entity;
5353

54-
typedef struct EntityObject
54+
typedef struct _GameWorld
5555
{
56-
struct Entity* entity;
57-
} EntityObject;
56+
Entity** entities;
57+
unsigned n_entities;
58+
} GameWorld;
5859

59-
typedef struct EntityList
60+
typedef struct _Door
6061
{
61-
struct EntityObject entities[99];
62-
} EntityList;
63-
64-
typedef struct Door
65-
{
66-
unsigned int door_type; // + 0x0000
67-
char _0x4B8[0x4B4];
68-
int access; // + 0x04B8
62+
unsigned door_type; // + 0x0000
63+
char __0x4B8__[0x4B4]; // [ padding ]
64+
int access; // + 0x04B8
6965
} Door;
7066

71-
typedef struct Weapon
67+
typedef struct _Weapon
7268
{
73-
int current_ammo; // + 0x0000
74-
int max_clip_size; // + 0x0004
75-
int total_ammo; // + 0x0008
76-
char _0x51C[0xF0];
77-
float minimum_reticle; // + 0x051C
78-
float bloom_x; // + 0x0520
79-
float bloom_y; // + 0x0524
69+
int current_ammo; // + 0x0000
70+
int max_clip_size; // + 0x0004
71+
int total_ammo; // + 0x0008
72+
char __0x51C__[0x0F0]; // [ padding ]
73+
float minimum_reticle; // + 0x051C
74+
float bloom_x; // + 0x0520
75+
float bloom_y; // + 0x0524
8076
} Weapon;
8177

82-
#endif
78+
#endif /* ENTITY_HEADER */

include/offsets.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#ifndef _OFFSETS_H
2-
#define _OFFSETS_H
1+
#ifndef OFFSETS_HEADER
2+
#define OFFSETS_HEADER
33

44
#include <stddef.h>
55
#include <stdint.h>
66

7-
uint32_t offsets_entity_list_base = 0x00A0DFEC;
7+
uint32_t offsets_game_world_base = 0x00A0DFEC;
88
uint32_t offsets_weapon_base = 0x00A0F434;
99

1010
uint32_t offsets_invisibility_base = 0x0027F12C;
@@ -17,10 +17,17 @@ uint32_t offsets_shotgun_ammo_base = 0x002FCFF0;
1717
uint32_t offsets_sniper_ammo_base = 0x002FBC58;
1818
uint32_t offsets_rapid_fire_base = 0x00178FA2;
1919

20-
uint16_t offsets_entity_list_pointers[2] = { 0x78, 0x5E4 };
21-
uint16_t offsets_weapon_pointers[3] = { 0x84, 0x6E0, 0x434 };
20+
uint16_t offsets_game_world_pointers[2] = {
21+
0x78,
22+
0x5E4
23+
};
24+
size_t offsets_game_world_pointers_size = ( sizeof(offsets_game_world_pointers)/sizeof(uint16_t) );
2225

23-
size_t offsets_entity_list_pointers_size = 2;
24-
size_t offset_weapon_pointers_size = 3;
26+
uint16_t offsets_weapon_pointers[3] = {
27+
0x84,
28+
0x6E0,
29+
0x434
30+
};
31+
size_t offsets_weapon_pointers_size = ( sizeof(offsets_weapon_pointers)/sizeof(uint16_t) );
2532

26-
#endif
33+
#endif /* OFFSETS_HEADER */

src/hacks.c

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,16 @@ void hack_DisableAlarms(bool bEnabled)
179179

180180
unsigned int hack_DisableEnemies(bool bEnabled)
181181
{
182-
EntityList* entity_list = *(EntityList **)memory_find_dynamic_address(module_base_addr + offsets_entity_list_base,
183-
offsets_entity_list_pointers,
184-
offsets_entity_list_pointers_size);
182+
GameWorld* gameWorld = (GameWorld *)memory_find_dynamic_address(module_base_addr + offsets_game_world_base,
183+
offsets_game_world_pointers,
184+
offsets_game_world_pointers_size);
185185

186-
size_t entity_list_size = *((size_t *)(memory_find_dynamic_address(module_base_addr + offsets_entity_list_base,
187-
offsets_entity_list_pointers,
188-
offsets_entity_list_pointers_size)) + 1);
186+
size_t size = gameWorld->n_entities;
189187

190188
unsigned int total_entities_changed = 0;
191-
for (size_t i = 0; i < entity_list_size; i++)
189+
for (size_t i = 0; i < size; i++)
192190
{
193-
Entity* entity = entity_list->entities[i].entity;
191+
Entity* entity = gameWorld->entities[i];
194192
if (TYPE(entity->lpVtable) == NPC)
195193
{
196194
if (bEnabled)
@@ -211,19 +209,17 @@ unsigned int hack_DisableEnemies(bool bEnabled)
211209

212210
unsigned int hack_UnlockAllDoors(void)
213211
{
214-
EntityList* _entity_list = *(EntityList **)memory_find_dynamic_address(module_base_addr + offsets_entity_list_base,
215-
offsets_entity_list_pointers,
216-
offsets_entity_list_pointers_size);
212+
GameWorld* gameWorld = (GameWorld *)memory_find_dynamic_address(module_base_addr + offsets_game_world_base,
213+
offsets_game_world_pointers,
214+
offsets_game_world_pointers_size);
217215

218-
size_t size = *((size_t *)(memory_find_dynamic_address(module_base_addr + offsets_entity_list_base,
219-
offsets_entity_list_pointers,
220-
offsets_entity_list_pointers_size)) + 1);
216+
size_t size = gameWorld->n_entities;
221217

222218
unsigned int local_total = 0;
223219
unsigned int n_doors_unlocked = 0;
224220
for (size_t i = 0; i < size; i++)
225221
{
226-
Entity* entity = _entity_list->entities[i].entity;
222+
Entity* entity = gameWorld->entities[i];
227223
if (TYPE(entity->lpVtable) == DOOR)
228224
{
229225
Door* door = (Door *)entity;
@@ -247,18 +243,16 @@ unsigned int hack_UnlockAllDoors(void)
247243

248244
void hack_test(void)
249245
{
250-
EntityList* _entity_list = *(EntityList **)memory_find_dynamic_address(module_base_addr + offsets_entity_list_base,
251-
offsets_entity_list_pointers,
252-
offsets_entity_list_pointers_size);
246+
GameWorld* gameWorld = (GameWorld *)memory_find_dynamic_address(module_base_addr + offsets_game_world_base,
247+
offsets_game_world_pointers,
248+
offsets_game_world_pointers_size);
253249

254-
size_t size = *((size_t *)(memory_find_dynamic_address(module_base_addr + offsets_entity_list_base,
255-
offsets_entity_list_pointers,
256-
offsets_entity_list_pointers_size)) + 1);
250+
size_t size = gameWorld->n_entities;
257251

258252
Entity* player = NULL;
259-
for (size_t i = 0; i < size; ++i)
253+
for (size_t i = size-1; size > 0; --i)
260254
{
261-
Entity* current_entity = _entity_list->entities[i].entity;
255+
Entity* current_entity = gameWorld->entities[i];
262256
if (TYPE(current_entity->lpVtable) == PLAYER)
263257
{
264258
player = current_entity;
@@ -268,10 +262,22 @@ void hack_test(void)
268262

269263
if (player != NULL)
270264
{
265+
// Teleport them all to me
266+
/*for (size_t i = 0; i < size; ++i)*/
267+
/*{*/
268+
/*Entity* current_entity = gameWorld->entities[i];*/
269+
/*if (TYPE(current_entity->lpVtable) == NPC)*/
270+
/*{*/
271+
/*current_entity->x = player->x;*/
272+
/*current_entity->y = player->y;*/
273+
/*current_entity->z = player->z;*/
274+
/*}*/
275+
/*}*/
276+
271277
/*player->lpVtable->function_1(player);*/
272278
/*player->lpVtable->function_2(player);*/
273279
/*player->lpVtable->function_3(player);*/
274-
player->lpVtable->func_10_1098DD40(player);
280+
/*player->lpVtable->func_10_1098DD40(player);*/
275281
/*player->lpVtable->function_5(player);*/
276282
/*player->lpVtable->function_6(player);*/
277283
/*player->lpVtable->function_7(player);*/

0 commit comments

Comments
 (0)