Skip to content

Commit

Permalink
Add some more details to some enemy rando error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Sep 22, 2024
1 parent 5d114e4 commit d40f866
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
// "-vv", // Increases verbosity
],
"editor.tabSize": 2,
"python.analysis.typeCheckingMode": "off",
}
25 changes: 20 additions & 5 deletions randomizers/enemies.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,25 +527,37 @@ def save_changed_enemies_and_randomize_their_params(self):
spawn_switch_param_name = original_enemy_type["Enable spawn switch param name"]

if spawn_switch_param_name is None:
raise Exception("An enemy location specified that it must check a switch before spawning, but the original enemy there is not documented to be able to check a switch before spawning.")
raise Exception(
f"An enemy location specified that it must check a switch before spawning, but the original enemy there is not documented to be able to check a switch before spawning.\n\n"
f"Enemy location: {path}"
)

spawn_switch_to_check = getattr(enemy, spawn_switch_param_name)
if spawn_switch_to_check in [0xFE, 0xFF] or spawn_switch_to_check >= 0xF0:
# 0xFE is invalid for Stalfos.
raise Exception("Switch index to check before spawning the enemy is not valid for all enemy types: %02X" % spawn_switch_to_check)
raise Exception(
f"Switch index to check before spawning the enemy is not valid for all enemy types: {spawn_switch_to_check:02X}\n\n"
f"Enemy location: {path}"
)

if "SetsDeathSwitch" in conditions:
# We need to copy the switch ID the original enemy set on death to the randomized enemy.
death_switch_param_name = original_enemy_type["Death switch param name"]

if death_switch_param_name is None:
raise Exception("An enemy location specified that it must set a switch on death, but the original enemy there is not documented to be able to set a switch on death.")
raise Exception(
f"An enemy location specified that it must set a switch on death, but the original enemy there is not documented to be able to set a switch on death.\n\n"
f"Enemy location: {path}"
)

death_switch_to_set = getattr(enemy, death_switch_param_name)
if death_switch_to_set in [0x00, 0x80, 0xFF] or death_switch_to_set >= 0xF0:
# 0x00 is invalid for ???
# 0x80 is invalid for ???
raise Exception("Switch index to set on enemy death is not valid for all enemy types: %02X" % death_switch_to_set)
raise Exception(
f"Switch index to set on enemy death is not valid for all enemy types: {death_switch_to_set:02X}\n\n"
f"Enemy location: {path}"
)

# We attempt to copy the path the original enemy followed to the randomized enemy.
path_index_param_name = original_enemy_type["Path param name"]
Expand Down Expand Up @@ -599,7 +611,10 @@ def save_changed_enemies_and_randomize_their_params(self):
death_switch_param_name = new_enemy_data["Death switch param name"]
if death_switch_param_name is None:
if DEBUG_ENEMY_NAME_TO_PLACE_EVERYWHERE is None:
raise Exception("Tried to place an enemy type that cannot set a switch on death in a location that requires a switch be set on death: %s" % enemy.name)
raise Exception(
f"Tried to place an enemy type that cannot set a switch on death in a location that requires a switch be set on death: {enemy.name}\n\n"
f"Enemy location: {path}"
)
else:
setattr(enemy, death_switch_param_name, death_switch_to_set)

Expand Down

0 comments on commit d40f866

Please sign in to comment.