warscript 0.0.1-dev.a5f2d10 → 0.0.1-dev.a73c979

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