Skip to content

Commit

Permalink
Added medium transport weight. Weights are now.
Browse files Browse the repository at this point in the history
 * [0, 500] = Light
 * (500, 1000] = Medium (ie Jack, Skuttle, Felon, Phantom, Minotaur, Emissary, Lance, Impaler, Siren, Envoy,  Aspis, Iris, Djinn)
 * (1000, inf) = Heavy

Transport speeds are.
 * Charon transports Light/Medium at 70%/50% speed.
 * Hercules transports Light/Medium/Heavy at 75%/65%/50% speed.
The heavy/light speeds were not changed.
  • Loading branch information
GoogleFrog committed Aug 29, 2021
1 parent b2bc7f9 commit c4d9a3d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions LuaRules/Configs/constants.lua
@@ -1,2 +1,4 @@
HIDDEN_STORAGE = 10000 -- hidden storage: it will spend all energy above (storage - hidden_storage)
TEAM_SLOWUPDATE_RATE = 30
TRANSPORT_LIGHT_COST_MAX = 500
TRANSPORT_MEDIUM_COST_MAX = 1000
7 changes: 7 additions & 0 deletions LuaRules/Gadgets/unit_transport_speed.lua
Expand Up @@ -23,16 +23,20 @@ end

local mass = {}
local requireHeavy = {}
local requireMedium = {}
local lightSpeed = {}
local mediumSpeed = {}
local heavySpeed = {}

for i = 1, #UnitDefs do
local ud = UnitDefs[i]
mass[i] = ud.mass
requireHeavy[i] = (ud.customParams.requireheavytrans and true) or false
requireMedium[i] = (ud.customParams.requiremediumtrans and true) or false

if ud.transportCapacity and (ud.transportCapacity > 0) then
lightSpeed[i] = tonumber(ud.customParams.transport_speed_light or "1")
mediumSpeed[i] = tonumber(ud.customParams.transport_speed_medium or "1")
heavySpeed[i] = tonumber(ud.customParams.transport_speed_heavy or "1")
end
end
Expand All @@ -46,6 +50,9 @@ local function GetSpeedFactor(tudid, unitDefID, effectiveMass)
if requireHeavy[unitDefID] then
return heavySpeed[tudid] or 1
end
if requireMedium[unitDefID] then
return mediumSpeed[tudid] or 1
end
return lightSpeed[tudid] or 1
end

Expand Down
8 changes: 6 additions & 2 deletions LuaUI/Widgets/gui_contextmenu.lua
Expand Up @@ -1160,9 +1160,13 @@ local function printAbilities(ud, unitID)

if ud.transportCapacity and (ud.transportCapacity > 0) then
cells[#cells+1] = 'Transport: '
cells[#cells+1] = ((ud.customParams.islighttransport) and "Light" or "Heavy")
cells[#cells+1] = (((ud.customParams.islightonlytransport) and "Light") or ((ud.customParams.islighttransport) and "Medium") or "Heavy")
cells[#cells+1] = 'Light Speed: '
cells[#cells+1] = math.floor((tonumber(ud.customParams.transport_speed_light or "1")*100) + 0.5) .. "%"
if not ud.customParams.islightonlytransport then
cells[#cells+1] = 'Medium Speed: '
cells[#cells+1] = math.floor((tonumber(ud.customParams.transport_speed_medium or "1")*100) + 0.5) .. "%"
end
if not ud.customParams.islighttransport then
cells[#cells+1] = 'Heavy Speed: '
cells[#cells+1] = math.floor((tonumber(ud.customParams.transport_speed_heavy or "1")*100) + 0.5) .. "%"
Expand Down Expand Up @@ -1550,7 +1554,7 @@ local function printunitinfo(ud, buttonWidth, unitID)
-- transportability by light or heavy airtrans
if not (ud.canFly or ud.cantBeTransported) then
statschildren[#statschildren+1] = Label:New{ caption = 'Transportable: ', textColor = color.stats_fg, }
statschildren[#statschildren+1] = Label:New{ caption = ((ud.customParams.requireheavytrans and "Heavy") or "Light"), textColor = color.stats_fg, }
statschildren[#statschildren+1] = Label:New{ caption = ((ud.customParams.requireheavytrans and "Heavy") or (ud.customParams.requiremediumtrans and "Medium") or "Light"), textColor = color.stats_fg, }
end

if isCommander then
Expand Down
10 changes: 7 additions & 3 deletions gamedata/unitdefs_post.lua
Expand Up @@ -12,7 +12,6 @@ Spring.Echo("Loading UnitDefs_posts")
--

VFS.Include("LuaRules/Configs/constants.lua")
local TRANSPORT_LIGHT_COST_MAX = 1000

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -941,8 +940,13 @@ end
if Utilities.IsCurrentVersionNewerThan(104, 600) then
for name, ud in pairs (UnitDefs) do
ud.transportmass = nil
if ud.buildcostmetal and tonumber(ud.buildcostmetal) > TRANSPORT_LIGHT_COST_MAX then
ud.customparams.requireheavytrans = 1
local buildCost = ud.buildcostmetal and tonumber(ud.buildcostmetal)
if buildCost then
if buildCost > TRANSPORT_MEDIUM_COST_MAX then
ud.customparams.requireheavytrans = 1
elseif buildCost > TRANSPORT_LIGHT_COST_MAX then
ud.customparams.requiremediumtrans = 1
end
end
end
else
Expand Down
2 changes: 2 additions & 0 deletions units/gunshipheavytrans.lua
Expand Up @@ -29,6 +29,8 @@ return { gunshipheavytrans = {
midposoffset = [[0 0 0]],
aimposoffset = [[0 10 0]],
modelradius = [[15]],
transport_speed_light = [[0.75]],
transport_speed_medium = [[0.65]],
transport_speed_heavy = [[0.5]],
},

Expand Down
3 changes: 2 additions & 1 deletion units/gunshiptrans.lua
Expand Up @@ -29,7 +29,8 @@ return { gunshiptrans = {
midposoffset = [[0 0 0]],
modelradius = [[15]],
transport_speed_light = [[0.7]],
islighttransport = 1,
transport_speed_medium = [[0.5]],
islighttransport = 1, -- Actually maybe this needs to be kept as is, how does Circuit handle it?
},

explodeAs = [[GUNSHIPEX]],
Expand Down

0 comments on commit c4d9a3d

Please sign in to comment.