warscript 0.0.1-dev.397722e → 0.0.1-dev.3d15d22

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 (36) hide show
  1. package/engine/behaviour/ability/apply-buff.d.ts +5 -0
  2. package/engine/behaviour/ability/apply-buff.lua +32 -0
  3. package/engine/behaviour/ability/emulate-impact.lua +4 -5
  4. package/engine/behaviour/ability.d.ts +7 -2
  5. package/engine/behaviour/ability.lua +48 -3
  6. package/engine/buff.d.ts +50 -40
  7. package/engine/buff.lua +259 -225
  8. package/engine/internal/ability.lua +0 -2
  9. package/engine/internal/item/ability.lua +19 -3
  10. package/engine/internal/item.d.ts +2 -2
  11. package/engine/internal/item.lua +56 -25
  12. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  13. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  14. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  15. package/engine/internal/object-data/evasion-probability.lua +16 -0
  16. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  17. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  18. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  19. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  20. package/engine/internal/unit/bonus.d.ts +2 -0
  21. package/engine/internal/unit/bonus.lua +17 -0
  22. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  23. package/engine/internal/unit/ignore-events-items.lua +5 -0
  24. package/engine/internal/unit/item.lua +3 -4
  25. package/engine/internal/unit.d.ts +1 -0
  26. package/engine/internal/unit.lua +20 -6
  27. package/engine/lightning.d.ts +12 -5
  28. package/engine/lightning.lua +48 -14
  29. package/engine/object-data/entry/buff-type/applicable.lua +10 -34
  30. package/engine/object-field/ability.d.ts +5 -2
  31. package/engine/object-field/ability.lua +3 -0
  32. package/engine/object-field.d.ts +2 -2
  33. package/engine/object-field.lua +4 -0
  34. package/engine/unit.d.ts +1 -0
  35. package/engine/unit.lua +1 -0
  36. 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,7 +394,8 @@ 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
386
400
  UnitBehavior.prototype.destroy(self)
387
401
  error(unsuccessfulApplicationMarker, 0)
@@ -396,20 +410,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
396
410
  self._level = level
397
411
  self._spellStealPriority = spellStealPriority
398
412
  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)
413
+ self[102] = source
414
+ self[103] = duration or 0
415
+ self[104] = uniqueGroup
416
+ self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
417
+ self[106] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
404
418
  if parameters ~= nil or (next(defaultParameters)) ~= nil then
405
419
  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]
420
+ local ____ability_24 = ability
421
+ local ____level_25 = level
422
+ local ____temp_23 = parameters and parameters[buffBooleanParameter]
423
+ if ____temp_23 == nil then
424
+ ____temp_23 = defaultParameters[buffBooleanParameter]
411
425
  end
412
- if resolveBooleanValue(____ability_22, ____level_23, ____temp_21) then
426
+ if resolveBooleanValue(____ability_24, ____level_25, ____temp_23) then
413
427
  self[buffBooleanParameter] = true
414
428
  end
415
429
  end
@@ -425,11 +439,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
425
439
  end
426
440
  local maximumDuration = parameters and parameters.maximumDuration or defaultParameters.maximumDuration
427
441
  if maximumDuration ~= nil then
428
- self[107] = resolveNumberValue(ability, level, maximumDuration)
442
+ self[108] = resolveNumberValue(ability, level, maximumDuration)
429
443
  end
430
444
  local maximumRemainingDuration = parameters and parameters.maximumRemainingDuration or defaultParameters.maximumRemainingDuration
431
445
  if maximumRemainingDuration ~= nil then
432
- self[108] = resolveNumberValue(ability, level, maximumRemainingDuration)
446
+ self[109] = resolveNumberValue(ability, level, maximumRemainingDuration)
433
447
  end
434
448
  local parametersAbilityTypeIds = parameters and parameters.abilityTypeIds or defaultParameters.abilityTypeIds
435
449
  if parametersAbilityTypeIds ~= nil then
@@ -487,10 +501,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
487
501
  self._timer = timer
488
502
  end
489
503
  self:onCreate()
504
+ self[100] = 1
490
505
  end
491
506
  function Buff.prototype.getUnitBonus(self, bonusType)
492
- local ____opt_36 = self._bonusIdByBonusType
493
- local bonusId = ____opt_36 and ____opt_36[bonusType]
507
+ local ____opt_38 = self._bonusIdByBonusType
508
+ local bonusId = ____opt_38 and ____opt_38[bonusType]
494
509
  return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
495
510
  end
496
511
  function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
@@ -503,67 +518,69 @@ function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
503
518
  end
504
519
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
505
520
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
506
- Effect:flash(self[104], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
521
+ Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
507
522
  else
508
523
  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],
524
+ local ____Effect_42 = Effect
525
+ local ____Effect_flash_43 = Effect.flash
526
+ local ____array_41 = __TS__SparseArrayNew(
527
+ self[105],
513
528
  isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
514
529
  stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
515
530
  )
516
- local ____isWidgetProvided_38
531
+ local ____isWidgetProvided_40
517
532
  if isWidgetProvided then
518
- ____isWidgetProvided_38 = yOrParametersOrDuration
533
+ ____isWidgetProvided_40 = yOrParametersOrDuration
519
534
  else
520
- ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
535
+ ____isWidgetProvided_40 = widgetOrXOrParametersOrDuration
521
536
  end
522
- __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
523
- ____Effect_flash_41(
524
- ____Effect_40,
525
- __TS__SparseArraySpread(____array_39)
537
+ __TS__SparseArrayPush(____array_41, ____isWidgetProvided_40)
538
+ ____Effect_flash_43(
539
+ ____Effect_42,
540
+ __TS__SparseArraySpread(____array_41)
526
541
  )
527
542
  end
528
543
  end
529
544
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
530
545
  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],
546
+ local ____Effect_46 = Effect
547
+ local ____Effect_flash_47 = Effect.flash
548
+ local ____array_45 = __TS__SparseArrayNew(
549
+ self[106],
535
550
  isWidgetProvided and widgetOrDuration or self._unit,
536
551
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
537
552
  )
538
- local ____isWidgetProvided_42
553
+ local ____isWidgetProvided_44
539
554
  if isWidgetProvided then
540
- ____isWidgetProvided_42 = duration
555
+ ____isWidgetProvided_44 = duration
541
556
  else
542
- ____isWidgetProvided_42 = widgetOrDuration
557
+ ____isWidgetProvided_44 = widgetOrDuration
543
558
  end
544
- __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
545
- ____Effect_flash_45(
546
- ____Effect_44,
547
- __TS__SparseArraySpread(____array_43)
559
+ __TS__SparseArrayPush(____array_45, ____isWidgetProvided_44)
560
+ ____Effect_flash_47(
561
+ ____Effect_46,
562
+ __TS__SparseArraySpread(____array_45)
548
563
  )
549
564
  end
550
565
  function Buff.prototype.onCreate(self)
551
566
  end
552
567
  function Buff.prototype.onDestroy(self)
568
+ check(self[100] ~= 0, "Cannot destroy a buff that has not finished creating yet.")
569
+ self[100] = 2
553
570
  local unit = self._unit
554
571
  if getUnitAbility(unit.handle, self.typeId) == self.handle then
555
572
  removeBuff(unit.handle, self.typeId)
556
573
  end
557
574
  buffByTypeIdByUnit[unit][self.typeId] = nil
558
- local healingIntervalTimer = self[118]
575
+ local healingIntervalTimer = self[119]
559
576
  if healingIntervalTimer ~= nil then
560
577
  healingIntervalTimer:destroy()
561
- self[118] = nil
578
+ self[119] = nil
562
579
  end
563
- local damageIntervalTimer = self[113]
580
+ local damageIntervalTimer = self[114]
564
581
  if damageIntervalTimer ~= nil then
565
582
  damageIntervalTimer:destroy()
566
- self[113] = nil
583
+ self[114] = nil
567
584
  end
568
585
  if self._timer ~= nil then
569
586
  self._timer:destroy()
@@ -573,11 +590,11 @@ function Buff.prototype.onDestroy(self)
573
590
  behavior:destroy()
574
591
  end
575
592
  end
576
- if self[136] then
593
+ if self[137] then
577
594
  unit:decrementDisableAutoAttackCounter()
578
595
  end
579
- if self[134] then
580
- if self[135] then
596
+ if self[135] then
597
+ if self[136] then
581
598
  unit:decrementStunCounter()
582
599
  end
583
600
  unit:decrementStunCounter()
@@ -592,6 +609,8 @@ function Buff.prototype.onDestroy(self)
592
609
  removeUnitBonus(unit, bonusType, bonusId)
593
610
  end
594
611
  end
612
+ Event.invoke(buffDestroyEvent, self)
613
+ self[100] = 3
595
614
  return UnitBehavior.prototype.onDestroy(self)
596
615
  end
597
616
  function Buff.apply(self, ...)
@@ -619,8 +638,8 @@ function Buff.apply(self, ...)
619
638
  end
620
639
  end
621
640
  function Buff.getByTypeId(self, unit, typeId)
622
- local ____opt_46 = buffByTypeIdByUnit[unit]
623
- local buff = ____opt_46 and ____opt_46[typeId]
641
+ local ____opt_48 = buffByTypeIdByUnit[unit]
642
+ local buff = ____opt_48 and ____opt_48[typeId]
624
643
  if __TS__InstanceOf(buff, self) then
625
644
  return buff
626
645
  end
@@ -628,72 +647,72 @@ function Buff.getByTypeId(self, unit, typeId)
628
647
  end
629
648
  function Buff.prototype.onExpiration(self)
630
649
  local unit = self.unit
631
- if self[119] ~= nil then
632
- (self[101] or unit):damageTarget(unit, self[119] or 0)
633
- end
634
650
  if self[120] ~= nil then
635
- (self[101] or unit):healTarget(unit, self[119] or 0)
651
+ (self[102] or unit):damageTarget(unit, self[120] or 0)
636
652
  end
637
- if self[139] then
653
+ if self[121] ~= nil then
654
+ (self[102] or unit):healTarget(unit, self[120] or 0)
655
+ end
656
+ if self[140] then
638
657
  unit:explode()
639
- elseif self[138] then
658
+ elseif self[139] then
640
659
  unit:kill()
641
660
  end
642
661
  end
643
662
  function Buff.prototype.onDeath(self, source)
644
663
  local unit = self.unit
645
- if self[121] ~= nil then
664
+ if self[122] ~= nil then
646
665
  damageArea(
647
- self[101] or unit,
648
- self[121],
666
+ self[102] or unit,
667
+ self[122],
649
668
  unit.x,
650
669
  unit.y,
670
+ self[124] or 0,
651
671
  self[123] or 0,
652
- self[122] or 0,
672
+ self[126] or 0,
653
673
  self[125] or 0,
654
- self[124] or 0,
655
- self[127] or 0,
656
- self[126] or 0
674
+ self[128] or 0,
675
+ self[127] or 0
657
676
  )
658
677
  end
659
678
  end
660
679
  function Buff.prototype.onDamageDealt(self, target, event)
661
680
  if event.isAttack then
662
- if self[106] ~= nil then
663
- local durationIncrease = self[106]
664
- local maximumDuration = self[107] or 0
681
+ if self[107] ~= nil then
682
+ local durationIncrease = self[107]
683
+ local maximumDuration = self[108] or 0
665
684
  if maximumDuration > 0 then
666
685
  durationIncrease = min(
667
686
  durationIncrease,
668
- max(0, maximumDuration - self[102])
687
+ max(0, maximumDuration - self[103])
669
688
  )
670
689
  end
671
690
  local remainingDuration = self.remainingDuration + durationIncrease
672
- local maximumRemainingDuration = self[108] or 0
691
+ local maximumRemainingDuration = self[109] or 0
673
692
  if maximumRemainingDuration > 0 then
674
693
  remainingDuration = min(remainingDuration, maximumRemainingDuration)
675
694
  end
676
695
  self.remainingDuration = remainingDuration
677
696
  end
678
- local autoAttackCount = (self[128] or 0) + 1
679
- self[128] = autoAttackCount
680
- if autoAttackCount == self[129] then
697
+ local autoAttackCount = (self[129] or 0) + 1
698
+ self[129] = autoAttackCount
699
+ if autoAttackCount == self[130] then
681
700
  self:destroy()
682
701
  end
683
702
  end
684
703
  if event.originalAmount ~= 0 then
685
- local damageDealtEventCount = (self[130] or 0) + 1
686
- self[130] = damageDealtEventCount
687
- if damageDealtEventCount == self[131] then
704
+ local damageDealtEventCount = (self[131] or 0) + 1
705
+ self[131] = damageDealtEventCount
706
+ if damageDealtEventCount == self[132] then
688
707
  self:destroy()
689
708
  end
690
709
  end
691
710
  end
692
711
  function Buff.prototype.onDamageReceived(self, source, event)
693
712
  if event.originalAmount ~= 0 then
694
- local damageReceivedEventCount = (self[132] or 0) + 1
695
- self[132] = damageReceivedEventCount
696
- if damageReceivedEventCount == self[133] then
713
+ local damageReceivedEventCount = (self[133] or 0) + 1
714
+ self[133] = damageReceivedEventCount
715
+ if damageReceivedEventCount == self[134] then
697
716
  self:destroy()
698
717
  end
699
718
  end
@@ -703,7 +722,7 @@ __TS__SetDescriptor(
703
722
  Buff.prototype,
704
723
  "source",
705
724
  {get = function(self)
706
- return self[101] or self._unit
725
+ return self[102] or self._unit
707
726
  end},
708
727
  true
709
728
  )
@@ -720,13 +739,13 @@ __TS__SetDescriptor(
720
739
  "remainingDamageOverDuration",
721
740
  {
722
741
  get = function(self)
723
- return self[112] or 0
742
+ return self[113] or 0
724
743
  end,
725
744
  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
745
+ local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[113] or 0)
746
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
747
+ local damageOverDuration = (self[110] or 0) + remainingDamageOverDurationDelta
748
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
730
749
  end
731
750
  },
732
751
  true
@@ -736,13 +755,13 @@ __TS__SetDescriptor(
736
755
  "damageOverDuration",
737
756
  {
738
757
  get = function(self)
739
- return self[109] or 0
758
+ return self[110] or 0
740
759
  end,
741
760
  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
761
+ local damageOverDurationDelta = damageOverDuration - (self[110] or 0)
762
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
763
+ local remainingDamageOverDuration = (self[113] or 0) + damageOverDurationDelta
764
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
746
765
  end
747
766
  },
748
767
  true
@@ -752,10 +771,10 @@ __TS__SetDescriptor(
752
771
  "damagePerInterval",
753
772
  {
754
773
  get = function(self)
755
- return self[110] or 0
774
+ return self[111] or 0
756
775
  end,
757
776
  set = function(self, damagePerInterval)
758
- self[110] = damagePerInterval ~= 0 and damagePerInterval or nil
777
+ self[111] = damagePerInterval ~= 0 and damagePerInterval or nil
759
778
  end
760
779
  },
761
780
  true
@@ -765,25 +784,25 @@ __TS__SetDescriptor(
765
784
  "damageInterval",
766
785
  {
767
786
  get = function(self)
768
- return self[111] or 0
787
+ return self[112] or 0
769
788
  end,
770
789
  set = function(self, damageInterval)
771
790
  if damageInterval <= 0 then
772
- self[111] = damageInterval ~= 0 and damageInterval or nil
773
- local timer = self[113]
791
+ self[112] = damageInterval ~= 0 and damageInterval or nil
792
+ local timer = self[114]
774
793
  if timer ~= nil then
775
794
  timer:destroy()
776
- self[113] = nil
795
+ self[114] = nil
777
796
  end
778
797
  return
779
798
  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]
799
+ self[112] = damageInterval
800
+ local ____opt_50 = self._timer
801
+ local elapsed = ____opt_50 and ____opt_50.elapsed or 0
802
+ local timer = self[114]
784
803
  if timer == nil then
785
804
  timer = Timer:create()
786
- self[113] = timer
805
+ self[114] = timer
787
806
  end
788
807
  local initialDelay = damageInterval - (elapsed >= damageInterval and math.fmod(elapsed, damageInterval) or elapsed)
789
808
  if initialDelay == damageInterval then
@@ -800,13 +819,13 @@ __TS__SetDescriptor(
800
819
  "remainingHealingOverDuration",
801
820
  {
802
821
  get = function(self)
803
- return self[117] or 0
822
+ return self[118] or 0
804
823
  end,
805
824
  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
825
+ local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[118] or 0)
826
+ self[113] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
827
+ local healingOverDuration = (self[115] or 0) + remainingHealingOverDurationDelta
828
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
810
829
  end
811
830
  },
812
831
  true
@@ -816,13 +835,13 @@ __TS__SetDescriptor(
816
835
  "healingOverDuration",
817
836
  {
818
837
  get = function(self)
819
- return self[114] or 0
838
+ return self[115] or 0
820
839
  end,
821
840
  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
841
+ local healingOverDurationDelta = healingOverDuration - (self[115] or 0)
842
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
843
+ local remainingHealingOverDuration = (self[118] or 0) + healingOverDurationDelta
844
+ self[118] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
826
845
  end
827
846
  },
828
847
  true
@@ -832,10 +851,10 @@ __TS__SetDescriptor(
832
851
  "healingPerInterval",
833
852
  {
834
853
  get = function(self)
835
- return self[115] or 0
854
+ return self[116] or 0
836
855
  end,
837
856
  set = function(self, healingPerInterval)
838
- self[115] = healingPerInterval ~= 0 and healingPerInterval or nil
857
+ self[116] = healingPerInterval ~= 0 and healingPerInterval or nil
839
858
  end
840
859
  },
841
860
  true
@@ -845,25 +864,25 @@ __TS__SetDescriptor(
845
864
  "healingInterval",
846
865
  {
847
866
  get = function(self)
848
- return self[116] or 0
867
+ return self[117] or 0
849
868
  end,
850
869
  set = function(self, healingInterval)
851
870
  if healingInterval <= 0 then
852
- self[116] = healingInterval ~= 0 and healingInterval or nil
853
- local timer = self[118]
871
+ self[117] = healingInterval ~= 0 and healingInterval or nil
872
+ local timer = self[119]
854
873
  if timer ~= nil then
855
874
  timer:destroy()
856
- self[118] = nil
875
+ self[119] = nil
857
876
  end
858
877
  return
859
878
  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]
879
+ self[117] = healingInterval
880
+ local ____opt_52 = self._timer
881
+ local elapsed = ____opt_52 and ____opt_52.elapsed or 0
882
+ local timer = self[119]
864
883
  if timer == nil then
865
884
  timer = Timer:create()
866
- self[118] = timer
885
+ self[119] = timer
867
886
  end
868
887
  local initialDelay = healingInterval - (elapsed >= healingInterval and math.fmod(elapsed, healingInterval) or elapsed)
869
888
  if initialDelay == healingInterval then
@@ -880,10 +899,10 @@ __TS__SetDescriptor(
880
899
  "damageOnExpiration",
881
900
  {
882
901
  get = function(self)
883
- return self[119] or 0
902
+ return self[120] or 0
884
903
  end,
885
904
  set = function(self, damageOnExpiration)
886
- self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
905
+ self[120] = damageOnExpiration ~= 0 and damageOnExpiration or nil
887
906
  end
888
907
  },
889
908
  true
@@ -893,10 +912,10 @@ __TS__SetDescriptor(
893
912
  "healingOnExpiration",
894
913
  {
895
914
  get = function(self)
896
- return self[120] or 0
915
+ return self[121] or 0
897
916
  end,
898
917
  set = function(self, healingOnExpiration)
899
- self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
918
+ self[121] = healingOnExpiration ~= 0 and healingOnExpiration or nil
900
919
  end
901
920
  },
902
921
  true
@@ -945,25 +964,25 @@ __TS__SetDescriptor(
945
964
  "stuns",
946
965
  {
947
966
  get = function(self)
948
- local ____self__134_52 = self[134]
949
- if ____self__134_52 == nil then
950
- ____self__134_52 = false
967
+ local ____self__135_54 = self[135]
968
+ if ____self__135_54 == nil then
969
+ ____self__135_54 = false
951
970
  end
952
- return ____self__134_52
971
+ return ____self__135_54
953
972
  end,
954
973
  set = function(self, stuns)
955
- if not stuns and self[134] then
956
- if self[135] then
974
+ if not stuns and self[135] then
975
+ if self[136] then
957
976
  self.object:decrementStunCounter()
958
977
  end
959
978
  self.object:decrementStunCounter()
960
- self[134] = nil
961
- elseif stuns and not self[134] then
962
- if self[135] then
979
+ self[135] = nil
980
+ elseif stuns and not self[135] then
981
+ if self[136] then
963
982
  self.object:incrementStunCounter()
964
983
  end
965
984
  self.object:incrementStunCounter()
966
- self[134] = true
985
+ self[135] = true
967
986
  end
968
987
  end
969
988
  },
@@ -974,23 +993,23 @@ __TS__SetDescriptor(
974
993
  "ignoresStunImmunity",
975
994
  {
976
995
  get = function(self)
977
- local ____self__135_53 = self[135]
978
- if ____self__135_53 == nil then
979
- ____self__135_53 = false
996
+ local ____self__136_55 = self[136]
997
+ if ____self__136_55 == nil then
998
+ ____self__136_55 = false
980
999
  end
981
- return ____self__135_53
1000
+ return ____self__136_55
982
1001
  end,
983
1002
  set = function(self, ignoresStunImmunity)
984
- if not ignoresStunImmunity and self[135] then
985
- if self[134] then
1003
+ if not ignoresStunImmunity and self[136] then
1004
+ if self[135] then
986
1005
  self.object:decrementStunCounter()
987
1006
  end
988
- self[135] = nil
989
- elseif ignoresStunImmunity and not self[135] then
990
- if self[134] then
1007
+ self[136] = nil
1008
+ elseif ignoresStunImmunity and not self[136] then
1009
+ if self[135] then
991
1010
  self.object:incrementStunCounter()
992
1011
  end
993
- self[135] = true
1012
+ self[136] = true
994
1013
  end
995
1014
  end
996
1015
  },
@@ -1001,19 +1020,19 @@ __TS__SetDescriptor(
1001
1020
  "disablesAutoAttack",
1002
1021
  {
1003
1022
  get = function(self)
1004
- local ____self__136_54 = self[136]
1005
- if ____self__136_54 == nil then
1006
- ____self__136_54 = false
1023
+ local ____self__137_56 = self[137]
1024
+ if ____self__137_56 == nil then
1025
+ ____self__137_56 = false
1007
1026
  end
1008
- return ____self__136_54
1027
+ return ____self__137_56
1009
1028
  end,
1010
1029
  set = function(self, disablesAutoAttack)
1011
- if not disablesAutoAttack and self[136] then
1030
+ if not disablesAutoAttack and self[137] then
1012
1031
  self.object:decrementDisableAutoAttackCounter()
1013
- self[136] = nil
1014
- elseif disablesAutoAttack and not self[136] then
1032
+ self[137] = nil
1033
+ elseif disablesAutoAttack and not self[137] then
1015
1034
  self.object:incrementDisableAutoAttackCounter()
1016
- self[136] = true
1035
+ self[137] = true
1017
1036
  end
1018
1037
  end
1019
1038
  },
@@ -1024,19 +1043,19 @@ __TS__SetDescriptor(
1024
1043
  "providesInvulnerability",
1025
1044
  {
1026
1045
  get = function(self)
1027
- local ____self__137_55 = self[137]
1028
- if ____self__137_55 == nil then
1029
- ____self__137_55 = false
1046
+ local ____self__138_57 = self[138]
1047
+ if ____self__138_57 == nil then
1048
+ ____self__138_57 = false
1030
1049
  end
1031
- return ____self__137_55
1050
+ return ____self__138_57
1032
1051
  end,
1033
1052
  set = function(self, providesInvulnerability)
1034
- if not providesInvulnerability and self[137] then
1053
+ if not providesInvulnerability and self[138] then
1035
1054
  self.object:decrementInvulnerabilityCounter()
1036
- self[137] = nil
1037
- elseif providesInvulnerability and not self[137] then
1055
+ self[138] = nil
1056
+ elseif providesInvulnerability and not self[138] then
1038
1057
  self.object:incrementInvulnerabilityCounter()
1039
- self[137] = true
1058
+ self[138] = true
1040
1059
  end
1041
1060
  end
1042
1061
  },
@@ -1047,17 +1066,17 @@ __TS__SetDescriptor(
1047
1066
  "killsOnExpiration",
1048
1067
  {
1049
1068
  get = function(self)
1050
- local ____self__138_56 = self[138]
1051
- if ____self__138_56 == nil then
1052
- ____self__138_56 = false
1069
+ local ____self__139_58 = self[139]
1070
+ if ____self__139_58 == nil then
1071
+ ____self__139_58 = false
1053
1072
  end
1054
- return ____self__138_56
1073
+ return ____self__139_58
1055
1074
  end,
1056
1075
  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
1076
+ if not killsOnExpiration and self[139] then
1077
+ self[139] = nil
1078
+ elseif killsOnExpiration and not self[139] then
1079
+ self[139] = true
1061
1080
  end
1062
1081
  end
1063
1082
  },
@@ -1068,17 +1087,17 @@ __TS__SetDescriptor(
1068
1087
  "explodesOnExpiration",
1069
1088
  {
1070
1089
  get = function(self)
1071
- local ____self__139_57 = self[139]
1072
- if ____self__139_57 == nil then
1073
- ____self__139_57 = false
1090
+ local ____self__140_59 = self[140]
1091
+ if ____self__140_59 == nil then
1092
+ ____self__140_59 = false
1074
1093
  end
1075
- return ____self__139_57
1094
+ return ____self__140_59
1076
1095
  end,
1077
1096
  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
1097
+ if not killsOnExpiration and self[140] then
1098
+ self[140] = nil
1099
+ elseif killsOnExpiration and not self[140] then
1100
+ self[140] = true
1082
1101
  end
1083
1102
  end
1084
1103
  },
@@ -1089,13 +1108,13 @@ __TS__SetDescriptor(
1089
1108
  "maximumDamageDealtEventCount",
1090
1109
  {
1091
1110
  get = function(self)
1092
- return self[131] or 0
1111
+ return self[132] or 0
1093
1112
  end,
1094
1113
  set = function(self, maximumDamageDealtEventCount)
1095
1114
  if maximumDamageDealtEventCount == 0 then
1096
- self[131] = nil
1115
+ self[132] = nil
1097
1116
  else
1098
- self[131] = maximumDamageDealtEventCount
1117
+ self[132] = maximumDamageDealtEventCount
1099
1118
  end
1100
1119
  end
1101
1120
  },
@@ -1106,13 +1125,13 @@ __TS__SetDescriptor(
1106
1125
  "maximumDamageReceivedEventCount",
1107
1126
  {
1108
1127
  get = function(self)
1109
- return self[133] or 0
1128
+ return self[134] or 0
1110
1129
  end,
1111
1130
  set = function(self, maximumDamageReceivedEventCount)
1112
1131
  if maximumDamageReceivedEventCount == 0 then
1113
- self[133] = nil
1132
+ self[134] = nil
1114
1133
  else
1115
- self[133] = maximumDamageReceivedEventCount
1134
+ self[134] = maximumDamageReceivedEventCount
1116
1135
  end
1117
1136
  end
1118
1137
  },
@@ -1123,13 +1142,13 @@ __TS__SetDescriptor(
1123
1142
  "maximumAutoAttackCount",
1124
1143
  {
1125
1144
  get = function(self)
1126
- return self[129] or 0
1145
+ return self[130] or 0
1127
1146
  end,
1128
1147
  set = function(self, maximumAutoAttackCount)
1129
1148
  if maximumAutoAttackCount == 0 then
1130
- self[129] = nil
1149
+ self[130] = nil
1131
1150
  else
1132
- self[129] = maximumAutoAttackCount
1151
+ self[130] = maximumAutoAttackCount
1133
1152
  end
1134
1153
  end
1135
1154
  },
@@ -1140,10 +1159,10 @@ __TS__SetDescriptor(
1140
1159
  "durationIncreaseOnAutoAttack",
1141
1160
  {
1142
1161
  get = function(self)
1143
- return self[106] or 0
1162
+ return self[107] or 0
1144
1163
  end,
1145
1164
  set = function(self, durationIncreaseOnAutoAttack)
1146
- self[106] = durationIncreaseOnAutoAttack
1165
+ self[107] = durationIncreaseOnAutoAttack
1147
1166
  end
1148
1167
  },
1149
1168
  true
@@ -1174,11 +1193,24 @@ __TS__SetDescriptor(
1174
1193
  },
1175
1194
  true
1176
1195
  )
1196
+ __TS__SetDescriptor(
1197
+ Buff.prototype,
1198
+ "evasionProbability",
1199
+ {
1200
+ get = function(self)
1201
+ return self:getUnitBonus(UnitBonusType.EVASION_PROBABILITY)
1202
+ end,
1203
+ set = function(self, evasionProbability)
1204
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.EVASION_PROBABILITY, evasionProbability)
1205
+ end
1206
+ },
1207
+ true
1208
+ )
1177
1209
  __TS__SetDescriptor(
1178
1210
  Buff.prototype,
1179
1211
  "duration",
1180
1212
  {get = function(self)
1181
- return self[102]
1213
+ return self[103]
1182
1214
  end},
1183
1215
  true
1184
1216
  )
@@ -1187,15 +1219,15 @@ __TS__SetDescriptor(
1187
1219
  "remainingDuration",
1188
1220
  {
1189
1221
  get = function(self)
1190
- local ____opt_58 = self._timer
1191
- return ____opt_58 and ____opt_58.remaining or 0
1222
+ local ____opt_60 = self._timer
1223
+ return ____opt_60 and ____opt_60.remaining or 0
1192
1224
  end,
1193
1225
  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)
1226
+ local ____remainingDuration_64 = remainingDuration
1227
+ local ____opt_62 = self._timer
1228
+ local remainingDurationDelta = ____remainingDuration_64 - (____opt_62 and ____opt_62.remaining or 0)
1197
1229
  if remainingDurationDelta ~= 0 then
1198
- self[102] = self[102] + remainingDurationDelta
1230
+ self[103] = self[103] + remainingDurationDelta
1199
1231
  if remainingDuration <= 0 then
1200
1232
  Timer:run(destroyBuff, self)
1201
1233
  else
@@ -1207,7 +1239,8 @@ __TS__SetDescriptor(
1207
1239
  self._level,
1208
1240
  remainingDuration,
1209
1241
  self._spellStealPriority,
1210
- self._learnLevelMinimum
1242
+ self._learnLevelMinimum,
1243
+ self[141]
1211
1244
  ) then
1212
1245
  local timer = self._timer
1213
1246
  if timer == nil then
@@ -1221,10 +1254,11 @@ __TS__SetDescriptor(
1221
1254
  end
1222
1255
  },
1223
1256
  true
1224
- );
1257
+ )
1258
+ Buff.destroyEvent = buffDestroyEvent;
1225
1259
  (function(self)
1226
1260
  local function destroyBuffIfNeeded(buff)
1227
- if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1261
+ if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
1228
1262
  buff:destroy()
1229
1263
  end
1230
1264
  end