warscript 0.0.1-dev.ee2345e → 0.0.1-dev.effa673

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 (197) hide show
  1. package/attributes.d.ts +0 -1
  2. package/binaryreader.d.ts +1 -0
  3. package/binaryreader.lua +3 -0
  4. package/config.d.ts +5 -0
  5. package/config.lua +10 -0
  6. package/core/types/effect.d.ts +14 -6
  7. package/core/types/effect.lua +131 -35
  8. package/core/types/frame.d.ts +8 -1
  9. package/core/types/frame.lua +93 -1
  10. package/core/types/group.d.ts +0 -1
  11. package/core/types/image.d.ts +0 -1
  12. package/core/types/missile.d.ts +2 -2
  13. package/core/types/missile.lua +8 -2
  14. package/core/types/sound.d.ts +17 -24
  15. package/core/types/sound.lua +94 -24
  16. package/core/types/unit.lua +8 -0
  17. package/core/util.d.ts +1 -1
  18. package/core/util.lua +18 -1
  19. package/decl/index.d.ts +1 -0
  20. package/engine/ability.d.ts +1 -1
  21. package/engine/behavior.d.ts +10 -10
  22. package/engine/behavior.lua +6 -6
  23. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  24. package/engine/behaviour/ability/always-enabled.lua +31 -0
  25. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  26. package/engine/behaviour/ability/apply-buff.lua +32 -0
  27. package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
  28. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  29. package/engine/behaviour/ability/damage.d.ts +36 -11
  30. package/engine/behaviour/ability/damage.lua +90 -32
  31. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  32. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  33. package/engine/behaviour/ability/heal.d.ts +33 -6
  34. package/engine/behaviour/ability/heal.lua +89 -10
  35. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  36. package/engine/behaviour/ability/instant-impact.lua +4 -15
  37. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  38. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  39. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  40. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  41. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  42. package/engine/behaviour/ability/restore-mana.lua +29 -0
  43. package/engine/behaviour/ability.d.ts +27 -4
  44. package/engine/behaviour/ability.lua +152 -17
  45. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  46. package/engine/behaviour/unit.d.ts +10 -2
  47. package/engine/behaviour/unit.lua +27 -0
  48. package/engine/buff.d.ts +103 -41
  49. package/engine/buff.lua +465 -212
  50. package/engine/game-map.d.ts +7 -0
  51. package/engine/game-map.lua +32 -0
  52. package/engine/internal/ability.d.ts +16 -13
  53. package/engine/internal/ability.lua +80 -76
  54. package/engine/internal/item/ability.lua +106 -0
  55. package/engine/internal/item+owner.lua +2 -2
  56. package/engine/internal/item.d.ts +2 -2
  57. package/engine/internal/item.lua +56 -25
  58. package/engine/internal/mechanics/ability-duration.lua +1 -1
  59. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  60. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  61. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  62. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  63. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  64. package/engine/internal/object-data/evasion-probability.lua +16 -0
  65. package/engine/internal/unit/ability.d.ts +10 -1
  66. package/engine/internal/unit/ability.lua +36 -14
  67. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  68. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  69. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  70. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  71. package/engine/internal/unit/bonus.d.ts +11 -8
  72. package/engine/internal/unit/bonus.lua +23 -1
  73. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  74. package/engine/internal/unit/ignore-events-items.lua +5 -0
  75. package/engine/internal/unit/item.d.ts +24 -0
  76. package/engine/internal/unit/item.lua +78 -0
  77. package/engine/internal/unit/main-selected.d.ts +13 -0
  78. package/engine/internal/unit/main-selected.lua +51 -0
  79. package/engine/internal/unit+ability.lua +2 -2
  80. package/engine/internal/unit+transport.lua +4 -10
  81. package/engine/internal/unit-missile-launch.lua +25 -6
  82. package/engine/internal/unit.d.ts +64 -16
  83. package/engine/internal/unit.lua +381 -134
  84. package/engine/internal/utility.lua +12 -0
  85. package/engine/lightning.d.ts +12 -5
  86. package/engine/lightning.lua +48 -14
  87. package/engine/local-client.d.ts +7 -2
  88. package/engine/local-client.lua +82 -0
  89. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  90. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  91. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -3
  92. package/engine/object-data/auxiliary/attachment-preset.lua +2 -2
  93. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  94. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  95. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  96. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  97. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  98. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  99. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  100. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  101. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  102. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  103. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  104. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  105. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  106. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  107. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  108. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  109. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  110. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  111. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  112. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  113. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  114. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  115. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  116. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  117. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  118. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  119. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  120. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  121. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  122. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  123. package/engine/object-data/entry/ability-type/web.lua +52 -0
  124. package/engine/object-data/entry/ability-type.d.ts +19 -18
  125. package/engine/object-data/entry/ability-type.lua +82 -33
  126. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  127. package/engine/object-data/entry/buff-type/applicable.lua +13 -37
  128. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  129. package/engine/object-data/entry/buff-type.d.ts +1 -2
  130. package/engine/object-data/entry/buff-type.lua +2 -2
  131. package/engine/object-data/entry/destructible-type.d.ts +1 -2
  132. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  133. package/engine/object-data/entry/item-type.d.ts +15 -2
  134. package/engine/object-data/entry/item-type.lua +93 -2
  135. package/engine/object-data/entry/lightning-type.d.ts +1 -2
  136. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  137. package/engine/object-data/entry/sound-preset.lua +140 -0
  138. package/engine/object-data/entry/unit-type.d.ts +45 -3
  139. package/engine/object-data/entry/unit-type.lua +394 -57
  140. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  141. package/engine/object-data/entry/upgrade.d.ts +1 -2
  142. package/engine/object-data/entry/upgrade.lua +4 -4
  143. package/engine/object-data/entry.d.ts +18 -17
  144. package/engine/object-data/entry.lua +60 -32
  145. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  146. package/engine/object-field/ability.d.ts +26 -3
  147. package/engine/object-field/ability.lua +54 -1
  148. package/engine/object-field.d.ts +2 -3
  149. package/engine/object-field.lua +4 -0
  150. package/engine/random.d.ts +1 -0
  151. package/engine/random.lua +9 -0
  152. package/engine/standard/entries/sound-preset.d.ts +10 -0
  153. package/engine/standard/entries/sound-preset.lua +10 -0
  154. package/engine/standard/entries/unit-type.d.ts +39 -1
  155. package/engine/standard/entries/unit-type.lua +39 -1
  156. package/engine/standard/fields/ability.d.ts +3 -1
  157. package/engine/standard/fields/ability.lua +3 -1
  158. package/engine/unit.d.ts +3 -0
  159. package/engine/unit.lua +12 -2
  160. package/event.d.ts +2 -3
  161. package/event.lua +9 -5
  162. package/index.d.ts +1 -0
  163. package/index.lua +1 -0
  164. package/lualib_bundle.lua +146 -42
  165. package/math/vec2.d.ts +2 -9
  166. package/math.d.ts +0 -2
  167. package/net/socket.d.ts +7 -1
  168. package/net/socket.lua +45 -4
  169. package/network.d.ts +1 -0
  170. package/network.lua +3 -2
  171. package/objutil/ability.d.ts +0 -1
  172. package/objutil/buff.d.ts +0 -1
  173. package/objutil/buff.lua +1 -1
  174. package/objutil/object.d.ts +0 -1
  175. package/objutil/unit.d.ts +0 -1
  176. package/objutil/unit.lua +8 -0
  177. package/package.json +13 -14
  178. package/patch-lua.d.ts +0 -0
  179. package/patch-lua.lua +10 -0
  180. package/property.d.ts +55 -0
  181. package/property.lua +374 -0
  182. package/string.d.ts +30 -0
  183. package/string.lua +14 -0
  184. package/util/stream.d.ts +0 -1
  185. package/utility/arrays.d.ts +11 -5
  186. package/utility/arrays.lua +34 -3
  187. package/utility/bit-set.d.ts +0 -2
  188. package/utility/lazy.d.ts +2 -0
  189. package/utility/lazy.lua +14 -0
  190. package/utility/linked-set.d.ts +11 -3
  191. package/utility/linked-set.lua +5 -2
  192. package/utility/lua-maps.d.ts +1 -2
  193. package/utility/lua-sets.d.ts +1 -2
  194. package/utility/reflection.lua +11 -7
  195. package/utility/types.d.ts +1 -0
  196. package/core/mapbounds.d.ts +0 -8
  197. package/core/mapbounds.lua +0 -12
package/engine/buff.lua CHANGED
@@ -35,6 +35,7 @@ local UnitBonusType = ____bonus.UnitBonusType
35
35
  local ____area_2Ddamage = require("engine.internal.mechanics.area-damage")
36
36
  local damageArea = ____area_2Ddamage.damageArea
37
37
  local ____preconditions = require("utility.preconditions")
38
+ local check = ____preconditions.check
38
39
  local checkNotNull = ____preconditions.checkNotNull
39
40
  local ____effect = require("core.types.effect")
40
41
  local Effect = ____effect.Effect
@@ -44,8 +45,14 @@ local ____unit = require("engine.behaviour.unit")
44
45
  local UnitBehavior = ____unit.UnitBehavior
45
46
  local ____arrays = require("utility.arrays")
46
47
  local forEach = ____arrays.forEach
48
+ local ____event = require("event")
49
+ local Event = ____event.Event
47
50
  local ____ability_2Dduration = require("engine.internal.mechanics.ability-duration")
48
51
  local getAbilityDuration = ____ability_2Dduration.getAbilityDuration
52
+ local ____item = require("engine.internal.item")
53
+ local Item = ____item.Item
54
+ local ____destructable = require("core.types.destructable")
55
+ local Destructable = ____destructable.Destructable
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,75 @@ 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 buffDestroyEvent = __TS__New(Event)
263
308
  ____exports.Buff = __TS__Class()
264
309
  local Buff = ____exports.Buff
265
310
  Buff.name = "Buff"
@@ -268,7 +313,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
268
313
  UnitBehavior.prototype.____constructor(self, _unit)
269
314
  self._unit = _unit
270
315
  self.parameters = nil
271
- self[100] = _unit
316
+ self[100] = 0
317
+ self[101] = _unit
272
318
  local typeId
273
319
  local polarity
274
320
  local resistanceType
@@ -277,7 +323,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
277
323
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
278
324
  polarity = resistanceTypeOrPolarity
279
325
  resistanceType = abilityOrParametersOrResistanceType
280
- if __TS__InstanceOf(parametersOrAbility, Ability) then
326
+ if __TS__InstanceOf(parametersOrAbility, Ability) or parametersOrAbility == nil then
281
327
  ability = parametersOrAbility
282
328
  else
283
329
  ability = nil
@@ -287,7 +333,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
287
333
  typeId = typeIdOrTypeIds
288
334
  polarity = polarityOrTypeIdSelectionPolicy
289
335
  resistanceType = resistanceTypeOrPolarity
290
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
336
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) or abilityOrParametersOrResistanceType == nil then
291
337
  ability = abilityOrParametersOrResistanceType
292
338
  parameters = parametersOrAbility
293
339
  else
@@ -296,9 +342,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
296
342
  end
297
343
  end
298
344
  self.typeId = typeId
299
- self.polarity = polarity
300
- self.resistanceType = resistanceType
301
- if not __TS__InstanceOf(ability, Ability) then
345
+ if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
302
346
  parameters = ability
303
347
  ability = nil
304
348
  end
@@ -324,14 +368,21 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
324
368
  learnLevelMinimum = learnLevelMinimum or ability:getField(ABILITY_IF_REQUIRED_LEVEL)
325
369
  duration = duration or getAbilityDuration(ability, _unit)
326
370
  end
371
+ self.polarity = resolveEnumValue(ability, level, polarity)
372
+ self.resistanceType = resolveEnumValue(ability, level, resistanceType)
373
+ local missProbability = parameters and parameters.missProbability or defaultParameters.missProbability
374
+ if missProbability ~= nil then
375
+ missProbability = resolveNumberValue(ability, level, missProbability)
376
+ self[142] = missProbability
377
+ end
327
378
  local buffByTypeId = buffByTypeIdByUnit[_unit]
328
379
  if buffByTypeId == nil then
329
380
  buffByTypeId = {}
330
381
  buffByTypeIdByUnit[_unit] = buffByTypeId
331
382
  end
332
- local ____opt_13 = buffByTypeId[typeId]
333
- if ____opt_13 ~= nil then
334
- ____opt_13:destroy()
383
+ local ____opt_15 = buffByTypeId[typeId]
384
+ if ____opt_15 ~= nil then
385
+ ____opt_15:destroy()
335
386
  end
336
387
  local uniqueGroup = parameters and parameters.uniqueGroup or defaultParameters and defaultParameters.uniqueGroup
337
388
  if uniqueGroup ~= nil then
@@ -340,18 +391,21 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
340
391
  if not internalApplyBuff(
341
392
  _unit,
342
393
  typeId,
343
- polarity,
344
- resistanceType,
394
+ self.polarity,
395
+ self.resistanceType,
345
396
  level,
346
397
  duration,
347
398
  spellStealPriority,
348
- learnLevelMinimum
399
+ learnLevelMinimum,
400
+ missProbability
349
401
  ) then
402
+ self[100] = 1
350
403
  UnitBehavior.prototype.destroy(self)
351
404
  error(unsuccessfulApplicationMarker, 0)
352
405
  end
353
406
  local handle = BlzGetUnitAbility(_unit.handle, typeId)
354
407
  if handle == nil then
408
+ self[100] = 1
355
409
  UnitBehavior.prototype.destroy(self)
356
410
  error(unsuccessfulApplicationMarker, 0)
357
411
  end
@@ -360,20 +414,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
360
414
  self._level = level
361
415
  self._spellStealPriority = spellStealPriority
362
416
  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)
417
+ self[102] = source
418
+ self[103] = duration or 0
419
+ self[104] = uniqueGroup
420
+ self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
421
+ self[106] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
368
422
  if parameters ~= nil or (next(defaultParameters)) ~= nil then
369
423
  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]
424
+ local ____ability_24 = ability
425
+ local ____level_25 = level
426
+ local ____temp_23 = parameters and parameters[buffBooleanParameter]
427
+ if ____temp_23 == nil then
428
+ ____temp_23 = defaultParameters[buffBooleanParameter]
375
429
  end
376
- if resolveBooleanValue(____ability_22, ____level_23, ____temp_21) then
430
+ if resolveBooleanValue(____ability_24, ____level_25, ____temp_23) then
377
431
  self[buffBooleanParameter] = true
378
432
  end
379
433
  end
@@ -389,11 +443,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
389
443
  end
390
444
  local maximumDuration = parameters and parameters.maximumDuration or defaultParameters.maximumDuration
391
445
  if maximumDuration ~= nil then
392
- self[107] = resolveNumberValue(ability, level, maximumDuration)
446
+ self[108] = resolveNumberValue(ability, level, maximumDuration)
393
447
  end
394
448
  local maximumRemainingDuration = parameters and parameters.maximumRemainingDuration or defaultParameters.maximumRemainingDuration
395
449
  if maximumRemainingDuration ~= nil then
396
- self[108] = resolveNumberValue(ability, level, maximumRemainingDuration)
450
+ self[109] = resolveNumberValue(ability, level, maximumRemainingDuration)
397
451
  end
398
452
  local parametersAbilityTypeIds = parameters and parameters.abilityTypeIds or defaultParameters.abilityTypeIds
399
453
  if parametersAbilityTypeIds ~= nil then
@@ -450,10 +504,12 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
450
504
  timer:start(duration, false, expireBuff, self)
451
505
  self._timer = timer
452
506
  end
507
+ self:onCreate()
508
+ self[100] = 1
453
509
  end
454
510
  function Buff.prototype.getUnitBonus(self, bonusType)
455
- local ____opt_36 = self._bonusIdByBonusType
456
- local bonusId = ____opt_36 and ____opt_36[bonusType]
511
+ local ____opt_38 = self._bonusIdByBonusType
512
+ local bonusId = ____opt_38 and ____opt_38[bonusType]
457
513
  return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
458
514
  end
459
515
  function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
@@ -464,63 +520,71 @@ function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
464
520
  end
465
521
  bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
466
522
  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
523
+ function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
524
+ if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
525
+ Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
479
526
  else
480
- ____isWidgetProvided_38 = widgetOrDuration
527
+ local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
528
+ local ____Effect_42 = Effect
529
+ local ____Effect_flash_43 = Effect.flash
530
+ local ____array_41 = __TS__SparseArrayNew(
531
+ self[105],
532
+ isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
533
+ stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
534
+ )
535
+ local ____isWidgetProvided_40
536
+ if isWidgetProvided then
537
+ ____isWidgetProvided_40 = yOrParametersOrDuration
538
+ else
539
+ ____isWidgetProvided_40 = widgetOrXOrParametersOrDuration
540
+ end
541
+ __TS__SparseArrayPush(____array_41, ____isWidgetProvided_40)
542
+ ____Effect_flash_43(
543
+ ____Effect_42,
544
+ __TS__SparseArraySpread(____array_41)
545
+ )
481
546
  end
482
- __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
483
- ____Effect_flash_41(
484
- ____Effect_40,
485
- __TS__SparseArraySpread(____array_39)
486
- )
487
547
  end
488
548
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
489
549
  local isWidgetProvided = type(widgetOrDuration) == "table"
490
- local ____Effect_44 = Effect
491
- local ____Effect_flash_45 = Effect.flash
492
- local ____array_43 = __TS__SparseArrayNew(
493
- self[105],
550
+ local ____Effect_46 = Effect
551
+ local ____Effect_flash_47 = Effect.flash
552
+ local ____array_45 = __TS__SparseArrayNew(
553
+ self[106],
494
554
  isWidgetProvided and widgetOrDuration or self._unit,
495
555
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
496
556
  )
497
- local ____isWidgetProvided_42
557
+ local ____isWidgetProvided_44
498
558
  if isWidgetProvided then
499
- ____isWidgetProvided_42 = duration
559
+ ____isWidgetProvided_44 = duration
500
560
  else
501
- ____isWidgetProvided_42 = widgetOrDuration
561
+ ____isWidgetProvided_44 = widgetOrDuration
502
562
  end
503
- __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
504
- ____Effect_flash_45(
505
- ____Effect_44,
506
- __TS__SparseArraySpread(____array_43)
563
+ __TS__SparseArrayPush(____array_45, ____isWidgetProvided_44)
564
+ ____Effect_flash_47(
565
+ ____Effect_46,
566
+ __TS__SparseArraySpread(____array_45)
507
567
  )
508
568
  end
569
+ function Buff.prototype.onCreate(self)
570
+ end
509
571
  function Buff.prototype.onDestroy(self)
572
+ check(self[100] ~= 0, "Cannot destroy a buff that has not finished creating yet.")
573
+ self[100] = 2
510
574
  local unit = self._unit
511
575
  if getUnitAbility(unit.handle, self.typeId) == self.handle then
512
576
  removeBuff(unit.handle, self.typeId)
513
577
  end
514
578
  buffByTypeIdByUnit[unit][self.typeId] = nil
515
- local healingIntervalTimer = self[118]
579
+ local healingIntervalTimer = self[119]
516
580
  if healingIntervalTimer ~= nil then
517
581
  healingIntervalTimer:destroy()
518
- self[118] = nil
582
+ self[119] = nil
519
583
  end
520
- local damageIntervalTimer = self[113]
584
+ local damageIntervalTimer = self[114]
521
585
  if damageIntervalTimer ~= nil then
522
586
  damageIntervalTimer:destroy()
523
- self[113] = nil
587
+ self[114] = nil
524
588
  end
525
589
  if self._timer ~= nil then
526
590
  self._timer:destroy()
@@ -530,15 +594,21 @@ function Buff.prototype.onDestroy(self)
530
594
  behavior:destroy()
531
595
  end
532
596
  end
533
- if self[130] then
597
+ if self[139] then
598
+ unit:decrementInvulnerabilityCounter()
599
+ end
600
+ if self[138] then
534
601
  unit:decrementDisableAutoAttackCounter()
535
602
  end
536
- if self[128] then
537
- if self[129] then
603
+ if self[136] then
604
+ if self[137] then
538
605
  unit:decrementStunCounter()
539
606
  end
540
607
  unit:decrementStunCounter()
541
608
  end
609
+ if self[135] then
610
+ unit:decrementGhostCounter()
611
+ end
542
612
  if self._abilityTypeIds ~= nil then
543
613
  for abilityTypeId in pairs(self._abilityTypeIds) do
544
614
  unit:removeAbility(abilityTypeId)
@@ -549,6 +619,8 @@ function Buff.prototype.onDestroy(self)
549
619
  removeUnitBonus(unit, bonusType, bonusId)
550
620
  end
551
621
  end
622
+ Event.invoke(buffDestroyEvent, self)
623
+ self[100] = 3
552
624
  return UnitBehavior.prototype.onDestroy(self)
553
625
  end
554
626
  function Buff.apply(self, ...)
@@ -576,51 +648,81 @@ function Buff.apply(self, ...)
576
648
  end
577
649
  end
578
650
  function Buff.getByTypeId(self, unit, typeId)
579
- local ____opt_46 = buffByTypeIdByUnit[unit]
580
- local buff = ____opt_46 and ____opt_46[typeId]
651
+ local ____opt_48 = buffByTypeIdByUnit[unit]
652
+ local buff = ____opt_48 and ____opt_48[typeId]
581
653
  if __TS__InstanceOf(buff, self) then
582
654
  return buff
583
655
  end
584
656
  return nil
585
657
  end
658
+ function Buff.prototype.onExpiration(self)
659
+ local unit = self.unit
660
+ if self[120] ~= nil then
661
+ (self[102] or unit):damageTarget(unit, self[120] or 0)
662
+ end
663
+ if self[121] ~= nil then
664
+ (self[102] or unit):healTarget(unit, self[120] or 0)
665
+ end
666
+ if self[141] then
667
+ unit:explode()
668
+ elseif self[140] then
669
+ unit:kill()
670
+ end
671
+ end
586
672
  function Buff.prototype.onDeath(self, source)
587
673
  local unit = self.unit
588
- if self[119] ~= nil then
674
+ if self[122] ~= nil then
589
675
  damageArea(
590
- self[101] or unit,
591
- self[119],
676
+ self[102] or unit,
677
+ self[122],
592
678
  unit.x,
593
679
  unit.y,
594
- self[121] or 0,
595
- self[120] or 0,
680
+ self[124] or 0,
596
681
  self[123] or 0,
597
- self[122] or 0,
682
+ self[126] or 0,
598
683
  self[125] or 0,
599
- self[124] or 0
684
+ self[128] or 0,
685
+ self[127] or 0
600
686
  )
601
687
  end
602
688
  end
603
689
  function Buff.prototype.onDamageDealt(self, target, event)
604
690
  if event.isAttack then
605
- if self[106] ~= nil then
606
- local durationIncrease = self[106]
607
- local maximumDuration = self[107] or 0
691
+ if self[107] ~= nil then
692
+ local durationIncrease = self[107]
693
+ local maximumDuration = self[108] or 0
608
694
  if maximumDuration > 0 then
609
695
  durationIncrease = min(
610
696
  durationIncrease,
611
- max(0, maximumDuration - self[102])
697
+ max(0, maximumDuration - self[103])
612
698
  )
613
699
  end
614
700
  local remainingDuration = self.remainingDuration + durationIncrease
615
- local maximumRemainingDuration = self[108] or 0
701
+ local maximumRemainingDuration = self[109] or 0
616
702
  if maximumRemainingDuration > 0 then
617
703
  remainingDuration = min(remainingDuration, maximumRemainingDuration)
618
704
  end
619
705
  self.remainingDuration = remainingDuration
620
706
  end
621
- local autoAttackCount = (self[126] or 0) + 1
622
- self[126] = autoAttackCount
623
- if autoAttackCount == self[127] then
707
+ local autoAttackCount = (self[129] or 0) + 1
708
+ self[129] = autoAttackCount
709
+ if autoAttackCount == self[130] then
710
+ self:destroy()
711
+ end
712
+ end
713
+ if event.originalAmount ~= 0 then
714
+ local damageDealtEventCount = (self[131] or 0) + 1
715
+ self[131] = damageDealtEventCount
716
+ if damageDealtEventCount == self[132] then
717
+ self:destroy()
718
+ end
719
+ end
720
+ end
721
+ function Buff.prototype.onDamageReceived(self, source, event)
722
+ if event.originalAmount ~= 0 then
723
+ local damageReceivedEventCount = (self[133] or 0) + 1
724
+ self[133] = damageReceivedEventCount
725
+ if damageReceivedEventCount == self[134] then
624
726
  self:destroy()
625
727
  end
626
728
  end
@@ -630,7 +732,7 @@ __TS__SetDescriptor(
630
732
  Buff.prototype,
631
733
  "source",
632
734
  {get = function(self)
633
- return self[101] or self._unit
735
+ return self[102] or self._unit
634
736
  end},
635
737
  true
636
738
  )
@@ -647,13 +749,13 @@ __TS__SetDescriptor(
647
749
  "remainingDamageOverDuration",
648
750
  {
649
751
  get = function(self)
650
- return self[112] or 0
752
+ return self[113] or 0
651
753
  end,
652
754
  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
755
+ local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[113] or 0)
756
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
757
+ local damageOverDuration = (self[110] or 0) + remainingDamageOverDurationDelta
758
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
657
759
  end
658
760
  },
659
761
  true
@@ -663,13 +765,13 @@ __TS__SetDescriptor(
663
765
  "damageOverDuration",
664
766
  {
665
767
  get = function(self)
666
- return self[109] or 0
768
+ return self[110] or 0
667
769
  end,
668
770
  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
771
+ local damageOverDurationDelta = damageOverDuration - (self[110] or 0)
772
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
773
+ local remainingDamageOverDuration = (self[113] or 0) + damageOverDurationDelta
774
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
673
775
  end
674
776
  },
675
777
  true
@@ -679,10 +781,10 @@ __TS__SetDescriptor(
679
781
  "damagePerInterval",
680
782
  {
681
783
  get = function(self)
682
- return self[110] or 0
784
+ return self[111] or 0
683
785
  end,
684
786
  set = function(self, damagePerInterval)
685
- self[110] = damagePerInterval ~= 0 and damagePerInterval or nil
787
+ self[111] = damagePerInterval ~= 0 and damagePerInterval or nil
686
788
  end
687
789
  },
688
790
  true
@@ -692,25 +794,25 @@ __TS__SetDescriptor(
692
794
  "damageInterval",
693
795
  {
694
796
  get = function(self)
695
- return self[111] or 0
797
+ return self[112] or 0
696
798
  end,
697
799
  set = function(self, damageInterval)
698
800
  if damageInterval <= 0 then
699
- self[111] = damageInterval ~= 0 and damageInterval or nil
700
- local timer = self[113]
801
+ self[112] = damageInterval ~= 0 and damageInterval or nil
802
+ local timer = self[114]
701
803
  if timer ~= nil then
702
804
  timer:destroy()
703
- self[113] = nil
805
+ self[114] = nil
704
806
  end
705
807
  return
706
808
  end
707
- self[111] = damageInterval
708
- local ____opt_48 = self._timer
709
- local elapsed = ____opt_48 and ____opt_48.elapsed or 0
710
- local timer = self[113]
809
+ self[112] = damageInterval
810
+ local ____opt_50 = self._timer
811
+ local elapsed = ____opt_50 and ____opt_50.elapsed or 0
812
+ local timer = self[114]
711
813
  if timer == nil then
712
814
  timer = Timer:create()
713
- self[113] = timer
815
+ self[114] = timer
714
816
  end
715
817
  local initialDelay = damageInterval - (elapsed >= damageInterval and math.fmod(elapsed, damageInterval) or elapsed)
716
818
  if initialDelay == damageInterval then
@@ -727,13 +829,13 @@ __TS__SetDescriptor(
727
829
  "remainingHealingOverDuration",
728
830
  {
729
831
  get = function(self)
730
- return self[117] or 0
832
+ return self[118] or 0
731
833
  end,
732
834
  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
835
+ local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[118] or 0)
836
+ self[113] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
837
+ local healingOverDuration = (self[115] or 0) + remainingHealingOverDurationDelta
838
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
737
839
  end
738
840
  },
739
841
  true
@@ -743,13 +845,13 @@ __TS__SetDescriptor(
743
845
  "healingOverDuration",
744
846
  {
745
847
  get = function(self)
746
- return self[114] or 0
848
+ return self[115] or 0
747
849
  end,
748
850
  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
851
+ local healingOverDurationDelta = healingOverDuration - (self[115] or 0)
852
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
853
+ local remainingHealingOverDuration = (self[118] or 0) + healingOverDurationDelta
854
+ self[118] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
753
855
  end
754
856
  },
755
857
  true
@@ -759,10 +861,10 @@ __TS__SetDescriptor(
759
861
  "healingPerInterval",
760
862
  {
761
863
  get = function(self)
762
- return self[115] or 0
864
+ return self[116] or 0
763
865
  end,
764
866
  set = function(self, healingPerInterval)
765
- self[115] = healingPerInterval ~= 0 and healingPerInterval or nil
867
+ self[116] = healingPerInterval ~= 0 and healingPerInterval or nil
766
868
  end
767
869
  },
768
870
  true
@@ -772,25 +874,25 @@ __TS__SetDescriptor(
772
874
  "healingInterval",
773
875
  {
774
876
  get = function(self)
775
- return self[116] or 0
877
+ return self[117] or 0
776
878
  end,
777
879
  set = function(self, healingInterval)
778
880
  if healingInterval <= 0 then
779
- self[116] = healingInterval ~= 0 and healingInterval or nil
780
- local timer = self[118]
881
+ self[117] = healingInterval ~= 0 and healingInterval or nil
882
+ local timer = self[119]
781
883
  if timer ~= nil then
782
884
  timer:destroy()
783
- self[118] = nil
885
+ self[119] = nil
784
886
  end
785
887
  return
786
888
  end
787
- self[116] = healingInterval
788
- local ____opt_50 = self._timer
789
- local elapsed = ____opt_50 and ____opt_50.elapsed or 0
790
- local timer = self[118]
889
+ self[117] = healingInterval
890
+ local ____opt_52 = self._timer
891
+ local elapsed = ____opt_52 and ____opt_52.elapsed or 0
892
+ local timer = self[119]
791
893
  if timer == nil then
792
894
  timer = Timer:create()
793
- self[118] = timer
895
+ self[119] = timer
794
896
  end
795
897
  local initialDelay = healingInterval - (elapsed >= healingInterval and math.fmod(elapsed, healingInterval) or elapsed)
796
898
  if initialDelay == healingInterval then
@@ -802,6 +904,45 @@ __TS__SetDescriptor(
802
904
  },
803
905
  true
804
906
  )
907
+ __TS__SetDescriptor(
908
+ Buff.prototype,
909
+ "damageOnExpiration",
910
+ {
911
+ get = function(self)
912
+ return self[120] or 0
913
+ end,
914
+ set = function(self, damageOnExpiration)
915
+ self[120] = damageOnExpiration ~= 0 and damageOnExpiration or nil
916
+ end
917
+ },
918
+ true
919
+ )
920
+ __TS__SetDescriptor(
921
+ Buff.prototype,
922
+ "healingOnExpiration",
923
+ {
924
+ get = function(self)
925
+ return self[121] or 0
926
+ end,
927
+ set = function(self, healingOnExpiration)
928
+ self[121] = healingOnExpiration ~= 0 and healingOnExpiration or nil
929
+ end
930
+ },
931
+ true
932
+ )
933
+ __TS__SetDescriptor(
934
+ Buff.prototype,
935
+ "damageFactor",
936
+ {
937
+ get = function(self)
938
+ return self:getUnitBonus(UnitBonusType.DAMAGE_FACTOR)
939
+ end,
940
+ set = function(self, damageFactor)
941
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.DAMAGE_FACTOR, damageFactor)
942
+ end
943
+ },
944
+ true
945
+ )
805
946
  __TS__SetDescriptor(
806
947
  Buff.prototype,
807
948
  "receivedDamageFactor",
@@ -828,30 +969,53 @@ __TS__SetDescriptor(
828
969
  },
829
970
  true
830
971
  )
972
+ __TS__SetDescriptor(
973
+ Buff.prototype,
974
+ "turnsIntoGhost",
975
+ {
976
+ get = function(self)
977
+ local ____self__135_54 = self[135]
978
+ if ____self__135_54 == nil then
979
+ ____self__135_54 = false
980
+ end
981
+ return ____self__135_54
982
+ end,
983
+ set = function(self, turnsIntoGhost)
984
+ if not turnsIntoGhost and self[135] then
985
+ self.object:decrementGhostCounter()
986
+ self[135] = nil
987
+ elseif turnsIntoGhost and not self[135] then
988
+ self.object:incrementGhostCounter()
989
+ self[135] = true
990
+ end
991
+ end
992
+ },
993
+ true
994
+ )
831
995
  __TS__SetDescriptor(
832
996
  Buff.prototype,
833
997
  "stuns",
834
998
  {
835
999
  get = function(self)
836
- local ____self__128_52 = self[128]
837
- if ____self__128_52 == nil then
838
- ____self__128_52 = false
1000
+ local ____self__136_55 = self[136]
1001
+ if ____self__136_55 == nil then
1002
+ ____self__136_55 = false
839
1003
  end
840
- return ____self__128_52
1004
+ return ____self__136_55
841
1005
  end,
842
1006
  set = function(self, stuns)
843
- if not stuns and self[128] then
844
- if self[129] then
1007
+ if not stuns and self[136] then
1008
+ if self[137] then
845
1009
  self.object:decrementStunCounter()
846
1010
  end
847
1011
  self.object:decrementStunCounter()
848
- self[128] = nil
849
- elseif stuns and not self[128] then
850
- if self[129] then
1012
+ self[136] = nil
1013
+ elseif stuns and not self[136] then
1014
+ if self[137] then
851
1015
  self.object:incrementStunCounter()
852
1016
  end
853
1017
  self.object:incrementStunCounter()
854
- self[128] = true
1018
+ self[136] = true
855
1019
  end
856
1020
  end
857
1021
  },
@@ -862,23 +1026,23 @@ __TS__SetDescriptor(
862
1026
  "ignoresStunImmunity",
863
1027
  {
864
1028
  get = function(self)
865
- local ____self__129_53 = self[129]
866
- if ____self__129_53 == nil then
867
- ____self__129_53 = false
1029
+ local ____self__137_56 = self[137]
1030
+ if ____self__137_56 == nil then
1031
+ ____self__137_56 = false
868
1032
  end
869
- return ____self__129_53
1033
+ return ____self__137_56
870
1034
  end,
871
1035
  set = function(self, ignoresStunImmunity)
872
- if not ignoresStunImmunity and self[129] then
873
- if self[128] then
1036
+ if not ignoresStunImmunity and self[137] then
1037
+ if self[136] then
874
1038
  self.object:decrementStunCounter()
875
1039
  end
876
- self[129] = nil
877
- elseif ignoresStunImmunity and not self[129] then
878
- if self[128] then
1040
+ self[137] = nil
1041
+ elseif ignoresStunImmunity and not self[137] then
1042
+ if self[136] then
879
1043
  self.object:incrementStunCounter()
880
1044
  end
881
- self[129] = true
1045
+ self[137] = true
882
1046
  end
883
1047
  end
884
1048
  },
@@ -889,19 +1053,19 @@ __TS__SetDescriptor(
889
1053
  "disablesAutoAttack",
890
1054
  {
891
1055
  get = function(self)
892
- local ____self__130_54 = self[130]
893
- if ____self__130_54 == nil then
894
- ____self__130_54 = false
1056
+ local ____self__138_57 = self[138]
1057
+ if ____self__138_57 == nil then
1058
+ ____self__138_57 = false
895
1059
  end
896
- return ____self__130_54
1060
+ return ____self__138_57
897
1061
  end,
898
1062
  set = function(self, disablesAutoAttack)
899
- if not disablesAutoAttack and self[130] then
1063
+ if not disablesAutoAttack and self[138] then
900
1064
  self.object:decrementDisableAutoAttackCounter()
901
- self[130] = nil
902
- elseif disablesAutoAttack and not self[130] then
1065
+ self[138] = nil
1066
+ elseif disablesAutoAttack and not self[138] then
903
1067
  self.object:incrementDisableAutoAttackCounter()
904
- self[130] = true
1068
+ self[138] = true
905
1069
  end
906
1070
  end
907
1071
  },
@@ -912,19 +1076,95 @@ __TS__SetDescriptor(
912
1076
  "providesInvulnerability",
913
1077
  {
914
1078
  get = function(self)
915
- local ____self__131_55 = self[131]
916
- if ____self__131_55 == nil then
917
- ____self__131_55 = false
1079
+ local ____self__139_58 = self[139]
1080
+ if ____self__139_58 == nil then
1081
+ ____self__139_58 = false
918
1082
  end
919
- return ____self__131_55
1083
+ return ____self__139_58
920
1084
  end,
921
1085
  set = function(self, providesInvulnerability)
922
- if not providesInvulnerability and self[131] then
1086
+ if not providesInvulnerability and self[139] then
923
1087
  self.object:decrementInvulnerabilityCounter()
924
- self[131] = nil
925
- elseif providesInvulnerability and not self[131] then
1088
+ self[139] = nil
1089
+ elseif providesInvulnerability and not self[139] then
926
1090
  self.object:incrementInvulnerabilityCounter()
927
- self[131] = true
1091
+ self[139] = true
1092
+ end
1093
+ end
1094
+ },
1095
+ true
1096
+ )
1097
+ __TS__SetDescriptor(
1098
+ Buff.prototype,
1099
+ "killsOnExpiration",
1100
+ {
1101
+ get = function(self)
1102
+ local ____self__140_59 = self[140]
1103
+ if ____self__140_59 == nil then
1104
+ ____self__140_59 = false
1105
+ end
1106
+ return ____self__140_59
1107
+ end,
1108
+ set = function(self, killsOnExpiration)
1109
+ if not killsOnExpiration and self[140] then
1110
+ self[140] = nil
1111
+ elseif killsOnExpiration and not self[140] then
1112
+ self[140] = true
1113
+ end
1114
+ end
1115
+ },
1116
+ true
1117
+ )
1118
+ __TS__SetDescriptor(
1119
+ Buff.prototype,
1120
+ "explodesOnExpiration",
1121
+ {
1122
+ get = function(self)
1123
+ local ____self__141_60 = self[141]
1124
+ if ____self__141_60 == nil then
1125
+ ____self__141_60 = false
1126
+ end
1127
+ return ____self__141_60
1128
+ end,
1129
+ set = function(self, killsOnExpiration)
1130
+ if not killsOnExpiration and self[141] then
1131
+ self[141] = nil
1132
+ elseif killsOnExpiration and not self[141] then
1133
+ self[141] = true
1134
+ end
1135
+ end
1136
+ },
1137
+ true
1138
+ )
1139
+ __TS__SetDescriptor(
1140
+ Buff.prototype,
1141
+ "maximumDamageDealtEventCount",
1142
+ {
1143
+ get = function(self)
1144
+ return self[132] or 0
1145
+ end,
1146
+ set = function(self, maximumDamageDealtEventCount)
1147
+ if maximumDamageDealtEventCount == 0 then
1148
+ self[132] = nil
1149
+ else
1150
+ self[132] = maximumDamageDealtEventCount
1151
+ end
1152
+ end
1153
+ },
1154
+ true
1155
+ )
1156
+ __TS__SetDescriptor(
1157
+ Buff.prototype,
1158
+ "maximumDamageReceivedEventCount",
1159
+ {
1160
+ get = function(self)
1161
+ return self[134] or 0
1162
+ end,
1163
+ set = function(self, maximumDamageReceivedEventCount)
1164
+ if maximumDamageReceivedEventCount == 0 then
1165
+ self[134] = nil
1166
+ else
1167
+ self[134] = maximumDamageReceivedEventCount
928
1168
  end
929
1169
  end
930
1170
  },
@@ -935,13 +1175,13 @@ __TS__SetDescriptor(
935
1175
  "maximumAutoAttackCount",
936
1176
  {
937
1177
  get = function(self)
938
- return self[127] or 0
1178
+ return self[130] or 0
939
1179
  end,
940
1180
  set = function(self, maximumAutoAttackCount)
941
1181
  if maximumAutoAttackCount == 0 then
942
- self[127] = nil
1182
+ self[130] = nil
943
1183
  else
944
- self[127] = maximumAutoAttackCount
1184
+ self[130] = maximumAutoAttackCount
945
1185
  end
946
1186
  end
947
1187
  },
@@ -952,10 +1192,10 @@ __TS__SetDescriptor(
952
1192
  "durationIncreaseOnAutoAttack",
953
1193
  {
954
1194
  get = function(self)
955
- return self[106] or 0
1195
+ return self[107] or 0
956
1196
  end,
957
1197
  set = function(self, durationIncreaseOnAutoAttack)
958
- self[106] = durationIncreaseOnAutoAttack
1198
+ self[107] = durationIncreaseOnAutoAttack
959
1199
  end
960
1200
  },
961
1201
  true
@@ -986,11 +1226,24 @@ __TS__SetDescriptor(
986
1226
  },
987
1227
  true
988
1228
  )
1229
+ __TS__SetDescriptor(
1230
+ Buff.prototype,
1231
+ "evasionProbability",
1232
+ {
1233
+ get = function(self)
1234
+ return self:getUnitBonus(UnitBonusType.EVASION_PROBABILITY)
1235
+ end,
1236
+ set = function(self, evasionProbability)
1237
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.EVASION_PROBABILITY, evasionProbability)
1238
+ end
1239
+ },
1240
+ true
1241
+ )
989
1242
  __TS__SetDescriptor(
990
1243
  Buff.prototype,
991
1244
  "duration",
992
1245
  {get = function(self)
993
- return self[102]
1246
+ return self[103]
994
1247
  end},
995
1248
  true
996
1249
  )
@@ -999,15 +1252,15 @@ __TS__SetDescriptor(
999
1252
  "remainingDuration",
1000
1253
  {
1001
1254
  get = function(self)
1002
- local ____opt_56 = self._timer
1003
- return ____opt_56 and ____opt_56.remaining or 0
1255
+ local ____opt_61 = self._timer
1256
+ return ____opt_61 and ____opt_61.remaining or 0
1004
1257
  end,
1005
1258
  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)
1259
+ local ____remainingDuration_65 = remainingDuration
1260
+ local ____opt_63 = self._timer
1261
+ local remainingDurationDelta = ____remainingDuration_65 - (____opt_63 and ____opt_63.remaining or 0)
1009
1262
  if remainingDurationDelta ~= 0 then
1010
- self[102] = self[102] + remainingDurationDelta
1263
+ self[103] = self[103] + remainingDurationDelta
1011
1264
  if remainingDuration <= 0 then
1012
1265
  Timer:run(destroyBuff, self)
1013
1266
  else
@@ -1019,7 +1272,8 @@ __TS__SetDescriptor(
1019
1272
  self._level,
1020
1273
  remainingDuration,
1021
1274
  self._spellStealPriority,
1022
- self._learnLevelMinimum
1275
+ self._learnLevelMinimum,
1276
+ self[142]
1023
1277
  ) then
1024
1278
  local timer = self._timer
1025
1279
  if timer == nil then
@@ -1033,26 +1287,25 @@ __TS__SetDescriptor(
1033
1287
  end
1034
1288
  },
1035
1289
  true
1036
- );
1290
+ )
1291
+ Buff.destroyEvent = buffDestroyEvent;
1037
1292
  (function(self)
1293
+ local function destroyBuffIfNeeded(buff)
1294
+ if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
1295
+ buff:destroy()
1296
+ end
1297
+ end
1038
1298
  ____exports.checkBuff = function(unit, buffTypeId)
1039
1299
  local buffByTypeId = buffByTypeIdByUnit[unit]
1040
1300
  if buffByTypeId ~= nil then
1041
1301
  local buff = buffByTypeId[buffTypeId]
1042
- if buff ~= nil and getUnitAbility(unit.handle, buffTypeId) ~= buff.handle then
1043
- buff:destroy()
1302
+ if buff ~= nil then
1303
+ destroyBuffIfNeeded(buff)
1044
1304
  end
1045
1305
  end
1046
1306
  end
1047
1307
  ____exports.checkBuffs = function(unit)
1048
- local buffByTypeId = buffByTypeIdByUnit[unit]
1049
- if buffByTypeId ~= nil then
1050
- for ____, buff in pairs(buffByTypeId) do
1051
- if getUnitAbility(unit.handle, buff.typeId) ~= buff.handle then
1052
- buff:destroy()
1053
- end
1054
- end
1055
- end
1308
+ ____exports.Buff:forAll(unit, destroyBuffIfNeeded)
1056
1309
  end
1057
1310
  Unit.abilityChannelingStartEvent:addListener(
1058
1311
  0,