Skip to content

Commit

Permalink
Fix UEF SACU fire rate upgrade using inaccurate fire rate value (#6121)
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 committed May 24, 2024
1 parent 47c6861 commit 40446fe
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 35 deletions.
3 changes: 3 additions & 0 deletions changelog/snippets/fix.6121.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- (#6121) Fix UEF SACU fire rate upgrade using inaccurate fire rate value.

The upgrade displayed 1.82x fire rate, but in fact provided 2x fire rate because of how fire rate is rounded to game ticks.
2 changes: 1 addition & 1 deletion loc/RU/strings_db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@ Unit_Description_0019="Заменяет персональный щит АКБП
Unit_Description_0020="Добавляет радиолокационный глушитель, создающий вокруг АКБП ложные цели на радаре. Бесполезен в зоне действия всеволнового сенсора."
Unit_Description_0021="Увеличивает выработку ресурсов АКБП на 10 материи/сек и 1000 энергии/сек."
Unit_Description_0022="Значительно увеличивает дальность действия сенсоров АКБП."
Unit_Description_0023="Позволяет главному орудию АКБП стрелять в 1,82 раза чаще."
Unit_Description_0023="Позволяет главному орудию АКБП стрелять в 2 раза чаще."
Unit_Description_0024="Усиливает стрельбу АКБП эффектом ударной волны, также значительно увеличивается дальнобойность орудия."
-- UEF -- Land Units
Unit_Description_0025="Быстрая разведывательная машина. Оснащена легким пулеметом и стандартным набором сенсоров."
Expand Down
2 changes: 1 addition & 1 deletion loc/US/strings_db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ Unit_Description_0019="Replaces the SACU's Personal Shield with a Bubble Shield
Unit_Description_0020="Adds a Radar Jammer which creates false radar images. Countered by omni sensors."
Unit_Description_0021="Increases SACU's resource generation by 10 mass per second and 1000 energy per second."
Unit_Description_0022="Greatly expands the range of the standard on-board SACU sensor systems.\n\n+64 Omni Radius\n+15 Vision Radius"
Unit_Description_0023="Primary weapon now fires 1.82 times as fast.\n\n+82% Rate of Fire"
Unit_Description_0023="Primary weapon now fires twice as fast.\n\n+100% Rate of Fire"
Unit_Description_0024="Equips the standard SACU Cannon with Area-Of-Effect damage and much higher range.\n\n+10 Main cannon range\n+2 Main cannon damage radius"

-- UEF -- Land Units
Expand Down
113 changes: 81 additions & 32 deletions tests/blueprint/unit.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,48 @@ end

-------------------------------------------------------------------------------


-- The game runs in ticks and therefore not every rate of
-- fire is possible. The game will round the rate of fire,
-- but as a result minor changes may not always have an
-- actual impact in-game. These tests guarantee that when
-- a rate of fire is adjusted that it is always the actual
-- rate of fire that the game uses.
---@param rateOfFire number
local function rateOfFireTest(rateOfFire)
return function()
luft.expect(rateOfFire).to.be.number()

if rateOfFire > 6.6666 then
luft.expect(rateOfFire).to.be.close.to(10)
elseif rateOfFire > 4.0 then
luft.expect(rateOfFire).to.be.close.to(5)
elseif rateOfFire > 2.8571 then
luft.expect(rateOfFire).to.be.close.to(3.333)
elseif rateOfFire > 2.2222 then
luft.expect(rateOfFire).to.be.close.to(2.5)
elseif rateOfFire > 1.8182 then
luft.expect(rateOfFire).to.be.close.to(2.0)
elseif rateOfFire > 1.5384 then
luft.expect(rateOfFire).to.be.close.to(1.666)
elseif rateOfFire > 1.3333 then
luft.expect(rateOfFire).to.be.close.to(1.428)
elseif rateOfFire > 1.1765 then
luft.expect(rateOfFire).to.be.close.to(1.25)
elseif rateOfFire > 1.0526 then
luft.expect(rateOfFire).to.be.close.to(1.111)
elseif rateOfFire > 0.9524 then
luft.expect(rateOfFire).to.be.close.to(1.0)
elseif rateOfFire > 0.8696 then
luft.expect(rateOfFire).to.be.close.to(0.909)
elseif rateOfFire > 0.8 then
luft.expect(rateOfFire).to.be.close.to(0.833)
elseif rateOfFire > 0.7407 then
luft.expect(rateOfFire).to.be.close.to(0.769)
end
end
end

-- this file is generated by the bash script that runs the test
dofile("./tests/generated/unit-blueprint-list.lua")

Expand Down Expand Up @@ -279,38 +321,45 @@ luft.describe(
if rateOfFire then
luft.test(
"Rate of fire",
function()

luft.expect(rateOfFire).to.be.number()

if rateOfFire > 6.6666 then
luft.expect(rateOfFire).to.be.close.to(10)
elseif rateOfFire > 4.0 then
luft.expect(rateOfFire).to.be.close.to(5)
elseif rateOfFire > 2.8571 then
luft.expect(rateOfFire).to.be.close.to(3.333)
elseif rateOfFire > 2.2222 then
luft.expect(rateOfFire).to.be.close.to(2.5)
elseif rateOfFire > 1.8182 then
luft.expect(rateOfFire).to.be.close.to(2.0)
elseif rateOfFire > 1.5384 then
luft.expect(rateOfFire).to.be.close.to(1.666)
elseif rateOfFire > 1.3333 then
luft.expect(rateOfFire).to.be.close.to(1.428)
elseif rateOfFire > 1.1765 then
luft.expect(rateOfFire).to.be.close.to(1.25)
elseif rateOfFire > 1.0526 then
luft.expect(rateOfFire).to.be.close.to(1.111)
elseif rateOfFire > 0.9524 then
luft.expect(rateOfFire).to.be.close.to(1.0)
elseif rateOfFire > 0.8696 then
luft.expect(rateOfFire).to.be.close.to(0.909)
elseif rateOfFire > 0.8 then
luft.expect(rateOfFire).to.be.close.to(0.833)
elseif rateOfFire > 0.7407 then
luft.expect(rateOfFire).to.be.close.to(0.769)
end
end
rateOfFireTest(rateOfFire)
)
end

--#endregion

end
)
end

if unitBlueprint.Enhancements then
local enhancements = {}
for enhancementKey, enhancement in pairs(unitBlueprint.Enhancements) do
enhancements[enhancementKey] = enhancement
end

luft.describe_each(
"Enhancement %s",
enhancements,

---@param name string
---@param enhancementBlueprint UnitBlueprintEnhancement
function(name, enhancementBlueprint)

-----------------------------------------------------------
--#region Rate of fire limitations

-- The game runs in ticks and therefore not every rate of
-- fire is possible. The game will round the rate of fire,
-- but as a result minor changes may not always have an
-- actual impact in-game. These tests guarantee that when
-- a rate of fire is adjusted that it is always the actual
-- rate of fire that the game uses.

local rateOfFire = enhancementBlueprint.NewRateOfFire
if rateOfFire then
luft.test(
"New Rate of fire",
rateOfFireTest(rateOfFire)
)
end

Expand Down
2 changes: 1 addition & 1 deletion units/UEL0301/UEL0301_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ UnitBlueprint{
BuildTime = 5040,
Icon = "acu",
Name = "<LOC enhancements_0061>Energy Accelerator",
NewRateOfFire = 1.82,
NewRateOfFire = 2,
Slot = "LCH",
UpgradeUnitAmbientBones = { "UEL0301" },
},
Expand Down

0 comments on commit 40446fe

Please sign in to comment.