KH2: Location Groups and Subclasses (#2700)

This commit is contained in:
JaredWeakStrike 2024-01-16 07:12:33 -05:00 committed by GitHub
parent c6896c6af9
commit 0efc13fc8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 118 additions and 103 deletions

View File

@ -821,7 +821,8 @@ class KH2Context(CommonContext):
def finishedGame(ctx: KH2Context, message):
if ctx.kh2slotdata['FinalXemnas'] == 1:
if not ctx.final_xemnas and ctx.kh2_loc_name_to_id[LocationName.FinalXemnas] in ctx.locations_checked:
if not ctx.final_xemnas and ctx.kh2_read_byte(ctx.Save + all_world_locations[LocationName.FinalXemnas].addrObtained) \
& 0x1 << all_world_locations[LocationName.FinalXemnas].bitIndex > 0:
ctx.final_xemnas = True
# three proofs
if ctx.kh2slotdata['Goal'] == 0:

View File

@ -2,22 +2,7 @@ import typing
from BaseClasses import Item
from .Names import ItemName
class KH2Item(Item):
game: str = "Kingdom Hearts 2"
class ItemData(typing.NamedTuple):
quantity: int = 0
kh2id: int = 0
# Save+ mem addr
memaddr: int = 0
# some items have bitmasks. if bitmask>0 bitor to give item else
bitmask: int = 0
# if ability then
ability: bool = False
from .Subclasses import ItemData
# 0x130000
Reports_Table = {
@ -349,7 +334,7 @@ GoofyAbility_Table = {
Wincon_Table = {
ItemName.LuckyEmblem: ItemData(kh2id=367, memaddr=0x3641), # letter item
ItemName.Victory: ItemData(kh2id=263, memaddr=0x111),
# ItemName.Victory: ItemData(kh2id=263, memaddr=0x111),
ItemName.Bounty: ItemData(kh2id=461, memaddr=0x365E), # Dummy 14
# ItemName.UniversalKey:ItemData(,365,0x363F,0)#Tournament Poster
}

View File

@ -1,19 +1,9 @@
import typing
from BaseClasses import Location
from .Names import LocationName, ItemName
class KH2Location(Location):
game: str = "Kingdom Hearts 2"
class LocationData(typing.NamedTuple):
locid: int
yml: str
charName: str = "Sora"
charNumber: int = 1
from .Names import LocationName, ItemName, RegionName
from .Subclasses import LocationData
from .Regions import KH2REGIONS
# data's addrcheck sys3 addr obtained roomid bit index is eventid
LoD_Checks = {
@ -541,7 +531,7 @@ TWTNW_Checks = {
LocationName.Xemnas1: LocationData(26, "Double Get Bonus"),
LocationName.Xemnas1GetBonus: LocationData(26, "Second Get Bonus"),
LocationName.Xemnas1SecretAnsemReport13: LocationData(537, "Chest"),
LocationName.FinalXemnas: LocationData(71, "Get Bonus"),
# LocationName.FinalXemnas: LocationData(71, "Get Bonus"),
LocationName.XemnasDataPowerBoost: LocationData(554, "Chest"),
}
@ -874,6 +864,7 @@ event_location_to_item = {
LocationName.Axel1EventLocation: ItemName.Axel1Event,
LocationName.Axel2EventLocation: ItemName.Axel2Event,
LocationName.DataRoxasEventLocation: ItemName.DataRoxasEvent,
LocationName.FinalXemnasEventLocation: ItemName.Victory,
}
all_weapon_slot = {
LocationName.FAKESlot,
@ -1361,3 +1352,9 @@ exclusion_table = {
location for location, data in all_locations.items() if location not in event_location_to_item.keys() and location not in popups_set and location != LocationName.StationofSerenityPotion and data.yml == "Chest"
}
}
location_groups: typing.Dict[str, list]
location_groups = {
Region_Name: [loc for loc in Region_Locs if "Event" not in loc]
for Region_Name, Region_Locs in KH2REGIONS.items() if Region_Locs
}

View File

@ -1,9 +1,11 @@
import typing
from BaseClasses import MultiWorld, Region
from . import Locations
from .Locations import KH2Location, event_location_to_item
from . import LocationName, RegionName, Events_Table
from .Subclasses import KH2Location
from .Names import LocationName, RegionName
from .Items import Events_Table
KH2REGIONS: typing.Dict[str, typing.List[str]] = {
"Menu": [],
@ -788,7 +790,7 @@ KH2REGIONS: typing.Dict[str, typing.List[str]] = {
LocationName.ArmoredXemnas2EventLocation
],
RegionName.FinalXemnas: [
LocationName.FinalXemnas
LocationName.FinalXemnasEventLocation
],
RegionName.DataXemnas: [
LocationName.XemnasDataPowerBoost,
@ -1020,7 +1022,8 @@ def create_regions(self):
multiworld.regions += [create_region(multiworld, player, active_locations, region, locations) for region, locations in
KH2REGIONS.items()]
# fill the event locations with events
for location, item in event_location_to_item.items():
for location, item in Locations.event_location_to_item.items():
multiworld.get_location(location, player).place_locked_item(
multiworld.worlds[player].create_event_item(item))

View File

@ -270,7 +270,7 @@ class KH2WorldRules(KH2Rules):
add_item_rule(location, lambda item: item.player == self.player and item.name in SupportAbility_Table.keys())
def set_kh2_goal(self):
final_xemnas_location = self.multiworld.get_location(LocationName.FinalXemnas, self.player)
final_xemnas_location = self.multiworld.get_location(LocationName.FinalXemnasEventLocation, self.player)
if self.multiworld.Goal[self.player] == "three_proofs":
final_xemnas_location.access_rule = lambda state: self.kh2_has_all(three_proofs, state)
if self.multiworld.FinalXemnas[self.player]:

29
worlds/kh2/Subclasses.py Normal file
View File

@ -0,0 +1,29 @@
import typing
from BaseClasses import Location, Item
class KH2Location(Location):
game: str = "Kingdom Hearts 2"
class LocationData(typing.NamedTuple):
locid: int
yml: str
charName: str = "Sora"
charNumber: int = 1
class KH2Item(Item):
game: str = "Kingdom Hearts 2"
class ItemData(typing.NamedTuple):
quantity: int = 0
kh2id: int = 0
# Save+ mem addr
memaddr: int = 0
# some items have bitmasks. if bitmask>0 bitor to give item else
bitmask: int = 0
# if ability then
ability: bool = False

View File

@ -12,6 +12,7 @@ from .OpenKH import patch_kh2
from .Options import KingdomHearts2Options
from .Regions import create_regions, connect_regions
from .Rules import *
from .Subclasses import KH2Item
def launch_client():
@ -49,7 +50,9 @@ class KH2World(World):
for item_id, item in enumerate(item_dictionary_table.keys(), 0x130000)}
location_name_to_id = {item: location
for location, item in enumerate(all_locations.keys(), 0x130000)}
item_name_groups = item_groups
location_name_groups = location_groups
visitlocking_dict: Dict[str, int]
plando_locations: Dict[str, str]
@ -253,11 +256,8 @@ class KH2World(World):
self.goofy_gen_early()
self.keyblade_gen_early()
if self.multiworld.FinalXemnas[self.player]:
self.plando_locations[LocationName.FinalXemnas] = ItemName.Victory
else:
self.plando_locations[LocationName.FinalXemnas] = self.create_filler().name
self.total_locations -= 1
# final xemnas isn't a location anymore
# self.total_locations -= 1
if self.options.WeaponSlotStartHint:
for location in all_weapon_slot: