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

Undertale: Key placement fix #2030

Merged
merged 29 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a2aad08
Undertale: Docs change and QOL addition
jonloveslegos Jul 5, 2023
1c6a269
Fixed items being sent out from changing slots without restarting the…
jonloveslegos Jul 7, 2023
673f41f
Copied over ChecksfinderClient's Linux compatibility code into Undert…
jonloveslegos Jul 10, 2023
4b2c004
Merge branch 'ArchipelagoMW:main' into UndertaleFixes2
jonloveslegos Jul 20, 2023
380c192
Undertale: Fixed a mysterious error caused by a new line instruction …
jonloveslegos Jul 20, 2023
74f9062
Added a missing piece of documentation about the custom items, made t…
jonloveslegos Jul 21, 2023
015184c
Merge branch 'main' into UndertaleFixes2
jonloveslegos Jul 21, 2023
d8b14dc
Merge branch 'main' into UndertaleFixes2
jonloveslegos Jul 22, 2023
7605e57
Undertale: Incremented data_version by 1
jonloveslegos Jul 22, 2023
9a0fd31
Undertale: Added setting starting key to pre_fill to allow plando to …
jonloveslegos Jul 24, 2023
c3a4fb6
Merge branch 'main' into UndertaleFixes2
jonloveslegos Jul 24, 2023
9d6dc39
Update worlds/undertale/__init__.py
jonloveslegos Jul 24, 2023
c08038e
Update worlds/undertale/__init__.py
jonloveslegos Jul 25, 2023
b635abc
Merge branch 'main' into UndertaleFixes2
jonloveslegos Jul 25, 2023
43b085e
Merge branch 'main' into UndertaleFixes2
jonloveslegos Jul 25, 2023
a10f3d3
Undertale: Changed the Starting Key location to be a start inventory …
jonloveslegos Jul 25, 2023
f80346b
Merge branch 'main' into UndertaleFixes2
jonloveslegos Jul 25, 2023
137c716
Update worlds/undertale/__init__.py
jonloveslegos Jul 27, 2023
aa96d87
Fixed github's suggestion mistake
jonloveslegos Jul 27, 2023
5c97a82
Merge branch 'main' into UndertaleFixes2
jonloveslegos Jul 28, 2023
4a0282d
Update worlds/undertale/Options.py
jonloveslegos Jul 28, 2023
4b6b5a7
Update worlds/undertale/Rules.py
jonloveslegos Jul 28, 2023
d109962
Undertale: Removed a redundant line of code in init.py
jonloveslegos Jul 28, 2023
a77ce1b
Merge branch 'main' into UndertaleFixes2
jonloveslegos Jul 28, 2023
c4323d5
Undertale: Moved the send_msgs awaits to prevent them returning with …
jonloveslegos Aug 1, 2023
75b00aa
Undertale: Added finished_game to __init__
jonloveslegos Aug 1, 2023
fa31f15
Merge branch 'main' into UndertaleFixes2
jonloveslegos Aug 1, 2023
7d2eb93
Merge branch 'main' into UndertaleFixes2
jonloveslegos Aug 2, 2023
449d63c
Merge branch 'main' into UndertaleFixes2
jonloveslegos Aug 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions UndertaleClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class UndertaleContext(CommonContext):
def __init__(self, server_address, password):
super().__init__(server_address, password)
self.pieces_needed = 0
self.finished_game = False
self.game = "Undertale"
self.got_deathlink = False
self.syncing = False
Expand Down Expand Up @@ -239,8 +240,6 @@ async def process_undertale_cmd(ctx: UndertaleContext, cmd: str, args: dict):
for ss in set(args["checked_locations"]):
f.write(str(ss-12000)+"\n")
f.close()
message = [{"cmd": "LocationChecks", "locations": [79067]}]
await ctx.send_msgs(message)
elif cmd == "LocationInfo":
for l in args["locations"]:
locationid = l.location
Expand Down Expand Up @@ -436,9 +435,9 @@ async def game_watcher(ctx: UndertaleContext):
for l in lines:
if ctx.server_locations.__contains__(int(l)+12000):
sending = sending + [int(l.rstrip('\n'))+12000]
finally:
await ctx.send_msgs([{"cmd": "LocationScouts", "locations": sending,
"create_as_hint": int(2)}])
finally:
os.remove(root+"/"+file)
if "check.spot" in file:
sending = []
Expand All @@ -447,10 +446,8 @@ async def game_watcher(ctx: UndertaleContext):
lines = f.readlines()
for l in lines:
sending = sending+[(int(l.rstrip('\n')))+12000]
message = [{"cmd": "LocationChecks", "locations": sending}]
await ctx.send_msgs(message)
finally:
pass
await ctx.send_msgs([{"cmd": "LocationChecks", "locations": sending}])
if "victory" in file and str(ctx.route) in file:
victory = True
if ".playerspot" in file and "Online" not in ctx.tags:
Expand Down
8 changes: 4 additions & 4 deletions worlds/undertale/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ class UndertaleItem(Item):
"ATK Up": ItemData(77065, ItemClassification.useful),
"DEF Up": ItemData(77066, ItemClassification.useful),
"HP Up": ItemData(77067, ItemClassification.useful),
"FIGHT": ItemData(77077, ItemClassification.progression),
"ACT": ItemData(77078, ItemClassification.progression),
"ITEM": ItemData(77079, ItemClassification.progression),
"MERCY": ItemData(77080, ItemClassification.progression),
"FIGHT": ItemData(77077, ItemClassification.useful),
"ACT": ItemData(77078, ItemClassification.useful),
"ITEM": ItemData(77079, ItemClassification.useful),
"MERCY": ItemData(77080, ItemClassification.useful),
"Ruins Key": ItemData(77081, ItemClassification.progression),
"Snowdin Key": ItemData(77082, ItemClassification.progression),
"Waterfall Key": ItemData(77083, ItemClassification.progression),
Expand Down
1 change: 0 additions & 1 deletion worlds/undertale/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def __init__(self, player: int, name: str, address: typing.Optional[int], parent
"True Lab Plot": AdvData(79063, "Hotland"),
"Left New Home Key": AdvData(79064, "New Home"),
"Right New Home Key": AdvData(79065, "New Home"),
"Starting Key": AdvData(79067, "Hub"),
"LOVE 2": AdvData(79902, "???"),
"LOVE 3": AdvData(79903, "???"),
"LOVE 4": AdvData(79904, "???"),
Expand Down
12 changes: 12 additions & 0 deletions worlds/undertale/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ class RouteRequired(Choice):
default = 0


class StartingArea(Choice):
"""Which area to start with access to."""
display_name = "Starting Area"
option_ruins = 0
option_snowdin = 1
option_waterfall = 2
option_hotland = 3
option_core = 4
default = 0


class IncludeTemy(Toggle):
"""Adds Temmy Armor to the item pool."""
display_name = "Include Temy Armor"
Expand Down Expand Up @@ -77,6 +88,7 @@ class RandoBattleOptions(Toggle):

undertale_options: typing.Dict[str, type(Option)] = {
"route_required": RouteRequired,
"starting_area": StartingArea,
"key_hunt": KeyHunt,
"key_pieces": KeyPieces,
"rando_love": RandomizeLove,
Expand Down
71 changes: 9 additions & 62 deletions worlds/undertale/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,6 @@ def set_rules(multiworld: MultiWorld, player: int):
set_rule(multiworld.get_entrance("Waterfall Hub", player), lambda state: state.has("Waterfall Key", player))
set_rule(multiworld.get_entrance("Hotland Hub", player), lambda state: state.has("Hotland Key", player))
set_rule(multiworld.get_entrance("Core Hub", player), lambda state: state.has("Core Key", player))
if _undertale_is_route(multiworld.state, player, 1):
add_rule(multiworld.get_entrance("Snowdin Hub", player), lambda state: state.has("ACT", player) and state.has("MERCY", player))
add_rule(multiworld.get_entrance("Waterfall Hub", player), lambda state: state.has("ACT", player) and state.has("MERCY", player))
add_rule(multiworld.get_entrance("Hotland Hub", player), lambda state: state.has("ACT", player) and state.has("MERCY", player))
add_rule(multiworld.get_entrance("Core Hub", player), lambda state: state.has("ACT", player) and state.has("MERCY", player))
if _undertale_is_route(multiworld.state, player, 2) or _undertale_is_route(multiworld.state, player, 3):
add_rule(multiworld.get_entrance("Snowdin Hub", player), lambda state: state.has("FIGHT", player))
add_rule(multiworld.get_entrance("Waterfall Hub", player), lambda state: state.has("FIGHT", player))
add_rule(multiworld.get_entrance("Hotland Hub", player), lambda state: state.has("FIGHT", player))
add_rule(multiworld.get_entrance("Core Hub", player), lambda state: state.has("FIGHT", player))
if _undertale_is_route(multiworld.state, player, 0):
add_rule(multiworld.get_entrance("Snowdin Hub", player), lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
add_rule(multiworld.get_entrance("Waterfall Hub", player), lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
add_rule(multiworld.get_entrance("Hotland Hub", player), lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
add_rule(multiworld.get_entrance("Core Hub", player), lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
set_rule(multiworld.get_entrance("Core Exit", player),
lambda state: _undertale_has_plot(state, player, "Mettaton Plush"))
set_rule(multiworld.get_entrance("New Home Exit", player),
Expand Down Expand Up @@ -153,7 +138,7 @@ def set_rules(multiworld: MultiWorld, player: int):
if multiworld.rando_stats[player]:
set_rule(multiworld.get_location(("ATK "+str(maxlv)), player), lambda state: False)
set_rule(multiworld.get_location(("HP "+str(maxlv)), player), lambda state: False)
if maxlv == 9 or maxlv == 13 or maxlv == 17:
if maxlv in {5, 9, 13, 17}:
set_rule(multiworld.get_location(("DEF "+str(maxlv)), player), lambda state: False)
maxlv = 1
while maxlv < 20:
Expand All @@ -165,53 +150,53 @@ def set_rules(multiworld: MultiWorld, player: int):
lambda state: (state.can_reach("Old Home", "Region", player)), combine="or")
add_rule(multiworld.get_location(("HP "+str(maxlv)), player),
lambda state: (state.can_reach("Old Home", "Region", player)), combine="or")
if maxlv == 9 or maxlv == 13 or maxlv == 17:
if maxlv == 5 or maxlv == 9 or maxlv == 13 or maxlv == 17:
add_rule(multiworld.get_location(("DEF "+str(maxlv)), player),
lambda state: (state.can_reach("Old Home", "Region", player)), combine="or")
elif curarea == "Snowdin Town":
add_rule(multiworld.get_location(("ATK "+str(maxlv)), player),
lambda state: (state.can_reach("Snowdin Town", "Region", player)), combine="or")
add_rule(multiworld.get_location(("HP "+str(maxlv)), player),
lambda state: (state.can_reach("Snowdin Town", "Region", player)), combine="or")
if maxlv == 9 or maxlv == 13 or maxlv == 17:
if maxlv == 5 or maxlv == 9 or maxlv == 13 or maxlv == 17:
add_rule(multiworld.get_location(("DEF "+str(maxlv)), player),
lambda state: (state.can_reach("Snowdin Town", "Region", player)), combine="or")
elif curarea == "Waterfall":
add_rule(multiworld.get_location(("ATK "+str(maxlv)), player),
lambda state: (state.can_reach("Waterfall", "Region", player)), combine="or")
add_rule(multiworld.get_location(("HP "+str(maxlv)), player),
lambda state: (state.can_reach("Waterfall", "Region", player)), combine="or")
if maxlv == 9 or maxlv == 13 or maxlv == 17:
if maxlv == 5 or maxlv == 9 or maxlv == 13 or maxlv == 17:
add_rule(multiworld.get_location(("DEF "+str(maxlv)), player),
lambda state: (state.can_reach("Waterfall", "Region", player)), combine="or")
elif curarea == "News Show":
add_rule(multiworld.get_location(("ATK "+str(maxlv)), player),
lambda state: (state.can_reach("News Show", "Region", player)), combine="or")
add_rule(multiworld.get_location(("HP "+str(maxlv)), player),
lambda state: (state.can_reach("News Show", "Region", player)), combine="or")
if maxlv == 9 or maxlv == 13 or maxlv == 17:
if maxlv == 5 or maxlv == 9 or maxlv == 13 or maxlv == 17:
add_rule(multiworld.get_location(("DEF "+str(maxlv)), player),
lambda state: (state.can_reach("News Show", "Region", player)), combine="or")
elif curarea == "Core":
add_rule(multiworld.get_location(("ATK "+str(maxlv)), player),
lambda state: (state.can_reach("Core Exit", "Entrance", player)), combine="or")
add_rule(multiworld.get_location(("HP "+str(maxlv)), player),
lambda state: (state.can_reach("Core Exit", "Entrance", player)), combine="or")
if maxlv == 9 or maxlv == 13 or maxlv == 17:
if maxlv == 5 or maxlv == 9 or maxlv == 13 or maxlv == 17:
add_rule(multiworld.get_location(("DEF "+str(maxlv)), player),
lambda state: (state.can_reach("Core Exit", "Entrance", player)), combine="or")
elif curarea == "Sans":
add_rule(multiworld.get_location(("ATK "+str(maxlv)), player),
lambda state: (state.can_reach("New Home Exit", "Entrance", player)), combine="or")
add_rule(multiworld.get_location(("HP "+str(maxlv)), player),
lambda state: (state.can_reach("New Home Exit", "Entrance", player)), combine="or")
if maxlv == 9 or maxlv == 13 or maxlv == 17:
if maxlv == 5 or maxlv == 9 or maxlv == 13 or maxlv == 17:
add_rule(multiworld.get_location(("DEF "+str(maxlv)), player),
lambda state: (state.can_reach("New Home Exit", "Entrance", player)), combine="or")
if multiworld.rando_love[player]:
if curarea == "Old Home":
add_rule(multiworld.get_location(("LOVE "+str(maxlv)), player),
lambda state: ( state.can_reach("Old Home", "Region", player)), combine="or")
lambda state: (state.can_reach("Old Home", "Region", player)), combine="or")
elif curarea == "Snowdin Town":
add_rule(multiworld.get_location(("LOVE "+str(maxlv)), player),
lambda state: (state.can_reach("Snowdin Town", "Region", player)), combine="or")
Expand Down Expand Up @@ -247,46 +232,8 @@ def set_rules(multiworld: MultiWorld, player: int):
curarea = "Sans"
maxlv = 1
exp = 99999
set_rule(multiworld.get_entrance("??? Exit", player), lambda state: state.has("FIGHT", player))
set_rule(multiworld.get_location("Snowman", player),
lambda state: state.can_reach("Snowdin Town", "Region", player))
add_item_rule(multiworld.get_location("Starting Key", player), lambda item: item.name == "Ruins Key" or
item.name == "Snowdin Key" or
item.name == "Waterfall Key" or
item.name == "Hotland Key")
if _undertale_is_route(multiworld.state, player, 1):
set_rule(multiworld.get_location("Donut Sale", player),
lambda state: state.has("ACT", player) and state.has("MERCY", player))
set_rule(multiworld.get_location("Cider Sale", player),
lambda state: state.has("ACT", player) and state.has("MERCY", player))
set_rule(multiworld.get_location("Ribbon Cracks", player),
lambda state: state.has("ACT", player) and state.has("MERCY", player))
set_rule(multiworld.get_location("Toy Knife Edge", player),
lambda state: state.has("ACT", player) and state.has("MERCY", player))
set_rule(multiworld.get_location("B.Scotch Pie Given", player),
lambda state: state.has("ACT", player) and state.has("MERCY", player))
if _undertale_is_route(multiworld.state, player, 2) or _undertale_is_route(multiworld.state, player, 3):
set_rule(multiworld.get_location("Donut Sale", player),
lambda state: state.has("FIGHT", player))
set_rule(multiworld.get_location("Cider Sale", player),
lambda state: state.has("FIGHT", player))
set_rule(multiworld.get_location("Ribbon Cracks", player),
lambda state: state.has("FIGHT", player))
set_rule(multiworld.get_location("Toy Knife Edge", player),
lambda state: state.has("FIGHT", player))
set_rule(multiworld.get_location("B.Scotch Pie Given", player),
lambda state: state.has("FIGHT", player))
if _undertale_is_route(multiworld.state, player, 0):
set_rule(multiworld.get_location("Donut Sale", player),
lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
set_rule(multiworld.get_location("Cider Sale", player),
lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
set_rule(multiworld.get_location("Ribbon Cracks", player),
lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
set_rule(multiworld.get_location("Toy Knife Edge", player),
lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
set_rule(multiworld.get_location("B.Scotch Pie Given", player),
lambda state: ((state.has("ACT", player) and state.has("MERCY", player)) or state.has("FIGHT", player)))
set_rule(multiworld.get_location("Mettaton Plot", player),
lambda state: state.can_reach("Core Exit", "Entrance", player))
set_rule(multiworld.get_location("Bunny 1", player),
Expand Down Expand Up @@ -357,7 +304,7 @@ def set_rules(multiworld: MultiWorld, player: int):

# Sets rules on completion condition
def set_completion_rules(multiworld: MultiWorld, player: int):
completion_requirements = lambda state: state.can_reach("New Home Exit", "Entrance", player) and state.has("FIGHT", player)
completion_requirements = lambda state: state.can_reach("New Home Exit", "Entrance", player)
if _undertale_is_route(multiworld.state, player, 1):
completion_requirements = lambda state: state.can_reach("True Lab", "Region", player)

Expand Down
7 changes: 6 additions & 1 deletion worlds/undertale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class UndertaleWorld(World):
item_name_to_id = {name: data.code for name, data in item_table.items()}
location_name_to_id = {name: data.id for name, data in advancement_table.items()}

data_version = 6
data_version = 7

def _get_undertale_data(self):
return {
Expand All @@ -63,6 +63,7 @@ def _get_undertale_data(self):
"client_version": self.required_client_version,
"race": self.multiworld.is_race,
"route": self.multiworld.route_required[self.player].current_key,
"starting_area": self.multiworld.starting_area[self.player].current_key,
"temy_armor_include": bool(self.multiworld.temy_include[self.player].value),
"only_flakes": bool(self.multiworld.only_flakes[self.player].value),
"no_equips": bool(self.multiworld.no_equips[self.player].value),
Expand Down Expand Up @@ -153,6 +154,10 @@ def create_items(self):
if item == "Heart Locket" else item for item in itempool]
if self.multiworld.only_flakes[self.player]:
itempool = [item for item in itempool if item not in non_key_items]

starting_key = self.multiworld.starting_area[self.player].current_key.title() + " Key"
itempool.remove(starting_key)
self.multiworld.push_precollected(self.create_item(starting_key))
# Choose locations to automatically exclude based on settings
exclusion_pool = set()
exclusion_pool.update(exclusion_table[self.multiworld.route_required[self.player].current_key])
Expand Down