Skip to content

Commit

Permalink
Merge branch 'canary' into logic_rework
Browse files Browse the repository at this point in the history
  • Loading branch information
lilDavid committed Aug 24, 2024
2 parents b1fb542 + 70e4e6f commit 3089b38
Show file tree
Hide file tree
Showing 11 changed files with 533 additions and 164 deletions.
18 changes: 11 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import typing
from pathlib import Path
from collections import Counter
from typing import Any, Dict, List, Optional
from typing import Any, ClassVar, Dict, List, Optional

from BaseClasses import ItemClassification, Tutorial
import settings
from worlds.AutoWorld import WebWorld, World

from .client import MZMClient
from .data import data_path
from .items import item_data_table, major_item_data_table, MZMItem
from .locations import full_location_table
from .items import item_data_table, major_item_data_table, mzm_item_name_groups, MZMItem
from .locations import full_location_table, mzm_location_name_groups
from .options import MZMOptions, MorphBallPlacement, mzm_option_groups
from .regions import create_regions_and_connections
from .rom import MZMProcedurePatch, write_tokens
Expand Down Expand Up @@ -58,7 +58,7 @@ class MZMWorld(World):
options_dataclass = MZMOptions
options: MZMOptions
topology_present = True
settings: MZMSettings
settings: ClassVar[MZMSettings]

web = MZMWeb()

Expand All @@ -67,6 +67,9 @@ class MZMWorld(World):
item_name_to_id = {name: data.code for name, data in item_data_table.items()}
location_name_to_id = {name: data.code for name, data in full_location_table.items()}

item_name_groups = mzm_item_name_groups
location_name_groups = mzm_location_name_groups

junk_fill: List[str]

def generate_early(self):
Expand Down Expand Up @@ -115,15 +118,16 @@ def generate_output(self, output_directory: str):
patch.write_file("basepatch.bsdiff", data_path("basepatch.bsdiff"))
write_tokens(self, patch)
if not self.options.unknown_items_always_usable:
patch.procedure.append(("add_unknown_item_graphics", []))
patch.add_vanilla_unknown_item_sprites()
if self.options.layout_patches:
patch.procedure.append(("apply_layout_patches", []))
patch.add_layout_patches()

output_filename = self.multiworld.get_out_file_name_base(self.player)
patch.write(output_path / f"{output_filename}{patch.patch_file_ending}")

def fill_slot_data(self) -> Dict[str, Any]:
return {
"goal": self.options.goal.value,
"unknown_items": self.options.unknown_items_always_usable.value,
"layout_patches": self.options.layout_patches.value,
"logic_difficulty": self.options.logic_difficulty.value,
Expand All @@ -143,7 +147,7 @@ def create_item(self, name: str, force_classification: Optional[ItemClassificati
self.item_name_to_id[name],
self.player)

def create_tanks(self, item_name: str, count: int, progression_count: int = None):
def create_tanks(self, item_name: str, count: int, progression_count: Optional[int] = None):
if progression_count is None:
progression_count = count
for _ in range(progression_count):
Expand Down
Binary file modified data/basepatch.bsdiff
Binary file not shown.
2 changes: 1 addition & 1 deletion data/extracted_symbols.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions items.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class ItemID(IntEnum):
APItemFiller = 19
APItemProgression = 20
APItemUseful = 21
SpazerBeam = 22
GrappleBeam = 23
SpringBall = 24
XRayScope = 25
ReserveTank = 26
WallJump = 27
PowerBeam = 28
SpiderBall = 29


tank_data_table = {
Expand Down Expand Up @@ -101,3 +109,16 @@ class ItemID(IntEnum):
**major_item_data_table,
**extra_item_data_table,
}

mzm_item_name_groups = {
"Beams": {name for name, data in major_item_data_table.items() if data.type == ItemType.beam and data.id != ItemID.Bomb},
"Upgrades": {
"Bomb",
*(name for name, data in major_item_data_table.items() if data.type == ItemType.major)
},
"Major Items": set(major_item_data_table.keys()),
"Missiles": {
"Missile Tank",
"Super Missile Tank",
},
}
87 changes: 87 additions & 0 deletions locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,90 @@ def __init__(self, reg, id):
**crateria_location_table,
**chozodia_location_table
}

mzm_location_name_groups = {
"Brinstar": {name for name, id in brinstar_location_table.items() if id is not None},
"Kraid": {name for name, id in kraid_location_table.items() if id is not None},
"Upper Norfair": {
"Norfair Power Grip Missile",
"Norfair Under Crateria Elevator",
"Norfair Bomb Trap",
"Norfair Heated Room Under Brinstar Elevator",
"Norfair Ice Beam",
"Norfair Heated Room above Ice Beam",
"Norfair Hi-Jump",
"Norfair Big Room",
"Norfair Behind Top Chozo Statue",
"Norfair Right Shaft Lower",
},
"Lower Norfair": {
"Norfair Lava Power Bomb",
"Norfair Lava Missile",
"Norfair Screw Attack",
"Norfair Screw Attack Missile",
"Norfair Wave Beam",
"Norfair Bottom Heated Room First",
"Norfair Bottom Heated Room Second",
"Norfair Space Boost Missile",
"Norfair Space Boost Super Missile",
"Norfair Larva Ceiling E-tank",
"Norfair Right Shaft Bottom",
},
"Ridley": {name for name, id in ridley_location_table.items() if id is not None},
"Tourian": {name for name, id in tourian_location_table.items() if id is not None},
"Crateria": {name for name, id in crateria_location_table.items() if id is not None},
"Chozo Ruins": {
"Chozodia Upper Crateria Door",
"Chozodia Ruins Near Upper Crateria Door",
"Chozodia Chozo Ghost Area Morph Tunnel Above Water",
"Chozodia Chozo Ghost Area Underwater",
"Chozodia Under Chozo Ghost Area Water",
"Chozodia Lava Super",
},
"Mother Ship": {
"Chozodia Bomb Maze",
"Chozodia Zoomer Maze",
"Chozodia Glass Tube E-Tank",
"Chozodia Original Power Bomb",
"Chozodia Next to Original Power Bomb",
"Chozodia Glass Tube Power Bomb",
"Chozodia Chozo Ghost Area Long Shinespark",
"Chozodia Shortcut Super",
"Chozodia Workbot Super",
"Chozodia Mothership Ceiling Near ZSS Start",
"Chozodia Under Mecha Ridley Hallway",
"Chozodia Southeast Corner In Hull",
},
"Chozo Statues": {
"Brinstar Long Beam",
"Brinstar Varia Suit",
"Brinstar Bomb",
"Kraid Space Jump/Unknown Item 2",
"Kraid Speed Booster",
"Norfair Screw Attack",
"Norfair Wave Beam",
"Norfair Ice Beam",
"Norfair Hi-Jump",
"Ridley Gravity Suit/Unknown Item 3",
"Crateria Plasma Beam/Unknown Item 1",
},
"Freestanding Items": {
"Brinstar Morph Ball",
"Brinstar Worm drop",
"Crateria Power Grip",
},
"Energy Tanks": {
"Brinstar Ceiling E-Tank",
"Brinstar Post-Hive E-Tank",
"Brinstar Acid near Varia",
"Kraid Worm E-Tank",
"Kraid Speed Jump",
"Norfair Larva Ceiling E-tank",
"Ridley E-Tank behind Gravity",
"Ridley Fake Floor E-Tank",
"Ridley Owl E-Tank",
"Chozodia Glass Tube E-Tank",
"Chozodia Chozo Ghost Area Long Shinespark",
"Chozodia Under Mecha Ridley Hallway",
},
}
12 changes: 12 additions & 0 deletions logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ def any(*args: Requirement):
EnergyTanks(4)
)

# Goal
ReachedGoal = any(
all(
Requirement.setting_is("goal", 0)
),
all(
Requirement.setting_is("goal", 1),
MotherBrainBoss,
ChozoGhostBoss
),
)


# Regional connection requirements

Expand Down
58 changes: 42 additions & 16 deletions nonnative_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,36 @@
"Hi-Jump Boots": ItemID.HiJump,
"Speed Booster": ItemID.SpeedBooster,
"Wave Beam": ItemID.WaveBeam,
# "Spazer Beam":
# "Spring Ball":
"Spazer Beam": ItemID.SpazerBeam,
"Spring Ball": ItemID.SpringBall,
"Varia Suit": ItemID.VariaSuit,
"Plasma Beam": ItemID.PlasmaBeam,
# "Grappling Beam":
"Grappling Beam": ItemID.GrappleBeam,
"Morph Ball": ItemID.MorphBall,
# "Reserve Tank":
"Reserve Tank": ItemID.ReserveTank,
"Gravity Suit": ItemID.GravitySuit,
# "X-Ray Scope":
"X-Ray Scope": ItemID.XRayScope,
"Space Jump": ItemID.SpaceJump,
"Screw Attack": ItemID.ScrewAttack,
},
"SMZ3": {
"Missile": ItemID.MissileTank,
"Super": ItemID.SuperMissileTank,
"PowerBomb": ItemID.PowerBombTank,
# "Grapple":
# "XRay":
"Grapple": ItemID.GrappleBeam,
"XRay": ItemID.XRayScope,
"ETank": ItemID.EnergyTank,
# "ReserveTank":
"ReserveTank": ItemID.ReserveTank,
"Charge": ItemID.ChargeBeam,
"Ice": ItemID.IceBeam,
"Wave": ItemID.WaveBeam,
# "Spazer":
"Spazer": ItemID.SpazerBeam,
"Plasma": ItemID.PlasmaBeam,
"Varia": ItemID.VariaSuit,
"Gravity": ItemID.GravitySuit,
"Morph": ItemID.MorphBall,
"Bombs": ItemID.Bomb,
# "SpringBall":
"SpringBall": ItemID.SpringBall,
"ScrewAttack": ItemID.ScrewAttack,
"HiJump": ItemID.HiJump,
"SpaceJump": ItemID.SpaceJump,
Expand All @@ -69,7 +69,7 @@
# "CardLowerNorfairBoss":
},
"Metroid Prime": {
# "Power Beam":
"Power Beam": ItemID.PowerBeam,
"Ice Beam": ItemID.IceBeam,
"Wave Beam": ItemID.WaveBeam,
"Plasma Beam": ItemID.PlasmaBeam,
Expand All @@ -81,22 +81,48 @@
# "Thermal Visor":
"Charge Beam": ItemID.ChargeBeam,
# "Super Missile":
# "Grapple Beam":
"Grapple Beam": ItemID.GrappleBeam,
# "X-Ray Visor":
# "Ice Spreader":
"Space Jump Boots": ItemID.HiJump,
"Space Jump Boots": ItemID.SpaceJump,
"Morph Ball": ItemID.MorphBall,
# "Combat Visor":
# "Boost Ball":
# "Spider Ball":
# "Power Suit":
"Spider Ball": ItemID.SpiderBall,
"Gravity Suit": ItemID.GravitySuit,
"Varia Suit": ItemID.VariaSuit,
# "Phazon Suit":
"Energy Tank": ItemID.EnergyTank,
# "Wavebuster":
# "Missile Launcher":
# "Power Bomb (Main)":
"Progressive Power Beam": ItemID.PowerBeam,
"Progressive Ice Beam": ItemID.IceBeam,
"Progressive Wave Beam": ItemID.WaveBeam,
"Progressive Plasma Beam": ItemID.PlasmaBeam,
},
"Super Metroid Map Rando": {
"ETank": ItemID.EnergyTank,
"Missile": ItemID.MissileTank,
"Super": ItemID.SuperMissileTank,
"PowerBomb": ItemID.PowerBombTank,
"Bombs": ItemID.Bomb,
"Charge": ItemID.ChargeBeam,
"Ice": ItemID.IceBeam,
"HiJump": ItemID.HiJump,
"SpeedBooster": ItemID.SpeedBooster,
"Wave": ItemID.WaveBeam,
"Spazer": ItemID.SpazerBeam,
"SpringBall": ItemID.SpringBall,
"Varia": ItemID.VariaSuit,
"Gravity": ItemID.GravitySuit,
"XRayScope": ItemID.XRayScope,
"Plasma": ItemID.PlasmaBeam,
"Grapple": ItemID.GrappleBeam,
"SpaceJump": ItemID.SpaceJump,
"ScrewAttack": ItemID.ScrewAttack,
"Morph": ItemID.MorphBall,
"ReserveTank": ItemID.ReserveTank,
"WallJump": ItemID.WallJump,
},
}

Expand Down
Loading

0 comments on commit 3089b38

Please sign in to comment.