Skip to content

Commit

Permalink
Implement variable transport speeds (#6309)
Browse files Browse the repository at this point in the history
Implement transports moving at different speeds depending on how many
and which types of units they have loaded. Closes #6186.

## Description of the proposed changes
- Each Tech 1 unit decreases the transport's MaxAirspeed by `0.15`
- Each Tech 2 unit decreases the transport's MaxAirspeed by `0.3`
- Each Tech 3 unit decreases the transport's MaxAirspeed by `0.6`
- ACUs decrease the transport's MaxAirspeed by `1`

## Stat changes:
**Transport**
MaxAirspeed: 10 --> 10.75 (Tech 1 Transports)
MaxAirspeed: 13.5 --> 14.5 (Tech 2 Transports)
MaxAirspeed: 15 --> 17.5 (The Continental)

**Land units**
TransportSpeedReduction: 0.15 (Tech 1 land units)
TransportSpeedReduction: 0.3 (Tech 2 land units)
TransportSpeedReduction: 0.6 (Tech 3 land units)
TransportSpeedReduction: 1 (ACUs and SACUs)
TransportSpeedReduction: 1 (Tech 4 land units, to ensure compatibility
with survival maps)
TransportSpeedReduction: 1 (naval units, to ensure mod compatibility)

The `TransportSpeedReduction` stat can be tweaked for each unit
individually, though I did not do it here for consistency reasons. For
example, you can make LABs lighter than tanks. The
`TransportSpeedReduction` stat has also been made visible in the UI in
the additional unit details displayed when `Show Armament Detail in
Build Menu` is enabled.

## Additional context
- As Jip already pointed out, the change introduces a new balance knob.
- Enables more teamplay, as getting an empty transport to your teammates
is faster.
- The changes would introduce a new choice for the player, allowing him
to decide between a swift and less damaging drop or a slower but more
damaging one.
- Nerfs arty drops, specifically Seraphim transports fully loaded with
Zthuees, in an intuitive way. As Seraphim has the highest capacity
transports (and the strongest Tech 1 Artillery), I regard this as a
positive.

## Checklist
- [x] ~~Populate the `TransportSpeedReduction` blueprint field of all
land units~~ (alternative approach via blueprints-units.lua)
- [x] Changes are annotated, including comments where useful
- [x] Changes are documented in the changelog for the next game version

---------

Co-authored-by: lL1l1 <[email protected]>
  • Loading branch information
Basilisk3 and lL1l1 authored Jul 10, 2024
1 parent 6e55c68 commit 28ecf91
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 9 deletions.
16 changes: 16 additions & 0 deletions changelog/snippets/features.6309.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- (#6309) The movement speed of transports now changes based on how many and which types of units they have loaded.
- Units slow down transports based on their `TransportSpeedReduction` stat. If a unit has a `TransportSpeedReduction` of 1, each instance of this unit will slow down the transport's `MaxAirspeed` by 1. The primary implication of this change is that the effectiveness of the currently too oppressive Zthuee drops is reduced in an intuitive way. The effectiveness of ACU drops via Tech 2 transports remains unchanged.

- TransportSpeedReduction: 0.15 (Tech 1 land units)
- TransportSpeedReduction: 0.3 (Tech 2 land units)
- TransportSpeedReduction: 0.6 (Tech 3 land units)
- TransportSpeedReduction: 1 (ACUs and SACUs)
- TransportSpeedReduction: 1 (Tech 4 land units for compatibility with survival maps)

- To prevent drops from being overnerfed by this change, the speeds of all transports is increased.

- MaxAirspeed: 10 --> 10.75 (Tech 1 transports)
- MaxAirspeed: 13.5 --> 14.5 (Tech 2 transports)
- MaxAirspeed: 15 --> 17.5 (The Continental)

- (#6309) Display the `TransportSpeedReduction` stat in the additional unit details displayed when `Show Armament Detail in Build Menu` is enabled in the settings.
1 change: 1 addition & 0 deletions loc/US/strings_db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6761,6 +6761,7 @@ uvd_0013="Vision: %d, Underwater Vision: %d, Regen: %0.1f, Cap Cost: %0.1f"
uvd_0014="Damage: %.8g - %.8g, Splash: %.3g - %.3g"
uvd_0015="Damage: %.8g x%d, Splash: %.3g"
uvd_0016="Enhancements: %d"
uvd_0017="Transport Speed Reduction: %.3g"

uvd_DPS="(DPS: %d)"
uvd_ManualFire="(Manual Fire)"
Expand Down
14 changes: 14 additions & 0 deletions lua/sim/units/AirTransportUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,25 @@ AirTransport = ClassUnit(AirUnit, BaseTransport) {
end
end,

---@param self AirTransport
---@param totalweight CargoWeight
---@param unit Unit
ReduceTransportSpeed = function(self)
local transportspeed = self.Blueprint.Air.MaxAirspeed
local totalweight = 0
for _, unit in self:GetCargo() do
totalweight = totalweight + unit.Blueprint.Physics.TransportSpeedReduction
end
self:SetSpeedMult(1 - (totalweight / transportspeed))
end,

---@param self AirTransport
---@param attachBone Bone
---@param unit Unit
OnTransportAttach = function(self, attachBone, unit)
AirUnitOnTransportAttach(self, attachBone, unit)
BaseTransportOnTransportAttach(self, attachBone, unit)
self:ReduceTransportSpeed()
end,

---@param self AirTransport
Expand All @@ -89,6 +102,7 @@ AirTransport = ClassUnit(AirUnit, BaseTransport) {
OnTransportDetach = function(self, attachBone, unit)
AirUnitOnTransportDetach(self, attachBone, unit)
BaseTransportOnTransportDetach(self, attachBone, unit)
self:ReduceTransportSpeed()
end,

OnAttachedKilled = function(self, attached)
Expand Down
24 changes: 24 additions & 0 deletions lua/system/blueprints-units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ local function PostProcessUnit(unit)
local isDummy = unit.CategoriesHash['DUMMYUNIT']
local isLand = unit.CategoriesHash['LAND']
local isAir = unit.CategoriesHash['AIR']
local isNaval = unit.CategoriesHash['NAVAL']
local isBomber = unit.CategoriesHash['BOMBER']
local isGunship = unit.CategoriesHash['GROUNDATTACK'] and isAir and (not isBomber)
local isTransport = unit.CategoriesHash['TRANSPORTATION']
Expand All @@ -170,6 +171,8 @@ local function PostProcessUnit(unit)
local isTech2 = unit.CategoriesHash['TECH2']
local isTech3 = unit.CategoriesHash['TECH3']
local isExperimental = unit.CategoriesHash['EXPERIMENTAL']
local isACU = unit.CategoriesHash['COMMAND']
local isSACU = unit.CategoriesHash['SUBCOMMANDER']

-- do not touch guard scan radius values of engineer-like units, as it is the reason we have
-- the factory-reclaim-bug that we're keen in keeping that at this point
Expand Down Expand Up @@ -543,6 +546,27 @@ local function PostProcessUnit(unit)
unit.Interface.HelpText = unit.Description or "" --[[@as string]]
end

-- Define a specific TransportSpeedReduction for all land and naval units.
-- Experimentals have a TransportSpeedReduction of 1 due to transports gaining 1 speed and some survival maps loading experimentals into transports.
-- Naval units also gain a TransportSpeedReduction of 1 to ensure mod compatibility.
if not unit.Physics.TransportSpeedReduction and not isStructure then
if isLand and isTech1 then
unit.Physics.TransportSpeedReduction = 0.15
elseif isLand and isTech2 then
unit.Physics.TransportSpeedReduction = 0.3
elseif isSACU then
unit.Physics.TransportSpeedReduction = 1
elseif isLand and isTech3 then
unit.Physics.TransportSpeedReduction = 0.6
elseif isLand and isExperimental then
unit.Physics.TransportSpeedReduction = 1
elseif isACU then
unit.Physics.TransportSpeedReduction = 1
elseif isNaval then
unit.Physics.TransportSpeedReduction = 1
end
end

---------------------------------------------------------------------------
--#region (Re) apply the ability to land on water

Expand Down
8 changes: 8 additions & 0 deletions lua/ui/game/unitviewDetail.lua
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,14 @@ function WrapAndPlaceText(bp, builder, descID, control)
table.insert(lines, LOCF("<LOC uvd_0012>Speed: %0.1f, Reverse: %0.1f, Acceleration: %0.1f, Turning: %d",
bp.Physics.MaxSpeed, bp.Physics.MaxSpeedReverse, bp.Physics.MaxAcceleration, bp.Physics.TurnRate))
end

-- Display the TransportSpeedReduction stat in the UI.
-- Naval units and land experimentals also have this stat, but it since it is not relevant for non-modded games, we do not display it by default.
-- If a mod wants to display this stat for naval units or experimentals, this file can be hooked.
if bp.Physics.TransportSpeedReduction and not (bp.CategoriesHash.NAVAL or bp.CategoriesHash.EXPERIMENTAL) then
table.insert(lines, LOCF("<LOC uvd_0017>Transport Speed Reduction: %.3g",
bp.Physics.TransportSpeedReduction))
end

table.insert(blocks, {color = 'FFB0FFB0', lines = lines})
end
Expand Down
2 changes: 1 addition & 1 deletion units/UAA0104/UAA0104_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 2,
LiftFactor = 8,
MaxAirspeed = 13.5,
MaxAirspeed = 14.5,
StartTurnDistance = 10,
TransportHoverHeight = 4,
},
Expand Down
2 changes: 1 addition & 1 deletion units/UAA0107/UAA0107_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 2,
LiftFactor = 8,
MaxAirspeed = 10,
MaxAirspeed = 10.75,
StartTurnDistance = 10,
TransportHoverHeight = 4,
},
Expand Down
2 changes: 1 addition & 1 deletion units/UEA0104/UEA0104_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 2,
LiftFactor = 8,
MaxAirspeed = 13.5,
MaxAirspeed = 14.5,
StartTurnDistance = 10,
TransportHoverHeight = 4,
},
Expand Down
2 changes: 1 addition & 1 deletion units/UEA0107/UEA0107_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 2,
LiftFactor = 8,
MaxAirspeed = 10,
MaxAirspeed = 10.75,
StartTurnDistance = 10,
TransportHoverHeight = 4,
},
Expand Down
2 changes: 1 addition & 1 deletion units/URA0104/URA0104_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 2,
LiftFactor = 8,
MaxAirspeed = 13.5,
MaxAirspeed = 14.5,
StartTurnDistance = 10,
TransportHoverHeight = 4,
},
Expand Down
2 changes: 1 addition & 1 deletion units/URA0107/URA0107_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 2,
LiftFactor = 8,
MaxAirspeed = 10,
MaxAirspeed = 10.75,
StartTurnDistance = 10,
TransportHoverHeight = 4,
},
Expand Down
2 changes: 1 addition & 1 deletion units/XEA0306/XEA0306_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 2,
LiftFactor = 7,
MaxAirspeed = 15,
MaxAirspeed = 17.5,
StartTurnDistance = 10,
TransportHoverHeight = 6,
},
Expand Down
2 changes: 1 addition & 1 deletion units/XSA0104/XSA0104_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 4,
LiftFactor = 8,
MaxAirspeed = 13.5,
MaxAirspeed = 14.5,
StartTurnDistance = 10,
TransportHoverHeight = 4,
},
Expand Down
2 changes: 1 addition & 1 deletion units/XSA0107/XSA0107_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UnitBlueprint{
KTurn = 2,
KTurnDamping = 2,
LiftFactor = 8,
MaxAirspeed = 10,
MaxAirspeed = 10.75,
StartTurnDistance = 10,
TransportHoverHeight = 4,
},
Expand Down

0 comments on commit 28ecf91

Please sign in to comment.