Skip to content

Commit 67951aa

Browse files
authored
Version 5
1 parent 09ff177 commit 67951aa

1 file changed

Lines changed: 75 additions & 8 deletions

File tree

dllmain.cpp

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ class entity
6666
return (vector3d*)&v9[12];
6767
}
6868

69+
void Teleport(vector3d* position)
70+
{
71+
vector3d* currentPosition = this->GetPosition();
72+
CREATE_FN(int, __cdecl, 0x4387F0, (void*, void*));
73+
CREATE_FN(int, __thiscall, 0x738AA0, (void*, void*));
74+
CREATE_FN(int, __thiscall, 0x779D10, (void*));
75+
CREATE_FN(int, __thiscall, 0x4145D0, (void*, char));
76+
float* v9 = (float*)((DWORD*)this)[4];
77+
int* v13 = (int*)sub_0x4145D0(*(void**)((DWORD)this + 28), 1);
78+
sub_0x4387F0(currentPosition, position);
79+
sub_0x738AA0(this, position);
80+
sub_0x779D10(v13);
81+
}
82+
6983
void ApplyDamage(int damage)
7084
{
7185
BYTE unk[32];
@@ -185,19 +199,19 @@ static void RespawnHero()
185199
ChangeHero(GetCurrentHero());
186200
}
187201

188-
static void TeleportHero(vector3d pos)
202+
static void TeleportHero(vector3d* pos)
189203
{
190204
if (IsInGame())
191205
{
192206
CREATE_FN(void, __thiscall, 0x894800, (void*, void*, char, char));
193-
sub_0x894800(*(void**)0x10CFEF0, &pos, 0, 1);
207+
sub_0x894800(*(void**)0x10CFEF0, pos, 0, 1);
194208
}
195209
}
196210

197211
static void SpawnToPoint(size_t idx)
198212
{
199213
vector3d* spawnPoints = (vector3d*)GetWorldValue2("g_hero_spawn_points");
200-
TeleportHero(spawnPoints[idx]);
214+
TeleportHero(&spawnPoints[idx]);
201215
}
202216

203217
static bool bShowStats = false;
@@ -325,7 +339,7 @@ static void TogglePause()
325339
sub_0x7F6E10(*(void**)0xDE7A1C, 4);
326340
}
327341

328-
static void UnlockAllInteriors()
342+
static void UnlockAllUndergroundInteriors()
329343
{
330344
DWORD regionsPtr = *(DWORD*)0x00F23780;
331345
if (regionsPtr != 0)
@@ -334,7 +348,11 @@ static void UnlockAllInteriors()
334348
for (size_t i = 0; i < SM3_REGIONS_COUNT; i++)
335349
{
336350
DWORD region = (regionStart + (i * SM3_SIZE_OF_REGION));
337-
*(DWORD*)((DWORD)region + 148) &= 0xFFFFFFFE;
351+
vector3d* pos = (vector3d*)(region + 208);
352+
if (pos->y < 0.0f)
353+
{
354+
*(DWORD*)((DWORD)region + 148) &= 0xFFFFFFFE;
355+
}
338356
}
339357
}
340358
}
@@ -1147,9 +1165,9 @@ static void LoadInterior(DWORD ptr)
11471165
vector3d pos2 = *(vector3d*)(ptr + 208);
11481166
pos2.y = pos1.y;
11491167
vector3d* heroPos = GetLocalPlayerEntity()->GetPosition();
1150-
if (pos2.y < 0.0f || heroPos->y < 0.0f)
1168+
if (pos2.y < 0.0f)
11511169
{
1152-
UnlockAllInteriors();
1170+
UnlockAllUndergroundInteriors();
11531171
}
11541172
else
11551173
{
@@ -1160,7 +1178,7 @@ static void LoadInterior(DWORD ptr)
11601178
*(DWORD*)((DWORD)region + 148) &= 0xFFFFFFFE;
11611179
}
11621180
}
1163-
TeleportHero(pos2);
1181+
TeleportHero(&pos2);
11641182
}
11651183

11661184
static void KillAllEntities()
@@ -1180,6 +1198,53 @@ static void KillAllEntities()
11801198
}
11811199
}
11821200

1201+
static void TeleportAllEntitiesToMe()
1202+
{
1203+
entity* localPlayer = GetLocalPlayerEntity();
1204+
entity_node* entityList = *(entity_node**)0xDEB84C;
1205+
for (entity_node* node = entityList; (node != nullptr); node = node->next)
1206+
{
1207+
entity* currentEntity = node->GetEntity();
1208+
if (currentEntity != localPlayer)
1209+
{
1210+
int hp = currentEntity->GetHealth();
1211+
if (hp > 0)
1212+
{
1213+
currentEntity->Teleport(localPlayer->GetPosition());
1214+
}
1215+
}
1216+
}
1217+
}
1218+
1219+
static void TeleportToNearestEntity()
1220+
{
1221+
float minDist = (float)0xFFFFFF;
1222+
entity* target = nullptr;
1223+
entity* localPlayer = GetLocalPlayerEntity();
1224+
entity_node* entityList = *(entity_node**)0xDEB84C;
1225+
for (entity_node* node = entityList; (node != nullptr); node = node->next)
1226+
{
1227+
entity* currentEntity = node->GetEntity();
1228+
if (currentEntity != localPlayer)
1229+
{
1230+
int hp = currentEntity->GetHealth();
1231+
if (hp > 0)
1232+
{
1233+
float dist = vector3d_Distance(localPlayer->GetPosition(), currentEntity->GetPosition());
1234+
if (dist < minDist)
1235+
{
1236+
target = currentEntity;
1237+
minDist = dist;
1238+
}
1239+
}
1240+
}
1241+
}
1242+
if (target != nullptr)
1243+
{
1244+
TeleportHero(target->GetPosition());
1245+
}
1246+
}
1247+
11831248
static bool NGLMenuOnHide()
11841249
{
11851250
if (IsGamePaused())
@@ -1339,6 +1404,8 @@ int nglPresent_Hook(void)
13391404

13401405
NGLMenu::NGLMenuItem* entitiesMenu = s_NGLMenu->AddItem(E_NGLMENU_ITEM_TYPE::E_MENU, "Entities", nullptr);
13411406
entitiesMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BUTTON, "Kill All", &KillAllEntities);
1407+
entitiesMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BUTTON, "Teleport All To Me", &TeleportAllEntitiesToMe);
1408+
entitiesMenu->AddSubItem(E_NGLMENU_ITEM_TYPE::E_BUTTON, "Teleport To Nearest", &TeleportToNearestEntity);
13421409

13431410
s_WarpButton = s_NGLMenu->AddItem(E_NGLMENU_ITEM_TYPE::E_MENU, "Warp", nullptr);
13441411
s_NGLMenu->OnHide = &NGLMenuOnHide;

0 commit comments

Comments
 (0)