Skip to content

Commit

Permalink
Dynamic everything (#29)
Browse files Browse the repository at this point in the history
* Add GetXProperty

* Finally got arrays of structs working

* Most of hook rework
  • Loading branch information
Matt-Hurd authored May 13, 2019
1 parent 0fbc337 commit ea25f0c
Show file tree
Hide file tree
Showing 70 changed files with 1,587 additions and 64,415 deletions.
521 changes: 462 additions & 59 deletions Python/init.py

Large diffs are not rendered by default.

20 changes: 8 additions & 12 deletions Python/randomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import json
import os


class CrossSkillRandomizer(bl2sdk.BL2MOD):
Description = "Randomize all the skills!"

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

def Enable(self):
def InjectSkills(caller: UObject, stack: FFrame, result: FStruct, function: UFunction):
code = stack.Code
SkillTreeDef = stack.popObject()
stack.Code = code
def InjectSkills(caller: UObject, function: UFunction, params: FStruct) -> bool:
if not self.Seed:
self.Seed = random.randrange(sys.maxsize)
bl2sdk.Log("Randomizing with seed '{}'".format(self.Seed))
self.RNG = random.Random(self.Seed)
self.RecordSeed()
else:
self.RNG = random.Random(self.Seed)
self.RandomizeTree(SkillTreeDef)
self.RandomizeTree(params.SkillTreeDef)
return True

bl2sdk.RegisterScriptHook(
bl2sdk.RegisterHook(
"WillowGame.PlayerSkillTree.Initialize", "InjectSkills", InjectSkills
)

def Disable(self):
bl2sdk.RemoveScriptHook("WillowGame.PlayerSkillTree.Initialize", "InjectSkills")
bl2sdk.RemoveHook("WillowGame.PlayerSkillTree.Initialize", "InjectSkills")

def PreloadPackages(self):
packages = [
Expand Down Expand Up @@ -79,7 +75,7 @@ def RandomizeBranch(self, SkillTreeBranchDef):
HasHellborn = False
for Tier in range(6):
Pity = True
TierLayout = [0, 0, 0]
TierLayout = [False, False, False]
MaxPoints = 0
NewSkills = []
for Skill in range(3):
Expand All @@ -91,7 +87,7 @@ def RandomizeBranch(self, SkillTreeBranchDef):
if (Skill == 2 and Pity):
Skill = self.RNG.randint(0, 2)
Pity = False
TierLayout[Skill] = 1
TierLayout[Skill] = True
SkillDefNum = self.RNG.randint(0, len(self.ValidSkills) - 1)
SkillDefName = self.ValidSkills.pop(SkillDefNum)
SkillDef = bl2sdk.FindObject("SkillDefinition", SkillDefName)
Expand Down Expand Up @@ -124,11 +120,11 @@ def RandomizeBranch(self, SkillTreeBranchDef):
)
NewTierLayout = SkillTreeBranchDef.Layout.Tiers[Tier]
NewTierLayout.bCellIsOccupied = TierLayout
SkillTreeBranchDef.Layout.Tiers.Set(Tier, NewTierLayout)
SkillTreeBranchDef.Layout.Tiers[Tier] = NewTierLayout
NewTier = SkillTreeBranchDef.Tiers[Tier]
NewTier.Skills = NewSkills
NewTier.PointsToUnlockNextTier = min(MaxPoints, 5)
SkillTreeBranchDef.Tiers.Set(Tier, NewTier)
SkillTreeBranchDef.Tiers[Tier] = NewTier

ClassSkills = {
"Soldier": [
Expand Down
43 changes: 4 additions & 39 deletions PythonSDK.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,19 @@
<ClCompile Include="src\BL2SDK\WillowGame_functions.cpp" />
<ClCompile Include="src\BL2SDK\WinDrv_functions.cpp" />
<ClCompile Include="src\BL2SDK\XAudio2_functions.cpp" />
<ClCompile Include="src\CEngineHookManager.cpp" />
<ClCompile Include="src\CHookManager.cpp" />
<ClCompile Include="src\CPythonInterface.cpp" />
<ClCompile Include="src\CScriptHookManager.cpp" />
<ClCompile Include="src\CSigScan.cpp" />
<ClCompile Include="src\CSimpleDetour.cpp" />
<ClCompile Include="src\GameHooks.cpp" />
<ClCompile Include="src\include\detours\detours.cpp" />
<ClCompile Include="src\include\detours\disasm.cpp" />
<ClCompile Include="src\include\detours\modules.cpp" />
<ClCompile Include="src\Logging.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\PackageFix.cpp" />
<ClCompile Include="src\pydefs\AkAudio_classes.cpp" />
<ClCompile Include="src\pydefs\AkAudio_f_structs.cpp" />
<ClCompile Include="src\pydefs\AkAudio_structs.cpp" />
<ClCompile Include="src\pydefs\Core_classes.cpp" />
<ClCompile Include="src\pydefs\Core_f_structs.cpp" />
<ClCompile Include="src\pydefs\Core_structs.cpp" />
<ClCompile Include="src\pydefs\Engine_classes.cpp" />
<ClCompile Include="src\pydefs\Engine_f_structs.cpp" />
<ClCompile Include="src\pydefs\Engine_structs.cpp" />
<ClCompile Include="src\pydefs\gamedefines.cpp" />
<ClCompile Include="src\pydefs\GameFramework_classes.cpp" />
<ClCompile Include="src\pydefs\GameFramework_f_structs.cpp" />
<ClCompile Include="src\pydefs\GameFramework_structs.cpp" />
<ClCompile Include="src\pydefs\GearboxFramework_classes.cpp" />
<ClCompile Include="src\pydefs\GearboxFramework_f_structs.cpp" />
<ClCompile Include="src\pydefs\GearboxFramework_structs.cpp" />
<ClCompile Include="src\pydefs\GFxUI_classes.cpp" />
<ClCompile Include="src\pydefs\GFxUI_f_structs.cpp" />
<ClCompile Include="src\pydefs\GFxUI_structs.cpp" />
<ClCompile Include="src\pydefs\IpDrv_classes.cpp" />
<ClCompile Include="src\pydefs\IpDrv_f_structs.cpp" />
<ClCompile Include="src\pydefs\IpDrv_structs.cpp" />
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_classes.cpp" />
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_f_structs.cpp" />
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_structs.cpp" />
<ClCompile Include="src\pydefs\WillowGame_classes.cpp" />
<ClCompile Include="src\pydefs\WillowGame_f_structs.cpp" />
<ClCompile Include="src\pydefs\WillowGame_structs.cpp" />
<ClCompile Include="src\pydefs\WinDrv_classes.cpp" />
<ClCompile Include="src\pydefs\WinDrv_f_structs.cpp" />
<ClCompile Include="src\pydefs\WinDrv_structs.cpp" />
<ClCompile Include="src\pydefs\XAudio2_classes.cpp" />
<ClCompile Include="src\pydefs\XAudio2_f_structs.cpp" />
<ClCompile Include="src\pydefs\XAudio2_structs.cpp" />
<ClCompile Include="src\pydefs\_TArray.cpp" />
<ClCompile Include="src\Settings.cpp" />
<ClCompile Include="src\stdafx.cpp" />
Expand Down Expand Up @@ -119,17 +86,15 @@
<ClInclude Include="src\include\BL2SDK\XAudio2\XAudio2_classes.h" />
<ClInclude Include="src\include\BL2SDK\XAudio2\XAudio2_f_structs.h" />
<ClInclude Include="src\include\BL2SDK\XAudio2\XAudio2_structs.h" />
<ClInclude Include="src\include\CEngineHookManager.h" />
<ClInclude Include="src\include\CHookManager.h" />
<ClInclude Include="src\include\CPythonInterface.h" />
<ClInclude Include="src\include\CScriptHookManager.h" />
<ClInclude Include="src\include\CSigScan.h" />
<ClInclude Include="src\include\CSimpleDetour.h" />
<ClInclude Include="src\include\detours\detours.h" />
<ClInclude Include="src\include\detours\detver.h" />
<ClInclude Include="src\include\Exceptions.h" />
<ClInclude Include="src\include\Exports.h" />
<ClInclude Include="src\include\external\detours\detours.h" />
<ClInclude Include="src\include\external\detours\detver.h" />
<ClInclude Include="src\include\gamedefines.h" />
<ClInclude Include="src\include\GameHooks.h" />
<ClInclude Include="src\include\Logging.h" />
<ClInclude Include="src\include\MemoryDebug.h" />
<ClInclude Include="src\include\MemorySignature.h" />
Expand Down
135 changes: 15 additions & 120 deletions PythonSDK.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,15 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\include\external\detours\detours.h">
<Filter>Header Files\detours</Filter>
</ClInclude>
<ClInclude Include="src\include\external\detours\detver.h">
<Filter>Header Files\detours</Filter>
</ClInclude>
<ClInclude Include="src\include\AntiDebug.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\BL2-SDK.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\CEngineHookManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\CPythonInterface.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\CScriptHookManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\CSigScan.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -101,9 +89,6 @@
<ClInclude Include="src\include\gamedefines.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\GameHooks.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\Logging.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -131,9 +116,6 @@
<ClInclude Include="src\include\stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\TypeMap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\Util.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -308,137 +290,47 @@
<ClInclude Include="src\include\pybind11\buffer_info.h">
<Filter>Header Files\pybind11</Filter>
</ClInclude>
<ClInclude Include="src\include\TypeMap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\detours\detours.h">
<Filter>Header Files\detours</Filter>
</ClInclude>
<ClInclude Include="src\include\detours\detver.h">
<Filter>Header Files\detours</Filter>
</ClInclude>
<ClInclude Include="src\include\CHookManager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\pydefs\_TArray.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\AkAudio_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\AkAudio_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\AkAudio_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\Core_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\Core_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\Core_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\Engine_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\Engine_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\Engine_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\gamedefines.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GameFramework_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GameFramework_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GameFramework_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GearboxFramework_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GearboxFramework_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GearboxFramework_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GFxUI_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GFxUI_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\GFxUI_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\IpDrv_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\IpDrv_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\IpDrv_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\OnlineSubsystemSteamworks_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\WillowGame_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\WillowGame_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\WillowGame_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\WinDrv_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\WinDrv_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\WinDrv_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\XAudio2_classes.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\XAudio2_f_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\pydefs\XAudio2_structs.cpp">
<Filter>Source Files\Pydefs</Filter>
</ClCompile>
<ClCompile Include="src\AntiDebug.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\BL2-SDK.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CEngineHookManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CPythonInterface.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CScriptHookManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CSigScan.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CSimpleDetour.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\GameHooks.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Logging.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -499,5 +391,8 @@
<ClCompile Include="src\include\detours\modules.cpp">
<Filter>Source Files\detours</Filter>
</ClCompile>
<ClCompile Include="src\CHookManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Loading

0 comments on commit ea25f0c

Please sign in to comment.