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

Commit ea25f0c

Browse files
authored
Dynamic everything (#29)
* Add GetXProperty * Finally got arrays of structs working * Most of hook rework
1 parent 0fbc337 commit ea25f0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1587
-64415
lines changed

Python/init.py

+462-59
Large diffs are not rendered by default.

Python/randomizer.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import json
66
import os
77

8-
98
class CrossSkillRandomizer(bl2sdk.BL2MOD):
109
Description = "Randomize all the skills!"
1110

@@ -30,26 +29,23 @@ def RecordSeed(self):
3029
bl2sdk.Mods.insert(0, NewRando)
3130

3231
def Enable(self):
33-
def InjectSkills(caller: UObject, stack: FFrame, result: FStruct, function: UFunction):
34-
code = stack.Code
35-
SkillTreeDef = stack.popObject()
36-
stack.Code = code
32+
def InjectSkills(caller: UObject, function: UFunction, params: FStruct) -> bool:
3733
if not self.Seed:
3834
self.Seed = random.randrange(sys.maxsize)
3935
bl2sdk.Log("Randomizing with seed '{}'".format(self.Seed))
4036
self.RNG = random.Random(self.Seed)
4137
self.RecordSeed()
4238
else:
4339
self.RNG = random.Random(self.Seed)
44-
self.RandomizeTree(SkillTreeDef)
40+
self.RandomizeTree(params.SkillTreeDef)
4541
return True
4642

47-
bl2sdk.RegisterScriptHook(
43+
bl2sdk.RegisterHook(
4844
"WillowGame.PlayerSkillTree.Initialize", "InjectSkills", InjectSkills
4945
)
5046

5147
def Disable(self):
52-
bl2sdk.RemoveScriptHook("WillowGame.PlayerSkillTree.Initialize", "InjectSkills")
48+
bl2sdk.RemoveHook("WillowGame.PlayerSkillTree.Initialize", "InjectSkills")
5349

5450
def PreloadPackages(self):
5551
packages = [
@@ -79,7 +75,7 @@ def RandomizeBranch(self, SkillTreeBranchDef):
7975
HasHellborn = False
8076
for Tier in range(6):
8177
Pity = True
82-
TierLayout = [0, 0, 0]
78+
TierLayout = [False, False, False]
8379
MaxPoints = 0
8480
NewSkills = []
8581
for Skill in range(3):
@@ -91,7 +87,7 @@ def RandomizeBranch(self, SkillTreeBranchDef):
9187
if (Skill == 2 and Pity):
9288
Skill = self.RNG.randint(0, 2)
9389
Pity = False
94-
TierLayout[Skill] = 1
90+
TierLayout[Skill] = True
9591
SkillDefNum = self.RNG.randint(0, len(self.ValidSkills) - 1)
9692
SkillDefName = self.ValidSkills.pop(SkillDefNum)
9793
SkillDef = bl2sdk.FindObject("SkillDefinition", SkillDefName)
@@ -124,11 +120,11 @@ def RandomizeBranch(self, SkillTreeBranchDef):
124120
)
125121
NewTierLayout = SkillTreeBranchDef.Layout.Tiers[Tier]
126122
NewTierLayout.bCellIsOccupied = TierLayout
127-
SkillTreeBranchDef.Layout.Tiers.Set(Tier, NewTierLayout)
123+
SkillTreeBranchDef.Layout.Tiers[Tier] = NewTierLayout
128124
NewTier = SkillTreeBranchDef.Tiers[Tier]
129125
NewTier.Skills = NewSkills
130126
NewTier.PointsToUnlockNextTier = min(MaxPoints, 5)
131-
SkillTreeBranchDef.Tiers.Set(Tier, NewTier)
127+
SkillTreeBranchDef.Tiers[Tier] = NewTier
132128

133129
ClassSkills = {
134130
"Soldier": [

PythonSDK.vcxproj

+4-39
Original file line numberDiff line numberDiff line change
@@ -32,52 +32,19 @@
3232
<ClCompile Include="src\BL2SDK\WillowGame_functions.cpp" />
3333
<ClCompile Include="src\BL2SDK\WinDrv_functions.cpp" />
3434
<ClCompile Include="src\BL2SDK\XAudio2_functions.cpp" />
35-
<ClCompile Include="src\CEngineHookManager.cpp" />
35+
<ClCompile Include="src\CHookManager.cpp" />
3636
<ClCompile Include="src\CPythonInterface.cpp" />
37-
<ClCompile Include="src\CScriptHookManager.cpp" />
3837
<ClCompile Include="src\CSigScan.cpp" />
3938
<ClCompile Include="src\CSimpleDetour.cpp" />
40-
<ClCompile Include="src\GameHooks.cpp" />
4139
<ClCompile Include="src\include\detours\detours.cpp" />
4240
<ClCompile Include="src\include\detours\disasm.cpp" />
4341
<ClCompile Include="src\include\detours\modules.cpp" />
4442
<ClCompile Include="src\Logging.cpp" />
4543
<ClCompile Include="src\main.cpp" />
4644
<ClCompile Include="src\PackageFix.cpp" />
47-
<ClCompile Include="src\pydefs\AkAudio_classes.cpp" />
48-
<ClCompile Include="src\pydefs\AkAudio_f_structs.cpp" />
49-
<ClCompile Include="src\pydefs\AkAudio_structs.cpp" />
5045
<ClCompile Include="src\pydefs\Core_classes.cpp" />
51-
<ClCompile Include="src\pydefs\Core_f_structs.cpp" />
5246
<ClCompile Include="src\pydefs\Core_structs.cpp" />
53-
<ClCompile Include="src\pydefs\Engine_classes.cpp" />
54-
<ClCompile Include="src\pydefs\Engine_f_structs.cpp" />
55-
<ClCompile Include="src\pydefs\Engine_structs.cpp" />
5647
<ClCompile Include="src\pydefs\gamedefines.cpp" />
57-
<ClCompile Include="src\pydefs\GameFramework_classes.cpp" />
58-
<ClCompile Include="src\pydefs\GameFramework_f_structs.cpp" />
59-
<ClCompile Include="src\pydefs\GameFramework_structs.cpp" />
60-
<ClCompile Include="src\pydefs\GearboxFramework_classes.cpp" />
61-
<ClCompile Include="src\pydefs\GearboxFramework_f_structs.cpp" />
62-
<ClCompile Include="src\pydefs\GearboxFramework_structs.cpp" />
63-
<ClCompile Include="src\pydefs\GFxUI_classes.cpp" />
64-
<ClCompile Include="src\pydefs\GFxUI_f_structs.cpp" />
65-
<ClCompile Include="src\pydefs\GFxUI_structs.cpp" />
66-
<ClCompile Include="src\pydefs\IpDrv_classes.cpp" />
67-
<ClCompile Include="src\pydefs\IpDrv_f_structs.cpp" />
68-
<ClCompile Include="src\pydefs\IpDrv_structs.cpp" />
69-
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_classes.cpp" />
70-
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_f_structs.cpp" />
71-
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_structs.cpp" />
72-
<ClCompile Include="src\pydefs\WillowGame_classes.cpp" />
73-
<ClCompile Include="src\pydefs\WillowGame_f_structs.cpp" />
74-
<ClCompile Include="src\pydefs\WillowGame_structs.cpp" />
75-
<ClCompile Include="src\pydefs\WinDrv_classes.cpp" />
76-
<ClCompile Include="src\pydefs\WinDrv_f_structs.cpp" />
77-
<ClCompile Include="src\pydefs\WinDrv_structs.cpp" />
78-
<ClCompile Include="src\pydefs\XAudio2_classes.cpp" />
79-
<ClCompile Include="src\pydefs\XAudio2_f_structs.cpp" />
80-
<ClCompile Include="src\pydefs\XAudio2_structs.cpp" />
8148
<ClCompile Include="src\pydefs\_TArray.cpp" />
8249
<ClCompile Include="src\Settings.cpp" />
8350
<ClCompile Include="src\stdafx.cpp" />
@@ -119,17 +86,15 @@
11986
<ClInclude Include="src\include\BL2SDK\XAudio2\XAudio2_classes.h" />
12087
<ClInclude Include="src\include\BL2SDK\XAudio2\XAudio2_f_structs.h" />
12188
<ClInclude Include="src\include\BL2SDK\XAudio2\XAudio2_structs.h" />
122-
<ClInclude Include="src\include\CEngineHookManager.h" />
89+
<ClInclude Include="src\include\CHookManager.h" />
12390
<ClInclude Include="src\include\CPythonInterface.h" />
124-
<ClInclude Include="src\include\CScriptHookManager.h" />
12591
<ClInclude Include="src\include\CSigScan.h" />
12692
<ClInclude Include="src\include\CSimpleDetour.h" />
93+
<ClInclude Include="src\include\detours\detours.h" />
94+
<ClInclude Include="src\include\detours\detver.h" />
12795
<ClInclude Include="src\include\Exceptions.h" />
12896
<ClInclude Include="src\include\Exports.h" />
129-
<ClInclude Include="src\include\external\detours\detours.h" />
130-
<ClInclude Include="src\include\external\detours\detver.h" />
13197
<ClInclude Include="src\include\gamedefines.h" />
132-
<ClInclude Include="src\include\GameHooks.h" />
13398
<ClInclude Include="src\include\Logging.h" />
13499
<ClInclude Include="src\include\MemoryDebug.h" />
135100
<ClInclude Include="src\include\MemorySignature.h" />

PythonSDK.vcxproj.filters

+15-120
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,15 @@
6565
</Filter>
6666
</ItemGroup>
6767
<ItemGroup>
68-
<ClInclude Include="src\include\external\detours\detours.h">
69-
<Filter>Header Files\detours</Filter>
70-
</ClInclude>
71-
<ClInclude Include="src\include\external\detours\detver.h">
72-
<Filter>Header Files\detours</Filter>
73-
</ClInclude>
7468
<ClInclude Include="src\include\AntiDebug.h">
7569
<Filter>Header Files</Filter>
7670
</ClInclude>
7771
<ClInclude Include="src\include\BL2-SDK.h">
7872
<Filter>Header Files</Filter>
7973
</ClInclude>
80-
<ClInclude Include="src\include\CEngineHookManager.h">
81-
<Filter>Header Files</Filter>
82-
</ClInclude>
8374
<ClInclude Include="src\include\CPythonInterface.h">
8475
<Filter>Header Files</Filter>
8576
</ClInclude>
86-
<ClInclude Include="src\include\CScriptHookManager.h">
87-
<Filter>Header Files</Filter>
88-
</ClInclude>
8977
<ClInclude Include="src\include\CSigScan.h">
9078
<Filter>Header Files</Filter>
9179
</ClInclude>
@@ -101,9 +89,6 @@
10189
<ClInclude Include="src\include\gamedefines.h">
10290
<Filter>Header Files</Filter>
10391
</ClInclude>
104-
<ClInclude Include="src\include\GameHooks.h">
105-
<Filter>Header Files</Filter>
106-
</ClInclude>
10792
<ClInclude Include="src\include\Logging.h">
10893
<Filter>Header Files</Filter>
10994
</ClInclude>
@@ -131,9 +116,6 @@
131116
<ClInclude Include="src\include\stdafx.h">
132117
<Filter>Header Files</Filter>
133118
</ClInclude>
134-
<ClInclude Include="src\include\TypeMap.h">
135-
<Filter>Header Files</Filter>
136-
</ClInclude>
137119
<ClInclude Include="src\include\Util.h">
138120
<Filter>Header Files</Filter>
139121
</ClInclude>
@@ -308,137 +290,47 @@
308290
<ClInclude Include="src\include\pybind11\buffer_info.h">
309291
<Filter>Header Files\pybind11</Filter>
310292
</ClInclude>
293+
<ClInclude Include="src\include\TypeMap.h">
294+
<Filter>Header Files</Filter>
295+
</ClInclude>
296+
<ClInclude Include="src\include\detours\detours.h">
297+
<Filter>Header Files\detours</Filter>
298+
</ClInclude>
299+
<ClInclude Include="src\include\detours\detver.h">
300+
<Filter>Header Files\detours</Filter>
301+
</ClInclude>
302+
<ClInclude Include="src\include\CHookManager.h">
303+
<Filter>Header Files</Filter>
304+
</ClInclude>
311305
</ItemGroup>
312306
<ItemGroup>
313307
<ClCompile Include="src\pydefs\_TArray.cpp">
314308
<Filter>Source Files\Pydefs</Filter>
315309
</ClCompile>
316-
<ClCompile Include="src\pydefs\AkAudio_classes.cpp">
317-
<Filter>Source Files\Pydefs</Filter>
318-
</ClCompile>
319-
<ClCompile Include="src\pydefs\AkAudio_f_structs.cpp">
320-
<Filter>Source Files\Pydefs</Filter>
321-
</ClCompile>
322-
<ClCompile Include="src\pydefs\AkAudio_structs.cpp">
323-
<Filter>Source Files\Pydefs</Filter>
324-
</ClCompile>
325310
<ClCompile Include="src\pydefs\Core_classes.cpp">
326311
<Filter>Source Files\Pydefs</Filter>
327312
</ClCompile>
328-
<ClCompile Include="src\pydefs\Core_f_structs.cpp">
329-
<Filter>Source Files\Pydefs</Filter>
330-
</ClCompile>
331313
<ClCompile Include="src\pydefs\Core_structs.cpp">
332314
<Filter>Source Files\Pydefs</Filter>
333315
</ClCompile>
334-
<ClCompile Include="src\pydefs\Engine_classes.cpp">
335-
<Filter>Source Files\Pydefs</Filter>
336-
</ClCompile>
337-
<ClCompile Include="src\pydefs\Engine_f_structs.cpp">
338-
<Filter>Source Files\Pydefs</Filter>
339-
</ClCompile>
340-
<ClCompile Include="src\pydefs\Engine_structs.cpp">
341-
<Filter>Source Files\Pydefs</Filter>
342-
</ClCompile>
343316
<ClCompile Include="src\pydefs\gamedefines.cpp">
344317
<Filter>Source Files\Pydefs</Filter>
345318
</ClCompile>
346-
<ClCompile Include="src\pydefs\GameFramework_classes.cpp">
347-
<Filter>Source Files\Pydefs</Filter>
348-
</ClCompile>
349-
<ClCompile Include="src\pydefs\GameFramework_f_structs.cpp">
350-
<Filter>Source Files\Pydefs</Filter>
351-
</ClCompile>
352-
<ClCompile Include="src\pydefs\GameFramework_structs.cpp">
353-
<Filter>Source Files\Pydefs</Filter>
354-
</ClCompile>
355-
<ClCompile Include="src\pydefs\GearboxFramework_classes.cpp">
356-
<Filter>Source Files\Pydefs</Filter>
357-
</ClCompile>
358-
<ClCompile Include="src\pydefs\GearboxFramework_f_structs.cpp">
359-
<Filter>Source Files\Pydefs</Filter>
360-
</ClCompile>
361-
<ClCompile Include="src\pydefs\GearboxFramework_structs.cpp">
362-
<Filter>Source Files\Pydefs</Filter>
363-
</ClCompile>
364-
<ClCompile Include="src\pydefs\GFxUI_classes.cpp">
365-
<Filter>Source Files\Pydefs</Filter>
366-
</ClCompile>
367-
<ClCompile Include="src\pydefs\GFxUI_f_structs.cpp">
368-
<Filter>Source Files\Pydefs</Filter>
369-
</ClCompile>
370-
<ClCompile Include="src\pydefs\GFxUI_structs.cpp">
371-
<Filter>Source Files\Pydefs</Filter>
372-
</ClCompile>
373-
<ClCompile Include="src\pydefs\IpDrv_classes.cpp">
374-
<Filter>Source Files\Pydefs</Filter>
375-
</ClCompile>
376-
<ClCompile Include="src\pydefs\IpDrv_f_structs.cpp">
377-
<Filter>Source Files\Pydefs</Filter>
378-
</ClCompile>
379-
<ClCompile Include="src\pydefs\IpDrv_structs.cpp">
380-
<Filter>Source Files\Pydefs</Filter>
381-
</ClCompile>
382-
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_classes.cpp">
383-
<Filter>Source Files\Pydefs</Filter>
384-
</ClCompile>
385-
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_f_structs.cpp">
386-
<Filter>Source Files\Pydefs</Filter>
387-
</ClCompile>
388-
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_structs.cpp">
389-
<Filter>Source Files\Pydefs</Filter>
390-
</ClCompile>
391-
<ClCompile Include="src\pydefs\WillowGame_classes.cpp">
392-
<Filter>Source Files\Pydefs</Filter>
393-
</ClCompile>
394-
<ClCompile Include="src\pydefs\WillowGame_f_structs.cpp">
395-
<Filter>Source Files\Pydefs</Filter>
396-
</ClCompile>
397-
<ClCompile Include="src\pydefs\WillowGame_structs.cpp">
398-
<Filter>Source Files\Pydefs</Filter>
399-
</ClCompile>
400-
<ClCompile Include="src\pydefs\WinDrv_classes.cpp">
401-
<Filter>Source Files\Pydefs</Filter>
402-
</ClCompile>
403-
<ClCompile Include="src\pydefs\WinDrv_f_structs.cpp">
404-
<Filter>Source Files\Pydefs</Filter>
405-
</ClCompile>
406-
<ClCompile Include="src\pydefs\WinDrv_structs.cpp">
407-
<Filter>Source Files\Pydefs</Filter>
408-
</ClCompile>
409-
<ClCompile Include="src\pydefs\XAudio2_classes.cpp">
410-
<Filter>Source Files\Pydefs</Filter>
411-
</ClCompile>
412-
<ClCompile Include="src\pydefs\XAudio2_f_structs.cpp">
413-
<Filter>Source Files\Pydefs</Filter>
414-
</ClCompile>
415-
<ClCompile Include="src\pydefs\XAudio2_structs.cpp">
416-
<Filter>Source Files\Pydefs</Filter>
417-
</ClCompile>
418319
<ClCompile Include="src\AntiDebug.cpp">
419320
<Filter>Source Files</Filter>
420321
</ClCompile>
421322
<ClCompile Include="src\BL2-SDK.cpp">
422323
<Filter>Source Files</Filter>
423324
</ClCompile>
424-
<ClCompile Include="src\CEngineHookManager.cpp">
425-
<Filter>Source Files</Filter>
426-
</ClCompile>
427325
<ClCompile Include="src\CPythonInterface.cpp">
428326
<Filter>Source Files</Filter>
429327
</ClCompile>
430-
<ClCompile Include="src\CScriptHookManager.cpp">
431-
<Filter>Source Files</Filter>
432-
</ClCompile>
433328
<ClCompile Include="src\CSigScan.cpp">
434329
<Filter>Source Files</Filter>
435330
</ClCompile>
436331
<ClCompile Include="src\CSimpleDetour.cpp">
437332
<Filter>Source Files</Filter>
438333
</ClCompile>
439-
<ClCompile Include="src\GameHooks.cpp">
440-
<Filter>Source Files</Filter>
441-
</ClCompile>
442334
<ClCompile Include="src\Logging.cpp">
443335
<Filter>Source Files</Filter>
444336
</ClCompile>
@@ -499,5 +391,8 @@
499391
<ClCompile Include="src\include\detours\modules.cpp">
500392
<Filter>Source Files\detours</Filter>
501393
</ClCompile>
394+
<ClCompile Include="src\CHookManager.cpp">
395+
<Filter>Source Files</Filter>
396+
</ClCompile>
502397
</ItemGroup>
503398
</Project>

0 commit comments

Comments
 (0)