Skip to content

Commit

Permalink
Merge pull request #841 from AntlerForce/fixoptionpresets_multiplayer
Browse files Browse the repository at this point in the history
Prevent modoptions from presets being applied if in multiplayer and not boss
  • Loading branch information
AntlerForce authored Dec 3, 2024
2 parents c63d1af + 5bb7ecb commit 559376f
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions LuaMenu/widgets/gui_optionpresets_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,6 @@ local function applyPreset(presetName)
battleLobby:SayBattle("!nbTeams " .. presetMPBattleSettings["nbTeams"])
end

-- modoptions
currentModoptions = presetObj["Modoptions"]
if (currentModoptions ~= nil and enabledOptions["Modoptions"]) then
-- if multiplayer have to disable other modoptions first:
if (multiplayer) then
-- now apply the modoptions as the baseline
local combinedModoptions = multiplayerModoptions
for key, value in pairs(currentModoptions) do
multiplayerModoptions[key] = value
end
currentModoptions = combinedModoptions
end

battleLobby:SetModOptions(currentModoptions)
end

-- map
local presetMapName = presetObj["Map"]
if (presetMapName ~= nil and enabledOptions["Map"]) then
Expand Down Expand Up @@ -196,6 +180,27 @@ local function applyPreset(presetName)
battlestatusoptions)
end
end

-- modoptions
currentModoptions = presetObj["Modoptions"]
if (currentModoptions ~= nil and enabledOptions["Modoptions"]) then
-- if multiplayer have to disable other modoptions first:
if (multiplayer) then
local isBoss = battle.bossed
if isBoss and isBoss == true then
-- now apply the modoptions as the baseline
local combinedModoptions = multiplayerModoptions
for key, value in pairs(currentModoptions) do
multiplayerModoptions[key] = value
end
currentModoptions = combinedModoptions
else
WG.Delay(function() battleLobby:SayBattleEx("tried to apply a preset containing modoptions, but was prevented due to not being boss") end, 1.5)
return
end
end
battleLobby:SetModOptions(currentModoptions)
end
end
end

Expand Down

0 comments on commit 559376f

Please sign in to comment.