Removed remnants of team stuff, make hide_goal default

This commit is contained in:
pepperpow 2021-02-05 20:37:27 -06:00
parent cd85279ded
commit 1d1abb7d22
9 changed files with 23 additions and 42 deletions

View File

@ -27,10 +27,11 @@ def main():
''')
parser.add_argument('--quickswap', help='Enable quick item swapping with L and R.', action='store_true')
parser.add_argument('--disablemusic', help='Disables game music.', action='store_true')
parser.add_argument('--triforcehud', default='normal', const='normal', nargs='?', choices=['normal', 'hide_goal', 'hide_total', 'hide_both'],
parser.add_argument('--triforcehud', default='hide_goal', const='hide_goal', nargs='?', choices=['normal', 'hide_goal', 'hide_required', 'hide_both'],
help='''\
Hide the triforce hud in certain circumstances.
hide_goal will hide the hud until finding a triforce piece, hide_total will hide the total amount needed to win
hide_goal will hide the hud until finding a triforce piece, hide_required will hide the total amount needed to win
(Both can be revealed when speaking to Murahalda)
(default: %(default)s)
''')
parser.add_argument('--heartbeep', default='normal', const='normal', nargs='?', choices=['double', 'normal', 'half', 'quarter', 'off'],

View File

@ -244,10 +244,11 @@ def parse_arguments(argv, no_defaults=False):
''')
parser.add_argument('--quickswap', help='Enable quick item swapping with L and R.', action='store_true')
parser.add_argument('--disablemusic', help='Disables game music.', action='store_true')
parser.add_argument('--triforcehud', default='normal', const='normal', nargs='?', choices=['normal', 'hide_goal', 'hide_total', 'hide_both'],
parser.add_argument('--triforcehud', default='hide_goal', const='hide_goal', nargs='?', choices=['normal', 'hide_goal', 'hide_required', 'hide_both'],
help='''\
Hide the triforce hud in certain circumstances.
hide_goal will hide the hud until finding a triforce piece, hide_total will hide the total amount needed to win
hide_goal will hide the hud until finding a triforce piece, hide_required will hide the total amount needed to win
(Both can be revealed when speaking to Murahalda)
(default: %(default)s)
''')
parser.add_argument('--mapshuffle', default=defval(False),

View File

@ -19,7 +19,7 @@ import shutil
from random import randrange
import Shops
from Utils import get_item_name_from_id, get_location_name_from_address, ReceivedItem, int16_as_bytes
from Utils import get_item_name_from_id, get_location_name_from_address, ReceivedItem
exit_func = atexit.register(input, "Press enter to close.")
@ -67,8 +67,6 @@ class Context():
self.forfeit_mode = ''
self.remaining_mode = ''
self.hint_points = 0
self.treasure_count = 0
self.requires_treasure_count = None
# End WebUI Stuff
self.exit_event = asyncio.Event()
@ -992,15 +990,6 @@ async def process_server_cmd(ctx: Context, cmd, args):
elif cmd == 'HintPointUpdate':
ctx.hint_points = args[0]
elif cmd == 'TreasureCount':
if ctx.requires_treasure_count is None:
ctx.requires_treasure_count = (await snes_read(ctx, 0x180165, size=1))[0] >= 0x80
if ctx.requires_treasure_count and ctx.treasure_count < args[0]:
logging.info('Team Triforce count is now {}'.format(args[0]))
ctx.treasure_count = args[0]
snes_buffered_write(ctx, WRAM_START + 0xF418, bytes(int16_as_bytes(ctx.treasure_count)))
await snes_flush_writes(ctx)
else:
logger.debug(f"unknown command {args}")

View File

@ -93,7 +93,6 @@ class Context(Node):
self.hint_cost = hint_cost
self.location_check_points = location_check_points
self.hints_used = collections.defaultdict(int)
self.treasure_count = collections.defaultdict(int)
self.hints: typing.Dict[typing.Tuple[int, int], typing.Set[Utils.Hint]] = collections.defaultdict(set)
self.forfeit_mode: str = forfeit_mode
self.remaining_mode: str = remaining_mode
@ -229,7 +228,6 @@ class Context(Node):
d = {
"rom_names": list(self.rom_names.items()),
"received_items": tuple((k, v) for k, v in self.received_items.items()),
"treasure_count": tuple(v for k, v in self.treasure_count.items()),
"hints_used": tuple((key, value) for key, value in self.hints_used.items()),
"hints": tuple(
(key, list(hint.re_check(self, key[0]) for hint in value)) for key, value in self.hints.items()),
@ -258,7 +256,6 @@ class Context(Node):
return
received_items = {tuple(k): [ReceivedItem(*i) for i in v] for k, v in savedata["received_items"]}
self.treasure_count = {k: v for k, v in enumerate(savedata["treasure_count"])}
self.received_items = received_items
self.hints_used.update({tuple(key): value for key, value in savedata["hints_used"]})
@ -294,8 +291,6 @@ class Context(Node):
logging.info(f'Loaded save file with {sum([len(p) for p in received_items.values()])} received items '
f'for {len(received_items)} players')
if len(self.treasure_count):
logging.info(f'Triforce pieces collected {self.treasure_count}')
def get_aliased_name(self, team: int, slot: int):
if (team, slot) in self.name_aliases:
@ -510,6 +505,7 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations):
if recvd_item.location == location and recvd_item.player == slot:
found = True
break
if not found:
new_item = ReceivedItem(target_item, location, slot)
recvd_items.append(new_item)
@ -525,9 +521,6 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations):
if client.team == team and client.wants_item_notification:
asyncio.create_task(
ctx.send_msgs(client, [['ItemFound', (target_item, location, slot)]]))
if 'Triforce Piece' in get_item_name_from_id(target_item):
ctx.treasure_count[team] = ctx.treasure_count.get(team, 0) + 1
ctx.broadcast_team(team, [['TreasureCount', (ctx.treasure_count[team],)]])
ctx.location_checks[team, slot] |= known_locations
send_new_items(ctx)
@ -1053,8 +1046,6 @@ async def process_client_cmd(ctx: Context, client: Client, cmd, args):
if items:
reply.append(['ReceivedItems', (0, tuplize_received_items(items))])
client.send_index = len(items)
if ctx.treasure_count.get(client.team):
ctx.broadcast_team(team, [['TreasureCount', (ctx.treasure_count[client.team],)]])
await ctx.send_msgs(client, reply)
await on_client_joined(ctx, client)
@ -1064,8 +1055,6 @@ async def process_client_cmd(ctx: Context, client: Client, cmd, args):
if items:
client.send_index = len(items)
await ctx.send_msgs(client, [['ReceivedItems', (0, tuplize_received_items(items))]])
if ctx.treasure_count.get((team)):
ctx.broadcast_team(team, [['TreasureCount', (ctx.treasure_count[team],)]])
elif cmd == 'LocationChecks':
if type(args) is not list:

View File

@ -650,7 +650,7 @@ def roll_settings(weights, plando_options: typing.Set[str] = frozenset(("bosses"
ret.sprite_pool += [key] * int(value)
ret.disablemusic = get_choice('disablemusic', romweights, False)
ret.triforcehud = get_choice('triforcehud', romweights, 'normal')
ret.triforcehud = get_choice('triforcehud', romweights, 'hide_goal')
ret.quickswap = get_choice('quickswap', romweights, True)
ret.fastmenu = get_choice('menuspeed', romweights, "normal")
ret.heartcolor = get_choice('heartcolor', romweights, "red")

10
Rom.py
View File

@ -1,7 +1,7 @@
from __future__ import annotations
JAP10HASH = '03a63945398191337e896e5771f77173'
RANDOMIZERBASEHASH = '93538d51eb018955a90181600e3384ba'
RANDOMIZERBASEHASH = '9cbbc0876dd5748125eda8b315347ad2'
import io
import json
@ -110,7 +110,6 @@ class LocalRom(object):
@staticmethod
def verify(buffer, expected: str = RANDOMIZERBASEHASH) -> bool:
return True
buffermd5 = hashlib.md5()
buffermd5.update(buffer)
return expected == buffermd5.hexdigest()
@ -1106,10 +1105,6 @@ def patch_rom(world, rom, player, team, enemized):
# set up goals for treasure hunt
rom.write_bytes(0x180163, [0x0E, 0x28] if world.treasure_hunt_icon[player] == 'Triforce Piece' else [0x0D, 0x28])
rom.write_int16(0x180166, world.treasure_hunt_count[player])
if 'local' in world.goal[player]:
total_treasures = sum([world.treasure_hunt_count[x] for x in range(1, world.players + 1)])
rom.write_byte(0x180165, rom.read_byte(0x180165) | 0x80)
rom.write_int16(0x180166, total_treasures)
rom.write_byte(0x180194, 1) # Must turn in triforced pieces (instant win not enabled)
rom.write_bytes(0x180213, [0x00, 0x01]) # Not a Tournament Seed
@ -1664,7 +1659,8 @@ def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, tri
rom.write_byte(0x65561, {'red': 0x05, 'blue': 0x0D, 'green': 0x19, 'yellow': 0x09}[color])
# set triforcehud
triforce_flag = (rom.read_byte(0x180165) & 0x80) | {'normal': 0x00, 'hide_goal': 0x01, 'hide_total': 0x02, 'hide_both': 0x03}[triforcehud]
triforce_flag = (rom.read_byte(0x180165) & 0x80) | {'normal': 0x00, 'hide_goal': 0x01, 'hide_required': 0x02, 'hide_both': 0x03}[triforcehud]
print(triforcehud, triforce_flag)
rom.write_byte(0x180165, triforce_flag)
if z3pr:

View File

@ -1580,18 +1580,18 @@
"keyString": "rom.triforcehud.normal",
"friendlyName": "Normal",
"description": "Always displays HUD as usual.",
"defaultValue": 50
"defaultValue": 0
},
"hide_goal": {
"keyString": "rom.triforcehud.hide_goal",
"friendlyName": "Hide Goal",
"description": "Hide Triforce Hud elements until a single triforce piece is acquired.",
"defaultValue": 0
"description": "Hide Triforce Hud elements until a single triforce piece is acquired or spoken to Murahadala",
"defaultValue": 50
},
"hide_total": {
"keyString": "rom.triforcehud.hide_total",
"friendlyName": "Hide Total",
"description": "Hide total amount needed to win the game",
"keyString": "rom.triforcehud.hide_required",
"friendlyName": "Hide Required Total",
"description": "Hide total amount needed to win the game (unless spoken to Murahadala)",
"defaultValue": 0
},
"hide_both": {

Binary file not shown.

View File

@ -388,6 +388,11 @@ rom:
quickswap: # Enable switching items by pressing the L+R shoulder buttons
on: 50
off: 0
triforcehud: # Disable visibility of the triforce hud unless collecting a piece or speaking to Murahalda
normal: 0 # original behavior (always visible)
hide_goal: 50 # hide counter until a piece is collected or speaking to Murahalda
hide_required: 0 # Always visible, but required amount is invisible until determined by Murahalda
hide_both: 0 # Hide both under above circumstances
menuspeed: # Controls how fast the item menu opens and closes
normal: 50
instant: 0