Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement variable transport speeds #6309

Merged
merged 28 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a86b2b6
Implement variable transport speeds
Basilisk3 Jun 26, 2024
76270cf
Implement the UnitWeight stat for four units to demonstrate the changes
Basilisk3 Jun 26, 2024
2defbc9
Merge branch 'develop' into VariableTransportSpeeds
Basilisk3 Jun 26, 2024
e1f1e07
Change the `MaxAirspeed` of all Tech 2 transports
Basilisk3 Jun 26, 2024
321df71
Change the `MaxAirspeed` of all Tech 1 transports
Basilisk3 Jun 26, 2024
e31fcff
Change the `MaxAirspeed` of the Continental
Basilisk3 Jun 26, 2024
d2a233a
Update lua/sim/units/AirTransportUnit.lua
Basilisk3 Jun 27, 2024
c92bf5f
Update lua/sim/units/AirTransportUnit.lua
Basilisk3 Jun 27, 2024
d6efcb1
Remove unneeded changes
Basilisk3 Jun 27, 2024
dc35ce8
Define the `UnitWeight` stat in blueprints-units.lua
Basilisk3 Jun 27, 2024
182822e
Update the name of the function
Basilisk3 Jun 27, 2024
1b6ff8e
Make it possible to override the `UnitWeight` definition in blueprint…
Basilisk3 Jun 27, 2024
3c3323b
Add a check for `isStructure` because structures can have the 'land' …
Basilisk3 Jun 27, 2024
39e7d93
Merge branch 'develop' into VariableTransportSpeeds
Basilisk3 Jun 27, 2024
1b5e73e
Add features.6309.md
Basilisk3 Jun 27, 2024
7b345bc
Add the `UnitWeight` stat to uvd.lua
Basilisk3 Jun 28, 2024
62bbd07
Update features.6309.md
Basilisk3 Jun 28, 2024
7c9f7db
Update features.6309.md
Basilisk3 Jun 28, 2024
83da1b6
Rename the blueprint stat
Basilisk3 Jun 30, 2024
9e3470e
Merge branch 'develop' into VariableTransportSpeeds
Basilisk3 Jun 30, 2024
2466715
Apply feedback
Basilisk3 Jun 30, 2024
bee4ead
Small fix
Basilisk3 Jun 30, 2024
0a4dab1
Remove the last remaining reference to `UnitWeight`
Basilisk3 Jun 30, 2024
a19c064
Move the `TransportSpeedReduction` stat from `General` to `Physics`
Basilisk3 Jun 30, 2024
9be240f
Add more fail-safes and improve annotations
Basilisk3 Jul 1, 2024
f93449a
Improve annotations
Basilisk3 Jul 1, 2024
222e68d
Update features.6309.md
Basilisk3 Jul 1, 2024
876aca5
Update features.6309.md
Basilisk3 Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
MrRowey marked this conversation as resolved.
Show resolved Hide resolved
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