Skip to content

Commit

Permalink
Fix the launch event of a Billy being synced to the UI of enemies/neu…
Browse files Browse the repository at this point in the history
…trals(#6546)

The launch event would not show by default for enemy/neutral players. However, if the information is available to the UI then all it takes is a single rogue UI mod to override the logic and show it anyway. Now the data is simply not available in the UI for enemy and neutral players.
  • Loading branch information
lL1l1 authored Nov 30, 2024
1 parent 0971d51 commit 18fab3c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/fix.6546.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6546) Fix an exploit that allows being notified of enemy Billy nuke launches.
8 changes: 2 additions & 6 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 16 additions & 8 deletions lua/sim/weapons/DefaultProjectileWeapon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 18fab3c

Please sign in to comment.