Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial client #2

Merged
merged 17 commits into from
Apr 6, 2024
Merged

Initial client #2

merged 17 commits into from
Apr 6, 2024

Conversation

hesto2
Copy link
Collaborator

@hesto2 hesto2 commented Mar 30, 2024

This adds the following:

  • Client for interacting w/ Dolphin for memory management
  • Interface for conducting pragmatic actions on the Game (Add item, set health, etc.)
  • MetroidPrime client for Archipelago

The client currently will do the following:

  • Manage the connection to the game (connect, disconnect on errors, and attempt to reconnect)
  • Manage the connection to the AP server
  • Detect when the game is in a state it can receive items
  • Handle receiving items from the AP server

Next steps (future PR):

  • Receiving Artifacts will currently add them to your inventory but does not actually do anything in the Artifact Temple. Need to update some flags so that when the player receives the artifact it will also update the world state.
  • Handle sending location checks (we've discussed this already 👍 )

Steps to test:

  • Generate a yaml for Metroid Prime and any other game with 2 separate player names
  • (For prime, I ran the webhost locally by adding a config.yaml file with PORT: 8080 in the root of the directory then python WebHost.py, here's the link http://localhost:8080/games/Metroid%20Prime/player-options )
  • Drop the yaml files in a folder titled Players in the root of the AP project
  • Run Generate.py and unzip the file in the output folder then click the .archipelago file to run the multi world server
  • In a separate terminal run python MetroidPrimeClient.py optionally add --connect localhost:9999 --name PlayerSlotName if you want to speed it up a bit

On the server, use /send_location other_player location_name to test sending items via location, /send_multiple 3 Hesto2 Missile Expansion also works if you want to test with specific items (a little bit more pragmatic for most cases)

Pardon the book here, I'm mostly documenting this here in such great detail so that if I forget how to test this later I'll be able to come back and reference this 😅

logger.debug(f"Giving item {item_data.name} to player")
ctx.game_interface.give_item_to_player(item_data.id, 1, 1)

# Handle Missile Expansions
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not in love with the size of this function, but I figured rather than creating an abstraction it'd be more pragmatic to keep them separate since each of these 3 different powerups have a slightly different effect when you receive them (gain 5 missiles, gain 1 bomb, restore health). Open to suggestions here though for sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an area where we can also gate the player from receiving any Missile or PB expansions if they haven't received the Missile Launcher or Power Bomb Main items yet.


if __name__ == "__main__":
parser = get_base_parser()
parser.add_argument('--name', default=None,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added support for a --name argument so I don't have to type it in every time I test the client connecting to AP. SC2 client does something similar so I figured it wasn't going to break anything upstream 🤣


class MetroidPrimeArea(Enum):
"""Game worlds with their corresponding IDs in memory"""
Impact_Crater = 3241871825
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move these into the Region data structure later if we want

@@ -47,7 +47,7 @@ class MetroidPrimeItem(Item):
"Gravity Suit": ItemData("Gravity Suit", 21, ItemClassification.progression),
"Varia Suit": ItemData("Varia Suit", 22, ItemClassification.progression),
"Phazon Suit": ItemData("Phazon Suit", 23, ItemClassification.progression),
"Energy Tank": ItemData("Energy Tank", 24, ItemClassification.useful),
"Energy Tank": ItemData("Energy Tank", 24, ItemClassification.useful, 14),
"Spring Ball": ItemData("Spring Ball", 25, ItemClassification.useful),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to look at putting Spring Ball somewhere else (maybe 43?) if we want to use UnknownItem1 for location checks

@Electro1512 Electro1512 merged commit 80ea63a into main Apr 6, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants