warscript 0.0.1-dev.099f0af → 0.0.1-dev.0ad346c

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