Skip to content

Commit

Permalink
Automatically rotate units with angle limits towards targets (#6437)
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 authored Jan 30, 2025
1 parent 9ca7749 commit 5555262
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
2 changes: 2 additions & 0 deletions changelog/snippets/balance.6437.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- (#6437) Automatically rotate Cybran Carrier and Othuum towards their targets when idle or attacking so that all their weapons can fire.
- Units rotate in place while aiming, so formations do not get disrupted.
4 changes: 3 additions & 1 deletion engine/Core/Blueprints/UnitBlueprint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@


---@class UnitBlueprintAI
--- under what angle the unit attacks its target after getting an attack order
--- At what angle (to either side) the unit attacks its target after getting an attack order.
--- If one of the unit's weapons has a target and has `SlavedToBody = true`, it will rotate when idle and attacking.
--- Overrides Weapon `SlavedToBody` and `SlavedToBodyArcRange` behavior.
---@field AttackAngle number
--- automatically surface to attack ground targets
---@field AutoSurfaceToAttack boolean
Expand Down
12 changes: 7 additions & 5 deletions engine/Core/Blueprints/WeaponBlueprint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@
---@field Flare WeaponBlueprintFlare
--- used to force packing up a weapon before being able to fire again
---@field ForceSingleFire? boolean
--- controls what the weapon is allowed to target in reference to the heading of the unit
--- controls what the weapon is allowed to target in reference to the heading of the unit. Defaults to 0
---@field HeadingArcCenter number
--- controls what the weapon is allowed to target in reference to the arc center,
--- this is degrees on either side
--- this is degrees on either side. Defaults to 180
---@field HeadingArcRange number
--- does not consider the weapon when attacking targets if it is disabled
---@field IgnoreIfDisabled? boolean
Expand Down Expand Up @@ -286,10 +286,12 @@
--- if the weapon goes directly from its `IdleState` to its `RackSalvoFiringState` without
--- going through its `RackSalvoFireReadyState` first
---@field SkipReadyState? boolean
--- if the weapon is "slaved" to the unit's body, thus requiring it to face its target to fire
--- If the weapon causes the unit to rotate towards the weapon's target when the target is outside of `SlavedToBodyArcRange`.
--- With multiple slaved weapons, the first slaved weapon in the blueprint that currently has a target is used for turning.
--- If `UnitBlueprintAI.AttackAngle` is true, then this causes the unit to rotate when attacking while idle.
---@field SlavedToBody? boolean
--- Range of arc in both directions to be considered "slaved" to a target. With multiple weapons,
--- the first weapon in the blueprint that currently has a target is used for turning.
--- Degrees to either side of the unit's heading outside of which the weapon will rotate the unit towards the target.
--- Defaults to 1. Behavior gets overriden by `UnitBlueprintAI.AttackAngle`.
---@field SlavedToBodyArcRange? number
--- flag to specify to not make the weapon active if the primary weapon has a current target
---@field StopOnPrimaryWeaponBusy? boolean
Expand Down
8 changes: 8 additions & 0 deletions units/URS0303/URS0303_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ UnitBlueprint{
RackSlavedToTurret = true,
RangeCategory = "UWRC_AntiAir",
RateOfFire = 10/5, --10/integer interval in ticks
SlavedToBody = true,
SlavedToBodyArcRange = 27,
TargetPriorities = {
"NAVAL MOBILE",
"ALLUNITS",
Expand Down Expand Up @@ -310,6 +312,8 @@ UnitBlueprint{
RackSlavedToTurret = true,
RangeCategory = "UWRC_AntiAir",
RateOfFire = 10/5, --10/integer interval in ticks
SlavedToBody = true,
SlavedToBodyArcRange = 27,
TargetPriorities = {
"EXPERIMENTAL",
"AIR MOBILE TECH3 BOMBER",
Expand Down Expand Up @@ -377,6 +381,8 @@ UnitBlueprint{
RackSlavedToTurret = true,
RangeCategory = "UWRC_AntiAir",
RateOfFire = 10/5, --10/integer interval in ticks
SlavedToBody = true,
SlavedToBodyArcRange = 27,
TargetPriorities = {
"EXPERIMENTAL",
"AIR MOBILE TECH3 BOMBER",
Expand Down Expand Up @@ -444,6 +450,8 @@ UnitBlueprint{
RackSlavedToTurret = true,
RangeCategory = "UWRC_AntiAir",
RateOfFire = 10/5, --10/integer interval in ticks
SlavedToBody = true,
SlavedToBodyArcRange = 27,
TargetPriorities = {
"EXPERIMENTAL",
"AIR MOBILE TECH3 BOMBER",
Expand Down
4 changes: 4 additions & 0 deletions units/XSL0303/XSL0303_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ UnitBlueprint{
RackSlavedToTurret = false,
RangeCategory = "UWRC_DirectFire",
RateOfFire = 10/5, --10/integer interval in ticks
SlavedToBody = true,
SlavedToBodyArcRange = 44,
TargetPriorities = {
"TECH3 MOBILE",
"TECH2 MOBILE",
Expand Down Expand Up @@ -310,6 +312,8 @@ UnitBlueprint{
RackSlavedToTurret = false,
RangeCategory = "UWRC_DirectFire",
RateOfFire = 10/5, --10/integer interval in ticks
SlavedToBody = true,
SlavedToBodyArcRange = 44,
TargetPriorities = {
"TECH3 MOBILE",
"TECH2 MOBILE",
Expand Down
2 changes: 0 additions & 2 deletions units/XSS0103/XSS0103_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ UnitBlueprint{
FireTargetLayerCapsTable = { Water = "Air" },
FiringRandomness = 0,
FiringTolerance = 1,
HeadingArcCenter = 0,
HeadingArcRange = 360,
Label = "AntiAir",
MaxRadius = 48,
MuzzleSalvoDelay = 0,
Expand Down

0 comments on commit 5555262

Please sign in to comment.