warscript 0.0.1-dev.4363c65 → 0.0.1-dev.46a1ede

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 (88) hide show
  1. package/core/types/effect.d.ts +13 -3
  2. package/core/types/effect.lua +116 -17
  3. package/core/types/frame.d.ts +4 -0
  4. package/core/types/frame.lua +71 -0
  5. package/core/util.d.ts +1 -1
  6. package/core/util.lua +12 -0
  7. package/engine/behavior.d.ts +2 -2
  8. package/engine/behavior.lua +6 -6
  9. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  10. package/engine/behaviour/ability/always-enabled.lua +31 -0
  11. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  12. package/engine/behaviour/ability/apply-buff.lua +32 -0
  13. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  14. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  15. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  16. package/engine/behaviour/ability/instant-impact.lua +4 -19
  17. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  18. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  19. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  20. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  21. package/engine/behaviour/ability.d.ts +15 -3
  22. package/engine/behaviour/ability.lua +93 -34
  23. package/engine/behaviour/unit.d.ts +5 -0
  24. package/engine/behaviour/unit.lua +20 -0
  25. package/engine/buff.d.ts +64 -46
  26. package/engine/buff.lua +251 -199
  27. package/engine/internal/ability.d.ts +16 -13
  28. package/engine/internal/ability.lua +80 -76
  29. package/engine/internal/item/ability.lua +106 -0
  30. package/engine/internal/item+owner.lua +2 -2
  31. package/engine/internal/item.d.ts +2 -2
  32. package/engine/internal/item.lua +56 -25
  33. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  34. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  35. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  36. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  37. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  38. package/engine/internal/object-data/evasion-probability.lua +16 -0
  39. package/engine/internal/unit/ability.d.ts +10 -1
  40. package/engine/internal/unit/ability.lua +36 -14
  41. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  42. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  43. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  44. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  45. package/engine/internal/unit/bonus.d.ts +6 -2
  46. package/engine/internal/unit/bonus.lua +23 -1
  47. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  48. package/engine/internal/unit/ignore-events-items.lua +5 -0
  49. package/engine/internal/unit/item.d.ts +24 -0
  50. package/engine/internal/unit/item.lua +78 -0
  51. package/engine/internal/unit/main-selected.d.ts +13 -0
  52. package/engine/internal/unit/main-selected.lua +51 -0
  53. package/engine/internal/unit+ability.lua +2 -2
  54. package/engine/internal/unit-missile-launch.lua +24 -5
  55. package/engine/internal/unit.d.ts +26 -10
  56. package/engine/internal/unit.lua +162 -81
  57. package/engine/internal/utility.lua +12 -0
  58. package/engine/lightning.d.ts +12 -5
  59. package/engine/lightning.lua +48 -14
  60. package/engine/local-client.d.ts +7 -2
  61. package/engine/local-client.lua +82 -0
  62. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  63. package/engine/object-data/entry/ability-type.lua +8 -12
  64. package/engine/object-data/entry/item-type.d.ts +14 -0
  65. package/engine/object-data/entry/item-type.lua +91 -0
  66. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  67. package/engine/object-field/ability.d.ts +9 -3
  68. package/engine/object-field/ability.lua +4 -1
  69. package/engine/object-field.d.ts +2 -2
  70. package/engine/object-field.lua +4 -0
  71. package/engine/standard/fields/ability.d.ts +2 -0
  72. package/engine/standard/fields/ability.lua +2 -0
  73. package/engine/unit.d.ts +3 -0
  74. package/engine/unit.lua +3 -0
  75. package/index.d.ts +1 -0
  76. package/index.lua +1 -0
  77. package/net/socket.d.ts +7 -1
  78. package/net/socket.lua +45 -4
  79. package/network.d.ts +1 -0
  80. package/network.lua +3 -2
  81. package/objutil/buff.lua +1 -1
  82. package/package.json +2 -2
  83. package/patch-lua.d.ts +0 -0
  84. package/patch-lua.lua +10 -0
  85. package/utility/arrays.d.ts +8 -1
  86. package/utility/arrays.lua +34 -3
  87. package/utility/lazy.d.ts +2 -0
  88. package/utility/lazy.lua +14 -0
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,8 +45,14 @@ 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
52
+ local ____item = require("engine.internal.item")
53
+ local Item = ____item.Item
54
+ local ____destructable = require("core.types.destructable")
55
+ local Destructable = ____destructable.Destructable
49
56
  local getUnitAbility = BlzGetUnitAbility
50
57
  local stringValueByBuffTypeIdByFieldId = postcompile(function()
51
58
  local stringValueByBuffTypeIdByFieldId = {}
@@ -94,6 +101,8 @@ local buffParametersKeys = {
94
101
  armorIncreaseFactor = true,
95
102
  attackSpeedIncreaseFactor = true,
96
103
  movementSpeedIncreaseFactor = true,
104
+ evasionProbability = true,
105
+ damageFactor = true,
97
106
  receivedDamageFactor = true,
98
107
  receivedMagicDamageFactor = true,
99
108
  durationIncreaseOnAutoAttack = true,
@@ -175,7 +184,9 @@ local buffNumberParameters = {
175
184
  "durationIncreaseOnAutoAttack",
176
185
  "attackSpeedIncreaseFactor",
177
186
  "movementSpeedIncreaseFactor",
187
+ "evasionProbability",
178
188
  "armorIncrease",
189
+ "damageFactor",
179
190
  "receivedDamageFactor",
180
191
  "maximumAutoAttackCount",
181
192
  "maximumDamageDealtEventCount",
@@ -214,7 +225,7 @@ local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
214
225
  return checkNotNull(firstNativeBuffTypeId)
215
226
  end
216
227
  local function destroyBuffIfItHasSameUniqueGroup(buff, uniqueGroup)
217
- if buff[103] == uniqueGroup then
228
+ if buff[104] == uniqueGroup then
218
229
  buff:destroy()
219
230
  end
220
231
  end
@@ -222,17 +233,17 @@ local function destroyBuff(buff)
222
233
  buff:destroy()
223
234
  end
224
235
  local function expireBuff(buff)
225
- local remainingDamageOverDuration = buff[112] or 0
226
- local remainingHealingOverDuration = buff[112] or 0
236
+ local remainingDamageOverDuration = buff[113] or 0
237
+ local remainingHealingOverDuration = buff[113] or 0
227
238
  if remainingDamageOverDuration ~= 0 or remainingHealingOverDuration ~= 0 then
228
239
  buff:flashSpecialEffect()
229
240
  if remainingDamageOverDuration ~= 0 then
230
- (buff[101] or buff[100]):damageTarget(buff[100], remainingDamageOverDuration)
231
- buff[112] = nil
241
+ (buff[102] or buff[101]):damageTarget(buff[101], remainingDamageOverDuration)
242
+ buff[113] = nil
232
243
  end
233
244
  if remainingHealingOverDuration ~= 0 then
234
- (buff[101] or buff[100]):healTarget(buff[100], remainingHealingOverDuration)
235
- buff[117] = nil
245
+ (buff[102] or buff[101]):healTarget(buff[101], remainingHealingOverDuration)
246
+ buff[118] = nil
236
247
  end
237
248
  end
238
249
  Timer:run(destroyBuff, buff)
@@ -240,56 +251,57 @@ local function expireBuff(buff)
240
251
  end
241
252
  local function buffDamageIntervalInitialTimerCallback(buff)
242
253
  buffDamageIntervalTimerCallback(buff)
243
- local timer = buff[113]
244
- local damageInterval = buff[111]
254
+ local timer = buff[114]
255
+ local damageInterval = buff[112]
245
256
  if timer ~= nil and damageInterval ~= nil and damageInterval > 0 then
246
257
  timer:start(damageInterval, true, buffDamageIntervalTimerCallback, buff)
247
258
  end
248
259
  end
249
260
  buffDamageIntervalTimerCallback = function(buff)
250
261
  buff:flashSpecialEffect()
251
- local source = buff[101] or buff[100]
252
- local remainingDamageOverDuration = buff[112] or 0
262
+ local source = buff[102] or buff[101]
263
+ local remainingDamageOverDuration = buff[113] or 0
253
264
  if remainingDamageOverDuration ~= 0 then
254
- local damageInterval = buff[111] or 0
265
+ local damageInterval = buff[112] or 0
255
266
  if damageInterval ~= 0 then
256
267
  local damage = remainingDamageOverDuration / (1 + buff.remainingDuration / damageInterval)
257
- source:damageTarget(buff[100], damage)
258
- buff[112] = remainingDamageOverDuration - damage
268
+ source:damageTarget(buff[101], damage)
269
+ buff[113] = remainingDamageOverDuration - damage
259
270
  end
260
271
  end
261
- local damagePerInterval = buff[110] or 0
272
+ local damagePerInterval = buff[111] or 0
262
273
  if remainingDamageOverDuration == 0 or damagePerInterval ~= 0 then
263
- source:damageTarget(buff[100], damagePerInterval)
274
+ source:damageTarget(buff[101], damagePerInterval)
264
275
  end
265
276
  end
266
277
  local function buffHealingIntervalInitialTimerCallback(buff)
267
278
  buffHealingIntervalTimerCallback(buff)
268
- local timer = buff[118]
269
- local healingInterval = buff[116]
279
+ local timer = buff[119]
280
+ local healingInterval = buff[117]
270
281
  if timer ~= nil and healingInterval ~= nil and healingInterval > 0 then
271
282
  timer:start(healingInterval, true, buffHealingIntervalTimerCallback, buff)
272
283
  end
273
284
  end
274
285
  buffHealingIntervalTimerCallback = function(buff)
275
- if buff[116] ~= buff[111] then
286
+ if buff[117] ~= buff[112] then
276
287
  buff:flashSpecialEffect()
277
288
  end
278
- local source = buff[101] or buff[100]
279
- local remainingHealingOverDuration = buff[117] or 0
289
+ local source = buff[102] or buff[101]
290
+ local remainingHealingOverDuration = buff[118] or 0
280
291
  if remainingHealingOverDuration ~= 0 then
281
- local healingInterval = buff[116] or 0
292
+ local healingInterval = buff[117] or 0
282
293
  if healingInterval ~= 0 then
283
294
  local healing = remainingHealingOverDuration / (1 + buff.remainingDuration / healingInterval)
284
- source:healTarget(buff[100], healing)
285
- buff[117] = remainingHealingOverDuration - healing
295
+ source:healTarget(buff[101], healing)
296
+ buff[118] = remainingHealingOverDuration - healing
286
297
  end
287
298
  end
288
- local healingPerInterval = buff[115] or 0
299
+ local healingPerInterval = buff[116] or 0
289
300
  if remainingHealingOverDuration == 0 or healingPerInterval ~= 0 then
290
- source:healTarget(buff[100], healingPerInterval)
301
+ source:healTarget(buff[101], healingPerInterval)
291
302
  end
292
303
  end
304
+ local buffDestroyEvent = __TS__New(Event)
293
305
  ____exports.Buff = __TS__Class()
294
306
  local Buff = ____exports.Buff
295
307
  Buff.name = "Buff"
@@ -298,7 +310,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
298
310
  UnitBehavior.prototype.____constructor(self, _unit)
299
311
  self._unit = _unit
300
312
  self.parameters = nil
301
- self[100] = _unit
313
+ self[100] = 0
314
+ self[101] = _unit
302
315
  local typeId
303
316
  local polarity
304
317
  local resistanceType
@@ -390,11 +403,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
390
403
  self._level = level
391
404
  self._spellStealPriority = spellStealPriority
392
405
  self._learnLevelMinimum = learnLevelMinimum
393
- self[101] = source
394
- self[102] = duration or 0
395
- self[103] = uniqueGroup
396
- self[104] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
397
- self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
406
+ self[102] = source
407
+ self[103] = duration or 0
408
+ self[104] = uniqueGroup
409
+ self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
410
+ self[106] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
398
411
  if parameters ~= nil or (next(defaultParameters)) ~= nil then
399
412
  for ____, buffBooleanParameter in ipairs(buffBooleanParameters) do
400
413
  local ____ability_22 = ability
@@ -419,11 +432,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
419
432
  end
420
433
  local maximumDuration = parameters and parameters.maximumDuration or defaultParameters.maximumDuration
421
434
  if maximumDuration ~= nil then
422
- self[107] = resolveNumberValue(ability, level, maximumDuration)
435
+ self[108] = resolveNumberValue(ability, level, maximumDuration)
423
436
  end
424
437
  local maximumRemainingDuration = parameters and parameters.maximumRemainingDuration or defaultParameters.maximumRemainingDuration
425
438
  if maximumRemainingDuration ~= nil then
426
- self[108] = resolveNumberValue(ability, level, maximumRemainingDuration)
439
+ self[109] = resolveNumberValue(ability, level, maximumRemainingDuration)
427
440
  end
428
441
  local parametersAbilityTypeIds = parameters and parameters.abilityTypeIds or defaultParameters.abilityTypeIds
429
442
  if parametersAbilityTypeIds ~= nil then
@@ -480,6 +493,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
480
493
  timer:start(duration, false, expireBuff, self)
481
494
  self._timer = timer
482
495
  end
496
+ self:onCreate()
497
+ self[100] = 1
483
498
  end
484
499
  function Buff.prototype.getUnitBonus(self, bonusType)
485
500
  local ____opt_36 = self._bonusIdByBonusType
@@ -494,33 +509,37 @@ function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
494
509
  end
495
510
  bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
496
511
  end
497
- function Buff.prototype.flashEffect(self, widgetOrDuration, duration)
498
- local isWidgetProvided = type(widgetOrDuration) == "table"
499
- local ____Effect_40 = Effect
500
- local ____Effect_flash_41 = Effect.flash
501
- local ____array_39 = __TS__SparseArrayNew(
502
- self[104],
503
- isWidgetProvided and widgetOrDuration or self._unit,
504
- stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
505
- )
506
- local ____isWidgetProvided_38
507
- if isWidgetProvided then
508
- ____isWidgetProvided_38 = duration
512
+ function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
513
+ if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
514
+ Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
509
515
  else
510
- ____isWidgetProvided_38 = widgetOrDuration
516
+ local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
517
+ local ____Effect_40 = Effect
518
+ local ____Effect_flash_41 = Effect.flash
519
+ local ____array_39 = __TS__SparseArrayNew(
520
+ self[105],
521
+ isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
522
+ stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
523
+ )
524
+ local ____isWidgetProvided_38
525
+ if isWidgetProvided then
526
+ ____isWidgetProvided_38 = yOrParametersOrDuration
527
+ else
528
+ ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
529
+ end
530
+ __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
531
+ ____Effect_flash_41(
532
+ ____Effect_40,
533
+ __TS__SparseArraySpread(____array_39)
534
+ )
511
535
  end
512
- __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
513
- ____Effect_flash_41(
514
- ____Effect_40,
515
- __TS__SparseArraySpread(____array_39)
516
- )
517
536
  end
518
537
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
519
538
  local isWidgetProvided = type(widgetOrDuration) == "table"
520
539
  local ____Effect_44 = Effect
521
540
  local ____Effect_flash_45 = Effect.flash
522
541
  local ____array_43 = __TS__SparseArrayNew(
523
- self[105],
542
+ self[106],
524
543
  isWidgetProvided and widgetOrDuration or self._unit,
525
544
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
526
545
  )
@@ -536,21 +555,25 @@ function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
536
555
  __TS__SparseArraySpread(____array_43)
537
556
  )
538
557
  end
558
+ function Buff.prototype.onCreate(self)
559
+ end
539
560
  function Buff.prototype.onDestroy(self)
561
+ check(self[100] ~= 0, "Cannot destroy a buff that has not finished creating yet.")
562
+ self[100] = 2
540
563
  local unit = self._unit
541
564
  if getUnitAbility(unit.handle, self.typeId) == self.handle then
542
565
  removeBuff(unit.handle, self.typeId)
543
566
  end
544
567
  buffByTypeIdByUnit[unit][self.typeId] = nil
545
- local healingIntervalTimer = self[118]
568
+ local healingIntervalTimer = self[119]
546
569
  if healingIntervalTimer ~= nil then
547
570
  healingIntervalTimer:destroy()
548
- self[118] = nil
571
+ self[119] = nil
549
572
  end
550
- local damageIntervalTimer = self[113]
573
+ local damageIntervalTimer = self[114]
551
574
  if damageIntervalTimer ~= nil then
552
575
  damageIntervalTimer:destroy()
553
- self[113] = nil
576
+ self[114] = nil
554
577
  end
555
578
  if self._timer ~= nil then
556
579
  self._timer:destroy()
@@ -560,11 +583,11 @@ function Buff.prototype.onDestroy(self)
560
583
  behavior:destroy()
561
584
  end
562
585
  end
563
- if self[136] then
586
+ if self[137] then
564
587
  unit:decrementDisableAutoAttackCounter()
565
588
  end
566
- if self[134] then
567
- if self[135] then
589
+ if self[135] then
590
+ if self[136] then
568
591
  unit:decrementStunCounter()
569
592
  end
570
593
  unit:decrementStunCounter()
@@ -579,6 +602,8 @@ function Buff.prototype.onDestroy(self)
579
602
  removeUnitBonus(unit, bonusType, bonusId)
580
603
  end
581
604
  end
605
+ Event.invoke(buffDestroyEvent, self)
606
+ self[100] = 3
582
607
  return UnitBehavior.prototype.onDestroy(self)
583
608
  end
584
609
  function Buff.apply(self, ...)
@@ -615,72 +640,72 @@ function Buff.getByTypeId(self, unit, typeId)
615
640
  end
616
641
  function Buff.prototype.onExpiration(self)
617
642
  local unit = self.unit
618
- if self[119] ~= nil then
619
- (self[101] or unit):damageTarget(unit, self[119] or 0)
620
- end
621
643
  if self[120] ~= nil then
622
- (self[101] or unit):healTarget(unit, self[119] or 0)
644
+ (self[102] or unit):damageTarget(unit, self[120] or 0)
645
+ end
646
+ if self[121] ~= nil then
647
+ (self[102] or unit):healTarget(unit, self[120] or 0)
623
648
  end
624
- if self[139] then
649
+ if self[140] then
625
650
  unit:explode()
626
- elseif self[138] then
651
+ elseif self[139] then
627
652
  unit:kill()
628
653
  end
629
654
  end
630
655
  function Buff.prototype.onDeath(self, source)
631
656
  local unit = self.unit
632
- if self[121] ~= nil then
657
+ if self[122] ~= nil then
633
658
  damageArea(
634
- self[101] or unit,
635
- self[121],
659
+ self[102] or unit,
660
+ self[122],
636
661
  unit.x,
637
662
  unit.y,
663
+ self[124] or 0,
638
664
  self[123] or 0,
639
- self[122] or 0,
665
+ self[126] or 0,
640
666
  self[125] or 0,
641
- self[124] or 0,
642
- self[127] or 0,
643
- self[126] or 0
667
+ self[128] or 0,
668
+ self[127] or 0
644
669
  )
645
670
  end
646
671
  end
647
672
  function Buff.prototype.onDamageDealt(self, target, event)
648
673
  if event.isAttack then
649
- if self[106] ~= nil then
650
- local durationIncrease = self[106]
651
- local maximumDuration = self[107] or 0
674
+ if self[107] ~= nil then
675
+ local durationIncrease = self[107]
676
+ local maximumDuration = self[108] or 0
652
677
  if maximumDuration > 0 then
653
678
  durationIncrease = min(
654
679
  durationIncrease,
655
- max(0, maximumDuration - self[102])
680
+ max(0, maximumDuration - self[103])
656
681
  )
657
682
  end
658
683
  local remainingDuration = self.remainingDuration + durationIncrease
659
- local maximumRemainingDuration = self[108] or 0
684
+ local maximumRemainingDuration = self[109] or 0
660
685
  if maximumRemainingDuration > 0 then
661
686
  remainingDuration = min(remainingDuration, maximumRemainingDuration)
662
687
  end
663
688
  self.remainingDuration = remainingDuration
664
689
  end
665
- local autoAttackCount = (self[128] or 0) + 1
666
- self[128] = autoAttackCount
667
- if autoAttackCount == self[129] then
690
+ local autoAttackCount = (self[129] or 0) + 1
691
+ self[129] = autoAttackCount
692
+ if autoAttackCount == self[130] then
668
693
  self:destroy()
669
694
  end
670
695
  end
671
- if event.amount ~= 0 then
672
- local damageDealtEventCount = (self[130] or 0) + 1
673
- self[130] = damageDealtEventCount
674
- if damageDealtEventCount == self[131] then
696
+ if event.originalAmount ~= 0 then
697
+ local damageDealtEventCount = (self[131] or 0) + 1
698
+ self[131] = damageDealtEventCount
699
+ if damageDealtEventCount == self[132] then
675
700
  self:destroy()
676
701
  end
677
702
  end
678
703
  end
679
704
  function Buff.prototype.onDamageReceived(self, source, event)
680
- if event.amount ~= 0 then
681
- local damageReceivedEventCount = (self[132] or 0) + 1
682
- self[132] = damageReceivedEventCount
683
- if damageReceivedEventCount == self[133] then
705
+ if event.originalAmount ~= 0 then
706
+ local damageReceivedEventCount = (self[133] or 0) + 1
707
+ self[133] = damageReceivedEventCount
708
+ if damageReceivedEventCount == self[134] then
684
709
  self:destroy()
685
710
  end
686
711
  end
@@ -690,7 +715,7 @@ __TS__SetDescriptor(
690
715
  Buff.prototype,
691
716
  "source",
692
717
  {get = function(self)
693
- return self[101] or self._unit
718
+ return self[102] or self._unit
694
719
  end},
695
720
  true
696
721
  )
@@ -707,13 +732,13 @@ __TS__SetDescriptor(
707
732
  "remainingDamageOverDuration",
708
733
  {
709
734
  get = function(self)
710
- return self[112] or 0
735
+ return self[113] or 0
711
736
  end,
712
737
  set = function(self, remainingDamageOverDuration)
713
- local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[112] or 0)
714
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
715
- local damageOverDuration = (self[109] or 0) + remainingDamageOverDurationDelta
716
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
738
+ local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[113] or 0)
739
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
740
+ local damageOverDuration = (self[110] or 0) + remainingDamageOverDurationDelta
741
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
717
742
  end
718
743
  },
719
744
  true
@@ -723,13 +748,13 @@ __TS__SetDescriptor(
723
748
  "damageOverDuration",
724
749
  {
725
750
  get = function(self)
726
- return self[109] or 0
751
+ return self[110] or 0
727
752
  end,
728
753
  set = function(self, damageOverDuration)
729
- local damageOverDurationDelta = damageOverDuration - (self[109] or 0)
730
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
731
- local remainingDamageOverDuration = (self[112] or 0) + damageOverDurationDelta
732
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
754
+ local damageOverDurationDelta = damageOverDuration - (self[110] or 0)
755
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
756
+ local remainingDamageOverDuration = (self[113] or 0) + damageOverDurationDelta
757
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
733
758
  end
734
759
  },
735
760
  true
@@ -739,10 +764,10 @@ __TS__SetDescriptor(
739
764
  "damagePerInterval",
740
765
  {
741
766
  get = function(self)
742
- return self[110] or 0
767
+ return self[111] or 0
743
768
  end,
744
769
  set = function(self, damagePerInterval)
745
- self[110] = damagePerInterval ~= 0 and damagePerInterval or nil
770
+ self[111] = damagePerInterval ~= 0 and damagePerInterval or nil
746
771
  end
747
772
  },
748
773
  true
@@ -752,25 +777,25 @@ __TS__SetDescriptor(
752
777
  "damageInterval",
753
778
  {
754
779
  get = function(self)
755
- return self[111] or 0
780
+ return self[112] or 0
756
781
  end,
757
782
  set = function(self, damageInterval)
758
783
  if damageInterval <= 0 then
759
- self[111] = damageInterval ~= 0 and damageInterval or nil
760
- local timer = self[113]
784
+ self[112] = damageInterval ~= 0 and damageInterval or nil
785
+ local timer = self[114]
761
786
  if timer ~= nil then
762
787
  timer:destroy()
763
- self[113] = nil
788
+ self[114] = nil
764
789
  end
765
790
  return
766
791
  end
767
- self[111] = damageInterval
792
+ self[112] = damageInterval
768
793
  local ____opt_48 = self._timer
769
794
  local elapsed = ____opt_48 and ____opt_48.elapsed or 0
770
- local timer = self[113]
795
+ local timer = self[114]
771
796
  if timer == nil then
772
797
  timer = Timer:create()
773
- self[113] = timer
798
+ self[114] = timer
774
799
  end
775
800
  local initialDelay = damageInterval - (elapsed >= damageInterval and math.fmod(elapsed, damageInterval) or elapsed)
776
801
  if initialDelay == damageInterval then
@@ -787,13 +812,13 @@ __TS__SetDescriptor(
787
812
  "remainingHealingOverDuration",
788
813
  {
789
814
  get = function(self)
790
- return self[117] or 0
815
+ return self[118] or 0
791
816
  end,
792
817
  set = function(self, remainingHealingOverDuration)
793
- local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[117] or 0)
794
- self[112] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
795
- local healingOverDuration = (self[114] or 0) + remainingHealingOverDurationDelta
796
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
818
+ local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[118] or 0)
819
+ self[113] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
820
+ local healingOverDuration = (self[115] or 0) + remainingHealingOverDurationDelta
821
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
797
822
  end
798
823
  },
799
824
  true
@@ -803,13 +828,13 @@ __TS__SetDescriptor(
803
828
  "healingOverDuration",
804
829
  {
805
830
  get = function(self)
806
- return self[114] or 0
831
+ return self[115] or 0
807
832
  end,
808
833
  set = function(self, healingOverDuration)
809
- local healingOverDurationDelta = healingOverDuration - (self[114] or 0)
810
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
811
- local remainingHealingOverDuration = (self[117] or 0) + healingOverDurationDelta
812
- self[117] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
834
+ local healingOverDurationDelta = healingOverDuration - (self[115] or 0)
835
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
836
+ local remainingHealingOverDuration = (self[118] or 0) + healingOverDurationDelta
837
+ self[118] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
813
838
  end
814
839
  },
815
840
  true
@@ -819,10 +844,10 @@ __TS__SetDescriptor(
819
844
  "healingPerInterval",
820
845
  {
821
846
  get = function(self)
822
- return self[115] or 0
847
+ return self[116] or 0
823
848
  end,
824
849
  set = function(self, healingPerInterval)
825
- self[115] = healingPerInterval ~= 0 and healingPerInterval or nil
850
+ self[116] = healingPerInterval ~= 0 and healingPerInterval or nil
826
851
  end
827
852
  },
828
853
  true
@@ -832,25 +857,25 @@ __TS__SetDescriptor(
832
857
  "healingInterval",
833
858
  {
834
859
  get = function(self)
835
- return self[116] or 0
860
+ return self[117] or 0
836
861
  end,
837
862
  set = function(self, healingInterval)
838
863
  if healingInterval <= 0 then
839
- self[116] = healingInterval ~= 0 and healingInterval or nil
840
- local timer = self[118]
864
+ self[117] = healingInterval ~= 0 and healingInterval or nil
865
+ local timer = self[119]
841
866
  if timer ~= nil then
842
867
  timer:destroy()
843
- self[118] = nil
868
+ self[119] = nil
844
869
  end
845
870
  return
846
871
  end
847
- self[116] = healingInterval
872
+ self[117] = healingInterval
848
873
  local ____opt_50 = self._timer
849
874
  local elapsed = ____opt_50 and ____opt_50.elapsed or 0
850
- local timer = self[118]
875
+ local timer = self[119]
851
876
  if timer == nil then
852
877
  timer = Timer:create()
853
- self[118] = timer
878
+ self[119] = timer
854
879
  end
855
880
  local initialDelay = healingInterval - (elapsed >= healingInterval and math.fmod(elapsed, healingInterval) or elapsed)
856
881
  if initialDelay == healingInterval then
@@ -867,10 +892,10 @@ __TS__SetDescriptor(
867
892
  "damageOnExpiration",
868
893
  {
869
894
  get = function(self)
870
- return self[119] or 0
895
+ return self[120] or 0
871
896
  end,
872
897
  set = function(self, damageOnExpiration)
873
- self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
898
+ self[120] = damageOnExpiration ~= 0 and damageOnExpiration or nil
874
899
  end
875
900
  },
876
901
  true
@@ -880,10 +905,23 @@ __TS__SetDescriptor(
880
905
  "healingOnExpiration",
881
906
  {
882
907
  get = function(self)
883
- return self[120] or 0
908
+ return self[121] or 0
884
909
  end,
885
910
  set = function(self, healingOnExpiration)
886
- self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
911
+ self[121] = healingOnExpiration ~= 0 and healingOnExpiration or nil
912
+ end
913
+ },
914
+ true
915
+ )
916
+ __TS__SetDescriptor(
917
+ Buff.prototype,
918
+ "damageFactor",
919
+ {
920
+ get = function(self)
921
+ return self:getUnitBonus(UnitBonusType.DAMAGE_FACTOR)
922
+ end,
923
+ set = function(self, damageFactor)
924
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.DAMAGE_FACTOR, damageFactor)
887
925
  end
888
926
  },
889
927
  true
@@ -919,25 +957,25 @@ __TS__SetDescriptor(
919
957
  "stuns",
920
958
  {
921
959
  get = function(self)
922
- local ____self__134_52 = self[134]
923
- if ____self__134_52 == nil then
924
- ____self__134_52 = false
960
+ local ____self__135_52 = self[135]
961
+ if ____self__135_52 == nil then
962
+ ____self__135_52 = false
925
963
  end
926
- return ____self__134_52
964
+ return ____self__135_52
927
965
  end,
928
966
  set = function(self, stuns)
929
- if not stuns and self[134] then
930
- if self[135] then
967
+ if not stuns and self[135] then
968
+ if self[136] then
931
969
  self.object:decrementStunCounter()
932
970
  end
933
971
  self.object:decrementStunCounter()
934
- self[134] = nil
935
- elseif stuns and not self[134] then
936
- if self[135] then
972
+ self[135] = nil
973
+ elseif stuns and not self[135] then
974
+ if self[136] then
937
975
  self.object:incrementStunCounter()
938
976
  end
939
977
  self.object:incrementStunCounter()
940
- self[134] = true
978
+ self[135] = true
941
979
  end
942
980
  end
943
981
  },
@@ -948,23 +986,23 @@ __TS__SetDescriptor(
948
986
  "ignoresStunImmunity",
949
987
  {
950
988
  get = function(self)
951
- local ____self__135_53 = self[135]
952
- if ____self__135_53 == nil then
953
- ____self__135_53 = false
989
+ local ____self__136_53 = self[136]
990
+ if ____self__136_53 == nil then
991
+ ____self__136_53 = false
954
992
  end
955
- return ____self__135_53
993
+ return ____self__136_53
956
994
  end,
957
995
  set = function(self, ignoresStunImmunity)
958
- if not ignoresStunImmunity and self[135] then
959
- if self[134] then
996
+ if not ignoresStunImmunity and self[136] then
997
+ if self[135] then
960
998
  self.object:decrementStunCounter()
961
999
  end
962
- self[135] = nil
963
- elseif ignoresStunImmunity and not self[135] then
964
- if self[134] then
1000
+ self[136] = nil
1001
+ elseif ignoresStunImmunity and not self[136] then
1002
+ if self[135] then
965
1003
  self.object:incrementStunCounter()
966
1004
  end
967
- self[135] = true
1005
+ self[136] = true
968
1006
  end
969
1007
  end
970
1008
  },
@@ -975,19 +1013,19 @@ __TS__SetDescriptor(
975
1013
  "disablesAutoAttack",
976
1014
  {
977
1015
  get = function(self)
978
- local ____self__136_54 = self[136]
979
- if ____self__136_54 == nil then
980
- ____self__136_54 = false
1016
+ local ____self__137_54 = self[137]
1017
+ if ____self__137_54 == nil then
1018
+ ____self__137_54 = false
981
1019
  end
982
- return ____self__136_54
1020
+ return ____self__137_54
983
1021
  end,
984
1022
  set = function(self, disablesAutoAttack)
985
- if not disablesAutoAttack and self[136] then
1023
+ if not disablesAutoAttack and self[137] then
986
1024
  self.object:decrementDisableAutoAttackCounter()
987
- self[136] = nil
988
- elseif disablesAutoAttack and not self[136] then
1025
+ self[137] = nil
1026
+ elseif disablesAutoAttack and not self[137] then
989
1027
  self.object:incrementDisableAutoAttackCounter()
990
- self[136] = true
1028
+ self[137] = true
991
1029
  end
992
1030
  end
993
1031
  },
@@ -998,19 +1036,19 @@ __TS__SetDescriptor(
998
1036
  "providesInvulnerability",
999
1037
  {
1000
1038
  get = function(self)
1001
- local ____self__137_55 = self[137]
1002
- if ____self__137_55 == nil then
1003
- ____self__137_55 = false
1039
+ local ____self__138_55 = self[138]
1040
+ if ____self__138_55 == nil then
1041
+ ____self__138_55 = false
1004
1042
  end
1005
- return ____self__137_55
1043
+ return ____self__138_55
1006
1044
  end,
1007
1045
  set = function(self, providesInvulnerability)
1008
- if not providesInvulnerability and self[137] then
1046
+ if not providesInvulnerability and self[138] then
1009
1047
  self.object:decrementInvulnerabilityCounter()
1010
- self[137] = nil
1011
- elseif providesInvulnerability and not self[137] then
1048
+ self[138] = nil
1049
+ elseif providesInvulnerability and not self[138] then
1012
1050
  self.object:incrementInvulnerabilityCounter()
1013
- self[137] = true
1051
+ self[138] = true
1014
1052
  end
1015
1053
  end
1016
1054
  },
@@ -1021,17 +1059,17 @@ __TS__SetDescriptor(
1021
1059
  "killsOnExpiration",
1022
1060
  {
1023
1061
  get = function(self)
1024
- local ____self__138_56 = self[138]
1025
- if ____self__138_56 == nil then
1026
- ____self__138_56 = false
1062
+ local ____self__139_56 = self[139]
1063
+ if ____self__139_56 == nil then
1064
+ ____self__139_56 = false
1027
1065
  end
1028
- return ____self__138_56
1066
+ return ____self__139_56
1029
1067
  end,
1030
1068
  set = function(self, killsOnExpiration)
1031
- if not killsOnExpiration and self[138] then
1032
- self[138] = nil
1033
- elseif killsOnExpiration and not self[138] then
1034
- self[138] = true
1069
+ if not killsOnExpiration and self[139] then
1070
+ self[139] = nil
1071
+ elseif killsOnExpiration and not self[139] then
1072
+ self[139] = true
1035
1073
  end
1036
1074
  end
1037
1075
  },
@@ -1042,17 +1080,17 @@ __TS__SetDescriptor(
1042
1080
  "explodesOnExpiration",
1043
1081
  {
1044
1082
  get = function(self)
1045
- local ____self__139_57 = self[139]
1046
- if ____self__139_57 == nil then
1047
- ____self__139_57 = false
1083
+ local ____self__140_57 = self[140]
1084
+ if ____self__140_57 == nil then
1085
+ ____self__140_57 = false
1048
1086
  end
1049
- return ____self__139_57
1087
+ return ____self__140_57
1050
1088
  end,
1051
1089
  set = function(self, killsOnExpiration)
1052
- if not killsOnExpiration and self[139] then
1053
- self[139] = nil
1054
- elseif killsOnExpiration and not self[139] then
1055
- self[139] = true
1090
+ if not killsOnExpiration and self[140] then
1091
+ self[140] = nil
1092
+ elseif killsOnExpiration and not self[140] then
1093
+ self[140] = true
1056
1094
  end
1057
1095
  end
1058
1096
  },
@@ -1063,13 +1101,13 @@ __TS__SetDescriptor(
1063
1101
  "maximumDamageDealtEventCount",
1064
1102
  {
1065
1103
  get = function(self)
1066
- return self[131] or 0
1104
+ return self[132] or 0
1067
1105
  end,
1068
1106
  set = function(self, maximumDamageDealtEventCount)
1069
1107
  if maximumDamageDealtEventCount == 0 then
1070
- self[131] = nil
1108
+ self[132] = nil
1071
1109
  else
1072
- self[131] = maximumDamageDealtEventCount
1110
+ self[132] = maximumDamageDealtEventCount
1073
1111
  end
1074
1112
  end
1075
1113
  },
@@ -1080,13 +1118,13 @@ __TS__SetDescriptor(
1080
1118
  "maximumDamageReceivedEventCount",
1081
1119
  {
1082
1120
  get = function(self)
1083
- return self[133] or 0
1121
+ return self[134] or 0
1084
1122
  end,
1085
1123
  set = function(self, maximumDamageReceivedEventCount)
1086
1124
  if maximumDamageReceivedEventCount == 0 then
1087
- self[133] = nil
1125
+ self[134] = nil
1088
1126
  else
1089
- self[133] = maximumDamageReceivedEventCount
1127
+ self[134] = maximumDamageReceivedEventCount
1090
1128
  end
1091
1129
  end
1092
1130
  },
@@ -1097,13 +1135,13 @@ __TS__SetDescriptor(
1097
1135
  "maximumAutoAttackCount",
1098
1136
  {
1099
1137
  get = function(self)
1100
- return self[129] or 0
1138
+ return self[130] or 0
1101
1139
  end,
1102
1140
  set = function(self, maximumAutoAttackCount)
1103
1141
  if maximumAutoAttackCount == 0 then
1104
- self[129] = nil
1142
+ self[130] = nil
1105
1143
  else
1106
- self[129] = maximumAutoAttackCount
1144
+ self[130] = maximumAutoAttackCount
1107
1145
  end
1108
1146
  end
1109
1147
  },
@@ -1114,10 +1152,10 @@ __TS__SetDescriptor(
1114
1152
  "durationIncreaseOnAutoAttack",
1115
1153
  {
1116
1154
  get = function(self)
1117
- return self[106] or 0
1155
+ return self[107] or 0
1118
1156
  end,
1119
1157
  set = function(self, durationIncreaseOnAutoAttack)
1120
- self[106] = durationIncreaseOnAutoAttack
1158
+ self[107] = durationIncreaseOnAutoAttack
1121
1159
  end
1122
1160
  },
1123
1161
  true
@@ -1148,11 +1186,24 @@ __TS__SetDescriptor(
1148
1186
  },
1149
1187
  true
1150
1188
  )
1189
+ __TS__SetDescriptor(
1190
+ Buff.prototype,
1191
+ "evasionProbability",
1192
+ {
1193
+ get = function(self)
1194
+ return self:getUnitBonus(UnitBonusType.EVASION_PROBABILITY)
1195
+ end,
1196
+ set = function(self, evasionProbability)
1197
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.EVASION_PROBABILITY, evasionProbability)
1198
+ end
1199
+ },
1200
+ true
1201
+ )
1151
1202
  __TS__SetDescriptor(
1152
1203
  Buff.prototype,
1153
1204
  "duration",
1154
1205
  {get = function(self)
1155
- return self[102]
1206
+ return self[103]
1156
1207
  end},
1157
1208
  true
1158
1209
  )
@@ -1169,7 +1220,7 @@ __TS__SetDescriptor(
1169
1220
  local ____opt_60 = self._timer
1170
1221
  local remainingDurationDelta = ____remainingDuration_62 - (____opt_60 and ____opt_60.remaining or 0)
1171
1222
  if remainingDurationDelta ~= 0 then
1172
- self[102] = self[102] + remainingDurationDelta
1223
+ self[103] = self[103] + remainingDurationDelta
1173
1224
  if remainingDuration <= 0 then
1174
1225
  Timer:run(destroyBuff, self)
1175
1226
  else
@@ -1195,10 +1246,11 @@ __TS__SetDescriptor(
1195
1246
  end
1196
1247
  },
1197
1248
  true
1198
- );
1249
+ )
1250
+ Buff.destroyEvent = buffDestroyEvent;
1199
1251
  (function(self)
1200
1252
  local function destroyBuffIfNeeded(buff)
1201
- if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1253
+ if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
1202
1254
  buff:destroy()
1203
1255
  end
1204
1256
  end