Skip to content

Commit

Permalink
Fix beam damage calculations in the detailed unit view (#6115)
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 committed May 1, 2024
1 parent 63a80ff commit 442c8ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/fix.6115.md
@@ -0,0 +1 @@
- (#6115) Fix damage calculation in the unit view UI for beam weapons with a `BeamCollisionDelay` such as the Zapper's weapon.
6 changes: 4 additions & 2 deletions lua/ui/game/unitviewDetail.lua
Expand Up @@ -12,6 +12,8 @@ local armorDefinition = import("/lua/armordefinition.lua").armordefinition

local controls = import("/lua/ui/controls.lua").Get()

local MathFloor = math.floor

View = controls.View or false
MapView = controls.MapView or false
ViewState = "full"
Expand Down Expand Up @@ -44,7 +46,7 @@ function GetTechLevelString(bp)
end

function FormatTime(seconds)
return string.format("%02d:%02d", math.floor(seconds / 60), math.mod(seconds, 60))
return string.format("%02d:%02d", MathFloor(seconds / 60), math.mod(seconds, 60))
end

function GetAbilityList(bp)
Expand Down Expand Up @@ -565,7 +567,7 @@ function WrapAndPlaceText(bp, builder, descID, control)
Damage = math.max(Damage, info.DamageToShields)
end
if info.BeamLifetime > 0 then
Damage = Damage * (MATH_IRound(10 * info.BeamLifetime) + 1)
Damage = Damage * (1 + MathFloor(MATH_IRound(info.BeamLifetime)/(info.BeamCollisionDelay+0.1)))
else
Damage = Damage * (info.DoTPulses or 1) + (info.InitialDamage or 0)
local ProjectilePhysics = __blueprints[info.ProjectileId].Physics
Expand Down

0 comments on commit 442c8ec

Please sign in to comment.