Skip to content

Commit

Permalink
Merge branch 'main' into schema-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dyceron authored Sep 1, 2024
2 parents 28ca78c + 6d02ea2 commit c8a6e69
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.1
rev: v0.6.2
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
29 changes: 27 additions & 2 deletions src/open_samus_returns_rando/files/custom/guilib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,19 @@ function GUILib.UpdateDNACounter(currentDNA, maxDNA)
end
end

function GUILib.GetTotalDNACounter()
return GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter")
end

function GUILib.UpdateTotalDNAColor()
if Game.GetItemAmount(Game.GetPlayerName(), "ITEM_ADN") < 39 then
local dnaCounter = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter")
local dnaCounter = GUILib.GetTotalDNACounter()
if Blackboard.GetProp("GAME", "OBJECTIVE_COMPLETE") then
GUI.SetProperties(dnaCounter, {
ColorR = "0.60392",
ColorG = "0.61569",
ColorB = "0.04314",
})
else
GUI.SetProperties(dnaCounter, {
ColorR = "0.68000",
ColorG = "0.83000",
Expand All @@ -75,6 +85,21 @@ function GUILib.UpdateTotalDNAColor()
end
end

function GUILib.BlinkTotalDNACounter()
local dnaCounter = GUILib.GetTotalDNACounter()
GUI.SetProperties(dnaCounter, {
ColorR = "0.60392",
ColorG = "0.61569",
ColorB = "0.04314",
Blink = "1.00000",
})
end

function GUILib.DisableBlinkTotalDNACounter()
local dnaCounter = GUILib.GetTotalDNACounter()
GUI.SetProperties(dnaCounter, { Blink = "0.00000" })
end

function GUILib.AddMessageBox()
local randoUI = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.USSEF.Outer")
if randoUI ~= nil then
Expand Down
9 changes: 1 addition & 8 deletions src/open_samus_returns_rando/files/custom/scenario.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,7 @@ function Scenario.UpdateDNACounter()
local maxDNA = Init.tDNAPerArea[scenario] or 0
local currentDNA = Blackboard.GetProp("GAME", scenario .."_acquired_dna") or 0
GUILib.UpdateDNACounter(currentDNA, maxDNA)
if Blackboard.GetProp("GAME", "OBJECTIVE_COMPLETE") then
local dnaCounter = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter")
GUI.SetProperties(dnaCounter, {
ColorR = "0.60392",
ColorG = "0.61569",
ColorB = "0.04314",
})
end
GUILib.UpdateTotalDNAColor()
end

local original_init = Scenario.InitScenario
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function s110_surfaceb.ElevatorSetTarget(_ARG_0_)
end
function s110_surfaceb.InitFromBlackboard()
s110_surfaceb.SetLowModelsVisibility(false)
if Game.GetItemAmount(Game.GetPlayerName(), "ITEM_ADN") < 39 and Game.GetItemAmount(Game.GetPlayerName(), "ITEM_BABY_HATCHLING") < 1 then
if Game.GetItemAmount(Game.GetPlayerName(), "ITEM_ADN") > 0 and Game.GetItemAmount(Game.GetPlayerName(), "ITEM_BABY_HATCHLING") < 1 then
Game.PlayMusicStream(0, "streams/music/t_m2_surface_arr1.wav", -1, -1, -1, 2, 2, 1)
end
if Blackboard.GetProp("DEFEATED_ENEMIES", "Ridley") and Game.GetEntity("TG_Ridley_Access") ~= nil then
Expand Down
6 changes: 1 addition & 5 deletions src/open_samus_returns_rando/files/templates/custom_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,10 @@ function Init.InitGameBlackboard()
end
end
Blackboard.SetProp("GAME", "OBJECTIVE_COMPLETE", "b", false)
Blackboard.SetProp("PLAYER_INVENTORY", "ITEM_ADN", "f", Init.iRequiredDNA)
if Init.iRequiredDNA == 0 then
-- If no DNA is required, then the path to Ridley should always be open
Blackboard.SetProp("GAME", "OBJECTIVE_COMPLETE", "b", true)
Blackboard.SetProp("PLAYER_INVENTORY", "ITEM_ADN", "f", 39)
elseif Init.iRequiredDNA <= 39 then
Blackboard.SetProp("PLAYER_INVENTORY", "ITEM_ADN", "f", 39 - Init.iRequiredDNA)
else
Blackboard.SetProp("PLAYER_INVENTORY", "ITEM_ADN", "f", 0)
end
Blackboard.SetProp("PLAYER_INVENTORY", "ITEM_METROID_COUNT", "f", 0)
Blackboard.SetProp("PLAYER_INVENTORY", "ITEM_CURRENT_LIFE", "f", Init.tNewGameInventory.ITEM_MAX_LIFE)
Expand Down
30 changes: 6 additions & 24 deletions src/open_samus_returns_rando/files/templates/randomizerpowerup.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Game.ImportLibrary("system/scripts/guilib.lua", false)

RandomizerPowerup = RandomizerPowerup or {}
function RandomizerPowerup.main()
end
Expand Down Expand Up @@ -158,7 +160,7 @@ function RandomizerPowerup.HandlePickupResources(progression, actorOrName)
Blackboard.SetProp("GAME", scenario .. "_acquired_dna", "i", currentDNA + 1)
end
Scenario.UpdateDNACounter()
RandomizerPowerup.IncreaseItemAmount("ITEM_ADN", resource.quantity)
RandomizerPowerup.IncreaseItemAmount("ITEM_ADN", -1 * resource.quantity)
RandomizerPowerup.ObjectiveComplete()
end
end
Expand Down Expand Up @@ -195,17 +197,11 @@ function RandomizerPowerup.IncreaseAmmo(resource)
end

function RandomizerPowerup.ObjectiveComplete()
local required_dna = 39
-- Default required_dna is 39, so change the requirement if set higher in the config
if Init.iRequiredDNA > 39 then
required_dna = Init.iRequiredDNA
end

if RandomizerPowerup.GetItemAmount("ITEM_ADN") == required_dna then
if RandomizerPowerup.GetItemAmount("ITEM_ADN") == 0 and not Blackboard.GetProp("GAME", "OBJECTIVE_COMPLETE") then
Blackboard.SetProp("GAME", "OBJECTIVE_COMPLETE", "b", true)
Game.HUDIdleScreenLeave()
RandomizerPowerup.UpdateDNACounter()
Game.AddGUISF(3, "RandomizerPowerup.DisableBlink", "")
GUILib.BlinkTotalDNACounter()
Game.AddGUISF(3, "GUILib.DisableBlinkTotalDNACounter", "")

-- Assign boss names and areas to each boss
local boss = Init.sFinalBoss
Expand Down Expand Up @@ -241,20 +237,6 @@ function RandomizerPowerup.ObjectiveComplete()
end
end

function RandomizerPowerup.UpdateDNACounter()
local dnaCounter = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter")
GUI.SetProperties(dnaCounter, {
ColorR = "0.60392",
ColorG = "0.61569",
ColorB = "0.04314",
Blink = "1.00000",
})
end

function RandomizerPowerup.DisableBlink()
local dnaCounter = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter")
GUI.SetProperties(dnaCounter, { Blink = "0.00000" })
end

function RandomizerPowerup.IncreaseMissileCheckValue()
-- Update the min missile reserve tank refill value (capped by config)
Expand Down
7 changes: 4 additions & 3 deletions src/open_samus_returns_rando/samus_returns_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
from open_samus_returns_rando.patcher_editor import PatcherEditor
from open_samus_returns_rando.pickups.custom_pickups import patch_custom_pickups
from open_samus_returns_rando.pickups.pickup import patch_pickups
from open_samus_returns_rando.specific_patches import cosmetic_patches, game_patches
from open_samus_returns_rando.specific_patches.chozo_seal_patches import patch_chozo_seals
from open_samus_returns_rando.specific_patches.cosmetic_patches import patch_cosmetics
from open_samus_returns_rando.specific_patches.door_patches import patch_doors
from open_samus_returns_rando.specific_patches.environmental_damage import apply_constant_damage
from open_samus_returns_rando.specific_patches.game_patches import apply_game_patches
from open_samus_returns_rando.specific_patches.heat_room_patches import patch_heat_rooms
from open_samus_returns_rando.specific_patches.hint_patches import patch_hints
from open_samus_returns_rando.specific_patches.metroid_patches import patch_metroids
Expand Down Expand Up @@ -111,7 +112,7 @@ def patch_extracted(input_path: Path, input_exheader: Path | None, output_path:
patch_tunables(editor, configuration)

# Patch cosmetics
cosmetic_patches.patch_cosmetics(editor, configuration.get("cosmetic_patches", {}))
patch_cosmetics(editor, configuration.get("cosmetic_patches", {}))

# Patch metroids
patch_metroids(editor)
Expand All @@ -121,7 +122,7 @@ def patch_extracted(input_path: Path, input_exheader: Path | None, output_path:
patch_hints(lua_scripts, configuration["hints"])

# Specific game patches
game_patches.apply_game_patches(editor, configuration.get("game_patches", {}))
apply_game_patches(editor, configuration.get("game_patches", {}))

# Text patches
if "text_patches" in configuration:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_files/starter_preset_patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -4037,8 +4037,8 @@
}
},
"objective": {
"required_dna": 10,
"final_boss": "Ridley"
"final_boss": "Ridley",
"required_dna": 10
},
"energy_per_tank": 100,
"reserves_per_tank": {
Expand Down

0 comments on commit c8a6e69

Please sign in to comment.