From 28ecf91092052b5124e8d04cfa7c6fcd2446c768 Mon Sep 17 00:00:00 2001 From: Basilisk3 <126026384+Basilisk3@users.noreply.github.com> Date: Wed, 10 Jul 2024 09:52:06 +0200 Subject: [PATCH] Implement variable transport speeds (#6309) 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 <82986251+lL1l1@users.noreply.github.com> --- changelog/snippets/features.6309.md | 16 ++++++++++++++++ loc/US/strings_db.lua | 1 + lua/sim/units/AirTransportUnit.lua | 14 ++++++++++++++ lua/system/blueprints-units.lua | 24 ++++++++++++++++++++++++ lua/ui/game/unitviewDetail.lua | 8 ++++++++ units/UAA0104/UAA0104_unit.bp | 2 +- units/UAA0107/UAA0107_unit.bp | 2 +- units/UEA0104/UEA0104_unit.bp | 2 +- units/UEA0107/UEA0107_unit.bp | 2 +- units/URA0104/URA0104_unit.bp | 2 +- units/URA0107/URA0107_unit.bp | 2 +- units/XEA0306/XEA0306_unit.bp | 2 +- units/XSA0104/XSA0104_unit.bp | 2 +- units/XSA0107/XSA0107_unit.bp | 2 +- 14 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 changelog/snippets/features.6309.md diff --git a/changelog/snippets/features.6309.md b/changelog/snippets/features.6309.md new file mode 100644 index 0000000000..8e24f0daa3 --- /dev/null +++ b/changelog/snippets/features.6309.md @@ -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. diff --git a/loc/US/strings_db.lua b/loc/US/strings_db.lua index 48a22e2e95..011f595e2d 100644 --- a/loc/US/strings_db.lua +++ b/loc/US/strings_db.lua @@ -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)" diff --git a/lua/sim/units/AirTransportUnit.lua b/lua/sim/units/AirTransportUnit.lua index 7cb1c8a951..03d3e2b360 100644 --- a/lua/sim/units/AirTransportUnit.lua +++ b/lua/sim/units/AirTransportUnit.lua @@ -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 @@ -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) diff --git a/lua/system/blueprints-units.lua b/lua/system/blueprints-units.lua index 1e6b28cb25..68b5ccf2e2 100644 --- a/lua/system/blueprints-units.lua +++ b/lua/system/blueprints-units.lua @@ -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'] @@ -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 @@ -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 diff --git a/lua/ui/game/unitviewDetail.lua b/lua/ui/game/unitviewDetail.lua index 39c2ed50b5..4fedc6fbcf 100644 --- a/lua/ui/game/unitviewDetail.lua +++ b/lua/ui/game/unitviewDetail.lua @@ -722,6 +722,14 @@ function WrapAndPlaceText(bp, builder, descID, control) table.insert(lines, LOCF("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("Transport Speed Reduction: %.3g", + bp.Physics.TransportSpeedReduction)) + end table.insert(blocks, {color = 'FFB0FFB0', lines = lines}) end diff --git a/units/UAA0104/UAA0104_unit.bp b/units/UAA0104/UAA0104_unit.bp index bf331c85ee..41d8df36fe 100644 --- a/units/UAA0104/UAA0104_unit.bp +++ b/units/UAA0104/UAA0104_unit.bp @@ -21,7 +21,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 2, LiftFactor = 8, - MaxAirspeed = 13.5, + MaxAirspeed = 14.5, StartTurnDistance = 10, TransportHoverHeight = 4, }, diff --git a/units/UAA0107/UAA0107_unit.bp b/units/UAA0107/UAA0107_unit.bp index 31b0ea5dc9..91428b1614 100644 --- a/units/UAA0107/UAA0107_unit.bp +++ b/units/UAA0107/UAA0107_unit.bp @@ -21,7 +21,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 2, LiftFactor = 8, - MaxAirspeed = 10, + MaxAirspeed = 10.75, StartTurnDistance = 10, TransportHoverHeight = 4, }, diff --git a/units/UEA0104/UEA0104_unit.bp b/units/UEA0104/UEA0104_unit.bp index 90e6692fa6..3ac3ec49e2 100644 --- a/units/UEA0104/UEA0104_unit.bp +++ b/units/UEA0104/UEA0104_unit.bp @@ -21,7 +21,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 2, LiftFactor = 8, - MaxAirspeed = 13.5, + MaxAirspeed = 14.5, StartTurnDistance = 10, TransportHoverHeight = 4, }, diff --git a/units/UEA0107/UEA0107_unit.bp b/units/UEA0107/UEA0107_unit.bp index 4b100d4b75..522466dffd 100644 --- a/units/UEA0107/UEA0107_unit.bp +++ b/units/UEA0107/UEA0107_unit.bp @@ -21,7 +21,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 2, LiftFactor = 8, - MaxAirspeed = 10, + MaxAirspeed = 10.75, StartTurnDistance = 10, TransportHoverHeight = 4, }, diff --git a/units/URA0104/URA0104_unit.bp b/units/URA0104/URA0104_unit.bp index 80b21f9559..097877e7ec 100644 --- a/units/URA0104/URA0104_unit.bp +++ b/units/URA0104/URA0104_unit.bp @@ -21,7 +21,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 2, LiftFactor = 8, - MaxAirspeed = 13.5, + MaxAirspeed = 14.5, StartTurnDistance = 10, TransportHoverHeight = 4, }, diff --git a/units/URA0107/URA0107_unit.bp b/units/URA0107/URA0107_unit.bp index 3a43b34a8f..b3e520ccf2 100644 --- a/units/URA0107/URA0107_unit.bp +++ b/units/URA0107/URA0107_unit.bp @@ -21,7 +21,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 2, LiftFactor = 8, - MaxAirspeed = 10, + MaxAirspeed = 10.75, StartTurnDistance = 10, TransportHoverHeight = 4, }, diff --git a/units/XEA0306/XEA0306_unit.bp b/units/XEA0306/XEA0306_unit.bp index efd545d228..67072dcd97 100644 --- a/units/XEA0306/XEA0306_unit.bp +++ b/units/XEA0306/XEA0306_unit.bp @@ -22,7 +22,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 2, LiftFactor = 7, - MaxAirspeed = 15, + MaxAirspeed = 17.5, StartTurnDistance = 10, TransportHoverHeight = 6, }, diff --git a/units/XSA0104/XSA0104_unit.bp b/units/XSA0104/XSA0104_unit.bp index bf7596039d..51a8e3d696 100644 --- a/units/XSA0104/XSA0104_unit.bp +++ b/units/XSA0104/XSA0104_unit.bp @@ -21,7 +21,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 4, LiftFactor = 8, - MaxAirspeed = 13.5, + MaxAirspeed = 14.5, StartTurnDistance = 10, TransportHoverHeight = 4, }, diff --git a/units/XSA0107/XSA0107_unit.bp b/units/XSA0107/XSA0107_unit.bp index 572ca9a369..20e75538c8 100644 --- a/units/XSA0107/XSA0107_unit.bp +++ b/units/XSA0107/XSA0107_unit.bp @@ -21,7 +21,7 @@ UnitBlueprint{ KTurn = 2, KTurnDamping = 2, LiftFactor = 8, - MaxAirspeed = 10, + MaxAirspeed = 10.75, StartTurnDistance = 10, TransportHoverHeight = 4, },