Skip to content

Commit e3468ed

Browse files
authored
Merge pull request #2610 from 2dos/s4
Bug Fixes
2 parents 960fc80 + c4a378c commit e3468ed

File tree

20 files changed

+773
-634
lines changed

20 files changed

+773
-634
lines changed

archipelago/Logic.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,15 @@ def galleonGatesStayOpen(self) -> bool:
657657
MiscChangesSelected.remove_galleon_ship_timers,
658658
)
659659

660+
@lru_cache(maxsize=None)
661+
def cabinBarrelMoved(self) -> bool:
662+
"""Determine whether the upper cabin rocketbarrel has been moved."""
663+
return IsItemSelected(
664+
self.settings.quality_of_life,
665+
self.settings.misc_changes_selected,
666+
MiscChangesSelected.move_spring_cabin_rocketbarrel,
667+
)
668+
660669
def canOpenLlamaTemple(self):
661670
"""Determine whether the switches on the Llama Temple can be shot."""
662671
if not (self.checkBarrier(RemovedBarriersSelected.aztec_llama_switches) or Events.LlamaFreed in self.Events):
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""File responsible for modifying the animation code file."""
2+
3+
import zlib
4+
from typing import BinaryIO
5+
from BuildClasses import ROMPointerFile
6+
from BuildEnums import TableNames
7+
from BuildLib import ROMName
8+
9+
anim_file = "animation_code.bin"
10+
11+
12+
class AnimChange:
13+
"""Class to store information pertaining to an animation coding change."""
14+
15+
def __init__(self, animation: int, offset: int, value: int, value_size: int):
16+
"""Initialize with given parameters."""
17+
self.animation = animation
18+
self.offset = offset
19+
self.value = value
20+
self.value_size = value_size
21+
22+
def enact(self, fh: BinaryIO):
23+
"""Apply the animation change."""
24+
fh.seek(self.animation * 4)
25+
header = int.from_bytes(fh.read(4), "big")
26+
fh.seek(header + self.offset)
27+
fh.write((self.value).to_bytes(self.value_size, "big"))
28+
29+
30+
anim_changes = [
31+
AnimChange(0x2C1, 0x26 + 3, 0xFF, 1), # Increase kop volume to 255
32+
AnimChange(0x2C1, 0x1C + 2, 15, 1), # Double the chance of a kop making a noise
33+
]
34+
35+
36+
def modifyAnimationCode():
37+
"""Pull geo file from ROM and modify."""
38+
with open(ROMName, "rb") as fh:
39+
anim_code_file = ROMPointerFile(fh, TableNames.Unknown13, 0)
40+
fh.seek(anim_code_file.start)
41+
dec = zlib.decompress(fh.read(anim_code_file.size), 15 + 32)
42+
with open(anim_file, "wb") as fg:
43+
fg.write(dec)
44+
with open(anim_file, "r+b") as fh:
45+
for change in anim_changes:
46+
change.enact(fh)

base-hack/Build/build.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from model_shrink import shrinkModel
3535
from port_krool_spawners import updateCutsceneScripts, updateSpawnerFiles, updatePathFiles
3636
from fixIceMaze import generateIceMaze
37+
from animation_modifier import modifyAnimationCode
3738

3839
# Infrastructure for recomputing DK64 global pointer tables
3940
# from BuildNames import maps
@@ -54,6 +55,7 @@
5455
updateSpawnerFiles()
5556
updatePathFiles()
5657
BuildInstanceScripts()
58+
modifyAnimationCode()
5759

5860
portal_images = []
5961
for x in range(2):
@@ -428,6 +430,7 @@
428430
File(name="Banana Medal", pointer_table_index=TableNames.ModelTwoGeometry, file_index=0x90, source_file="updated_medal.bin", do_not_delete_source=True),
429431
File(name="Mushroom Red (Mush Puzzle)", pointer_table_index=TableNames.ModelTwoGeometry, file_index=0x1BE, source_file="updated_mush_0x1BE.bin", do_not_delete_source=True),
430432
File(name="Ice Maze", pointer_table_index=TableNames.ModelTwoGeometry, file_index=522, source_file="assets/Gong/ice_maze.bin", do_not_delete_source=True),
433+
File(name="Animation Code", pointer_table_index=TableNames.Unknown13, file_index=0, source_file="animation_code.bin", do_not_delete_source=True),
431434
]
432435

433436
cutscene_scripts = buildScripts()

base-hack/src/fixes/guardCatch.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ typedef struct guard_paad {
2727
/* 0x00E */ short z_something;
2828
/* 0x010 */ char unk_10[0x1A-0x10];
2929
/* 0x01A */ short unk_1A;
30-
/* 0x01C */ char unk_1C[0x47-0x1C];
30+
/* 0x01C */ char unk_1C[0x44-0x1C];
31+
/* 0x044 */ short kop_idle_guarantee;
32+
/* 0x046 */ char unk_46;
3133
/* 0x047 */ char played_uhoh;
3234
} guard_paad;
3335

@@ -224,4 +226,19 @@ void newGuardCode(void) {
224226
}
225227
}
226228
}
229+
}
230+
231+
void setKopIdleGuarantee(actorData *actor, int spd) {
232+
guard_paad *paad = actor->paad;
233+
paad->kop_idle_guarantee = 30 * 3; // 3s
234+
setActorSpeed(actor, spd);
235+
}
236+
237+
int giveKopIdleGuarantee(void) {
238+
guard_paad *paad = CurrentActorPointer_0->paad;
239+
if (paad->kop_idle_guarantee > 0) {
240+
paad->kop_idle_guarantee--;
241+
return 0; // Always return false
242+
}
243+
return getRNGLower31();
227244
}

randomizer/CompileHints.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from randomizer.Enums.Settings import (
2121
ClimbingStatus,
2222
ProgressiveHintItem,
23-
HelmSetting,
23+
ActivateAllBananaports,
2424
LogicType,
2525
MicrohintsEnabled,
2626
MoveRando,
@@ -725,9 +725,13 @@ def compileHints(spoiler: Spoiler) -> bool:
725725
}
726726
# Your training in Gorilla Gone, Monkeyport, Climbing and Vines are always pointless hints if Key 8 is in Helm, so let's not
727727
if spoiler.settings.key_8_helm and Locations.HelmKey in spoiler.woth_paths.keys():
728-
useless_moves = [Items.Vines]
728+
useless_moves = []
729+
if spoiler.settings.activate_all_bananaports != ActivateAllBananaports.isles_inc_helm_lobby:
730+
useless_moves.append(Items.Vines)
729731
if not spoiler.settings.switchsanity:
730-
useless_moves.extend([Items.Monkeyport, Items.GorillaGone])
732+
useless_moves.append(Items.Monkeyport)
733+
if not spoiler.settings.switchsanity and spoiler.settings.activate_all_bananaports != ActivateAllBananaports.isles_inc_helm_lobby:
734+
useless_moves.append(Items.GorillaGone)
731735
useless_locations[Items.HideoutHelmKey] = [
732736
loc for loc in spoiler.woth_paths[Locations.HelmKey] if (loc in TrainingBarrelLocations or loc in PreGivenLocations) and spoiler.LocationList[loc].item in useless_moves
733737
]

randomizer/Enums/Settings.jsonc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"ActivateAllBananaports": {
1010
"off": 0,
1111
"all": 1,
12-
"isles": 2
12+
"isles": 2,
13+
"isles_inc_helm_lobby": 3
1314
},
1415

1516
/*
@@ -601,7 +602,8 @@
601602
"better_fairy_camera": 26,
602603
"remove_enemy_cabin_timer": 27,
603604
"remove_galleon_ship_timers": 28,
604-
"japes_bridge_permanently_extended": 29
605+
"japes_bridge_permanently_extended": 29,
606+
"move_spring_cabin_rocketbarrel": 30
605607
},
606608

607609
/*

randomizer/Lists/EnemyTypes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ def canBypass(self) -> bool:
519519
minigame_enabled=False,
520520
interaction=InteractionMethods(kill_melee=False, can_bypass=False), # Can be meleed with distraction mechanic, but we'll ignore that for now
521521
default_size=50,
522+
max_speed=100,
522523
),
523524
Enemies.Bug: EnemyData(
524525
name="Bug",

randomizer/Lists/Multiselectors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def __init__(self, name: str, shift: int, tooltip: str = "") -> None:
130130
2,
131131
"The spiral bridge around Japes Mountain will be permanently extended as soon as you shoot the peanut switch.",
132132
),
133+
MultiselectorItem("Move Spring Cabin Rocketbarrel", -1, "Moves the rocketbarrel in the Spring 5-Door Cabin to prevent being able to enter it earlier than intended."),
133134
]
134135
RemovedBarrierItems = [
135136
MultiselectorItem(

randomizer/Logic.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,21 @@ def Reset(self):
271271
Maps.CreepyCastle,
272272
Maps.CastleCrypt,
273273
Maps.Isles,
274+
# Maps.HideoutHelmLobby, # Not in BananaportVanilla
274275
]
275276
elif self.settings.activate_all_bananaports == ActivateAllBananaports.isles:
276277
activated_warp_maps = [Maps.Isles]
278+
elif self.settings.activate_all_bananaports == ActivateAllBananaports.isles_inc_helm_lobby:
279+
activated_warp_maps = [
280+
Maps.Isles,
281+
# Maps.HideoutHelmLobby, # Not in BananaportVanilla
282+
]
277283
if any(activated_warp_maps):
278284
for warp_data in BananaportVanilla.values():
279285
if warp_data.map_id in activated_warp_maps:
280286
self.Events.append(warp_data.event)
287+
if self.settings.activate_all_bananaports in (ActivateAllBananaports.all, ActivateAllBananaports.isles_inc_helm_lobby):
288+
self.Events.extend([Events.HelmLobbyW1aTagged, Events.HelmLobbyW1bTagged])
281289

282290
# Colored banana and coin arrays
283291
# Colored bananas as 9 arrays of 5 (8 levels for 5 kongs, Helm is level index 7, so skip this)
@@ -515,6 +523,15 @@ def galleonGatesStayOpen(self) -> bool:
515523
MiscChangesSelected.remove_galleon_ship_timers,
516524
)
517525

526+
@lru_cache(maxsize=None)
527+
def cabinBarrelMoved(self) -> bool:
528+
"""Determine whether the upper cabin rocketbarrel has been moved."""
529+
return IsItemSelected(
530+
self.settings.quality_of_life,
531+
self.settings.misc_changes_selected,
532+
MiscChangesSelected.move_spring_cabin_rocketbarrel,
533+
)
534+
518535
def canOpenLlamaTemple(self):
519536
"""Determine whether the switches on the Llama Temple can be shot."""
520537
if not (self.checkBarrier(RemovedBarriersSelected.aztec_llama_switches) or Events.LlamaFreed in self.Events):

randomizer/LogicFiles/CrystalCaves.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244

245245
Regions.DiddyUpperCabin: Region("Diddy Upper Cabin", HintRegion.Cabins, Levels.CrystalCaves, False, None, [
246246
LocationLogic(Locations.CavesDiddy5DoorCabinUpper, lambda l: (l.guitar or l.oranges) and (l.spring or l.CanMoontail()) and l.jetpack and l.isdiddy),
247-
LocationLogic(Locations.CavesBananaFairyCabin, lambda l: l.camera and (l.guitar or l.oranges) and (l.spring or l.CanMoontail()) and l.jetpack and l.isdiddy),
247+
LocationLogic(Locations.CavesBananaFairyCabin, lambda l: l.camera and (l.guitar or l.oranges) and (l.spring or (l.CanMoontail() and not l.cabinBarrelMoved())) and l.jetpack and l.isdiddy),
248248
# LocationLogic(Locations.Caves5DCDiddyUpperEnemy_Enemy0, lambda l: True),
249249
# LocationLogic(Locations.Caves5DCDiddyUpperEnemy_Enemy1, lambda l: True),
250250
], [], [

0 commit comments

Comments
 (0)