TUNIC: Expanded hexagon quest options (#4076)

* More hex quest updates

- Implement page ability shuffle for hex quest
- Fix keys behind bosses if hex goal is less than 3
- Added check to fix conflicting hex quest options
- Add option to slot data

* Change option comparison

* Change option checking and fix some stuff

- also keep prayer first on low hex counts

* Update option defaulting

* Update option checking

* Fix option assignment again

* Show player name in option warning

* Add new option to universal tracker stuff

* Update __init__.py

* Make helper method for getting total hexagons in itempool

* Update options.py

* Update option value passthrough

* Change ability shuffle to default on

* Check for hexagons option when writing spoiler
This commit is contained in:
Silent
2025-03-07 19:43:02 -05:00
committed by GitHub
parent 2f0b81e12c
commit bc61221ec6
3 changed files with 103 additions and 25 deletions

View File

@@ -1,8 +1,14 @@
import logging
from dataclasses import dataclass
from typing import Dict, Any
from typing import Dict, Any, TYPE_CHECKING
from decimal import Decimal, ROUND_HALF_UP
from Options import (DefaultOnToggle, Toggle, StartInventoryPool, Choice, Range, TextChoice, PlandoConnections,
PerGameCommonOptions, OptionGroup, Visibility, NamedRange)
from .er_data import portal_mapping
if TYPE_CHECKING:
from . import TunicWorld
class SwordProgression(DefaultOnToggle):
@@ -24,6 +30,7 @@ class StartWithSword(Toggle):
class KeysBehindBosses(Toggle):
"""
Places the three hexagon keys behind their respective boss fight in your world.
If playing Hexagon Quest, it will place three gold hexagons at the boss locations.
"""
internal_name = "keys_behind_bosses"
display_name = "Keys Behind Bosses"
@@ -32,7 +39,8 @@ class KeysBehindBosses(Toggle):
class AbilityShuffling(DefaultOnToggle):
"""
Locks the usage of Prayer, Holy Cross*, and the Icebolt combo until the relevant pages of the manual have been found.
If playing Hexagon Quest, abilities are instead randomly unlocked after obtaining 25%, 50%, and 75% of the required Hexagon goal amount.
If playing Hexagon Quest, abilities are instead randomly unlocked after obtaining 25%, 50%, and 75% of the required
Hexagon goal amount, unless the option is set to have them unlock via pages instead.
* Certain Holy Cross usages are still allowed, such as the free bomb codes, the seeking spell, and other player-facing codes.
"""
internal_name = "ability_shuffling"
@@ -84,14 +92,16 @@ class HexagonGoal(Range):
"""
internal_name = "hexagon_goal"
display_name = "Gold Hexagons Required"
range_start = 15
range_end = 50
range_start = 1
range_end = 100
default = 20
class ExtraHexagonPercentage(Range):
"""
How many extra Gold Questagons are shuffled into the item pool, taken as a percentage of the goal amount.
The max number of Gold Questagons that can be in the item pool is 100, so this option may be overridden and/or
reduced if the Hexagon Goal amount is greater than 50.
"""
internal_name = "extra_hexagon_percentage"
display_name = "Percentage of Extra Gold Hexagons"
@@ -100,11 +110,27 @@ class ExtraHexagonPercentage(Range):
default = 50
class HexagonQuestAbilityUnlockType(Choice):
"""
Determines how abilities are unlocked when playing Hexagon Quest with Shuffled Abilities enabled.
Hexagons: A new ability is randomly unlocked after obtaining 25%, 50%, and 75% of the required Hexagon goal amount. Requires at least 3 Gold Hexagons in the item pool, or 15 if Keys Behind Bosses is enabled.
Pages: Abilities are unlocked by finding specific pages in the manual.
This option does nothing if Shuffled Abilities is not enabled.
"""
internal_name = "hexagon_quest_ability_type"
display_name = "Hexagon Quest Ability Unlocks"
option_hexagons = 0
option_pages = 1
default = 0
class EntranceRando(TextChoice):
"""
Randomize the connections between scenes.
A small, very lost fox on a big adventure.
If you set this option's value to a string, it will be used as a custom seed.
Every player who uses the same custom seed will have the same entrances, choosing the most restrictive settings among these players for the purpose of pairing entrances.
"""
@@ -301,6 +327,7 @@ class TunicOptions(PerGameCommonOptions):
hexagon_quest: HexagonQuest
hexagon_goal: HexagonGoal
extra_hexagon_percentage: ExtraHexagonPercentage
hexagon_quest_ability_type: HexagonQuestAbilityUnlockType
shuffle_ladders: ShuffleLadders
grass_randomizer: GrassRandomizer
@@ -323,6 +350,12 @@ class TunicOptions(PerGameCommonOptions):
tunic_option_groups = [
OptionGroup("Hexagon Quest Options", [
HexagonQuest,
HexagonGoal,
ExtraHexagonPercentage,
HexagonQuestAbilityUnlockType
]),
OptionGroup("Logic Options", [
CombatLogic,
Lanternless,
@@ -357,3 +390,23 @@ tunic_option_presets: Dict[str, Dict[str, Any]] = {
"lanternless": True,
},
}
def check_options(world: "TunicWorld"):
options = world.options
if options.hexagon_quest and options.ability_shuffling and options.hexagon_quest_ability_type == HexagonQuestAbilityUnlockType.option_hexagons:
total_hexes = get_hexagons_in_pool(world)
min_hexes = 3
if options.keys_behind_bosses:
min_hexes = 15
if total_hexes < min_hexes:
logging.warning(f"TUNIC: Not enough Gold Hexagons in {world.player_name}'s item pool for Hexagon Ability Shuffle with the selected options. Ability Shuffle mode will be switched to Pages.")
options.hexagon_quest_ability_type.value = HexagonQuestAbilityUnlockType.option_pages
def get_hexagons_in_pool(world: "TunicWorld"):
# Calculate number of hexagons in item pool
options = world.options
return min(int((Decimal(100 + options.extra_hexagon_percentage) / 100 * options.hexagon_goal)
.to_integral_value(rounding=ROUND_HALF_UP)), 100)