Skip to content

Commit

Permalink
Try to properly disable multi arena gammas
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanatosGit authored and dyceron committed Oct 14, 2023
1 parent c8d5271 commit b2a3812
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 22 deletions.
3 changes: 2 additions & 1 deletion open_samus_returns_rando/files/custom_scenario.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ function Scenario.OnSubAreaChange(old_subarea, old_actorgroup, new_subarea, new_
Scenario.UpdateProgressiveItemModels()
end

function Scenario.SetMetroidSpawngroupOnCurrentScenario(created_actor, group_name)
function Scenario.SetMetroidSpawngroupOnCurrentScenario(created_actor, group_name, is_multi)
if created_actor ~= nil and created_actor.sName ~= nil then
CurrentScenario.currentMetroidSpawngroup = group_name
CurrentScenario.isMultiGamma = is_multi or false
end
end
3 changes: 1 addition & 2 deletions open_samus_returns_rando/files/levels/s030_area3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ function s030_area3.OnGamma_005_Intro_C_Generated(_ARG_0_, _ARG_1_)
s030_area3.OnGamma_005_C_Generated(_ARG_0_, _ARG_1_)
end
function s030_area3.OnGamma_005_C_Generated(_ARG_0_, _ARG_1_)
-- TODO: No idea if this is the right one (multi-room gamma)
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_005_C")
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_005_C", true)
if _ARG_1_ ~= nil then
-- _ARG_1_.AI:AddBossDoorUnlockedOnDeath("Door015")
_ARG_1_.AI.bPlaceholder = false
Expand Down
3 changes: 1 addition & 2 deletions open_samus_returns_rando/files/levels/s033_area3b.lua
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,7 @@ function s033_area3b.OnGamma_004_Intro_B_Generated(_ARG_0_, _ARG_1_)
s033_area3b.OnGamma_004_B_Generated(_ARG_0_, _ARG_1_)
end
function s033_area3b.OnGamma_004_B_Generated(_ARG_0_, _ARG_1_)
-- TODO: No idea if this is the right one (multi-room gamma)
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_004_B")
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_004_B", true)
if _ARG_1_ ~= nil then
-- _ARG_1_.AI:AddBossDoorUnlockedOnDeath("Door014")
_ARG_1_.AI.bPlaceholder = false
Expand Down
3 changes: 1 addition & 2 deletions open_samus_returns_rando/files/levels/s036_area3c.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ function s036_area3c.OnEnter_SetCheckpoint_001_Gamma_007()
Game.SetBossCheckPointNames("ST_SG_Gamma_007", "ST_SG_Gamma_007", "SG_Gamma_007_A", "SG_Gamma_007_B", "SG_Gamma_007_C")
end
function s036_area3c.OnGamma_007_A_Generated(_ARG_0_, _ARG_1_)
-- TODO: No idea if this is the right one (multi-room gamma)
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_007_A")
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_007_A", true)
if _ARG_1_ ~= nil then
-- _ARG_1_.AI:AddBossDoorUnlockedOnDeath("Door006")
_ARG_1_.AI.bPlaceholder = false
Expand Down
3 changes: 1 addition & 2 deletions open_samus_returns_rando/files/levels/s040_area4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ function s040_area4.OnGamma_001_Intro_A_Generated(_ARG_0_, _ARG_1_)
s040_area4.OnGamma_001_A_Generated(_ARG_0_, _ARG_1_)
end
function s040_area4.OnGamma_001_A_Generated(_ARG_0_, _ARG_1_)
-- TODO: No idea if this is the right one (multi-room gamma)
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_001_A")
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_001_A", true)
if _ARG_1_ ~= nil then
-- _ARG_1_.AI:AddBossDoor("Door011")
-- _ARG_1_.AI:AddBossDoorUnlockedOnDeath("Door004")
Expand Down
3 changes: 1 addition & 2 deletions open_samus_returns_rando/files/levels/s050_area5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ function s050_area5.OnGamma_002_Intro_A_Generated(_ARG_0_, _ARG_1_)
s050_area5.OnGamma_002_A_Generated(_ARG_0_, _ARG_1_)
end
function s050_area5.OnGamma_002_A_Generated(_ARG_0_, _ARG_1_)
-- TODO: No idea if this is the right one (multi-room gamma)
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_002_A")
Scenario.SetMetroidSpawngroupOnCurrentScenario(_ARG_0_, "SG_Gamma_002_A", true)
if _ARG_1_ ~= nil then
-- _ARG_1_.AI:AddBossDoorUnlockedOnDeath("Door014")
_ARG_1_.AI.bPlaceholder = false
Expand Down
33 changes: 22 additions & 11 deletions open_samus_returns_rando/files/templates/metroid_template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,39 @@ Metroid = {}
function Metroid.Dummy()
end

function Metroid.DisableSpawnGroup(spawnGroupName)
local spawnGroup = Game.GetEntity(spawnGroupName)
if spawnGroup ~= nil and spawnGroup.SPAWNGROUP ~= nil then
spawnGroup.SPAWNGROUP:DisableSpawnGroup()
Scenario.WriteToBlackboard("entity_" .. spawnGroupName .. "_dead", "b", true)
Scenario.WriteToBlackboard("entity_" .. spawnGroupName .. "_deaths", "i", 1)
Scenario.WriteToBlackboard("entity_" .. spawnGroupName .. "_enabled", "b", false)
end
end

function Metroid.RemoveMetroid(_ARG_0_)
local spawnGroupName = CurrentScenario.currentMetroidSpawngroup
if spawnGroupName ~= nil then
-- GUI.LaunchMessage(spawnGroupName, "Metroid.Dummy", "")

local spawnGroup = Game.GetEntity(spawnGroupName)
if spawnGroup ~= nil and spawnGroup.SPAWNGROUP ~= nil then
spawnGroup.SPAWNGROUP:DisableSpawnGroup()
-- disable all spawn groups in case of multi arena gamma
if CurrentScenario.isMultiGamma then
local endingLetters = {"A", "B", "C"}
for index, letter in pairs(endingLetters) do
local otherSpawnGroupName = string.sub(spawnGroupName, 0, -2) .. letter
Metroid.DisableSpawnGroup(otherSpawnGroupName)
end
local allDead = "Arena_" .. string.sub(spawnGroupName, 4, -3) .. "_AllDead"
Scenario.WriteToBlackboard(allDead, "b", true)
-- disable single arena metroid
else
GUI.LaunchMessage("Oops 1" .. spawnGroupName, "Metroid.Dummy", "")
return
Metroid.DisableSpawnGroup(spawnGroupName)
end

Scenario.WriteToBlackboard("entity_" .. spawnGroupName .. "_dead", "b", true)
Scenario.WriteToBlackboard("entity_" .. spawnGroupName .. "_deaths", "i", 1)
Scenario.WriteToBlackboard("entity_" .. spawnGroupName .. "_enabled", "b", false)

local count = Game.GetItemAmount(Game.GetPlayerName(), "ITEM_METROID_COUNT") + 1
Game.SetItemAmount(Game.GetPlayerName(), "ITEM_METROID_COUNT", count)
Game.IncrementMetroidTotalCount(0)

CurrentScenario.currentMetroidSpawngroup = nil
CurrentScenario.isMultiGamma = nil

local scenario = Scenario.CurrentScenarioID
if scenario ~= nil and Metroid.Pickups ~= nil and
Expand Down

0 comments on commit b2a3812

Please sign in to comment.