warscript 0.0.1-dev.59cd31d → 0.0.1-dev.5abc199

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