warscript 0.0.1-dev.ccc2b77 → 0.0.1-dev.cdcfbc9

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