@@ -21,9 +21,13 @@ if IsServer() then
21
21
if not modifier_charges then
22
22
modifier_charges = caster :AddNewModifier ( self :GetCaster (), self , " modifier_sohei_dash_charges" , {} )
23
23
modifier_charges :SetStackCount ( chargesMax )
24
- elseif modifier_charges :GetStackCount () < chargesMax then
24
+ elseif modifier_charges :GetStackCount () < chargesMax then
25
+ -- Reset the cooldown on the modifier
25
26
modifier_charges :SetDuration ( self :GetChargeRefreshTime (), true )
26
- modifier_charges :StartIntervalThink ( 0.1 )
27
+ modifier_charges :StartIntervalThink ( 0.1 )
28
+ if modifier_charges :GetStackCount () < 1 then
29
+ self :StartCooldown ( modifier_charges :GetRemainingTime () )
30
+ end
27
31
end
28
32
end
29
33
@@ -76,16 +80,28 @@ if IsServer() then
76
80
self :EndCooldown ()
77
81
78
82
if modifier_charges and not modifier_charges :IsNull () then
79
- -- Perform the dash if there is at least one charge remaining
80
- if modifier_charges :GetStackCount () >= 1 then
81
- modifier_charges :SetStackCount ( modifier_charges :GetStackCount () - 1 )
82
-
83
- local shortCD = dashDistance / dashSpeed
84
- if self :GetCooldownTimeRemaining () < shortCD then
85
- self :EndCooldown ()
86
- self :StartCooldown ( dashDistance / dashSpeed )
87
- end
88
- end
83
+ -- Perform the dash if there is at least one charge remaining
84
+ local currentStackCount = modifier_charges :GetStackCount ()
85
+ if currentStackCount >= 1 then
86
+ if currentStackCount > 1 then
87
+ -- enable short cooldown if has enough charges for the next dash
88
+ local shortCD = dashDistance / dashSpeed
89
+ if self :GetCooldownTimeRemaining () < shortCD then
90
+ self :EndCooldown ()
91
+ self :StartCooldown ( dashDistance / dashSpeed )
92
+ end
93
+ else
94
+ -- if does not have charges for the next dash, set the cd to the remain time of the modifier
95
+ self :StartCooldown ( modifier_charges :GetRemainingTime () )
96
+ end
97
+ modifier_charges :SetStackCount ( currentStackCount - 1 )
98
+ else
99
+ -- should not enter here, but if it does :
100
+ -- set the cd to the remain time of the modifier
101
+ self :StartCooldown ( modifier_charges :GetRemainingTime () )
102
+ -- and return without performing the spell action (this will still consume resources)
103
+ return
104
+ end
89
105
else
90
106
caster :AddNewModifier ( caster , self , " modifier_sohei_dash_charges" , {
91
107
duration = self :GetChargeRefreshTime ()
0 commit comments