warscript 0.0.1-dev.a921742 → 0.0.1-dev.a9f2494

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