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

Commit

Permalink
Rando v2 (#22)
Browse files Browse the repository at this point in the history
* Improve rando significantly

* Fix bitfiles

* Remove local rando_log
  • Loading branch information
Matt-Hurd authored Apr 20, 2019
1 parent 977d932 commit 759636f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 48 deletions.
3 changes: 2 additions & 1 deletion Python/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def ReplaceDLCWithMods(caller: UObject, stack: FFrame, result: FStruct, function
bNew = stack.popULong()
if Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.DLC":
Caption = "MODS"
caller.AddListItem(EventID, Caption, bDisabled, False)
bNew = True
caller.AddListItem(EventID, Caption, bDisabled, bNew)
stack.SkipFunction()
return False

Expand Down
1 change: 0 additions & 1 deletion Python/rando_log.json

This file was deleted.

8 changes: 4 additions & 4 deletions Python/randomizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import bl2sdk
from bl2sdk import *
import sys
import random
import json
Expand Down Expand Up @@ -31,7 +32,7 @@ def RecordSeed(self):
self.Seed = None

def Enable(self):
def InjectSkills(caller, stack, result, function):
def InjectSkills(caller: UObject, stack: FFrame, result: FStruct, function: UFunction):
code = stack.Code
SkillTreeDef = stack.popObject()
stack.Code = code
Expand Down Expand Up @@ -75,7 +76,7 @@ def RandomizeTree(self, SkillTreeDef):

def RandomizeBranch(self, SkillTreeBranchDef):
self.PreloadPackages()
TierCountOdds = [95, 40, 70, 30, 80, 40]
TierCountOdds = [95, 40, 80, 30, 80, 40]
HasBloodlust = False
HasHellborn = False
for Tier in range(6):
Expand All @@ -94,8 +95,7 @@ def RandomizeBranch(self, SkillTreeBranchDef):
SkillDefNum = self.RNG.randint(0, len(self.ValidSkills) - 1)
SkillDefName = self.ValidSkills.pop(SkillDefNum)
SkillDef = bl2sdk.FindObject("SkillDefinition", SkillDefName)
# TEMP HACK UNTIL SDK IS REBUILD
MaxPoints += SkillDef.PlayerLevelRequirement
MaxPoints += SkillDef.MaxGrade
NewSkills.append(SkillDef)
HasHellborn = HasHellborn or "Hellborn" in SkillDef.GetFullName()
if not HasBloodlust and SkillDef.GetName() in ["BloodfilledGuns", "BloodyTwitch"]:
Expand Down
39 changes: 30 additions & 9 deletions Python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@
# NewSkill = bl2sdk.ConstructObject(Class="SkillDefinition", Name="MyBrandNewSkill", Template=SomeSkill, Outer=SomeSkill.Outer)
# Branch.Tiers[0].Skills.Set(1, NewSkill)
# return True
pc = bl2sdk.GetEngine().GamePlayers[0].Actor
InfectionStateDef = bl2sdk.ConstructObject(Class="AnemoneInfectionDefinition", Outer=AIS.Outer, SetFlags=3)
# pc = bl2sdk.GetEngine().GamePlayers[0].Actor
# InfectionStateDef = bl2sdk.ConstructObject(Class="AnemoneInfectionDefinition", Outer=AIS.Outer, SetFlags=3)
# Fog = bl2sdk.FindObject("HeightFog", "SanctuaryAir_Light.TheWorld:PersistentLevel.HeightFog_0")
# print(InfectionStateDef)
# print(Fog)
pc.Pawn.AnemoneInfectionState = pc.Spawn(bl2sdk.UObject.FindClass("AnemoneInfectionState", False), pc, "Test", pc.Location, pc.Rotation, None, True)
AIS = pc.Pawn.AnemoneInfectionState
AIS.WPC = pc
AIS.InfectionRate = 1.0
AIS.ToggleInfectionEffects(True, pc)
AIS.bIsLocalPlayer = True
# pc.Pawn.AnemoneInfectionState = pc.Spawn(bl2sdk.UObject.FindClass("AnemoneInfectionState", False), pc, "Test", pc.Location, pc.Rotation, None, True)
# AIS = pc.Pawn.AnemoneInfectionState
# AIS.WPC = pc
# AIS.InfectionRate = 1.0
# AIS.ToggleInfectionEffects(True, pc)
# AIS.bIsLocalPlayer = True
# pc.Pawn.SetAnemoneInfectionState(True,True,pc.Pawn,InfectionStateDef,Fog)

# x = bl2sdk.ConstructObject(bl2sdk.UObject.StaticClass())
Expand All @@ -94,4 +94,25 @@
# print("%s: 0x%x, 0x%x, 0x%x, 0x%x" % (obj.GetFullName(), obj.HashNext.Dummy, obj.HashOuterNext.Dummy, obj.StateFrame.Dummy, obj.LinkerIndex.Dummy))
# tree.Branches.Set(2, definition)
# for y in x:
# print(y.GetFullName())
# print(y.GetFullName())
def RefreshRandoList(caller: UObject, stack: FFrame, result: FStruct, function: UFunction) -> bool:
new_list = []
for x in range(5):
CD = FLoadCharacterData()
CD.CharClass = "TestClass"
CD.CharName = "TestName"
CD.SaveDataId = -1
CD.CharPlayedTime = "NULL"
CD.CharSaveDate = "NULL"
CD.PlayThrough = caller.ResolvePlaythrough(1)
CD.ActiveMission = caller.ResolveMission(0)
CD.PlotMission = caller.ResolveMission(0)
new_list.append(CD)
caller.DisplayedCharacterDataList = new_list
stack.SkipFunction()
return False

pc = bl2sdk.GetEngine().GamePlayers[0].Actor
# RemoveEngineHook("WillowGame.WillowGFxLobbyLoadCharacter.SavesUpdated", "RefreshRandoList")
RegisterScriptHook("WillowGame.WillowGFxLobbyLoadCharacter.SavesUpdated", "RefreshRandoList", RefreshRandoList)
# movie = pc.GFxUIManager.PlayMovie(pc.GetWillowGlobals().GetGlobalsDefinition().LoadCharacterMovieDefinition, None)
35 changes: 2 additions & 33 deletions bl2-sdk/gamedefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,67 +218,52 @@ struct FMalloc
struct FStruct
{
void* base;
private:
int bitfield = 0;
unsigned long currentField = NULL;
public:
FStruct(void *base) {
this->base = base;
};
UObject *popObject() {
bitfield = 0;
class UObject *object = ((UObject **)(this->base))[0];
this->base = (void*)((UObject **)this->base + 1);
return object;
};
struct FName *popFName() {
bitfield = 0;
struct FName *object = (FName *)(this->base);
this->base = (void *)((FName *)this->base + 1);
return object;
};
struct FString *popFString() {
bitfield = 0;
struct FString *object = (FString *)(this->base);
this->base = (void *)((FString *)this->base + 1);
return object;
};
struct FVector *popFVector() {
bitfield = 0;
struct FVector *object = (FVector *)(this->base);
this->base = (void *)((int)this->base + 0xC);
return object;
};
float *popFloat() {
bitfield = 0;
float *object = (float *)(this->base);
this->base = (void *)((float *)this->base + 1);
return object;
};
unsigned char popByte() {
bitfield = 0;
unsigned char object = ((char *)(this->base))[0];
this->base = (void *)((char *)this->base + 1);
return object;
};
int popInt() {
bitfield = 0;
int object = ((int *)(this->base))[0];
this->base = (void *)((int *)this->base + 1);
return object;
};
unsigned long popULong() {
bitfield = 0;
unsigned long object = ((unsigned long *)(this->base))[0];
this->base = (void *)((unsigned long *)this->base + 1);
return object;
};
bool popBool() {
if (bitfield % 64 == 0) {
currentField = popULong();
bitfield = 0;
}
return (currentField & (1 << (63 - bitfield++))) == 1;
return (bool)popULong();
};
};

Expand All @@ -292,71 +277,55 @@ struct FFrame : public FOutputDevice
struct FFrame* PreviousFrame;
struct FOutParmRec* Outparams;

private:
int bitfield = 0;
unsigned long currentField = NULL;
public:
void SkipFunction() {
while ((this->Code++)[0] != 0x16)
;
}
UObject *popObject() {
bitfield = 0;
UObject *obj = nullptr;
BL2SDK::pFrameStep(this, this->Object, &obj);
return obj;
};
struct FName *popFName() {
bitfield = 0;
FName *obj = new FName();
BL2SDK::pFrameStep(this, this->Object, obj);
return obj;
};
struct FString *popFString() {
bitfield = 0;
FString *obj = new FString();
BL2SDK::pFrameStep(this, this->Object, obj);
return obj;
};
float popFloat() {
bitfield = 0;
float obj = 0;
BL2SDK::pFrameStep(this, this->Object, &obj);
return obj;
};
unsigned char popByte() {
bitfield = 0;
unsigned char obj = 0;
BL2SDK::pFrameStep(this, this->Object, &obj);
return obj;
};
int popInt() {
bitfield = 0;
int obj = 0;
BL2SDK::pFrameStep(this, this->Object, &obj);
return obj;
};
unsigned long popULong() {
bitfield = 0;
unsigned long obj = 0;
BL2SDK::pFrameStep(this, this->Object, &obj);
return obj;
};
bool popBool() {
if (bitfield % 64 == 0) {
currentField = popULong();
bitfield = 0;
}
return (currentField & (1 << (63 - bitfield++))) == 1;
return (bool)popULong();
};
TArray<UObject *> *popTArrayObjects() {
bitfield = 0;
TArray<UObject *> *obj = new TArray<UObject *>();
BL2SDK::pFrameStep(this, this->Object, obj);
return obj;
};
py::tuple popRawTArray() {
bitfield = 0;
TArray<void *> *obj = &TArray<void *>();
BL2SDK::pFrameStep(this, this->Object, obj);
return py::make_tuple(FStruct((void *)obj->Data), obj->Count);
Expand Down

0 comments on commit 759636f

Please sign in to comment.