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 UnitViewDetail beam damage calculation #6115

Merged
merged 5 commits into from May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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