Skip to content

Commit 4bd5de4

Browse files
committed
Unhide odin technical range back to unitdef
- in weapondef customparams.fake_range_override - assorted cleanup
1 parent bd282b5 commit 4bd5de4

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

scripts/bomberassault.lua

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ local manualTarget_p1 = false
2929
local manualTarget_p2 = false
3030
local manualTarget_p3 = false
3131
local rangeChanged = false
32-
local THERMITE_BOMB_ID
33-
local FAKE_WEAPON_ID
32+
local THERMITE_NUM, FAKE_GUN_NUM, THERMITE_TRUERANGE, THERMITE_RANGE_OVERRIDE
3433
for i = 1, #UnitDefs[unitDefID].weapons do
35-
local weaponName = WeaponDefs[UnitDefs[unitDefID].weapons[i].weaponDef].name
36-
if weaponName == "bomberassault_thermite_bomb" then
37-
THERMITE_BOMB_ID = i
34+
local weapondef = WeaponDefs[UnitDefs[unitDefID].weapons[i].weaponDef]
35+
if weapondef == WeaponDefNames["bomberassault_thermite_bomb"] then
36+
THERMITE_NUM = i
37+
THERMITE_TRUERANGE = weapondef.customParams.truerange
38+
THERMITE_RANGE_OVERRIDE = weapondef.customParams.fake_range_override
3839
end
39-
if weaponName == "bomberassault_zeppelin_bomb" then
40-
FAKE_WEAPON_ID = i
40+
if weapondef == WeaponDefNames["bomberassault_zeppelin_bomb"] then
41+
FAKE_GUN_NUM = i
4142
end
4243
end
43-
local THERMITE_BOMB_RANGE = Spring.GetUnitWeaponState(unitID, FAKE_WEAPON_ID, "range")
4444

4545
function ReammoComplete()
4646
Show(bomb)
@@ -142,22 +142,23 @@ function script.FireWeapon(num)
142142
end
143143

144144
function script.BlockShot(num, targetID)
145-
if num == 1 or
145+
if num == FAKE_GUN_NUM or
146146
(num == manualfireWeapon and not IsManualFireTargetValid()) or
147-
(GetUnitValue(COB.CRASHING) == 1) or RearmBlockShot() then
147+
(GetUnitValue(COB.CRASHING) == 1) or
148+
RearmBlockShot() then
148149
return true
149150
end
150-
if num == THERMITE_BOMB_ID then
151+
if num == THERMITE_NUM then
151152
rangeChanged = true
152-
Spring.SetUnitWeaponState(unitID, THERMITE_BOMB_ID, "range", 9001) -- large so noExplode doesn't remove projectile due to vertical drop distance
153+
Spring.SetUnitWeaponState(unitID, THERMITE_NUM, "range", THERMITE_RANGE_OVERRIDE)
153154
end
154155
return false
155156
end
156157

157158
function script.EndBurst()
158159
if rangeChanged then
159160
rangeChanged = false
160-
Spring.SetUnitWeaponState(unitID, THERMITE_BOMB_ID, "range", THERMITE_BOMB_RANGE)
161+
Spring.SetUnitWeaponState(unitID, THERMITE_NUM, "range", THERMITE_TRUERANGE)
161162
end
162163
end
163164

units/bomberassault.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ return { bomberassault = {
124124
stats_hide_damage = 1,
125125
damage_vs_feature = 20, -- Doesn't ramp for technical reasons, so this is here to deal some reasonable damage.
126126
truerange = 180,
127+
fake_range_override = 9001, -- range extention to not disappear past trueraange (noExplode interaction)
127128

128129
thermite_frames = 900,
129130
thermite_dps_start = 0,
@@ -152,7 +153,7 @@ return { bomberassault = {
152153
myGravity = 0.08,
153154
noExplode = true,
154155
noSelfDamage = true,
155-
range = 180, -- dynamically updated in LUS so noExplode doesn't remove projectile due to vertical drop distance
156+
range = 180, -- overridden by customparams.truerange
156157
reloadtime = 2,
157158
size = 0.01,
158159
soundStart = [[explosion/ex_large9]],

0 commit comments

Comments
 (0)