warscript 0.0.1-dev.d63794c → 0.0.1-dev.d842bb6

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 (47) hide show
  1. package/core/types/sound.d.ts +1 -0
  2. package/core/types/sound.lua +32 -2
  3. package/engine/behaviour/ability/apply-buff.d.ts +5 -0
  4. package/engine/behaviour/ability/apply-buff.lua +32 -0
  5. package/engine/behaviour/ability/emulate-impact.lua +4 -5
  6. package/engine/behaviour/ability/on-command-impact.lua +7 -0
  7. package/engine/behaviour/ability.d.ts +7 -2
  8. package/engine/behaviour/ability.lua +48 -3
  9. package/engine/buff.d.ts +50 -40
  10. package/engine/buff.lua +261 -225
  11. package/engine/internal/ability.lua +17 -24
  12. package/engine/internal/item/ability.lua +77 -3
  13. package/engine/internal/item.d.ts +2 -2
  14. package/engine/internal/item.lua +56 -25
  15. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  16. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  17. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  18. package/engine/internal/object-data/evasion-probability.lua +16 -0
  19. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  20. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  21. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  22. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  23. package/engine/internal/unit/bonus.d.ts +2 -0
  24. package/engine/internal/unit/bonus.lua +17 -0
  25. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  26. package/engine/internal/unit/ignore-events-items.lua +5 -0
  27. package/engine/internal/unit/item.lua +3 -4
  28. package/engine/internal/unit.d.ts +1 -0
  29. package/engine/internal/unit.lua +40 -11
  30. package/engine/lightning.d.ts +12 -5
  31. package/engine/lightning.lua +48 -14
  32. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  33. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  34. package/engine/object-data/entry/ability-type/blank-configurable.lua +21 -1
  35. package/engine/object-data/entry/ability-type/curse.lua +2 -2
  36. package/engine/object-data/entry/ability-type.lua +8 -12
  37. package/engine/object-data/entry/buff-type/applicable.lua +10 -34
  38. package/engine/object-data/entry/item-type.d.ts +2 -0
  39. package/engine/object-data/entry/item-type.lua +13 -0
  40. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  41. package/engine/object-field/ability.d.ts +5 -2
  42. package/engine/object-field/ability.lua +3 -0
  43. package/engine/object-field.d.ts +2 -2
  44. package/engine/object-field.lua +4 -0
  45. package/engine/unit.d.ts +1 -0
  46. package/engine/unit.lua +1 -0
  47. package/package.json +2 -2
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")
@@ -98,6 +101,8 @@ local buffParametersKeys = {
98
101
  armorIncreaseFactor = true,
99
102
  attackSpeedIncreaseFactor = true,
100
103
  movementSpeedIncreaseFactor = true,
104
+ evasionProbability = true,
105
+ missProbability = true,
101
106
  damageFactor = true,
102
107
  receivedDamageFactor = true,
103
108
  receivedMagicDamageFactor = true,
@@ -180,6 +185,7 @@ local buffNumberParameters = {
180
185
  "durationIncreaseOnAutoAttack",
181
186
  "attackSpeedIncreaseFactor",
182
187
  "movementSpeedIncreaseFactor",
188
+ "evasionProbability",
183
189
  "armorIncrease",
184
190
  "damageFactor",
185
191
  "receivedDamageFactor",
@@ -220,7 +226,7 @@ local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
220
226
  return checkNotNull(firstNativeBuffTypeId)
221
227
  end
222
228
  local function destroyBuffIfItHasSameUniqueGroup(buff, uniqueGroup)
223
- if buff[103] == uniqueGroup then
229
+ if buff[104] == uniqueGroup then
224
230
  buff:destroy()
225
231
  end
226
232
  end
@@ -228,17 +234,17 @@ local function destroyBuff(buff)
228
234
  buff:destroy()
229
235
  end
230
236
  local function expireBuff(buff)
231
- local remainingDamageOverDuration = buff[112] or 0
232
- local remainingHealingOverDuration = buff[112] or 0
237
+ local remainingDamageOverDuration = buff[113] or 0
238
+ local remainingHealingOverDuration = buff[113] or 0
233
239
  if remainingDamageOverDuration ~= 0 or remainingHealingOverDuration ~= 0 then
234
240
  buff:flashSpecialEffect()
235
241
  if remainingDamageOverDuration ~= 0 then
236
- (buff[101] or buff[100]):damageTarget(buff[100], remainingDamageOverDuration)
237
- buff[112] = nil
242
+ (buff[102] or buff[101]):damageTarget(buff[101], remainingDamageOverDuration)
243
+ buff[113] = nil
238
244
  end
239
245
  if remainingHealingOverDuration ~= 0 then
240
- (buff[101] or buff[100]):healTarget(buff[100], remainingHealingOverDuration)
241
- buff[117] = nil
246
+ (buff[102] or buff[101]):healTarget(buff[101], remainingHealingOverDuration)
247
+ buff[118] = nil
242
248
  end
243
249
  end
244
250
  Timer:run(destroyBuff, buff)
@@ -246,56 +252,57 @@ local function expireBuff(buff)
246
252
  end
247
253
  local function buffDamageIntervalInitialTimerCallback(buff)
248
254
  buffDamageIntervalTimerCallback(buff)
249
- local timer = buff[113]
250
- local damageInterval = buff[111]
255
+ local timer = buff[114]
256
+ local damageInterval = buff[112]
251
257
  if timer ~= nil and damageInterval ~= nil and damageInterval > 0 then
252
258
  timer:start(damageInterval, true, buffDamageIntervalTimerCallback, buff)
253
259
  end
254
260
  end
255
261
  buffDamageIntervalTimerCallback = function(buff)
256
262
  buff:flashSpecialEffect()
257
- local source = buff[101] or buff[100]
258
- local remainingDamageOverDuration = buff[112] or 0
263
+ local source = buff[102] or buff[101]
264
+ local remainingDamageOverDuration = buff[113] or 0
259
265
  if remainingDamageOverDuration ~= 0 then
260
- local damageInterval = buff[111] or 0
266
+ local damageInterval = buff[112] or 0
261
267
  if damageInterval ~= 0 then
262
268
  local damage = remainingDamageOverDuration / (1 + buff.remainingDuration / damageInterval)
263
- source:damageTarget(buff[100], damage)
264
- buff[112] = remainingDamageOverDuration - damage
269
+ source:damageTarget(buff[101], damage)
270
+ buff[113] = remainingDamageOverDuration - damage
265
271
  end
266
272
  end
267
- local damagePerInterval = buff[110] or 0
273
+ local damagePerInterval = buff[111] or 0
268
274
  if remainingDamageOverDuration == 0 or damagePerInterval ~= 0 then
269
- source:damageTarget(buff[100], damagePerInterval)
275
+ source:damageTarget(buff[101], damagePerInterval)
270
276
  end
271
277
  end
272
278
  local function buffHealingIntervalInitialTimerCallback(buff)
273
279
  buffHealingIntervalTimerCallback(buff)
274
- local timer = buff[118]
275
- local healingInterval = buff[116]
280
+ local timer = buff[119]
281
+ local healingInterval = buff[117]
276
282
  if timer ~= nil and healingInterval ~= nil and healingInterval > 0 then
277
283
  timer:start(healingInterval, true, buffHealingIntervalTimerCallback, buff)
278
284
  end
279
285
  end
280
286
  buffHealingIntervalTimerCallback = function(buff)
281
- if buff[116] ~= buff[111] then
287
+ if buff[117] ~= buff[112] then
282
288
  buff:flashSpecialEffect()
283
289
  end
284
- local source = buff[101] or buff[100]
285
- local remainingHealingOverDuration = buff[117] or 0
290
+ local source = buff[102] or buff[101]
291
+ local remainingHealingOverDuration = buff[118] or 0
286
292
  if remainingHealingOverDuration ~= 0 then
287
- local healingInterval = buff[116] or 0
293
+ local healingInterval = buff[117] or 0
288
294
  if healingInterval ~= 0 then
289
295
  local healing = remainingHealingOverDuration / (1 + buff.remainingDuration / healingInterval)
290
- source:healTarget(buff[100], healing)
291
- buff[117] = remainingHealingOverDuration - healing
296
+ source:healTarget(buff[101], healing)
297
+ buff[118] = remainingHealingOverDuration - healing
292
298
  end
293
299
  end
294
- local healingPerInterval = buff[115] or 0
300
+ local healingPerInterval = buff[116] or 0
295
301
  if remainingHealingOverDuration == 0 or healingPerInterval ~= 0 then
296
- source:healTarget(buff[100], healingPerInterval)
302
+ source:healTarget(buff[101], healingPerInterval)
297
303
  end
298
304
  end
305
+ local buffDestroyEvent = __TS__New(Event)
299
306
  ____exports.Buff = __TS__Class()
300
307
  local Buff = ____exports.Buff
301
308
  Buff.name = "Buff"
@@ -304,7 +311,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
304
311
  UnitBehavior.prototype.____constructor(self, _unit)
305
312
  self._unit = _unit
306
313
  self.parameters = nil
307
- self[100] = _unit
314
+ self[100] = 0
315
+ self[101] = _unit
308
316
  local typeId
309
317
  local polarity
310
318
  local resistanceType
@@ -360,14 +368,19 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
360
368
  end
361
369
  self.polarity = resolveEnumValue(ability, level, polarity)
362
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[141] = missProbability
375
+ end
363
376
  local buffByTypeId = buffByTypeIdByUnit[_unit]
364
377
  if buffByTypeId == nil then
365
378
  buffByTypeId = {}
366
379
  buffByTypeIdByUnit[_unit] = buffByTypeId
367
380
  end
368
- local ____opt_13 = buffByTypeId[typeId]
369
- if ____opt_13 ~= nil then
370
- ____opt_13:destroy()
381
+ local ____opt_15 = buffByTypeId[typeId]
382
+ if ____opt_15 ~= nil then
383
+ ____opt_15:destroy()
371
384
  end
372
385
  local uniqueGroup = parameters and parameters.uniqueGroup or defaultParameters and defaultParameters.uniqueGroup
373
386
  if uniqueGroup ~= nil then
@@ -381,13 +394,16 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
381
394
  level,
382
395
  duration,
383
396
  spellStealPriority,
384
- learnLevelMinimum
397
+ learnLevelMinimum,
398
+ missProbability
385
399
  ) then
400
+ self[100] = 1
386
401
  UnitBehavior.prototype.destroy(self)
387
402
  error(unsuccessfulApplicationMarker, 0)
388
403
  end
389
404
  local handle = BlzGetUnitAbility(_unit.handle, typeId)
390
405
  if handle == nil then
406
+ self[100] = 1
391
407
  UnitBehavior.prototype.destroy(self)
392
408
  error(unsuccessfulApplicationMarker, 0)
393
409
  end
@@ -396,20 +412,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
396
412
  self._level = level
397
413
  self._spellStealPriority = spellStealPriority
398
414
  self._learnLevelMinimum = learnLevelMinimum
399
- self[101] = source
400
- self[102] = duration or 0
401
- self[103] = uniqueGroup
402
- self[104] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
403
- 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)
404
420
  if parameters ~= nil or (next(defaultParameters)) ~= nil then
405
421
  for ____, buffBooleanParameter in ipairs(buffBooleanParameters) do
406
- local ____ability_22 = ability
407
- local ____level_23 = level
408
- local ____temp_21 = parameters and parameters[buffBooleanParameter]
409
- if ____temp_21 == nil then
410
- ____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]
411
427
  end
412
- if resolveBooleanValue(____ability_22, ____level_23, ____temp_21) then
428
+ if resolveBooleanValue(____ability_24, ____level_25, ____temp_23) then
413
429
  self[buffBooleanParameter] = true
414
430
  end
415
431
  end
@@ -425,11 +441,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
425
441
  end
426
442
  local maximumDuration = parameters and parameters.maximumDuration or defaultParameters.maximumDuration
427
443
  if maximumDuration ~= nil then
428
- self[107] = resolveNumberValue(ability, level, maximumDuration)
444
+ self[108] = resolveNumberValue(ability, level, maximumDuration)
429
445
  end
430
446
  local maximumRemainingDuration = parameters and parameters.maximumRemainingDuration or defaultParameters.maximumRemainingDuration
431
447
  if maximumRemainingDuration ~= nil then
432
- self[108] = resolveNumberValue(ability, level, maximumRemainingDuration)
448
+ self[109] = resolveNumberValue(ability, level, maximumRemainingDuration)
433
449
  end
434
450
  local parametersAbilityTypeIds = parameters and parameters.abilityTypeIds or defaultParameters.abilityTypeIds
435
451
  if parametersAbilityTypeIds ~= nil then
@@ -487,10 +503,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
487
503
  self._timer = timer
488
504
  end
489
505
  self:onCreate()
506
+ self[100] = 1
490
507
  end
491
508
  function Buff.prototype.getUnitBonus(self, bonusType)
492
- local ____opt_36 = self._bonusIdByBonusType
493
- local bonusId = ____opt_36 and ____opt_36[bonusType]
509
+ local ____opt_38 = self._bonusIdByBonusType
510
+ local bonusId = ____opt_38 and ____opt_38[bonusType]
494
511
  return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
495
512
  end
496
513
  function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
@@ -503,67 +520,69 @@ function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
503
520
  end
504
521
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
505
522
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
506
- Effect:flash(self[104], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
523
+ Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
507
524
  else
508
525
  local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
509
- local ____Effect_40 = Effect
510
- local ____Effect_flash_41 = Effect.flash
511
- local ____array_39 = __TS__SparseArrayNew(
512
- self[104],
526
+ local ____Effect_42 = Effect
527
+ local ____Effect_flash_43 = Effect.flash
528
+ local ____array_41 = __TS__SparseArrayNew(
529
+ self[105],
513
530
  isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
514
531
  stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
515
532
  )
516
- local ____isWidgetProvided_38
533
+ local ____isWidgetProvided_40
517
534
  if isWidgetProvided then
518
- ____isWidgetProvided_38 = yOrParametersOrDuration
535
+ ____isWidgetProvided_40 = yOrParametersOrDuration
519
536
  else
520
- ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
537
+ ____isWidgetProvided_40 = widgetOrXOrParametersOrDuration
521
538
  end
522
- __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
523
- ____Effect_flash_41(
524
- ____Effect_40,
525
- __TS__SparseArraySpread(____array_39)
539
+ __TS__SparseArrayPush(____array_41, ____isWidgetProvided_40)
540
+ ____Effect_flash_43(
541
+ ____Effect_42,
542
+ __TS__SparseArraySpread(____array_41)
526
543
  )
527
544
  end
528
545
  end
529
546
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
530
547
  local isWidgetProvided = type(widgetOrDuration) == "table"
531
- local ____Effect_44 = Effect
532
- local ____Effect_flash_45 = Effect.flash
533
- local ____array_43 = __TS__SparseArrayNew(
534
- self[105],
548
+ local ____Effect_46 = Effect
549
+ local ____Effect_flash_47 = Effect.flash
550
+ local ____array_45 = __TS__SparseArrayNew(
551
+ self[106],
535
552
  isWidgetProvided and widgetOrDuration or self._unit,
536
553
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
537
554
  )
538
- local ____isWidgetProvided_42
555
+ local ____isWidgetProvided_44
539
556
  if isWidgetProvided then
540
- ____isWidgetProvided_42 = duration
557
+ ____isWidgetProvided_44 = duration
541
558
  else
542
- ____isWidgetProvided_42 = widgetOrDuration
559
+ ____isWidgetProvided_44 = widgetOrDuration
543
560
  end
544
- __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
545
- ____Effect_flash_45(
546
- ____Effect_44,
547
- __TS__SparseArraySpread(____array_43)
561
+ __TS__SparseArrayPush(____array_45, ____isWidgetProvided_44)
562
+ ____Effect_flash_47(
563
+ ____Effect_46,
564
+ __TS__SparseArraySpread(____array_45)
548
565
  )
549
566
  end
550
567
  function Buff.prototype.onCreate(self)
551
568
  end
552
569
  function Buff.prototype.onDestroy(self)
570
+ check(self[100] ~= 0, "Cannot destroy a buff that has not finished creating yet.")
571
+ self[100] = 2
553
572
  local unit = self._unit
554
573
  if getUnitAbility(unit.handle, self.typeId) == self.handle then
555
574
  removeBuff(unit.handle, self.typeId)
556
575
  end
557
576
  buffByTypeIdByUnit[unit][self.typeId] = nil
558
- local healingIntervalTimer = self[118]
577
+ local healingIntervalTimer = self[119]
559
578
  if healingIntervalTimer ~= nil then
560
579
  healingIntervalTimer:destroy()
561
- self[118] = nil
580
+ self[119] = nil
562
581
  end
563
- local damageIntervalTimer = self[113]
582
+ local damageIntervalTimer = self[114]
564
583
  if damageIntervalTimer ~= nil then
565
584
  damageIntervalTimer:destroy()
566
- self[113] = nil
585
+ self[114] = nil
567
586
  end
568
587
  if self._timer ~= nil then
569
588
  self._timer:destroy()
@@ -573,11 +592,11 @@ function Buff.prototype.onDestroy(self)
573
592
  behavior:destroy()
574
593
  end
575
594
  end
576
- if self[136] then
595
+ if self[137] then
577
596
  unit:decrementDisableAutoAttackCounter()
578
597
  end
579
- if self[134] then
580
- if self[135] then
598
+ if self[135] then
599
+ if self[136] then
581
600
  unit:decrementStunCounter()
582
601
  end
583
602
  unit:decrementStunCounter()
@@ -592,6 +611,8 @@ function Buff.prototype.onDestroy(self)
592
611
  removeUnitBonus(unit, bonusType, bonusId)
593
612
  end
594
613
  end
614
+ Event.invoke(buffDestroyEvent, self)
615
+ self[100] = 3
595
616
  return UnitBehavior.prototype.onDestroy(self)
596
617
  end
597
618
  function Buff.apply(self, ...)
@@ -619,8 +640,8 @@ function Buff.apply(self, ...)
619
640
  end
620
641
  end
621
642
  function Buff.getByTypeId(self, unit, typeId)
622
- local ____opt_46 = buffByTypeIdByUnit[unit]
623
- local buff = ____opt_46 and ____opt_46[typeId]
643
+ local ____opt_48 = buffByTypeIdByUnit[unit]
644
+ local buff = ____opt_48 and ____opt_48[typeId]
624
645
  if __TS__InstanceOf(buff, self) then
625
646
  return buff
626
647
  end
@@ -628,72 +649,72 @@ function Buff.getByTypeId(self, unit, typeId)
628
649
  end
629
650
  function Buff.prototype.onExpiration(self)
630
651
  local unit = self.unit
631
- if self[119] ~= nil then
632
- (self[101] or unit):damageTarget(unit, self[119] or 0)
633
- end
634
652
  if self[120] ~= nil then
635
- (self[101] or unit):healTarget(unit, self[119] or 0)
653
+ (self[102] or unit):damageTarget(unit, self[120] or 0)
636
654
  end
637
- if self[139] then
655
+ if self[121] ~= nil then
656
+ (self[102] or unit):healTarget(unit, self[120] or 0)
657
+ end
658
+ if self[140] then
638
659
  unit:explode()
639
- elseif self[138] then
660
+ elseif self[139] then
640
661
  unit:kill()
641
662
  end
642
663
  end
643
664
  function Buff.prototype.onDeath(self, source)
644
665
  local unit = self.unit
645
- if self[121] ~= nil then
666
+ if self[122] ~= nil then
646
667
  damageArea(
647
- self[101] or unit,
648
- self[121],
668
+ self[102] or unit,
669
+ self[122],
649
670
  unit.x,
650
671
  unit.y,
672
+ self[124] or 0,
651
673
  self[123] or 0,
652
- self[122] or 0,
674
+ self[126] or 0,
653
675
  self[125] or 0,
654
- self[124] or 0,
655
- self[127] or 0,
656
- self[126] or 0
676
+ self[128] or 0,
677
+ self[127] or 0
657
678
  )
658
679
  end
659
680
  end
660
681
  function Buff.prototype.onDamageDealt(self, target, event)
661
682
  if event.isAttack then
662
- if self[106] ~= nil then
663
- local durationIncrease = self[106]
664
- local maximumDuration = self[107] or 0
683
+ if self[107] ~= nil then
684
+ local durationIncrease = self[107]
685
+ local maximumDuration = self[108] or 0
665
686
  if maximumDuration > 0 then
666
687
  durationIncrease = min(
667
688
  durationIncrease,
668
- max(0, maximumDuration - self[102])
689
+ max(0, maximumDuration - self[103])
669
690
  )
670
691
  end
671
692
  local remainingDuration = self.remainingDuration + durationIncrease
672
- local maximumRemainingDuration = self[108] or 0
693
+ local maximumRemainingDuration = self[109] or 0
673
694
  if maximumRemainingDuration > 0 then
674
695
  remainingDuration = min(remainingDuration, maximumRemainingDuration)
675
696
  end
676
697
  self.remainingDuration = remainingDuration
677
698
  end
678
- local autoAttackCount = (self[128] or 0) + 1
679
- self[128] = autoAttackCount
680
- if autoAttackCount == self[129] then
699
+ local autoAttackCount = (self[129] or 0) + 1
700
+ self[129] = autoAttackCount
701
+ if autoAttackCount == self[130] then
681
702
  self:destroy()
682
703
  end
683
704
  end
684
705
  if event.originalAmount ~= 0 then
685
- local damageDealtEventCount = (self[130] or 0) + 1
686
- self[130] = damageDealtEventCount
687
- if damageDealtEventCount == self[131] then
706
+ local damageDealtEventCount = (self[131] or 0) + 1
707
+ self[131] = damageDealtEventCount
708
+ if damageDealtEventCount == self[132] then
688
709
  self:destroy()
689
710
  end
690
711
  end
691
712
  end
692
713
  function Buff.prototype.onDamageReceived(self, source, event)
693
714
  if event.originalAmount ~= 0 then
694
- local damageReceivedEventCount = (self[132] or 0) + 1
695
- self[132] = damageReceivedEventCount
696
- if damageReceivedEventCount == self[133] then
715
+ local damageReceivedEventCount = (self[133] or 0) + 1
716
+ self[133] = damageReceivedEventCount
717
+ if damageReceivedEventCount == self[134] then
697
718
  self:destroy()
698
719
  end
699
720
  end
@@ -703,7 +724,7 @@ __TS__SetDescriptor(
703
724
  Buff.prototype,
704
725
  "source",
705
726
  {get = function(self)
706
- return self[101] or self._unit
727
+ return self[102] or self._unit
707
728
  end},
708
729
  true
709
730
  )
@@ -720,13 +741,13 @@ __TS__SetDescriptor(
720
741
  "remainingDamageOverDuration",
721
742
  {
722
743
  get = function(self)
723
- return self[112] or 0
744
+ return self[113] or 0
724
745
  end,
725
746
  set = function(self, remainingDamageOverDuration)
726
- local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[112] or 0)
727
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
728
- local damageOverDuration = (self[109] or 0) + remainingDamageOverDurationDelta
729
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
747
+ local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[113] or 0)
748
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
749
+ local damageOverDuration = (self[110] or 0) + remainingDamageOverDurationDelta
750
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
730
751
  end
731
752
  },
732
753
  true
@@ -736,13 +757,13 @@ __TS__SetDescriptor(
736
757
  "damageOverDuration",
737
758
  {
738
759
  get = function(self)
739
- return self[109] or 0
760
+ return self[110] or 0
740
761
  end,
741
762
  set = function(self, damageOverDuration)
742
- local damageOverDurationDelta = damageOverDuration - (self[109] or 0)
743
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
744
- local remainingDamageOverDuration = (self[112] or 0) + damageOverDurationDelta
745
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
763
+ local damageOverDurationDelta = damageOverDuration - (self[110] or 0)
764
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
765
+ local remainingDamageOverDuration = (self[113] or 0) + damageOverDurationDelta
766
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
746
767
  end
747
768
  },
748
769
  true
@@ -752,10 +773,10 @@ __TS__SetDescriptor(
752
773
  "damagePerInterval",
753
774
  {
754
775
  get = function(self)
755
- return self[110] or 0
776
+ return self[111] or 0
756
777
  end,
757
778
  set = function(self, damagePerInterval)
758
- self[110] = damagePerInterval ~= 0 and damagePerInterval or nil
779
+ self[111] = damagePerInterval ~= 0 and damagePerInterval or nil
759
780
  end
760
781
  },
761
782
  true
@@ -765,25 +786,25 @@ __TS__SetDescriptor(
765
786
  "damageInterval",
766
787
  {
767
788
  get = function(self)
768
- return self[111] or 0
789
+ return self[112] or 0
769
790
  end,
770
791
  set = function(self, damageInterval)
771
792
  if damageInterval <= 0 then
772
- self[111] = damageInterval ~= 0 and damageInterval or nil
773
- local timer = self[113]
793
+ self[112] = damageInterval ~= 0 and damageInterval or nil
794
+ local timer = self[114]
774
795
  if timer ~= nil then
775
796
  timer:destroy()
776
- self[113] = nil
797
+ self[114] = nil
777
798
  end
778
799
  return
779
800
  end
780
- self[111] = damageInterval
781
- local ____opt_48 = self._timer
782
- local elapsed = ____opt_48 and ____opt_48.elapsed or 0
783
- local timer = self[113]
801
+ self[112] = damageInterval
802
+ local ____opt_50 = self._timer
803
+ local elapsed = ____opt_50 and ____opt_50.elapsed or 0
804
+ local timer = self[114]
784
805
  if timer == nil then
785
806
  timer = Timer:create()
786
- self[113] = timer
807
+ self[114] = timer
787
808
  end
788
809
  local initialDelay = damageInterval - (elapsed >= damageInterval and math.fmod(elapsed, damageInterval) or elapsed)
789
810
  if initialDelay == damageInterval then
@@ -800,13 +821,13 @@ __TS__SetDescriptor(
800
821
  "remainingHealingOverDuration",
801
822
  {
802
823
  get = function(self)
803
- return self[117] or 0
824
+ return self[118] or 0
804
825
  end,
805
826
  set = function(self, remainingHealingOverDuration)
806
- local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[117] or 0)
807
- self[112] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
808
- local healingOverDuration = (self[114] or 0) + remainingHealingOverDurationDelta
809
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
827
+ local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[118] or 0)
828
+ self[113] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
829
+ local healingOverDuration = (self[115] or 0) + remainingHealingOverDurationDelta
830
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
810
831
  end
811
832
  },
812
833
  true
@@ -816,13 +837,13 @@ __TS__SetDescriptor(
816
837
  "healingOverDuration",
817
838
  {
818
839
  get = function(self)
819
- return self[114] or 0
840
+ return self[115] or 0
820
841
  end,
821
842
  set = function(self, healingOverDuration)
822
- local healingOverDurationDelta = healingOverDuration - (self[114] or 0)
823
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
824
- local remainingHealingOverDuration = (self[117] or 0) + healingOverDurationDelta
825
- self[117] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
843
+ local healingOverDurationDelta = healingOverDuration - (self[115] or 0)
844
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
845
+ local remainingHealingOverDuration = (self[118] or 0) + healingOverDurationDelta
846
+ self[118] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
826
847
  end
827
848
  },
828
849
  true
@@ -832,10 +853,10 @@ __TS__SetDescriptor(
832
853
  "healingPerInterval",
833
854
  {
834
855
  get = function(self)
835
- return self[115] or 0
856
+ return self[116] or 0
836
857
  end,
837
858
  set = function(self, healingPerInterval)
838
- self[115] = healingPerInterval ~= 0 and healingPerInterval or nil
859
+ self[116] = healingPerInterval ~= 0 and healingPerInterval or nil
839
860
  end
840
861
  },
841
862
  true
@@ -845,25 +866,25 @@ __TS__SetDescriptor(
845
866
  "healingInterval",
846
867
  {
847
868
  get = function(self)
848
- return self[116] or 0
869
+ return self[117] or 0
849
870
  end,
850
871
  set = function(self, healingInterval)
851
872
  if healingInterval <= 0 then
852
- self[116] = healingInterval ~= 0 and healingInterval or nil
853
- local timer = self[118]
873
+ self[117] = healingInterval ~= 0 and healingInterval or nil
874
+ local timer = self[119]
854
875
  if timer ~= nil then
855
876
  timer:destroy()
856
- self[118] = nil
877
+ self[119] = nil
857
878
  end
858
879
  return
859
880
  end
860
- self[116] = healingInterval
861
- local ____opt_50 = self._timer
862
- local elapsed = ____opt_50 and ____opt_50.elapsed or 0
863
- local timer = self[118]
881
+ self[117] = healingInterval
882
+ local ____opt_52 = self._timer
883
+ local elapsed = ____opt_52 and ____opt_52.elapsed or 0
884
+ local timer = self[119]
864
885
  if timer == nil then
865
886
  timer = Timer:create()
866
- self[118] = timer
887
+ self[119] = timer
867
888
  end
868
889
  local initialDelay = healingInterval - (elapsed >= healingInterval and math.fmod(elapsed, healingInterval) or elapsed)
869
890
  if initialDelay == healingInterval then
@@ -880,10 +901,10 @@ __TS__SetDescriptor(
880
901
  "damageOnExpiration",
881
902
  {
882
903
  get = function(self)
883
- return self[119] or 0
904
+ return self[120] or 0
884
905
  end,
885
906
  set = function(self, damageOnExpiration)
886
- self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
907
+ self[120] = damageOnExpiration ~= 0 and damageOnExpiration or nil
887
908
  end
888
909
  },
889
910
  true
@@ -893,10 +914,10 @@ __TS__SetDescriptor(
893
914
  "healingOnExpiration",
894
915
  {
895
916
  get = function(self)
896
- return self[120] or 0
917
+ return self[121] or 0
897
918
  end,
898
919
  set = function(self, healingOnExpiration)
899
- self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
920
+ self[121] = healingOnExpiration ~= 0 and healingOnExpiration or nil
900
921
  end
901
922
  },
902
923
  true
@@ -945,25 +966,25 @@ __TS__SetDescriptor(
945
966
  "stuns",
946
967
  {
947
968
  get = function(self)
948
- local ____self__134_52 = self[134]
949
- if ____self__134_52 == nil then
950
- ____self__134_52 = false
969
+ local ____self__135_54 = self[135]
970
+ if ____self__135_54 == nil then
971
+ ____self__135_54 = false
951
972
  end
952
- return ____self__134_52
973
+ return ____self__135_54
953
974
  end,
954
975
  set = function(self, stuns)
955
- if not stuns and self[134] then
956
- if self[135] then
976
+ if not stuns and self[135] then
977
+ if self[136] then
957
978
  self.object:decrementStunCounter()
958
979
  end
959
980
  self.object:decrementStunCounter()
960
- self[134] = nil
961
- elseif stuns and not self[134] then
962
- if self[135] then
981
+ self[135] = nil
982
+ elseif stuns and not self[135] then
983
+ if self[136] then
963
984
  self.object:incrementStunCounter()
964
985
  end
965
986
  self.object:incrementStunCounter()
966
- self[134] = true
987
+ self[135] = true
967
988
  end
968
989
  end
969
990
  },
@@ -974,23 +995,23 @@ __TS__SetDescriptor(
974
995
  "ignoresStunImmunity",
975
996
  {
976
997
  get = function(self)
977
- local ____self__135_53 = self[135]
978
- if ____self__135_53 == nil then
979
- ____self__135_53 = false
998
+ local ____self__136_55 = self[136]
999
+ if ____self__136_55 == nil then
1000
+ ____self__136_55 = false
980
1001
  end
981
- return ____self__135_53
1002
+ return ____self__136_55
982
1003
  end,
983
1004
  set = function(self, ignoresStunImmunity)
984
- if not ignoresStunImmunity and self[135] then
985
- if self[134] then
1005
+ if not ignoresStunImmunity and self[136] then
1006
+ if self[135] then
986
1007
  self.object:decrementStunCounter()
987
1008
  end
988
- self[135] = nil
989
- elseif ignoresStunImmunity and not self[135] then
990
- if self[134] then
1009
+ self[136] = nil
1010
+ elseif ignoresStunImmunity and not self[136] then
1011
+ if self[135] then
991
1012
  self.object:incrementStunCounter()
992
1013
  end
993
- self[135] = true
1014
+ self[136] = true
994
1015
  end
995
1016
  end
996
1017
  },
@@ -1001,19 +1022,19 @@ __TS__SetDescriptor(
1001
1022
  "disablesAutoAttack",
1002
1023
  {
1003
1024
  get = function(self)
1004
- local ____self__136_54 = self[136]
1005
- if ____self__136_54 == nil then
1006
- ____self__136_54 = false
1025
+ local ____self__137_56 = self[137]
1026
+ if ____self__137_56 == nil then
1027
+ ____self__137_56 = false
1007
1028
  end
1008
- return ____self__136_54
1029
+ return ____self__137_56
1009
1030
  end,
1010
1031
  set = function(self, disablesAutoAttack)
1011
- if not disablesAutoAttack and self[136] then
1032
+ if not disablesAutoAttack and self[137] then
1012
1033
  self.object:decrementDisableAutoAttackCounter()
1013
- self[136] = nil
1014
- elseif disablesAutoAttack and not self[136] then
1034
+ self[137] = nil
1035
+ elseif disablesAutoAttack and not self[137] then
1015
1036
  self.object:incrementDisableAutoAttackCounter()
1016
- self[136] = true
1037
+ self[137] = true
1017
1038
  end
1018
1039
  end
1019
1040
  },
@@ -1024,19 +1045,19 @@ __TS__SetDescriptor(
1024
1045
  "providesInvulnerability",
1025
1046
  {
1026
1047
  get = function(self)
1027
- local ____self__137_55 = self[137]
1028
- if ____self__137_55 == nil then
1029
- ____self__137_55 = false
1048
+ local ____self__138_57 = self[138]
1049
+ if ____self__138_57 == nil then
1050
+ ____self__138_57 = false
1030
1051
  end
1031
- return ____self__137_55
1052
+ return ____self__138_57
1032
1053
  end,
1033
1054
  set = function(self, providesInvulnerability)
1034
- if not providesInvulnerability and self[137] then
1055
+ if not providesInvulnerability and self[138] then
1035
1056
  self.object:decrementInvulnerabilityCounter()
1036
- self[137] = nil
1037
- elseif providesInvulnerability and not self[137] then
1057
+ self[138] = nil
1058
+ elseif providesInvulnerability and not self[138] then
1038
1059
  self.object:incrementInvulnerabilityCounter()
1039
- self[137] = true
1060
+ self[138] = true
1040
1061
  end
1041
1062
  end
1042
1063
  },
@@ -1047,17 +1068,17 @@ __TS__SetDescriptor(
1047
1068
  "killsOnExpiration",
1048
1069
  {
1049
1070
  get = function(self)
1050
- local ____self__138_56 = self[138]
1051
- if ____self__138_56 == nil then
1052
- ____self__138_56 = false
1071
+ local ____self__139_58 = self[139]
1072
+ if ____self__139_58 == nil then
1073
+ ____self__139_58 = false
1053
1074
  end
1054
- return ____self__138_56
1075
+ return ____self__139_58
1055
1076
  end,
1056
1077
  set = function(self, killsOnExpiration)
1057
- if not killsOnExpiration and self[138] then
1058
- self[138] = nil
1059
- elseif killsOnExpiration and not self[138] then
1060
- self[138] = true
1078
+ if not killsOnExpiration and self[139] then
1079
+ self[139] = nil
1080
+ elseif killsOnExpiration and not self[139] then
1081
+ self[139] = true
1061
1082
  end
1062
1083
  end
1063
1084
  },
@@ -1068,17 +1089,17 @@ __TS__SetDescriptor(
1068
1089
  "explodesOnExpiration",
1069
1090
  {
1070
1091
  get = function(self)
1071
- local ____self__139_57 = self[139]
1072
- if ____self__139_57 == nil then
1073
- ____self__139_57 = false
1092
+ local ____self__140_59 = self[140]
1093
+ if ____self__140_59 == nil then
1094
+ ____self__140_59 = false
1074
1095
  end
1075
- return ____self__139_57
1096
+ return ____self__140_59
1076
1097
  end,
1077
1098
  set = function(self, killsOnExpiration)
1078
- if not killsOnExpiration and self[139] then
1079
- self[139] = nil
1080
- elseif killsOnExpiration and not self[139] then
1081
- self[139] = true
1099
+ if not killsOnExpiration and self[140] then
1100
+ self[140] = nil
1101
+ elseif killsOnExpiration and not self[140] then
1102
+ self[140] = true
1082
1103
  end
1083
1104
  end
1084
1105
  },
@@ -1089,13 +1110,13 @@ __TS__SetDescriptor(
1089
1110
  "maximumDamageDealtEventCount",
1090
1111
  {
1091
1112
  get = function(self)
1092
- return self[131] or 0
1113
+ return self[132] or 0
1093
1114
  end,
1094
1115
  set = function(self, maximumDamageDealtEventCount)
1095
1116
  if maximumDamageDealtEventCount == 0 then
1096
- self[131] = nil
1117
+ self[132] = nil
1097
1118
  else
1098
- self[131] = maximumDamageDealtEventCount
1119
+ self[132] = maximumDamageDealtEventCount
1099
1120
  end
1100
1121
  end
1101
1122
  },
@@ -1106,13 +1127,13 @@ __TS__SetDescriptor(
1106
1127
  "maximumDamageReceivedEventCount",
1107
1128
  {
1108
1129
  get = function(self)
1109
- return self[133] or 0
1130
+ return self[134] or 0
1110
1131
  end,
1111
1132
  set = function(self, maximumDamageReceivedEventCount)
1112
1133
  if maximumDamageReceivedEventCount == 0 then
1113
- self[133] = nil
1134
+ self[134] = nil
1114
1135
  else
1115
- self[133] = maximumDamageReceivedEventCount
1136
+ self[134] = maximumDamageReceivedEventCount
1116
1137
  end
1117
1138
  end
1118
1139
  },
@@ -1123,13 +1144,13 @@ __TS__SetDescriptor(
1123
1144
  "maximumAutoAttackCount",
1124
1145
  {
1125
1146
  get = function(self)
1126
- return self[129] or 0
1147
+ return self[130] or 0
1127
1148
  end,
1128
1149
  set = function(self, maximumAutoAttackCount)
1129
1150
  if maximumAutoAttackCount == 0 then
1130
- self[129] = nil
1151
+ self[130] = nil
1131
1152
  else
1132
- self[129] = maximumAutoAttackCount
1153
+ self[130] = maximumAutoAttackCount
1133
1154
  end
1134
1155
  end
1135
1156
  },
@@ -1140,10 +1161,10 @@ __TS__SetDescriptor(
1140
1161
  "durationIncreaseOnAutoAttack",
1141
1162
  {
1142
1163
  get = function(self)
1143
- return self[106] or 0
1164
+ return self[107] or 0
1144
1165
  end,
1145
1166
  set = function(self, durationIncreaseOnAutoAttack)
1146
- self[106] = durationIncreaseOnAutoAttack
1167
+ self[107] = durationIncreaseOnAutoAttack
1147
1168
  end
1148
1169
  },
1149
1170
  true
@@ -1174,11 +1195,24 @@ __TS__SetDescriptor(
1174
1195
  },
1175
1196
  true
1176
1197
  )
1198
+ __TS__SetDescriptor(
1199
+ Buff.prototype,
1200
+ "evasionProbability",
1201
+ {
1202
+ get = function(self)
1203
+ return self:getUnitBonus(UnitBonusType.EVASION_PROBABILITY)
1204
+ end,
1205
+ set = function(self, evasionProbability)
1206
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.EVASION_PROBABILITY, evasionProbability)
1207
+ end
1208
+ },
1209
+ true
1210
+ )
1177
1211
  __TS__SetDescriptor(
1178
1212
  Buff.prototype,
1179
1213
  "duration",
1180
1214
  {get = function(self)
1181
- return self[102]
1215
+ return self[103]
1182
1216
  end},
1183
1217
  true
1184
1218
  )
@@ -1187,15 +1221,15 @@ __TS__SetDescriptor(
1187
1221
  "remainingDuration",
1188
1222
  {
1189
1223
  get = function(self)
1190
- local ____opt_58 = self._timer
1191
- return ____opt_58 and ____opt_58.remaining or 0
1224
+ local ____opt_60 = self._timer
1225
+ return ____opt_60 and ____opt_60.remaining or 0
1192
1226
  end,
1193
1227
  set = function(self, remainingDuration)
1194
- local ____remainingDuration_62 = remainingDuration
1195
- local ____opt_60 = self._timer
1196
- local remainingDurationDelta = ____remainingDuration_62 - (____opt_60 and ____opt_60.remaining or 0)
1228
+ local ____remainingDuration_64 = remainingDuration
1229
+ local ____opt_62 = self._timer
1230
+ local remainingDurationDelta = ____remainingDuration_64 - (____opt_62 and ____opt_62.remaining or 0)
1197
1231
  if remainingDurationDelta ~= 0 then
1198
- self[102] = self[102] + remainingDurationDelta
1232
+ self[103] = self[103] + remainingDurationDelta
1199
1233
  if remainingDuration <= 0 then
1200
1234
  Timer:run(destroyBuff, self)
1201
1235
  else
@@ -1207,7 +1241,8 @@ __TS__SetDescriptor(
1207
1241
  self._level,
1208
1242
  remainingDuration,
1209
1243
  self._spellStealPriority,
1210
- self._learnLevelMinimum
1244
+ self._learnLevelMinimum,
1245
+ self[141]
1211
1246
  ) then
1212
1247
  local timer = self._timer
1213
1248
  if timer == nil then
@@ -1221,10 +1256,11 @@ __TS__SetDescriptor(
1221
1256
  end
1222
1257
  },
1223
1258
  true
1224
- );
1259
+ )
1260
+ Buff.destroyEvent = buffDestroyEvent;
1225
1261
  (function(self)
1226
1262
  local function destroyBuffIfNeeded(buff)
1227
- if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1263
+ if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
1228
1264
  buff:destroy()
1229
1265
  end
1230
1266
  end