@@ -234,7 +234,7 @@ local function UpdatePausedReload(unitID, unitDefID, gameFrame)
234234 end
235235end
236236
237- local function UpdateWeapons (unitID , unitDefID , weaponMods , speedFactor , rangeChange , rangeFactor , projSpeedFactor , projectilesFactor , damageFactor , minSpray , gameFrame )
237+ local function UpdateWeapons (unitID , unitDefID , weaponMods , speedFactor , rangeUpdateRequired , rangeFactor , projSpeedFactor , projectilesFactor , damageFactor , minSpray , gameFrame )
238238 if not origUnitWeapons [unitDefID ] then
239239 local ud = UnitDefs [unitDefID ]
240240
@@ -320,13 +320,13 @@ local function UpdateWeapons(unitID, unitDefID, weaponMods, speedFactor, rangeCh
320320 local sprayAngle = math.max (w .sprayAngle , minSpray )
321321 spSetUnitWeaponState (unitID , i , " sprayAngle" , sprayAngle )
322322
323- if w .projectileSpeed and not projectileSpeedLock [unitID ] then
324- local moddedSpeed = w .projectileSpeed * ((weaponMods and weaponMods [i ] and weaponMods [i ].projSpeedMult ) or 1 )* projSpeedFactor
325- spSetUnitWeaponState (unitID , i , " projectileSpeed" , moddedSpeed )
326- end
327-
328323 spSetUnitWeaponState (unitID , i , " projectiles" , moddedProjectiles )
329- if rangeChange and not rangeUpdater [unitID ] then
324+ if rangeUpdateRequired and not rangeUpdater [unitID ] then
325+ if w .projectileSpeed and not projectileSpeedLock [unitID ] then
326+ -- Changing projectile speed without subsequently setting range causes some weapons to go to zero range. Eg Scorcher
327+ local moddedSpeed = w .projectileSpeed * ((weaponMods and weaponMods [i ] and weaponMods [i ].projSpeedMult ) or 1 )* projSpeedFactor
328+ spSetUnitWeaponState (unitID , i , " projectileSpeed" , moddedSpeed )
329+ end
330330 local moddedRange = w .range * ((weaponMods and weaponMods [i ] and weaponMods [i ].rangeMult ) or 1 )* rangeFactor
331331 spSetUnitWeaponState (unitID , i , " range" , moddedRange )
332332 spSetUnitWeaponDamages (unitID , i , " dynDamageRange" , moddedRange )
@@ -346,7 +346,7 @@ local function UpdateWeapons(unitID, unitDefID, weaponMods, speedFactor, rangeCh
346346 end
347347 end
348348
349- if rangeChange then
349+ if rangeUpdateRequired then
350350 if rangeUpdater [unitID ] and rangeUpdater [unitID ] ~= true then
351351 local mods = {}
352352 for i = 1 , state .weaponCount do
@@ -759,7 +759,7 @@ local function UpdateUnitAttributes(unitID, attTypeMap)
759759 local healthChanges = (currentHealthAdd [unitID ] or 0 ) ~= healthAdd
760760 or (currentHealthMult [unitID ] or 1 ) ~= healthMult
761761
762- local rangeChange = (currentRange [unitID ] or 1 ) ~= rangeMult
762+ local rangeUpdateRequired = (currentRange [unitID ] or 1 ) ~= rangeMult or ( currentProjectiles [ unitID ] or 1 ) ~= projectilesMult
763763 local weaponChanges = (currentReload [unitID ] or 1 ) ~= reloadMult
764764 or (currentRange [unitID ] or 1 ) ~= rangeMult
765765 or (currentProjectiles [unitID ] or 1 ) ~= projectilesMult
@@ -794,7 +794,7 @@ local function UpdateUnitAttributes(unitID, attTypeMap)
794794 end
795795
796796 if weaponSpecificMods or weaponChanges then
797- UpdateWeapons (unitID , unitDefID , weaponSpecificMods , reloadMult , rangeChange , rangeMult , projSpeedMult , projectilesMult , damageMult , minSpray , frame )
797+ UpdateWeapons (unitID , unitDefID , weaponSpecificMods , reloadMult , rangeUpdateRequired , rangeMult , projSpeedMult , projectilesMult , damageMult , minSpray , frame )
798798 currentReload [unitID ] = reloadMult
799799 currentRange [unitID ] = rangeMult
800800 currentProjSpeed [unitID ] = projSpeedMult
0 commit comments