Skip to content

Commit d429d83

Browse files
committed
Knight buff as well as the EMP buff.
* EMP damage 600 -> 750 Implemented overstun for disarm and for the disarm-emp interaction. Removed the missing health multiplier from EMP award. Eg a unit shooting at a unit on 5% health would be awarded 20x the emp damage.
1 parent dfb0e2e commit d429d83

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

LuaRules/Gadgets/awards.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,8 @@ function gadget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weap
428428
local costdamage = (damage / maxHP) * GetUnitCost(unitID, unitDefID)
429429

430430
if not spAreTeamsAllied(attackerTeam, unitTeam) then
431-
if paralyzer then
432-
AddAwardPoints( 'emp', attackerTeam, costdamage )
433-
elseif attackerDefID then
431+
if attackerDefID and not paralyzer then
432+
-- Paralysis gadget adds emp award
434433
if unitDefID == chickenflyerqueenDefID or unitDefID == chickenlandqueenDefID then
435434
AddAwardPoints( 'heart', attackerTeam, damage )
436435
end

LuaRules/Gadgets/unit_boolean_disable.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
129133
end
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
232241
end

LuaRules/Gadgets/unit_paralysis_damage.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ end
2222
local spGetUnitHealth = Spring.GetUnitHealth
2323
local spGetUnitArmored = Spring.GetUnitArmored
2424
local spAddUnitDamage = Spring.AddUnitDamage
25+
local GetUnitCost = Spring.Utilities.GetUnitCost
2526

2627
local DECAY_SECONDS = 40 -- how long it takes to decay 100% para to 0
2728

@@ -82,21 +83,25 @@ local function GetStunDamage(weaponDefID, damage, health, maxHealth, paralyzeDam
8283
return damageGap + (rawDamage - damageGap)*overstunDamageMult[weaponDefID]
8384
end
8485

85-
function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer,
86+
function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, rawDamage, paralyzer,
8687
weaponDefID, attackerID, attackerDefID, attackerTeam)
8788
if paralyzer then -- the weapon deals paralysis damage
8889
local health, maxHealth, paralyzeDamage = spGetUnitHealth(unitID)
8990
if health and maxHealth and health > 0 then -- taking no chances.
90-
local damage = GetStunDamage(weaponDefID, damage, health, maxHealth, paralyzeDamage)
91+
if GG.Awards and GG.Awards.AddAwardPoints then
92+
local cost_emped = (rawDamage / maxHealth) * GetUnitCost(unitID)
93+
GG.Awards.AddAwardPoints('emp', attackerTeam, cost_emped)
94+
end
95+
local damage = GetStunDamage(weaponDefID, rawDamage, health, maxHealth, paralyzeDamage)
9196
if overstunTime[weaponDefID] > 0 then
92-
-- Overstun allows units to stun for an addition time (usually 1 second) if the current stun time on the unit is within that range.
97+
-- Overstun allows units to extend the stun near their stun threshold, usally by 1 second.
9398
local currentStunTime = (paralyzeDamage/maxHealth - 1) * DECAY_SECONDS
9499
local maxTime = math.max(paraTime[weaponDefID], math.min(paraTime[weaponDefID], currentStunTime) + overstunTime[weaponDefID])
95100
-- Solve the following for damage to limit damage by stun time:
96101
-- stun time = ((damage + paralyzeDamage)/maxHealth - 1) * DECAY_SECONDS
97-
damage = (maxTime/DECAY_SECONDS + 1)*maxHealth - paralyzeDamage
102+
damage = math.min(damage, (maxTime/DECAY_SECONDS + 1)*maxHealth - paralyzeDamage)
98103
end
99-
--Spring.Echo("damage", damage, ((damage + paralyzeDamage)/maxHealth - 1) * DECAY_SECONDS, paralyzeDamage, math.random())
104+
--Spring.Echo("damage", damage, ((damage + paralyzeDamage)/maxHealth - 1) * DECAY_SECONDS, paralyzeDamage, WeaponDefs[weaponDefID].damages.paralyzeDamageTime, math.random())
100105
return damage
101106
end
102107
end

units/cloakassault.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ return { cloakassault = {
7676
craterMult = 0,
7777

7878
customParams = {
79-
extra_damage = 600,
79+
extra_damage = 750,
8080

8181
light_camera_height = 1600,
8282
light_color = [[0.85 0.85 1.2]],

0 commit comments

Comments
 (0)