warscript 0.0.1-dev.971c803 → 0.0.1-dev.989e1a3

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