Skip to content

Commit

Permalink
Remove weapons from available before making group/split goals.
Browse files Browse the repository at this point in the history
Fix GUN enemysanity count for LI.
Require story region for Warp item.
Alter story command to, if given no arguments, print available stages.
Fix error handling for boss processing.
Resolve issues with progression decreasing after death or when 0.
Fix issue with vanilla boss data not being deepcopied.
Add more weapon groups.
  • Loading branch information
choatix committed Jan 8, 2025
1 parent 779ade6 commit acdf85e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 30 deletions.
8 changes: 4 additions & 4 deletions worlds/shadow_the_hedgehog/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,14 @@ def PopulateItemPool(world : World, first_regions):

weapon_items.extend(special_weapon_extras)
shadow_rifle = GetShadowRifle()
available_weapons = [ w for w in weapon_items if w.name in world.available_weapons ]

if not world.options.rifle_components:
special_weapon_extras.append(shadow_rifle)
weapon_items.append(shadow_rifle)
available_weapons.append(shadow_rifle)
else:
special_weapon_extras.extend(rifle_components)
weapon_items.extend(rifle_components)

available_weapons = [ w for w in weapon_items if w.name in world.available_weapons ]
available_weapons.extend(rifle_components)

HandleAllWeaponsGroups(world.options, available_weapons, weapon_group_items)

Expand Down
2 changes: 1 addition & 1 deletion worlds/shadow_the_hedgehog/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ class CharacterLocation:
EnemySanityLocation(STAGE_SPACE_GADGET, ENEMY_CLASS_GUN, 25, "GUN Soldier"),
EnemySanityLocation(STAGE_SPACE_GADGET, ENEMY_CLASS_ALIEN, 33, "Black Arm"),

EnemySanityLocation(STAGE_LOST_IMPACT, ENEMY_CLASS_GUN, 31, "GUN Soldier"),
EnemySanityLocation(STAGE_LOST_IMPACT, ENEMY_CLASS_GUN, 37, "GUN Soldier"),
EnemySanityLocation(STAGE_LOST_IMPACT, ENEMY_CLASS_ALIEN, 35, "Artificial Chaos"),

EnemySanityLocation(STAGE_GUN_FORTRESS, ENEMY_CLASS_GUN, 94, "GUN Soldier"),
Expand Down
3 changes: 3 additions & 0 deletions worlds/shadow_the_hedgehog/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ def lock_warp_items(multiworld, world, player):
if warp.stageId not in world.available_levels:
continue

warp_story_region = Regions.stage_id_to_story_region(warp.stageId)
location = multiworld.get_location(warp.name, player)
i = [ w for w in warpItemInfos if w.stageId == warp.stageId][0]
mw_token_item = ShadowTheHedgehogItem(i, player)
location.access_rule = lambda state, r=location.access_rule: r(state) and state.can_reach_region(
warp_story_region, player)
location.place_locked_item(
mw_token_item)

Expand Down
61 changes: 40 additions & 21 deletions worlds/shadow_the_hedgehog/ShTHClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ def _cmd_story(self, *args):
arguments = self.parse_args(args)
if 's' in arguments:
stage = arguments['s']
self.ctx.set_story_mode(stage)
self.ctx.set_story_mode(stage)
else:
available = self.ctx.get_story_accessible_stages()
logger.info(available)

def _cmd_token(self, *args):
if isinstance(self.ctx, ShTHContext):
Expand Down Expand Up @@ -713,7 +716,7 @@ def __init__(self, server_address, password):
self.previous_rings = None
self.ring_link_rings = 0
self.instance_id = time.time()
self.debug_logging = False
self.debug_logging = True
self.error_logging = True
self.info_logging = True
self.last_level = None
Expand Down Expand Up @@ -1056,9 +1059,16 @@ def find_boss(self, stage):
if not known_route:
logger.info("Route currently unknown.")

def get_story_accessible_stages(self):
if not self.auth:
return False

results = []
for stageId in Levels.ALL_STAGES:
if is_level_accessible(self, stageId, story=True):
results.append(Levels.LEVEL_ID_TO_LEVEL[stageId])


return results

def set_story_mode(self, stage):
if not self.auth:
Expand All @@ -1068,7 +1078,7 @@ def set_story_mode(self, stage):
return None

if not is_level_accessible(self, stageId, story=True):
logger.error("Level is not accessible", stage)
logger.error("Level is not accessible: %s", stage)

story_block = Levels.STAGE_TO_STORY_BLOCK[stageId]

Expand Down Expand Up @@ -1487,15 +1497,16 @@ def complete_completable_levels(ctx):
to_end_boss = [ s for s in story if s.start_stage_id == mission.stageId and s.alignment_id == mission.alignmentId]
if len(to_end_boss) == 1:
boss_path = to_end_boss[0]
r_boss_l = [b for b in Locations.BossClearLocations if b.stageId == boss_path.boss]
if len(r_boss_l) == 1:
r_boss = r_boss_l[0]
boss_location_id, boss_location_name = Locations.GetBossLocationName(r_boss.name, r_boss.stageId)
u_bosses = [b for b in uncleared_bosses if b == boss_location_id]
if len(u_bosses) != 0:
continue
else:
print("Unable to find boss clear location for", boss_path)
if boss_path.boss is not None:
r_boss_l = [b for b in Locations.BossClearLocations if b.stageId == boss_path.boss]
if len(r_boss_l) == 1:
r_boss = r_boss_l[0]
boss_location_id, boss_location_name = Locations.GetBossLocationName(r_boss.name, r_boss.stageId)
u_bosses = [b for b in uncleared_bosses if b == boss_location_id]
if len(u_bosses) != 0:
continue
else:
print("Unable to find boss clear location for", boss_path)

mission_complete_locations = [ l for l in location_dict.values() if l.stageId == mission.stageId and
l.location_type == Locations.LOCATION_TYPE_MISSION_CLEAR
Expand Down Expand Up @@ -1789,6 +1800,7 @@ async def check_level_status(ctx):
current_screen_bytes = dolphin_memory_engine.read_bytes(GAME_ADDRESSES.MENU_ENUM, 4)
current_screen = int.from_bytes(current_screen_bytes, byteorder='big')

logger.debug("Detected screen %d", current_screen)
if current_screen != MenuOptions.NotInMenu:
extra_messages = CheckAutoWarps(ctx)
new_messages.extend(extra_messages)
Expand Down Expand Up @@ -2739,8 +2751,9 @@ async def update_level_behaviour(ctx, current_level, death):
current_count = int.from_bytes(current_bytes, byteorder='big')

if current_count is not None and expected_hero_value is not None and current_count < expected_hero_value:
ctx.level_state["hero_progress"] = current_count
expected_hero_value = current_count
if not death and ctx.level_state["hero_progress"] != 0:
logger.info("Detected decrease in hero count")
ctx.level_state["hero_progress"] -= 1

if expected_hero_value is not None and current_count > expected_hero_value:
if ctx.debug_logging:
Expand Down Expand Up @@ -2781,8 +2794,9 @@ async def update_level_behaviour(ctx, current_level, death):
current_count = int.from_bytes(current_bytes, byteorder='big')

if current_count is not None and expected_dark_value is not None and current_count < expected_dark_value:
ctx.level_state["dark_progress"] = current_count
expected_dark_value = current_count
if not death and ctx.level_state["dark_progress"] != 0:
logger.info("Detected decrease in dark count")
ctx.level_state["dark_progress"] -= 1

if expected_dark_value is not None and current_count > expected_dark_value:
if ctx.debug_logging:
Expand Down Expand Up @@ -2825,8 +2839,9 @@ async def update_level_behaviour(ctx, current_level, death):
current_bytes = dolphin_memory_engine.read_bytes(GAME_ADDRESSES.ADDRESS_ALIEN_COUNT, alien_address_size)
current_count = int.from_bytes(current_bytes, byteorder='big')

if current_count is not None and alien_count is not None and current_count < alien_count:
ctx.level_state["alien_progress"] = current_count
if not death and ctx.level_state["alien_progress"] != 0:
logger.info("Detected decrease in alien count")
ctx.level_state["alien_progress"] -= 1

if current_count > alien_count:
if current_count > alienInfo.total_count + extra_increase:
Expand All @@ -2842,7 +2857,9 @@ async def update_level_behaviour(ctx, current_level, death):
current_count = int.from_bytes(current_bytes, byteorder='big')

if current_count is not None and gun_count is not None and current_count < gun_count:
ctx.level_state["gun_progress"] = current_count
if not death and ctx.level_state["gun_progress"] != 0:
logger.info("Detected decrease in gun count")
ctx.level_state["gun_progress"] -= 1

if current_count > gun_count:
#print("gun count increased --", current_count, gun_count)
Expand All @@ -2859,7 +2876,9 @@ async def update_level_behaviour(ctx, current_level, death):
current_count = int.from_bytes(current_bytes, byteorder='big')

if current_count is not None and egg_count is not None and current_count < egg_count:
ctx.level_state["egg_progress"] = current_count
if not death and ctx.level_state["egg_progress"] != 0:
logger.info("Detected decrease in egg count")
ctx.level_state["egg_progress"] -= 1

if current_count > egg_count:
#print("egg count increased --", current_count, egg_count)
Expand Down
8 changes: 5 additions & 3 deletions worlds/shadow_the_hedgehog/Story.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import random
from dataclasses import dataclass

Expand Down Expand Up @@ -64,7 +65,8 @@ def StoryToOrder(StoryMode):


def ChaosShuffle(world):
ModifiedStoryMode = DefaultStoryMode.copy()

ModifiedStoryMode = copy.deepcopy(DefaultStoryMode)

include_last_way = world.options.include_last_way_shuffle

Expand Down Expand Up @@ -231,7 +233,7 @@ def ChaosShuffle(world):


def ShuffleStoryMode(world):
ModifiedStoryMode = DefaultStoryMode.copy()
ModifiedStoryMode = copy.deepcopy(DefaultStoryMode)
story_stages = []
for step in ModifiedStoryMode:
if step.end_stage_id is not None and step.end_stage_id not in story_stages and \
Expand All @@ -254,7 +256,7 @@ def ShuffleStoryMode(world):


def GenerateStoryMode(world):
ModifiedStoryMode = DefaultStoryMode.copy()
ModifiedStoryMode = copy.deepcopy(DefaultStoryMode)
ModifiedStoryMode[0].end_stage_id = world.random.choice(
[s for s in Levels.ALL_STAGES if s not in Levels.BOSS_STAGES and s not in Levels.LAST_STORY_STAGES
and s not in Levels.FINAL_STAGES and Levels.LEVEL_ID_TO_LEVEL[s] not in world.options.excluded_stages])
Expand Down
11 changes: 10 additions & 1 deletion worlds/shadow_the_hedgehog/Weapons.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,16 @@ def GetWeaponByName(name):
"Gun Mech Weapons": [WEAPONS.SEMI_AUTOMATIC_RIFLE, WEAPONS.LASER_RIFLE, WEAPONS.HEAVY_MACHINE_GUN,
WEAPONS.SUB_MACHINE_GUN, WEAPONS.GATLING_GUN],

"Laser Weapons": [WEAPONS.REFRACTOR, WEAPONS.LASER_RIFLE, WEAPONS.SPLITTER, WEAPONS.RING_SHOT]
"Laser Weapons": [WEAPONS.REFRACTOR, WEAPONS.LASER_RIFLE, WEAPONS.SPLITTER, WEAPONS.RING_SHOT],

"Standard Melee Weapons": [WEAPONS.SURVIVAL_KNIFE, WEAPONS.BLACK_SWORD, WEAPONS.DARK_HAMMER],

"All Melee Weapons": [WEAPONS.SPEED_LIMIT_SIGN, WEAPONS.DIGITAL_POLE, WEAPONS.CANYON_POLE, WEAPONS.LETHAL_POLE,
WEAPONS.PRISON_BRANCH, WEAPONS.CIRCUS_POLE, WEAPONS.STOP_SIGN, WEAPONS.DOOM_POLE,
WEAPONS.SKY_POLE, WEAPONS.MATRIX_POLE, WEAPONS.RUINS_BRANCH, WEAPONS.FLEET_POLE,
WEAPONS.IRON_POLE, WEAPONS.GADGET_POLE, WEAPONS.IMPACT_POLE, WEAPONS.FORTRESS_POLE,
WEAPONS.LAVA_SHOVEL, WEAPONS.COSMIC_POLE, WEAPONS.HAUNT_POLE, WEAPONS.LAST_POLE, WEAPONS.CRYPTIC_TORCH,
WEAPONS.SURVIVAL_KNIFE, WEAPONS.BLACK_SWORD, WEAPONS.DARK_HAMMER]



Expand Down

0 comments on commit acdf85e

Please sign in to comment.