warscript 0.0.1-dev.9eab2af → 0.0.1-dev.9f30788

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