Skip to content

Commit

Permalink
Space Engineers: Fixed logic
Browse files Browse the repository at this point in the history
  • Loading branch information
FlySniper committed Dec 2, 2023
1 parent 39c7f26 commit 66d91ab
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 98 deletions.
110 changes: 55 additions & 55 deletions worlds/space_engineers/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,89 +18,89 @@ class ItemData(typing.NamedTuple):

item_table: Dict[str, ItemData] = {
# Blocks
"Light Armor Block": ItemData(38800, "Block", USEFUL, "Light Armor Block"),
"Heavy Armor Block": ItemData(38801, "Block", USEFUL, "Heavy Armor Block"),
"Round Armor Slope": ItemData(38802, "Block", FILLER, "Round Armor Slope"),
"Heavy Armor Round Slope": ItemData(38803, "Block", FILLER, "Heavy Armor Round Slope"),
"Light Armor Ramps": ItemData(38804, "Block", FILLER, "Light Armor Ramps"),
# "Light Armor Ramp Corners": ItemData(38805, "Block", FILLER),
"Heavy Armor Ramps": ItemData(38806, "Block", FILLER, "Heavy Armor Ramps"),
# "Heavy Armor Ramp Corners": ItemData(38807, "Block", FILLER),
# "Light Armor Sloped Corners": ItemData(38808, "Block", FILLER),
# "Heavy Armor Sloped Corners": ItemData(38809, "Block", FILLER),
"Light Armor Block": ItemData(38800, "Block", PROGRESSION, "Light Armor Block"),
"Heavy Armor Block": ItemData(38801, "Block", PROGRESSION, "Heavy Armor Block"),
"Round Armor Slope": ItemData(38802, "Block", PROGRESSION, "Round Armor Slope"),
"Heavy Armor Round Slope": ItemData(38803, "Block", PROGRESSION, "Heavy Armor Round Slope"),
"Light Armor Ramps": ItemData(38804, "Block", PROGRESSION, "Light Armor Ramps"),
# "Light Armor Ramp Corners": ItemData(38805, "Block", PROGRESSION),
"Heavy Armor Ramps": ItemData(38806, "Block", PROGRESSION, "Heavy Armor Ramps"),
# "Heavy Armor Ramp Corners": ItemData(38807, "Block", PROGRESSION),
# "Light Armor Sloped Corners": ItemData(38808, "Block", PROGRESSION),
# "Heavy Armor Sloped Corners": ItemData(38809, "Block", PROGRESSION),
# "DisplayName_BlockGroup_LightArmorTransitionBlocks": ItemData(38810, "Block"),
# "DisplayName_BlockGroup_HeavyArmorTransitionBlocks": ItemData(38811, "Block"),
# "DisplayName_Block_LightArmorPanel": ItemData(38812, "Block"),
# "DisplayName_Block_heavyArmorPanel": ItemData(38813, "Block"),
"Projector": ItemData(38814, "Block", FILLER, "Projector"),
"Target Dummy": ItemData(38815, "Block", FILLER, "Target Dummy"),
"Sound Block": ItemData(38816, "Block", FILLER, "Sound Block"),
"Button Panel": ItemData(38817, "Block", FILLER, "Button Panel"),
# "Automation Blocks": ItemData(38818, "Block", FILLER),
"AI Blocks": ItemData(38819, "Block", FILLER, "AI Flight Move"),
"Communication Blocks": ItemData(38820, "Block", USEFUL, "Communication Blocks"),
"Remote Control": ItemData(38821, "Block", FILLER, "Remote Control"),
# "Control Station": ItemData(38822, "Block", FILLER),
"Projector": ItemData(38814, "Block", PROGRESSION, "Projector"),
"Target Dummy": ItemData(38815, "Block", PROGRESSION, "Target Dummy"),
"Sound Block": ItemData(38816, "Block", PROGRESSION, "Sound Block"),
"Button Panel": ItemData(38817, "Block", PROGRESSION, "Button Panel"),
# "Automation Blocks": ItemData(38818, "Block", PROGRESSION),
"AI Blocks": ItemData(38819, "Block", PROGRESSION, "AI Flight Move"),
"Communication Blocks": ItemData(38820, "Block", PROGRESSION, "Communication Blocks"),
"Remote Control": ItemData(38821, "Block", PROGRESSION, "Remote Control"),
# "Control Station": ItemData(38822, "Block", PROGRESSION),
"Gyroscope": ItemData(38823, "Block", PROGRESSION, "Gyroscope"),
"Control Seat": ItemData(38824, "Block", PROGRESSION, "Control Seat"),
"Door": ItemData(38825, "Block", FILLER, "Door"),
"Airtight Hangar Door": ItemData(38826, "Block", FILLER, "Airtight Hangar Door"),
"Blast Doors": ItemData(38827, "Block", FILLER, "Blast Doors"),
"Door": ItemData(38825, "Block", PROGRESSION, "Door"),
"Airtight Hangar Door": ItemData(38826, "Block", PROGRESSION, "Airtight Hangar Door"),
"Blast Doors": ItemData(38827, "Block", PROGRESSION, "Blast Doors"),
# "Store": ItemData(38828, "Block"),
"Battery": ItemData(38829, "Block", USEFUL, "Battery"),
"Battery": ItemData(38829, "Block", PROGRESSION, "Battery"),
"Fueled Energy Sources": ItemData(38830, "Block", PROGRESSION, "Fueled Energy Sources"),
"Renewable Energy Sources": ItemData(38831, "Block", PROGRESSION, "Renewable Energy Sources"),
"Engineer Plushie": ItemData(38832, "Block", FILLER, "Engineer Plushie"),
"Saberoid Plushie": ItemData(38833, "Block", FILLER, "Saberoid Plushie"),
"Anniversary Statue": ItemData(38834, "Block", FILLER, "Anniversary Statue"),
"Gravity Blocks": ItemData(38835, "Block", USEFUL, "Gravity Blocks"),
"Passage": ItemData(38836, "Block", FILLER, "Passage"),
"Steel Catwalk": ItemData(38837, "Block", FILLER, "Steel Catwalk"),
"Stairs": ItemData(38838, "Block", FILLER, "Stairs"),
# "DisplayName_Block_AirDucts": ItemData(38839, "Block", FILLER),
"Engineer Plushie": ItemData(38832, "Block", PROGRESSION, "Engineer Plushie"),
"Saberoid Plushie": ItemData(38833, "Block", PROGRESSION, "Saberoid Plushie"),
"Anniversary Statue": ItemData(38834, "Block", PROGRESSION, "Anniversary Statue"),
"Gravity Blocks": ItemData(38835, "Block", PROGRESSION, "Gravity Blocks"),
"Passage": ItemData(38836, "Block", PROGRESSION, "Passage"),
"Steel Catwalk": ItemData(38837, "Block", PROGRESSION, "Steel Catwalk"),
"Stairs": ItemData(38838, "Block", PROGRESSION, "Stairs"),
# "DisplayName_Block_AirDucts": ItemData(38839, "Block", PROGRESSION),
# "Corner LCD Screens": ItemData(38840, "Block"),
"LCD Screens": ItemData(38841, "Block", FILLER, "LCD Screens"),
"Lighting": ItemData(38842, "Block", FILLER, "Lighting"),
"LCD Screens": ItemData(38841, "Block", PROGRESSION, "LCD Screens"),
"Lighting": ItemData(38842, "Block", PROGRESSION, "Lighting"),
"Gas Tanks": ItemData(38843, "Block", PROGRESSION, "Gas Tanks"),
"Air Vent": ItemData(38844, "Block", USEFUL, "Air Vent"),
"Air Vent": ItemData(38844, "Block", PROGRESSION, "Air Vent"),
"Cargo Containers": ItemData(38845, "Block", PROGRESSION, "Cargo Containers"),
"Small Conveyor Tube": ItemData(38846, "Block", PROGRESSION, "Small Conveyor Tube"),
"Large Conveyor Tube": ItemData(38847, "Block", PROGRESSION, "Conveyor Junction"),
"Connector": ItemData(38848, "Block", FILLER, "Inputs/Outputs"),
"Piston": ItemData(38849, "Block", FILLER, "Piston"),
"Rotor": ItemData(38850, "Block", FILLER, "Rotor"),
"Hinge": ItemData(38851, "Block", FILLER, "DisplayName_Block_Hinge"),
"Connector": ItemData(38848, "Block", PROGRESSION, "Inputs/Outputs"),
"Piston": ItemData(38849, "Block", PROGRESSION, "Piston"),
"Rotor": ItemData(38850, "Block", PROGRESSION, "Rotor"),
"Hinge": ItemData(38851, "Block", PROGRESSION, "DisplayName_Block_Hinge"),
"Medical Blocks": ItemData(38852, "Block", PROGRESSION, "Medical Blocks"),
"Refinery": ItemData(38853, "Block", PROGRESSION, "Refinery"),
"O2/H2 Generator": ItemData(38854, "Block", PROGRESSION, "O2/H2 Generator"),
"Assembler": ItemData(38855, "Block", PROGRESSION, "Assembler"),
"Oxygen Farm": ItemData(38856, "Block", USEFUL, "Oxygen Farm"),
"Upgrade Modules": ItemData(38857, "Block", USEFUL, "Upgrade Modules"),
# "letters A to H": ItemData(38858, "Block", FILLER),
"Oxygen Farm": ItemData(38856, "Block", PROGRESSION, "Oxygen Farm"),
"Upgrade Modules": ItemData(38857, "Block", PROGRESSION, "Upgrade Modules"),
# "letters A to H": ItemData(38858, "Block", PROGRESSION),
# "DisplayName_BlockGroup_Numbers": ItemData(38859, "Block"),
# "Symbols": ItemData(38860, "Block"),
"Ion Thrusters": ItemData(38861, "Block", PROGRESSION, "Large Ion Thruster"),
"Hydrogen Thrusters": ItemData(38862, "Block", PROGRESSION, "Large Hydrogen Thruster"),
"Atmospheric Thrusters": ItemData(38863, "Block", PROGRESSION, "Large Atmospheric Thruster"),
"Ship Tools": ItemData(38864, "Block", USEFUL, "Ship Tools"),
"Ore Detector": ItemData(38865, "Block", USEFUL, "Ore Detector"),
"Landing Gear": ItemData(38866, "Block", USEFUL, "Landing Gear"),
"Ship Tools": ItemData(38864, "Block", PROGRESSION, "Ship Tools"),
"Ore Detector": ItemData(38865, "Block", PROGRESSION, "Ore Detector"),
"Landing Gear": ItemData(38866, "Block", PROGRESSION, "Landing Gear"),
"Jump Drive": ItemData(38867, "Block", PROGRESSION, "Jump Drive"),
"Parachute Hatch": ItemData(38868, "Block", FILLER, "Parachute Hatch"),
"Warhead": ItemData(38869, "Block", FILLER, "Warhead"),
"Decoy": ItemData(38870, "Block", FILLER, "Decoy"),
"Turreted Weapons": ItemData(38871, "Block", PROGRESSION, "Turreted Weapons"), # Might be progression if trying to fight enemies
"Stationary Weapons": ItemData(38872, "Block", FILLER, "Stationary Weapons"), # Might be progression if trying to fight enemies
"Parachute Hatch": ItemData(38868, "Block", PROGRESSION, "Parachute Hatch"),
"Warhead": ItemData(38869, "Block", PROGRESSION, "Warhead"),
"Decoy": ItemData(38870, "Block", PROGRESSION, "Decoy"),
"Turreted Weapons": ItemData(38871, "Block", PROGRESSION, "Turreted Weapons"),
"Stationary Weapons": ItemData(38872, "Block", PROGRESSION, "Stationary Weapons"),
# "Wheel Suspension 3x3 Right": ItemData(38873, "Block"),
# "Wheel Suspension 3x3 Left": ItemData(38874, "Block"),
"Wheels": ItemData(38875, "Block", FILLER, "Static Wheels"),
"Windows": ItemData(38876, "Block", FILLER, "Shutters"),
"Wheels": ItemData(38875, "Block", PROGRESSION, "Static Wheels"),
"Windows": ItemData(38876, "Block", PROGRESSION, "Shutters"),
# "Medium Corner Windows": ItemData(38877, "Block"),
# "Small Corner Windows": ItemData(38878, "Block"),
# "Medium Windows": ItemData(38879, "Block", FILLER),
# "Small Windows": ItemData(38880, "Block", FILLER),
# "Large Windows": ItemData(38881, "Block", FILLER),
# "Round Windows": ItemData(38882, "Block", FILLER),
# "Medium Windows": ItemData(38879, "Block", PROGRESSION),
# "Small Windows": ItemData(38880, "Block", PROGRESSION),
# "Large Windows": ItemData(38881, "Block", PROGRESSION),
# "Round Windows": ItemData(38882, "Block", PROGRESSION),

# Filler Items

Expand Down
55 changes: 14 additions & 41 deletions worlds/space_engineers/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,26 @@ def _space_engineers_has_region(self, player: int, region: str) -> bool:


def set_rules(world: MultiWorld, player: int):
# set_rule(world.get_location("Built Gravity Blocks", player),
# lambda state: state._space_engineers_has_item(player, "Gravity Blocks") and
# state._space_engineers_has_region("Space: World Size 2"))

for item_name in item_table.keys():
item_data = item_table[item_name]
if item_data.type == "Block":
location_data = location_table[f"Built {item_name}"]
if any(component in location_data.component_list for component in SPACE_COMPONENTS):
set_rule(world.get_location(f"Built {item_name}", player),
lambda state: state._space_engineers_has_region(player, "Space: World Size 2") and
state._space_engineers_has_item(player, "Progressive Space Size") and
state._space_engineers_has_item(player, item_name))
lambda state, item_name=item_name, player=player:
state._space_engineers_has_region(player, "Space: World Size 2") and
state._space_engineers_has_item(player, "Progressive Space Size") and
state._space_engineers_has_item(player, item_name))
elif any(component in location_data.component_list for component in MANUFACTURING_UPGRADE_COMPONENTS):
set_rule(world.get_location(f"Built {item_name}", player),
lambda state: state._space_engineers_has_region(player,
"Starting Planet: No Flight Full Refinery and Assembler") and
state._space_engineers_has_item(player, item_name))
lambda state, item_name=item_name, player=player:
state._space_engineers_has_region(player,
"Starting Planet: No Flight Full Refinery and Assembler") and state._space_engineers_has_item(
player, item_name))
elif any(component in location_data.component_list for component in STARTING_COMPONENTS):
set_rule(world.get_location(f"Built {item_name}", player),
lambda state: state._space_engineers_has_item(player, item_name))
lambda state, item_name=item_name, player=player: state._space_engineers_has_item(player,
item_name))

set_rule(world.get_location("Stone", player),
lambda state: True)
Expand Down Expand Up @@ -295,30 +294,16 @@ def set_rules(world: MultiWorld, player: int):
lambda state: state._space_engineers_has_region(player, "Space: World Size 2") and
state._space_engineers_has_item(player, "Jump Drive") and
state._space_engineers_has_item(player, "Progressive Space Size", 1))
if world.goal[player].value == 1: # Visit every Planet
set_rule(world.get_location('Space Engineers: Victory', player),
lambda state: state._space_engineers_has_region(player, "Space: World Size 4") and
state._space_engineers_has_item(player, "Progressive Space Size", 3))
# Start

# set_rule(world.get_entrance('Starting Planet: No Flight Full Refinery and Assembler', player), lambda state:
# state._space_engineers_has_item(player, "Refinery") and
# state._space_engineers_has_item(player, "Assembler") and
# state._space_engineers_has_item(player, "Renewable Energy Sources"))
# set_region_exit_rules(world.get_region('Starting Planet: No Materials', player),
# [], operator='and')

debug = world.get_region('Starting Planet: No Flight Survival Kit', player)
set_region_exit_rules(world.get_region('Starting Planet: No Flight Survival Kit', player),
[], items=[("Refinery", 1), ("Assembler", 1), ("Renewable Energy Sources", 1)],
player=player, operator='and')

# Has flight
# set_rule(world.get_entrance('Starting Planet: Has Flight', player), lambda state:
# state._space_engineers_has_item(player, "Atmospheric Thrusters") and
# state._space_engineers_has_item(player, "Gyroscope") and
# state._space_engineers_has_item(player, "Control Seat") and
# state._space_engineers_has_item(player, "Cargo Containers") and
# state._space_engineers_has_item(player, "Small Conveyor Tube") and
# state._space_engineers_has_item(player, "Large Conveyor Tube") and
# state._space_engineers_has_item(player, "Connector") and
# state._space_engineers_has_item(player, "Turreted Weapons"))
set_region_exit_rules(world.get_region('Starting Planet: No Flight Full Refinery and Assembler', player),
[],
items=[("Atmospheric Thrusters", 1), ("Gyroscope", 1), ("Control Seat", 1),
Expand All @@ -327,29 +312,17 @@ def set_rules(world: MultiWorld, player: int):
player=player, operator='and')

# Can reach space
# set_rule(world.get_entrance('Space: World Size 2', player), lambda state:
# state._space_engineers_has_item(player, "Hydrogen Thrusters") and
# state._space_engineers_has_item(player, "O2/H2 Generator") and
# state._space_engineers_has_item(player, "Medical Blocks") and
# state._space_engineers_has_item(player, "Gas Tanks") and
# state._space_engineers_has_item(player, "Progressive Space Size", 1))
set_region_exit_rules(world.get_region('Starting Planet: Has Flight', player),
[], items=[("Progressive Space Size", 1), ("Hydrogen Thrusters", 1), ("O2/H2 Generator", 1),
("Medical Blocks", 1), ("Gas Tanks", 1)],
player=player, operator='and')

# Space is larger
# set_rule(world.get_entrance('Space: World Size 3', player), lambda state:
# state._space_engineers_has_item(player, "Ion Thrusters") and
# state._space_engineers_has_item(player, "Jump Drive") and
# state._space_engineers_has_item(player, "Progressive Space Size", 2))
set_region_exit_rules(world.get_region('Space: World Size 2', player),
[], items=[("Progressive Space Size", 2)],
player=player, operator='and')

# Space is even larger
# set_rule(world.get_entrance('Space: World Size 4', player), lambda state:
# state._space_engineers_has_item(player, "Progressive Space Size", 3))
set_region_exit_rules(world.get_region('Space: World Size 3', player), [],
items=[("Progressive Space Size", 3)], player=player, operator="and")
set_region_exit_rules(world.get_region('Space: World Size 4', player),
Expand Down
5 changes: 3 additions & 2 deletions worlds/space_engineers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def _get_slot_data(self):
"refinery_speed": self.multiworld.refinery_speed[self.player],
"welding_speed": self.multiworld.welding_speed[self.player],
"grinding_speed": self.multiworld.grinding_speed[self.player],
"se_item_names": ",".join(name + "\\" + item.se_item_name for name, item in item_table.items())
}

def generate_early(self):
Expand All @@ -95,7 +96,7 @@ def create_items(self):

pool.extend(SpaceEngineersItem("Progressive Space Size", self.player) for _ in range(0, 2))
# Matching number of unfilled locations with filler items
locations_remaining = len(location_table) - 1 - len(pool)
locations_remaining = len(location_table) - 2 - len(pool)
while locations_remaining > 0:
# Filling the pool equally with both types of filler items
pool.append(SpaceEngineersItem("Oxygen Bottle", self.player))
Expand Down Expand Up @@ -173,7 +174,7 @@ def __init__(self, player: int, name: str, address=None, parent=None):


class SpaceEngineersItem(Item):
game = "Space Engineers"
game: str = "Space Engineers"

def __init__(self, name, player: int = None):
item_data = item_table[name]
Expand Down

0 comments on commit 66d91ab

Please sign in to comment.