From 910e5fa4fa7f5c944661321097076f6bf59b19b6 Mon Sep 17 00:00:00 2001 From: Floris Date: Sun, 4 Feb 2024 16:15:40 +0100 Subject: [PATCH] more commander related adjustments --- luarules/gadgets/unit_tombstones.lua | 2 +- luaui/Widgets/cmd_fac_holdposition.lua | 10 ++++-- luaui/Widgets/gui_unit_stats.lua | 9 +++++- luaui/Widgets/unit_dontmove.lua | 42 +++++++++++++++----------- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/luarules/gadgets/unit_tombstones.lua b/luarules/gadgets/unit_tombstones.lua index 9900bcf75a4..1383764ae7e 100644 --- a/luarules/gadgets/unit_tombstones.lua +++ b/luarules/gadgets/unit_tombstones.lua @@ -18,7 +18,7 @@ end local isCommander = {} for defID, def in ipairs(UnitDefs) do if def.customParams.iscommander ~= nil and not string.find(def.name, "scav") then - isCommander[defID] = def.name == 'armcom' and FeatureDefNames.armstone.id or FeatureDefNames.corstone.id + isCommander[defID] = def.name == 'corcom' and FeatureDefNames.corstone.id or FeatureDefNames.armstone.id end end diff --git a/luaui/Widgets/cmd_fac_holdposition.lua b/luaui/Widgets/cmd_fac_holdposition.lua index 47339bd284c..6ddef5a05b3 100644 --- a/luaui/Widgets/cmd_fac_holdposition.lua +++ b/luaui/Widgets/cmd_fac_holdposition.lua @@ -39,7 +39,6 @@ local unitArray_ = { "armfhp", "armshltx", "armshltxuw", - "armcom", "armamsub", "corlab", "coralab", @@ -52,13 +51,20 @@ local unitArray_ = { "corgant", "corgantuw", "coramsub", - "corcom", "leglab", "legvp", "legalab", "legavp", "leggant", } +-- add commanders too +local isCommander = {} +for unitDefID, unitDef in pairs(UnitDefs) do + if unitDef.customParams.iscommander then + unitArray_[#unitArray_+1] = unitDef.name + end +end + local unitArray = {} for _, name in pairs(unitArray_) do unitArray[UnitDefNames[name].id] = true diff --git a/luaui/Widgets/gui_unit_stats.lua b/luaui/Widgets/gui_unit_stats.lua index 624e8fd2146..6e071b87869 100644 --- a/luaui/Widgets/gui_unit_stats.lua +++ b/luaui/Widgets/gui_unit_stats.lua @@ -16,6 +16,13 @@ local texts = {} local damageStats = (VFS.FileExists("LuaUI/Config/BAR_damageStats.lua")) and VFS.Include("LuaUI/Config/BAR_damageStats.lua") local gameName = Game.gameName +local isCommander = {} +for unitDefID, unitDef in pairs(UnitDefs) do + if unitDef.customParams.iscommander then + isCommander[unitDefID] = true + end +end + if damageStats and damageStats[gameName] and damageStats[gameName].team then local rate = 0 for k, v in pairs (damageStats[gameName].team) do @@ -376,7 +383,7 @@ local function drawStats(uDefID, uID) uExp = spGetUnitExperience(uID) armoredMultiple = select(2,Spring.GetUnitArmored(uID)) - unbacom = unba and (UnitDefs[Spring.GetUnitDefID(uID)].name == "armcom" or UnitDefs[Spring.GetUnitDefID(uID)].name == "corcom") + unbacom = unba and isCommander[Spring.GetUnitDefID(uID)] --(UnitDefs[Spring.GetUnitDefID(uID)].name == "armcom" or UnitDefs[Spring.GetUnitDefID(uID)].name == "corcom") local _, xp = Spring.GetUnitExperience(uID) if unbacom then if xp then diff --git a/luaui/Widgets/unit_dontmove.lua b/luaui/Widgets/unit_dontmove.lua index f5725ce1088..2f4df7f721a 100644 --- a/luaui/Widgets/unit_dontmove.lua +++ b/luaui/Widgets/unit_dontmove.lua @@ -16,33 +16,31 @@ end local unitArray_ = { - --comms - "armcom", - "corcom", + --comms added below separately --aa units "armjeth", "armaak", "corcrash", "coraak", - + "armsam", "armyork", "cormist", "corsent", - + "armah", "corah", "armmls", "cormls", "armaas", "corarch", - + --arty "armart", "armham", "corwolv", - + "armmart", "armmerl", "cormart", @@ -50,14 +48,14 @@ local unitArray_ = { "cortrem", "armsnipe", "corhrk", - + "armmh", "cormh", "armroy", "corroy", "armserp", "corssub", - + "armmship", "cormship", "armbats", @@ -65,10 +63,10 @@ local unitArray_ = { "armepoch", "corblackhy", - + "corcat", "armvang", - + --skirmishers/fire support "armjanus", "armrock", @@ -77,27 +75,27 @@ local unitArray_ = { "corban", "armmanni", "cormort", - + --scouts "armflea", "armfav", "corfav", "armspy", "armgremlin", - + "armpt", "corpt", - + --shields/jammers/radars "armaser", "armjam", "corspec", - + "armseer", "armmark", "corvrad", "corvoyr", - + --antinukes "armscab", "cormabm", @@ -107,8 +105,16 @@ local unitArray_ = { "corantiship", --misc - + } +-- add commanders +local isCommander = {} +for unitDefID, unitDef in pairs(UnitDefs) do + if unitDef.customParams.iscommander then + unitArray_[#unitArray_+1] = unitDef.name + end +end + local unitArray = {} for _, name in pairs(unitArray_) do if UnitDefNames[name] then @@ -137,6 +143,6 @@ function widget:UnitFromFactory(unitID, unitDefID, unitTeam) if unitTeam == myTeamID then if unitArray[unitDefID] then Spring.GiveOrderToUnit(unitID, CMD.MOVE_STATE, { 0 }, 0) - end + end end end