warscript 0.0.1-dev.29630c5 → 0.0.1-dev.2a08418

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 (176) hide show
  1. package/attributes.d.ts +6 -0
  2. package/attributes.lua +17 -1
  3. package/config.d.ts +5 -0
  4. package/config.lua +10 -0
  5. package/core/types/effect.d.ts +1 -3
  6. package/core/types/effect.lua +26 -29
  7. package/core/types/frame.lua +24 -21
  8. package/core/types/player.d.ts +16 -0
  9. package/core/types/player.lua +60 -15
  10. package/core/types/playerCamera.d.ts +2 -0
  11. package/core/types/playerCamera.lua +123 -5
  12. package/core/types/sound.d.ts +17 -24
  13. package/core/types/sound.lua +99 -24
  14. package/core/types/tileCell.d.ts +11 -1
  15. package/core/types/tileCell.lua +97 -0
  16. package/core/types/timer.d.ts +9 -8
  17. package/core/types/timer.lua +45 -23
  18. package/core/util.lua +6 -1
  19. package/decl/native.d.ts +846 -790
  20. package/engine/behavior.d.ts +12 -1
  21. package/engine/behavior.lua +172 -70
  22. package/engine/behaviour/ability/apply-buff.d.ts +5 -0
  23. package/engine/behaviour/ability/apply-buff.lua +32 -0
  24. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  25. package/engine/behaviour/ability/damage.d.ts +9 -3
  26. package/engine/behaviour/ability/damage.lua +26 -38
  27. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  28. package/engine/behaviour/ability/emulate-impact.lua +18 -3
  29. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  30. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  31. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  32. package/engine/behaviour/ability/restore-mana.lua +6 -6
  33. package/engine/behaviour/ability.d.ts +7 -3
  34. package/engine/behaviour/ability.lua +34 -26
  35. package/engine/behaviour/unit/stun-immunity.d.ts +11 -5
  36. package/engine/behaviour/unit/stun-immunity.lua +53 -28
  37. package/engine/behaviour/unit.d.ts +40 -2
  38. package/engine/behaviour/unit.lua +259 -6
  39. package/engine/buff.d.ts +63 -44
  40. package/engine/buff.lua +318 -225
  41. package/engine/internal/ability.d.ts +7 -1
  42. package/engine/internal/ability.lua +49 -9
  43. package/engine/internal/item/ability.lua +63 -11
  44. package/engine/internal/item+owner.lua +12 -6
  45. package/engine/internal/item.d.ts +20 -19
  46. package/engine/internal/item.lua +191 -74
  47. package/engine/internal/mechanics/ability-duration.lua +1 -1
  48. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  49. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  50. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  51. package/engine/internal/misc/frame-coordinates.lua +21 -0
  52. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  53. package/engine/internal/misc/get-terrain-z.lua +11 -0
  54. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  55. package/engine/internal/misc/player-local-handle.lua +5 -0
  56. package/engine/internal/unit/ability.d.ts +35 -0
  57. package/engine/internal/unit/ability.lua +98 -9
  58. package/engine/internal/unit/add-item-to-slot.lua +4 -2
  59. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  60. package/engine/internal/unit/allowed-targets.lua +9 -1
  61. package/engine/internal/unit/fly-height.d.ts +7 -0
  62. package/engine/internal/unit/fly-height.lua +20 -0
  63. package/engine/internal/unit/main-selected.lua +12 -27
  64. package/engine/internal/unit/order.d.ts +20 -0
  65. package/engine/internal/unit/order.lua +136 -0
  66. package/engine/internal/unit/scale.d.ts +7 -0
  67. package/engine/internal/unit/scale.lua +20 -0
  68. package/engine/internal/unit+ability.lua +10 -1
  69. package/engine/internal/unit+damage.d.ts +2 -11
  70. package/engine/internal/unit+damage.lua +10 -14
  71. package/engine/internal/unit+spellSteal.lua +1 -2
  72. package/engine/internal/unit-missile-launch.lua +45 -14
  73. package/engine/internal/unit.d.ts +42 -17
  74. package/engine/internal/unit.lua +331 -165
  75. package/engine/lightning.d.ts +4 -3
  76. package/engine/lightning.lua +21 -12
  77. package/engine/local-client.d.ts +2 -0
  78. package/engine/local-client.lua +30 -0
  79. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  80. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  81. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  82. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  83. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  84. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  85. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  86. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  87. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  88. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  89. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  90. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  91. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  92. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  93. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  94. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  95. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  96. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  97. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  98. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  99. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  100. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  101. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  102. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  103. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  104. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  105. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  106. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  107. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  108. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  109. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  110. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  111. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  112. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  113. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  114. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  115. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  116. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  117. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  118. package/engine/object-data/entry/ability-type/web.lua +52 -0
  119. package/engine/object-data/entry/ability-type.d.ts +19 -17
  120. package/engine/object-data/entry/ability-type.lua +85 -24
  121. package/engine/object-data/entry/buff-type/applicable.lua +18 -37
  122. package/engine/object-data/entry/buff-type.d.ts +6 -12
  123. package/engine/object-data/entry/buff-type.lua +13 -29
  124. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  125. package/engine/object-data/entry/item-type.d.ts +1 -1
  126. package/engine/object-data/entry/item-type.lua +4 -4
  127. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  128. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  129. package/engine/object-data/entry/sound-preset.lua +140 -0
  130. package/engine/object-data/entry/unit-type.d.ts +21 -5
  131. package/engine/object-data/entry/unit-type.lua +214 -93
  132. package/engine/object-data/entry/upgrade.d.ts +1 -1
  133. package/engine/object-data/entry/upgrade.lua +4 -4
  134. package/engine/object-data/entry.d.ts +16 -14
  135. package/engine/object-data/entry.lua +60 -32
  136. package/engine/object-field/ability.d.ts +4 -4
  137. package/engine/object-field/ability.lua +7 -6
  138. package/engine/object-field/unit.d.ts +69 -3
  139. package/engine/object-field/unit.lua +264 -7
  140. package/engine/object-field.d.ts +23 -6
  141. package/engine/object-field.lua +309 -126
  142. package/engine/random.d.ts +9 -0
  143. package/engine/random.lua +13 -0
  144. package/engine/standard/entries/buff-type.d.ts +3 -0
  145. package/engine/standard/entries/buff-type.lua +3 -0
  146. package/engine/standard/entries/sound-preset.d.ts +10 -0
  147. package/engine/standard/entries/sound-preset.lua +10 -0
  148. package/engine/standard/fields/unit.d.ts +6 -0
  149. package/engine/standard/fields/unit.lua +11 -0
  150. package/engine/synchronization.d.ts +11 -0
  151. package/engine/synchronization.lua +77 -0
  152. package/engine/text-tag.d.ts +36 -2
  153. package/engine/text-tag.lua +250 -10
  154. package/engine/unit.d.ts +3 -0
  155. package/engine/unit.lua +3 -0
  156. package/net/socket.lua +1 -1
  157. package/objutil/buff.lua +2 -3
  158. package/objutil/unit.lua +8 -0
  159. package/package.json +2 -2
  160. package/patch-lualib.lua +1 -1
  161. package/utility/arrays.d.ts +2 -0
  162. package/utility/arrays.lua +11 -0
  163. package/utility/callback-array.d.ts +17 -0
  164. package/utility/callback-array.lua +61 -0
  165. package/utility/functions.d.ts +8 -0
  166. package/utility/functions.lua +13 -0
  167. package/utility/linked-set.d.ts +2 -0
  168. package/utility/linked-set.lua +22 -1
  169. package/utility/lua-maps.d.ts +15 -2
  170. package/utility/lua-maps.lua +53 -2
  171. package/utility/lua-sets.d.ts +2 -0
  172. package/utility/lua-sets.lua +7 -0
  173. package/utility/reflection.lua +11 -7
  174. package/utility/types.d.ts +3 -0
  175. package/core/types/order.d.ts +0 -25
  176. package/core/types/order.lua +0 -55
package/engine/buff.lua CHANGED
@@ -16,6 +16,7 @@ local internalApplyBuff = ____applicable.internalApplyBuff
16
16
  local removeBuff = ____applicable.removeBuff
17
17
  local ____ability = require("engine.internal.ability")
18
18
  local Ability = ____ability.Ability
19
+ local UnitAbility = ____ability.UnitAbility
19
20
  local ____ability = require("engine.object-field.ability")
20
21
  local AbilityBooleanField = ____ability.AbilityBooleanField
21
22
  local AbilityNumberField = ____ability.AbilityNumberField
@@ -28,13 +29,11 @@ local ____math = require("math")
28
29
  local max = ____math.max
29
30
  local min = ____math.min
30
31
  local ____bonus = require("engine.internal.unit.bonus")
31
- local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
32
- local getUnitBonus = ____bonus.getUnitBonus
33
- local removeUnitBonus = ____bonus.removeUnitBonus
34
32
  local UnitBonusType = ____bonus.UnitBonusType
35
33
  local ____area_2Ddamage = require("engine.internal.mechanics.area-damage")
36
34
  local damageArea = ____area_2Ddamage.damageArea
37
35
  local ____preconditions = require("utility.preconditions")
36
+ local check = ____preconditions.check
38
37
  local checkNotNull = ____preconditions.checkNotNull
39
38
  local ____effect = require("core.types.effect")
40
39
  local Effect = ____effect.Effect
@@ -44,12 +43,16 @@ local ____unit = require("engine.behaviour.unit")
44
43
  local UnitBehavior = ____unit.UnitBehavior
45
44
  local ____arrays = require("utility.arrays")
46
45
  local forEach = ____arrays.forEach
46
+ local ____event = require("event")
47
+ local Event = ____event.Event
47
48
  local ____ability_2Dduration = require("engine.internal.mechanics.ability-duration")
48
49
  local getAbilityDuration = ____ability_2Dduration.getAbilityDuration
49
50
  local ____item = require("engine.internal.item")
50
51
  local Item = ____item.Item
51
52
  local ____destructable = require("core.types.destructable")
52
53
  local Destructable = ____destructable.Destructable
54
+ local ____ability = require("engine.standard.fields.ability")
55
+ local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
53
56
  local getUnitAbility = BlzGetUnitAbility
54
57
  local stringValueByBuffTypeIdByFieldId = postcompile(function()
55
58
  local stringValueByBuffTypeIdByFieldId = {}
@@ -99,12 +102,14 @@ local buffParametersKeys = {
99
102
  attackSpeedIncreaseFactor = true,
100
103
  movementSpeedIncreaseFactor = true,
101
104
  evasionProbability = true,
105
+ missProbability = true,
102
106
  damageFactor = true,
103
107
  receivedDamageFactor = true,
104
108
  receivedMagicDamageFactor = true,
105
109
  durationIncreaseOnAutoAttack = true,
106
110
  maximumDuration = true,
107
111
  maximumRemainingDuration = true,
112
+ turnsIntoGhost = true,
108
113
  stuns = true,
109
114
  ignoresStunImmunity = true,
110
115
  providesStunImmunity = true,
@@ -119,7 +124,8 @@ local buffParametersKeys = {
119
124
  damageOnExpiration = true,
120
125
  healingOnExpiration = true,
121
126
  killsOnExpiration = true,
122
- explodesOnExpiration = true
127
+ explodesOnExpiration = true,
128
+ abilityCooldownFactor = true
123
129
  }
124
130
  local function resolveEnumValue(ability, level, value)
125
131
  if value == nil or type(value) == "number" then
@@ -170,6 +176,7 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
170
176
  end
171
177
  end
172
178
  local buffBooleanParameters = {
179
+ "turnsIntoGhost",
173
180
  "stuns",
174
181
  "ignoresStunImmunity",
175
182
  "disablesAutoAttack",
@@ -195,7 +202,8 @@ local buffNumberParameters = {
195
202
  "healingPerInterval",
196
203
  "healingOverDuration",
197
204
  "damageOnExpiration",
198
- "healingOnExpiration"
205
+ "healingOnExpiration",
206
+ "abilityCooldownFactor"
199
207
  }
200
208
  local unsuccessfulApplicationMarker = {}
201
209
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -222,7 +230,7 @@ local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
222
230
  return checkNotNull(firstNativeBuffTypeId)
223
231
  end
224
232
  local function destroyBuffIfItHasSameUniqueGroup(buff, uniqueGroup)
225
- if buff[103] == uniqueGroup then
233
+ if buff[104] == uniqueGroup then
226
234
  buff:destroy()
227
235
  end
228
236
  end
@@ -230,17 +238,17 @@ local function destroyBuff(buff)
230
238
  buff:destroy()
231
239
  end
232
240
  local function expireBuff(buff)
233
- local remainingDamageOverDuration = buff[112] or 0
234
- local remainingHealingOverDuration = buff[112] or 0
241
+ local remainingDamageOverDuration = buff[113] or 0
242
+ local remainingHealingOverDuration = buff[113] or 0
235
243
  if remainingDamageOverDuration ~= 0 or remainingHealingOverDuration ~= 0 then
236
244
  buff:flashSpecialEffect()
237
245
  if remainingDamageOverDuration ~= 0 then
238
- (buff[101] or buff[100]):damageTarget(buff[100], remainingDamageOverDuration)
239
- buff[112] = nil
246
+ (buff[102] or buff[101]):damageTarget(buff[101], remainingDamageOverDuration)
247
+ buff[113] = nil
240
248
  end
241
249
  if remainingHealingOverDuration ~= 0 then
242
- (buff[101] or buff[100]):healTarget(buff[100], remainingHealingOverDuration)
243
- buff[117] = nil
250
+ (buff[102] or buff[101]):healTarget(buff[101], remainingHealingOverDuration)
251
+ buff[118] = nil
244
252
  end
245
253
  end
246
254
  Timer:run(destroyBuff, buff)
@@ -248,56 +256,58 @@ local function expireBuff(buff)
248
256
  end
249
257
  local function buffDamageIntervalInitialTimerCallback(buff)
250
258
  buffDamageIntervalTimerCallback(buff)
251
- local timer = buff[113]
252
- local damageInterval = buff[111]
259
+ local timer = buff[114]
260
+ local damageInterval = buff[112]
253
261
  if timer ~= nil and damageInterval ~= nil and damageInterval > 0 then
254
262
  timer:start(damageInterval, true, buffDamageIntervalTimerCallback, buff)
255
263
  end
256
264
  end
257
265
  buffDamageIntervalTimerCallback = function(buff)
258
266
  buff:flashSpecialEffect()
259
- local source = buff[101] or buff[100]
260
- local remainingDamageOverDuration = buff[112] or 0
267
+ local source = buff[102] or buff[101]
268
+ local remainingDamageOverDuration = buff[113] or 0
261
269
  if remainingDamageOverDuration ~= 0 then
262
- local damageInterval = buff[111] or 0
270
+ local damageInterval = buff[112] or 0
263
271
  if damageInterval ~= 0 then
264
272
  local damage = remainingDamageOverDuration / (1 + buff.remainingDuration / damageInterval)
265
- source:damageTarget(buff[100], damage)
266
- buff[112] = remainingDamageOverDuration - damage
273
+ source:damageTarget(buff[101], damage)
274
+ buff[113] = remainingDamageOverDuration - damage
267
275
  end
268
276
  end
269
- local damagePerInterval = buff[110] or 0
277
+ local damagePerInterval = buff[111] or 0
270
278
  if remainingDamageOverDuration == 0 or damagePerInterval ~= 0 then
271
- source:damageTarget(buff[100], damagePerInterval)
279
+ source:damageTarget(buff[101], damagePerInterval)
272
280
  end
273
281
  end
274
282
  local function buffHealingIntervalInitialTimerCallback(buff)
275
283
  buffHealingIntervalTimerCallback(buff)
276
- local timer = buff[118]
277
- local healingInterval = buff[116]
284
+ local timer = buff[119]
285
+ local healingInterval = buff[117]
278
286
  if timer ~= nil and healingInterval ~= nil and healingInterval > 0 then
279
287
  timer:start(healingInterval, true, buffHealingIntervalTimerCallback, buff)
280
288
  end
281
289
  end
282
290
  buffHealingIntervalTimerCallback = function(buff)
283
- if buff[116] ~= buff[111] then
291
+ if buff[117] ~= buff[112] then
284
292
  buff:flashSpecialEffect()
285
293
  end
286
- local source = buff[101] or buff[100]
287
- local remainingHealingOverDuration = buff[117] or 0
294
+ local source = buff[102] or buff[101]
295
+ local remainingHealingOverDuration = buff[118] or 0
288
296
  if remainingHealingOverDuration ~= 0 then
289
- local healingInterval = buff[116] or 0
297
+ local healingInterval = buff[117] or 0
290
298
  if healingInterval ~= 0 then
291
299
  local healing = remainingHealingOverDuration / (1 + buff.remainingDuration / healingInterval)
292
- source:healTarget(buff[100], healing)
293
- buff[117] = remainingHealingOverDuration - healing
300
+ source:healTarget(buff[101], healing)
301
+ buff[118] = remainingHealingOverDuration - healing
294
302
  end
295
303
  end
296
- local healingPerInterval = buff[115] or 0
304
+ local healingPerInterval = buff[116] or 0
297
305
  if remainingHealingOverDuration == 0 or healingPerInterval ~= 0 then
298
- source:healTarget(buff[100], healingPerInterval)
306
+ source:healTarget(buff[101], healingPerInterval)
299
307
  end
300
308
  end
309
+ local buffCreatedEvent = __TS__New(Event)
310
+ local buffBeingDestroyedEvent = __TS__New(Event)
301
311
  ____exports.Buff = __TS__Class()
302
312
  local Buff = ____exports.Buff
303
313
  Buff.name = "Buff"
@@ -306,7 +316,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
306
316
  UnitBehavior.prototype.____constructor(self, _unit)
307
317
  self._unit = _unit
308
318
  self.parameters = nil
309
- self[100] = _unit
319
+ self[100] = 0
320
+ self[101] = _unit
310
321
  local typeId
311
322
  local polarity
312
323
  local resistanceType
@@ -315,7 +326,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
315
326
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
316
327
  polarity = resistanceTypeOrPolarity
317
328
  resistanceType = abilityOrParametersOrResistanceType
318
- if __TS__InstanceOf(parametersOrAbility, Ability) then
329
+ if __TS__InstanceOf(parametersOrAbility, Ability) or parametersOrAbility == nil then
319
330
  ability = parametersOrAbility
320
331
  else
321
332
  ability = nil
@@ -325,7 +336,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
325
336
  typeId = typeIdOrTypeIds
326
337
  polarity = polarityOrTypeIdSelectionPolicy
327
338
  resistanceType = resistanceTypeOrPolarity
328
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
339
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) or abilityOrParametersOrResistanceType == nil then
329
340
  ability = abilityOrParametersOrResistanceType
330
341
  parameters = parametersOrAbility
331
342
  else
@@ -334,7 +345,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
334
345
  end
335
346
  end
336
347
  self.typeId = typeId
337
- if not __TS__InstanceOf(ability, Ability) then
348
+ if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
338
349
  parameters = ability
339
350
  ability = nil
340
351
  end
@@ -362,14 +373,19 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
362
373
  end
363
374
  self.polarity = resolveEnumValue(ability, level, polarity)
364
375
  self.resistanceType = resolveEnumValue(ability, level, resistanceType)
376
+ local missProbability = parameters and parameters.missProbability or defaultParameters.missProbability
377
+ if missProbability ~= nil then
378
+ missProbability = resolveNumberValue(ability, level, missProbability)
379
+ self[142] = missProbability
380
+ end
365
381
  local buffByTypeId = buffByTypeIdByUnit[_unit]
366
382
  if buffByTypeId == nil then
367
383
  buffByTypeId = {}
368
384
  buffByTypeIdByUnit[_unit] = buffByTypeId
369
385
  end
370
- local ____opt_13 = buffByTypeId[typeId]
371
- if ____opt_13 ~= nil then
372
- ____opt_13:destroy()
386
+ local ____opt_15 = buffByTypeId[typeId]
387
+ if ____opt_15 ~= nil then
388
+ ____opt_15:destroy()
373
389
  end
374
390
  local uniqueGroup = parameters and parameters.uniqueGroup or defaultParameters and defaultParameters.uniqueGroup
375
391
  if uniqueGroup ~= nil then
@@ -383,13 +399,16 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
383
399
  level,
384
400
  duration,
385
401
  spellStealPriority,
386
- learnLevelMinimum
402
+ learnLevelMinimum,
403
+ missProbability
387
404
  ) then
405
+ self[100] = 1
388
406
  UnitBehavior.prototype.destroy(self)
389
407
  error(unsuccessfulApplicationMarker, 0)
390
408
  end
391
409
  local handle = BlzGetUnitAbility(_unit.handle, typeId)
392
410
  if handle == nil then
411
+ self[100] = 1
393
412
  UnitBehavior.prototype.destroy(self)
394
413
  error(unsuccessfulApplicationMarker, 0)
395
414
  end
@@ -398,20 +417,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
398
417
  self._level = level
399
418
  self._spellStealPriority = spellStealPriority
400
419
  self._learnLevelMinimum = learnLevelMinimum
401
- self[101] = source
402
- self[102] = duration or 0
403
- self[103] = uniqueGroup
404
- self[104] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
405
- self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
420
+ self[102] = source
421
+ self[103] = duration or 0
422
+ self[104] = uniqueGroup
423
+ self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
424
+ self[106] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
406
425
  if parameters ~= nil or (next(defaultParameters)) ~= nil then
407
426
  for ____, buffBooleanParameter in ipairs(buffBooleanParameters) do
408
- local ____ability_22 = ability
409
- local ____level_23 = level
410
- local ____temp_21 = parameters and parameters[buffBooleanParameter]
411
- if ____temp_21 == nil then
412
- ____temp_21 = defaultParameters[buffBooleanParameter]
427
+ local ____ability_24 = ability
428
+ local ____level_25 = level
429
+ local ____temp_23 = parameters and parameters[buffBooleanParameter]
430
+ if ____temp_23 == nil then
431
+ ____temp_23 = defaultParameters[buffBooleanParameter]
413
432
  end
414
- if resolveBooleanValue(____ability_22, ____level_23, ____temp_21) then
433
+ if resolveBooleanValue(____ability_24, ____level_25, ____temp_23) then
415
434
  self[buffBooleanParameter] = true
416
435
  end
417
436
  end
@@ -427,11 +446,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
427
446
  end
428
447
  local maximumDuration = parameters and parameters.maximumDuration or defaultParameters.maximumDuration
429
448
  if maximumDuration ~= nil then
430
- self[107] = resolveNumberValue(ability, level, maximumDuration)
449
+ self[108] = resolveNumberValue(ability, level, maximumDuration)
431
450
  end
432
451
  local maximumRemainingDuration = parameters and parameters.maximumRemainingDuration or defaultParameters.maximumRemainingDuration
433
452
  if maximumRemainingDuration ~= nil then
434
- self[108] = resolveNumberValue(ability, level, maximumRemainingDuration)
453
+ self[109] = resolveNumberValue(ability, level, maximumRemainingDuration)
435
454
  end
436
455
  local parametersAbilityTypeIds = parameters and parameters.abilityTypeIds or defaultParameters.abilityTypeIds
437
456
  if parametersAbilityTypeIds ~= nil then
@@ -489,29 +508,34 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
489
508
  self._timer = timer
490
509
  end
491
510
  self:onCreate()
511
+ self[100] = 1
512
+ Event.invoke(buffCreatedEvent, self)
492
513
  end
493
- function Buff.prototype.getUnitBonus(self, bonusType)
494
- local ____opt_36 = self._bonusIdByBonusType
495
- local bonusId = ____opt_36 and ____opt_36[bonusType]
496
- return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
514
+ function Buff.prototype.onAbilityGained(self, ability)
515
+ if __TS__InstanceOf(ability, UnitAbility) then
516
+ local abilityCooldownModifier = self[144]
517
+ if abilityCooldownModifier then
518
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
519
+ end
520
+ end
497
521
  end
498
- function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
499
- local bonusIdByBonusType = self._bonusIdByBonusType
500
- if bonusIdByBonusType == nil then
501
- bonusIdByBonusType = {}
502
- self._bonusIdByBonusType = bonusIdByBonusType
522
+ function Buff.prototype.onAbilityLost(self, ability)
523
+ if __TS__InstanceOf(ability, UnitAbility) then
524
+ local abilityCooldownModifier = self[144]
525
+ if abilityCooldownModifier then
526
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
527
+ end
503
528
  end
504
- bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
505
529
  end
506
530
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
507
531
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
508
- Effect:flash(self[104], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
532
+ Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
509
533
  else
510
534
  local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
511
535
  local ____Effect_40 = Effect
512
536
  local ____Effect_flash_41 = Effect.flash
513
537
  local ____array_39 = __TS__SparseArrayNew(
514
- self[104],
538
+ self[105],
515
539
  isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
516
540
  stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
517
541
  )
@@ -533,7 +557,7 @@ function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
533
557
  local ____Effect_44 = Effect
534
558
  local ____Effect_flash_45 = Effect.flash
535
559
  local ____array_43 = __TS__SparseArrayNew(
536
- self[105],
560
+ self[106],
537
561
  isWidgetProvided and widgetOrDuration or self._unit,
538
562
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
539
563
  )
@@ -552,20 +576,22 @@ end
552
576
  function Buff.prototype.onCreate(self)
553
577
  end
554
578
  function Buff.prototype.onDestroy(self)
579
+ check(self[100] ~= 0, "Cannot destroy a buff that has not finished creating yet.")
580
+ self[100] = 2
555
581
  local unit = self._unit
556
582
  if getUnitAbility(unit.handle, self.typeId) == self.handle then
557
583
  removeBuff(unit.handle, self.typeId)
558
584
  end
559
585
  buffByTypeIdByUnit[unit][self.typeId] = nil
560
- local healingIntervalTimer = self[118]
586
+ local healingIntervalTimer = self[119]
561
587
  if healingIntervalTimer ~= nil then
562
588
  healingIntervalTimer:destroy()
563
- self[118] = nil
589
+ self[119] = nil
564
590
  end
565
- local damageIntervalTimer = self[113]
591
+ local damageIntervalTimer = self[114]
566
592
  if damageIntervalTimer ~= nil then
567
593
  damageIntervalTimer:destroy()
568
- self[113] = nil
594
+ self[114] = nil
569
595
  end
570
596
  if self._timer ~= nil then
571
597
  self._timer:destroy()
@@ -575,25 +601,34 @@ function Buff.prototype.onDestroy(self)
575
601
  behavior:destroy()
576
602
  end
577
603
  end
578
- if self[136] then
604
+ local previousAbilityCooldownModifier = self[144]
605
+ if previousAbilityCooldownModifier then
606
+ for ____, ability in ipairs(self._unit.abilities) do
607
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
608
+ end
609
+ end
610
+ if self[139] then
611
+ unit:decrementInvulnerabilityCounter()
612
+ end
613
+ if self[138] then
579
614
  unit:decrementDisableAutoAttackCounter()
580
615
  end
581
- if self[134] then
582
- if self[135] then
583
- unit:decrementStunCounter()
616
+ if self[136] then
617
+ if self[137] then
618
+ unit:decrementForceStunCounter()
584
619
  end
585
620
  unit:decrementStunCounter()
586
621
  end
622
+ if self[135] then
623
+ unit:decrementGhostCounter()
624
+ end
587
625
  if self._abilityTypeIds ~= nil then
588
626
  for abilityTypeId in pairs(self._abilityTypeIds) do
589
627
  unit:removeAbility(abilityTypeId)
590
628
  end
591
629
  end
592
- if self._bonusIdByBonusType ~= nil then
593
- for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
594
- removeUnitBonus(unit, bonusType, bonusId)
595
- end
596
- end
630
+ Event.invoke(buffBeingDestroyedEvent, self)
631
+ self[100] = 3
597
632
  return UnitBehavior.prototype.onDestroy(self)
598
633
  end
599
634
  function Buff.apply(self, ...)
@@ -630,72 +665,72 @@ function Buff.getByTypeId(self, unit, typeId)
630
665
  end
631
666
  function Buff.prototype.onExpiration(self)
632
667
  local unit = self.unit
633
- if self[119] ~= nil then
634
- (self[101] or unit):damageTarget(unit, self[119] or 0)
635
- end
636
668
  if self[120] ~= nil then
637
- (self[101] or unit):healTarget(unit, self[119] or 0)
669
+ (self[102] or unit):damageTarget(unit, self[120] or 0)
638
670
  end
639
- if self[139] then
671
+ if self[121] ~= nil then
672
+ (self[102] or unit):healTarget(unit, self[120] or 0)
673
+ end
674
+ if self[141] then
640
675
  unit:explode()
641
- elseif self[138] then
676
+ elseif self[140] then
642
677
  unit:kill()
643
678
  end
644
679
  end
645
680
  function Buff.prototype.onDeath(self, source)
646
681
  local unit = self.unit
647
- if self[121] ~= nil then
682
+ if self[122] ~= nil then
648
683
  damageArea(
649
- self[101] or unit,
650
- self[121],
684
+ self[102] or unit,
685
+ self[122],
651
686
  unit.x,
652
687
  unit.y,
688
+ self[124] or 0,
653
689
  self[123] or 0,
654
- self[122] or 0,
690
+ self[126] or 0,
655
691
  self[125] or 0,
656
- self[124] or 0,
657
- self[127] or 0,
658
- self[126] or 0
692
+ self[128] or 0,
693
+ self[127] or 0
659
694
  )
660
695
  end
661
696
  end
662
697
  function Buff.prototype.onDamageDealt(self, target, event)
663
698
  if event.isAttack then
664
- if self[106] ~= nil then
665
- local durationIncrease = self[106]
666
- local maximumDuration = self[107] or 0
699
+ if self[107] ~= nil then
700
+ local durationIncrease = self[107]
701
+ local maximumDuration = self[108] or 0
667
702
  if maximumDuration > 0 then
668
703
  durationIncrease = min(
669
704
  durationIncrease,
670
- max(0, maximumDuration - self[102])
705
+ max(0, maximumDuration - self[103])
671
706
  )
672
707
  end
673
708
  local remainingDuration = self.remainingDuration + durationIncrease
674
- local maximumRemainingDuration = self[108] or 0
709
+ local maximumRemainingDuration = self[109] or 0
675
710
  if maximumRemainingDuration > 0 then
676
711
  remainingDuration = min(remainingDuration, maximumRemainingDuration)
677
712
  end
678
713
  self.remainingDuration = remainingDuration
679
714
  end
680
- local autoAttackCount = (self[128] or 0) + 1
681
- self[128] = autoAttackCount
682
- if autoAttackCount == self[129] then
715
+ local autoAttackCount = (self[129] or 0) + 1
716
+ self[129] = autoAttackCount
717
+ if autoAttackCount == self[130] then
683
718
  self:destroy()
684
719
  end
685
720
  end
686
721
  if event.originalAmount ~= 0 then
687
- local damageDealtEventCount = (self[130] or 0) + 1
688
- self[130] = damageDealtEventCount
689
- if damageDealtEventCount == self[131] then
722
+ local damageDealtEventCount = (self[131] or 0) + 1
723
+ self[131] = damageDealtEventCount
724
+ if damageDealtEventCount == self[132] then
690
725
  self:destroy()
691
726
  end
692
727
  end
693
728
  end
694
729
  function Buff.prototype.onDamageReceived(self, source, event)
695
730
  if event.originalAmount ~= 0 then
696
- local damageReceivedEventCount = (self[132] or 0) + 1
697
- self[132] = damageReceivedEventCount
698
- if damageReceivedEventCount == self[133] then
731
+ local damageReceivedEventCount = (self[133] or 0) + 1
732
+ self[133] = damageReceivedEventCount
733
+ if damageReceivedEventCount == self[134] then
699
734
  self:destroy()
700
735
  end
701
736
  end
@@ -705,7 +740,7 @@ __TS__SetDescriptor(
705
740
  Buff.prototype,
706
741
  "source",
707
742
  {get = function(self)
708
- return self[101] or self._unit
743
+ return self[102] or self._unit
709
744
  end},
710
745
  true
711
746
  )
@@ -722,13 +757,13 @@ __TS__SetDescriptor(
722
757
  "remainingDamageOverDuration",
723
758
  {
724
759
  get = function(self)
725
- return self[112] or 0
760
+ return self[113] or 0
726
761
  end,
727
762
  set = function(self, remainingDamageOverDuration)
728
- local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[112] or 0)
729
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
730
- local damageOverDuration = (self[109] or 0) + remainingDamageOverDurationDelta
731
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
763
+ local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[113] or 0)
764
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
765
+ local damageOverDuration = (self[110] or 0) + remainingDamageOverDurationDelta
766
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
732
767
  end
733
768
  },
734
769
  true
@@ -738,13 +773,13 @@ __TS__SetDescriptor(
738
773
  "damageOverDuration",
739
774
  {
740
775
  get = function(self)
741
- return self[109] or 0
776
+ return self[110] or 0
742
777
  end,
743
778
  set = function(self, damageOverDuration)
744
- local damageOverDurationDelta = damageOverDuration - (self[109] or 0)
745
- self[109] = damageOverDuration ~= 0 and damageOverDuration or nil
746
- local remainingDamageOverDuration = (self[112] or 0) + damageOverDurationDelta
747
- self[112] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
779
+ local damageOverDurationDelta = damageOverDuration - (self[110] or 0)
780
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
781
+ local remainingDamageOverDuration = (self[113] or 0) + damageOverDurationDelta
782
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
748
783
  end
749
784
  },
750
785
  true
@@ -754,10 +789,10 @@ __TS__SetDescriptor(
754
789
  "damagePerInterval",
755
790
  {
756
791
  get = function(self)
757
- return self[110] or 0
792
+ return self[111] or 0
758
793
  end,
759
794
  set = function(self, damagePerInterval)
760
- self[110] = damagePerInterval ~= 0 and damagePerInterval or nil
795
+ self[111] = damagePerInterval ~= 0 and damagePerInterval or nil
761
796
  end
762
797
  },
763
798
  true
@@ -767,25 +802,25 @@ __TS__SetDescriptor(
767
802
  "damageInterval",
768
803
  {
769
804
  get = function(self)
770
- return self[111] or 0
805
+ return self[112] or 0
771
806
  end,
772
807
  set = function(self, damageInterval)
773
808
  if damageInterval <= 0 then
774
- self[111] = damageInterval ~= 0 and damageInterval or nil
775
- local timer = self[113]
809
+ self[112] = damageInterval ~= 0 and damageInterval or nil
810
+ local timer = self[114]
776
811
  if timer ~= nil then
777
812
  timer:destroy()
778
- self[113] = nil
813
+ self[114] = nil
779
814
  end
780
815
  return
781
816
  end
782
- self[111] = damageInterval
817
+ self[112] = damageInterval
783
818
  local ____opt_48 = self._timer
784
819
  local elapsed = ____opt_48 and ____opt_48.elapsed or 0
785
- local timer = self[113]
820
+ local timer = self[114]
786
821
  if timer == nil then
787
822
  timer = Timer:create()
788
- self[113] = timer
823
+ self[114] = timer
789
824
  end
790
825
  local initialDelay = damageInterval - (elapsed >= damageInterval and math.fmod(elapsed, damageInterval) or elapsed)
791
826
  if initialDelay == damageInterval then
@@ -802,13 +837,13 @@ __TS__SetDescriptor(
802
837
  "remainingHealingOverDuration",
803
838
  {
804
839
  get = function(self)
805
- return self[117] or 0
840
+ return self[118] or 0
806
841
  end,
807
842
  set = function(self, remainingHealingOverDuration)
808
- local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[117] or 0)
809
- self[112] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
810
- local healingOverDuration = (self[114] or 0) + remainingHealingOverDurationDelta
811
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
843
+ local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[118] or 0)
844
+ self[113] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
845
+ local healingOverDuration = (self[115] or 0) + remainingHealingOverDurationDelta
846
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
812
847
  end
813
848
  },
814
849
  true
@@ -818,13 +853,13 @@ __TS__SetDescriptor(
818
853
  "healingOverDuration",
819
854
  {
820
855
  get = function(self)
821
- return self[114] or 0
856
+ return self[115] or 0
822
857
  end,
823
858
  set = function(self, healingOverDuration)
824
- local healingOverDurationDelta = healingOverDuration - (self[114] or 0)
825
- self[114] = healingOverDuration ~= 0 and healingOverDuration or nil
826
- local remainingHealingOverDuration = (self[117] or 0) + healingOverDurationDelta
827
- self[117] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
859
+ local healingOverDurationDelta = healingOverDuration - (self[115] or 0)
860
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
861
+ local remainingHealingOverDuration = (self[118] or 0) + healingOverDurationDelta
862
+ self[118] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
828
863
  end
829
864
  },
830
865
  true
@@ -834,10 +869,10 @@ __TS__SetDescriptor(
834
869
  "healingPerInterval",
835
870
  {
836
871
  get = function(self)
837
- return self[115] or 0
872
+ return self[116] or 0
838
873
  end,
839
874
  set = function(self, healingPerInterval)
840
- self[115] = healingPerInterval ~= 0 and healingPerInterval or nil
875
+ self[116] = healingPerInterval ~= 0 and healingPerInterval or nil
841
876
  end
842
877
  },
843
878
  true
@@ -847,25 +882,25 @@ __TS__SetDescriptor(
847
882
  "healingInterval",
848
883
  {
849
884
  get = function(self)
850
- return self[116] or 0
885
+ return self[117] or 0
851
886
  end,
852
887
  set = function(self, healingInterval)
853
888
  if healingInterval <= 0 then
854
- self[116] = healingInterval ~= 0 and healingInterval or nil
855
- local timer = self[118]
889
+ self[117] = healingInterval ~= 0 and healingInterval or nil
890
+ local timer = self[119]
856
891
  if timer ~= nil then
857
892
  timer:destroy()
858
- self[118] = nil
893
+ self[119] = nil
859
894
  end
860
895
  return
861
896
  end
862
- self[116] = healingInterval
897
+ self[117] = healingInterval
863
898
  local ____opt_50 = self._timer
864
899
  local elapsed = ____opt_50 and ____opt_50.elapsed or 0
865
- local timer = self[118]
900
+ local timer = self[119]
866
901
  if timer == nil then
867
902
  timer = Timer:create()
868
- self[118] = timer
903
+ self[119] = timer
869
904
  end
870
905
  local initialDelay = healingInterval - (elapsed >= healingInterval and math.fmod(elapsed, healingInterval) or elapsed)
871
906
  if initialDelay == healingInterval then
@@ -882,10 +917,10 @@ __TS__SetDescriptor(
882
917
  "damageOnExpiration",
883
918
  {
884
919
  get = function(self)
885
- return self[119] or 0
920
+ return self[120] or 0
886
921
  end,
887
922
  set = function(self, damageOnExpiration)
888
- self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
923
+ self[120] = damageOnExpiration ~= 0 and damageOnExpiration or nil
889
924
  end
890
925
  },
891
926
  true
@@ -895,10 +930,10 @@ __TS__SetDescriptor(
895
930
  "healingOnExpiration",
896
931
  {
897
932
  get = function(self)
898
- return self[120] or 0
933
+ return self[121] or 0
899
934
  end,
900
935
  set = function(self, healingOnExpiration)
901
- self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
936
+ self[121] = healingOnExpiration ~= 0 and healingOnExpiration or nil
902
937
  end
903
938
  },
904
939
  true
@@ -942,30 +977,53 @@ __TS__SetDescriptor(
942
977
  },
943
978
  true
944
979
  )
980
+ __TS__SetDescriptor(
981
+ Buff.prototype,
982
+ "turnsIntoGhost",
983
+ {
984
+ get = function(self)
985
+ local ____self__135_52 = self[135]
986
+ if ____self__135_52 == nil then
987
+ ____self__135_52 = false
988
+ end
989
+ return ____self__135_52
990
+ end,
991
+ set = function(self, turnsIntoGhost)
992
+ if not turnsIntoGhost and self[135] then
993
+ self.object:decrementGhostCounter()
994
+ self[135] = nil
995
+ elseif turnsIntoGhost and not self[135] then
996
+ self.object:incrementGhostCounter()
997
+ self[135] = true
998
+ end
999
+ end
1000
+ },
1001
+ true
1002
+ )
945
1003
  __TS__SetDescriptor(
946
1004
  Buff.prototype,
947
1005
  "stuns",
948
1006
  {
949
1007
  get = function(self)
950
- local ____self__134_52 = self[134]
951
- if ____self__134_52 == nil then
952
- ____self__134_52 = false
1008
+ local ____self__136_53 = self[136]
1009
+ if ____self__136_53 == nil then
1010
+ ____self__136_53 = false
953
1011
  end
954
- return ____self__134_52
1012
+ return ____self__136_53
955
1013
  end,
956
1014
  set = function(self, stuns)
957
- if not stuns and self[134] then
958
- if self[135] then
959
- self.object:decrementStunCounter()
1015
+ if not stuns and self[136] then
1016
+ if self[137] then
1017
+ self.object:decrementForceStunCounter()
960
1018
  end
961
1019
  self.object:decrementStunCounter()
962
- self[134] = nil
963
- elseif stuns and not self[134] then
964
- if self[135] then
965
- self.object:incrementStunCounter()
1020
+ self[136] = nil
1021
+ elseif stuns and not self[136] then
1022
+ if self[137] then
1023
+ self.object:incrementForceStunCounter()
966
1024
  end
967
1025
  self.object:incrementStunCounter()
968
- self[134] = true
1026
+ self[136] = true
969
1027
  end
970
1028
  end
971
1029
  },
@@ -976,23 +1034,23 @@ __TS__SetDescriptor(
976
1034
  "ignoresStunImmunity",
977
1035
  {
978
1036
  get = function(self)
979
- local ____self__135_53 = self[135]
980
- if ____self__135_53 == nil then
981
- ____self__135_53 = false
1037
+ local ____self__137_54 = self[137]
1038
+ if ____self__137_54 == nil then
1039
+ ____self__137_54 = false
982
1040
  end
983
- return ____self__135_53
1041
+ return ____self__137_54
984
1042
  end,
985
1043
  set = function(self, ignoresStunImmunity)
986
- if not ignoresStunImmunity and self[135] then
987
- if self[134] then
988
- self.object:decrementStunCounter()
1044
+ if not ignoresStunImmunity and self[137] then
1045
+ if self[136] then
1046
+ self.object:decrementForceStunCounter()
989
1047
  end
990
- self[135] = nil
991
- elseif ignoresStunImmunity and not self[135] then
992
- if self[134] then
993
- self.object:incrementStunCounter()
1048
+ self[137] = nil
1049
+ elseif ignoresStunImmunity and not self[137] then
1050
+ if self[136] then
1051
+ self.object:incrementForceStunCounter()
994
1052
  end
995
- self[135] = true
1053
+ self[137] = true
996
1054
  end
997
1055
  end
998
1056
  },
@@ -1003,19 +1061,19 @@ __TS__SetDescriptor(
1003
1061
  "disablesAutoAttack",
1004
1062
  {
1005
1063
  get = function(self)
1006
- local ____self__136_54 = self[136]
1007
- if ____self__136_54 == nil then
1008
- ____self__136_54 = false
1064
+ local ____self__138_55 = self[138]
1065
+ if ____self__138_55 == nil then
1066
+ ____self__138_55 = false
1009
1067
  end
1010
- return ____self__136_54
1068
+ return ____self__138_55
1011
1069
  end,
1012
1070
  set = function(self, disablesAutoAttack)
1013
- if not disablesAutoAttack and self[136] then
1071
+ if not disablesAutoAttack and self[138] then
1014
1072
  self.object:decrementDisableAutoAttackCounter()
1015
- self[136] = nil
1016
- elseif disablesAutoAttack and not self[136] then
1073
+ self[138] = nil
1074
+ elseif disablesAutoAttack and not self[138] then
1017
1075
  self.object:incrementDisableAutoAttackCounter()
1018
- self[136] = true
1076
+ self[138] = true
1019
1077
  end
1020
1078
  end
1021
1079
  },
@@ -1026,19 +1084,19 @@ __TS__SetDescriptor(
1026
1084
  "providesInvulnerability",
1027
1085
  {
1028
1086
  get = function(self)
1029
- local ____self__137_55 = self[137]
1030
- if ____self__137_55 == nil then
1031
- ____self__137_55 = false
1087
+ local ____self__139_56 = self[139]
1088
+ if ____self__139_56 == nil then
1089
+ ____self__139_56 = false
1032
1090
  end
1033
- return ____self__137_55
1091
+ return ____self__139_56
1034
1092
  end,
1035
1093
  set = function(self, providesInvulnerability)
1036
- if not providesInvulnerability and self[137] then
1094
+ if not providesInvulnerability and self[139] then
1037
1095
  self.object:decrementInvulnerabilityCounter()
1038
- self[137] = nil
1039
- elseif providesInvulnerability and not self[137] then
1096
+ self[139] = nil
1097
+ elseif providesInvulnerability and not self[139] then
1040
1098
  self.object:incrementInvulnerabilityCounter()
1041
- self[137] = true
1099
+ self[139] = true
1042
1100
  end
1043
1101
  end
1044
1102
  },
@@ -1049,17 +1107,17 @@ __TS__SetDescriptor(
1049
1107
  "killsOnExpiration",
1050
1108
  {
1051
1109
  get = function(self)
1052
- local ____self__138_56 = self[138]
1053
- if ____self__138_56 == nil then
1054
- ____self__138_56 = false
1110
+ local ____self__140_57 = self[140]
1111
+ if ____self__140_57 == nil then
1112
+ ____self__140_57 = false
1055
1113
  end
1056
- return ____self__138_56
1114
+ return ____self__140_57
1057
1115
  end,
1058
1116
  set = function(self, killsOnExpiration)
1059
- if not killsOnExpiration and self[138] then
1060
- self[138] = nil
1061
- elseif killsOnExpiration and not self[138] then
1062
- self[138] = true
1117
+ if not killsOnExpiration and self[140] then
1118
+ self[140] = nil
1119
+ elseif killsOnExpiration and not self[140] then
1120
+ self[140] = true
1063
1121
  end
1064
1122
  end
1065
1123
  },
@@ -1070,17 +1128,17 @@ __TS__SetDescriptor(
1070
1128
  "explodesOnExpiration",
1071
1129
  {
1072
1130
  get = function(self)
1073
- local ____self__139_57 = self[139]
1074
- if ____self__139_57 == nil then
1075
- ____self__139_57 = false
1131
+ local ____self__141_58 = self[141]
1132
+ if ____self__141_58 == nil then
1133
+ ____self__141_58 = false
1076
1134
  end
1077
- return ____self__139_57
1135
+ return ____self__141_58
1078
1136
  end,
1079
1137
  set = function(self, killsOnExpiration)
1080
- if not killsOnExpiration and self[139] then
1081
- self[139] = nil
1082
- elseif killsOnExpiration and not self[139] then
1083
- self[139] = true
1138
+ if not killsOnExpiration and self[141] then
1139
+ self[141] = nil
1140
+ elseif killsOnExpiration and not self[141] then
1141
+ self[141] = true
1084
1142
  end
1085
1143
  end
1086
1144
  },
@@ -1091,13 +1149,13 @@ __TS__SetDescriptor(
1091
1149
  "maximumDamageDealtEventCount",
1092
1150
  {
1093
1151
  get = function(self)
1094
- return self[131] or 0
1152
+ return self[132] or 0
1095
1153
  end,
1096
1154
  set = function(self, maximumDamageDealtEventCount)
1097
1155
  if maximumDamageDealtEventCount == 0 then
1098
- self[131] = nil
1156
+ self[132] = nil
1099
1157
  else
1100
- self[131] = maximumDamageDealtEventCount
1158
+ self[132] = maximumDamageDealtEventCount
1101
1159
  end
1102
1160
  end
1103
1161
  },
@@ -1108,13 +1166,13 @@ __TS__SetDescriptor(
1108
1166
  "maximumDamageReceivedEventCount",
1109
1167
  {
1110
1168
  get = function(self)
1111
- return self[133] or 0
1169
+ return self[134] or 0
1112
1170
  end,
1113
1171
  set = function(self, maximumDamageReceivedEventCount)
1114
1172
  if maximumDamageReceivedEventCount == 0 then
1115
- self[133] = nil
1173
+ self[134] = nil
1116
1174
  else
1117
- self[133] = maximumDamageReceivedEventCount
1175
+ self[134] = maximumDamageReceivedEventCount
1118
1176
  end
1119
1177
  end
1120
1178
  },
@@ -1125,13 +1183,13 @@ __TS__SetDescriptor(
1125
1183
  "maximumAutoAttackCount",
1126
1184
  {
1127
1185
  get = function(self)
1128
- return self[129] or 0
1186
+ return self[130] or 0
1129
1187
  end,
1130
1188
  set = function(self, maximumAutoAttackCount)
1131
1189
  if maximumAutoAttackCount == 0 then
1132
- self[129] = nil
1190
+ self[130] = nil
1133
1191
  else
1134
- self[129] = maximumAutoAttackCount
1192
+ self[130] = maximumAutoAttackCount
1135
1193
  end
1136
1194
  end
1137
1195
  },
@@ -1142,10 +1200,10 @@ __TS__SetDescriptor(
1142
1200
  "durationIncreaseOnAutoAttack",
1143
1201
  {
1144
1202
  get = function(self)
1145
- return self[106] or 0
1203
+ return self[107] or 0
1146
1204
  end,
1147
1205
  set = function(self, durationIncreaseOnAutoAttack)
1148
- self[106] = durationIncreaseOnAutoAttack
1206
+ self[107] = durationIncreaseOnAutoAttack
1149
1207
  end
1150
1208
  },
1151
1209
  true
@@ -1193,7 +1251,7 @@ __TS__SetDescriptor(
1193
1251
  Buff.prototype,
1194
1252
  "duration",
1195
1253
  {get = function(self)
1196
- return self[102]
1254
+ return self[103]
1197
1255
  end},
1198
1256
  true
1199
1257
  )
@@ -1202,15 +1260,15 @@ __TS__SetDescriptor(
1202
1260
  "remainingDuration",
1203
1261
  {
1204
1262
  get = function(self)
1205
- local ____opt_58 = self._timer
1206
- return ____opt_58 and ____opt_58.remaining or 0
1263
+ local ____opt_59 = self._timer
1264
+ return ____opt_59 and ____opt_59.remaining or 0
1207
1265
  end,
1208
1266
  set = function(self, remainingDuration)
1209
- local ____remainingDuration_62 = remainingDuration
1210
- local ____opt_60 = self._timer
1211
- local remainingDurationDelta = ____remainingDuration_62 - (____opt_60 and ____opt_60.remaining or 0)
1267
+ local ____remainingDuration_63 = remainingDuration
1268
+ local ____opt_61 = self._timer
1269
+ local remainingDurationDelta = ____remainingDuration_63 - (____opt_61 and ____opt_61.remaining or 0)
1212
1270
  if remainingDurationDelta ~= 0 then
1213
- self[102] = self[102] + remainingDurationDelta
1271
+ self[103] = self[103] + remainingDurationDelta
1214
1272
  if remainingDuration <= 0 then
1215
1273
  Timer:run(destroyBuff, self)
1216
1274
  else
@@ -1222,7 +1280,8 @@ __TS__SetDescriptor(
1222
1280
  self._level,
1223
1281
  remainingDuration,
1224
1282
  self._spellStealPriority,
1225
- self._learnLevelMinimum
1283
+ self._learnLevelMinimum,
1284
+ self[142]
1226
1285
  ) then
1227
1286
  local timer = self._timer
1228
1287
  if timer == nil then
@@ -1236,10 +1295,38 @@ __TS__SetDescriptor(
1236
1295
  end
1237
1296
  },
1238
1297
  true
1239
- );
1298
+ )
1299
+ __TS__SetDescriptor(
1300
+ Buff.prototype,
1301
+ "abilityCooldownFactor",
1302
+ {
1303
+ get = function(self)
1304
+ return self[143] or 1
1305
+ end,
1306
+ set = function(self, abilityCooldownFactor)
1307
+ local previousAbilityCooldownModifier = self[144]
1308
+ if previousAbilityCooldownModifier then
1309
+ for ____, ability in ipairs(self._unit.abilities) do
1310
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
1311
+ end
1312
+ end
1313
+ local function modifier(ability, level, cooldown)
1314
+ return cooldown * abilityCooldownFactor
1315
+ end
1316
+ for ____, ability in ipairs(self._unit.abilities) do
1317
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
1318
+ end
1319
+ self[144] = modifier
1320
+ self[143] = abilityCooldownFactor
1321
+ end
1322
+ },
1323
+ true
1324
+ )
1325
+ Buff.createdEvent = buffCreatedEvent
1326
+ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1240
1327
  (function(self)
1241
1328
  local function destroyBuffIfNeeded(buff)
1242
- if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1329
+ if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
1243
1330
  buff:destroy()
1244
1331
  end
1245
1332
  end
@@ -1290,5 +1377,11 @@ __TS__SetDescriptor(
1290
1377
  ____exports.checkBuffs(target)
1291
1378
  end
1292
1379
  )
1380
+ buffCreatedEvent:addListener(function(buff)
1381
+ UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1382
+ end)
1383
+ buffBeingDestroyedEvent:addListener(function(buff)
1384
+ UnitBehavior:forAll(buff.unit, "onBuffLost", buff)
1385
+ end)
1293
1386
  end)(Buff)
1294
1387
  return ____exports