Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehseezed committed Feb 25, 2024
2 parents fbd0abd + 34487dc commit 69acd9c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
7 changes: 6 additions & 1 deletion worlds/am2r/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import copy
import json
import time
import random
from asyncio import StreamReader, StreamWriter
from typing import List
from worlds.am2r.items import item_table
Expand Down Expand Up @@ -112,7 +113,10 @@ def get_payload(ctx: AM2RContext):
for locationid, netitem in ctx.locations_info.items():
gamelocation = location_id_to_game_id[locationid]
if netitem.item in item_id_to_game_id:
gameitem = item_id_to_game_id[netitem.item]
if netitem.flags & 0b100 != 0:
gameitem = random.randint(0, 20)
else:
gameitem = item_id_to_game_id[netitem.item]
else:
gameitem = 20
itemdict[gamelocation] = gameitem
Expand Down Expand Up @@ -206,6 +210,7 @@ def launch():
options = Utils.get_options()

async def main(args):
random.seed()
ctx = AM2RContext(args.connect, args.password)
ctx.server_task = asyncio.create_task(server_loop(ctx), name="ServerLoop")
if gui_enabled:
Expand Down
28 changes: 19 additions & 9 deletions worlds/am2r/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Dict, List, NamedTuple, Set

from BaseClasses import Item, ItemClassification, MultiWorld
from .options import MetroidsAreChecks, MetroidsRequired, get_option_value, TrapFillPercentage, RemoveEquipmentTrap, RemoveTossTrap, RemoveShortBeam, RemoveEMPTrap
from .options import MetroidsAreChecks, MetroidsRequired, get_option_value, TrapFillPercentage, RemoveFloodTrap, RemoveTossTrap, RemoveShortBeam, RemoveEMPTrap, RemoveOHKOTrap, RemoveTouhouTrap


class ItemData(NamedTuple):
Expand Down Expand Up @@ -40,8 +40,8 @@ def create_metroid_items(MetroidsRequired: MetroidsRequired, MetroidsAreChecks:
def create_trap_items(multiworld: MultiWorld, player: int, locations_to_trap: int) -> List[str]:
trap_pool = trap_weights.copy()

if multiworld.RemoveEquipmentTrap[player].value == 1:
del trap_pool["Equipment Trap"]
if multiworld.RemoveFloodTrap[player].value == 1:
del trap_pool["Flood Trap"]

if multiworld.RemoveTossTrap[player].value == 1:
del trap_pool["Big Toss Trap"]
Expand All @@ -51,6 +51,12 @@ def create_trap_items(multiworld: MultiWorld, player: int, locations_to_trap: in

if multiworld.RemoveEMPTrap[player].value == 1:
del trap_pool["EMP Trap"]

if multiworld.RemoveTouhouTrap[player].value == 1:
del trap_pool["Touhou Trap"]

if multiworld.RemoveOHKOTrap[player].value == 1:
del trap_pool["OHKO Trap"]

return multiworld.random.choices(
population=list(trap_pool.keys()),
Expand Down Expand Up @@ -112,10 +118,12 @@ def create_all_items(multiworld: MultiWorld, player: int) -> None:
"Spazer": ItemData(8678018, "Beam", ItemClassification.useful, 13, 1),
"Plasma Beam": ItemData(8678019, "Beam", ItemClassification.useful, 14, 1),
"Ice Beam": ItemData(8678020, "Beam", ItemClassification.progression, 11, 1),
"Equipment Trap": ItemData(8678021, "Trap", ItemClassification.trap, 21),
"Big Toss Trap": ItemData(8678022, "Trap", ItemClassification.trap, 22),
"Flood Trap": ItemData(8678021, "Trap", ItemClassification.trap, 21),
"Big Toss Trap": ItemData(8678022, "Trap", ItemClassification.trap, 22),
"Short Beam": ItemData(8678023, "Trap", ItemClassification.trap, 23),
"EMP Trap": ItemData(8678024, "Trap", ItemClassification.trap, 24),
"OHKO Trap": ItemData(8678026, "Trap", ItemClassification.trap, 25),
"Touhou Trap": ItemData(8678027, "Trap", ItemClassification.trap, 26),
"Metroid": ItemData(8678025, "MacGuffin", ItemClassification.progression_skip_balancing, 19),
"The Galaxy is at Peace": ItemData(None, "Victory", ItemClassification.progression)

Expand All @@ -128,10 +136,12 @@ def create_all_items(multiworld: MultiWorld, player: int) -> None:
}

trap_weights: Dict[str, int] = {
"Equipment Trap": 1,
"Big Toss Trap": 3,
"Short Beam": 3,
"EMP Trap": 2
"Flood Trap": 1,
"Big Toss Trap": 1,
"Short Beam": 1,
"EMP Trap": 1,
"Touhou Trap": 1,
"OHKO Trap": 1
}


Expand Down
18 changes: 14 additions & 4 deletions worlds/am2r/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class TrapFillPercentage(Range):
default = 0


class RemoveEquipmentTrap(Toggle):
"""This one sucks and is generally un-fun, so it is likely to change"""
display_name = "Remove Equipment Trap"
class RemoveFloodTrap(Toggle):
"""Removes Flood Traps from trap fill"""
display_name = "Remove Flood Trap"


class RemoveTossTrap(Toggle):
Expand All @@ -48,6 +48,14 @@ class RemoveEMPTrap(Toggle):
"""Yes we know that it looks weird during the idle animation, but it's a vanilla bug"""
display_name = "Remove EMP Trap"

class RemoveTouhouTrap(Toggle):
"""Removes Touhou Traps from trap fill"""
display_name = "Remove Touhou Trap"

class RemoveOHKOTrap(Toggle):
"""Removes OHKO Traps from trap fill"""
display_name = "Remove OHKO Trap"


#class ItemSprites(OptionList):
# """Changes Item Sprites. Does not affect gameplay
Expand Down Expand Up @@ -102,10 +110,12 @@ class RemoveEMPTrap(Toggle):
"MetroidsRequired": MetroidsRequired,
"MetroidsAreChecks": MetroidsAreChecks,
"TrapFillPercentage": TrapFillPercentage,
"RemoveEquipmentTrap": RemoveEquipmentTrap,
"RemoveFloodTrap": RemoveFloodTrap,
"RemoveTossTrap": RemoveTossTrap,
"RemoveShortBeam": RemoveShortBeam,
"RemoveEMPTrap": RemoveEMPTrap,
"RemoveTouhouTrap": RemoveTouhouTrap,
"RemoveOHKOTrap": RemoveOHKOTrap,
# "Item Sprites": ItemSprites,
# "Starting Weapons": StartingWeapons,
# "Randomize Baby", RandomizeBaby
Expand Down

0 comments on commit 69acd9c

Please sign in to comment.