Skip to content

Commit

Permalink
Added "Computer Opponents" option, which replaces empty player spots …
Browse files Browse the repository at this point in the history
…with computer players; fixed a couple of desync causes
  • Loading branch information
Andrettin committed Jun 29, 2015
1 parent bf0908e commit a4862aa
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ https://github.com/Andrettin/Wyrmsun
- Fixed save game crash related to whether a unit's AI is active.
- Slight improvement to unit selection.

* Multiplayer
- Added "Computer Opponents" option, which replaces empty player spots with computer players.
- Fixed a couple of desync causes.

* Quests
- Minor text update to the dwarven quests.

Expand Down
6 changes: 4 additions & 2 deletions scripts/guichan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,10 @@ function RunMap(map, objective, fow, revealmap)
end
end
RunResultsMenu(s)
if (GetCivilizationTechnologyPoints(GetPlayerData(GetThisPlayer(), "RaceName")) > 0 and GameResult == GameVictory and CurrentQuest ~= "" and not IsReplayGame() and not IsNetworkGame() and not GrandStrategy) then
RunTechTreeMenu(GetTechTreeCivilizationNumber(GetPlayerData(GetThisPlayer(), "RaceName")))
if not (IsNetworkGame()) then
if (GetCivilizationTechnologyPoints(GetPlayerData(GetThisPlayer(), "RaceName")) > 0 and GameResult == GameVictory and CurrentQuest ~= "" and not IsReplayGame() and not GrandStrategy) then
RunTechTreeMenu(GetTechTreeCivilizationNumber(GetPlayerData(GetThisPlayer(), "RaceName")))
end
end

InitGameSettings()
Expand Down
36 changes: 28 additions & 8 deletions scripts/menus/network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ function RunJoiningMapMenu(s)
local no_randomness = menu:addImageCheckBox("No Randomness", sx, sy*3+180, function() end)
no_randomness:setEnabled(true)
no_randomness:setMarked(int2bool(ServerSetupState.NoRandomness))
local computer_opponents = menu:addImageCheckBox("Computer Opponents", sx, sy*3+210, function() end)
computer_opponents:setEnabled(true)
computer_opponents:setMarked(ServerSetupState.Opponents > 0)

menu:writeText("Civilization:", sx, sy*11)
local civilization_list = {_("Map Default"), _("Dwarf"), _("Human - Germanic")}
Expand Down Expand Up @@ -199,11 +202,12 @@ function RunJoiningMapMenu(s)
GameSettings.RevealMap = ServerSetupState.RevealMap
no_randomness:setMarked(int2bool(ServerSetupState.NoRandomness))
GameSettings.NoRandomness = int2bool(ServerSetupState.NoRandomness)
computer_opponents:setMarked(ServerSetupState.Opponents > 0)
units:setSelected(ServerSetupState.UnitsOption)
GameSettings.NumUnits = ServerSetupState.UnitsOption
resources:setSelected(ServerSetupState.ResourcesOption)
GameSettings.Resources = ServerSetupState.ResourcesOption
GameSettings.Inside = int2bool(ServerSetupState.Inside)
-- GameSettings.Inside = int2bool(ServerSetupState.Inside)
updatePlayersList()
state = GetNetworkState()
-- FIXME: don't use numbers
Expand Down Expand Up @@ -355,6 +359,24 @@ function RunServerMultiGameMenu(map, description, numplayers)
end
local no_randomness = menu:addImageCheckBox("No Randomness", sx, sy*3+180, no_randomnessCb)
no_randomness:setMarked(false)

ServerSetupState.Opponents = 0
local function computer_opponentsCb(dd)
if (dd:isMarked()) then
local connected_players = 0
for i=2,8 do
if (Hosts[i-1].PlyName ~= "") then
connected_players = connected_players + 1
end
end
ServerSetupState.Opponents = numplayers - 1 - connected_players
else
ServerSetupState.Opponents = 0
end
NetworkServerResyncClients()
end
local computer_opponents = menu:addImageCheckBox("Computer Opponents", sx, sy*3+210, computer_opponentsCb)
computer_opponents:setMarked(false)

menu:writeText("Civilization:", sx, sy*11)
local civilization_list = {_("Map Default"), _("Dwarf"), _("Human - Germanic")}
Expand Down Expand Up @@ -397,7 +419,7 @@ function RunServerMultiGameMenu(map, description, numplayers)
NetworkMapName = map
NetworkInitServerConnect(numplayers)
ServerSetupState.FogOfWar = 1
ServerSetupState.Inside = 0
-- ServerSetupState.Inside = 0
GameSettings.Inside = false
startgame = menu:addFullButton(_("~!Start Game"), "s", sx * 11, sy*14,
function(s)
Expand Down Expand Up @@ -552,13 +574,11 @@ function RunCreateMultiGameMenu(s)
MapRequiredQuest = ""
Load(maps[i])
if (MapWorld == world_list[world:getSelected() + 1] or (MapWorld == "" and world_list[world:getSelected() + 1] == "Custom")) then
if (MapRequiredQuest == "" or GetArrayIncludes(wyr.preferences.QuestsCompleted, MapRequiredQuest)) then
local map_description = _(description)
if (map_description == "") then
map_description = string.gsub(string.gsub(maps[i], ".smp", ""), "(.*)/", "")
end
table.insert(scenario_list, map_description)
local map_description = _(description)
if (map_description == "") then
map_description = string.gsub(string.gsub(maps[i], ".smp", ""), "(.*)/", "")
end
table.insert(scenario_list, map_description)
end
end

Expand Down
Binary file modified wyrmsun.exe
Binary file not shown.

0 comments on commit a4862aa

Please sign in to comment.