@@ -41,11 +41,15 @@ for wid = 1, #WeaponDefs do
4141 damageMult = wcp .disarmdamagemult ,
4242 normalDamage = 1 - (wcp .disarmdamageonly or 0 ),
4343 disarmTimer = wcp .disarmtimer * FRAMES_PER_SECOND ,
44+ overstunTime = wcp .overstun_time * FRAMES_PER_SECOND ,
4445 }
4546 wantedWeaponList [# wantedWeaponList + 1 ] = wid
4647 elseif wd .paralyzer or wd .customParams .extra_damage then
4748 local paraTime = wd .paralyzer and wd .customParams .emp_paratime or wd .customParams .extra_paratime
48- paraWeapons [wid ] = paraTime * FRAMES_PER_SECOND
49+ paraWeapons [wid ] = {
50+ empTime = paraTime * FRAMES_PER_SECOND ,
51+ overstunTime = wcp .overstun_time * FRAMES_PER_SECOND ,
52+ }
4953 wantedWeaponList [# wantedWeaponList + 1 ] = wid
5054 end
5155 if wd .customParams and wd .customParams .overstun_damage_mult then
@@ -128,7 +132,7 @@ local function moveUnitID(unitID, byFrame, byUnitID, frame, extraParamFrames)
128132 Spring .SetUnitRulesParam (unitID , " disarmframe" , frame + extraParamFrames , LOS_ACCESS )
129133end
130134
131- local function addParalysisDamageToUnit (unitID , damage , pTime , overstunMult )
135+ local function addParalysisDamageToUnit (unitID , damage , pTime , overstunTime , overstunMult )
132136 local health , maxHealth , paralyzeDamage = Spring .GetUnitHealth (unitID )
133137 if partialUnitID [unitID ] then -- if the unit is partially paralysed
134138 local extraTime = math.floor (damage / health * DECAY_FRAMES ) -- time that the damage would add
@@ -152,6 +156,10 @@ local function addParalysisDamageToUnit(unitID, damage, pTime, overstunMult)
152156 local newPara = paraUnitID [unitID ].frameID
153157 if (not pTime ) or pTime > newPara - f then -- if the para time on the unit is less than this weapons para timer
154158 newPara = newPara + extraTime
159+ if overstunTime and overstunTime > 0 then
160+ -- Overstun allows units to extend the stun near their stun threshold, usally by 1 second.
161+ pTime = math.max (pTime , math.min (pTime , paraUnitID [unitID ].frameID - f ) + overstunTime )
162+ end
155163 if pTime and pTime < newPara - f then -- prevent going over para time
156164 newPara = math.floor (pTime ) + f
157165 end
@@ -214,7 +222,7 @@ function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer,
214222
215223 if disarmWeapons [weaponDefID ] then
216224 local def = disarmWeapons [weaponDefID ]
217- addParalysisDamageToUnit (unitID , damage * def .damageMult , def .disarmTimer , overstunDamageMult [weaponDefID ])
225+ addParalysisDamageToUnit (unitID , damage * def .damageMult , def .disarmTimer , def . overstunTime , overstunDamageMult [weaponDefID ])
218226
219227 if GG .Awards and GG .Awards .AddAwardPoints then
220228 local _ , maxHP = Spring .GetUnitHealth (unitID )
@@ -226,7 +234,8 @@ function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer,
226234 end
227235
228236 if paralyzer and (partialUnitID [unitID ] or paraUnitID [unitID ]) then
229- addParalysisDamageToUnit (unitID , damage , paraWeapons [weaponDefID ], overstunDamageMult [weaponDefID ])
237+ local def = paraWeapons [weaponDefID ]
238+ addParalysisDamageToUnit (unitID , damage , def .empTime , def .overstunTime , overstunDamageMult [weaponDefID ])
230239 end
231240 return damage
232241end
0 commit comments