Skip to content

Commit

Permalink
Add Shield GUI info (#4105)
Browse files Browse the repository at this point in the history
Handles when a unit has a shield and weapons, and when a unit has a shield only.
Added some google translated entries for all the languages except for (chinese?) as if I didn't they would crash the UI.
  • Loading branch information
SethDGamre authored Jan 4, 2025
1 parent a770749 commit c121ebc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
6 changes: 5 additions & 1 deletion language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,11 @@
"eneededforconversion": "E needed for conversion",
"convertedm": "converted M",
"estorage": "E storage",
"mstorage": "M storage"
"mstorage": "M storage",
"shieldcapacity": "Shield capacity",
"shieldrange": "Shield range",
"shieldrechargerate": "Recharge rate",
"shieldrechargecost": "Recharge cost"
},
"spectator_hud": {
"metalIncome_title": "Metal Income",
Expand Down
25 changes: 24 additions & 1 deletion luaui/Widgets/gui_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,22 @@ local function refreshUnitInfo()
unitDefInfo[unitDefID].isAaUnit = true
end

--shield params
if weaponDef.shieldRadius and weaponDef.shieldRadius > 0 then
if #weapons <= 1 then
unitDefInfo[unitDefID].weapons = {}
unitDefInfo[unitDefID].mindps = 0
unitDefInfo[unitDefID].maxdps = 0
unitDefInfo[unitDefID].range = 0
unitDefInfo[unitDefID].reloadTime = 0
unitDefInfo[unitDefID].mainWeapon = 1
unitDefInfo[unitDefID].shieldOnly = true
end
unitDefInfo[unitDefID].shieldRange = weaponDef.shieldRadius
unitDefInfo[unitDefID].shieldCapacity = weaponDef.shieldPower
unitDefInfo[unitDefID].shieldRechargeRate = weaponDef.shieldPowerRegen
unitDefInfo[unitDefID].shieldRechargeCost = weaponDef.shieldPowerRegenEnergy
end
end

if unitDef.customParams.unitgroup and unitDef.customParams.unitgroup == 'explo' and unitDef.deathExplosion and WeaponDefNames[unitDef.deathExplosion] then
Expand Down Expand Up @@ -1427,7 +1443,7 @@ local function drawUnitInfo()

if unitDefInfo[displayUnitDefID].maxCoverage then
addTextInfo(Spring.I18N('ui.info.coverrange'), unitDefInfo[displayUnitDefID].maxCoverage)
elseif maxRange then
elseif maxRange and not unitDefInfo[displayUnitDefID].shieldOnly then
addTextInfo(Spring.I18N('ui.info.weaponrange'), math_floor(maxRange))
end
if currentReloadTime and currentReloadTime > 0 then
Expand All @@ -1441,6 +1457,13 @@ local function drawUnitInfo()
addTextInfo(Spring.I18N('ui.info.metalshot'), unitDefInfo[displayUnitDefID].metalPerShot)
end
end
-- shield display
if unitDefInfo[displayUnitDefID].shieldCapacity then
addTextInfo(Spring.I18N('ui.info.shieldcapacity'), unitDefInfo[displayUnitDefID].shieldCapacity)
addTextInfo(Spring.I18N('ui.info.shieldrange'), unitDefInfo[displayUnitDefID].shieldRange)
addTextInfo(Spring.I18N('ui.info.shieldrechargerate'), unitDefInfo[displayUnitDefID].shieldRechargeRate)
addTextInfo(Spring.I18N('ui.info.shieldrechargecost'), unitDefInfo[displayUnitDefID].shieldRechargeCost)
end

if unitDefInfo[displayUnitDefID].stealth then
addTextInfo(Spring.I18N('ui.info.stealthy'), nil)
Expand Down
4 changes: 0 additions & 4 deletions units/ArmBuildings/LandUtil/armgate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ return {
cratermult = 0,
edgeeffectiveness = 0.15,
name = "PlasmaRepulsor",
range = 550,
soundhitwet = "sizzle",
weapontype = "Shield",
damage = {
default = 100,
},
shield = {
alpha = 0.17,
armortype = "shields",
Expand Down
4 changes: 0 additions & 4 deletions units/ArmBuildings/SeaUtil/armfgate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,8 @@ return {
cratermult = 0,
edgeeffectiveness = 0.15,
name = "NavalPlasmaRepulsor",
range = 600,
soundhitwet = "sizzle",
weapontype = "Shield",
damage = {
default = 100,
},
shield = {
alpha = 0.17,
armortype = "shields",
Expand Down
4 changes: 0 additions & 4 deletions units/CorBuildings/LandUtil/corgate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ return {
cratermult = 0,
edgeeffectiveness = 0.15,
name = "PlasmaRepulsor",
range = 550,
soundhitwet = "sizzle",
weapontype = "Shield",
damage = {
default = 100,
},
shield = {
alpha = 0.17,
armortype = "shields",
Expand Down
4 changes: 0 additions & 4 deletions units/CorBuildings/SeaUtil/corfgate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,8 @@ return {
cratermult = 0,
edgeeffectiveness = 0.15,
name = "NavalPlasmaRepulsor",
range = 600,
soundhitwet = "sizzle",
weapontype = "Shield",
damage = {
default = 100,
},
shield = {
alpha = 0.17,
armortype = "shields",
Expand Down

0 comments on commit c121ebc

Please sign in to comment.