Skip to content
This repository was archived by the owner on Jan 1, 2025. It is now read-only.

Commit 9da008a

Browse files
authored
Attack on Dragon Keep Standalone Support (#98)
* preliminary aodk support * fixed input eating whoever wrote this hex edit should be ashamed of themselves
1 parent f5d8296 commit 9da008a

File tree

6 files changed

+38
-22
lines changed

6 files changed

+38
-22
lines changed

Mods/ModMenu/MenuManager.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class _General(ModObjects.SDKMod):
6565
)
6666
Version: str = f"{VERSION_MAJOR}.{VERSION_MINOR}"
6767

68+
SupportedGames: ModObjects.Game = (
69+
ModObjects.Game.BL2 | ModObjects.Game.TPS | ModObjects.Game.AoDK
70+
)
6871
Types: ModObjects.ModTypes = ModObjects.ModTypes.All
6972

7073
Status: str = ""
@@ -75,7 +78,7 @@ class _General(ModObjects.SDKMod):
7578

7679
def SettingsInputPressed(self, action: str) -> None:
7780
if action == "Help":
78-
webbrowser.open("http://borderlandsmodding.com/sdk-mods/")
81+
webbrowser.open("http://bl-sdk.github.io/")
7982
elif action == "Open Mods Folder":
8083
os.startfile(os.path.join(os.path.dirname(sys.executable), "Mods"))
8184

@@ -157,10 +160,17 @@ def AddListItem(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params
157160
Using it cause it simplifies the code to replace the caption.
158161
"""
159162
if params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.DLC":
160-
unrealsdk.DoInjectedCallNext()
161-
caller.AddListItem(_MODS_EVENT_ID, _MODS_MENU_NAME, False, False)
162163
return False
163164

165+
inject_now = False
166+
if unrealsdk.GetEngine().GetCurrentWorldInfo().NetMode == 3: # NM_Client
167+
inject_now = params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.Disconnect"
168+
else:
169+
inject_now = params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.Quit"
170+
171+
if inject_now:
172+
caller.AddListItem(_MODS_EVENT_ID, _MODS_MENU_NAME, False, False)
173+
164174
return True
165175

166176
unrealsdk.RunHook("WillowGame.WillowScrollingList.AddListItem", "ModMenu.MenuManager", AddListItem)

Mods/ModMenu/ModObjects.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import sys
77
from abc import ABCMeta
8+
from functools import lru_cache
89
from os import path
910
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, cast
1011

@@ -78,17 +79,23 @@ class EnabledSaveType(enum.Enum):
7879
class Game(enum.Flag):
7980
BL2 = enum.auto()
8081
TPS = enum.auto()
82+
AoDK = enum.auto()
8183

8284
@staticmethod
85+
@lru_cache(None)
8386
def GetCurrent() -> Game:
8487
""" Gets the current game. """
88+
lower_exe_names: Dict[str, Game] = {
89+
"borderlands2.exe": Game.BL2,
90+
"borderlandspresequel.exe": Game.TPS,
91+
"tinytina.exe": Game.AoDK,
92+
}
93+
8594
exe = path.basename(sys.executable)
8695
exe_lower = exe.lower()
87-
if exe_lower == "borderlands2.exe":
88-
return Game.BL2
89-
elif exe_lower == "borderlandspresequel.exe":
90-
return Game.TPS
91-
raise RuntimeError(f"Unknown executable name '{exe}'!")
96+
if exe_lower not in lower_exe_names:
97+
raise RuntimeError(f"Unknown executable name '{exe}'!")
98+
return lower_exe_names[exe_lower]
9299

93100

94101
class _ModMeta(ABCMeta):
@@ -172,7 +179,7 @@ class SDKMod(metaclass=_ModMeta):
172179
Description: str = ""
173180
Version: str = "Unknown Version"
174181

175-
SupportedGames: Game = Game.BL2 | Game.TPS
182+
SupportedGames: Game = Game.BL2 | Game.TPS | Game.AoDK
176183
Types: ModTypes = ModTypes.NONE
177184
Priority: int = ModPriorities.Standard
178185
SaveEnabledState: EnabledSaveType = EnabledSaveType.NotSaved
@@ -228,7 +235,6 @@ def Enable(self) -> None:
228235
"""
229236
HookManager.RegisterHooks(self)
230237
NetworkManager.RegisterNetworkMethods(self)
231-
pass
232238

233239
def Disable(self) -> None:
234240
"""
@@ -237,7 +243,6 @@ def Disable(self) -> None:
237243
"""
238244
HookManager.RemoveHooks(self)
239245
NetworkManager.UnregisterNetworkMethods(self)
240-
pass
241246

242247
def SettingsInputPressed(self, action: str) -> None:
243248
"""

Mods/ModMenu/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
# Need to define these up here so that they're accessable when importing the other files
3939
VERSION_MAJOR = 2
40-
VERSION_MINOR = 4
40+
VERSION_MINOR = 5
4141

4242
unrealsdk.Log(f"[ModMenu] Version: {VERSION_MAJOR}.{VERSION_MINOR}")
4343

src/UnrealSDK.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,16 @@ namespace UnrealSDK
196196
try
197197
{
198198
void* SetCommand = sigscan.Scan(Signatures::SetCommand);
199-
DWORD near out = 0;
200-
if (!VirtualProtectEx(GetCurrentProcess(), SetCommand, 5, 0x40, &out))
199+
Logging::LogF("[Internal] SetCommand = 0x%p\n", SetCommand);
200+
DWORD oldProtect = 0;
201+
if (!VirtualProtectEx(GetCurrentProcess(), SetCommand, 7, PAGE_EXECUTE_READWRITE, &oldProtect))
201202
{
202203
Logging::LogF("WINAPI Error when enabling 'SET' commands: %d\n", GetLastError());
203204
}
204205
else
205206
{
206-
static_cast<unsigned char *>(SetCommand)[5] = 0xFF;
207+
static_cast<unsigned char *>(SetCommand)[5] = 0x90;
208+
static_cast<unsigned char *>(SetCommand)[6] = 0x90;
207209
}
208210
}
209211
catch (std::exception e)
@@ -280,9 +282,6 @@ namespace UnrealSDK
280282
if (!strcmp(Object->GetFullName().c_str(), ObjectMap["EngineFullName"].c_str()))
281283
gEngine = Object;
282284
}
283-
#ifdef _DEBUG
284-
Logging::InitializeExtern();
285-
#endif
286285

287286
initializeGameVersions();
288287

src/include/Games.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ static std::map<std::string, MemorySignature> bl2_signatures{{
1919
}},
2020
{
2121
"SetCommand", {
22-
"\xFF\x83\xC4\x0C\x85\xC0\x75\x1A\x6A\x01\x8D",
23-
"xxxxxxxxxxx",
24-
11
22+
"\x83\xC4\x0C\x85\xC0\x75\x1A\x6A\x01\x8D",
23+
"xxxxxxxxxx",
24+
10
2525
}},
2626
{
2727
"ProcessEvent", {
@@ -95,7 +95,8 @@ static std::map<std::string, MemorySignature> tps_signatures{ {
9595

9696
static std::map<std::string, std::map<std::string, MemorySignature>> game_signature_map{
9797
{"Borderlands2", bl2_signatures},
98-
{"BorderlandsPreSequel", tps_signatures}
98+
{"BorderlandsPreSequel", tps_signatures},
99+
{"TinyTina", tps_signatures}
99100
};
100101

101102
static std::map<std::string, std::string> bl2_object_map{
@@ -110,4 +111,5 @@ static std::map<std::string, std::string> bl2_object_map{
110111
static std::map<std::string, std::map<std::string, std::string>> game_object_map{
111112
{"Borderlands2", bl2_object_map},
112113
{"BorderlandsPreSequel", bl2_object_map},
114+
{"TinyTina", bl2_object_map}
113115
};

src/main.cpp

108 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)