From 4e7d6983087a17e07666d267d9bb405f10ad7a8c Mon Sep 17 00:00:00 2001 From: Thanatos <117127188+ThanatosGit@users.noreply.github.com> Date: Wed, 11 Oct 2023 17:40:28 +0200 Subject: [PATCH] Remove aeion tanks logic and handle them as ammo upgrade (#142) --- .../files/randomizer_powerup.lua | 28 ++---- open_samus_returns_rando/files/schema.json | 6 -- .../files/templates/custom_init.lua | 1 - open_samus_returns_rando/lua_editor.py | 3 +- .../samus_returns_patcher.py | 7 -- tests/test_files/models_surface.json | 86 +++++++++++++++---- 6 files changed, 77 insertions(+), 54 deletions(-) diff --git a/open_samus_returns_rando/files/randomizer_powerup.lua b/open_samus_returns_rando/files/randomizer_powerup.lua index 7da52c9..9b7a03b 100644 --- a/open_samus_returns_rando/files/randomizer_powerup.lua +++ b/open_samus_returns_rando/files/randomizer_powerup.lua @@ -35,6 +35,12 @@ function RandomizerPowerup.IncreaseItemAmount(item_id, quantity, capacity) end target = math.max(target, 0) RandomizerPowerup.SetItemAmount(item_id, target) + + if item_id == "ITEM_CURRENT_SPECIAL_ENERGY" then + local specialEnergy = Game.GetPlayer().SPECIALENERGY + specialEnergy.fMaxEnergy = capacity + quantity + specialEnergy.fEnergy = capacity + quantity + end end function RandomizerPowerup.OnPickedUp(resources) @@ -123,6 +129,8 @@ function RandomizerPowerup.IncreaseAmmo(resource) current_id = "ITEM_WEAPON_SUPER_MISSILE_CURRENT" elseif resource.item_id == "ITEM_WEAPON_POWER_BOMB_MAX" then current_id = "ITEM_WEAPON_POWER_BOMB_CURRENT" + elseif resource.item_id == "ITEM_MAX_SPECIAL_ENERGY" then + current_id = "ITEM_CURRENT_SPECIAL_ENERGY" end if current_id == nil then return end @@ -143,19 +151,6 @@ function RandomizerPowerup.IncreaseEnergy() life.fCurrentLife = new_max end -MAX_AEION= 2200 -function RandomizerPowerup.IncreaseAeion() - local aeion = Init.fAeionPerTank - local new_max = RandomizerPowerup.GetItemAmount("ITEM_MAX_SPECIAL_ENERGY") + aeion - new_max = math.min(new_max, MAX_AEION) - RandomizerPowerup.SetItemAmount("ITEM_MAX_SPECIAL_ENERGY", new_max) - RandomizerPowerup.SetItemAmount("ITEM_CURRENT_SPECIAL_ENERGY", new_max) - - local specialEnergy = Game.GetPlayer().SPECIALENERGY - specialEnergy.fMaxEnergy = new_max - specialEnergy.fEnergy = new_max -end - RandomizerPowerBomb = {} setmetatable(RandomizerPowerBomb, {__index = RandomizerPowerup}) function RandomizerPowerBomb.OnPickedUp(progression) @@ -247,13 +242,6 @@ function RandomizerEnergyTank.OnPickedUp(progression) RandomizerPowerup.IncreaseEnergy() end -RandomizerAeionTank = {} -setmetatable(RandomizerAeionTank, {__index = RandomizerPowerup}) -function RandomizerAeionTank.OnPickedUp(progression) - RandomizerPowerup.OnPickedUp(progression) - RandomizerPowerup.IncreaseAeion() -end - RandomizerBabyHatchling = {} setmetatable(RandomizerBabyHatchling, {__index = RandomizerPowerup}) function RandomizerBabyHatchling.OnPickedUp(progression) diff --git a/open_samus_returns_rando/files/schema.json b/open_samus_returns_rando/files/schema.json index 1e3f740..d5d4c50 100644 --- a/open_samus_returns_rando/files/schema.json +++ b/open_samus_returns_rando/files/schema.json @@ -130,11 +130,6 @@ "type": "number", "default": 100.0 }, - "aeion_per_tank": { - "description": "How much aeion collecting an Aeion Tank gives", - "type": "number", - "default": 50.0 - }, "reveal_map_on_start": { "type": "boolean", "default": false, @@ -325,7 +320,6 @@ "ITEM_SCREW_ATTACK", "ITEM_BABY_HATCHLING", "ITEM_ENERGY_TANKS", - "ITEM_AEION_TANKS", "ITEM_METROID_COUNT", "ITEM_METROID_TOTAL_COUNT", "ITEM_ADN", diff --git a/open_samus_returns_rando/files/templates/custom_init.lua b/open_samus_returns_rando/files/templates/custom_init.lua index ea1c682..5d84544 100644 --- a/open_samus_returns_rando/files/templates/custom_init.lua +++ b/open_samus_returns_rando/files/templates/custom_init.lua @@ -6,7 +6,6 @@ Init.bRevealMap = TEMPLATE("reveal_map_on_start") Init.sStartingScenario = TEMPLATE("starting_scenario") Init.sStartingActor = TEMPLATE("starting_actor") Init.fEnergyPerTank = TEMPLATE("energy_per_tank") -Init.fAeionPerTank = TEMPLATE("aeion_per_tank") Game.LogWarn(0, "Inventory:") for k, v in pairs(Init.tNewGameInventory) do diff --git a/open_samus_returns_rando/lua_editor.py b/open_samus_returns_rando/lua_editor.py index bd16ef1..d1455ed 100644 --- a/open_samus_returns_rando/lua_editor.py +++ b/open_samus_returns_rando/lua_editor.py @@ -27,7 +27,6 @@ def _read_level_lua(level_id: str) -> str: "ITEM_SPECIAL_ENERGY_ENERGY_WAVE": "RandomizerEnergyWave", "ITEM_SPECIAL_ENERGY_PHASE_DISPLACEMENT": "RandomizerPhaseDisplacement", "ITEM_ENERGY_TANKS": "RandomizerEnergyTank", - "ITEM_AEION_TANKS": "RandomizerAeionTank", } SPECIFIC_SOUNDS = { @@ -36,7 +35,7 @@ def _read_level_lua(level_id: str) -> str: "ITEM_SPECIAL_ENERGY_ENERGY_WAVE": "streams/music/special_ability2_32.wav", "ITEM_SPECIAL_ENERGY_PHASE_DISPLACEMENT": "streams/music/special_ability2_32.wav", "ITEM_ENERGY_TANKS": "streams/music/tank_jingle.wav", - "ITEM_AEION_TANKS": "streams/music/tank_jingle.wav", + "ITEM_MAX_SPECIAL_ENERGY": "streams/music/tank_jingle.wav", "ITEM_SUPER_MISSILE_TANKS": "streams/music/tank_jingle.wav", "ITEM_POWER_BOMB_TANKS": "streams/music/tank_jingle.wav", "ITEM_WEAPON_MISSILE_MAX": "streams/music/tank_jingle.wav", diff --git a/open_samus_returns_rando/samus_returns_patcher.py b/open_samus_returns_rando/samus_returns_patcher.py index acde0f9..7db190a 100644 --- a/open_samus_returns_rando/samus_returns_patcher.py +++ b/open_samus_returns_rando/samus_returns_patcher.py @@ -38,7 +38,6 @@ def create_custom_init(configuration: dict) -> str: energy_per_tank = configuration["energy_per_tank"] max_life = inventory.pop("ITEM_MAX_LIFE") - aeion_per_tank = configuration["aeion_per_tank"] max_aeion = inventory.pop("ITEM_MAX_SPECIAL_ENERGY") # increase starting HP if starting with etanks @@ -46,11 +45,6 @@ def create_custom_init(configuration: dict) -> str: etanks = inventory.pop("ITEM_ENERGY_TANKS") max_life += etanks * energy_per_tank - # increase starting Aeion if starting with atanks - if "ITEM_AEION_TANKS" in inventory: - atanks = inventory.pop("ITEM_AEION_TANKS") - max_aeion += atanks * aeion_per_tank - # These fields are required to start the game final_inventory = { "ITEM_MAX_LIFE": max_life, @@ -68,7 +62,6 @@ def create_custom_init(configuration: dict) -> str: "starting_scenario": lua_util.wrap_string(starting_location["scenario"]), "starting_actor": lua_util.wrap_string(starting_location["actor"]), "energy_per_tank": energy_per_tank, - "aeion_per_tank": aeion_per_tank, "reveal_map_on_start": configuration["reveal_map_on_start"], } diff --git a/tests/test_files/models_surface.json b/tests/test_files/models_surface.json index 0752e60..3fb3aba 100644 --- a/tests/test_files/models_surface.json +++ b/tests/test_files/models_surface.json @@ -5,12 +5,39 @@ "actor": "StartPoint0" }, "starting_items": { - "ITEM_MAX_LIFE": 599, - "ITEM_WEAPON_MISSILE_MAX": 50, - "ITEM_WEAPON_SUPER_MISSILE_MAX": 0, - "ITEM_WEAPON_POWER_BOMB_MAX": 0, - "ITEM_METROID_COUNT": 0, - "ITEM_METROID_TOTAL_COUNT": 40 + "ITEM_WEAPON_MISSILE_MAX": 24, + "ITEM_SPECIAL_ENERGY_SCANNING_PULSE": 1, + "ITEM_RANDO_DNA_11": 1, + "ITEM_RANDO_DNA_12": 1, + "ITEM_RANDO_DNA_13": 1, + "ITEM_RANDO_DNA_14": 1, + "ITEM_RANDO_DNA_15": 1, + "ITEM_RANDO_DNA_16": 1, + "ITEM_RANDO_DNA_17": 1, + "ITEM_RANDO_DNA_18": 1, + "ITEM_RANDO_DNA_19": 1, + "ITEM_RANDO_DNA_20": 1, + "ITEM_RANDO_DNA_21": 1, + "ITEM_RANDO_DNA_22": 1, + "ITEM_RANDO_DNA_23": 1, + "ITEM_RANDO_DNA_24": 1, + "ITEM_RANDO_DNA_25": 1, + "ITEM_RANDO_DNA_26": 1, + "ITEM_RANDO_DNA_27": 1, + "ITEM_RANDO_DNA_28": 1, + "ITEM_RANDO_DNA_29": 1, + "ITEM_RANDO_DNA_30": 1, + "ITEM_RANDO_DNA_31": 1, + "ITEM_RANDO_DNA_32": 1, + "ITEM_RANDO_DNA_33": 1, + "ITEM_RANDO_DNA_34": 1, + "ITEM_RANDO_DNA_35": 1, + "ITEM_RANDO_DNA_36": 1, + "ITEM_RANDO_DNA_37": 1, + "ITEM_RANDO_DNA_38": 1, + "ITEM_RANDO_DNA_39": 1, + "ITEM_MAX_LIFE": 99, + "ITEM_MAX_SPECIAL_ENERGY": 1000 }, "pickups": [ { @@ -72,11 +99,15 @@ }, { "pickup_type": "actor", - "caption": "Power Bomb acquired.", + "caption": "Main Power Bomb acquired.", "resources": [ [ { - "item_id": "ITEM_WEAPON_POWER_BOMB_MAX", + "item_id": "ITEM_WEAPON_POWER_BOMB", + "quantity": 1 + }, + { + "item_id": "ITEM_POWER_BOMB_TANKS", "quantity": 5 } ] @@ -281,11 +312,15 @@ }, { "pickup_type": "actor", - "caption": "Super Missile acquired.", + "caption": "Super Missile Launcher acquired.", "resources": [ [ { - "item_id": "ITEM_WEAPON_SUPER_MISSILE_MAX", + "item_id": "ITEM_WEAPON_SUPER_MISSILE", + "quantity": 1 + }, + { + "item_id": "ITEM_SUPER_MISSILE_TANKS", "quantity": 5 } ] @@ -344,6 +379,10 @@ { "item_id": "ITEM_SPECIAL_ENERGY_SCANNING_PULSE", "quantity": 1 + }, + { + "item_id": "ITEM_MAX_SPECIAL_ENERGY", + "quantity": 150 } ] ], @@ -363,6 +402,10 @@ { "item_id": "ITEM_SPECIAL_ENERGY_ENERGY_SHIELD", "quantity": 1 + }, + { + "item_id": "ITEM_MAX_SPECIAL_ENERGY", + "quantity": 150 } ] ], @@ -382,6 +425,10 @@ { "item_id": "ITEM_SPECIAL_ENERGY_ENERGY_WAVE", "quantity": 1 + }, + { + "item_id": "ITEM_MAX_SPECIAL_ENERGY", + "quantity": 150 } ] ], @@ -401,6 +448,10 @@ { "item_id": "ITEM_SPECIAL_ENERGY_PHASE_DISPLACEMENT", "quantity": 1 + }, + { + "item_id": "ITEM_MAX_SPECIAL_ENERGY", + "quantity": 150 } ] ], @@ -452,11 +503,11 @@ }, { "pickup_type": "actor", - "caption": "Super Missile Tank acquired. Super Missile capacity increased by 1.", + "caption": "Super Missile Tank acquired.\nSuper Missile capacity increased by 1.", "resources": [ [ { - "item_id": "ITEM_RANDO_LOCKED_SUPERS", + "item_id": "ITEM_SUPER_MISSILE_TANKS", "quantity": 1 } ] @@ -471,11 +522,11 @@ }, { "pickup_type": "actor", - "caption": "Power Bomb Tank acquired. Power Bomb capacity increased by 1.", + "caption": "Power Bomb Tank acquired.\nPower Bomb capacity increased by 1.", "resources": [ [ { - "item_id": "ITEM_RANDO_LOCKED_PBS", + "item_id": "ITEM_POWER_BOMB_TANKS", "quantity": 1 } ] @@ -490,12 +541,12 @@ }, { "pickup_type": "actor", - "caption": "Aeion Tank acquired. Aeion capacity increased.", + "caption": "Aeion Tank acquired.\nAeion Gauge expanded.", "resources": [ [ { - "item_id": "ITEM_AEION_TANKS", - "quantity": 1 + "item_id": "ITEM_MAX_SPECIAL_ENERGY", + "quantity": 50 } ] ], @@ -566,7 +617,6 @@ } ], "energy_per_tank": 100, - "aeion_per_tank": 50, "reveal_map_on_start": true, "game_patches": { "nerf_power_bombs": false