diff --git a/changelog/snippets/fix.6546.md b/changelog/snippets/fix.6546.md new file mode 100644 index 0000000000..52c07bf551 --- /dev/null +++ b/changelog/snippets/fix.6546.md @@ -0,0 +1 @@ +- (#6546) Fix an exploit that allows being notified of enemy Billy nuke launches. diff --git a/lua/sim/Unit.lua b/lua/sim/Unit.lua index 6482b12186..bbe6a3ab48 100644 --- a/lua/sim/Unit.lua +++ b/lua/sim/Unit.lua @@ -2156,14 +2156,10 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni return end - local bp = self.Blueprint.Audio + local bp = self.Blueprint.Audio.NuclearLaunchDetected if bp then for num, aiBrain in ArmyBrains do - local factionIndex = aiBrain:GetFactionIndex() - - if bp['NuclearLaunchDetected'] then - aiBrain:NuclearLaunchDetected(bp['NuclearLaunchDetected']) - end + aiBrain:NuclearLaunchDetected(bp) end end end, diff --git a/lua/sim/weapons/DefaultProjectileWeapon.lua b/lua/sim/weapons/DefaultProjectileWeapon.lua index 9bfcb7f524..40a6821df4 100644 --- a/lua/sim/weapons/DefaultProjectileWeapon.lua +++ b/lua/sim/weapons/DefaultProjectileWeapon.lua @@ -1058,18 +1058,26 @@ DefaultProjectileWeapon = ClassWeapon(Weapon) { -- Decrement the ammo if they are a counted projectile if proj and not proj:BeenDestroyed() and countedProjectile then if bp.NukeWeapon then + -- Play the "Strategic launch detected" VO to all armies unit:NukeCreatedAtUnit() unit:RemoveNukeSiloAmmo(1) + -- Generate UI notification for automatic nuke ping - local launchData = { - army = self.Army - 1, - location = (GetFocusArmy() == -1 or IsAlly(self.Army, GetFocusArmy())) and - self:GetCurrentTargetPos() or nil - } - if not Sync.NukeLaunchData then - Sync.NukeLaunchData = {} + -- Enemies receive the notification without location data to avoid cheats, while still being notified visually instead of only by audio + + local isObsOrAlly = GetFocusArmy() == -1 or IsAlly(self.Army, GetFocusArmy()) + + -- the global VO plays only when the audio exists, so notify enemies if it exists + if isObsOrAlly or unit.Blueprint.Audio.NuclearLaunchDetected ~= nil then + local launchData = { + army = self.Army - 1, + location = isObsOrAlly and self:GetCurrentTargetPos() or nil + } + if not Sync.NukeLaunchData then + Sync.NukeLaunchData = {} + end + table.insert(Sync.NukeLaunchData, launchData) end - table.insert(Sync.NukeLaunchData, launchData) else unit:RemoveTacticalSiloAmmo(1) end