From bd282b5be4449a09d84fafcaddcfc750a968580e Mon Sep 17 00:00:00 2001 From: Steel_Blue Date: Mon, 20 Jul 2026 18:24:40 -0400 Subject: [PATCH 1/2] Hide odin technical range in LUS fix for https://github.com/ZeroK-RTS/Zero-K/issues/5587 --- scripts/bomberassault.lua | 30 ++++++++++++++++++++++++++++-- units/bomberassault.lua | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/scripts/bomberassault.lua b/scripts/bomberassault.lua index c0c945e912..9ba6525910 100644 --- a/scripts/bomberassault.lua +++ b/scripts/bomberassault.lua @@ -28,6 +28,19 @@ include "constants.lua" local manualTarget_p1 = false local manualTarget_p2 = false local manualTarget_p3 = false +local rangeChanged = false +local THERMITE_BOMB_ID +local FAKE_WEAPON_ID +for i = 1, #UnitDefs[unitDefID].weapons do + local weaponName = WeaponDefs[UnitDefs[unitDefID].weapons[i].weaponDef].name + if weaponName == "bomberassault_thermite_bomb" then + THERMITE_BOMB_ID = i + end + if weaponName == "bomberassault_zeppelin_bomb" then + FAKE_WEAPON_ID = i + end +end +local THERMITE_BOMB_RANGE = Spring.GetUnitWeaponState(unitID, FAKE_WEAPON_ID, "range") function ReammoComplete() Show(bomb) @@ -129,10 +142,23 @@ function script.FireWeapon(num) end function script.BlockShot(num, targetID) - if num == 1 or (num == manualfireWeapon and not IsManualFireTargetValid()) then + if num == 1 or + (num == manualfireWeapon and not IsManualFireTargetValid()) or + (GetUnitValue(COB.CRASHING) == 1) or RearmBlockShot() then return true end - return (GetUnitValue(COB.CRASHING) == 1) or RearmBlockShot() + if num == THERMITE_BOMB_ID then + rangeChanged = true + Spring.SetUnitWeaponState(unitID, THERMITE_BOMB_ID, "range", 9001) -- large so noExplode doesn't remove projectile due to vertical drop distance + end + return false +end + +function script.EndBurst() + if rangeChanged then + rangeChanged = false + Spring.SetUnitWeaponState(unitID, THERMITE_BOMB_ID, "range", THERMITE_BOMB_RANGE) + end end function script.Killed(recentDamage, maxHealth) diff --git a/units/bomberassault.lua b/units/bomberassault.lua index 4ae77ea012..25f3f6dba8 100644 --- a/units/bomberassault.lua +++ b/units/bomberassault.lua @@ -152,7 +152,7 @@ return { bomberassault = { myGravity = 0.08, noExplode = true, noSelfDamage = true, - range = 3000, -- large so noExplode doesn't remove projectile due to vertical drop distance + range = 180, -- dynamically updated in LUS so noExplode doesn't remove projectile due to vertical drop distance reloadtime = 2, size = 0.01, soundStart = [[explosion/ex_large9]], From da1581deb1cba8ec92f22482c0619a2de4c1ff34 Mon Sep 17 00:00:00 2001 From: Steel_Blue Date: Tue, 21 Jul 2026 22:02:32 -0400 Subject: [PATCH 2/2] Unhide odin technical range back to unitdef - in weapondef customparams.fake_range_override - assorted cleanup --- scripts/bomberassault.lua | 27 ++++++++++++++------------- units/bomberassault.lua | 3 ++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/scripts/bomberassault.lua b/scripts/bomberassault.lua index 9ba6525910..3fb092339c 100644 --- a/scripts/bomberassault.lua +++ b/scripts/bomberassault.lua @@ -29,18 +29,18 @@ local manualTarget_p1 = false local manualTarget_p2 = false local manualTarget_p3 = false local rangeChanged = false -local THERMITE_BOMB_ID -local FAKE_WEAPON_ID +local THERMITE_NUM, FAKE_GUN_NUM, THERMITE_TRUERANGE, THERMITE_ALT_RANGE for i = 1, #UnitDefs[unitDefID].weapons do - local weaponName = WeaponDefs[UnitDefs[unitDefID].weapons[i].weaponDef].name - if weaponName == "bomberassault_thermite_bomb" then - THERMITE_BOMB_ID = i + local weapondef = WeaponDefs[UnitDefs[unitDefID].weapons[i].weaponDef] + if weapondef == WeaponDefNames["bomberassault_thermite_bomb"] then + THERMITE_NUM = i + THERMITE_TRUERANGE = weapondef.customParams.truerange + THERMITE_ALT_RANGE = weapondef.customParams.fakerange end - if weaponName == "bomberassault_zeppelin_bomb" then - FAKE_WEAPON_ID = i + if weapondef == WeaponDefNames["bomberassault_zeppelin_bomb"] then + FAKE_GUN_NUM = i end end -local THERMITE_BOMB_RANGE = Spring.GetUnitWeaponState(unitID, FAKE_WEAPON_ID, "range") function ReammoComplete() Show(bomb) @@ -142,14 +142,15 @@ function script.FireWeapon(num) end function script.BlockShot(num, targetID) - if num == 1 or + if num == FAKE_GUN_NUM or (num == manualfireWeapon and not IsManualFireTargetValid()) or - (GetUnitValue(COB.CRASHING) == 1) or RearmBlockShot() then + (GetUnitValue(COB.CRASHING) == 1) or + RearmBlockShot() then return true end - if num == THERMITE_BOMB_ID then + if num == THERMITE_NUM then rangeChanged = true - Spring.SetUnitWeaponState(unitID, THERMITE_BOMB_ID, "range", 9001) -- large so noExplode doesn't remove projectile due to vertical drop distance + Spring.SetUnitWeaponState(unitID, THERMITE_NUM, "range", THERMITE_ALT_RANGE) end return false end @@ -157,7 +158,7 @@ end function script.EndBurst() if rangeChanged then rangeChanged = false - Spring.SetUnitWeaponState(unitID, THERMITE_BOMB_ID, "range", THERMITE_BOMB_RANGE) + Spring.SetUnitWeaponState(unitID, THERMITE_NUM, "range", THERMITE_TRUERANGE) end end diff --git a/units/bomberassault.lua b/units/bomberassault.lua index 25f3f6dba8..89ac0f8fb3 100644 --- a/units/bomberassault.lua +++ b/units/bomberassault.lua @@ -124,6 +124,7 @@ return { bomberassault = { stats_hide_damage = 1, damage_vs_feature = 20, -- Doesn't ramp for technical reasons, so this is here to deal some reasonable damage. truerange = 180, + fakerange = 9001, -- range extention to not disappear past trueraange (noExplode interaction) thermite_frames = 900, thermite_dps_start = 0, @@ -152,7 +153,7 @@ return { bomberassault = { myGravity = 0.08, noExplode = true, noSelfDamage = true, - range = 180, -- dynamically updated in LUS so noExplode doesn't remove projectile due to vertical drop distance + range = 180, -- overridden by customparams.truerange reloadtime = 2, size = 0.01, soundStart = [[explosion/ex_large9]],