LADX: Add Hints (#1932)
This commit is contained in:
parent
a88e75f3a1
commit
48ffad867a
|
@ -59,6 +59,8 @@ from .patches.aesthetics import rgb_to_bin, bin_to_rgb
|
||||||
|
|
||||||
from .locations.keyLocation import KeyLocation
|
from .locations.keyLocation import KeyLocation
|
||||||
|
|
||||||
|
from BaseClasses import ItemClassification
|
||||||
|
from ..Locations import LinksAwakeningLocation
|
||||||
from ..Options import TrendyGame, Palette, MusicChangeCondition
|
from ..Options import TrendyGame, Palette, MusicChangeCondition
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,12 +240,40 @@ def generateRom(args, settings, ap_settings, auth, seed_name, logic, rnd=None, m
|
||||||
elif settings.quickswap == 'b':
|
elif settings.quickswap == 'b':
|
||||||
patches.core.quickswap(rom, 0)
|
patches.core.quickswap(rom, 0)
|
||||||
|
|
||||||
# TODO: hints bad
|
|
||||||
|
|
||||||
world_setup = logic.world_setup
|
world_setup = logic.world_setup
|
||||||
|
|
||||||
|
JUNK_HINT = 0.33
|
||||||
|
RANDOM_HINT= 0.66
|
||||||
|
# USEFUL_HINT = 1.0
|
||||||
|
# TODO: filter events, filter unshuffled keys
|
||||||
|
all_items = multiworld.get_items()
|
||||||
|
our_items = [item for item in all_items if item.player == player_id and item.code is not None and item.location.show_in_spoiler]
|
||||||
|
our_useful_items = [item for item in our_items if ItemClassification.progression in item.classification]
|
||||||
|
def gen_hint():
|
||||||
|
chance = rnd.uniform(0, 1)
|
||||||
|
if chance < JUNK_HINT:
|
||||||
|
return None
|
||||||
|
elif chance < RANDOM_HINT:
|
||||||
|
location = rnd.choice(our_items).location
|
||||||
|
else: # USEFUL_HINT
|
||||||
|
location = rnd.choice(our_useful_items).location
|
||||||
|
|
||||||
hints.addHints(rom, rnd, item_list)
|
if location.item.player == player_id:
|
||||||
|
name = "Your"
|
||||||
|
else:
|
||||||
|
name = f"{multiworld.player_name[location.item.player]}'s"
|
||||||
|
|
||||||
|
if isinstance(location, LinksAwakeningLocation):
|
||||||
|
location_name = location.ladxr_item.metadata.name
|
||||||
|
else:
|
||||||
|
location_name = location.name
|
||||||
|
hint = f"{name} {location.item} is at {location_name}"
|
||||||
|
if location.player != player_id:
|
||||||
|
hint += f" in {multiworld.player_name[location.player]}'s world"
|
||||||
|
|
||||||
|
return hint
|
||||||
|
|
||||||
|
hints.addHints(rom, rnd, gen_hint)
|
||||||
|
|
||||||
if world_setup.goal == "raft":
|
if world_setup.goal == "raft":
|
||||||
patches.goal.setRaftGoal(rom)
|
patches.goal.setRaftGoal(rom)
|
||||||
|
|
|
@ -49,16 +49,12 @@ useless_hint = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def addHints(rom, rnd, spots):
|
def addHints(rom, rnd, hint_generator):
|
||||||
spots = list(sorted(filter(lambda spot: spot.item in hint_items, spots), key=lambda spot: spot.nameId))
|
|
||||||
text_ids = hint_text_ids.copy()
|
text_ids = hint_text_ids.copy()
|
||||||
rnd.shuffle(text_ids)
|
rnd.shuffle(text_ids)
|
||||||
for text_id in text_ids:
|
for text_id in text_ids:
|
||||||
if len(spots) > 0:
|
hint = hint_generator()
|
||||||
spot_index = rnd.randint(0, len(spots) - 1)
|
if not hint:
|
||||||
spot = spots.pop(spot_index)
|
|
||||||
hint = rnd.choice(hints).format("{%s}" % (spot.item), spot.metadata.area)
|
|
||||||
else:
|
|
||||||
hint = rnd.choice(hints).format(*rnd.choice(useless_hint))
|
hint = rnd.choice(hints).format(*rnd.choice(useless_hint))
|
||||||
rom.texts[text_id] = formatText(hint)
|
rom.texts[text_id] = formatText(hint)
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ class LinksAwakeningWorld(World):
|
||||||
if not self.multiworld.tradequest[self.player] and isinstance(item.item_data, TradeItemData):
|
if not self.multiworld.tradequest[self.player] and isinstance(item.item_data, TradeItemData):
|
||||||
location = self.multiworld.get_location(item.item_data.vanilla_location, self.player)
|
location = self.multiworld.get_location(item.item_data.vanilla_location, self.player)
|
||||||
location.place_locked_item(item)
|
location.place_locked_item(item)
|
||||||
|
location.show_in_spoiler = False
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(item.item_data, DungeonItemData):
|
if isinstance(item.item_data, DungeonItemData):
|
||||||
|
@ -487,7 +488,8 @@ class LinksAwakeningWorld(World):
|
||||||
rnd=self.multiworld.per_slot_randoms[self.player],
|
rnd=self.multiworld.per_slot_randoms[self.player],
|
||||||
player_name=name_for_rom,
|
player_name=name_for_rom,
|
||||||
player_names=all_names,
|
player_names=all_names,
|
||||||
player_id = self.player)
|
player_id = self.player,
|
||||||
|
multiworld=self.multiworld)
|
||||||
|
|
||||||
with open(out_path, "wb") as handle:
|
with open(out_path, "wb") as handle:
|
||||||
rom.save(handle, name="LADXR")
|
rom.save(handle, name="LADXR")
|
||||||
|
|
Loading…
Reference in New Issue