Skip to content

Commit

Permalink
Fix various issues with naval units (FAForever#5834)
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 authored Jan 19, 2024
1 parent 5306e6f commit 64d4e4a
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 38 deletions.
39 changes: 39 additions & 0 deletions lua/system/blueprints-units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ local BlueprintNameToIntel = {
SonarStealthFieldRadius = 'SonarStealthField',
}

local BlueprintIntelNameToOgrids = {
CloakFieldRadius = 4,
OmniRadius = 4,
RadarRadius = 4,
RadarStealthFieldRadius = 4,
SonarRadius = 4,
SonarStealthFieldRadius = 4,
WaterVisionRadius = 4,
VisionRadius = 2,
}

local LabelToVeterancyUse = {
['DeathWeapon'] = true,
['DeathImpact'] = true,
Expand Down Expand Up @@ -528,6 +539,34 @@ local function PostProcessUnit(unit)
if unit.Economy and not unit.Economy.BuildRate then
unit.Economy.BuildRate = 0
end

---------------------------------------------------------------------------
--#region Sanity check for intel values

-- Intel is visualised as a circle but it works in squares/blocks. You can
-- view the intel that a unit produces via a console command 'dbg Radar'.
--
-- It appears the engine divides the radius by the grid size and floors the
-- result. Therefore not all intel values and/or changes are actually
-- meaningful. With this code we check all intel values and point out those
-- that are not accurate.

if unit.Intel then
for nameIntel, radius in unit.Intel do
local ogrids = BlueprintIntelNameToOgrids[nameIntel]
if ogrids then
local radiusOnGrid = math.floor(radius / ogrids) * ogrids
if radiusOnGrid != radius then
WARN(
string.format(
"Intel radius of %s (= %d) for %s does not match intel grid (%d ogrids), should be either %d or %d",
tostring(unit.BlueprintId), radius, nameIntel, ogrids, radiusOnGrid, radiusOnGrid + ogrids
)
)
end
end
end
end
end

---@param allBlueprints BlueprintsTable
Expand Down
2 changes: 1 addition & 1 deletion lua/ui/game/unitviewDetail.lua
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ function WrapAndPlaceText(bp, builder, descID, control)
if info.MuzzleSalvoDelay == 0 then
MuzzleCount = table.getsize(Rack.MuzzleBones)
end
if MuzzleCount > 1 then singleShot = false end
if MuzzleCount > 1 or info.RackFireTogether and RackCount > 1 then singleShot = false end
CycleProjs = CycleProjs + MuzzleCount

SubCycleTime = SubCycleTime + MuzzleCount * MuzzleDelays
Expand Down
2 changes: 1 addition & 1 deletion units/UAS0103/UAS0103_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ UnitBlueprint{
DamageType = "Normal",
DisableWhileReloading = true,
DisplayName = "Quasar Anti Torpedo",
FireTargetLayerCapsTable = { Water = "Seabed|Sub|Water" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 10,
Label = "AntiTorpedo01",
LeadTarget = false,
Expand Down
63 changes: 58 additions & 5 deletions units/UAS0201/UAS0201_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,20 @@ UnitBlueprint{
DisableWhileReloading = true,
DisplayName = "Anti Torpedo",
EffectiveRadius = 42,
FireTargetLayerCapsTable = { Water = "Sub|Water|Seabed" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedo",
MaxRadius = 45,
MinRadius = 5,
MinRadius = 15,
MuzzleSalvoDelay = 0,
MuzzleSalvoSize = 2,
MuzzleSalvoSize = 1,
MuzzleVelocity = 80,
ProjectileId = "/projectiles/AIMAntiTorpedo01/AIMAntiTorpedo01_proj.bp",
ProjectileLifetime = 4,
RackBones = {
{
MuzzleBones = {
"Projectile02",
"Projectile04",
},
RackBone = "Projectile02",
},
Expand All @@ -368,7 +367,61 @@ UnitBlueprint{
RackSalvoSize = 1,
RackSlavedToTurret = false,
RangeCategory = "UWRC_Countermeasure",
RateOfFire = 0.26,
RateOfFire = 0.131,
TargetCheckInterval = 1.0,
TargetResetWhenReady = true,
TargetRestrictDisallow = "UNTARGETABLE",
TargetRestrictOnlyAllow = "TORPEDO",
TargetType = "RULEWTT_Projectile",
TrackingRadius = 1.0,
TurretDualManipulators = false,
TurretPitch = 0,
TurretPitchRange = 0,
TurretPitchSpeed = 0,
TurretYaw = 0,
TurretYawRange = 180,
TurretYawSpeed = 360,
Turreted = false,
WeaponCategory = "Defense",
WeaponRepackTimeout = 0,
WeaponUnpacks = false,
},
{
AlwaysRecheckTarget = false,
BallisticArc = "RULEUBA_None",
CollideFriendly = false,
Damage = 2,
DamageType = "Normal",
DisableWhileReloading = true,
DisplayName = "Anti Torpedo",
EffectiveRadius = 42,
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedo",
MaxRadius = 45,
MinRadius = 15,
MuzzleSalvoDelay = 0,
MuzzleSalvoSize = 1,
MuzzleVelocity = 80,
ProjectileId = "/projectiles/AIMAntiTorpedo01/AIMAntiTorpedo01_proj.bp",
ProjectileLifetime = 4,
RackBones = {
{
MuzzleBones = {
"Projectile04",
},
RackBone = "Projectile04",
},
},
RackFireTogether = false,
RackRecoilDistance = 0,
RackReloadTimeout = 0,
RackSalvoChargeTime = 0,
RackSalvoReloadTime = 0,
RackSalvoSize = 1,
RackSlavedToTurret = false,
RangeCategory = "UWRC_Countermeasure",
RateOfFire = 0.131,
TargetCheckInterval = 1.0,
TargetResetWhenReady = true,
TargetRestrictDisallow = "UNTARGETABLE",
Expand Down
4 changes: 2 additions & 2 deletions units/UAS0401/UAS0401_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ UnitBlueprint{
DisableWhileReloading = true,
DisplayName = "Quasar Anti Torpedo",
FireTargetLayerCapsTable = {
Sub = "Sub|Water",
Water = "Sub|Water",
Sub = "Water",
Water = "Water",
},
FiringTolerance = 180,
Label = "AntiTorpedo01",
Expand Down
2 changes: 1 addition & 1 deletion units/UES0201/UES0201_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ UnitBlueprint{
},
DisableWhileReloading = true,
DisplayName = "Smart Charge AntiTorpedo",
FireTargetLayerCapsTable = { Water = "Sub|Water|Seabed" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 15,
Label = "AntiTorpedo",
MaxRadius = 30,
Expand Down
2 changes: 1 addition & 1 deletion units/URS0201/URS0201_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ UnitBlueprint{
},
DisableWhileReloading = true,
DisplayName = "Anti Torpedo Solution",
FireTargetLayerCapsTable = { Water = "Seabed|Sub|Water" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedoF",
MaxRadius = 30,
Expand Down
67 changes: 63 additions & 4 deletions units/XAS0204/XAS0204_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,14 @@ UnitBlueprint{
DisplayName = "Quasar Anti-Torpedo",
DisableWhileReloading = true,
FireTargetLayerCapsTable = {
Sub = "Seabed|Sub|Water",
Water = "Seabed|Sub|Water",
Sub = "Water",
Water = "Water",
},
FiringTolerance = 2,
Label = "AntiTorpedo01",
LeadTarget = false,
MaxRadius = 32,
MinRadius = 10,
MuzzleSalvoDelay = 0,
MuzzleSalvoSize = 1,
MuzzleVelocity = 80,
Expand All @@ -315,7 +316,6 @@ UnitBlueprint{
{
MuzzleBones = {
"Projectile_Right_Center01",
"Projectile_Left_Center01",
},
RackBone = "Projectile_Right_Center01",
},
Expand All @@ -328,7 +328,66 @@ UnitBlueprint{
RackSalvoSize = 1,
RackSlavedToTurret = false,
RangeCategory = "UWRC_Countermeasure",
RateOfFire = 0.13,
RateOfFire = 0.065,
TargetCheckInterval = 1.0,
TargetRestrictDisallow = "UNTARGETABLE",
TargetRestrictOnlyAllow = "TORPEDO",
TargetType = "RULEWTT_Projectile",
TrackingRadius = 1.0,
TurretDualManipulators = false,
TurretPitch = 0,
TurretPitchRange = 0,
TurretPitchSpeed = 0,
TurretYaw = 0,
TurretYawRange = 0,
TurretYawSpeed = 0,
Turreted = false,
WeaponCategory = "Defense",
WeaponRepackTimeout = 0,
WeaponUnpacks = false,
},
{
AlwaysRecheckTarget = false,
Audio = {
Fire = Sound { Bank = 'XAS_Weapon', Cue = 'XAS0204_AntiTorpedo', LodCutoff = 'Weapon_LodCutoff' },
},
BallisticArc = "RULEUBA_None",
CollideFriendly = false,
Damage = 2,
DamageType = "Normal",
DisplayName = "Quasar Anti-Torpedo",
DisableWhileReloading = true,
FireTargetLayerCapsTable = {
Sub = "Water",
Water = "Water",
},
FiringTolerance = 2,
Label = "AntiTorpedo01",
LeadTarget = false,
MaxRadius = 32,
MinRadius = 10,
MuzzleSalvoDelay = 0,
MuzzleSalvoSize = 1,
MuzzleVelocity = 80,
ProjectileId = "/projectiles/AIMAntiTorpedo02/AIMAntiTorpedo02_proj.bp",
ProjectileLifetime = 4,
RackBones = {
{
MuzzleBones = {
"Projectile_Left_Center01",
},
RackBone = "Projectile_Left_Center01",
},
},
RackFireTogether = false,
RackRecoilDistance = 0,
RackReloadTimeout = 0,
RackSalvoChargeTime = 0,
RackSalvoReloadTime = 0,
RackSalvoSize = 1,
RackSlavedToTurret = false,
RangeCategory = "UWRC_Countermeasure",
RateOfFire = 0.065,
TargetCheckInterval = 1.0,
TargetRestrictDisallow = "UNTARGETABLE",
TargetRestrictOnlyAllow = "TORPEDO",
Expand Down
8 changes: 4 additions & 4 deletions units/XAS0306/XAS0306_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Quasar Anti-Torpedo",
DisableWhileReloading = true,
FireTargetLayerCapsTable = { Water = "Sub|Water|Seabed" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedoLeft1",
MaxRadius = 45,
Expand Down Expand Up @@ -397,7 +397,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Quasar Anti-Torpedo",
DisableWhileReloading = true,
FireTargetLayerCapsTable = { Water = "Sub|Water|Seabed" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedoLeft2",
MaxRadius = 45,
Expand Down Expand Up @@ -451,7 +451,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Quasar Anti-Torpedo",
DisableWhileReloading = true,
FireTargetLayerCapsTable = { Water = "Sub|Water|Seabed" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedoRight1",
MaxRadius = 45,
Expand Down Expand Up @@ -505,7 +505,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Quasar Anti-Torpedo",
DisableWhileReloading = true,
FireTargetLayerCapsTable = { Water = "Sub|Water|Seabed" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedoRight2",
MaxRadius = 45,
Expand Down
4 changes: 2 additions & 2 deletions units/XES0102/XES0102_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ UnitBlueprint{
Intel = {
SonarRadius = 35,
VisionRadius = 32,
WaterVisionRadius = 55,
WaterVisionRadius = 56,
},
LifeBarHeight = 0.075,
LifeBarOffset = 0.7,
Expand Down Expand Up @@ -243,7 +243,7 @@ UnitBlueprint{
},
DisplayName = "Smart Charge AntiTorpedo",
DisableWhileReloading = true,
FireTargetLayerCapsTable = { Water = "Sub|Water|Seabed|Land" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringRandomness = 0,
FiringTolerance = 15,
Label = "AntiTorpedo",
Expand Down
2 changes: 1 addition & 1 deletion units/XES0307/XES0307_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ UnitBlueprint{
},
DisableWhileReloading = true,
DisplayName = "Smart Charge AntiTorpedo",
FireTargetLayerCapsTable = { Water = "Sub|Water|Seabed" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringRandomness = 0,
FiringTolerance = 15,
Label = "AntiTorpedo",
Expand Down
2 changes: 1 addition & 1 deletion units/XRL0305/XRL0305_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ UnitBlueprint{
DisableWhileReloading = true,
DisplayName = "Anti-Torpedo Flare",
EffectiveRadius = 29,
FireTargetLayerCapsTable = { Seabed = "Sub|Water|Seabed" },
FireTargetLayerCapsTable = { Seabed = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedo",
MaxRadius = 34,
Expand Down
2 changes: 1 addition & 1 deletion units/XRL0403/XRL0403_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ UnitBlueprint {
},
DisableWhileReloading = true,
DisplayName = "Anti-Torpedo Flare",
FireTargetLayerCapsTable = { Seabed = "Seabed|Sub|Water" },
FireTargetLayerCapsTable = { Seabed = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedo",
MaxRadius = 25,
Expand Down
4 changes: 2 additions & 2 deletions units/XRS0204/XRS0204_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ UnitBlueprint{
DisableWhileReloading = true,
DisplayName = "Anti-Torpedo Flare",
FireTargetLayerCapsTable = {
Sub = "Seabed|Sub|Water",
Water = "Seabed|Sub|Water",
Sub = "Water",
Water = "Water",
},
FiringTolerance = 2,
Label = "AntiTorpedo01",
Expand Down
2 changes: 1 addition & 1 deletion units/XRS0205/XRS0205_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ UnitBlueprint{
},
DisableWhileReloading = true,
DisplayName = "Anti-Torpedo Flare",
FireTargetLayerCapsTable = { Water = "Seabed|Sub|Water" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 2,
Label = "AntiTorpedo",
MaxRadius = 30,
Expand Down
2 changes: 1 addition & 1 deletion units/XSB2205/XSB2205_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Ajellu Anti-Torpedo Defense",
DisableWhileReloading = true,
FireTargetLayerCapsTable = { Water = "Seabed|Sub|Water" },
FireTargetLayerCapsTable = { Water = "Water" },
FiringTolerance = 10,
Label = "AjelluTorpedoDefense",
LeadTarget = false,
Expand Down
Loading

0 comments on commit 64d4e4a

Please sign in to comment.