Skip to content

Commit

Permalink
Merge pull request #419 from randovania/tanks-refill-ammo
Browse files Browse the repository at this point in the history
Add toggle for tanks fully refilling ammo
  • Loading branch information
ThanatosGit authored Jul 18, 2024
2 parents 9e09193 + efbbaee commit 0e09300
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/open_samus_returns_rando/files/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@
"type": "boolean",
"description": "Removes the wall between the Queen and Baby, allowing access into Area 8 from Surface West.",
"default": false
},
"tanks_refill_ammo": {
"type": "boolean",
"description": "If enabled, collecting a tank refills that ammo to max capacity. In vanilla, only Energy and Aeion get fully refilled to max capacity.",
"default": true
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Init.sThisRandoIdentifier = TEMPLATE("configuration_identifier") .. Init.sLayout
Init.tBoxesSeen = 0
Init.bEnableRoomIds = TEMPLATE("enable_room_ids")
Init.sBabyMetroidHint = TEMPLATE("baby_metroid_hint")
Init.bTanksRefillAmmo = TEMPLATE("tanks_refill_ammo")

local orig_log = Game.LogWarn
if TEMPLATE("enable_remote_lua") then
Expand Down
18 changes: 11 additions & 7 deletions src/open_samus_returns_rando/files/templates/randomizerpowerup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ function RandomizerPowerup.IncreaseItemAmount(item_id, quantity, capacity)
target = math.max(target, 0)
RandomizerPowerup.SetItemAmount(item_id, target)

local itemAmount = Game.GetPlayer().INVENTORY
if item_id == "ITEM_CURRENT_SPECIAL_ENERGY" then
local specialEnergy = Game.GetPlayer().SPECIALENERGY
specialEnergy.fMaxEnergy = capacity
specialEnergy.fEnergy = capacity
elseif item_id == "ITEM_WEAPON_MISSILE_CURRENT" then
itemAmount:SetItemAmount(item_id, capacity)
elseif item_id == "ITEM_WEAPON_SUPER_MISSILE_CURRENT" then
itemAmount:SetItemAmount(item_id, capacity)
elseif item_id == "ITEM_WEAPON_POWER_BOMB_CURRENT" then
itemAmount:SetItemAmount(item_id, capacity)
end

if Init.bTanksRefillAmmo then
local tank = Game.GetPlayer().INVENTORY
if item_id == "ITEM_WEAPON_MISSILE_CURRENT" then
tank:SetItemAmount(item_id, capacity)
elseif item_id == "ITEM_WEAPON_SUPER_MISSILE_CURRENT" then
tank:SetItemAmount(item_id, capacity)
elseif item_id == "ITEM_WEAPON_POWER_BOMB_CURRENT" then
tank:SetItemAmount(item_id, capacity)
end
end
end

Expand Down
6 changes: 4 additions & 2 deletions src/open_samus_returns_rando/lua_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ def add_progressive_models(self, pickup: dict, actordef_name: str) -> None:
self._progressive_models += models

def _create_custom_init(self, editor: PatcherEditor, configuration: dict) -> str:
cosmetic_options: dict = configuration["cosmetic_patches"]
inventory: dict[str, int] = configuration["starting_items"]
starting_location: dict = configuration["starting_location"]
starting_text: list[str] = configuration.get("starting_text", [])
game_patches: dict = configuration["game_patches"]
cosmetic_options: dict = configuration["cosmetic_patches"]
configuration_identifier: str = configuration["configuration_identifier"]
enable_remote_lua: bool = configuration.get("enable_remote_lua", False)

Expand Down Expand Up @@ -273,7 +274,8 @@ def chunks(array: list[str], n: int) -> Iterable[list[str]]:
"enable_room_ids": False if cosmetic_options["enable_room_name_display"] == "NEVER" else True,
"layout_uuid": layout_uuid,
"enable_remote_lua": enable_remote_lua,
"baby_metroid_hint": baby_metroid_hint
"baby_metroid_hint": baby_metroid_hint,
"tanks_refill_ammo": game_patches["tanks_refill_ammo"]
}

return lua_util.replace_lua_template("custom_init.lua", replacement)
Expand Down

0 comments on commit 0e09300

Please sign in to comment.