Skip to content

Commit deb5716

Browse files
Updated Location Logic
1 parent a1754bf commit deb5716

6 files changed

Lines changed: 342 additions & 295 deletions

File tree

worlds/chibi_robo/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ def create_itempool(world: "ChibiRoboWorld") -> List[Item]:
240240
item_type: ItemClassification = ITEM_TABLE.get(name).classification
241241
itempool += create_multiple_items(world, name, 1, item_type)
242242

243+
world.get_location("Living Room - Candy Wrapper by Jenny B").place_locked_item(itempool[0])
244+
itempool.remove(itempool[0])
245+
246+
# Force coin so users can climb the drain
247+
world.get_location("Middle Row 10M Coin C").place_locked_item(itempool[51])
248+
itempool.remove(itempool[51])
249+
243250
unfilled_locations = len(world.multiworld.get_unfilled_locations(world.player))
244251

245252
while len(itempool) < unfilled_locations:

worlds/chibi_robo/client.py

Lines changed: 73 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@
3535
CURRENT_INDEX_ADDR = 0
3636

3737
# This address contains the current stage / room ID.
38-
CURR_STAGE_ID_ADDR = 0x8026644C
38+
CURR_STAGE_ID_ADDR = 0x8025f847
39+
40+
CURR_GAME_STATE = 0x8025df17
3941

4042
# This address is used to check/set the player's battery
41-
CURR_BATTERY_ADDR = 0x8396558
43+
CURR_BATTERY_ADDR = 0x8038f748
4244

4345
GC_GAME_ID_ADDRESS = 0x80000000
4446

@@ -48,6 +50,8 @@
4850

4951
HAPPY_POINTS_ADDR = 0x8039653C
5052

53+
BASE_ITEM_ADDR = 0x80370000
54+
5155
class ChibiRoboJSONToTextParser(JSONtoTextParser):
5256
def _handle_color(self, node: JSONMessagePart):
5357
return self._handle_text(node) # No colors for the in-game text
@@ -71,6 +75,16 @@ def _cmd_debug(self) -> None:
7175
# logger.info(f"{self.ctx.location_names["Chibi Robo"]}")
7276
return
7377

78+
def _cmd_equip_blaster(self) -> None:
79+
"""
80+
Equip Blaster
81+
"""
82+
if isinstance(self.ctx, ChibiRoboContext):
83+
dolphin_memory_engine.write_bytes(0x8038f6c2, bytes(2))
84+
dolphin_memory_engine.write_bytes(0x8038f6c4, bytes(0))
85+
dolphin_memory_engine.write_bytes(0x8038f6c6, bytes(2))
86+
return
87+
7488
def _cmd_dolphin(self) -> None:
7589
"""
7690
Display the current Dolphin emulator connection status.
@@ -288,8 +302,6 @@ def _give_item(ctx: ChibiRoboContext, item_name: str) -> bool:
288302
:param item_name: Name of the item to give.
289303
:return: Whether the item was successfully given.
290304
"""
291-
global CURR_STAGE_ID_ADDR
292-
global EXPECTED_INDEX_ADDR
293305

294306
if not check_ingame() or dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0e":
295307
return False
@@ -368,7 +380,9 @@ def check_ingame() -> bool:
368380
:return: `True` if the player is in-game, otherwise `False`.
369381
"""
370382

371-
return dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) not in ["" , '\x00\x00\x00\x0e', '\x00\x00\x00\x01', '\x00\x00\x00\x02', '\x00\x00\x00\x03', '\x00\x00\x00\x04', '\x00\x00\x00\x05', '\x00\x00\x00\x06','\x00\x00\x00\x07','\x00\x00\x00\x09','\x00\x00\x00\x0a','\x00\x00\x00\x0b','\x00\x00\x00\x10','\x00\x00\x00\x12','\x00\x00\x00\x16']
383+
# logger.info(dolphin_memory_engine.read_bytes(CURR_GAME_STATE, 1))
384+
385+
return dolphin_memory_engine.read_bytes(CURR_GAME_STATE, 1) not in ["" , '\x00', '\x40', '\x07']
372386

373387
async def give_items(ctx: ChibiRoboContext) -> None:
374388
"""
@@ -429,6 +443,13 @@ async def check_locations(ctx: ChibiRoboContext) -> None:
429443
curr_stage_id = stage_hex_to_id()
430444
ctx.curr_stage_pickup = read_4byte_short(EXPECTED_INDEX_ADDR)
431445

446+
for location, data in LOCATION_TABLE.items():
447+
checked = False
448+
449+
# logger.info(data.bit)
450+
451+
checked = check_location(ctx, curr_stage_id, location, data)
452+
432453
if ctx.curr_stage_pickup != 65535:
433454

434455
# Loop through all locations to see if each has been checked.
@@ -472,79 +493,88 @@ def check_location(ctx: ChibiRoboContext, curr_stage_id: int, name: str ,data: C
472493
checked = False
473494
# If the location is in the current stage, check the bitfields for the current stage as well.
474495
if not checked and curr_stage_id == data.stage_id:
475-
# logger.info(name)
476-
checked = bool((ctx.curr_stage_pickup >> data.bit) & 1)
496+
497+
if data.address:
498+
499+
logger.info(name)
500+
501+
location_addr = hex(BASE_ITEM_ADDR + data.address)
502+
503+
logger.info( dolphin_memory_engine.read_bytes(int( location_addr, 16), 4) )
504+
505+
# checked = bool((ctx.curr_stage_pickup >> data.bit) & 1)
477506

478507
return checked
479508

480509
def stage_hex_to_name() -> str:
481-
global CURR_STAGE_ID_ADDR
510+
stage_value = dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 1)
482511

483-
if dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0e":
512+
if stage_value == b"\x0e":
484513
return "Menu"
485-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x01":
514+
elif stage_value == b"\x01":
486515
return "Kitchen"
487-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x02":
516+
elif stage_value == b"\x02":
488517
return "Foyer"
489-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x03":
518+
elif stage_value == b"\x03":
490519
return "Basement"
491-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x04":
520+
elif stage_value == b"\x04":
492521
return "Jenny's Room"
493-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x05":
522+
elif stage_value == b"\x05":
494523
return "Chibi House"
495-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x06":
524+
elif stage_value == b"\x06":
496525
return "Bedroom"
497-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x07":
526+
elif stage_value == b"\x07":
498527
return "Living Room"
499-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x09":
528+
elif stage_value == b"\x09":
500529
return "Backyard"
501-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0a":
530+
elif stage_value == b"\x0a":
502531
return "Staff Credits"
503-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0b":
532+
elif stage_value == b"\x0b":
504533
return "Drain"
505-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0e":
534+
elif stage_value == b"\x0e":
506535
return "Living Room (Birthday)"
507-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x10":
536+
elif stage_value == b"\x10":
508537
return "UFO"
509-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x12":
538+
elif stage_value == b"\x12":
510539
return "Bedroom (Past)"
511-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x16":
540+
elif stage_value == b"\x16":
512541
return "Mother Spider Boss"
513542

514543
return "Could Not Find Room / Stage Name"
515544

516545
def stage_hex_to_id() -> int:
517-
global CURR_STAGE_ID_ADDR
518546

519-
if dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0e":
547+
stage_value = dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 1)
548+
549+
if stage_value == b"\x0e":
520550
return 0 # 'Menu'
521-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x01":
551+
elif stage_value == b"\x01":
522552
return 1 # "Kitchen"
523-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x02":
553+
elif stage_value == b"\x02":
524554
return 2 #"Foyer"
525-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x03":
555+
elif stage_value == b"\x03":
526556
return 3 #"Basement"
527-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x04":
557+
elif stage_value == b"\x04":
528558
return 4 #"Jenny's Room"
529-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x05":
559+
elif stage_value == b"\x05":
530560
return 5 #"Chibi House"
531-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x06":
561+
elif stage_value == b"\x06":
532562
return 6 #"Bedroom"
533-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x07":
563+
elif stage_value == b"\x07":
534564
return 7 #"Living Room"
535-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x09":
565+
elif stage_value == b"\x09":
536566
return 8 #"Backyard"
537-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0a":
567+
elif stage_value == b"\x0a":
538568
return 9 #"Staff Credits"
539-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0b":
569+
elif stage_value == b"\x0b":
540570
return 10 #"Drain"
541-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x0e":
571+
elif stage_value == b"\x0e":
542572
return 11 #"Living Room (Birthday)"
543-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x10":
573+
elif stage_value == b"\x10":
544574
return 12 #"UFO"
545-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x12":
575+
elif stage_value == b"\x12":
546576
return 13 #"Bedroom (Past)"
547-
elif dolphin_memory_engine.read_bytes(CURR_STAGE_ID_ADDR, 4) == b"\x00\x00\x00\x16":
577+
elif stage_value == b"\x16":
548578
return 14 #"Mother Spider Boss"
549579

550580
return -1 #"Could Not Find Room / Stage Name"
@@ -581,6 +611,9 @@ async def check_alive() -> bool:
581611
:return: `True` if the player is alive, otherwise `False`.
582612
"""
583613
cur_health = read_short(CURR_BATTERY_ADDR)
614+
615+
logger.info(cur_health)
616+
584617
return cur_health > 0
585618

586619

@@ -628,7 +661,7 @@ async def dolphin_sync_task(ctx: ChibiRoboContext) -> None:
628661
dolphin_memory_engine.hook()
629662
if dolphin_memory_engine.is_hooked():
630663

631-
if dolphin_memory_engine.read_bytes(0x80000000, 6) != b"GGTP01":
664+
if dolphin_memory_engine.read_bytes(0x80000000, 6) != b"GGTE01":
632665
ctx.dolphin_status = CONNECTION_REFUSED_GAME_STATUS
633666
dolphin_memory_engine.un_hook()
634667
sleep_time = 5

worlds/chibi_robo/items.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ def get_apid(code: int) -> int:
126126

127127
"Coin C": ChibiRoboItemData("Item", IC.filler, 52, 0x6b, "coin_c"),
128128
"Coin S": ChibiRoboItemData("Item", IC.filler, 82, 0x6b, "coin_s"),
129-
"Coin G": ChibiRoboItemData("Item", IC.filler, 89, 0x6b, "coin_g"),
130-
"Junk A": ChibiRoboItemData("Item", IC.filler, 93, 0x12, "item_junk_a"),
131-
"Junk B": ChibiRoboItemData("Item", IC.filler, 110, 0x12, "item_junk_b"),
132-
"Junk C": ChibiRoboItemData("Item", IC.filler, 127, 0x12, "item_junk_c"),
129+
# "Coin G": ChibiRoboItemData("Item", IC.filler, 89, 0x6b, "coin_g"),
130+
# "Junk A": ChibiRoboItemData("Item", IC.filler, 93, 0x12, "item_junk_a"),
131+
# "Junk B": ChibiRoboItemData("Item", IC.filler, 110, 0x12, "item_junk_b"),
132+
# "Junk C": ChibiRoboItemData("Item", IC.filler, 127, 0x12, "item_junk_c"),
133133
"Wastepaper": ChibiRoboItemData("Item", IC.filler, 144, 0x12, "item_kami_kuzu"),
134134
"Candy Wrapper": ChibiRoboItemData("Item", IC.filler, 166, 0x88, "item_candy_gomi"),
135135
"Candy Bag": ChibiRoboItemData("Item", IC.filler, 174, 0x89, "item_okasi_gomi_1"),
136136
"Cookie Box": ChibiRoboItemData("Item", IC.filler, 179, 0x8a, "item_okasi_gomi_2"),
137-
"Empty Can": ChibiRoboItemData("Item", IC.filler, 186, 0x6b, "item_okasi_gomi_2"),
137+
# "Empty Can": ChibiRoboItemData("Item", IC.filler, 186, 0x6b, "item_okasi_gomi_2"),
138138

139139
}
140140

0 commit comments

Comments
 (0)