Skip to content

Commit 87282db

Browse files
authored
Merge pull request #2959 from 2dos/quick-changes
Changes
2 parents 663b1bf + 940a989 commit 87282db

File tree

19 files changed

+606
-584
lines changed

19 files changed

+606
-584
lines changed

archipelago/Logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ def CanAccessKRool(self):
14961496
Events.CastleKeyTurnedIn,
14971497
Events.HelmKeyTurnedIn,
14981498
]
1499-
if self.settings.k_rool_vanilla_requirement:
1499+
if self.settings.win_condition_item == WinConditionComplex.get_keys_3_and_8:
15001500
required_base_keys = [
15011501
Events.FactoryKeyTurnedIn,
15021502
Events.HelmKeyTurnedIn,

base-hack/include/global.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ extern void checkSeedVictory(void);
236236
extern void checkVictory_flaghook(int flag);
237237
extern void winRabbitSeed(int song, float volume);
238238
extern void safeguardRabbitReward(void);
239-
extern int canAccessKroolsChallenge(void);
240239
extern int canAccessWinCondition(void);
241240
extern void FileProgressInitSub(int file, int shuffle);
242241
extern void handleFileSelectSprites(void* paad, void* sprite, int x, int y, float scale, int unk0, int control);
@@ -389,6 +388,9 @@ extern void HelmLobbyGoneCode(behaviour_data* behaviour_pointer, int index);
389388
extern void setObjectOpacity(behaviour_data* behaviour_pointer, int opacity);
390389
extern int standingOnM2Object(int index);
391390

391+
extern void renderSparkles(float scale);
392+
extern void renderBoulderSparkles(actorData *actor);
393+
392394
extern int getItemCountReq(requirement_item item);
393395
extern int isItemRequirementSatisfied(ItemRequirement* req);
394396

base-hack/include/variable_space_structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ typedef struct varspace {
138138
/* 0x1C6 */ RandomSwitchesSetting switchsanity; // Size 0x15
139139
/* 0x1DB */ unsigned char fungi_time_of_day_setting; // See fungi_time enum
140140
/* 0x1DC */ unsigned char galleon_water_raised;
141-
/* 0x1DD */ unsigned char krool_requirements; // K Rool bitfield 8765 4321
141+
/* 0x1DD */ unsigned char unk_1dd;
142142
/* 0x1DE */ RemovedBarriers removed_barriers; // Size: 2
143143
/* 0x1E0 */ FasterChecks faster_checks; // Size: 1
144144
/* 0x1E1 */ char big_head_mode; // 0 = off, 1 = on, 2 = small head

base-hack/src/instances/instances.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,19 +495,15 @@ int change_object_scripts(behaviour_data* behaviour_pointer, int id, int index,
495495
}
496496
} else if (param2 == K_ROOL_SHIP) {
497497
// Check access requirements based on ship spawn method
498-
if (Rando.win_condition_spawns_ship == 1) {
498+
if (Rando.win_condition_spawns_ship) {
499499
// Win condition-based access
500500
if (!canAccessWinCondition()) {
501501
return 0;
502502
}
503503
} else {
504504
// Key-based access
505-
for (int i = 0; i < 8; i++) {
506-
if (Rando.krool_requirements & (1 << i)) {
507-
if (!getItemCount_new(REQITEM_KEY, i, 0)) {
508-
return 0;
509-
}
510-
}
505+
if (!getItemCount_new(REQITEM_KEY, -1, 0) < 8) {
506+
return 0;
511507
}
512508
}
513509
return 1;

base-hack/src/item rando/enemy_items.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,27 @@ float getRNGWithinRange(float min, float max) {
109109
return min + offset;
110110
}
111111

112+
void renderSparkles(float scale) {
113+
*(char*)(0x807FDB18) = 1; // Adjust Z-Indexing
114+
*(short*)(0x807FDB36) = 4; // Fix rendering
115+
float x_offset = getRNGWithinRange(-20.f, 20.0f);
116+
float y_offset = getRNGWithinRange(5.0f, 25.0f);
117+
float z_offset = getRNGWithinRange(-20.f, 20.0f);
118+
x_offset *= scale;
119+
y_offset *= scale;
120+
z_offset *= scale;
121+
int sprite = 0x5E;
122+
if (getRNGLower31() & 1) {
123+
sprite = 0x69;
124+
}
125+
displaySpriteAtXYZ(
126+
sprite_table[sprite],
127+
0.6f,
128+
CurrentActorPointer_0->xPos + x_offset,
129+
CurrentActorPointer_0->yPos + y_offset,
130+
CurrentActorPointer_0->zPos + z_offset);
131+
}
132+
112133
void indicateCollectionStatus(void) {
113134
*(char*)(0x807F94AE) = 0;
114135
*(char*)(0x807F94AF) = 0;
@@ -125,21 +146,7 @@ void indicateCollectionStatus(void) {
125146
if (!canSpawnEnemyReward()) {
126147
return;
127148
}
128-
*(char*)(0x807FDB18) = 1; // Adjust Z-Indexing
129-
*(short*)(0x807FDB36) = 4; // Fix rendering
130-
float x_offset = getRNGWithinRange(-20.f, 20.0f);
131-
float y_offset = getRNGWithinRange(5.0f, 25.0f);
132-
float z_offset = getRNGWithinRange(-20.f, 20.0f);
133-
int sprite = 0x5E;
134-
if (getRNGLower31() & 1) {
135-
sprite = 0x69;
136-
}
137-
displaySpriteAtXYZ(
138-
sprite_table[sprite],
139-
0.6f,
140-
CurrentActorPointer_0->xPos + x_offset,
141-
CurrentActorPointer_0->yPos + y_offset,
142-
CurrentActorPointer_0->zPos + z_offset);
149+
renderSparkles(1.0f);
143150
}
144151

145152

base-hack/src/item rando/spawning.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,23 +300,28 @@ void* updateKegIDs(int actor, float x, float y, float z) {
300300
return spawnActorAtXYZ(actor, x, y, z);
301301
}
302302

303-
void spawnBoulderObject(actorData *actor) {
304-
int index = getBoulderIndex();
303+
int isValidBoulderObject(int index) {
305304
if (index < 0) {
306-
return;
305+
return 0;
307306
}
308307
if (HoldableSpawnBitfield & (1 << index)) {
309-
return;
308+
return 0;
310309
}
311310
int flag = FLAG_GRABBABLES_DESTROYED + index;
312311
if (checkFlag(flag, FLAGTYPE_PERMANENT)) {
313-
return;
312+
return 0;
314313
}
315314
int item = getBoulderItem(index);
316-
if (!item) {
317-
return;
318-
}
319315
if (item == NEWACTOR_NULL) {
316+
return 0;
317+
}
318+
return item;
319+
}
320+
321+
void spawnBoulderObject(actorData *actor) {
322+
int index = getBoulderIndex();
323+
int item = isValidBoulderObject(index);
324+
if (!item) {
320325
return;
321326
}
322327
int cutscene = 1;
@@ -328,8 +333,26 @@ void spawnBoulderObject(actorData *actor) {
328333
actor->yPos,
329334
actor->zPos,
330335
0, cutscene,
331-
flag, 0,
336+
FLAG_GRABBABLES_DESTROYED + index, 0,
332337
boulder_item_table[index].level,
333338
boulder_item_table[index].kong);
334339
HoldableSpawnBitfield |= (1 << index);
340+
}
341+
342+
void renderBoulderSparkles(actorData *actor) {
343+
unkBonusFunction(actor);
344+
int index = getBoulderIndex();
345+
int item = isValidBoulderObject(index);
346+
if (!item) {
347+
return;
348+
}
349+
int timer = ObjectModel2Timer + (index * 5);
350+
if (timer % 10) {
351+
return;
352+
}
353+
float scale = 1.0f;
354+
if (index == GRABBABLE_CAVES_LARGE) {
355+
scale = 3.0f;
356+
}
357+
renderSparkles(scale);
335358
}

base-hack/src/misc/music_text.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,17 @@ void SpeedUpMusic(void) {
6262
return;
6363
}
6464
win_conditions win_con = Rando.win_condition;
65-
if (win_con == GOAL_KROOLS_CHALLENGE) {
66-
if (!canAccessKroolsChallenge()) {
65+
if (Rando.win_condition_spawns_ship) {
66+
if (!canAccessWinCondition()) {
6767
return;
6868
}
69-
} else {
70-
requirement_item win_con_item = Rando.win_condition_extra.item;
69+
} else if (win_con == GOAL_CUSTOMITEM) {
7170
int win_con_count = Rando.win_condition_extra.count;
72-
// Checking items
73-
if (win_con == GOAL_KROOL) {
74-
win_con_item = REQITEM_KEY;
75-
win_con_count = 9; // Triggers upon picking up the 8th key
76-
} else if (win_con != GOAL_CUSTOMITEM) {
77-
// Goal is ineligible for speed up
78-
return;
79-
}
8071
if (win_con_count < 2) {
8172
// Doesn't work for 1-item win conditions
8273
return;
8374
}
84-
int item_count = getItemCountReq(win_con_item);
75+
int item_count = getItemCountReq(Rando.win_condition_extra.item);
8576
if (item_count != (win_con_count - 1)) {
8677
return;
8778
}

base-hack/src/misc/win_condition.c

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -118,30 +118,6 @@ int hasBeatenDKRapWinCon(void) {
118118
return 1;
119119
}
120120

121-
int canAccessKroolsChallenge(void) {
122-
// Check all 8 Keys
123-
if (getItemCountReq(REQITEM_KEY) < 8) {
124-
return 0;
125-
}
126-
127-
// Check all 40 Blueprints
128-
if (getItemCountReq(REQITEM_BLUEPRINT) < 40) {
129-
return 0;
130-
}
131-
132-
// Check all 7 Bosses
133-
if (getItemCountReq(REQITEM_BOSSES) < 7) {
134-
return 0;
135-
}
136-
137-
// Check all 43 Bonus Barrels
138-
if (getItemCountReq(REQITEM_BONUSES_NOHELM) < 43) {
139-
return 0;
140-
}
141-
142-
return 1;
143-
}
144-
145121
int canAccessWinCondition(void) {
146122
// Check if the win condition requirements are met
147123
switch(Rando.win_condition) {
@@ -172,8 +148,19 @@ int canAccessWinCondition(void) {
172148

173149
case GOAL_KROOLS_CHALLENGE:
174150
// Krool's Challenge - check if all required items are collected
175-
return canAccessKroolsChallenge();
176-
151+
if (getItemCountReq(REQITEM_KEY) < 8) {
152+
return 0;
153+
}
154+
if (getItemCountReq(REQITEM_BLUEPRINT) < 40) {
155+
return 0;
156+
}
157+
if (getItemCountReq(REQITEM_BOSSES) < 7) {
158+
return 0;
159+
}
160+
if (getItemCountReq(REQITEM_BONUSES_NOHELM) < 43) {
161+
return 0;
162+
}
163+
return 1;
177164
case GOAL_CUSTOMITEM:
178165
// Custom item requirement - check the specified item count
179166
return isItemRequirementSatisfied(&Rando.win_condition_extra);
@@ -188,7 +175,7 @@ int canAccessWinCondition(void) {
188175
void checkSeedVictory(void) {
189176
if (!checkFlag(FLAG_GAME_BEATEN, FLAGTYPE_PERMANENT)) {
190177
// If win_condition_spawns_ship is enabled, don't trigger victory on win condition items - only when K. Rool is defeated
191-
if (Rando.win_condition_spawns_ship == 1) {
178+
if (Rando.win_condition_spawns_ship) {
192179
return;
193180
}
194181
if (canAccessWinCondition()) {

randomizer/Logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ def CanAccessKRool(self):
11571157
Events.CastleKeyTurnedIn,
11581158
Events.HelmKeyTurnedIn,
11591159
]
1160-
if self.settings.k_rool_vanilla_requirement:
1160+
if self.settings.win_condition_item == WinConditionComplex.get_keys_3_and_8:
11611161
required_base_keys = [
11621162
Events.FactoryKeyTurnedIn,
11631163
Events.HelmKeyTurnedIn,

randomizer/Patching/ASM/Items.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def grabUpdates(ROM_COPY: LocalROM, settings, offset_dict: dict, spoiler):
240240
writeLabelValue(ROM_COPY, 0x80747EB0, Overlay.Static, "melonCrateItemHandler", offset_dict)
241241
# Grabbable Item Rando
242242
writeHook(ROM_COPY, 0x8069C210, Overlay.Static, "spawnHoldableObject", offset_dict)
243+
writeFunction(ROM_COPY, 0x8069BDE8, Overlay.Static, "renderBoulderSparkles", offset_dict)
243244
writeFunction(ROM_COPY, 0x8067BDA0, Overlay.Static, "updateKegIDs", offset_dict)
244245
# Jetpac Reward Text
245246
addr = getROMAddress(0x8002EABC, Overlay.Jetpac, offset_dict)

0 commit comments

Comments
 (0)