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

Fix billy nuke launches being synced to UI #6546

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -2154,14 +2154,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
Loading