Skip to content

Commit c9c5560

Browse files
authored
Version 3
1 parent 3c67f94 commit c9c5560

1 file changed

Lines changed: 75 additions & 29 deletions

File tree

dllmain.cpp

Lines changed: 75 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#define SM3_FIXED_DELTA_TIME 0.033333335f
1010
#define SM3_PLAYER_MAX_HEALTH 2000
11-
#define SM3_HERO_NAME_MAX_SIZE 16
1211
#define SM3_SPAWN_PONTS_COUNT 13
1312
#define SM3_SIZE_OF_REGION 304
1413
#define SM3_REGIONS_COUNT 560
@@ -17,12 +16,12 @@
1716
typedef RETURN_TYPE(CALLING_CONV* sub_##RVA##_t)ARGS; \
1817
sub_##RVA##_t sub_##RVA = (sub_##RVA##_t)##RVA \
1918

20-
struct Sm3Vector3
19+
struct vector3d
2120
{
2221
float x, y, z;
2322
};
2423

25-
static float Sm3Vector3_Distance(Sm3Vector3* a, Sm3Vector3* b)
24+
static float vector3d_Distance(vector3d* a, vector3d* b)
2625
{
2726
float x = a->x - b->x;
2827
float y = a->y - b->y;
@@ -61,19 +60,19 @@ static float* GetWorldValue2(const char* g)
6160
return sub_0x906100(*(void**)0x110A668, g);
6261
}
6362

64-
static Sm3Vector3* GetHeroPosPtr()
63+
static vector3d* GetHeroPosPtr()
6564
{
6665
DWORD v1 = *(DWORD*)0x10CFEF0;
6766
int* v6 = *(int**)(*(DWORD*)(v1 + 532) + 16);
6867
float* v47 = ((float*)v6 + 12);
69-
return (Sm3Vector3*)v47;
68+
return (vector3d*)v47;
7069
}
7170

72-
static Sm3Vector3* GetCamPosPtr()
71+
static vector3d* GetCamPosPtr()
7372
{
7473
DWORD v4 = *(DWORD*)0xDE7A1C;
7574
DWORD v9 = *(DWORD*)(*(DWORD*)(v4 + 92) + 16) + 48;
76-
return (Sm3Vector3*)v9;
75+
return (vector3d*)v9;
7776
}
7877

7978
class Sm3String
@@ -142,24 +141,18 @@ static void RespawnHero()
142141
ChangeHero(GetCurrentHero());
143142
}
144143

145-
static void TeleportHero(Sm3Vector3 pos)
144+
static void TeleportHero(vector3d pos)
146145
{
147146
if (IsInGame())
148147
{
149-
Sm3Vector3* posPtr = GetHeroPosPtr();
150-
Sm3Vector3* camPosPtr = GetCamPosPtr();
151-
if (posPtr != nullptr && camPosPtr != nullptr)
152-
{
153-
*posPtr = pos;
154-
*camPosPtr = pos;
155-
RespawnHero();
156-
}
148+
CREATE_FN(void, __thiscall, 0x894800, (void*, void*, char, char));
149+
sub_0x894800(*(void**)0x10CFEF0, &pos, 0, 1);
157150
}
158151
}
159152

160153
static void SpawnToPoint(size_t idx)
161154
{
162-
Sm3Vector3* spawnPoints = (Sm3Vector3*)GetWorldValue2("g_hero_spawn_points");
155+
vector3d* spawnPoints = (vector3d*)GetWorldValue2("g_hero_spawn_points");
163156
TeleportHero(spawnPoints[idx]);
164157
}
165158

@@ -171,6 +164,8 @@ static bool bFreezeTimer = false;
171164
static bool bDisablePedestrians = false;
172165
static bool bDisableTraffic = false;
173166
static bool bDisableInterface = false;
167+
static bool bBlacksuitRage = false;
168+
static bool bInfiniteCombo = false;
174169

175170
static void KillHero()
176171
{
@@ -403,9 +398,6 @@ static void EndCurrentTimer()
403398
*(float*)((DWORD)s_CurrentTimer + 48) = 0.0f;
404399
}
405400

406-
typedef int (*nglPresent_t)(void);
407-
static nglPresent_t p_nglPresent;
408-
409401
#define RGBA_TO_INT(r, g, b, a) ((a << 24) | (r << 16) | (g << 8) | b)
410402

411403
enum class E_NGLMENU_ITEM_TYPE
@@ -1104,10 +1096,10 @@ static std::map<DWORD, MenuRegionInfo> s_MenuRegions;
11041096

11051097
static void LoadInterior(DWORD ptr)
11061098
{
1107-
Sm3Vector3 pos1 = *(Sm3Vector3*)(ptr + 220);
1108-
Sm3Vector3 pos2 = *(Sm3Vector3*)(ptr + 208);
1099+
vector3d pos1 = *(vector3d*)(ptr + 220);
1100+
vector3d pos2 = *(vector3d*)(ptr + 208);
11091101
pos2.y = pos1.y;
1110-
Sm3Vector3* heroPos = GetHeroPosPtr();
1102+
vector3d* heroPos = GetHeroPosPtr();
11111103
if (pos2.y < 0.0f || heroPos->y < 0.0f)
11121104
{
11131105
UnlockAllInteriors();
@@ -1205,6 +1197,10 @@ static bool NGLMenuOnShow()
12051197
return true;
12061198
}
12071199

1200+
typedef int (*nglPresent_t)(void);
1201+
static nglPresent_t original_nglPresent;
1202+
static const uintptr_t NGL_PRESENT_ADDRESS = 0x8CD650;
1203+
12081204
int nglPresent_Hook(void)
12091205
{
12101206
if (s_NGLMenu == nullptr)
@@ -1231,7 +1227,9 @@ int nglPresent_Hook(void)
12311227
spawnPointsMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BUTTON, idxBuffer, &SpawnToPoint, (void*)i);
12321228
}
12331229
heroMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BOOLEAN, "God Mode", &bGodMode);
1234-
heroMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BOOLEAN, "New Goblin Inf. Boost", &bNewGoblinBoost);
1230+
heroMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BOOLEAN, "Spidey Infinite Combo Meter", &bInfiniteCombo);
1231+
heroMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BOOLEAN, "Black Suit Rage", &bBlacksuitRage);
1232+
heroMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BOOLEAN, "New Goblin Infinite Boost", &bNewGoblinBoost);
12351233
heroMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BUTTON, "Unlock All Upgrades", &UnlockAllUpgrades);
12361234
heroMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BUTTON, "Kill Hero", &KillHero);
12371235
heroMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BUTTON, "Respawn", &RespawnHero);
@@ -1283,7 +1281,7 @@ int nglPresent_Hook(void)
12831281
}
12841282
s_NGLMenu->Draw();
12851283
s_NGLMenu->HandleUserInput();
1286-
return p_nglPresent();
1284+
return original_nglPresent();
12871285
}
12881286

12891287
typedef void(__thiscall* Sm3Game__Update_t)(void*);
@@ -1379,9 +1377,9 @@ struct Megacity
13791377
else
13801378
{
13811379
char* name = *(char**)((DWORD)region + 188);
1382-
Sm3Vector3* pos = (Sm3Vector3*)((DWORD)region + 220);
1380+
vector3d* pos = (vector3d*)((DWORD)region + 220);
13831381
char* hero = GetCurrentHero();
1384-
if (strcmp(hero, "ch_playergoblin") == 0 && strncmp(name, "DBG", 3) == 0 && Sm3Vector3_Distance(pos, GetHeroPosPtr()) < 130.0f)
1382+
if (strcmp(hero, "ch_playergoblin") == 0 && strncmp(name, "DBG", 3) == 0 && vector3d_Distance(pos, GetHeroPosPtr()) < 130.0f)
13851383
{
13861384
// the game forces the daily bugle interior to unload if you switch to new goblin
13871385
// by hooking this function, we prevent that
@@ -1395,12 +1393,52 @@ struct Megacity
13951393
}
13961394
};
13971395

1396+
typedef double(__thiscall* blacksuit_player_interface__GetRageValue_t)(void*);
1397+
blacksuit_player_interface__GetRageValue_t original_blacksuit_player_interface__GetRageValue;
1398+
1399+
struct blacksuit_player_interface
1400+
{
1401+
static const uintptr_t GET_RAGE_VALUE_ADDRESS = 0x66B260;
1402+
1403+
double GetRageValue_Hook()
1404+
{
1405+
if (bBlacksuitRage)
1406+
{
1407+
*(float*)((DWORD)this + 2028) = 1000.0f;
1408+
*(float*)((DWORD)this + 2032) = 1000.0f;
1409+
*(float*)((DWORD)this + 2036) = 1000.0f;
1410+
return 1.0;
1411+
}
1412+
else
1413+
{
1414+
return original_blacksuit_player_interface__GetRageValue(this);
1415+
}
1416+
}
1417+
};
1418+
1419+
typedef signed int(__thiscall* player_interface__UpdateComboMeter_t)(void*, float, signed int);
1420+
player_interface__UpdateComboMeter_t original_player_interface__UpdateComboMeter;
1421+
1422+
struct player_interface
1423+
{
1424+
static const uintptr_t UPDATE_COMBO_METER_ADDRESS = 0x55B5E0;
1425+
1426+
signed int UpdateComboMeter_Hook(float a2, signed int a3)
1427+
{
1428+
if (bInfiniteCombo)
1429+
a2 = 10000.0f;
1430+
1431+
return original_player_interface__UpdateComboMeter(this, a2, a3);
1432+
}
1433+
};
1434+
13981435
void StartThread(HANDLE mainThread)
13991436
{
14001437
DetourTransactionBegin();
14011438

1402-
p_nglPresent = (nglPresent_t)0x8CD650;
1403-
DetourAttach(&(PVOID&)p_nglPresent, nglPresent_Hook);
1439+
original_nglPresent = (nglPresent_t)NGL_PRESENT_ADDRESS;
1440+
DetourAttach(&(PVOID&)original_nglPresent, nglPresent_Hook);
1441+
14041442
original_Sm3Game__Update = (Sm3Game__Update_t)(Sm3Game::UPDATE_ADDRESS);
14051443
auto ptrUpdateHook = &Sm3Game::Update_Hook;
14061444
DetourAttach(&(PVOID&)original_Sm3Game__Update, *(void**)&ptrUpdateHook);
@@ -1417,6 +1455,14 @@ void StartThread(HANDLE mainThread)
14171455
auto ptrDrawHook = &IGOFrontEnd::Draw_Hook;
14181456
DetourAttach(&(PVOID&)original_IGOFrontEnd__Draw, *(void**)&ptrDrawHook);
14191457

1458+
original_blacksuit_player_interface__GetRageValue = (blacksuit_player_interface__GetRageValue_t)blacksuit_player_interface::GET_RAGE_VALUE_ADDRESS;
1459+
auto ptrGetRageValueHook = &blacksuit_player_interface::GetRageValue_Hook;
1460+
DetourAttach(&(PVOID&)original_blacksuit_player_interface__GetRageValue, *(void**)&ptrGetRageValueHook);
1461+
1462+
original_player_interface__UpdateComboMeter = (player_interface__UpdateComboMeter_t)player_interface::UPDATE_COMBO_METER_ADDRESS;
1463+
auto ptrUpdateComboMeter = &player_interface::UpdateComboMeter_Hook;
1464+
DetourAttach(&(PVOID&)original_player_interface__UpdateComboMeter, *(void**)&ptrUpdateComboMeter);
1465+
14201466
DetourTransactionCommit();
14211467
}
14221468

0 commit comments

Comments
 (0)