Skip to content

Commit

Permalink
more commander related adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruwetuin committed Feb 4, 2024
1 parent a794e3c commit 910e5fa
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion luarules/gadgets/unit_tombstones.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions luaui/Widgets/cmd_fac_holdposition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ local unitArray_ = {
"armfhp",
"armshltx",
"armshltxuw",
"armcom",
"armamsub",
"corlab",
"coralab",
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion luaui/Widgets/gui_unit_stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
42 changes: 24 additions & 18 deletions luaui/Widgets/unit_dontmove.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,57 @@ 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",
"corvroc",
"cortrem",
"armsnipe",
"corhrk",

"armmh",
"cormh",
"armroy",
"corroy",
"armserp",
"corssub",

"armmship",
"cormship",
"armbats",
"corbats",

"armepoch",
"corblackhy",

"corcat",
"armvang",

--skirmishers/fire support
"armjanus",
"armrock",
Expand All @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 910e5fa

Please sign in to comment.