@@ -29,18 +29,18 @@ local manualTarget_p1 = false
2929local manualTarget_p2 = false
3030local manualTarget_p3 = false
3131local rangeChanged = false
32- local THERMITE_BOMB_ID
33- local FAKE_WEAPON_ID
32+ local THERMITE_NUM , FAKE_GUN_NUM , THERMITE_TRUERANGE , THERMITE_ALT_RANGE
3433for 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_ALT_RANGE = weapondef .customParams .fakerange
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
4243end
43- local THERMITE_BOMB_RANGE = Spring .GetUnitWeaponState (unitID , FAKE_WEAPON_ID , " range" )
4444
4545function ReammoComplete ()
4646 Show (bomb )
@@ -142,22 +142,23 @@ function script.FireWeapon(num)
142142end
143143
144144function 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_ALT_RANGE )
153154 end
154155 return false
155156end
156157
157158function 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
162163end
163164
0 commit comments