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

Commit 759636f

Browse files
authored
Rando v2 (#22)
* Improve rando significantly * Fix bitfiles * Remove local rando_log
1 parent 977d932 commit 759636f

File tree

5 files changed

+38
-48
lines changed

5 files changed

+38
-48
lines changed

Python/init.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def ReplaceDLCWithMods(caller: UObject, stack: FFrame, result: FStruct, function
7878
bNew = stack.popULong()
7979
if Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.DLC":
8080
Caption = "MODS"
81-
caller.AddListItem(EventID, Caption, bDisabled, False)
81+
bNew = True
82+
caller.AddListItem(EventID, Caption, bDisabled, bNew)
8283
stack.SkipFunction()
8384
return False
8485

Python/rando_log.json

-1
This file was deleted.

Python/randomizer.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import bl2sdk
2+
from bl2sdk import *
23
import sys
34
import random
45
import json
@@ -31,7 +32,7 @@ def RecordSeed(self):
3132
self.Seed = None
3233

3334
def Enable(self):
34-
def InjectSkills(caller, stack, result, function):
35+
def InjectSkills(caller: UObject, stack: FFrame, result: FStruct, function: UFunction):
3536
code = stack.Code
3637
SkillTreeDef = stack.popObject()
3738
stack.Code = code
@@ -75,7 +76,7 @@ def RandomizeTree(self, SkillTreeDef):
7576

7677
def RandomizeBranch(self, SkillTreeBranchDef):
7778
self.PreloadPackages()
78-
TierCountOdds = [95, 40, 70, 30, 80, 40]
79+
TierCountOdds = [95, 40, 80, 30, 80, 40]
7980
HasBloodlust = False
8081
HasHellborn = False
8182
for Tier in range(6):
@@ -94,8 +95,7 @@ def RandomizeBranch(self, SkillTreeBranchDef):
9495
SkillDefNum = self.RNG.randint(0, len(self.ValidSkills) - 1)
9596
SkillDefName = self.ValidSkills.pop(SkillDefNum)
9697
SkillDef = bl2sdk.FindObject("SkillDefinition", SkillDefName)
97-
# TEMP HACK UNTIL SDK IS REBUILD
98-
MaxPoints += SkillDef.PlayerLevelRequirement
98+
MaxPoints += SkillDef.MaxGrade
9999
NewSkills.append(SkillDef)
100100
HasHellborn = HasHellborn or "Hellborn" in SkillDef.GetFullName()
101101
if not HasBloodlust and SkillDef.GetName() in ["BloodfilledGuns", "BloodyTwitch"]:

Python/test.py

+30-9
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@
6565
# NewSkill = bl2sdk.ConstructObject(Class="SkillDefinition", Name="MyBrandNewSkill", Template=SomeSkill, Outer=SomeSkill.Outer)
6666
# Branch.Tiers[0].Skills.Set(1, NewSkill)
6767
# return True
68-
pc = bl2sdk.GetEngine().GamePlayers[0].Actor
69-
InfectionStateDef = bl2sdk.ConstructObject(Class="AnemoneInfectionDefinition", Outer=AIS.Outer, SetFlags=3)
68+
# pc = bl2sdk.GetEngine().GamePlayers[0].Actor
69+
# InfectionStateDef = bl2sdk.ConstructObject(Class="AnemoneInfectionDefinition", Outer=AIS.Outer, SetFlags=3)
7070
# Fog = bl2sdk.FindObject("HeightFog", "SanctuaryAir_Light.TheWorld:PersistentLevel.HeightFog_0")
7171
# print(InfectionStateDef)
7272
# print(Fog)
73-
pc.Pawn.AnemoneInfectionState = pc.Spawn(bl2sdk.UObject.FindClass("AnemoneInfectionState", False), pc, "Test", pc.Location, pc.Rotation, None, True)
74-
AIS = pc.Pawn.AnemoneInfectionState
75-
AIS.WPC = pc
76-
AIS.InfectionRate = 1.0
77-
AIS.ToggleInfectionEffects(True, pc)
78-
AIS.bIsLocalPlayer = True
73+
# pc.Pawn.AnemoneInfectionState = pc.Spawn(bl2sdk.UObject.FindClass("AnemoneInfectionState", False), pc, "Test", pc.Location, pc.Rotation, None, True)
74+
# AIS = pc.Pawn.AnemoneInfectionState
75+
# AIS.WPC = pc
76+
# AIS.InfectionRate = 1.0
77+
# AIS.ToggleInfectionEffects(True, pc)
78+
# AIS.bIsLocalPlayer = True
7979
# pc.Pawn.SetAnemoneInfectionState(True,True,pc.Pawn,InfectionStateDef,Fog)
8080

8181
# x = bl2sdk.ConstructObject(bl2sdk.UObject.StaticClass())
@@ -94,4 +94,25 @@
9494
# print("%s: 0x%x, 0x%x, 0x%x, 0x%x" % (obj.GetFullName(), obj.HashNext.Dummy, obj.HashOuterNext.Dummy, obj.StateFrame.Dummy, obj.LinkerIndex.Dummy))
9595
# tree.Branches.Set(2, definition)
9696
# for y in x:
97-
# print(y.GetFullName())
97+
# print(y.GetFullName())
98+
def RefreshRandoList(caller: UObject, stack: FFrame, result: FStruct, function: UFunction) -> bool:
99+
new_list = []
100+
for x in range(5):
101+
CD = FLoadCharacterData()
102+
CD.CharClass = "TestClass"
103+
CD.CharName = "TestName"
104+
CD.SaveDataId = -1
105+
CD.CharPlayedTime = "NULL"
106+
CD.CharSaveDate = "NULL"
107+
CD.PlayThrough = caller.ResolvePlaythrough(1)
108+
CD.ActiveMission = caller.ResolveMission(0)
109+
CD.PlotMission = caller.ResolveMission(0)
110+
new_list.append(CD)
111+
caller.DisplayedCharacterDataList = new_list
112+
stack.SkipFunction()
113+
return False
114+
115+
pc = bl2sdk.GetEngine().GamePlayers[0].Actor
116+
# RemoveEngineHook("WillowGame.WillowGFxLobbyLoadCharacter.SavesUpdated", "RefreshRandoList")
117+
RegisterScriptHook("WillowGame.WillowGFxLobbyLoadCharacter.SavesUpdated", "RefreshRandoList", RefreshRandoList)
118+
# movie = pc.GFxUIManager.PlayMovie(pc.GetWillowGlobals().GetGlobalsDefinition().LoadCharacterMovieDefinition, None)

bl2-sdk/gamedefines.h

+2-33
Original file line numberDiff line numberDiff line change
@@ -218,67 +218,52 @@ struct FMalloc
218218
struct FStruct
219219
{
220220
void* base;
221-
private:
222-
int bitfield = 0;
223-
unsigned long currentField = NULL;
224221
public:
225222
FStruct(void *base) {
226223
this->base = base;
227224
};
228225
UObject *popObject() {
229-
bitfield = 0;
230226
class UObject *object = ((UObject **)(this->base))[0];
231227
this->base = (void*)((UObject **)this->base + 1);
232228
return object;
233229
};
234230
struct FName *popFName() {
235-
bitfield = 0;
236231
struct FName *object = (FName *)(this->base);
237232
this->base = (void *)((FName *)this->base + 1);
238233
return object;
239234
};
240235
struct FString *popFString() {
241-
bitfield = 0;
242236
struct FString *object = (FString *)(this->base);
243237
this->base = (void *)((FString *)this->base + 1);
244238
return object;
245239
};
246240
struct FVector *popFVector() {
247-
bitfield = 0;
248241
struct FVector *object = (FVector *)(this->base);
249242
this->base = (void *)((int)this->base + 0xC);
250243
return object;
251244
};
252245
float *popFloat() {
253-
bitfield = 0;
254246
float *object = (float *)(this->base);
255247
this->base = (void *)((float *)this->base + 1);
256248
return object;
257249
};
258250
unsigned char popByte() {
259-
bitfield = 0;
260251
unsigned char object = ((char *)(this->base))[0];
261252
this->base = (void *)((char *)this->base + 1);
262253
return object;
263254
};
264255
int popInt() {
265-
bitfield = 0;
266256
int object = ((int *)(this->base))[0];
267257
this->base = (void *)((int *)this->base + 1);
268258
return object;
269259
};
270260
unsigned long popULong() {
271-
bitfield = 0;
272261
unsigned long object = ((unsigned long *)(this->base))[0];
273262
this->base = (void *)((unsigned long *)this->base + 1);
274263
return object;
275264
};
276265
bool popBool() {
277-
if (bitfield % 64 == 0) {
278-
currentField = popULong();
279-
bitfield = 0;
280-
}
281-
return (currentField & (1 << (63 - bitfield++))) == 1;
266+
return (bool)popULong();
282267
};
283268
};
284269

@@ -292,71 +277,55 @@ struct FFrame : public FOutputDevice
292277
struct FFrame* PreviousFrame;
293278
struct FOutParmRec* Outparams;
294279

295-
private:
296-
int bitfield = 0;
297-
unsigned long currentField = NULL;
298280
public:
299281
void SkipFunction() {
300282
while ((this->Code++)[0] != 0x16)
301283
;
302284
}
303285
UObject *popObject() {
304-
bitfield = 0;
305286
UObject *obj = nullptr;
306287
BL2SDK::pFrameStep(this, this->Object, &obj);
307288
return obj;
308289
};
309290
struct FName *popFName() {
310-
bitfield = 0;
311291
FName *obj = new FName();
312292
BL2SDK::pFrameStep(this, this->Object, obj);
313293
return obj;
314294
};
315295
struct FString *popFString() {
316-
bitfield = 0;
317296
FString *obj = new FString();
318297
BL2SDK::pFrameStep(this, this->Object, obj);
319298
return obj;
320299
};
321300
float popFloat() {
322-
bitfield = 0;
323301
float obj = 0;
324302
BL2SDK::pFrameStep(this, this->Object, &obj);
325303
return obj;
326304
};
327305
unsigned char popByte() {
328-
bitfield = 0;
329306
unsigned char obj = 0;
330307
BL2SDK::pFrameStep(this, this->Object, &obj);
331308
return obj;
332309
};
333310
int popInt() {
334-
bitfield = 0;
335311
int obj = 0;
336312
BL2SDK::pFrameStep(this, this->Object, &obj);
337313
return obj;
338314
};
339315
unsigned long popULong() {
340-
bitfield = 0;
341316
unsigned long obj = 0;
342317
BL2SDK::pFrameStep(this, this->Object, &obj);
343318
return obj;
344319
};
345320
bool popBool() {
346-
if (bitfield % 64 == 0) {
347-
currentField = popULong();
348-
bitfield = 0;
349-
}
350-
return (currentField & (1 << (63 - bitfield++))) == 1;
321+
return (bool)popULong();
351322
};
352323
TArray<UObject *> *popTArrayObjects() {
353-
bitfield = 0;
354324
TArray<UObject *> *obj = new TArray<UObject *>();
355325
BL2SDK::pFrameStep(this, this->Object, obj);
356326
return obj;
357327
};
358328
py::tuple popRawTArray() {
359-
bitfield = 0;
360329
TArray<void *> *obj = &TArray<void *>();
361330
BL2SDK::pFrameStep(this, this->Object, obj);
362331
return py::make_tuple(FStruct((void *)obj->Data), obj->Count);

0 commit comments

Comments
 (0)