Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LADX: Improve icon guesses for foreign items #2201

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
145e052
synonyms to new file, many added
threeandthreee Sep 20, 2023
9d7d222
handle singular rupee
threeandthreee Sep 21, 2023
a107459
remove redundant map and compass entries
threeandthreee Sep 21, 2023
092bf95
automatic pluralization
threeandthreee Sep 21, 2023
dca3868
add guardian acorn and piece of power
threeandthreee Sep 23, 2023
fb23dc5
move phrases to ItemIconGuessing.py
threeandthreee Sep 23, 2023
41b7e3d
organize, comment
threeandthreee Sep 23, 2023
a1e208d
fix tab spacing
threeandthreee Sep 23, 2023
6807ef0
fix
threeandthreee Sep 23, 2023
a60a179
Merge branch 'main' into ladx/improve-foreign-item-icon-guessing
threeandthreee Mar 26, 2024
a1ba9c4
add tunic and noita synonyms
threeandthreee Aug 30, 2024
5a9ef2b
Merge branch 'main' into ladx/improve-foreign-item-icon-guessing
threeandthreee Aug 30, 2024
0dc02c7
remove triangle instrument synonym
threeandthreee Aug 30, 2024
dcb5a23
reorganize, add some matches
threeandthreee Aug 31, 2024
7c38e8c
add tunic lucky up
threeandthreee Aug 31, 2024
3865507
Update worlds/ladx/ItemIconGuessing.py
threeandthreee Sep 1, 2024
41b256d
handle camelCase and single rupee
threeandthreee Sep 2, 2024
66f6003
Merge branch 'main' into ladx/improve-foreign-item-icon-guessing
threeandthreee Sep 2, 2024
59a5f3f
add indicate_progression option
threeandthreee Sep 10, 2024
b9d0be2
improve splitting
threeandthreee Sep 20, 2024
b708a45
the witness stuff
threeandthreee Sep 20, 2024
5ecf739
forbid more
threeandthreee Sep 20, 2024
e2f5682
remove boost and surge
threeandthreee Sep 20, 2024
e0d2f84
Update worlds/ladx/ItemIconGuessing.py
threeandthreee Sep 20, 2024
f948ed8
match by game name
threeandthreee Sep 30, 2024
6094d8a
Merge remote-tracking branch 'upstream/main' into ladx/improve-foreig…
threeandthreee Sep 30, 2024
699f305
show message for all key drops
threeandthreee Oct 28, 2024
4bd038b
Merge branch 'ladx/show-message-for-all-key-drops' into ladx/improve-…
threeandthreee Nov 5, 2024
82ce9e9
Merge remote-tracking branch 'upstream/main' into ladx/improve-foreig…
threeandthreee Nov 5, 2024
769d206
updates from async test
threeandthreee Nov 6, 2024
ee106ce
Merge branch 'main' into ladx/improve-foreign-item-icon-guessing
NewSoupVi Nov 29, 2024
075faf0
vi suggestions
threeandthreee Dec 2, 2024
2b5dead
Adding FNAFW suggestions from @lolz1190 (#40)
palex00 Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
464 changes: 464 additions & 0 deletions worlds/ladx/ItemIconGuessing.py

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion worlds/ladx/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class ItemName:
HEART_CONTAINER = "Heart Container"
BAD_HEART_CONTAINER = "Bad Heart Container"
TOADSTOOL = "Toadstool"
GUARDIAN_ACORN = "Guardian Acorn"
KEY = "Key"
KEY1 = "Small Key (Tail Cave)"
KEY2 = "Small Key (Bottle Grotto)"
Expand Down Expand Up @@ -174,6 +175,7 @@ class ItemName:
TRADING_ITEM_NECKLACE = "Necklace"
TRADING_ITEM_SCALE = "Scale"
TRADING_ITEM_MAGNIFYING_GLASS = "Magnifying Glass"
PIECE_OF_POWER = "Piece Of Power"

trade_item_prog = ItemClassification.progression

Expand Down Expand Up @@ -221,6 +223,7 @@ class ItemName:
ItemData(ItemName.HEART_CONTAINER, "HEART_CONTAINER", ItemClassification.useful),
#ItemData(ItemName.BAD_HEART_CONTAINER, "BAD_HEART_CONTAINER", ItemClassification.trap),
ItemData(ItemName.TOADSTOOL, "TOADSTOOL", ItemClassification.progression),
ItemData(ItemName.GUARDIAN_ACORN, "GUARDIAN_ACORN", ItemClassification.filler),
DungeonItemData(ItemName.KEY, "KEY", ItemClassification.progression),
DungeonItemData(ItemName.KEY1, "KEY1", ItemClassification.progression),
DungeonItemData(ItemName.KEY2, "KEY2", ItemClassification.progression),
Expand Down Expand Up @@ -295,7 +298,8 @@ class ItemName:
TradeItemData(ItemName.TRADING_ITEM_FISHING_HOOK, "TRADING_ITEM_FISHING_HOOK", trade_item_prog, "Grandma (Animal Village)"),
TradeItemData(ItemName.TRADING_ITEM_NECKLACE, "TRADING_ITEM_NECKLACE", trade_item_prog, "Fisher (Martha's Bay)"),
TradeItemData(ItemName.TRADING_ITEM_SCALE, "TRADING_ITEM_SCALE", trade_item_prog, "Mermaid (Martha's Bay)"),
TradeItemData(ItemName.TRADING_ITEM_MAGNIFYING_GLASS, "TRADING_ITEM_MAGNIFYING_GLASS", trade_item_prog, "Mermaid Statue (Martha's Bay)")
TradeItemData(ItemName.TRADING_ITEM_MAGNIFYING_GLASS, "TRADING_ITEM_MAGNIFYING_GLASS", trade_item_prog, "Mermaid Statue (Martha's Bay)"),
ItemData(ItemName.PIECE_OF_POWER, "PIECE_OF_POWER", ItemClassification.filler),
]

ladxr_item_to_la_item_name = {
Expand Down
4 changes: 4 additions & 0 deletions worlds/ladx/LADXR/locations/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@

TOADSTOOL: 0x50,

GUARDIAN_ACORN: 0x51,

HEART_PIECE: 0x80,
BOWWOW: 0x81,
ARROWS_10: 0x82,
Expand Down Expand Up @@ -128,4 +130,6 @@
TRADING_ITEM_NECKLACE: 0xA2,
TRADING_ITEM_SCALE: 0xA3,
TRADING_ITEM_MAGNIFYING_GLASS: 0xA4,

PIECE_OF_POWER: 0xA5,
}
4 changes: 4 additions & 0 deletions worlds/ladx/LADXR/locations/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

TOADSTOOL = "TOADSTOOL"

GUARDIAN_ACORN = "GUARDIAN_ACORN"

KEY = "KEY"
KEY1 = "KEY1"
KEY2 = "KEY2"
Expand Down Expand Up @@ -125,3 +127,5 @@
TRADING_ITEM_NECKLACE = "TRADING_ITEM_NECKLACE"
TRADING_ITEM_SCALE = "TRADING_ITEM_SCALE"
TRADING_ITEM_MAGNIFYING_GLASS = "TRADING_ITEM_MAGNIFYING_GLASS"

PIECE_OF_POWER = "PIECE_OF_POWER"
4 changes: 3 additions & 1 deletion worlds/ladx/LADXR/patches/bank3e.asm/chest.asm
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ ItemSpriteTable:
db $46, $1C ; NIGHTMARE_KEY8
db $46, $1C ; NIGHTMARE_KEY9
db $4C, $1C ; Toadstool
db $AE, $14 ; Guardian Acorn

LargeItemSpriteTable:
db $AC, $02, $AC, $22 ; heart piece
Expand Down Expand Up @@ -874,6 +875,7 @@ LargeItemSpriteTable:
db $D8, $0D, $DA, $0D ; TradeItem12
db $DC, $0D, $DE, $0D ; TradeItem13
db $E0, $0D, $E2, $0D ; TradeItem14
db $14, $42, $14, $62 ; Piece Of Power

ItemMessageTable:
db $90, $3D, $89, $93, $94, $95, $96, $97, $98, $99, $9A, $9B, $9C, $9D, $D9, $A2
Expand All @@ -888,7 +890,7 @@ ItemMessageTable:
; $80
db $4F, $C8, $CA, $CB, $E2, $E3, $E4, $CC, $CD, $2A, $2B, $C9, $C9, $C9, $C9, $C9
db $C9, $C9, $C9, $C9, $C9, $C9, $B8, $44, $C9, $C9, $C9, $C9, $C9, $C9, $C9, $C9
db $C9, $C9, $C9, $C9, $9D
db $C9, $C9, $C9, $C9, $9D, $C9

RenderDroppedKey:
;TODO: See EntityInitKeyDropPoint for a few special cases to unload.
Expand Down
8 changes: 7 additions & 1 deletion worlds/ladx/LADXR/patches/bank3e.asm/itemnames.asm
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ ItemNamePointers:
dw ItemNameNightmareKey8
dw ItemNameNightmareKey9
dw ItemNameToadstool
dw ItemNameNone ; 0x51
dw ItemNameGuardianAcorn
dw ItemNameNone ; 0x52
dw ItemNameNone ; 0x53
dw ItemNameNone ; 0x54
Expand Down Expand Up @@ -254,6 +254,7 @@ ItemNamePointers:
dw ItemTradeQuest12
dw ItemTradeQuest13
dw ItemTradeQuest14
dw ItemPieceOfPower

ItemNameNone:
db m"NONE", $ff
Expand Down Expand Up @@ -418,6 +419,8 @@ ItemNameNightmareKey9:
db m"Got the {NIGHTMARE_KEY9}", $ff
ItemNameToadstool:
db m"Got the {TOADSTOOL}", $ff
ItemNameGuardianAcorn:
db m"Got a Guardian Acorn", $ff

ItemNameHeartPiece:
db m"Got the {HEART_PIECE}", $ff
Expand Down Expand Up @@ -496,5 +499,8 @@ ItemTradeQuest13:
db m"You've got the Scale", $ff
ItemTradeQuest14:
db m"You've got the Magnifying Lens", $ff

ItemPieceOfPower:
db m"You've got a Piece of Power", $ff

MultiNamePointers:
14 changes: 14 additions & 0 deletions worlds/ladx/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,18 @@ class AdditionalWarpPoints(DefaultOffToggle):
"""
display_name = "Additional Warp Points"


class ForeignItemIcons(Choice):
"""
Choose how to display foreign items.
[Guess By Name] Foreign items can look like any Link's Awakening item.
[Indicate Progression] Foreign items are either a Piece of Power (progression) or Guardian Acorn (non-progression).
"""
display_name = "Foreign Item Icons"
option_guess_by_name = 0
option_indicate_progression = 1
threeandthreee marked this conversation as resolved.
Show resolved Hide resolved


ladx_option_groups = [
OptionGroup("Goal Options", [
Goal,
Expand Down Expand Up @@ -533,6 +545,7 @@ class AdditionalWarpPoints(DefaultOffToggle):
LinkPalette,
Palette,
TextShuffle,
ForeignItemIcons,
APTitleScreen,
GfxMod,
Music,
Expand Down Expand Up @@ -568,6 +581,7 @@ class LinksAwakeningOptions(PerGameCommonOptions):
gfxmod: GfxMod
palette: Palette
text_shuffle: TextShuffle
foreign_item_icons: ForeignItemIcons
shuffle_nightmare_keys: ShuffleNightmareKeys
shuffle_small_keys: ShuffleSmallKeys
shuffle_maps: ShuffleMaps
Expand Down
89 changes: 36 additions & 53 deletions worlds/ladx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pkgutil
import tempfile
import typing
import re

import bsdiff4

Expand All @@ -12,6 +13,7 @@
from Fill import fill_restrictive
from worlds.AutoWorld import WebWorld, World
from .Common import *
from . import ItemIconGuessing
from .Items import (DungeonItemData, DungeonItemType, ItemName, LinksAwakeningItem, TradeItemData,
ladxr_item_to_la_item_name, links_awakening_items, links_awakening_items_by_name)
from .LADXR import generator
Expand Down Expand Up @@ -372,66 +374,40 @@ def priority(item):

name_cache = {}
# Tries to associate an icon from another game with an icon we have
def guess_icon_for_other_world(self, other):
def guess_icon_for_other_world(self, foreign_item):
if not self.name_cache:
forbidden = [
"TRADING",
"ITEM",
"BAD",
"SINGLE",
"UPGRADE",
"BLUE",
"RED",
"NOTHING",
"MESSAGE",
]
for item in ladxr_item_to_la_item_name.keys():
self.name_cache[item] = item
splits = item.split("_")
self.name_cache["".join(splits)] = item
if 'RUPEES' in splits:
self.name_cache["".join(reversed(splits))] = item

for word in item.split("_"):
if word not in forbidden and not word.isnumeric():
if word not in ItemIconGuessing.BLOCKED_ASSOCIATIONS and not word.isnumeric():
self.name_cache[word] = item
others = {
'KEY': 'KEY',
'COMPASS': 'COMPASS',
'BIGKEY': 'NIGHTMARE_KEY',
'MAP': 'MAP',
'FLUTE': 'OCARINA',
'SONG': 'OCARINA',
'MUSHROOM': 'TOADSTOOL',
'GLOVE': 'POWER_BRACELET',
'BOOT': 'PEGASUS_BOOTS',
'SHOE': 'PEGASUS_BOOTS',
'SHOES': 'PEGASUS_BOOTS',
'SANCTUARYHEARTCONTAINER': 'HEART_CONTAINER',
'BOSSHEARTCONTAINER': 'HEART_CONTAINER',
'HEARTCONTAINER': 'HEART_CONTAINER',
'ENERGYTANK': 'HEART_CONTAINER',
'MISSILE': 'SINGLE_ARROW',
'BOMBS': 'BOMB',
'BLUEBOOMERANG': 'BOOMERANG',
'MAGICMIRROR': 'TRADING_ITEM_MAGNIFYING_GLASS',
'MIRROR': 'TRADING_ITEM_MAGNIFYING_GLASS',
'MESSAGE': 'TRADING_ITEM_LETTER',
# TODO: Also use AP item name
}
for name in others.values():
for name in ItemIconGuessing.SYNONYMS.values():
assert name in self.name_cache, name
assert name in CHEST_ITEMS, name
self.name_cache.update(others)


uppered = other.upper()
if "BIG KEY" in uppered:
return 'NIGHTMARE_KEY'
possibles = other.upper().split(" ")
rejoined = "".join(possibles)
if rejoined in self.name_cache:
return self.name_cache[rejoined]
self.name_cache.update(ItemIconGuessing.SYNONYMS)
pluralizations = {}
for k in self.name_cache.keys():
ks = k + 'S'
if ks not in self.name_cache:
pluralizations[ks] = self.name_cache[k]
self.name_cache.update(pluralizations)
threeandthreee marked this conversation as resolved.
Show resolved Hide resolved

uppered = foreign_item.name.upper()
foreign_game = self.multiworld.game[foreign_item.player]
phrases = ItemIconGuessing.PHRASES.copy()
if foreign_game in ItemIconGuessing.GAME_SPECIFIC_PHRASES:
phrases.update(ItemIconGuessing.GAME_SPECIFIC_PHRASES[foreign_game])

for phrase in phrases.keys():
if phrase in uppered:
return phrases[phrase]
threeandthreee marked this conversation as resolved.
Show resolved Hide resolved
# pattern for breaking down camelCase, also separates out digits
pattern = re.compile(r"(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-zA-Z])(?=\d)")
possibles = pattern.sub(' ', foreign_item.name).upper()
for ch in "[]()_":
possibles = possibles.replace(ch, " ")
possibles = possibles.split()
for name in possibles:
if name in self.name_cache:
return self.name_cache[name]
Expand All @@ -457,8 +433,15 @@ def generate_output(self, output_directory: str):

# If the item name contains "sword", use a sword icon, etc
# Otherwise, use a cute letter as the icon
elif self.options.foreign_item_icons == 'guess_by_name':
loc.ladxr_item.item = self.guess_icon_for_other_world(loc.item)
loc.ladxr_item.custom_item_name = loc.item.name

else:
loc.ladxr_item.item = self.guess_icon_for_other_world(loc.item.name)
if loc.item.advancement:
loc.ladxr_item.item = 'PIECE_OF_POWER'
else:
loc.ladxr_item.item = 'GUARDIAN_ACORN'
loc.ladxr_item.custom_item_name = loc.item.name

if loc.item:
Expand Down
Loading