warscript 0.0.1-dev.ff2a62d → 0.0.1-dev.ffaa090

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 (128) hide show
  1. package/config.d.ts +5 -0
  2. package/config.lua +10 -0
  3. package/core/types/effect.d.ts +13 -3
  4. package/core/types/effect.lua +116 -17
  5. package/core/types/frame.d.ts +6 -0
  6. package/core/types/frame.lua +91 -1
  7. package/core/types/sound.d.ts +1 -0
  8. package/core/types/sound.lua +36 -2
  9. package/core/util.d.ts +1 -1
  10. package/core/util.lua +18 -1
  11. package/engine/behavior.d.ts +2 -2
  12. package/engine/behavior.lua +6 -6
  13. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  14. package/engine/behaviour/ability/always-enabled.lua +31 -0
  15. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  16. package/engine/behaviour/ability/apply-buff.lua +32 -0
  17. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  18. package/engine/behaviour/ability/damage.d.ts +3 -0
  19. package/engine/behaviour/ability/damage.lua +2 -2
  20. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  21. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  22. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  23. package/engine/behaviour/ability/instant-impact.lua +4 -19
  24. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  25. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  26. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  27. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  28. package/engine/behaviour/ability.d.ts +16 -3
  29. package/engine/behaviour/ability.lua +105 -34
  30. package/engine/behaviour/unit.d.ts +7 -0
  31. package/engine/behaviour/unit.lua +20 -0
  32. package/engine/buff.d.ts +84 -43
  33. package/engine/buff.lua +379 -226
  34. package/engine/internal/ability.d.ts +16 -13
  35. package/engine/internal/ability.lua +80 -76
  36. package/engine/internal/item/ability.lua +106 -0
  37. package/engine/internal/item+owner.lua +2 -2
  38. package/engine/internal/item.d.ts +2 -2
  39. package/engine/internal/item.lua +56 -25
  40. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  41. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  42. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  43. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  44. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  45. package/engine/internal/object-data/evasion-probability.lua +16 -0
  46. package/engine/internal/unit/ability.d.ts +10 -1
  47. package/engine/internal/unit/ability.lua +36 -14
  48. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  49. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  50. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  51. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  52. package/engine/internal/unit/bonus.d.ts +6 -2
  53. package/engine/internal/unit/bonus.lua +23 -1
  54. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  55. package/engine/internal/unit/ignore-events-items.lua +5 -0
  56. package/engine/internal/unit/item.d.ts +24 -0
  57. package/engine/internal/unit/item.lua +78 -0
  58. package/engine/internal/unit/main-selected.d.ts +13 -0
  59. package/engine/internal/unit/main-selected.lua +51 -0
  60. package/engine/internal/unit+ability.lua +2 -2
  61. package/engine/internal/unit-missile-launch.lua +24 -5
  62. package/engine/internal/unit.d.ts +31 -10
  63. package/engine/internal/unit.lua +170 -83
  64. package/engine/internal/utility.lua +12 -0
  65. package/engine/lightning.d.ts +12 -5
  66. package/engine/lightning.lua +48 -14
  67. package/engine/local-client.d.ts +7 -2
  68. package/engine/local-client.lua +82 -0
  69. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  70. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  71. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  72. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  73. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  74. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  75. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  76. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  77. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  78. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  79. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  80. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  81. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  82. package/engine/object-data/entry/ability-type.d.ts +8 -6
  83. package/engine/object-data/entry/ability-type.lua +62 -27
  84. package/engine/object-data/entry/buff-type/applicable.lua +13 -37
  85. package/engine/object-data/entry/buff-type.d.ts +1 -1
  86. package/engine/object-data/entry/buff-type.lua +2 -2
  87. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  88. package/engine/object-data/entry/item-type.d.ts +15 -1
  89. package/engine/object-data/entry/item-type.lua +93 -2
  90. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  91. package/engine/object-data/entry/sound-preset.d.ts +16 -0
  92. package/engine/object-data/entry/sound-preset.lua +36 -0
  93. package/engine/object-data/entry/unit-type.d.ts +8 -1
  94. package/engine/object-data/entry/unit-type.lua +61 -8
  95. package/engine/object-data/entry/upgrade.d.ts +1 -1
  96. package/engine/object-data/entry/upgrade.lua +4 -4
  97. package/engine/object-data/entry.d.ts +16 -14
  98. package/engine/object-data/entry.lua +60 -32
  99. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  100. package/engine/object-field/ability.d.ts +26 -3
  101. package/engine/object-field/ability.lua +54 -1
  102. package/engine/object-field.d.ts +2 -2
  103. package/engine/object-field.lua +4 -0
  104. package/engine/standard/entries/sound-preset.d.ts +10 -0
  105. package/engine/standard/entries/sound-preset.lua +10 -0
  106. package/engine/standard/fields/ability.d.ts +2 -0
  107. package/engine/standard/fields/ability.lua +2 -0
  108. package/engine/unit.d.ts +3 -0
  109. package/engine/unit.lua +3 -0
  110. package/index.d.ts +1 -0
  111. package/index.lua +1 -0
  112. package/net/socket.d.ts +7 -1
  113. package/net/socket.lua +45 -4
  114. package/network.d.ts +1 -0
  115. package/network.lua +3 -2
  116. package/objutil/buff.lua +1 -1
  117. package/objutil/unit.lua +8 -0
  118. package/package.json +2 -2
  119. package/patch-lua.d.ts +0 -0
  120. package/patch-lua.lua +10 -0
  121. package/utility/arrays.d.ts +8 -1
  122. package/utility/arrays.lua +34 -3
  123. package/utility/lazy.d.ts +2 -0
  124. package/utility/lazy.lua +14 -0
  125. package/utility/linked-set.d.ts +11 -2
  126. package/utility/linked-set.lua +5 -2
  127. package/utility/reflection.lua +11 -7
  128. package/utility/types.d.ts +1 -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,11 +101,15 @@ local buffParametersKeys = {
94
101
  armorIncreaseFactor = true,
95
102
  attackSpeedIncreaseFactor = true,
96
103
  movementSpeedIncreaseFactor = true,
104
+ evasionProbability = true,
105
+ missProbability = true,
106
+ damageFactor = true,
97
107
  receivedDamageFactor = true,
98
108
  receivedMagicDamageFactor = true,
99
109
  durationIncreaseOnAutoAttack = true,
100
110
  maximumDuration = true,
101
111
  maximumRemainingDuration = true,
112
+ turnsIntoGhost = true,
102
113
  stuns = true,
103
114
  ignoresStunImmunity = true,
104
115
  providesStunImmunity = true,
@@ -107,12 +118,26 @@ local buffParametersKeys = {
107
118
  disablesAutoAttack = true,
108
119
  destroysOnDamage = true,
109
120
  maximumAutoAttackCount = true,
121
+ maximumDamageDealtEventCount = true,
122
+ maximumDamageReceivedEventCount = true,
110
123
  uniqueGroup = true,
111
124
  damageOnExpiration = true,
112
125
  healingOnExpiration = true,
113
126
  killsOnExpiration = true,
114
127
  explodesOnExpiration = true
115
128
  }
129
+ local function resolveEnumValue(ability, level, value)
130
+ if value == nil or type(value) == "number" then
131
+ return value
132
+ end
133
+ if ability == nil then
134
+ error(
135
+ __TS__New(IllegalArgumentException),
136
+ 0
137
+ )
138
+ end
139
+ return value:getValue(ability, level or ability.level)
140
+ end
116
141
  local function resolveNumberValue(ability, level, value)
117
142
  if value == nil or type(value) == "number" then
118
143
  return value
@@ -150,6 +175,7 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
150
175
  end
151
176
  end
152
177
  local buffBooleanParameters = {
178
+ "turnsIntoGhost",
153
179
  "stuns",
154
180
  "ignoresStunImmunity",
155
181
  "disablesAutoAttack",
@@ -161,9 +187,13 @@ local buffNumberParameters = {
161
187
  "durationIncreaseOnAutoAttack",
162
188
  "attackSpeedIncreaseFactor",
163
189
  "movementSpeedIncreaseFactor",
190
+ "evasionProbability",
164
191
  "armorIncrease",
192
+ "damageFactor",
165
193
  "receivedDamageFactor",
166
194
  "maximumAutoAttackCount",
195
+ "maximumDamageDealtEventCount",
196
+ "maximumDamageReceivedEventCount",
167
197
  "damageInterval",
168
198
  "damagePerInterval",
169
199
  "damageOverDuration",
@@ -198,7 +228,7 @@ local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
198
228
  return checkNotNull(firstNativeBuffTypeId)
199
229
  end
200
230
  local function destroyBuffIfItHasSameUniqueGroup(buff, uniqueGroup)
201
- if buff[103] == uniqueGroup then
231
+ if buff[104] == uniqueGroup then
202
232
  buff:destroy()
203
233
  end
204
234
  end
@@ -206,17 +236,17 @@ local function destroyBuff(buff)
206
236
  buff:destroy()
207
237
  end
208
238
  local function expireBuff(buff)
209
- local remainingDamageOverDuration = buff[112] or 0
210
- local remainingHealingOverDuration = buff[112] or 0
239
+ local remainingDamageOverDuration = buff[113] or 0
240
+ local remainingHealingOverDuration = buff[113] or 0
211
241
  if remainingDamageOverDuration ~= 0 or remainingHealingOverDuration ~= 0 then
212
242
  buff:flashSpecialEffect()
213
243
  if remainingDamageOverDuration ~= 0 then
214
- (buff[101] or buff[100]):damageTarget(buff[100], remainingDamageOverDuration)
215
- buff[112] = nil
244
+ (buff[102] or buff[101]):damageTarget(buff[101], remainingDamageOverDuration)
245
+ buff[113] = nil
216
246
  end
217
247
  if remainingHealingOverDuration ~= 0 then
218
- (buff[101] or buff[100]):healTarget(buff[100], remainingHealingOverDuration)
219
- buff[117] = nil
248
+ (buff[102] or buff[101]):healTarget(buff[101], remainingHealingOverDuration)
249
+ buff[118] = nil
220
250
  end
221
251
  end
222
252
  Timer:run(destroyBuff, buff)
@@ -224,56 +254,57 @@ local function expireBuff(buff)
224
254
  end
225
255
  local function buffDamageIntervalInitialTimerCallback(buff)
226
256
  buffDamageIntervalTimerCallback(buff)
227
- local timer = buff[113]
228
- local damageInterval = buff[111]
257
+ local timer = buff[114]
258
+ local damageInterval = buff[112]
229
259
  if timer ~= nil and damageInterval ~= nil and damageInterval > 0 then
230
260
  timer:start(damageInterval, true, buffDamageIntervalTimerCallback, buff)
231
261
  end
232
262
  end
233
263
  buffDamageIntervalTimerCallback = function(buff)
234
264
  buff:flashSpecialEffect()
235
- local source = buff[101] or buff[100]
236
- local remainingDamageOverDuration = buff[112] or 0
265
+ local source = buff[102] or buff[101]
266
+ local remainingDamageOverDuration = buff[113] or 0
237
267
  if remainingDamageOverDuration ~= 0 then
238
- local damageInterval = buff[111] or 0
268
+ local damageInterval = buff[112] or 0
239
269
  if damageInterval ~= 0 then
240
270
  local damage = remainingDamageOverDuration / (1 + buff.remainingDuration / damageInterval)
241
- source:damageTarget(buff[100], damage)
242
- buff[112] = remainingDamageOverDuration - damage
271
+ source:damageTarget(buff[101], damage)
272
+ buff[113] = remainingDamageOverDuration - damage
243
273
  end
244
274
  end
245
- local damagePerInterval = buff[110] or 0
275
+ local damagePerInterval = buff[111] or 0
246
276
  if remainingDamageOverDuration == 0 or damagePerInterval ~= 0 then
247
- source:damageTarget(buff[100], damagePerInterval)
277
+ source:damageTarget(buff[101], damagePerInterval)
248
278
  end
249
279
  end
250
280
  local function buffHealingIntervalInitialTimerCallback(buff)
251
281
  buffHealingIntervalTimerCallback(buff)
252
- local timer = buff[118]
253
- local healingInterval = buff[116]
282
+ local timer = buff[119]
283
+ local healingInterval = buff[117]
254
284
  if timer ~= nil and healingInterval ~= nil and healingInterval > 0 then
255
285
  timer:start(healingInterval, true, buffHealingIntervalTimerCallback, buff)
256
286
  end
257
287
  end
258
288
  buffHealingIntervalTimerCallback = function(buff)
259
- if buff[116] ~= buff[111] then
289
+ if buff[117] ~= buff[112] then
260
290
  buff:flashSpecialEffect()
261
291
  end
262
- local source = buff[101] or buff[100]
263
- local remainingHealingOverDuration = buff[117] or 0
292
+ local source = buff[102] or buff[101]
293
+ local remainingHealingOverDuration = buff[118] or 0
264
294
  if remainingHealingOverDuration ~= 0 then
265
- local healingInterval = buff[116] or 0
295
+ local healingInterval = buff[117] or 0
266
296
  if healingInterval ~= 0 then
267
297
  local healing = remainingHealingOverDuration / (1 + buff.remainingDuration / healingInterval)
268
- source:healTarget(buff[100], healing)
269
- buff[117] = remainingHealingOverDuration - healing
298
+ source:healTarget(buff[101], healing)
299
+ buff[118] = remainingHealingOverDuration - healing
270
300
  end
271
301
  end
272
- local healingPerInterval = buff[115] or 0
302
+ local healingPerInterval = buff[116] or 0
273
303
  if remainingHealingOverDuration == 0 or healingPerInterval ~= 0 then
274
- source:healTarget(buff[100], healingPerInterval)
304
+ source:healTarget(buff[101], healingPerInterval)
275
305
  end
276
306
  end
307
+ local buffDestroyEvent = __TS__New(Event)
277
308
  ____exports.Buff = __TS__Class()
278
309
  local Buff = ____exports.Buff
279
310
  Buff.name = "Buff"
@@ -282,7 +313,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
282
313
  UnitBehavior.prototype.____constructor(self, _unit)
283
314
  self._unit = _unit
284
315
  self.parameters = nil
285
- self[100] = _unit
316
+ self[100] = 0
317
+ self[101] = _unit
286
318
  local typeId
287
319
  local polarity
288
320
  local resistanceType
@@ -291,7 +323,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
291
323
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
292
324
  polarity = resistanceTypeOrPolarity
293
325
  resistanceType = abilityOrParametersOrResistanceType
294
- if __TS__InstanceOf(parametersOrAbility, Ability) then
326
+ if __TS__InstanceOf(parametersOrAbility, Ability) or parametersOrAbility == nil then
295
327
  ability = parametersOrAbility
296
328
  else
297
329
  ability = nil
@@ -301,7 +333,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
301
333
  typeId = typeIdOrTypeIds
302
334
  polarity = polarityOrTypeIdSelectionPolicy
303
335
  resistanceType = resistanceTypeOrPolarity
304
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
336
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) or abilityOrParametersOrResistanceType == nil then
305
337
  ability = abilityOrParametersOrResistanceType
306
338
  parameters = parametersOrAbility
307
339
  else
@@ -310,9 +342,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
310
342
  end
311
343
  end
312
344
  self.typeId = typeId
313
- self.polarity = polarity
314
- self.resistanceType = resistanceType
315
- if not __TS__InstanceOf(ability, Ability) then
345
+ if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
316
346
  parameters = ability
317
347
  ability = nil
318
348
  end
@@ -338,14 +368,21 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
338
368
  learnLevelMinimum = learnLevelMinimum or ability:getField(ABILITY_IF_REQUIRED_LEVEL)
339
369
  duration = duration or getAbilityDuration(ability, _unit)
340
370
  end
371
+ self.polarity = resolveEnumValue(ability, level, polarity)
372
+ self.resistanceType = resolveEnumValue(ability, level, resistanceType)
373
+ local missProbability = parameters and parameters.missProbability or defaultParameters.missProbability
374
+ if missProbability ~= nil then
375
+ missProbability = resolveNumberValue(ability, level, missProbability)
376
+ self[142] = missProbability
377
+ end
341
378
  local buffByTypeId = buffByTypeIdByUnit[_unit]
342
379
  if buffByTypeId == nil then
343
380
  buffByTypeId = {}
344
381
  buffByTypeIdByUnit[_unit] = buffByTypeId
345
382
  end
346
- local ____opt_13 = buffByTypeId[typeId]
347
- if ____opt_13 ~= nil then
348
- ____opt_13:destroy()
383
+ local ____opt_15 = buffByTypeId[typeId]
384
+ if ____opt_15 ~= nil then
385
+ ____opt_15:destroy()
349
386
  end
350
387
  local uniqueGroup = parameters and parameters.uniqueGroup or defaultParameters and defaultParameters.uniqueGroup
351
388
  if uniqueGroup ~= nil then
@@ -354,18 +391,21 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
354
391
  if not internalApplyBuff(
355
392
  _unit,
356
393
  typeId,
357
- polarity,
358
- resistanceType,
394
+ self.polarity,
395
+ self.resistanceType,
359
396
  level,
360
397
  duration,
361
398
  spellStealPriority,
362
- learnLevelMinimum
399
+ learnLevelMinimum,
400
+ missProbability
363
401
  ) then
402
+ self[100] = 1
364
403
  UnitBehavior.prototype.destroy(self)
365
404
  error(unsuccessfulApplicationMarker, 0)
366
405
  end
367
406
  local handle = BlzGetUnitAbility(_unit.handle, typeId)
368
407
  if handle == nil then
408
+ self[100] = 1
369
409
  UnitBehavior.prototype.destroy(self)
370
410
  error(unsuccessfulApplicationMarker, 0)
371
411
  end
@@ -374,20 +414,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
374
414
  self._level = level
375
415
  self._spellStealPriority = spellStealPriority
376
416
  self._learnLevelMinimum = learnLevelMinimum
377
- self[101] = source
378
- self[102] = duration or 0
379
- self[103] = uniqueGroup
380
- self[104] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
381
- self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
417
+ self[102] = source
418
+ self[103] = duration or 0
419
+ self[104] = uniqueGroup
420
+ self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
421
+ self[106] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
382
422
  if parameters ~= nil or (next(defaultParameters)) ~= nil then
383
423
  for ____, buffBooleanParameter in ipairs(buffBooleanParameters) do
384
- local ____ability_22 = ability
385
- local ____level_23 = level
386
- local ____temp_21 = parameters and parameters[buffBooleanParameter]
387
- if ____temp_21 == nil then
388
- ____temp_21 = defaultParameters[buffBooleanParameter]
424
+ local ____ability_24 = ability
425
+ local ____level_25 = level
426
+ local ____temp_23 = parameters and parameters[buffBooleanParameter]
427
+ if ____temp_23 == nil then
428
+ ____temp_23 = defaultParameters[buffBooleanParameter]
389
429
  end
390
- if resolveBooleanValue(____ability_22, ____level_23, ____temp_21) then
430
+ if resolveBooleanValue(____ability_24, ____level_25, ____temp_23) then
391
431
  self[buffBooleanParameter] = true
392
432
  end
393
433
  end
@@ -403,11 +443,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
403
443
  end
404
444
  local maximumDuration = parameters and parameters.maximumDuration or defaultParameters.maximumDuration
405
445
  if maximumDuration ~= nil then
406
- self[107] = resolveNumberValue(ability, level, maximumDuration)
446
+ self[108] = resolveNumberValue(ability, level, maximumDuration)
407
447
  end
408
448
  local maximumRemainingDuration = parameters and parameters.maximumRemainingDuration or defaultParameters.maximumRemainingDuration
409
449
  if maximumRemainingDuration ~= nil then
410
- self[108] = resolveNumberValue(ability, level, maximumRemainingDuration)
450
+ self[109] = resolveNumberValue(ability, level, maximumRemainingDuration)
411
451
  end
412
452
  local parametersAbilityTypeIds = parameters and parameters.abilityTypeIds or defaultParameters.abilityTypeIds
413
453
  if parametersAbilityTypeIds ~= nil then
@@ -464,10 +504,12 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
464
504
  timer:start(duration, false, expireBuff, self)
465
505
  self._timer = timer
466
506
  end
507
+ self:onCreate()
508
+ self[100] = 1
467
509
  end
468
510
  function Buff.prototype.getUnitBonus(self, bonusType)
469
- local ____opt_36 = self._bonusIdByBonusType
470
- local bonusId = ____opt_36 and ____opt_36[bonusType]
511
+ local ____opt_38 = self._bonusIdByBonusType
512
+ local bonusId = ____opt_38 and ____opt_38[bonusType]
471
513
  return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
472
514
  end
473
515
  function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
@@ -478,63 +520,71 @@ function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
478
520
  end
479
521
  bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
480
522
  end
481
- function Buff.prototype.flashEffect(self, widgetOrDuration, duration)
482
- local isWidgetProvided = type(widgetOrDuration) == "table"
483
- local ____Effect_40 = Effect
484
- local ____Effect_flash_41 = Effect.flash
485
- local ____array_39 = __TS__SparseArrayNew(
486
- self[104],
487
- isWidgetProvided and widgetOrDuration or self._unit,
488
- stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
489
- )
490
- local ____isWidgetProvided_38
491
- if isWidgetProvided then
492
- ____isWidgetProvided_38 = duration
523
+ function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
524
+ if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
525
+ Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
493
526
  else
494
- ____isWidgetProvided_38 = widgetOrDuration
527
+ local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
528
+ local ____Effect_42 = Effect
529
+ local ____Effect_flash_43 = Effect.flash
530
+ local ____array_41 = __TS__SparseArrayNew(
531
+ self[105],
532
+ isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
533
+ stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
534
+ )
535
+ local ____isWidgetProvided_40
536
+ if isWidgetProvided then
537
+ ____isWidgetProvided_40 = yOrParametersOrDuration
538
+ else
539
+ ____isWidgetProvided_40 = widgetOrXOrParametersOrDuration
540
+ end
541
+ __TS__SparseArrayPush(____array_41, ____isWidgetProvided_40)
542
+ ____Effect_flash_43(
543
+ ____Effect_42,
544
+ __TS__SparseArraySpread(____array_41)
545
+ )
495
546
  end
496
- __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
497
- ____Effect_flash_41(
498
- ____Effect_40,
499
- __TS__SparseArraySpread(____array_39)
500
- )
501
547
  end
502
548
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
503
549
  local isWidgetProvided = type(widgetOrDuration) == "table"
504
- local ____Effect_44 = Effect
505
- local ____Effect_flash_45 = Effect.flash
506
- local ____array_43 = __TS__SparseArrayNew(
507
- self[105],
550
+ local ____Effect_46 = Effect
551
+ local ____Effect_flash_47 = Effect.flash
552
+ local ____array_45 = __TS__SparseArrayNew(
553
+ self[106],
508
554
  isWidgetProvided and widgetOrDuration or self._unit,
509
555
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
510
556
  )
511
- local ____isWidgetProvided_42
557
+ local ____isWidgetProvided_44
512
558
  if isWidgetProvided then
513
- ____isWidgetProvided_42 = duration
559
+ ____isWidgetProvided_44 = duration
514
560
  else
515
- ____isWidgetProvided_42 = widgetOrDuration
561
+ ____isWidgetProvided_44 = widgetOrDuration
516
562
  end
517
- __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
518
- ____Effect_flash_45(
519
- ____Effect_44,
520
- __TS__SparseArraySpread(____array_43)
563
+ __TS__SparseArrayPush(____array_45, ____isWidgetProvided_44)
564
+ ____Effect_flash_47(
565
+ ____Effect_46,
566
+ __TS__SparseArraySpread(____array_45)
521
567
  )
522
568
  end
569
+ function Buff.prototype.onCreate(self)
570
+ end
523
571
  function Buff.prototype.onDestroy(self)
572
+ check(self[100] ~= 0, "Cannot destroy a buff that has not finished creating yet.")
573
+ self[100] = 2
524
574
  local unit = self._unit
525
575
  if getUnitAbility(unit.handle, self.typeId) == self.handle then
526
576
  removeBuff(unit.handle, self.typeId)
527
577
  end
528
578
  buffByTypeIdByUnit[unit][self.typeId] = nil
529
- local healingIntervalTimer = self[118]
579
+ local healingIntervalTimer = self[119]
530
580
  if healingIntervalTimer ~= nil then
531
581
  healingIntervalTimer:destroy()
532
- self[118] = nil
582
+ self[119] = nil
533
583
  end
534
- local damageIntervalTimer = self[113]
584
+ local damageIntervalTimer = self[114]
535
585
  if damageIntervalTimer ~= nil then
536
586
  damageIntervalTimer:destroy()
537
- self[113] = nil
587
+ self[114] = nil
538
588
  end
539
589
  if self._timer ~= nil then
540
590
  self._timer:destroy()
@@ -544,11 +594,11 @@ function Buff.prototype.onDestroy(self)
544
594
  behavior:destroy()
545
595
  end
546
596
  end
547
- if self[132] then
597
+ if self[138] then
548
598
  unit:decrementDisableAutoAttackCounter()
549
599
  end
550
- if self[130] then
551
- if self[131] then
600
+ if self[136] then
601
+ if self[137] then
552
602
  unit:decrementStunCounter()
553
603
  end
554
604
  unit:decrementStunCounter()
@@ -563,6 +613,8 @@ function Buff.prototype.onDestroy(self)
563
613
  removeUnitBonus(unit, bonusType, bonusId)
564
614
  end
565
615
  end
616
+ Event.invoke(buffDestroyEvent, self)
617
+ self[100] = 3
566
618
  return UnitBehavior.prototype.onDestroy(self)
567
619
  end
568
620
  function Buff.apply(self, ...)
@@ -590,8 +642,8 @@ function Buff.apply(self, ...)
590
642
  end
591
643
  end
592
644
  function Buff.getByTypeId(self, unit, typeId)
593
- local ____opt_46 = buffByTypeIdByUnit[unit]
594
- local buff = ____opt_46 and ____opt_46[typeId]
645
+ local ____opt_48 = buffByTypeIdByUnit[unit]
646
+ local buff = ____opt_48 and ____opt_48[typeId]
595
647
  if __TS__InstanceOf(buff, self) then
596
648
  return buff
597
649
  end
@@ -599,56 +651,72 @@ function Buff.getByTypeId(self, unit, typeId)
599
651
  end
600
652
  function Buff.prototype.onExpiration(self)
601
653
  local unit = self.unit
602
- if self[119] ~= nil then
603
- (self[101] or unit):damageTarget(unit, self[119] or 0)
604
- end
605
654
  if self[120] ~= nil then
606
- (self[101] or unit):healTarget(unit, self[119] or 0)
655
+ (self[102] or unit):damageTarget(unit, self[120] or 0)
607
656
  end
608
- if self[135] then
657
+ if self[121] ~= nil then
658
+ (self[102] or unit):healTarget(unit, self[120] or 0)
659
+ end
660
+ if self[141] then
609
661
  unit:explode()
610
- elseif self[134] then
662
+ elseif self[140] then
611
663
  unit:kill()
612
664
  end
613
665
  end
614
666
  function Buff.prototype.onDeath(self, source)
615
667
  local unit = self.unit
616
- if self[121] ~= nil then
668
+ if self[122] ~= nil then
617
669
  damageArea(
618
- self[101] or unit,
619
- self[121],
670
+ self[102] or unit,
671
+ self[122],
620
672
  unit.x,
621
673
  unit.y,
674
+ self[124] or 0,
622
675
  self[123] or 0,
623
- self[122] or 0,
676
+ self[126] or 0,
624
677
  self[125] or 0,
625
- self[124] or 0,
626
- self[127] or 0,
627
- self[126] or 0
678
+ self[128] or 0,
679
+ self[127] or 0
628
680
  )
629
681
  end
630
682
  end
631
683
  function Buff.prototype.onDamageDealt(self, target, event)
632
684
  if event.isAttack then
633
- if self[106] ~= nil then
634
- local durationIncrease = self[106]
635
- local maximumDuration = self[107] or 0
685
+ if self[107] ~= nil then
686
+ local durationIncrease = self[107]
687
+ local maximumDuration = self[108] or 0
636
688
  if maximumDuration > 0 then
637
689
  durationIncrease = min(
638
690
  durationIncrease,
639
- max(0, maximumDuration - self[102])
691
+ max(0, maximumDuration - self[103])
640
692
  )
641
693
  end
642
694
  local remainingDuration = self.remainingDuration + durationIncrease
643
- local maximumRemainingDuration = self[108] or 0
695
+ local maximumRemainingDuration = self[109] or 0
644
696
  if maximumRemainingDuration > 0 then
645
697
  remainingDuration = min(remainingDuration, maximumRemainingDuration)
646
698
  end
647
699
  self.remainingDuration = remainingDuration
648
700
  end
649
- local autoAttackCount = (self[128] or 0) + 1
650
- self[128] = autoAttackCount
651
- if autoAttackCount == self[129] then
701
+ local autoAttackCount = (self[129] or 0) + 1
702
+ self[129] = autoAttackCount
703
+ if autoAttackCount == self[130] then
704
+ self:destroy()
705
+ end
706
+ end
707
+ if event.originalAmount ~= 0 then
708
+ local damageDealtEventCount = (self[131] or 0) + 1
709
+ self[131] = damageDealtEventCount
710
+ if damageDealtEventCount == self[132] then
711
+ self:destroy()
712
+ end
713
+ end
714
+ end
715
+ function Buff.prototype.onDamageReceived(self, source, event)
716
+ if event.originalAmount ~= 0 then
717
+ local damageReceivedEventCount = (self[133] or 0) + 1
718
+ self[133] = damageReceivedEventCount
719
+ if damageReceivedEventCount == self[134] then
652
720
  self:destroy()
653
721
  end
654
722
  end
@@ -658,7 +726,7 @@ __TS__SetDescriptor(
658
726
  Buff.prototype,
659
727
  "source",
660
728
  {get = function(self)
661
- return self[101] or self._unit
729
+ return self[102] or self._unit
662
730
  end},
663
731
  true
664
732
  )
@@ -675,13 +743,13 @@ __TS__SetDescriptor(
675
743
  "remainingDamageOverDuration",
676
744
  {
677
745
  get = function(self)
678
- return self[112] or 0
746
+ return self[113] or 0
679
747
  end,
680
748
  set = function(self, remainingDamageOverDuration)
681
- local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[112] or 0)
682
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
683
- local damageOverDuration = (self[109] or 0) + remainingDamageOverDurationDelta
684
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
749
+ local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[113] or 0)
750
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
751
+ local damageOverDuration = (self[110] or 0) + remainingDamageOverDurationDelta
752
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
685
753
  end
686
754
  },
687
755
  true
@@ -691,13 +759,13 @@ __TS__SetDescriptor(
691
759
  "damageOverDuration",
692
760
  {
693
761
  get = function(self)
694
- return self[109] or 0
762
+ return self[110] or 0
695
763
  end,
696
764
  set = function(self, damageOverDuration)
697
- local damageOverDurationDelta = damageOverDuration - (self[109] or 0)
698
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
699
- local remainingDamageOverDuration = (self[112] or 0) + damageOverDurationDelta
700
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
765
+ local damageOverDurationDelta = damageOverDuration - (self[110] or 0)
766
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
767
+ local remainingDamageOverDuration = (self[113] or 0) + damageOverDurationDelta
768
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
701
769
  end
702
770
  },
703
771
  true
@@ -707,10 +775,10 @@ __TS__SetDescriptor(
707
775
  "damagePerInterval",
708
776
  {
709
777
  get = function(self)
710
- return self[110] or 0
778
+ return self[111] or 0
711
779
  end,
712
780
  set = function(self, damagePerInterval)
713
- self[110] = damagePerInterval ~= 0 and damagePerInterval or nil
781
+ self[111] = damagePerInterval ~= 0 and damagePerInterval or nil
714
782
  end
715
783
  },
716
784
  true
@@ -720,25 +788,25 @@ __TS__SetDescriptor(
720
788
  "damageInterval",
721
789
  {
722
790
  get = function(self)
723
- return self[111] or 0
791
+ return self[112] or 0
724
792
  end,
725
793
  set = function(self, damageInterval)
726
794
  if damageInterval <= 0 then
727
- self[111] = damageInterval ~= 0 and damageInterval or nil
728
- local timer = self[113]
795
+ self[112] = damageInterval ~= 0 and damageInterval or nil
796
+ local timer = self[114]
729
797
  if timer ~= nil then
730
798
  timer:destroy()
731
- self[113] = nil
799
+ self[114] = nil
732
800
  end
733
801
  return
734
802
  end
735
- self[111] = damageInterval
736
- local ____opt_48 = self._timer
737
- local elapsed = ____opt_48 and ____opt_48.elapsed or 0
738
- local timer = self[113]
803
+ self[112] = damageInterval
804
+ local ____opt_50 = self._timer
805
+ local elapsed = ____opt_50 and ____opt_50.elapsed or 0
806
+ local timer = self[114]
739
807
  if timer == nil then
740
808
  timer = Timer:create()
741
- self[113] = timer
809
+ self[114] = timer
742
810
  end
743
811
  local initialDelay = damageInterval - (elapsed >= damageInterval and math.fmod(elapsed, damageInterval) or elapsed)
744
812
  if initialDelay == damageInterval then
@@ -755,13 +823,13 @@ __TS__SetDescriptor(
755
823
  "remainingHealingOverDuration",
756
824
  {
757
825
  get = function(self)
758
- return self[117] or 0
826
+ return self[118] or 0
759
827
  end,
760
828
  set = function(self, remainingHealingOverDuration)
761
- local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[117] or 0)
762
- self[112] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
763
- local healingOverDuration = (self[114] or 0) + remainingHealingOverDurationDelta
764
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
829
+ local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[118] or 0)
830
+ self[113] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
831
+ local healingOverDuration = (self[115] or 0) + remainingHealingOverDurationDelta
832
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
765
833
  end
766
834
  },
767
835
  true
@@ -771,13 +839,13 @@ __TS__SetDescriptor(
771
839
  "healingOverDuration",
772
840
  {
773
841
  get = function(self)
774
- return self[114] or 0
842
+ return self[115] or 0
775
843
  end,
776
844
  set = function(self, healingOverDuration)
777
- local healingOverDurationDelta = healingOverDuration - (self[114] or 0)
778
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
779
- local remainingHealingOverDuration = (self[117] or 0) + healingOverDurationDelta
780
- self[117] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
845
+ local healingOverDurationDelta = healingOverDuration - (self[115] or 0)
846
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
847
+ local remainingHealingOverDuration = (self[118] or 0) + healingOverDurationDelta
848
+ self[118] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
781
849
  end
782
850
  },
783
851
  true
@@ -787,10 +855,10 @@ __TS__SetDescriptor(
787
855
  "healingPerInterval",
788
856
  {
789
857
  get = function(self)
790
- return self[115] or 0
858
+ return self[116] or 0
791
859
  end,
792
860
  set = function(self, healingPerInterval)
793
- self[115] = healingPerInterval ~= 0 and healingPerInterval or nil
861
+ self[116] = healingPerInterval ~= 0 and healingPerInterval or nil
794
862
  end
795
863
  },
796
864
  true
@@ -800,25 +868,25 @@ __TS__SetDescriptor(
800
868
  "healingInterval",
801
869
  {
802
870
  get = function(self)
803
- return self[116] or 0
871
+ return self[117] or 0
804
872
  end,
805
873
  set = function(self, healingInterval)
806
874
  if healingInterval <= 0 then
807
- self[116] = healingInterval ~= 0 and healingInterval or nil
808
- local timer = self[118]
875
+ self[117] = healingInterval ~= 0 and healingInterval or nil
876
+ local timer = self[119]
809
877
  if timer ~= nil then
810
878
  timer:destroy()
811
- self[118] = nil
879
+ self[119] = nil
812
880
  end
813
881
  return
814
882
  end
815
- self[116] = healingInterval
816
- local ____opt_50 = self._timer
817
- local elapsed = ____opt_50 and ____opt_50.elapsed or 0
818
- local timer = self[118]
883
+ self[117] = healingInterval
884
+ local ____opt_52 = self._timer
885
+ local elapsed = ____opt_52 and ____opt_52.elapsed or 0
886
+ local timer = self[119]
819
887
  if timer == nil then
820
888
  timer = Timer:create()
821
- self[118] = timer
889
+ self[119] = timer
822
890
  end
823
891
  local initialDelay = healingInterval - (elapsed >= healingInterval and math.fmod(elapsed, healingInterval) or elapsed)
824
892
  if initialDelay == healingInterval then
@@ -835,10 +903,10 @@ __TS__SetDescriptor(
835
903
  "damageOnExpiration",
836
904
  {
837
905
  get = function(self)
838
- return self[119] or 0
906
+ return self[120] or 0
839
907
  end,
840
908
  set = function(self, damageOnExpiration)
841
- self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
909
+ self[120] = damageOnExpiration ~= 0 and damageOnExpiration or nil
842
910
  end
843
911
  },
844
912
  true
@@ -848,10 +916,23 @@ __TS__SetDescriptor(
848
916
  "healingOnExpiration",
849
917
  {
850
918
  get = function(self)
851
- return self[120] or 0
919
+ return self[121] or 0
852
920
  end,
853
921
  set = function(self, healingOnExpiration)
854
- self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
922
+ self[121] = healingOnExpiration ~= 0 and healingOnExpiration or nil
923
+ end
924
+ },
925
+ true
926
+ )
927
+ __TS__SetDescriptor(
928
+ Buff.prototype,
929
+ "damageFactor",
930
+ {
931
+ get = function(self)
932
+ return self:getUnitBonus(UnitBonusType.DAMAGE_FACTOR)
933
+ end,
934
+ set = function(self, damageFactor)
935
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.DAMAGE_FACTOR, damageFactor)
855
936
  end
856
937
  },
857
938
  true
@@ -882,30 +963,53 @@ __TS__SetDescriptor(
882
963
  },
883
964
  true
884
965
  )
966
+ __TS__SetDescriptor(
967
+ Buff.prototype,
968
+ "turnsIntoGhost",
969
+ {
970
+ get = function(self)
971
+ local ____self__135_54 = self[135]
972
+ if ____self__135_54 == nil then
973
+ ____self__135_54 = false
974
+ end
975
+ return ____self__135_54
976
+ end,
977
+ set = function(self, turnsIntoGhost)
978
+ if not turnsIntoGhost and self[135] then
979
+ self.object:decrementGhostCounter()
980
+ self[135] = nil
981
+ elseif turnsIntoGhost and not self[135] then
982
+ self.object:incrementGhostCounter()
983
+ self[135] = true
984
+ end
985
+ end
986
+ },
987
+ true
988
+ )
885
989
  __TS__SetDescriptor(
886
990
  Buff.prototype,
887
991
  "stuns",
888
992
  {
889
993
  get = function(self)
890
- local ____self__130_52 = self[130]
891
- if ____self__130_52 == nil then
892
- ____self__130_52 = false
994
+ local ____self__136_55 = self[136]
995
+ if ____self__136_55 == nil then
996
+ ____self__136_55 = false
893
997
  end
894
- return ____self__130_52
998
+ return ____self__136_55
895
999
  end,
896
1000
  set = function(self, stuns)
897
- if not stuns and self[130] then
898
- if self[131] then
1001
+ if not stuns and self[136] then
1002
+ if self[137] then
899
1003
  self.object:decrementStunCounter()
900
1004
  end
901
1005
  self.object:decrementStunCounter()
902
- self[130] = nil
903
- elseif stuns and not self[130] then
904
- if self[131] then
1006
+ self[136] = nil
1007
+ elseif stuns and not self[136] then
1008
+ if self[137] then
905
1009
  self.object:incrementStunCounter()
906
1010
  end
907
1011
  self.object:incrementStunCounter()
908
- self[130] = true
1012
+ self[136] = true
909
1013
  end
910
1014
  end
911
1015
  },
@@ -916,23 +1020,23 @@ __TS__SetDescriptor(
916
1020
  "ignoresStunImmunity",
917
1021
  {
918
1022
  get = function(self)
919
- local ____self__131_53 = self[131]
920
- if ____self__131_53 == nil then
921
- ____self__131_53 = false
1023
+ local ____self__137_56 = self[137]
1024
+ if ____self__137_56 == nil then
1025
+ ____self__137_56 = false
922
1026
  end
923
- return ____self__131_53
1027
+ return ____self__137_56
924
1028
  end,
925
1029
  set = function(self, ignoresStunImmunity)
926
- if not ignoresStunImmunity and self[131] then
927
- if self[130] then
1030
+ if not ignoresStunImmunity and self[137] then
1031
+ if self[136] then
928
1032
  self.object:decrementStunCounter()
929
1033
  end
930
- self[131] = nil
931
- elseif ignoresStunImmunity and not self[131] then
932
- if self[130] then
1034
+ self[137] = nil
1035
+ elseif ignoresStunImmunity and not self[137] then
1036
+ if self[136] then
933
1037
  self.object:incrementStunCounter()
934
1038
  end
935
- self[131] = true
1039
+ self[137] = true
936
1040
  end
937
1041
  end
938
1042
  },
@@ -943,19 +1047,19 @@ __TS__SetDescriptor(
943
1047
  "disablesAutoAttack",
944
1048
  {
945
1049
  get = function(self)
946
- local ____self__132_54 = self[132]
947
- if ____self__132_54 == nil then
948
- ____self__132_54 = false
1050
+ local ____self__138_57 = self[138]
1051
+ if ____self__138_57 == nil then
1052
+ ____self__138_57 = false
949
1053
  end
950
- return ____self__132_54
1054
+ return ____self__138_57
951
1055
  end,
952
1056
  set = function(self, disablesAutoAttack)
953
- if not disablesAutoAttack and self[132] then
1057
+ if not disablesAutoAttack and self[138] then
954
1058
  self.object:decrementDisableAutoAttackCounter()
955
- self[132] = nil
956
- elseif disablesAutoAttack and not self[132] then
1059
+ self[138] = nil
1060
+ elseif disablesAutoAttack and not self[138] then
957
1061
  self.object:incrementDisableAutoAttackCounter()
958
- self[132] = true
1062
+ self[138] = true
959
1063
  end
960
1064
  end
961
1065
  },
@@ -966,19 +1070,19 @@ __TS__SetDescriptor(
966
1070
  "providesInvulnerability",
967
1071
  {
968
1072
  get = function(self)
969
- local ____self__133_55 = self[133]
970
- if ____self__133_55 == nil then
971
- ____self__133_55 = false
1073
+ local ____self__139_58 = self[139]
1074
+ if ____self__139_58 == nil then
1075
+ ____self__139_58 = false
972
1076
  end
973
- return ____self__133_55
1077
+ return ____self__139_58
974
1078
  end,
975
1079
  set = function(self, providesInvulnerability)
976
- if not providesInvulnerability and self[133] then
1080
+ if not providesInvulnerability and self[139] then
977
1081
  self.object:decrementInvulnerabilityCounter()
978
- self[133] = nil
979
- elseif providesInvulnerability and not self[133] then
1082
+ self[139] = nil
1083
+ elseif providesInvulnerability and not self[139] then
980
1084
  self.object:incrementInvulnerabilityCounter()
981
- self[133] = true
1085
+ self[139] = true
982
1086
  end
983
1087
  end
984
1088
  },
@@ -989,17 +1093,17 @@ __TS__SetDescriptor(
989
1093
  "killsOnExpiration",
990
1094
  {
991
1095
  get = function(self)
992
- local ____self__134_56 = self[134]
993
- if ____self__134_56 == nil then
994
- ____self__134_56 = false
1096
+ local ____self__140_59 = self[140]
1097
+ if ____self__140_59 == nil then
1098
+ ____self__140_59 = false
995
1099
  end
996
- return ____self__134_56
1100
+ return ____self__140_59
997
1101
  end,
998
1102
  set = function(self, killsOnExpiration)
999
- if not killsOnExpiration and self[134] then
1000
- self[134] = nil
1001
- elseif killsOnExpiration and not self[134] then
1002
- self[134] = true
1103
+ if not killsOnExpiration and self[140] then
1104
+ self[140] = nil
1105
+ elseif killsOnExpiration and not self[140] then
1106
+ self[140] = true
1003
1107
  end
1004
1108
  end
1005
1109
  },
@@ -1010,17 +1114,51 @@ __TS__SetDescriptor(
1010
1114
  "explodesOnExpiration",
1011
1115
  {
1012
1116
  get = function(self)
1013
- local ____self__135_57 = self[135]
1014
- if ____self__135_57 == nil then
1015
- ____self__135_57 = false
1117
+ local ____self__141_60 = self[141]
1118
+ if ____self__141_60 == nil then
1119
+ ____self__141_60 = false
1016
1120
  end
1017
- return ____self__135_57
1121
+ return ____self__141_60
1018
1122
  end,
1019
1123
  set = function(self, killsOnExpiration)
1020
- if not killsOnExpiration and self[135] then
1021
- self[135] = nil
1022
- elseif killsOnExpiration and not self[135] then
1023
- self[135] = true
1124
+ if not killsOnExpiration and self[141] then
1125
+ self[141] = nil
1126
+ elseif killsOnExpiration and not self[141] then
1127
+ self[141] = true
1128
+ end
1129
+ end
1130
+ },
1131
+ true
1132
+ )
1133
+ __TS__SetDescriptor(
1134
+ Buff.prototype,
1135
+ "maximumDamageDealtEventCount",
1136
+ {
1137
+ get = function(self)
1138
+ return self[132] or 0
1139
+ end,
1140
+ set = function(self, maximumDamageDealtEventCount)
1141
+ if maximumDamageDealtEventCount == 0 then
1142
+ self[132] = nil
1143
+ else
1144
+ self[132] = maximumDamageDealtEventCount
1145
+ end
1146
+ end
1147
+ },
1148
+ true
1149
+ )
1150
+ __TS__SetDescriptor(
1151
+ Buff.prototype,
1152
+ "maximumDamageReceivedEventCount",
1153
+ {
1154
+ get = function(self)
1155
+ return self[134] or 0
1156
+ end,
1157
+ set = function(self, maximumDamageReceivedEventCount)
1158
+ if maximumDamageReceivedEventCount == 0 then
1159
+ self[134] = nil
1160
+ else
1161
+ self[134] = maximumDamageReceivedEventCount
1024
1162
  end
1025
1163
  end
1026
1164
  },
@@ -1031,13 +1169,13 @@ __TS__SetDescriptor(
1031
1169
  "maximumAutoAttackCount",
1032
1170
  {
1033
1171
  get = function(self)
1034
- return self[129] or 0
1172
+ return self[130] or 0
1035
1173
  end,
1036
1174
  set = function(self, maximumAutoAttackCount)
1037
1175
  if maximumAutoAttackCount == 0 then
1038
- self[129] = nil
1176
+ self[130] = nil
1039
1177
  else
1040
- self[129] = maximumAutoAttackCount
1178
+ self[130] = maximumAutoAttackCount
1041
1179
  end
1042
1180
  end
1043
1181
  },
@@ -1048,10 +1186,10 @@ __TS__SetDescriptor(
1048
1186
  "durationIncreaseOnAutoAttack",
1049
1187
  {
1050
1188
  get = function(self)
1051
- return self[106] or 0
1189
+ return self[107] or 0
1052
1190
  end,
1053
1191
  set = function(self, durationIncreaseOnAutoAttack)
1054
- self[106] = durationIncreaseOnAutoAttack
1192
+ self[107] = durationIncreaseOnAutoAttack
1055
1193
  end
1056
1194
  },
1057
1195
  true
@@ -1082,11 +1220,24 @@ __TS__SetDescriptor(
1082
1220
  },
1083
1221
  true
1084
1222
  )
1223
+ __TS__SetDescriptor(
1224
+ Buff.prototype,
1225
+ "evasionProbability",
1226
+ {
1227
+ get = function(self)
1228
+ return self:getUnitBonus(UnitBonusType.EVASION_PROBABILITY)
1229
+ end,
1230
+ set = function(self, evasionProbability)
1231
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.EVASION_PROBABILITY, evasionProbability)
1232
+ end
1233
+ },
1234
+ true
1235
+ )
1085
1236
  __TS__SetDescriptor(
1086
1237
  Buff.prototype,
1087
1238
  "duration",
1088
1239
  {get = function(self)
1089
- return self[102]
1240
+ return self[103]
1090
1241
  end},
1091
1242
  true
1092
1243
  )
@@ -1095,15 +1246,15 @@ __TS__SetDescriptor(
1095
1246
  "remainingDuration",
1096
1247
  {
1097
1248
  get = function(self)
1098
- local ____opt_58 = self._timer
1099
- return ____opt_58 and ____opt_58.remaining or 0
1249
+ local ____opt_61 = self._timer
1250
+ return ____opt_61 and ____opt_61.remaining or 0
1100
1251
  end,
1101
1252
  set = function(self, remainingDuration)
1102
- local ____remainingDuration_62 = remainingDuration
1103
- local ____opt_60 = self._timer
1104
- local remainingDurationDelta = ____remainingDuration_62 - (____opt_60 and ____opt_60.remaining or 0)
1253
+ local ____remainingDuration_65 = remainingDuration
1254
+ local ____opt_63 = self._timer
1255
+ local remainingDurationDelta = ____remainingDuration_65 - (____opt_63 and ____opt_63.remaining or 0)
1105
1256
  if remainingDurationDelta ~= 0 then
1106
- self[102] = self[102] + remainingDurationDelta
1257
+ self[103] = self[103] + remainingDurationDelta
1107
1258
  if remainingDuration <= 0 then
1108
1259
  Timer:run(destroyBuff, self)
1109
1260
  else
@@ -1115,7 +1266,8 @@ __TS__SetDescriptor(
1115
1266
  self._level,
1116
1267
  remainingDuration,
1117
1268
  self._spellStealPriority,
1118
- self._learnLevelMinimum
1269
+ self._learnLevelMinimum,
1270
+ self[142]
1119
1271
  ) then
1120
1272
  local timer = self._timer
1121
1273
  if timer == nil then
@@ -1129,10 +1281,11 @@ __TS__SetDescriptor(
1129
1281
  end
1130
1282
  },
1131
1283
  true
1132
- );
1284
+ )
1285
+ Buff.destroyEvent = buffDestroyEvent;
1133
1286
  (function(self)
1134
1287
  local function destroyBuffIfNeeded(buff)
1135
- if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1288
+ if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
1136
1289
  buff:destroy()
1137
1290
  end
1138
1291
  end