warscript 0.0.1-dev.a3723da → 0.0.1-dev.a3deff8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/attributes.d.ts +6 -0
  2. package/attributes.lua +17 -1
  3. package/binaryreader.d.ts +1 -0
  4. package/binaryreader.lua +3 -0
  5. package/config.d.ts +5 -0
  6. package/config.lua +10 -0
  7. package/core/types/effect.d.ts +14 -6
  8. package/core/types/effect.lua +131 -35
  9. package/core/types/frame.d.ts +6 -0
  10. package/core/types/frame.lua +115 -22
  11. package/core/types/player.d.ts +15 -0
  12. package/core/types/player.lua +56 -14
  13. package/core/types/playerCamera.d.ts +2 -0
  14. package/core/types/playerCamera.lua +123 -5
  15. package/core/types/sound.d.ts +17 -24
  16. package/core/types/sound.lua +99 -24
  17. package/core/types/tileCell.d.ts +9 -0
  18. package/core/types/tileCell.lua +92 -0
  19. package/core/types/timer.d.ts +9 -8
  20. package/core/types/timer.lua +45 -23
  21. package/core/util.d.ts +1 -1
  22. package/core/util.lua +18 -1
  23. package/decl/native.d.ts +846 -790
  24. package/engine/behavior.d.ts +7 -2
  25. package/engine/behavior.lua +112 -33
  26. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  27. package/engine/behaviour/ability/always-enabled.lua +31 -0
  28. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  29. package/engine/behaviour/ability/apply-buff.lua +32 -0
  30. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  31. package/engine/behaviour/ability/damage.d.ts +12 -6
  32. package/engine/behaviour/ability/damage.lua +37 -51
  33. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  34. package/engine/behaviour/ability/emulate-impact.lua +43 -0
  35. package/engine/behaviour/ability/heal.d.ts +33 -6
  36. package/engine/behaviour/ability/heal.lua +89 -10
  37. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  38. package/engine/behaviour/ability/instant-impact.lua +4 -19
  39. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  40. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  41. package/engine/behaviour/ability/remove-buffs.d.ts +25 -0
  42. package/engine/behaviour/ability/remove-buffs.lua +49 -0
  43. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  44. package/engine/behaviour/ability/restore-mana.lua +6 -6
  45. package/engine/behaviour/ability.d.ts +20 -4
  46. package/engine/behaviour/ability.lua +111 -47
  47. package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
  48. package/engine/behaviour/unit/stun-immunity.lua +52 -27
  49. package/engine/behaviour/unit.d.ts +39 -0
  50. package/engine/behaviour/unit.lua +210 -4
  51. package/engine/buff.d.ts +110 -42
  52. package/engine/buff.lua +499 -208
  53. package/engine/internal/ability.d.ts +23 -14
  54. package/engine/internal/ability.lua +129 -85
  55. package/engine/internal/item/ability.lua +162 -4
  56. package/engine/internal/item+owner.lua +12 -6
  57. package/engine/internal/item.d.ts +20 -19
  58. package/engine/internal/item.lua +191 -74
  59. package/engine/internal/mechanics/ability-duration.lua +1 -1
  60. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  61. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  62. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  63. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  64. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  65. package/engine/internal/misc/frame-coordinates.lua +21 -0
  66. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  67. package/engine/internal/misc/get-terrain-z.lua +11 -0
  68. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  69. package/engine/internal/misc/player-local-handle.lua +5 -0
  70. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  71. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  72. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  73. package/engine/internal/object-data/evasion-probability.lua +16 -0
  74. package/engine/internal/unit/ability.d.ts +45 -1
  75. package/engine/internal/unit/ability.lua +128 -17
  76. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  77. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  78. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  79. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  80. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  81. package/engine/internal/unit/allowed-targets.lua +9 -1
  82. package/engine/internal/unit/bonus.d.ts +6 -2
  83. package/engine/internal/unit/bonus.lua +23 -1
  84. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  85. package/engine/internal/unit/ignore-events-items.lua +5 -0
  86. package/engine/internal/unit/item.d.ts +24 -0
  87. package/engine/internal/unit/item.lua +78 -0
  88. package/engine/internal/unit/main-selected.d.ts +13 -0
  89. package/engine/internal/unit/main-selected.lua +36 -0
  90. package/engine/internal/unit/order.d.ts +20 -0
  91. package/engine/internal/unit/order.lua +136 -0
  92. package/engine/internal/unit+ability.lua +12 -3
  93. package/engine/internal/unit+damage.d.ts +2 -11
  94. package/engine/internal/unit+damage.lua +10 -14
  95. package/engine/internal/unit+spellSteal.lua +1 -2
  96. package/engine/internal/unit-missile-launch.lua +63 -13
  97. package/engine/internal/unit.d.ts +63 -18
  98. package/engine/internal/unit.lua +437 -163
  99. package/engine/internal/utility.lua +12 -0
  100. package/engine/lightning.d.ts +12 -5
  101. package/engine/lightning.lua +48 -14
  102. package/engine/local-client.d.ts +9 -2
  103. package/engine/local-client.lua +112 -0
  104. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  105. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  106. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  107. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  108. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  109. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  110. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  111. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  112. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  113. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  114. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  115. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  116. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  117. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  118. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  119. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  120. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  121. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  122. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  123. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  124. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  125. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  126. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  127. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  128. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  129. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  130. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  131. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  132. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  133. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  134. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  135. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  136. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  137. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  138. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  139. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  140. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  141. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  142. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  143. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  144. package/engine/object-data/entry/ability-type/web.lua +52 -0
  145. package/engine/object-data/entry/ability-type.d.ts +19 -17
  146. package/engine/object-data/entry/ability-type.lua +93 -36
  147. package/engine/object-data/entry/buff-type/applicable.lua +18 -37
  148. package/engine/object-data/entry/buff-type.d.ts +6 -12
  149. package/engine/object-data/entry/buff-type.lua +13 -29
  150. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  151. package/engine/object-data/entry/item-type.d.ts +15 -1
  152. package/engine/object-data/entry/item-type.lua +93 -2
  153. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  154. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  155. package/engine/object-data/entry/sound-preset.lua +140 -0
  156. package/engine/object-data/entry/unit-type.d.ts +21 -5
  157. package/engine/object-data/entry/unit-type.lua +214 -93
  158. package/engine/object-data/entry/upgrade.d.ts +1 -1
  159. package/engine/object-data/entry/upgrade.lua +4 -4
  160. package/engine/object-data/entry.d.ts +16 -14
  161. package/engine/object-data/entry.lua +60 -32
  162. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  163. package/engine/object-field/ability.d.ts +28 -5
  164. package/engine/object-field/ability.lua +59 -5
  165. package/engine/object-field/unit.d.ts +57 -3
  166. package/engine/object-field/unit.lua +207 -7
  167. package/engine/object-field.d.ts +23 -6
  168. package/engine/object-field.lua +303 -114
  169. package/engine/random.d.ts +9 -0
  170. package/engine/random.lua +13 -0
  171. package/engine/standard/entries/buff-type.d.ts +3 -0
  172. package/engine/standard/entries/buff-type.lua +3 -0
  173. package/engine/standard/entries/sound-preset.d.ts +10 -0
  174. package/engine/standard/entries/sound-preset.lua +10 -0
  175. package/engine/standard/fields/ability.d.ts +2 -0
  176. package/engine/standard/fields/ability.lua +2 -0
  177. package/engine/standard/fields/unit.d.ts +4 -0
  178. package/engine/standard/fields/unit.lua +7 -0
  179. package/engine/synchronization.d.ts +11 -0
  180. package/engine/synchronization.lua +77 -0
  181. package/engine/text-tag.d.ts +36 -2
  182. package/engine/text-tag.lua +250 -10
  183. package/engine/unit.d.ts +4 -0
  184. package/engine/unit.lua +4 -0
  185. package/index.d.ts +1 -0
  186. package/index.lua +1 -0
  187. package/net/socket.d.ts +7 -1
  188. package/net/socket.lua +45 -4
  189. package/network.d.ts +1 -0
  190. package/network.lua +3 -2
  191. package/objutil/buff.lua +3 -4
  192. package/objutil/unit.lua +8 -0
  193. package/package.json +2 -2
  194. package/patch-lua.d.ts +0 -0
  195. package/patch-lua.lua +10 -0
  196. package/patch-lualib.lua +1 -1
  197. package/property.d.ts +55 -0
  198. package/property.lua +374 -0
  199. package/utility/arrays.d.ts +10 -1
  200. package/utility/arrays.lua +45 -3
  201. package/utility/callback-array.d.ts +17 -0
  202. package/utility/callback-array.lua +61 -0
  203. package/utility/functions.d.ts +8 -0
  204. package/utility/functions.lua +13 -0
  205. package/utility/lazy.d.ts +2 -0
  206. package/utility/lazy.lua +14 -0
  207. package/utility/linked-set.d.ts +13 -2
  208. package/utility/linked-set.lua +27 -3
  209. package/utility/lua-maps.d.ts +15 -2
  210. package/utility/lua-maps.lua +53 -2
  211. package/utility/lua-sets.d.ts +2 -0
  212. package/utility/lua-sets.lua +7 -0
  213. package/utility/reflection.lua +11 -7
  214. package/utility/types.d.ts +4 -0
  215. package/core/types/order.d.ts +0 -25
  216. package/core/types/order.lua +0 -55
package/engine/buff.lua CHANGED
@@ -16,6 +16,7 @@ local internalApplyBuff = ____applicable.internalApplyBuff
16
16
  local removeBuff = ____applicable.removeBuff
17
17
  local ____ability = require("engine.internal.ability")
18
18
  local Ability = ____ability.Ability
19
+ local UnitAbility = ____ability.UnitAbility
19
20
  local ____ability = require("engine.object-field.ability")
20
21
  local AbilityBooleanField = ____ability.AbilityBooleanField
21
22
  local AbilityNumberField = ____ability.AbilityNumberField
@@ -28,13 +29,11 @@ local ____math = require("math")
28
29
  local max = ____math.max
29
30
  local min = ____math.min
30
31
  local ____bonus = require("engine.internal.unit.bonus")
31
- local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
32
- local getUnitBonus = ____bonus.getUnitBonus
33
- local removeUnitBonus = ____bonus.removeUnitBonus
34
32
  local UnitBonusType = ____bonus.UnitBonusType
35
33
  local ____area_2Ddamage = require("engine.internal.mechanics.area-damage")
36
34
  local damageArea = ____area_2Ddamage.damageArea
37
35
  local ____preconditions = require("utility.preconditions")
36
+ local check = ____preconditions.check
38
37
  local checkNotNull = ____preconditions.checkNotNull
39
38
  local ____effect = require("core.types.effect")
40
39
  local Effect = ____effect.Effect
@@ -44,8 +43,16 @@ local ____unit = require("engine.behaviour.unit")
44
43
  local UnitBehavior = ____unit.UnitBehavior
45
44
  local ____arrays = require("utility.arrays")
46
45
  local forEach = ____arrays.forEach
46
+ local ____event = require("event")
47
+ local Event = ____event.Event
47
48
  local ____ability_2Dduration = require("engine.internal.mechanics.ability-duration")
48
49
  local getAbilityDuration = ____ability_2Dduration.getAbilityDuration
50
+ local ____item = require("engine.internal.item")
51
+ local Item = ____item.Item
52
+ local ____destructable = require("core.types.destructable")
53
+ local Destructable = ____destructable.Destructable
54
+ local ____ability = require("engine.standard.fields.ability")
55
+ local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
49
56
  local getUnitAbility = BlzGetUnitAbility
50
57
  local stringValueByBuffTypeIdByFieldId = postcompile(function()
51
58
  local stringValueByBuffTypeIdByFieldId = {}
@@ -94,11 +101,15 @@ local buffParametersKeys = {
94
101
  armorIncreaseFactor = true,
95
102
  attackSpeedIncreaseFactor = true,
96
103
  movementSpeedIncreaseFactor = true,
104
+ evasionProbability = true,
105
+ missProbability = true,
106
+ damageFactor = true,
97
107
  receivedDamageFactor = true,
98
108
  receivedMagicDamageFactor = true,
99
109
  durationIncreaseOnAutoAttack = true,
100
110
  maximumDuration = true,
101
111
  maximumRemainingDuration = true,
112
+ turnsIntoGhost = true,
102
113
  stuns = true,
103
114
  ignoresStunImmunity = true,
104
115
  providesStunImmunity = true,
@@ -107,8 +118,26 @@ local buffParametersKeys = {
107
118
  disablesAutoAttack = true,
108
119
  destroysOnDamage = true,
109
120
  maximumAutoAttackCount = true,
110
- uniqueGroup = true
121
+ maximumDamageDealtEventCount = true,
122
+ maximumDamageReceivedEventCount = true,
123
+ uniqueGroup = true,
124
+ damageOnExpiration = true,
125
+ healingOnExpiration = true,
126
+ killsOnExpiration = true,
127
+ explodesOnExpiration = true
111
128
  }
129
+ local function resolveEnumValue(ability, level, value)
130
+ if value == nil or type(value) == "number" then
131
+ return value
132
+ end
133
+ if ability == nil then
134
+ error(
135
+ __TS__New(IllegalArgumentException),
136
+ 0
137
+ )
138
+ end
139
+ return value:getValue(ability, level or ability.level)
140
+ end
112
141
  local function resolveNumberValue(ability, level, value)
113
142
  if value == nil or type(value) == "number" then
114
143
  return value
@@ -145,20 +174,34 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
145
174
  buff[property] = resolvedValue
146
175
  end
147
176
  end
148
- local buffBooleanParameters = {"stuns", "ignoresStunImmunity", "disablesAutoAttack", "providesInvulnerability"}
177
+ local buffBooleanParameters = {
178
+ "turnsIntoGhost",
179
+ "stuns",
180
+ "ignoresStunImmunity",
181
+ "disablesAutoAttack",
182
+ "providesInvulnerability",
183
+ "killsOnExpiration",
184
+ "explodesOnExpiration"
185
+ }
149
186
  local buffNumberParameters = {
150
187
  "durationIncreaseOnAutoAttack",
151
188
  "attackSpeedIncreaseFactor",
152
189
  "movementSpeedIncreaseFactor",
190
+ "evasionProbability",
153
191
  "armorIncrease",
192
+ "damageFactor",
154
193
  "receivedDamageFactor",
155
194
  "maximumAutoAttackCount",
195
+ "maximumDamageDealtEventCount",
196
+ "maximumDamageReceivedEventCount",
156
197
  "damageInterval",
157
198
  "damagePerInterval",
158
199
  "damageOverDuration",
159
200
  "healingInterval",
160
201
  "healingPerInterval",
161
- "healingOverDuration"
202
+ "healingOverDuration",
203
+ "damageOnExpiration",
204
+ "healingOnExpiration"
162
205
  }
163
206
  local unsuccessfulApplicationMarker = {}
164
207
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -185,7 +228,7 @@ local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
185
228
  return checkNotNull(firstNativeBuffTypeId)
186
229
  end
187
230
  local function destroyBuffIfItHasSameUniqueGroup(buff, uniqueGroup)
188
- if buff[103] == uniqueGroup then
231
+ if buff[104] == uniqueGroup then
189
232
  buff:destroy()
190
233
  end
191
234
  end
@@ -193,73 +236,76 @@ local function destroyBuff(buff)
193
236
  buff:destroy()
194
237
  end
195
238
  local function expireBuff(buff)
196
- local remainingDamageOverDuration = buff[112] or 0
197
- local remainingHealingOverDuration = buff[112] or 0
239
+ local remainingDamageOverDuration = buff[113] or 0
240
+ local remainingHealingOverDuration = buff[113] or 0
198
241
  if remainingDamageOverDuration ~= 0 or remainingHealingOverDuration ~= 0 then
199
242
  buff:flashSpecialEffect()
200
243
  if remainingDamageOverDuration ~= 0 then
201
- (buff[101] or buff[100]):damageTarget(buff[100], remainingDamageOverDuration)
202
- buff[112] = nil
244
+ (buff[102] or buff[101]):damageTarget(buff[101], remainingDamageOverDuration)
245
+ buff[113] = nil
203
246
  end
204
247
  if remainingHealingOverDuration ~= 0 then
205
- (buff[101] or buff[100]):healTarget(buff[100], remainingHealingOverDuration)
206
- buff[117] = nil
248
+ (buff[102] or buff[101]):healTarget(buff[101], remainingHealingOverDuration)
249
+ buff[118] = nil
207
250
  end
208
251
  end
209
252
  Timer:run(destroyBuff, buff)
253
+ buff:onExpiration()
210
254
  end
211
255
  local function buffDamageIntervalInitialTimerCallback(buff)
212
256
  buffDamageIntervalTimerCallback(buff)
213
- local timer = buff[113]
214
- local damageInterval = buff[111]
257
+ local timer = buff[114]
258
+ local damageInterval = buff[112]
215
259
  if timer ~= nil and damageInterval ~= nil and damageInterval > 0 then
216
260
  timer:start(damageInterval, true, buffDamageIntervalTimerCallback, buff)
217
261
  end
218
262
  end
219
263
  buffDamageIntervalTimerCallback = function(buff)
220
264
  buff:flashSpecialEffect()
221
- local source = buff[101] or buff[100]
222
- local remainingDamageOverDuration = buff[112] or 0
265
+ local source = buff[102] or buff[101]
266
+ local remainingDamageOverDuration = buff[113] or 0
223
267
  if remainingDamageOverDuration ~= 0 then
224
- local damageInterval = buff[111] or 0
268
+ local damageInterval = buff[112] or 0
225
269
  if damageInterval ~= 0 then
226
270
  local damage = remainingDamageOverDuration / (1 + buff.remainingDuration / damageInterval)
227
- source:damageTarget(buff[100], damage)
228
- buff[112] = remainingDamageOverDuration - damage
271
+ source:damageTarget(buff[101], damage)
272
+ buff[113] = remainingDamageOverDuration - damage
229
273
  end
230
274
  end
231
- local damagePerInterval = buff[110] or 0
275
+ local damagePerInterval = buff[111] or 0
232
276
  if remainingDamageOverDuration == 0 or damagePerInterval ~= 0 then
233
- source:damageTarget(buff[100], damagePerInterval)
277
+ source:damageTarget(buff[101], damagePerInterval)
234
278
  end
235
279
  end
236
280
  local function buffHealingIntervalInitialTimerCallback(buff)
237
281
  buffHealingIntervalTimerCallback(buff)
238
- local timer = buff[118]
239
- local healingInterval = buff[116]
282
+ local timer = buff[119]
283
+ local healingInterval = buff[117]
240
284
  if timer ~= nil and healingInterval ~= nil and healingInterval > 0 then
241
285
  timer:start(healingInterval, true, buffHealingIntervalTimerCallback, buff)
242
286
  end
243
287
  end
244
288
  buffHealingIntervalTimerCallback = function(buff)
245
- if buff[116] ~= buff[111] then
289
+ if buff[117] ~= buff[112] then
246
290
  buff:flashSpecialEffect()
247
291
  end
248
- local source = buff[101] or buff[100]
249
- local remainingHealingOverDuration = buff[117] or 0
292
+ local source = buff[102] or buff[101]
293
+ local remainingHealingOverDuration = buff[118] or 0
250
294
  if remainingHealingOverDuration ~= 0 then
251
- local healingInterval = buff[116] or 0
295
+ local healingInterval = buff[117] or 0
252
296
  if healingInterval ~= 0 then
253
297
  local healing = remainingHealingOverDuration / (1 + buff.remainingDuration / healingInterval)
254
- source:healTarget(buff[100], healing)
255
- buff[117] = remainingHealingOverDuration - healing
298
+ source:healTarget(buff[101], healing)
299
+ buff[118] = remainingHealingOverDuration - healing
256
300
  end
257
301
  end
258
- local healingPerInterval = buff[115] or 0
302
+ local healingPerInterval = buff[116] or 0
259
303
  if remainingHealingOverDuration == 0 or healingPerInterval ~= 0 then
260
- source:healTarget(buff[100], healingPerInterval)
304
+ source:healTarget(buff[101], healingPerInterval)
261
305
  end
262
306
  end
307
+ local buffCreatedEvent = __TS__New(Event)
308
+ local buffBeingDestroyedEvent = __TS__New(Event)
263
309
  ____exports.Buff = __TS__Class()
264
310
  local Buff = ____exports.Buff
265
311
  Buff.name = "Buff"
@@ -268,7 +314,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
268
314
  UnitBehavior.prototype.____constructor(self, _unit)
269
315
  self._unit = _unit
270
316
  self.parameters = nil
271
- self[100] = _unit
317
+ self[100] = 0
318
+ self[101] = _unit
272
319
  local typeId
273
320
  local polarity
274
321
  local resistanceType
@@ -277,7 +324,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
277
324
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
278
325
  polarity = resistanceTypeOrPolarity
279
326
  resistanceType = abilityOrParametersOrResistanceType
280
- if __TS__InstanceOf(parametersOrAbility, Ability) then
327
+ if __TS__InstanceOf(parametersOrAbility, Ability) or parametersOrAbility == nil then
281
328
  ability = parametersOrAbility
282
329
  else
283
330
  ability = nil
@@ -287,7 +334,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
287
334
  typeId = typeIdOrTypeIds
288
335
  polarity = polarityOrTypeIdSelectionPolicy
289
336
  resistanceType = resistanceTypeOrPolarity
290
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
337
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) or abilityOrParametersOrResistanceType == nil then
291
338
  ability = abilityOrParametersOrResistanceType
292
339
  parameters = parametersOrAbility
293
340
  else
@@ -296,9 +343,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
296
343
  end
297
344
  end
298
345
  self.typeId = typeId
299
- self.polarity = polarity
300
- self.resistanceType = resistanceType
301
- if not __TS__InstanceOf(ability, Ability) then
346
+ if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
302
347
  parameters = ability
303
348
  ability = nil
304
349
  end
@@ -324,14 +369,21 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
324
369
  learnLevelMinimum = learnLevelMinimum or ability:getField(ABILITY_IF_REQUIRED_LEVEL)
325
370
  duration = duration or getAbilityDuration(ability, _unit)
326
371
  end
372
+ self.polarity = resolveEnumValue(ability, level, polarity)
373
+ self.resistanceType = resolveEnumValue(ability, level, resistanceType)
374
+ local missProbability = parameters and parameters.missProbability or defaultParameters.missProbability
375
+ if missProbability ~= nil then
376
+ missProbability = resolveNumberValue(ability, level, missProbability)
377
+ self[142] = missProbability
378
+ end
327
379
  local buffByTypeId = buffByTypeIdByUnit[_unit]
328
380
  if buffByTypeId == nil then
329
381
  buffByTypeId = {}
330
382
  buffByTypeIdByUnit[_unit] = buffByTypeId
331
383
  end
332
- local ____opt_13 = buffByTypeId[typeId]
333
- if ____opt_13 ~= nil then
334
- ____opt_13:destroy()
384
+ local ____opt_15 = buffByTypeId[typeId]
385
+ if ____opt_15 ~= nil then
386
+ ____opt_15:destroy()
335
387
  end
336
388
  local uniqueGroup = parameters and parameters.uniqueGroup or defaultParameters and defaultParameters.uniqueGroup
337
389
  if uniqueGroup ~= nil then
@@ -340,18 +392,21 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
340
392
  if not internalApplyBuff(
341
393
  _unit,
342
394
  typeId,
343
- polarity,
344
- resistanceType,
395
+ self.polarity,
396
+ self.resistanceType,
345
397
  level,
346
398
  duration,
347
399
  spellStealPriority,
348
- learnLevelMinimum
400
+ learnLevelMinimum,
401
+ missProbability
349
402
  ) then
403
+ self[100] = 1
350
404
  UnitBehavior.prototype.destroy(self)
351
405
  error(unsuccessfulApplicationMarker, 0)
352
406
  end
353
407
  local handle = BlzGetUnitAbility(_unit.handle, typeId)
354
408
  if handle == nil then
409
+ self[100] = 1
355
410
  UnitBehavior.prototype.destroy(self)
356
411
  error(unsuccessfulApplicationMarker, 0)
357
412
  end
@@ -360,20 +415,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
360
415
  self._level = level
361
416
  self._spellStealPriority = spellStealPriority
362
417
  self._learnLevelMinimum = learnLevelMinimum
363
- self[101] = source
364
- self[102] = duration or 0
365
- self[103] = uniqueGroup
366
- self[104] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
367
- self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
418
+ self[102] = source
419
+ self[103] = duration or 0
420
+ self[104] = uniqueGroup
421
+ self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
422
+ self[106] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
368
423
  if parameters ~= nil or (next(defaultParameters)) ~= nil then
369
424
  for ____, buffBooleanParameter in ipairs(buffBooleanParameters) do
370
- local ____ability_22 = ability
371
- local ____level_23 = level
372
- local ____temp_21 = parameters and parameters[buffBooleanParameter]
373
- if ____temp_21 == nil then
374
- ____temp_21 = defaultParameters[buffBooleanParameter]
425
+ local ____ability_24 = ability
426
+ local ____level_25 = level
427
+ local ____temp_23 = parameters and parameters[buffBooleanParameter]
428
+ if ____temp_23 == nil then
429
+ ____temp_23 = defaultParameters[buffBooleanParameter]
375
430
  end
376
- if resolveBooleanValue(____ability_22, ____level_23, ____temp_21) then
431
+ if resolveBooleanValue(____ability_24, ____level_25, ____temp_23) then
377
432
  self[buffBooleanParameter] = true
378
433
  end
379
434
  end
@@ -389,11 +444,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
389
444
  end
390
445
  local maximumDuration = parameters and parameters.maximumDuration or defaultParameters.maximumDuration
391
446
  if maximumDuration ~= nil then
392
- self[107] = resolveNumberValue(ability, level, maximumDuration)
447
+ self[108] = resolveNumberValue(ability, level, maximumDuration)
393
448
  end
394
449
  local maximumRemainingDuration = parameters and parameters.maximumRemainingDuration or defaultParameters.maximumRemainingDuration
395
450
  if maximumRemainingDuration ~= nil then
396
- self[108] = resolveNumberValue(ability, level, maximumRemainingDuration)
451
+ self[109] = resolveNumberValue(ability, level, maximumRemainingDuration)
397
452
  end
398
453
  local parametersAbilityTypeIds = parameters and parameters.abilityTypeIds or defaultParameters.abilityTypeIds
399
454
  if parametersAbilityTypeIds ~= nil then
@@ -450,47 +505,57 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
450
505
  timer:start(duration, false, expireBuff, self)
451
506
  self._timer = timer
452
507
  end
508
+ self:onCreate()
509
+ self[100] = 1
510
+ Event.invoke(buffCreatedEvent, self)
453
511
  end
454
- function Buff.prototype.getUnitBonus(self, bonusType)
455
- local ____opt_36 = self._bonusIdByBonusType
456
- local bonusId = ____opt_36 and ____opt_36[bonusType]
457
- return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
512
+ function Buff.prototype.onAbilityGained(self, ability)
513
+ if __TS__InstanceOf(ability, UnitAbility) then
514
+ local abilityCooldownModifier = self[144]
515
+ if abilityCooldownModifier then
516
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
517
+ end
518
+ end
458
519
  end
459
- function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
460
- local bonusIdByBonusType = self._bonusIdByBonusType
461
- if bonusIdByBonusType == nil then
462
- bonusIdByBonusType = {}
463
- self._bonusIdByBonusType = bonusIdByBonusType
520
+ function Buff.prototype.onAbilityLost(self, ability)
521
+ if __TS__InstanceOf(ability, UnitAbility) then
522
+ local abilityCooldownModifier = self[144]
523
+ if abilityCooldownModifier then
524
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
525
+ end
464
526
  end
465
- bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
466
527
  end
467
- function Buff.prototype.flashEffect(self, widgetOrDuration, duration)
468
- local isWidgetProvided = type(widgetOrDuration) == "table"
469
- local ____Effect_40 = Effect
470
- local ____Effect_flash_41 = Effect.flash
471
- local ____array_39 = __TS__SparseArrayNew(
472
- self[104],
473
- isWidgetProvided and widgetOrDuration or self._unit,
474
- stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
475
- )
476
- local ____isWidgetProvided_38
477
- if isWidgetProvided then
478
- ____isWidgetProvided_38 = duration
528
+ function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
529
+ if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
530
+ Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
479
531
  else
480
- ____isWidgetProvided_38 = widgetOrDuration
532
+ local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
533
+ local ____Effect_40 = Effect
534
+ local ____Effect_flash_41 = Effect.flash
535
+ local ____array_39 = __TS__SparseArrayNew(
536
+ self[105],
537
+ isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
538
+ stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
539
+ )
540
+ local ____isWidgetProvided_38
541
+ if isWidgetProvided then
542
+ ____isWidgetProvided_38 = yOrParametersOrDuration
543
+ else
544
+ ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
545
+ end
546
+ __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
547
+ ____Effect_flash_41(
548
+ ____Effect_40,
549
+ __TS__SparseArraySpread(____array_39)
550
+ )
481
551
  end
482
- __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
483
- ____Effect_flash_41(
484
- ____Effect_40,
485
- __TS__SparseArraySpread(____array_39)
486
- )
487
552
  end
488
553
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
489
554
  local isWidgetProvided = type(widgetOrDuration) == "table"
490
555
  local ____Effect_44 = Effect
491
556
  local ____Effect_flash_45 = Effect.flash
492
557
  local ____array_43 = __TS__SparseArrayNew(
493
- self[105],
558
+ self[106],
494
559
  isWidgetProvided and widgetOrDuration or self._unit,
495
560
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
496
561
  )
@@ -506,21 +571,25 @@ function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
506
571
  __TS__SparseArraySpread(____array_43)
507
572
  )
508
573
  end
574
+ function Buff.prototype.onCreate(self)
575
+ end
509
576
  function Buff.prototype.onDestroy(self)
577
+ check(self[100] ~= 0, "Cannot destroy a buff that has not finished creating yet.")
578
+ self[100] = 2
510
579
  local unit = self._unit
511
580
  if getUnitAbility(unit.handle, self.typeId) == self.handle then
512
581
  removeBuff(unit.handle, self.typeId)
513
582
  end
514
583
  buffByTypeIdByUnit[unit][self.typeId] = nil
515
- local healingIntervalTimer = self[118]
584
+ local healingIntervalTimer = self[119]
516
585
  if healingIntervalTimer ~= nil then
517
586
  healingIntervalTimer:destroy()
518
- self[118] = nil
587
+ self[119] = nil
519
588
  end
520
- local damageIntervalTimer = self[113]
589
+ local damageIntervalTimer = self[114]
521
590
  if damageIntervalTimer ~= nil then
522
591
  damageIntervalTimer:destroy()
523
- self[113] = nil
592
+ self[114] = nil
524
593
  end
525
594
  if self._timer ~= nil then
526
595
  self._timer:destroy()
@@ -530,25 +599,34 @@ function Buff.prototype.onDestroy(self)
530
599
  behavior:destroy()
531
600
  end
532
601
  end
533
- if self[130] then
602
+ local previousAbilityCooldownModifier = self[144]
603
+ if previousAbilityCooldownModifier then
604
+ for ____, ability in ipairs(self._unit.abilities) do
605
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
606
+ end
607
+ end
608
+ if self[139] then
609
+ unit:decrementInvulnerabilityCounter()
610
+ end
611
+ if self[138] then
534
612
  unit:decrementDisableAutoAttackCounter()
535
613
  end
536
- if self[128] then
537
- if self[129] then
538
- unit:decrementStunCounter()
614
+ if self[136] then
615
+ if self[137] then
616
+ unit:decrementForceStunCounter()
539
617
  end
540
618
  unit:decrementStunCounter()
541
619
  end
620
+ if self[135] then
621
+ unit:decrementGhostCounter()
622
+ end
542
623
  if self._abilityTypeIds ~= nil then
543
624
  for abilityTypeId in pairs(self._abilityTypeIds) do
544
625
  unit:removeAbility(abilityTypeId)
545
626
  end
546
627
  end
547
- if self._bonusIdByBonusType ~= nil then
548
- for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
549
- removeUnitBonus(unit, bonusType, bonusId)
550
- end
551
- end
628
+ Event.invoke(buffBeingDestroyedEvent, self)
629
+ self[100] = 3
552
630
  return UnitBehavior.prototype.onDestroy(self)
553
631
  end
554
632
  function Buff.apply(self, ...)
@@ -583,44 +661,74 @@ function Buff.getByTypeId(self, unit, typeId)
583
661
  end
584
662
  return nil
585
663
  end
664
+ function Buff.prototype.onExpiration(self)
665
+ local unit = self.unit
666
+ if self[120] ~= nil then
667
+ (self[102] or unit):damageTarget(unit, self[120] or 0)
668
+ end
669
+ if self[121] ~= nil then
670
+ (self[102] or unit):healTarget(unit, self[120] or 0)
671
+ end
672
+ if self[141] then
673
+ unit:explode()
674
+ elseif self[140] then
675
+ unit:kill()
676
+ end
677
+ end
586
678
  function Buff.prototype.onDeath(self, source)
587
679
  local unit = self.unit
588
- if self[119] ~= nil then
680
+ if self[122] ~= nil then
589
681
  damageArea(
590
- self[101] or unit,
591
- self[119],
682
+ self[102] or unit,
683
+ self[122],
592
684
  unit.x,
593
685
  unit.y,
594
- self[121] or 0,
595
- self[120] or 0,
686
+ self[124] or 0,
596
687
  self[123] or 0,
597
- self[122] or 0,
688
+ self[126] or 0,
598
689
  self[125] or 0,
599
- self[124] or 0
690
+ self[128] or 0,
691
+ self[127] or 0
600
692
  )
601
693
  end
602
694
  end
603
695
  function Buff.prototype.onDamageDealt(self, target, event)
604
696
  if event.isAttack then
605
- if self[106] ~= nil then
606
- local durationIncrease = self[106]
607
- local maximumDuration = self[107] or 0
697
+ if self[107] ~= nil then
698
+ local durationIncrease = self[107]
699
+ local maximumDuration = self[108] or 0
608
700
  if maximumDuration > 0 then
609
701
  durationIncrease = min(
610
702
  durationIncrease,
611
- max(0, maximumDuration - self[102])
703
+ max(0, maximumDuration - self[103])
612
704
  )
613
705
  end
614
706
  local remainingDuration = self.remainingDuration + durationIncrease
615
- local maximumRemainingDuration = self[108] or 0
707
+ local maximumRemainingDuration = self[109] or 0
616
708
  if maximumRemainingDuration > 0 then
617
709
  remainingDuration = min(remainingDuration, maximumRemainingDuration)
618
710
  end
619
711
  self.remainingDuration = remainingDuration
620
712
  end
621
- local autoAttackCount = (self[126] or 0) + 1
622
- self[126] = autoAttackCount
623
- if autoAttackCount == self[127] then
713
+ local autoAttackCount = (self[129] or 0) + 1
714
+ self[129] = autoAttackCount
715
+ if autoAttackCount == self[130] then
716
+ self:destroy()
717
+ end
718
+ end
719
+ if event.originalAmount ~= 0 then
720
+ local damageDealtEventCount = (self[131] or 0) + 1
721
+ self[131] = damageDealtEventCount
722
+ if damageDealtEventCount == self[132] then
723
+ self:destroy()
724
+ end
725
+ end
726
+ end
727
+ function Buff.prototype.onDamageReceived(self, source, event)
728
+ if event.originalAmount ~= 0 then
729
+ local damageReceivedEventCount = (self[133] or 0) + 1
730
+ self[133] = damageReceivedEventCount
731
+ if damageReceivedEventCount == self[134] then
624
732
  self:destroy()
625
733
  end
626
734
  end
@@ -630,7 +738,7 @@ __TS__SetDescriptor(
630
738
  Buff.prototype,
631
739
  "source",
632
740
  {get = function(self)
633
- return self[101] or self._unit
741
+ return self[102] or self._unit
634
742
  end},
635
743
  true
636
744
  )
@@ -647,13 +755,13 @@ __TS__SetDescriptor(
647
755
  "remainingDamageOverDuration",
648
756
  {
649
757
  get = function(self)
650
- return self[112] or 0
758
+ return self[113] or 0
651
759
  end,
652
760
  set = function(self, remainingDamageOverDuration)
653
- local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[112] or 0)
654
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
655
- local damageOverDuration = (self[109] or 0) + remainingDamageOverDurationDelta
656
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
761
+ local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[113] or 0)
762
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
763
+ local damageOverDuration = (self[110] or 0) + remainingDamageOverDurationDelta
764
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
657
765
  end
658
766
  },
659
767
  true
@@ -663,13 +771,13 @@ __TS__SetDescriptor(
663
771
  "damageOverDuration",
664
772
  {
665
773
  get = function(self)
666
- return self[109] or 0
774
+ return self[110] or 0
667
775
  end,
668
776
  set = function(self, damageOverDuration)
669
- local damageOverDurationDelta = damageOverDuration - (self[109] or 0)
670
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
671
- local remainingDamageOverDuration = (self[112] or 0) + damageOverDurationDelta
672
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
777
+ local damageOverDurationDelta = damageOverDuration - (self[110] or 0)
778
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
779
+ local remainingDamageOverDuration = (self[113] or 0) + damageOverDurationDelta
780
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
673
781
  end
674
782
  },
675
783
  true
@@ -679,10 +787,10 @@ __TS__SetDescriptor(
679
787
  "damagePerInterval",
680
788
  {
681
789
  get = function(self)
682
- return self[110] or 0
790
+ return self[111] or 0
683
791
  end,
684
792
  set = function(self, damagePerInterval)
685
- self[110] = damagePerInterval ~= 0 and damagePerInterval or nil
793
+ self[111] = damagePerInterval ~= 0 and damagePerInterval or nil
686
794
  end
687
795
  },
688
796
  true
@@ -692,25 +800,25 @@ __TS__SetDescriptor(
692
800
  "damageInterval",
693
801
  {
694
802
  get = function(self)
695
- return self[111] or 0
803
+ return self[112] or 0
696
804
  end,
697
805
  set = function(self, damageInterval)
698
806
  if damageInterval <= 0 then
699
- self[111] = damageInterval ~= 0 and damageInterval or nil
700
- local timer = self[113]
807
+ self[112] = damageInterval ~= 0 and damageInterval or nil
808
+ local timer = self[114]
701
809
  if timer ~= nil then
702
810
  timer:destroy()
703
- self[113] = nil
811
+ self[114] = nil
704
812
  end
705
813
  return
706
814
  end
707
- self[111] = damageInterval
815
+ self[112] = damageInterval
708
816
  local ____opt_48 = self._timer
709
817
  local elapsed = ____opt_48 and ____opt_48.elapsed or 0
710
- local timer = self[113]
818
+ local timer = self[114]
711
819
  if timer == nil then
712
820
  timer = Timer:create()
713
- self[113] = timer
821
+ self[114] = timer
714
822
  end
715
823
  local initialDelay = damageInterval - (elapsed >= damageInterval and math.fmod(elapsed, damageInterval) or elapsed)
716
824
  if initialDelay == damageInterval then
@@ -727,13 +835,13 @@ __TS__SetDescriptor(
727
835
  "remainingHealingOverDuration",
728
836
  {
729
837
  get = function(self)
730
- return self[117] or 0
838
+ return self[118] or 0
731
839
  end,
732
840
  set = function(self, remainingHealingOverDuration)
733
- local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[117] or 0)
734
- self[112] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
735
- local healingOverDuration = (self[114] or 0) + remainingHealingOverDurationDelta
736
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
841
+ local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[118] or 0)
842
+ self[113] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
843
+ local healingOverDuration = (self[115] or 0) + remainingHealingOverDurationDelta
844
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
737
845
  end
738
846
  },
739
847
  true
@@ -743,13 +851,13 @@ __TS__SetDescriptor(
743
851
  "healingOverDuration",
744
852
  {
745
853
  get = function(self)
746
- return self[114] or 0
854
+ return self[115] or 0
747
855
  end,
748
856
  set = function(self, healingOverDuration)
749
- local healingOverDurationDelta = healingOverDuration - (self[114] or 0)
750
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
751
- local remainingHealingOverDuration = (self[117] or 0) + healingOverDurationDelta
752
- self[117] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
857
+ local healingOverDurationDelta = healingOverDuration - (self[115] or 0)
858
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
859
+ local remainingHealingOverDuration = (self[118] or 0) + healingOverDurationDelta
860
+ self[118] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
753
861
  end
754
862
  },
755
863
  true
@@ -759,10 +867,10 @@ __TS__SetDescriptor(
759
867
  "healingPerInterval",
760
868
  {
761
869
  get = function(self)
762
- return self[115] or 0
870
+ return self[116] or 0
763
871
  end,
764
872
  set = function(self, healingPerInterval)
765
- self[115] = healingPerInterval ~= 0 and healingPerInterval or nil
873
+ self[116] = healingPerInterval ~= 0 and healingPerInterval or nil
766
874
  end
767
875
  },
768
876
  true
@@ -772,25 +880,25 @@ __TS__SetDescriptor(
772
880
  "healingInterval",
773
881
  {
774
882
  get = function(self)
775
- return self[116] or 0
883
+ return self[117] or 0
776
884
  end,
777
885
  set = function(self, healingInterval)
778
886
  if healingInterval <= 0 then
779
- self[116] = healingInterval ~= 0 and healingInterval or nil
780
- local timer = self[118]
887
+ self[117] = healingInterval ~= 0 and healingInterval or nil
888
+ local timer = self[119]
781
889
  if timer ~= nil then
782
890
  timer:destroy()
783
- self[118] = nil
891
+ self[119] = nil
784
892
  end
785
893
  return
786
894
  end
787
- self[116] = healingInterval
895
+ self[117] = healingInterval
788
896
  local ____opt_50 = self._timer
789
897
  local elapsed = ____opt_50 and ____opt_50.elapsed or 0
790
- local timer = self[118]
898
+ local timer = self[119]
791
899
  if timer == nil then
792
900
  timer = Timer:create()
793
- self[118] = timer
901
+ self[119] = timer
794
902
  end
795
903
  local initialDelay = healingInterval - (elapsed >= healingInterval and math.fmod(elapsed, healingInterval) or elapsed)
796
904
  if initialDelay == healingInterval then
@@ -802,6 +910,45 @@ __TS__SetDescriptor(
802
910
  },
803
911
  true
804
912
  )
913
+ __TS__SetDescriptor(
914
+ Buff.prototype,
915
+ "damageOnExpiration",
916
+ {
917
+ get = function(self)
918
+ return self[120] or 0
919
+ end,
920
+ set = function(self, damageOnExpiration)
921
+ self[120] = damageOnExpiration ~= 0 and damageOnExpiration or nil
922
+ end
923
+ },
924
+ true
925
+ )
926
+ __TS__SetDescriptor(
927
+ Buff.prototype,
928
+ "healingOnExpiration",
929
+ {
930
+ get = function(self)
931
+ return self[121] or 0
932
+ end,
933
+ set = function(self, healingOnExpiration)
934
+ self[121] = healingOnExpiration ~= 0 and healingOnExpiration or nil
935
+ end
936
+ },
937
+ true
938
+ )
939
+ __TS__SetDescriptor(
940
+ Buff.prototype,
941
+ "damageFactor",
942
+ {
943
+ get = function(self)
944
+ return self:getUnitBonus(UnitBonusType.DAMAGE_FACTOR)
945
+ end,
946
+ set = function(self, damageFactor)
947
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.DAMAGE_FACTOR, damageFactor)
948
+ end
949
+ },
950
+ true
951
+ )
805
952
  __TS__SetDescriptor(
806
953
  Buff.prototype,
807
954
  "receivedDamageFactor",
@@ -828,30 +975,53 @@ __TS__SetDescriptor(
828
975
  },
829
976
  true
830
977
  )
978
+ __TS__SetDescriptor(
979
+ Buff.prototype,
980
+ "turnsIntoGhost",
981
+ {
982
+ get = function(self)
983
+ local ____self__135_52 = self[135]
984
+ if ____self__135_52 == nil then
985
+ ____self__135_52 = false
986
+ end
987
+ return ____self__135_52
988
+ end,
989
+ set = function(self, turnsIntoGhost)
990
+ if not turnsIntoGhost and self[135] then
991
+ self.object:decrementGhostCounter()
992
+ self[135] = nil
993
+ elseif turnsIntoGhost and not self[135] then
994
+ self.object:incrementGhostCounter()
995
+ self[135] = true
996
+ end
997
+ end
998
+ },
999
+ true
1000
+ )
831
1001
  __TS__SetDescriptor(
832
1002
  Buff.prototype,
833
1003
  "stuns",
834
1004
  {
835
1005
  get = function(self)
836
- local ____self__128_52 = self[128]
837
- if ____self__128_52 == nil then
838
- ____self__128_52 = false
1006
+ local ____self__136_53 = self[136]
1007
+ if ____self__136_53 == nil then
1008
+ ____self__136_53 = false
839
1009
  end
840
- return ____self__128_52
1010
+ return ____self__136_53
841
1011
  end,
842
1012
  set = function(self, stuns)
843
- if not stuns and self[128] then
844
- if self[129] then
845
- self.object:decrementStunCounter()
1013
+ if not stuns and self[136] then
1014
+ if self[137] then
1015
+ self.object:decrementForceStunCounter()
846
1016
  end
847
1017
  self.object:decrementStunCounter()
848
- self[128] = nil
849
- elseif stuns and not self[128] then
850
- if self[129] then
851
- self.object:incrementStunCounter()
1018
+ self[136] = nil
1019
+ elseif stuns and not self[136] then
1020
+ if self[137] then
1021
+ self.object:incrementForceStunCounter()
852
1022
  end
853
1023
  self.object:incrementStunCounter()
854
- self[128] = true
1024
+ self[136] = true
855
1025
  end
856
1026
  end
857
1027
  },
@@ -862,23 +1032,23 @@ __TS__SetDescriptor(
862
1032
  "ignoresStunImmunity",
863
1033
  {
864
1034
  get = function(self)
865
- local ____self__129_53 = self[129]
866
- if ____self__129_53 == nil then
867
- ____self__129_53 = false
1035
+ local ____self__137_54 = self[137]
1036
+ if ____self__137_54 == nil then
1037
+ ____self__137_54 = false
868
1038
  end
869
- return ____self__129_53
1039
+ return ____self__137_54
870
1040
  end,
871
1041
  set = function(self, ignoresStunImmunity)
872
- if not ignoresStunImmunity and self[129] then
873
- if self[128] then
874
- self.object:decrementStunCounter()
1042
+ if not ignoresStunImmunity and self[137] then
1043
+ if self[136] then
1044
+ self.object:decrementForceStunCounter()
875
1045
  end
876
- self[129] = nil
877
- elseif ignoresStunImmunity and not self[129] then
878
- if self[128] then
879
- self.object:incrementStunCounter()
1046
+ self[137] = nil
1047
+ elseif ignoresStunImmunity and not self[137] then
1048
+ if self[136] then
1049
+ self.object:incrementForceStunCounter()
880
1050
  end
881
- self[129] = true
1051
+ self[137] = true
882
1052
  end
883
1053
  end
884
1054
  },
@@ -889,19 +1059,19 @@ __TS__SetDescriptor(
889
1059
  "disablesAutoAttack",
890
1060
  {
891
1061
  get = function(self)
892
- local ____self__130_54 = self[130]
893
- if ____self__130_54 == nil then
894
- ____self__130_54 = false
1062
+ local ____self__138_55 = self[138]
1063
+ if ____self__138_55 == nil then
1064
+ ____self__138_55 = false
895
1065
  end
896
- return ____self__130_54
1066
+ return ____self__138_55
897
1067
  end,
898
1068
  set = function(self, disablesAutoAttack)
899
- if not disablesAutoAttack and self[130] then
1069
+ if not disablesAutoAttack and self[138] then
900
1070
  self.object:decrementDisableAutoAttackCounter()
901
- self[130] = nil
902
- elseif disablesAutoAttack and not self[130] then
1071
+ self[138] = nil
1072
+ elseif disablesAutoAttack and not self[138] then
903
1073
  self.object:incrementDisableAutoAttackCounter()
904
- self[130] = true
1074
+ self[138] = true
905
1075
  end
906
1076
  end
907
1077
  },
@@ -912,19 +1082,95 @@ __TS__SetDescriptor(
912
1082
  "providesInvulnerability",
913
1083
  {
914
1084
  get = function(self)
915
- local ____self__131_55 = self[131]
916
- if ____self__131_55 == nil then
917
- ____self__131_55 = false
1085
+ local ____self__139_56 = self[139]
1086
+ if ____self__139_56 == nil then
1087
+ ____self__139_56 = false
918
1088
  end
919
- return ____self__131_55
1089
+ return ____self__139_56
920
1090
  end,
921
1091
  set = function(self, providesInvulnerability)
922
- if not providesInvulnerability and self[131] then
1092
+ if not providesInvulnerability and self[139] then
923
1093
  self.object:decrementInvulnerabilityCounter()
924
- self[131] = nil
925
- elseif providesInvulnerability and not self[131] then
1094
+ self[139] = nil
1095
+ elseif providesInvulnerability and not self[139] then
926
1096
  self.object:incrementInvulnerabilityCounter()
927
- self[131] = true
1097
+ self[139] = true
1098
+ end
1099
+ end
1100
+ },
1101
+ true
1102
+ )
1103
+ __TS__SetDescriptor(
1104
+ Buff.prototype,
1105
+ "killsOnExpiration",
1106
+ {
1107
+ get = function(self)
1108
+ local ____self__140_57 = self[140]
1109
+ if ____self__140_57 == nil then
1110
+ ____self__140_57 = false
1111
+ end
1112
+ return ____self__140_57
1113
+ end,
1114
+ set = function(self, killsOnExpiration)
1115
+ if not killsOnExpiration and self[140] then
1116
+ self[140] = nil
1117
+ elseif killsOnExpiration and not self[140] then
1118
+ self[140] = true
1119
+ end
1120
+ end
1121
+ },
1122
+ true
1123
+ )
1124
+ __TS__SetDescriptor(
1125
+ Buff.prototype,
1126
+ "explodesOnExpiration",
1127
+ {
1128
+ get = function(self)
1129
+ local ____self__141_58 = self[141]
1130
+ if ____self__141_58 == nil then
1131
+ ____self__141_58 = false
1132
+ end
1133
+ return ____self__141_58
1134
+ end,
1135
+ set = function(self, killsOnExpiration)
1136
+ if not killsOnExpiration and self[141] then
1137
+ self[141] = nil
1138
+ elseif killsOnExpiration and not self[141] then
1139
+ self[141] = true
1140
+ end
1141
+ end
1142
+ },
1143
+ true
1144
+ )
1145
+ __TS__SetDescriptor(
1146
+ Buff.prototype,
1147
+ "maximumDamageDealtEventCount",
1148
+ {
1149
+ get = function(self)
1150
+ return self[132] or 0
1151
+ end,
1152
+ set = function(self, maximumDamageDealtEventCount)
1153
+ if maximumDamageDealtEventCount == 0 then
1154
+ self[132] = nil
1155
+ else
1156
+ self[132] = maximumDamageDealtEventCount
1157
+ end
1158
+ end
1159
+ },
1160
+ true
1161
+ )
1162
+ __TS__SetDescriptor(
1163
+ Buff.prototype,
1164
+ "maximumDamageReceivedEventCount",
1165
+ {
1166
+ get = function(self)
1167
+ return self[134] or 0
1168
+ end,
1169
+ set = function(self, maximumDamageReceivedEventCount)
1170
+ if maximumDamageReceivedEventCount == 0 then
1171
+ self[134] = nil
1172
+ else
1173
+ self[134] = maximumDamageReceivedEventCount
928
1174
  end
929
1175
  end
930
1176
  },
@@ -935,13 +1181,13 @@ __TS__SetDescriptor(
935
1181
  "maximumAutoAttackCount",
936
1182
  {
937
1183
  get = function(self)
938
- return self[127] or 0
1184
+ return self[130] or 0
939
1185
  end,
940
1186
  set = function(self, maximumAutoAttackCount)
941
1187
  if maximumAutoAttackCount == 0 then
942
- self[127] = nil
1188
+ self[130] = nil
943
1189
  else
944
- self[127] = maximumAutoAttackCount
1190
+ self[130] = maximumAutoAttackCount
945
1191
  end
946
1192
  end
947
1193
  },
@@ -952,10 +1198,10 @@ __TS__SetDescriptor(
952
1198
  "durationIncreaseOnAutoAttack",
953
1199
  {
954
1200
  get = function(self)
955
- return self[106] or 0
1201
+ return self[107] or 0
956
1202
  end,
957
1203
  set = function(self, durationIncreaseOnAutoAttack)
958
- self[106] = durationIncreaseOnAutoAttack
1204
+ self[107] = durationIncreaseOnAutoAttack
959
1205
  end
960
1206
  },
961
1207
  true
@@ -986,11 +1232,24 @@ __TS__SetDescriptor(
986
1232
  },
987
1233
  true
988
1234
  )
1235
+ __TS__SetDescriptor(
1236
+ Buff.prototype,
1237
+ "evasionProbability",
1238
+ {
1239
+ get = function(self)
1240
+ return self:getUnitBonus(UnitBonusType.EVASION_PROBABILITY)
1241
+ end,
1242
+ set = function(self, evasionProbability)
1243
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.EVASION_PROBABILITY, evasionProbability)
1244
+ end
1245
+ },
1246
+ true
1247
+ )
989
1248
  __TS__SetDescriptor(
990
1249
  Buff.prototype,
991
1250
  "duration",
992
1251
  {get = function(self)
993
- return self[102]
1252
+ return self[103]
994
1253
  end},
995
1254
  true
996
1255
  )
@@ -999,15 +1258,15 @@ __TS__SetDescriptor(
999
1258
  "remainingDuration",
1000
1259
  {
1001
1260
  get = function(self)
1002
- local ____opt_56 = self._timer
1003
- return ____opt_56 and ____opt_56.remaining or 0
1261
+ local ____opt_59 = self._timer
1262
+ return ____opt_59 and ____opt_59.remaining or 0
1004
1263
  end,
1005
1264
  set = function(self, remainingDuration)
1006
- local ____remainingDuration_60 = remainingDuration
1007
- local ____opt_58 = self._timer
1008
- local remainingDurationDelta = ____remainingDuration_60 - (____opt_58 and ____opt_58.remaining or 0)
1265
+ local ____remainingDuration_63 = remainingDuration
1266
+ local ____opt_61 = self._timer
1267
+ local remainingDurationDelta = ____remainingDuration_63 - (____opt_61 and ____opt_61.remaining or 0)
1009
1268
  if remainingDurationDelta ~= 0 then
1010
- self[102] = self[102] + remainingDurationDelta
1269
+ self[103] = self[103] + remainingDurationDelta
1011
1270
  if remainingDuration <= 0 then
1012
1271
  Timer:run(destroyBuff, self)
1013
1272
  else
@@ -1019,7 +1278,8 @@ __TS__SetDescriptor(
1019
1278
  self._level,
1020
1279
  remainingDuration,
1021
1280
  self._spellStealPriority,
1022
- self._learnLevelMinimum
1281
+ self._learnLevelMinimum,
1282
+ self[142]
1023
1283
  ) then
1024
1284
  local timer = self._timer
1025
1285
  if timer == nil then
@@ -1033,10 +1293,38 @@ __TS__SetDescriptor(
1033
1293
  end
1034
1294
  },
1035
1295
  true
1036
- );
1296
+ )
1297
+ __TS__SetDescriptor(
1298
+ Buff.prototype,
1299
+ "abilityCooldownFactor",
1300
+ {
1301
+ get = function(self)
1302
+ return self[143] or 1
1303
+ end,
1304
+ set = function(self, abilityCooldownFactor)
1305
+ local previousAbilityCooldownModifier = self[144]
1306
+ if previousAbilityCooldownModifier then
1307
+ for ____, ability in ipairs(self._unit.abilities) do
1308
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
1309
+ end
1310
+ end
1311
+ local function modifier(ability, level, cooldown)
1312
+ return cooldown * abilityCooldownFactor
1313
+ end
1314
+ for ____, ability in ipairs(self._unit.abilities) do
1315
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
1316
+ end
1317
+ self[144] = modifier
1318
+ self[143] = abilityCooldownFactor
1319
+ end
1320
+ },
1321
+ true
1322
+ )
1323
+ Buff.createdEvent = buffCreatedEvent
1324
+ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1037
1325
  (function(self)
1038
1326
  local function destroyBuffIfNeeded(buff)
1039
- if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1327
+ if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
1040
1328
  buff:destroy()
1041
1329
  end
1042
1330
  end
@@ -1087,5 +1375,8 @@ __TS__SetDescriptor(
1087
1375
  ____exports.checkBuffs(target)
1088
1376
  end
1089
1377
  )
1378
+ buffCreatedEvent:addListener(function(buff)
1379
+ UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1380
+ end)
1090
1381
  end)(Buff)
1091
1382
  return ____exports