Skip to content

Commit

Permalink
Merge pull request #879 from beyond-all-reason/legionfactionpicker
Browse files Browse the repository at this point in the history
Legion and Random in Faction Picker
  • Loading branch information
AntlerForce authored Feb 17, 2025
2 parents 1d72c2d + bd45dc4 commit 678cae1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
9 changes: 9 additions & 0 deletions LuaMenu/configs/gameConfig/byar/sidedata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@ return {
name = "Cortex",
logo = SIDEPICS_DIR .. "cortex.png",
},
{
name = "Legion",
logo = SIDEPICS_DIR .. "legion.png",
requiresModoption = "experimentallegionfaction",
},
{
name = "Random",
logo = SIDEPICS_DIR .. "random.png",
},
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions LuaMenu/widgets/gui_side_change_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,22 @@ local function CreateSideChangeWindow(opts)
local Configuration = WG.Chobby.Configuration
local sidedata = Configuration:GetSideData()

local battleLobby = WG.LibLobby.localLobby
local battle = battleLobby:GetBattle(battleLobby:GetMyBattleID())
if not battle then
battleLobby = WG.LibLobby.lobby
end

local factionMap = {}
local factionNames = {}

local modoptions = battleLobby.modoptions

for index, data in ipairs(sidedata) do
factionMap[data.name] = index - 1
table.insert(factionNames, data.name)
if not data.requiresModoption or (modoptions and modoptions[data.requiresModoption] == "1") then
factionMap[data.name] = index - 1
table.insert(factionNames, data.name)
end
end

local sideChangeWindow = Window:New {
Expand Down Expand Up @@ -89,6 +100,7 @@ local function CreateSideChangeWindow(opts)
y = 150,
width = sideChangeWindow.width * 0.5,
height = 40,
caption = Configuration:GetSideById(selectedFaction).name or "",
items = factionNames,
parent = sideChangeWindow,
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
Expand Down
10 changes: 10 additions & 0 deletions libs/liblobby/lobby/interface_skirmish.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ function InterfaceSkirmish:_StartScript(gameName, mapName, playerName, friendLis

for userName, data in pairs(self.userBattleStatus) do
if data.allyNumber and not data.aiLib then --every player must have an allynumber!
local sideData = WG.Chobby.Configuration:GetSideById(data.side)
if sideData and sideData.requiresModoption and
(not self.modoptions or self.modoptions[sideData.requiresModoption] ~= "1") then
data.side = 0
end
players[playerCount] = {
Name = userName,
Team = teamCount,
Expand Down Expand Up @@ -153,6 +158,11 @@ function InterfaceSkirmish:_StartScript(gameName, mapName, playerName, friendLis
local chickenAdded = false
for userName, data in pairs(self.userBattleStatus) do
if data.allyNumber and data.aiLib then
local sideData = WG.Chobby.Configuration:GetSideById(data.side)
if sideData and sideData.requiresModoption and
(not self.modoptions or self.modoptions[sideData.requiresModoption] ~= "1") then
data.side = 3 --Random faction
end
if friendAllyTeam == data.allyNumber and aiReplaceCount > 0 and not string.find(data.aiLib, "Raptor") then
aiReplaceCount = aiReplaceCount - 1
else
Expand Down
9 changes: 9 additions & 0 deletions libs/liblobby/lobby/lobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,15 @@ function Lobby:_OnJoinedBattle(battleID, userName, scriptPassword)
Spring.Log(LOG_SECTION, LOG.WARNING, "_OnJoinedBattle nonexistent battle.")
return
end
if userName == self:GetMyUserName() then
local lastFaction = WG.Chobby.Configuration.lastFactionChoice
if lastFaction then
local sideData = WG.Chobby.Configuration:GetSideById(lastFaction)
if sideData and sideData.requiresModoption and (not self.modoptions or self.modoptions[sideData.requiresModoption] ~= "1") then
WG.Chobby.Configuration.lastFactionChoice = 0
end
end
end
local found = false
local users = battle.users
for i = 1, #users do
Expand Down

0 comments on commit 678cae1

Please sign in to comment.