warscript 0.0.1-dev.a4deb44 → 0.0.1-dev.a5a2f5e

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 (319) 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 +164 -23
  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/item.d.ts +1 -0
  16. package/core/types/item.lua +1 -0
  17. package/core/types/missile.d.ts +2 -2
  18. package/core/types/missile.lua +8 -2
  19. package/core/types/player.d.ts +17 -1
  20. package/core/types/player.lua +70 -24
  21. package/core/types/playerCamera.d.ts +2 -0
  22. package/core/types/playerCamera.lua +123 -5
  23. package/core/types/sound.d.ts +17 -24
  24. package/core/types/sound.lua +100 -25
  25. package/core/types/tileCell.d.ts +11 -1
  26. package/core/types/tileCell.lua +97 -0
  27. package/core/types/timer.d.ts +9 -8
  28. package/core/types/timer.lua +45 -23
  29. package/core/types/unit.lua +8 -0
  30. package/core/util.d.ts +1 -1
  31. package/core/util.lua +18 -1
  32. package/decl/index.d.ts +1 -0
  33. package/decl/native.d.ts +846 -790
  34. package/destroyable.d.ts +1 -0
  35. package/destroyable.lua +9 -0
  36. package/engine/ability.d.ts +1 -1
  37. package/engine/behavior.d.ts +24 -11
  38. package/engine/behavior.lua +233 -73
  39. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  40. package/engine/behaviour/ability/always-enabled.lua +31 -0
  41. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  42. package/engine/behaviour/ability/apply-buff.lua +36 -4
  43. package/engine/behaviour/ability/apply-unit-behavior.d.ts +13 -4
  44. package/engine/behaviour/ability/apply-unit-behavior.lua +32 -9
  45. package/engine/behaviour/ability/damage.d.ts +42 -11
  46. package/engine/behaviour/ability/damage.lua +89 -37
  47. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  48. package/engine/behaviour/ability/emulate-impact.lua +44 -0
  49. package/engine/behaviour/ability/heal.d.ts +33 -6
  50. package/engine/behaviour/ability/heal.lua +89 -10
  51. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  52. package/engine/behaviour/ability/instant-impact.lua +4 -15
  53. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  54. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  55. package/engine/behaviour/ability/remove-buffs.d.ts +25 -0
  56. package/engine/behaviour/ability/remove-buffs.lua +49 -0
  57. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  58. package/engine/behaviour/ability/restore-mana.lua +29 -0
  59. package/engine/behaviour/ability.d.ts +35 -7
  60. package/engine/behaviour/ability.lua +183 -27
  61. package/engine/behaviour/unit/stun-immunity.d.ts +12 -7
  62. package/engine/behaviour/unit/stun-immunity.lua +57 -31
  63. package/engine/behaviour/unit.d.ts +48 -4
  64. package/engine/behaviour/unit.lua +292 -2
  65. package/engine/buff.d.ts +160 -53
  66. package/engine/buff.lua +711 -269
  67. package/engine/game-map.d.ts +7 -0
  68. package/engine/game-map.lua +32 -0
  69. package/engine/internal/ability.d.ts +23 -14
  70. package/engine/internal/ability.lua +129 -85
  71. package/engine/internal/item/ability.lua +162 -4
  72. package/engine/internal/item/fields.d.ts +12 -0
  73. package/engine/internal/item/fields.lua +33 -0
  74. package/engine/internal/item+owner.lua +12 -6
  75. package/engine/internal/item.d.ts +16 -19
  76. package/engine/internal/item.lua +174 -94
  77. package/engine/internal/mechanics/ability-duration.d.ts +1 -3
  78. package/engine/internal/mechanics/ability-duration.lua +3 -1
  79. package/engine/internal/mechanics/cast-ability.lua +89 -0
  80. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  81. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  82. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  83. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  84. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  85. package/engine/internal/misc/frame-coordinates.lua +21 -0
  86. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  87. package/engine/internal/misc/get-terrain-z.lua +11 -0
  88. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  89. package/engine/internal/misc/player-local-handle.lua +5 -0
  90. package/engine/internal/object-data/armor-bonus.d.ts +2 -0
  91. package/engine/internal/object-data/attribute-bonus.lua +2 -2
  92. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  93. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  94. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  95. package/engine/internal/object-data/evasion-probability.lua +16 -0
  96. package/engine/internal/object-data/health-bonus.d.ts +2 -0
  97. package/engine/internal/object-data/health-bonus.lua +16 -0
  98. package/engine/internal/object-data/mana-bonus.d.ts +2 -0
  99. package/engine/internal/object-data/mana-bonus.lua +16 -0
  100. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  101. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  102. package/engine/internal/unit/ability.d.ts +45 -1
  103. package/engine/internal/unit/ability.lua +128 -17
  104. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  105. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  106. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  107. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  108. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  109. package/engine/internal/unit/allowed-targets.lua +9 -1
  110. package/engine/internal/unit/attributes.d.ts +17 -0
  111. package/engine/internal/unit/attributes.lua +46 -0
  112. package/engine/internal/unit/bonus.d.ts +17 -8
  113. package/engine/internal/unit/bonus.lua +56 -4
  114. package/engine/internal/unit/detach-missiles.d.ts +7 -0
  115. package/engine/internal/unit/detach-missiles.lua +30 -0
  116. package/engine/internal/unit/fly-height.d.ts +7 -0
  117. package/engine/internal/unit/fly-height.lua +20 -0
  118. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  119. package/engine/internal/unit/ignore-events-items.lua +5 -0
  120. package/engine/internal/unit/interrupts.d.ts +12 -0
  121. package/engine/internal/unit/interrupts.lua +28 -0
  122. package/engine/internal/unit/item.d.ts +24 -0
  123. package/engine/internal/unit/item.lua +78 -0
  124. package/engine/internal/unit/main-selected.d.ts +13 -0
  125. package/engine/internal/unit/main-selected.lua +36 -0
  126. package/engine/internal/unit/order.d.ts +20 -0
  127. package/engine/internal/unit/order.lua +136 -0
  128. package/engine/internal/unit/range-event.d.ts +12 -0
  129. package/engine/internal/unit/range-event.lua +90 -0
  130. package/engine/internal/unit/scale.d.ts +7 -0
  131. package/engine/internal/unit/scale.lua +20 -0
  132. package/engine/internal/unit+ability.lua +12 -3
  133. package/engine/internal/unit+bonus.lua +3 -3
  134. package/engine/internal/unit+damage.d.ts +2 -11
  135. package/engine/internal/unit+damage.lua +10 -14
  136. package/engine/internal/unit+spellSteal.lua +1 -2
  137. package/engine/internal/unit+transport.lua +4 -10
  138. package/engine/internal/unit-missile-launch.lua +70 -13
  139. package/engine/internal/unit.d.ts +97 -36
  140. package/engine/internal/unit.lua +701 -336
  141. package/engine/internal/utility.lua +12 -0
  142. package/engine/lightning.d.ts +12 -5
  143. package/engine/lightning.lua +48 -14
  144. package/engine/local-client.d.ts +14 -2
  145. package/engine/local-client.lua +168 -1
  146. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  147. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  148. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  149. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  150. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -3
  151. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  152. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  153. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  154. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  155. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  156. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  157. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  158. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  159. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  160. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  161. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  162. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  163. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  164. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  165. package/engine/object-data/entry/ability-type/{armor-increase.d.ts → armor-bonus.d.ts} +3 -3
  166. package/engine/object-data/entry/ability-type/{armor-increase.lua → armor-bonus.lua} +9 -9
  167. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  168. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  169. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  170. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  171. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  172. package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
  173. package/engine/object-data/entry/ability-type/blink.lua +39 -0
  174. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  175. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  176. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  177. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  178. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  179. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  180. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  181. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  182. package/engine/object-data/entry/ability-type/health-bonus.d.ts +8 -0
  183. package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
  184. package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
  185. package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
  186. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  187. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  188. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  189. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  190. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  191. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  192. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  193. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  194. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  195. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  196. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  197. package/engine/object-data/entry/ability-type/reincarnation.d.ts +8 -0
  198. package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
  199. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  200. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  201. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  202. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  203. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  204. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  205. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  206. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  207. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  208. package/engine/object-data/entry/ability-type/web.lua +52 -0
  209. package/engine/object-data/entry/ability-type.d.ts +21 -18
  210. package/engine/object-data/entry/ability-type.lua +177 -40
  211. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  212. package/engine/object-data/entry/buff-type/applicable.lua +143 -202
  213. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  214. package/engine/object-data/entry/buff-type.d.ts +6 -13
  215. package/engine/object-data/entry/buff-type.lua +13 -29
  216. package/engine/object-data/entry/destructible-type.d.ts +28 -3
  217. package/engine/object-data/entry/destructible-type.lua +155 -0
  218. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  219. package/engine/object-data/entry/item-type.d.ts +15 -2
  220. package/engine/object-data/entry/item-type.lua +93 -2
  221. package/engine/object-data/entry/lightning-type.d.ts +1 -2
  222. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  223. package/engine/object-data/entry/sound-preset.lua +140 -0
  224. package/engine/object-data/entry/unit-type.d.ts +65 -5
  225. package/engine/object-data/entry/unit-type.lua +555 -62
  226. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  227. package/engine/object-data/entry/upgrade.d.ts +1 -2
  228. package/engine/object-data/entry/upgrade.lua +4 -4
  229. package/engine/object-data/entry.d.ts +18 -17
  230. package/engine/object-data/entry.lua +60 -32
  231. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  232. package/engine/object-field/ability.d.ts +28 -5
  233. package/engine/object-field/ability.lua +61 -7
  234. package/engine/object-field/item.d.ts +22 -0
  235. package/engine/object-field/item.lua +118 -0
  236. package/engine/object-field/unit.d.ts +72 -3
  237. package/engine/object-field/unit.lua +268 -7
  238. package/engine/object-field.d.ts +26 -8
  239. package/engine/object-field.lua +362 -117
  240. package/engine/random.d.ts +11 -0
  241. package/engine/random.lua +30 -0
  242. package/engine/standard/entries/buff-type.d.ts +3 -0
  243. package/engine/standard/entries/buff-type.lua +3 -0
  244. package/engine/standard/entries/sound-preset.d.ts +10 -0
  245. package/engine/standard/entries/sound-preset.lua +10 -0
  246. package/engine/standard/entries/unit-type.d.ts +42 -1
  247. package/engine/standard/entries/unit-type.lua +42 -1
  248. package/engine/standard/fields/ability.d.ts +5 -3
  249. package/engine/standard/fields/ability.lua +5 -3
  250. package/engine/standard/fields/item.d.ts +4 -0
  251. package/engine/standard/fields/item.lua +6 -0
  252. package/engine/standard/fields/unit.d.ts +12 -0
  253. package/engine/standard/fields/unit.lua +20 -0
  254. package/engine/synchronization.d.ts +11 -0
  255. package/engine/synchronization.lua +77 -0
  256. package/engine/text-tag.d.ts +36 -2
  257. package/engine/text-tag.lua +250 -10
  258. package/engine/unit.d.ts +10 -0
  259. package/engine/unit.lua +19 -2
  260. package/event.d.ts +2 -3
  261. package/event.lua +9 -5
  262. package/global/vec2.lua +1 -0
  263. package/index.d.ts +1 -0
  264. package/index.lua +1 -0
  265. package/lualib_bundle.lua +147 -43
  266. package/math/vec2.d.ts +2 -9
  267. package/math.d.ts +2 -2
  268. package/math.lua +14 -0
  269. package/net/socket.d.ts +7 -1
  270. package/net/socket.lua +45 -4
  271. package/network.d.ts +1 -0
  272. package/network.lua +3 -2
  273. package/objutil/ability.d.ts +0 -1
  274. package/objutil/buff.d.ts +0 -1
  275. package/objutil/buff.lua +12 -11
  276. package/objutil/object.d.ts +0 -1
  277. package/objutil/object.lua +1 -1
  278. package/objutil/unit.d.ts +0 -1
  279. package/objutil/unit.lua +8 -0
  280. package/operation.lua +1 -4
  281. package/package.json +13 -14
  282. package/patch-lua.d.ts +0 -0
  283. package/patch-lua.lua +25 -0
  284. package/patch-lualib.lua +1 -1
  285. package/property.d.ts +55 -0
  286. package/property.lua +374 -0
  287. package/string.d.ts +30 -0
  288. package/string.lua +14 -0
  289. package/util/stream.d.ts +0 -1
  290. package/utility/arrays.d.ts +13 -5
  291. package/utility/arrays.lua +45 -3
  292. package/utility/bit-set.d.ts +0 -2
  293. package/utility/callback-array.d.ts +17 -0
  294. package/utility/callback-array.lua +61 -0
  295. package/utility/functions.d.ts +8 -0
  296. package/utility/functions.lua +13 -0
  297. package/utility/lazy.d.ts +2 -0
  298. package/utility/lazy.lua +14 -0
  299. package/utility/linked-map.d.ts +35 -0
  300. package/utility/linked-map.lua +107 -0
  301. package/utility/linked-set.d.ts +16 -4
  302. package/utility/linked-set.lua +54 -3
  303. package/utility/lua-maps.d.ts +16 -4
  304. package/utility/lua-maps.lua +53 -2
  305. package/utility/lua-sets.d.ts +3 -2
  306. package/utility/lua-sets.lua +7 -0
  307. package/utility/records.lua +20 -1
  308. package/utility/reflection.lua +11 -7
  309. package/utility/types.d.ts +6 -2
  310. package/utility/unordered-map.d.ts +27 -0
  311. package/utility/unordered-map.lua +99 -0
  312. package/core/mapbounds.d.ts +0 -8
  313. package/core/mapbounds.lua +0 -12
  314. package/core/types/order.d.ts +0 -25
  315. package/core/types/order.lua +0 -55
  316. /package/engine/internal/{object-data/armor-increase.d.ts → mechanics/cast-ability.d.ts} +0 -0
  317. /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
  318. /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
  319. /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
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 = {}
@@ -91,14 +103,20 @@ local buffParametersKeys = {
91
103
  damageIncrease = true,
92
104
  damageIncreaseFactor = true,
93
105
  armorIncrease = true,
94
- armorIncreaseFactor = true,
106
+ maxHealthIncrease = true,
107
+ maxManaIncrease = true,
95
108
  attackSpeedIncreaseFactor = true,
96
109
  movementSpeedIncreaseFactor = true,
110
+ manaRegenerationRateIncreaseFactor = true,
111
+ evasionProbability = true,
112
+ missProbability = true,
113
+ damageFactor = true,
97
114
  receivedDamageFactor = true,
98
115
  receivedMagicDamageFactor = true,
99
116
  durationIncreaseOnAutoAttack = true,
100
117
  maximumDuration = true,
101
118
  maximumRemainingDuration = true,
119
+ turnsIntoGhost = true,
102
120
  stuns = true,
103
121
  ignoresStunImmunity = true,
104
122
  providesStunImmunity = true,
@@ -107,8 +125,30 @@ local buffParametersKeys = {
107
125
  disablesAutoAttack = true,
108
126
  destroysOnDamage = true,
109
127
  maximumAutoAttackCount = true,
110
- uniqueGroup = true
128
+ maximumDamageDealtEventCount = true,
129
+ maximumDamageReceivedEventCount = true,
130
+ absorbedDamageFactor = true,
131
+ maximumDamageAbsorbed = true,
132
+ destroysOnMaximumDamageAbsorbed = true,
133
+ uniqueGroup = true,
134
+ damageOnExpiration = true,
135
+ healingOnExpiration = true,
136
+ killsOnExpiration = true,
137
+ explodesOnExpiration = true,
138
+ abilityCooldownFactor = true
111
139
  }
140
+ local function resolveEnumValue(ability, level, value)
141
+ if value == nil or type(value) == "number" then
142
+ return value
143
+ end
144
+ if ability == nil then
145
+ error(
146
+ __TS__New(IllegalArgumentException),
147
+ 0
148
+ )
149
+ end
150
+ return value:getValue(ability, level or ability.level)
151
+ end
112
152
  local function resolveNumberValue(ability, level, value)
113
153
  if value == nil or type(value) == "number" then
114
154
  return value
@@ -145,20 +185,41 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
145
185
  buff[property] = resolvedValue
146
186
  end
147
187
  end
148
- local buffBooleanParameters = {"stuns", "ignoresStunImmunity", "disablesAutoAttack", "providesInvulnerability"}
188
+ local buffBooleanParameters = {
189
+ "destroysOnMaximumDamageAbsorbed",
190
+ "turnsIntoGhost",
191
+ "stuns",
192
+ "ignoresStunImmunity",
193
+ "disablesAutoAttack",
194
+ "providesInvulnerability",
195
+ "killsOnExpiration",
196
+ "explodesOnExpiration"
197
+ }
149
198
  local buffNumberParameters = {
150
199
  "durationIncreaseOnAutoAttack",
151
200
  "attackSpeedIncreaseFactor",
152
201
  "movementSpeedIncreaseFactor",
202
+ "manaRegenerationRateIncreaseFactor",
203
+ "evasionProbability",
153
204
  "armorIncrease",
205
+ "maxHealthIncrease",
206
+ "maxManaIncrease",
207
+ "damageFactor",
154
208
  "receivedDamageFactor",
155
209
  "maximumAutoAttackCount",
210
+ "maximumDamageDealtEventCount",
211
+ "maximumDamageReceivedEventCount",
156
212
  "damageInterval",
157
213
  "damagePerInterval",
158
214
  "damageOverDuration",
159
215
  "healingInterval",
160
216
  "healingPerInterval",
161
- "healingOverDuration"
217
+ "healingOverDuration",
218
+ "damageOnExpiration",
219
+ "healingOnExpiration",
220
+ "absorbedDamageFactor",
221
+ "maximumDamageAbsorbed",
222
+ "abilityCooldownFactor"
162
223
  }
163
224
  local unsuccessfulApplicationMarker = {}
164
225
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -185,7 +246,7 @@ local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
185
246
  return checkNotNull(firstNativeBuffTypeId)
186
247
  end
187
248
  local function destroyBuffIfItHasSameUniqueGroup(buff, uniqueGroup)
188
- if buff[103] == uniqueGroup then
249
+ if buff[104] == uniqueGroup then
189
250
  buff:destroy()
190
251
  end
191
252
  end
@@ -193,73 +254,76 @@ local function destroyBuff(buff)
193
254
  buff:destroy()
194
255
  end
195
256
  local function expireBuff(buff)
196
- local remainingDamageOverDuration = buff[112] or 0
197
- local remainingHealingOverDuration = buff[112] or 0
257
+ local remainingDamageOverDuration = buff[113] or 0
258
+ local remainingHealingOverDuration = buff[113] or 0
198
259
  if remainingDamageOverDuration ~= 0 or remainingHealingOverDuration ~= 0 then
199
260
  buff:flashSpecialEffect()
200
261
  if remainingDamageOverDuration ~= 0 then
201
- (buff[101] or buff[100]):damageTarget(buff[100], remainingDamageOverDuration)
202
- buff[112] = nil
262
+ (buff[102] or buff[101]):damageTarget(buff[101], remainingDamageOverDuration)
263
+ buff[113] = nil
203
264
  end
204
265
  if remainingHealingOverDuration ~= 0 then
205
- (buff[101] or buff[100]):healTarget(buff[100], remainingHealingOverDuration)
206
- buff[117] = nil
266
+ (buff[102] or buff[101]):healTarget(buff[101], remainingHealingOverDuration)
267
+ buff[118] = nil
207
268
  end
208
269
  end
209
270
  Timer:run(destroyBuff, buff)
271
+ buff:onExpiration()
210
272
  end
211
273
  local function buffDamageIntervalInitialTimerCallback(buff)
212
274
  buffDamageIntervalTimerCallback(buff)
213
- local timer = buff[113]
214
- local damageInterval = buff[111]
275
+ local timer = buff[114]
276
+ local damageInterval = buff[112]
215
277
  if timer ~= nil and damageInterval ~= nil and damageInterval > 0 then
216
278
  timer:start(damageInterval, true, buffDamageIntervalTimerCallback, buff)
217
279
  end
218
280
  end
219
281
  buffDamageIntervalTimerCallback = function(buff)
220
282
  buff:flashSpecialEffect()
221
- local source = buff[101] or buff[100]
222
- local remainingDamageOverDuration = buff[112] or 0
283
+ local source = buff[102] or buff[101]
284
+ local remainingDamageOverDuration = buff[113] or 0
223
285
  if remainingDamageOverDuration ~= 0 then
224
- local damageInterval = buff[111] or 0
286
+ local damageInterval = buff[112] or 0
225
287
  if damageInterval ~= 0 then
226
288
  local damage = remainingDamageOverDuration / (1 + buff.remainingDuration / damageInterval)
227
- source:damageTarget(buff[100], damage)
228
- buff[112] = remainingDamageOverDuration - damage
289
+ source:damageTarget(buff[101], damage)
290
+ buff[113] = remainingDamageOverDuration - damage
229
291
  end
230
292
  end
231
- local damagePerInterval = buff[110] or 0
293
+ local damagePerInterval = buff[111] or 0
232
294
  if remainingDamageOverDuration == 0 or damagePerInterval ~= 0 then
233
- source:damageTarget(buff[100], damagePerInterval)
295
+ source:damageTarget(buff[101], damagePerInterval)
234
296
  end
235
297
  end
236
298
  local function buffHealingIntervalInitialTimerCallback(buff)
237
299
  buffHealingIntervalTimerCallback(buff)
238
- local timer = buff[118]
239
- local healingInterval = buff[116]
300
+ local timer = buff[119]
301
+ local healingInterval = buff[117]
240
302
  if timer ~= nil and healingInterval ~= nil and healingInterval > 0 then
241
303
  timer:start(healingInterval, true, buffHealingIntervalTimerCallback, buff)
242
304
  end
243
305
  end
244
306
  buffHealingIntervalTimerCallback = function(buff)
245
- if buff[116] ~= buff[111] then
307
+ if buff[117] ~= buff[112] then
246
308
  buff:flashSpecialEffect()
247
309
  end
248
- local source = buff[101] or buff[100]
249
- local remainingHealingOverDuration = buff[117] or 0
310
+ local source = buff[102] or buff[101]
311
+ local remainingHealingOverDuration = buff[118] or 0
250
312
  if remainingHealingOverDuration ~= 0 then
251
- local healingInterval = buff[116] or 0
313
+ local healingInterval = buff[117] or 0
252
314
  if healingInterval ~= 0 then
253
315
  local healing = remainingHealingOverDuration / (1 + buff.remainingDuration / healingInterval)
254
- source:healTarget(buff[100], healing)
255
- buff[117] = remainingHealingOverDuration - healing
316
+ source:healTarget(buff[101], healing)
317
+ buff[118] = remainingHealingOverDuration - healing
256
318
  end
257
319
  end
258
- local healingPerInterval = buff[115] or 0
320
+ local healingPerInterval = buff[116] or 0
259
321
  if remainingHealingOverDuration == 0 or healingPerInterval ~= 0 then
260
- source:healTarget(buff[100], healingPerInterval)
322
+ source:healTarget(buff[101], healingPerInterval)
261
323
  end
262
324
  end
325
+ local buffCreatedEvent = __TS__New(Event)
326
+ local buffBeingDestroyedEvent = __TS__New(Event)
263
327
  ____exports.Buff = __TS__Class()
264
328
  local Buff = ____exports.Buff
265
329
  Buff.name = "Buff"
@@ -268,40 +332,44 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
268
332
  UnitBehavior.prototype.____constructor(self, _unit)
269
333
  self._unit = _unit
270
334
  self.parameters = nil
271
- self[100] = _unit
335
+ self[100] = 0
336
+ self[101] = _unit
272
337
  local typeId
273
338
  local polarity
274
339
  local resistanceType
275
340
  local ability
341
+ local abilityBehavior
276
342
  if type(typeIdOrTypeIds) ~= "number" then
277
343
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
278
344
  polarity = resistanceTypeOrPolarity
279
345
  resistanceType = abilityOrParametersOrResistanceType
280
- if __TS__InstanceOf(parametersOrAbility, Ability) then
346
+ if __TS__InstanceOf(parametersOrAbility, AbilityBehavior) then
347
+ abilityBehavior = parametersOrAbility
348
+ ability = abilityBehavior.ability
349
+ elseif __TS__InstanceOf(parametersOrAbility, Ability) then
281
350
  ability = parametersOrAbility
282
- else
283
- ability = nil
351
+ elseif parametersOrAbility ~= nil then
284
352
  parameters = parametersOrAbility
285
353
  end
286
354
  else
287
355
  typeId = typeIdOrTypeIds
288
356
  polarity = polarityOrTypeIdSelectionPolicy
289
357
  resistanceType = resistanceTypeOrPolarity
290
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
358
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, AbilityBehavior) then
359
+ abilityBehavior = abilityOrParametersOrResistanceType
360
+ ability = abilityBehavior.ability
361
+ parameters = parametersOrAbility
362
+ elseif __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
291
363
  ability = abilityOrParametersOrResistanceType
292
364
  parameters = parametersOrAbility
293
- else
294
- ability = nil
365
+ elseif abilityOrParametersOrResistanceType ~= nil then
295
366
  parameters = abilityOrParametersOrResistanceType
367
+ else
368
+ parameters = parametersOrAbility
296
369
  end
297
370
  end
371
+ self.sourceAbilityBehavior = abilityBehavior
298
372
  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
373
  local defaultParameters = self.constructor.defaultParameters
306
374
  local level = parameters and parameters.level or defaultParameters.level
307
375
  local spellStealPriority = parameters and parameters.spellStealPriority or defaultParameters.spellStealPriority
@@ -324,14 +392,22 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
324
392
  learnLevelMinimum = learnLevelMinimum or ability:getField(ABILITY_IF_REQUIRED_LEVEL)
325
393
  duration = duration or getAbilityDuration(ability, _unit)
326
394
  end
395
+ self.polarity = resolveEnumValue(ability, level, polarity)
396
+ self.resistanceType = resolveEnumValue(ability, level, resistanceType)
397
+ local missProbability = parameters and parameters.missProbability or defaultParameters.missProbability
398
+ if missProbability ~= nil then
399
+ missProbability = resolveNumberValue(ability, level, missProbability)
400
+ self[146] = missProbability
401
+ end
327
402
  local buffByTypeId = buffByTypeIdByUnit[_unit]
328
403
  if buffByTypeId == nil then
329
404
  buffByTypeId = {}
330
405
  buffByTypeIdByUnit[_unit] = buffByTypeId
331
406
  end
332
- local ____opt_13 = buffByTypeId[typeId]
333
- if ____opt_13 ~= nil then
334
- ____opt_13:destroy()
407
+ self.previousBuff = buffByTypeId[typeId]
408
+ local ____opt_15 = self.previousBuff
409
+ if ____opt_15 ~= nil then
410
+ ____opt_15:destroy()
335
411
  end
336
412
  local uniqueGroup = parameters and parameters.uniqueGroup or defaultParameters and defaultParameters.uniqueGroup
337
413
  if uniqueGroup ~= nil then
@@ -340,18 +416,21 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
340
416
  if not internalApplyBuff(
341
417
  _unit,
342
418
  typeId,
343
- polarity,
344
- resistanceType,
419
+ self.polarity,
420
+ self.resistanceType,
345
421
  level,
346
422
  duration,
347
423
  spellStealPriority,
348
- learnLevelMinimum
424
+ learnLevelMinimum,
425
+ missProbability
349
426
  ) then
427
+ self[100] = 1
350
428
  UnitBehavior.prototype.destroy(self)
351
429
  error(unsuccessfulApplicationMarker, 0)
352
430
  end
353
431
  local handle = BlzGetUnitAbility(_unit.handle, typeId)
354
432
  if handle == nil then
433
+ self[100] = 1
355
434
  UnitBehavior.prototype.destroy(self)
356
435
  error(unsuccessfulApplicationMarker, 0)
357
436
  end
@@ -360,20 +439,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
360
439
  self._level = level
361
440
  self._spellStealPriority = spellStealPriority
362
441
  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)
442
+ self[102] = source
443
+ self[103] = duration or 0
444
+ self[104] = uniqueGroup
445
+ self[105] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_EFFECT, 0)
446
+ self[106] = BlzGetAbilityStringLevelField(self.handle, ABILITY_SLF_SPECIAL, 0)
368
447
  if parameters ~= nil or (next(defaultParameters)) ~= nil then
369
448
  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]
449
+ local ____ability_24 = ability
450
+ local ____level_25 = level
451
+ local ____temp_23 = parameters and parameters[buffBooleanParameter]
452
+ if ____temp_23 == nil then
453
+ ____temp_23 = defaultParameters[buffBooleanParameter]
375
454
  end
376
- if resolveBooleanValue(____ability_22, ____level_23, ____temp_21) then
455
+ if resolveBooleanValue(____ability_24, ____level_25, ____temp_23) then
377
456
  self[buffBooleanParameter] = true
378
457
  end
379
458
  end
@@ -389,11 +468,11 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
389
468
  end
390
469
  local maximumDuration = parameters and parameters.maximumDuration or defaultParameters.maximumDuration
391
470
  if maximumDuration ~= nil then
392
- self[107] = resolveNumberValue(ability, level, maximumDuration)
471
+ self[108] = resolveNumberValue(ability, level, maximumDuration)
393
472
  end
394
473
  local maximumRemainingDuration = parameters and parameters.maximumRemainingDuration or defaultParameters.maximumRemainingDuration
395
474
  if maximumRemainingDuration ~= nil then
396
- self[108] = resolveNumberValue(ability, level, maximumRemainingDuration)
475
+ self[109] = resolveNumberValue(ability, level, maximumRemainingDuration)
397
476
  end
398
477
  local parametersAbilityTypeIds = parameters and parameters.abilityTypeIds or defaultParameters.abilityTypeIds
399
478
  if parametersAbilityTypeIds ~= nil then
@@ -402,24 +481,22 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
402
481
  abilityTypeIds = {}
403
482
  self._abilityTypeIds = abilityTypeIds
404
483
  end
405
- for abilityTypeId, abilityParameters in pairs(parametersAbilityTypeIds) do
484
+ for ____, abilityTypeId in ipairs(sortedKeysUnnested(parametersAbilityTypeIds)) do
485
+ local abilityParameters = parametersAbilityTypeIds[abilityTypeId]
406
486
  local addedAbility = _unit:addAbility(abilityTypeId)
407
487
  if addedAbility ~= nil then
408
488
  _unit:makeAbilityPermanent(abilityTypeId, true)
409
489
  _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
490
+ if abilityParameters.isButtonVisible == false then
491
+ _unit:hideAbility(abilityTypeId, true)
421
492
  end
422
- abilityTypeIds[abilityTypeId] = true
493
+ for ____, field in ipairs(abilityParameters.fields or emptyArray()) do
494
+ field[1]:setValue(
495
+ addedAbility,
496
+ resolveNumberValue(ability, level, field[2])
497
+ )
498
+ end
499
+ abilityTypeIds[#abilityTypeIds + 1] = abilityTypeId
423
500
  end
424
501
  end
425
502
  local behaviorConstructors = parameters and parameters.behaviorConstructors or defaultParameters.behaviorConstructors
@@ -431,18 +508,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
431
508
  self._behaviors = behaviors
432
509
  end
433
510
  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
511
+ if parameters ~= nil then
512
+ local additionalParameters = {}
513
+ for ____, key in ipairs(sortedKeysUnnested(parameters)) do
514
+ if not buffParametersKeys[key] then
515
+ if ability then
516
+ additionalParameters[key] = resolveCurrentAbilityDependentValue(ability, parameters[key])
517
+ else
518
+ additionalParameters[key] = parameters[key]
519
+ end
441
520
  end
442
521
  end
443
- end
444
- if (next(additionalParameters)) ~= nil then
445
- self.parameters = additionalParameters
522
+ if (next(additionalParameters)) ~= nil then
523
+ self.parameters = additionalParameters
524
+ end
446
525
  end
447
526
  end
448
527
  if duration ~= nil and duration > 0 then
@@ -450,77 +529,87 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
450
529
  timer:start(duration, false, expireBuff, self)
451
530
  self._timer = timer
452
531
  end
532
+ self:onCreate()
533
+ self[100] = 1
534
+ Event.invoke(buffCreatedEvent, self)
453
535
  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)
458
- 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
536
+ function Buff.prototype.onAbilityGained(self, ability)
537
+ if __TS__InstanceOf(ability, UnitAbility) then
538
+ local abilityCooldownModifier = self[148]
539
+ if abilityCooldownModifier then
540
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
541
+ end
464
542
  end
465
- bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
466
543
  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
479
- else
480
- ____isWidgetProvided_38 = widgetOrDuration
544
+ function Buff.prototype.onAbilityLost(self, ability)
545
+ if __TS__InstanceOf(ability, UnitAbility) then
546
+ local abilityCooldownModifier = self[148]
547
+ if abilityCooldownModifier then
548
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
549
+ end
481
550
  end
482
- __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
483
- ____Effect_flash_41(
484
- ____Effect_40,
485
- __TS__SparseArraySpread(____array_39)
486
- )
487
551
  end
488
- function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
489
- local isWidgetProvided = type(widgetOrDuration) == "table"
490
- local ____Effect_44 = Effect
491
- local ____Effect_flash_45 = Effect.flash
492
- local ____array_43 = __TS__SparseArrayNew(
552
+ function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
553
+ self:flash(
493
554
  self[105],
494
- isWidgetProvided and widgetOrDuration or self._unit,
495
- stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
555
+ stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin",
556
+ widgetOrXOrParametersOrDuration,
557
+ yOrParametersOrDuration,
558
+ parametersOrDuration
559
+ )
560
+ end
561
+ function Buff.prototype.flashSpecialEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
562
+ self:flash(
563
+ self[106],
564
+ stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin",
565
+ widgetOrXOrParametersOrDuration,
566
+ yOrParametersOrDuration,
567
+ parametersOrDuration
496
568
  )
497
- local ____isWidgetProvided_42
498
- if isWidgetProvided then
499
- ____isWidgetProvided_42 = duration
569
+ end
570
+ function Buff.prototype.flash(self, modelPath, attachmentPoint, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
571
+ if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
572
+ Effect:flash(modelPath, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
500
573
  else
501
- ____isWidgetProvided_42 = widgetOrDuration
574
+ local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
575
+ local ____Effect_40 = Effect
576
+ local ____Effect_flash_41 = Effect.flash
577
+ local ____array_39 = __TS__SparseArrayNew(modelPath, isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit, attachmentPoint)
578
+ local ____isWidgetProvided_38
579
+ if isWidgetProvided then
580
+ ____isWidgetProvided_38 = yOrParametersOrDuration
581
+ else
582
+ ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
583
+ end
584
+ __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
585
+ ____Effect_flash_41(
586
+ ____Effect_40,
587
+ __TS__SparseArraySpread(____array_39)
588
+ )
502
589
  end
503
- __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
504
- ____Effect_flash_45(
505
- ____Effect_44,
506
- __TS__SparseArraySpread(____array_43)
507
- )
590
+ end
591
+ function Buff.prototype.expire(self)
592
+ expireBuff(self)
593
+ end
594
+ function Buff.prototype.onCreate(self)
508
595
  end
509
596
  function Buff.prototype.onDestroy(self)
597
+ check(self[100] ~= 0, "Cannot destroy a buff that has not finished creating yet.")
598
+ self[100] = 2
510
599
  local unit = self._unit
511
600
  if getUnitAbility(unit.handle, self.typeId) == self.handle then
512
601
  removeBuff(unit.handle, self.typeId)
513
602
  end
514
603
  buffByTypeIdByUnit[unit][self.typeId] = nil
515
- local healingIntervalTimer = self[118]
604
+ local healingIntervalTimer = self[119]
516
605
  if healingIntervalTimer ~= nil then
517
606
  healingIntervalTimer:destroy()
518
- self[118] = nil
607
+ self[119] = nil
519
608
  end
520
- local damageIntervalTimer = self[113]
609
+ local damageIntervalTimer = self[114]
521
610
  if damageIntervalTimer ~= nil then
522
611
  damageIntervalTimer:destroy()
523
- self[113] = nil
612
+ self[114] = nil
524
613
  end
525
614
  if self._timer ~= nil then
526
615
  self._timer:destroy()
@@ -530,25 +619,34 @@ function Buff.prototype.onDestroy(self)
530
619
  behavior:destroy()
531
620
  end
532
621
  end
533
- if self[130] then
622
+ local previousAbilityCooldownModifier = self[148]
623
+ if previousAbilityCooldownModifier then
624
+ for ____, ability in ipairs(self._unit.abilities) do
625
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
626
+ end
627
+ end
628
+ if self[143] then
629
+ unit:decrementInvulnerabilityCounter()
630
+ end
631
+ if self[142] then
534
632
  unit:decrementDisableAutoAttackCounter()
535
633
  end
536
- if self[128] then
537
- if self[129] then
538
- unit:decrementStunCounter()
634
+ if self[140] then
635
+ if self[141] then
636
+ unit:decrementForceStunCounter()
539
637
  end
540
638
  unit:decrementStunCounter()
541
639
  end
640
+ if self[139] then
641
+ unit:decrementGhostCounter()
642
+ end
542
643
  if self._abilityTypeIds ~= nil then
543
- for abilityTypeId in pairs(self._abilityTypeIds) do
644
+ for ____, abilityTypeId in ipairs(self._abilityTypeIds) do
544
645
  unit:removeAbility(abilityTypeId)
545
646
  end
546
647
  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
648
+ Event.invoke(buffBeingDestroyedEvent, self)
649
+ self[100] = 3
552
650
  return UnitBehavior.prototype.onDestroy(self)
553
651
  end
554
652
  function Buff.apply(self, ...)
@@ -576,51 +674,93 @@ function Buff.apply(self, ...)
576
674
  end
577
675
  end
578
676
  function Buff.getByTypeId(self, unit, typeId)
579
- local ____opt_46 = buffByTypeIdByUnit[unit]
580
- local buff = ____opt_46 and ____opt_46[typeId]
677
+ local ____opt_42 = buffByTypeIdByUnit[unit]
678
+ local buff = ____opt_42 and ____opt_42[typeId]
581
679
  if __TS__InstanceOf(buff, self) then
582
680
  return buff
583
681
  end
584
682
  return nil
585
683
  end
684
+ function Buff.prototype.onExpiration(self)
685
+ local unit = self.unit
686
+ if self[120] ~= nil then
687
+ (self[102] or unit):damageTarget(unit, self[120] or 0)
688
+ end
689
+ if self[121] ~= nil then
690
+ (self[102] or unit):healTarget(unit, self[120] or 0)
691
+ end
692
+ if self[145] then
693
+ unit:explode()
694
+ elseif self[144] then
695
+ unit:kill()
696
+ end
697
+ end
586
698
  function Buff.prototype.onDeath(self, source)
587
699
  local unit = self.unit
588
- if self[119] ~= nil then
700
+ if self[122] ~= nil then
589
701
  damageArea(
590
- self[101] or unit,
591
- self[119],
702
+ self[102] or unit,
703
+ self[122],
592
704
  unit.x,
593
705
  unit.y,
594
- self[121] or 0,
595
- self[120] or 0,
706
+ self[124] or 0,
596
707
  self[123] or 0,
597
- self[122] or 0,
708
+ self[126] or 0,
598
709
  self[125] or 0,
599
- self[124] or 0
710
+ self[128] or 0,
711
+ self[127] or 0
600
712
  )
601
713
  end
602
714
  end
603
715
  function Buff.prototype.onDamageDealt(self, target, event)
604
716
  if event.isAttack then
605
- if self[106] ~= nil then
606
- local durationIncrease = self[106]
607
- local maximumDuration = self[107] or 0
717
+ if self[107] ~= nil then
718
+ local durationIncrease = self[107]
719
+ local maximumDuration = self[108] or 0
608
720
  if maximumDuration > 0 then
609
721
  durationIncrease = min(
610
722
  durationIncrease,
611
- max(0, maximumDuration - self[102])
723
+ max(0, maximumDuration - self[103])
612
724
  )
613
725
  end
614
726
  local remainingDuration = self.remainingDuration + durationIncrease
615
- local maximumRemainingDuration = self[108] or 0
727
+ local maximumRemainingDuration = self[109] or 0
616
728
  if maximumRemainingDuration > 0 then
617
729
  remainingDuration = min(remainingDuration, maximumRemainingDuration)
618
730
  end
619
731
  self.remainingDuration = remainingDuration
620
732
  end
621
- local autoAttackCount = (self[126] or 0) + 1
622
- self[126] = autoAttackCount
623
- if autoAttackCount == self[127] then
733
+ local autoAttackCount = (self[129] or 0) + 1
734
+ self[129] = autoAttackCount
735
+ if autoAttackCount == self[130] then
736
+ self:destroy()
737
+ end
738
+ end
739
+ if event.originalAmount ~= 0 then
740
+ local damageDealtEventCount = (self[131] or 0) + 1
741
+ self[131] = damageDealtEventCount
742
+ if damageDealtEventCount == self[132] then
743
+ self:destroy()
744
+ end
745
+ end
746
+ end
747
+ function Buff.prototype.onDamageReceived(self, source, event)
748
+ if event.originalAmount ~= 0 then
749
+ local absorbedDamage = min(event.amount * (self[135] or 1), (self[136] or 0) - (self[137] or 0))
750
+ if absorbedDamage > 0 then
751
+ event.amount = event.amount - absorbedDamage
752
+ self[137] = (self[137] or 0) + absorbedDamage
753
+ local ____self__138_44 = self[138]
754
+ if ____self__138_44 == nil then
755
+ ____self__138_44 = true
756
+ end
757
+ if ____self__138_44 and self[137] >= (self[136] or 0) then
758
+ self:destroy()
759
+ end
760
+ end
761
+ local damageReceivedEventCount = (self[133] or 0) + 1
762
+ self[133] = damageReceivedEventCount
763
+ if damageReceivedEventCount == self[134] then
624
764
  self:destroy()
625
765
  end
626
766
  end
@@ -630,7 +770,7 @@ __TS__SetDescriptor(
630
770
  Buff.prototype,
631
771
  "source",
632
772
  {get = function(self)
633
- return self[101] or self._unit
773
+ return self[102] or self._unit
634
774
  end},
635
775
  true
636
776
  )
@@ -647,13 +787,13 @@ __TS__SetDescriptor(
647
787
  "remainingDamageOverDuration",
648
788
  {
649
789
  get = function(self)
650
- return self[112] or 0
790
+ return self[113] or 0
651
791
  end,
652
792
  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
793
+ local remainingDamageOverDurationDelta = remainingDamageOverDuration - (self[113] or 0)
794
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
795
+ local damageOverDuration = (self[110] or 0) + remainingDamageOverDurationDelta
796
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
657
797
  end
658
798
  },
659
799
  true
@@ -663,13 +803,13 @@ __TS__SetDescriptor(
663
803
  "damageOverDuration",
664
804
  {
665
805
  get = function(self)
666
- return self[109] or 0
806
+ return self[110] or 0
667
807
  end,
668
808
  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
809
+ local damageOverDurationDelta = damageOverDuration - (self[110] or 0)
810
+ self[110] = damageOverDuration ~= 0 and damageOverDuration or nil
811
+ local remainingDamageOverDuration = (self[113] or 0) + damageOverDurationDelta
812
+ self[113] = remainingDamageOverDuration ~= 0 and remainingDamageOverDuration or nil
673
813
  end
674
814
  },
675
815
  true
@@ -679,10 +819,10 @@ __TS__SetDescriptor(
679
819
  "damagePerInterval",
680
820
  {
681
821
  get = function(self)
682
- return self[110] or 0
822
+ return self[111] or 0
683
823
  end,
684
824
  set = function(self, damagePerInterval)
685
- self[110] = damagePerInterval ~= 0 and damagePerInterval or nil
825
+ self[111] = damagePerInterval ~= 0 and damagePerInterval or nil
686
826
  end
687
827
  },
688
828
  true
@@ -692,25 +832,25 @@ __TS__SetDescriptor(
692
832
  "damageInterval",
693
833
  {
694
834
  get = function(self)
695
- return self[111] or 0
835
+ return self[112] or 0
696
836
  end,
697
837
  set = function(self, damageInterval)
698
838
  if damageInterval <= 0 then
699
- self[111] = damageInterval ~= 0 and damageInterval or nil
700
- local timer = self[113]
839
+ self[112] = damageInterval ~= 0 and damageInterval or nil
840
+ local timer = self[114]
701
841
  if timer ~= nil then
702
842
  timer:destroy()
703
- self[113] = nil
843
+ self[114] = nil
704
844
  end
705
845
  return
706
846
  end
707
- self[111] = damageInterval
708
- local ____opt_48 = self._timer
709
- local elapsed = ____opt_48 and ____opt_48.elapsed or 0
710
- local timer = self[113]
847
+ self[112] = damageInterval
848
+ local ____opt_45 = self._timer
849
+ local elapsed = ____opt_45 and ____opt_45.elapsed or 0
850
+ local timer = self[114]
711
851
  if timer == nil then
712
852
  timer = Timer:create()
713
- self[113] = timer
853
+ self[114] = timer
714
854
  end
715
855
  local initialDelay = damageInterval - (elapsed >= damageInterval and math.fmod(elapsed, damageInterval) or elapsed)
716
856
  if initialDelay == damageInterval then
@@ -727,13 +867,13 @@ __TS__SetDescriptor(
727
867
  "remainingHealingOverDuration",
728
868
  {
729
869
  get = function(self)
730
- return self[117] or 0
870
+ return self[118] or 0
731
871
  end,
732
872
  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
873
+ local remainingHealingOverDurationDelta = remainingHealingOverDuration - (self[118] or 0)
874
+ self[113] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
875
+ local healingOverDuration = (self[115] or 0) + remainingHealingOverDurationDelta
876
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
737
877
  end
738
878
  },
739
879
  true
@@ -743,13 +883,13 @@ __TS__SetDescriptor(
743
883
  "healingOverDuration",
744
884
  {
745
885
  get = function(self)
746
- return self[114] or 0
886
+ return self[115] or 0
747
887
  end,
748
888
  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
889
+ local healingOverDurationDelta = healingOverDuration - (self[115] or 0)
890
+ self[115] = healingOverDuration ~= 0 and healingOverDuration or nil
891
+ local remainingHealingOverDuration = (self[118] or 0) + healingOverDurationDelta
892
+ self[118] = remainingHealingOverDuration ~= 0 and remainingHealingOverDuration or nil
753
893
  end
754
894
  },
755
895
  true
@@ -759,10 +899,10 @@ __TS__SetDescriptor(
759
899
  "healingPerInterval",
760
900
  {
761
901
  get = function(self)
762
- return self[115] or 0
902
+ return self[116] or 0
763
903
  end,
764
904
  set = function(self, healingPerInterval)
765
- self[115] = healingPerInterval ~= 0 and healingPerInterval or nil
905
+ self[116] = healingPerInterval ~= 0 and healingPerInterval or nil
766
906
  end
767
907
  },
768
908
  true
@@ -772,25 +912,25 @@ __TS__SetDescriptor(
772
912
  "healingInterval",
773
913
  {
774
914
  get = function(self)
775
- return self[116] or 0
915
+ return self[117] or 0
776
916
  end,
777
917
  set = function(self, healingInterval)
778
918
  if healingInterval <= 0 then
779
- self[116] = healingInterval ~= 0 and healingInterval or nil
780
- local timer = self[118]
919
+ self[117] = healingInterval ~= 0 and healingInterval or nil
920
+ local timer = self[119]
781
921
  if timer ~= nil then
782
922
  timer:destroy()
783
- self[118] = nil
923
+ self[119] = nil
784
924
  end
785
925
  return
786
926
  end
787
- self[116] = healingInterval
788
- local ____opt_50 = self._timer
789
- local elapsed = ____opt_50 and ____opt_50.elapsed or 0
790
- local timer = self[118]
927
+ self[117] = healingInterval
928
+ local ____opt_47 = self._timer
929
+ local elapsed = ____opt_47 and ____opt_47.elapsed or 0
930
+ local timer = self[119]
791
931
  if timer == nil then
792
932
  timer = Timer:create()
793
- self[118] = timer
933
+ self[119] = timer
794
934
  end
795
935
  local initialDelay = healingInterval - (elapsed >= healingInterval and math.fmod(elapsed, healingInterval) or elapsed)
796
936
  if initialDelay == healingInterval then
@@ -802,6 +942,45 @@ __TS__SetDescriptor(
802
942
  },
803
943
  true
804
944
  )
945
+ __TS__SetDescriptor(
946
+ Buff.prototype,
947
+ "damageOnExpiration",
948
+ {
949
+ get = function(self)
950
+ return self[120] or 0
951
+ end,
952
+ set = function(self, damageOnExpiration)
953
+ self[120] = damageOnExpiration ~= 0 and damageOnExpiration or nil
954
+ end
955
+ },
956
+ true
957
+ )
958
+ __TS__SetDescriptor(
959
+ Buff.prototype,
960
+ "healingOnExpiration",
961
+ {
962
+ get = function(self)
963
+ return self[121] or 0
964
+ end,
965
+ set = function(self, healingOnExpiration)
966
+ self[121] = healingOnExpiration ~= 0 and healingOnExpiration or nil
967
+ end
968
+ },
969
+ true
970
+ )
971
+ __TS__SetDescriptor(
972
+ Buff.prototype,
973
+ "damageFactor",
974
+ {
975
+ get = function(self)
976
+ return self:getUnitBonus(UnitBonusType.DAMAGE_FACTOR)
977
+ end,
978
+ set = function(self, damageFactor)
979
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.DAMAGE_FACTOR, damageFactor)
980
+ end
981
+ },
982
+ true
983
+ )
805
984
  __TS__SetDescriptor(
806
985
  Buff.prototype,
807
986
  "receivedDamageFactor",
@@ -828,30 +1007,79 @@ __TS__SetDescriptor(
828
1007
  },
829
1008
  true
830
1009
  )
1010
+ __TS__SetDescriptor(
1011
+ Buff.prototype,
1012
+ "maxHealthIncrease",
1013
+ {
1014
+ get = function(self)
1015
+ return self:getUnitBonus(UnitBonusType.HEALTH)
1016
+ end,
1017
+ set = function(self, maxHealthIncrease)
1018
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.HEALTH, maxHealthIncrease)
1019
+ end
1020
+ },
1021
+ true
1022
+ )
1023
+ __TS__SetDescriptor(
1024
+ Buff.prototype,
1025
+ "maxManaIncrease",
1026
+ {
1027
+ get = function(self)
1028
+ return self:getUnitBonus(UnitBonusType.MANA)
1029
+ end,
1030
+ set = function(self, maxManaIncrease)
1031
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.MANA, maxManaIncrease)
1032
+ end
1033
+ },
1034
+ true
1035
+ )
1036
+ __TS__SetDescriptor(
1037
+ Buff.prototype,
1038
+ "turnsIntoGhost",
1039
+ {
1040
+ get = function(self)
1041
+ local ____self__139_49 = self[139]
1042
+ if ____self__139_49 == nil then
1043
+ ____self__139_49 = false
1044
+ end
1045
+ return ____self__139_49
1046
+ end,
1047
+ set = function(self, turnsIntoGhost)
1048
+ if not turnsIntoGhost and self[139] then
1049
+ self.object:decrementGhostCounter()
1050
+ self[139] = nil
1051
+ elseif turnsIntoGhost and not self[139] then
1052
+ self.object:incrementGhostCounter()
1053
+ self[139] = true
1054
+ end
1055
+ end
1056
+ },
1057
+ true
1058
+ )
831
1059
  __TS__SetDescriptor(
832
1060
  Buff.prototype,
833
1061
  "stuns",
834
1062
  {
835
1063
  get = function(self)
836
- local ____self__128_52 = self[128]
837
- if ____self__128_52 == nil then
838
- ____self__128_52 = false
1064
+ local ____self__140_50 = self[140]
1065
+ if ____self__140_50 == nil then
1066
+ ____self__140_50 = false
839
1067
  end
840
- return ____self__128_52
1068
+ return ____self__140_50
841
1069
  end,
842
1070
  set = function(self, stuns)
843
- if not stuns and self[128] then
844
- if self[129] then
845
- self.object:decrementStunCounter()
1071
+ if not stuns and self[140] then
1072
+ if self[141] then
1073
+ self.object:decrementForceStunCounter()
846
1074
  end
847
1075
  self.object:decrementStunCounter()
848
- self[128] = nil
849
- elseif stuns and not self[128] then
850
- if self[129] then
851
- self.object:incrementStunCounter()
1076
+ self[140] = nil
1077
+ elseif stuns and not self[140] then
1078
+ if self[141] then
1079
+ self.object:incrementForceStunCounter()
852
1080
  end
853
1081
  self.object:incrementStunCounter()
854
- self[128] = true
1082
+ self[140] = true
855
1083
  end
856
1084
  end
857
1085
  },
@@ -862,23 +1090,23 @@ __TS__SetDescriptor(
862
1090
  "ignoresStunImmunity",
863
1091
  {
864
1092
  get = function(self)
865
- local ____self__129_53 = self[129]
866
- if ____self__129_53 == nil then
867
- ____self__129_53 = false
1093
+ local ____self__141_51 = self[141]
1094
+ if ____self__141_51 == nil then
1095
+ ____self__141_51 = false
868
1096
  end
869
- return ____self__129_53
1097
+ return ____self__141_51
870
1098
  end,
871
1099
  set = function(self, ignoresStunImmunity)
872
- if not ignoresStunImmunity and self[129] then
873
- if self[128] then
874
- self.object:decrementStunCounter()
1100
+ if not ignoresStunImmunity and self[141] then
1101
+ if self[140] then
1102
+ self.object:decrementForceStunCounter()
875
1103
  end
876
- self[129] = nil
877
- elseif ignoresStunImmunity and not self[129] then
878
- if self[128] then
879
- self.object:incrementStunCounter()
1104
+ self[141] = nil
1105
+ elseif ignoresStunImmunity and not self[141] then
1106
+ if self[140] then
1107
+ self.object:incrementForceStunCounter()
880
1108
  end
881
- self[129] = true
1109
+ self[141] = true
882
1110
  end
883
1111
  end
884
1112
  },
@@ -889,19 +1117,19 @@ __TS__SetDescriptor(
889
1117
  "disablesAutoAttack",
890
1118
  {
891
1119
  get = function(self)
892
- local ____self__130_54 = self[130]
893
- if ____self__130_54 == nil then
894
- ____self__130_54 = false
1120
+ local ____self__142_52 = self[142]
1121
+ if ____self__142_52 == nil then
1122
+ ____self__142_52 = false
895
1123
  end
896
- return ____self__130_54
1124
+ return ____self__142_52
897
1125
  end,
898
1126
  set = function(self, disablesAutoAttack)
899
- if not disablesAutoAttack and self[130] then
1127
+ if not disablesAutoAttack and self[142] then
900
1128
  self.object:decrementDisableAutoAttackCounter()
901
- self[130] = nil
902
- elseif disablesAutoAttack and not self[130] then
1129
+ self[142] = nil
1130
+ elseif disablesAutoAttack and not self[142] then
903
1131
  self.object:incrementDisableAutoAttackCounter()
904
- self[130] = true
1132
+ self[142] = true
905
1133
  end
906
1134
  end
907
1135
  },
@@ -912,19 +1140,95 @@ __TS__SetDescriptor(
912
1140
  "providesInvulnerability",
913
1141
  {
914
1142
  get = function(self)
915
- local ____self__131_55 = self[131]
916
- if ____self__131_55 == nil then
917
- ____self__131_55 = false
1143
+ local ____self__143_53 = self[143]
1144
+ if ____self__143_53 == nil then
1145
+ ____self__143_53 = false
918
1146
  end
919
- return ____self__131_55
1147
+ return ____self__143_53
920
1148
  end,
921
1149
  set = function(self, providesInvulnerability)
922
- if not providesInvulnerability and self[131] then
1150
+ if not providesInvulnerability and self[143] then
923
1151
  self.object:decrementInvulnerabilityCounter()
924
- self[131] = nil
925
- elseif providesInvulnerability and not self[131] then
1152
+ self[143] = nil
1153
+ elseif providesInvulnerability and not self[143] then
926
1154
  self.object:incrementInvulnerabilityCounter()
927
- self[131] = true
1155
+ self[143] = true
1156
+ end
1157
+ end
1158
+ },
1159
+ true
1160
+ )
1161
+ __TS__SetDescriptor(
1162
+ Buff.prototype,
1163
+ "killsOnExpiration",
1164
+ {
1165
+ get = function(self)
1166
+ local ____self__144_54 = self[144]
1167
+ if ____self__144_54 == nil then
1168
+ ____self__144_54 = false
1169
+ end
1170
+ return ____self__144_54
1171
+ end,
1172
+ set = function(self, killsOnExpiration)
1173
+ if not killsOnExpiration and self[144] then
1174
+ self[144] = nil
1175
+ elseif killsOnExpiration and not self[144] then
1176
+ self[144] = true
1177
+ end
1178
+ end
1179
+ },
1180
+ true
1181
+ )
1182
+ __TS__SetDescriptor(
1183
+ Buff.prototype,
1184
+ "explodesOnExpiration",
1185
+ {
1186
+ get = function(self)
1187
+ local ____self__145_55 = self[145]
1188
+ if ____self__145_55 == nil then
1189
+ ____self__145_55 = false
1190
+ end
1191
+ return ____self__145_55
1192
+ end,
1193
+ set = function(self, killsOnExpiration)
1194
+ if not killsOnExpiration and self[145] then
1195
+ self[145] = nil
1196
+ elseif killsOnExpiration and not self[145] then
1197
+ self[145] = true
1198
+ end
1199
+ end
1200
+ },
1201
+ true
1202
+ )
1203
+ __TS__SetDescriptor(
1204
+ Buff.prototype,
1205
+ "maximumDamageDealtEventCount",
1206
+ {
1207
+ get = function(self)
1208
+ return self[132] or 0
1209
+ end,
1210
+ set = function(self, maximumDamageDealtEventCount)
1211
+ if maximumDamageDealtEventCount == 0 then
1212
+ self[132] = nil
1213
+ else
1214
+ self[132] = maximumDamageDealtEventCount
1215
+ end
1216
+ end
1217
+ },
1218
+ true
1219
+ )
1220
+ __TS__SetDescriptor(
1221
+ Buff.prototype,
1222
+ "maximumDamageReceivedEventCount",
1223
+ {
1224
+ get = function(self)
1225
+ return self[134] or 0
1226
+ end,
1227
+ set = function(self, maximumDamageReceivedEventCount)
1228
+ if maximumDamageReceivedEventCount == 0 then
1229
+ self[134] = nil
1230
+ else
1231
+ self[134] = maximumDamageReceivedEventCount
928
1232
  end
929
1233
  end
930
1234
  },
@@ -935,13 +1239,13 @@ __TS__SetDescriptor(
935
1239
  "maximumAutoAttackCount",
936
1240
  {
937
1241
  get = function(self)
938
- return self[127] or 0
1242
+ return self[130] or 0
939
1243
  end,
940
1244
  set = function(self, maximumAutoAttackCount)
941
1245
  if maximumAutoAttackCount == 0 then
942
- self[127] = nil
1246
+ self[130] = nil
943
1247
  else
944
- self[127] = maximumAutoAttackCount
1248
+ self[130] = maximumAutoAttackCount
945
1249
  end
946
1250
  end
947
1251
  },
@@ -952,10 +1256,10 @@ __TS__SetDescriptor(
952
1256
  "durationIncreaseOnAutoAttack",
953
1257
  {
954
1258
  get = function(self)
955
- return self[106] or 0
1259
+ return self[107] or 0
956
1260
  end,
957
1261
  set = function(self, durationIncreaseOnAutoAttack)
958
- self[106] = durationIncreaseOnAutoAttack
1262
+ self[107] = durationIncreaseOnAutoAttack
959
1263
  end
960
1264
  },
961
1265
  true
@@ -986,12 +1290,52 @@ __TS__SetDescriptor(
986
1290
  },
987
1291
  true
988
1292
  )
1293
+ __TS__SetDescriptor(
1294
+ Buff.prototype,
1295
+ "evasionProbability",
1296
+ {
1297
+ get = function(self)
1298
+ return self:getUnitBonus(UnitBonusType.EVASION_PROBABILITY)
1299
+ end,
1300
+ set = function(self, evasionProbability)
1301
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.EVASION_PROBABILITY, evasionProbability)
1302
+ end
1303
+ },
1304
+ true
1305
+ )
1306
+ __TS__SetDescriptor(
1307
+ Buff.prototype,
1308
+ "manaRegenerationRateIncreaseFactor",
1309
+ {
1310
+ get = function(self)
1311
+ return self:getUnitBonus(UnitBonusType.MANA_REGENERATION_RATE_FACTOR)
1312
+ end,
1313
+ set = function(self, manaRegenerationRateIncreaseFactor)
1314
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.MANA_REGENERATION_RATE_FACTOR, manaRegenerationRateIncreaseFactor)
1315
+ end
1316
+ },
1317
+ true
1318
+ )
989
1319
  __TS__SetDescriptor(
990
1320
  Buff.prototype,
991
1321
  "duration",
992
- {get = function(self)
993
- return self[102]
994
- end},
1322
+ {
1323
+ get = function(self)
1324
+ return self[103]
1325
+ end,
1326
+ set = function(self, duration)
1327
+ if duration <= 0 then
1328
+ local timer = self._timer
1329
+ if timer ~= nil then
1330
+ timer:destroy()
1331
+ self._timer = nil
1332
+ end
1333
+ self[103] = 0
1334
+ else
1335
+ self.remainingDuration = self.remainingDuration + (duration - self[103])
1336
+ end
1337
+ end
1338
+ },
995
1339
  true
996
1340
  )
997
1341
  __TS__SetDescriptor(
@@ -1007,7 +1351,7 @@ __TS__SetDescriptor(
1007
1351
  local ____opt_58 = self._timer
1008
1352
  local remainingDurationDelta = ____remainingDuration_60 - (____opt_58 and ____opt_58.remaining or 0)
1009
1353
  if remainingDurationDelta ~= 0 then
1010
- self[102] = self[102] + remainingDurationDelta
1354
+ self[103] = self[103] + remainingDurationDelta
1011
1355
  if remainingDuration <= 0 then
1012
1356
  Timer:run(destroyBuff, self)
1013
1357
  else
@@ -1019,7 +1363,8 @@ __TS__SetDescriptor(
1019
1363
  self._level,
1020
1364
  remainingDuration,
1021
1365
  self._spellStealPriority,
1022
- self._learnLevelMinimum
1366
+ self._learnLevelMinimum,
1367
+ self[146]
1023
1368
  ) then
1024
1369
  local timer = self._timer
1025
1370
  if timer == nil then
@@ -1033,26 +1378,117 @@ __TS__SetDescriptor(
1033
1378
  end
1034
1379
  },
1035
1380
  true
1036
- );
1381
+ )
1382
+ __TS__SetDescriptor(
1383
+ Buff.prototype,
1384
+ "absorbedDamageFactor",
1385
+ {
1386
+ get = function(self)
1387
+ return self[135] or 1
1388
+ end,
1389
+ set = function(self, absorbedDamageFactor)
1390
+ if absorbedDamageFactor == 1 then
1391
+ self[135] = nil
1392
+ else
1393
+ self[135] = absorbedDamageFactor
1394
+ end
1395
+ end
1396
+ },
1397
+ true
1398
+ )
1399
+ __TS__SetDescriptor(
1400
+ Buff.prototype,
1401
+ "maximumDamageAbsorbed",
1402
+ {
1403
+ get = function(self)
1404
+ return self[136] or 0
1405
+ end,
1406
+ set = function(self, maximumDamageAbsorbed)
1407
+ if maximumDamageAbsorbed == 0 then
1408
+ self[136] = nil
1409
+ else
1410
+ self[136] = maximumDamageAbsorbed
1411
+ end
1412
+ end
1413
+ },
1414
+ true
1415
+ )
1416
+ __TS__SetDescriptor(
1417
+ Buff.prototype,
1418
+ "damageAbsorbed",
1419
+ {get = function(self)
1420
+ return self[137] or 0
1421
+ end},
1422
+ true
1423
+ )
1424
+ __TS__SetDescriptor(
1425
+ Buff.prototype,
1426
+ "destroysOnMaximumDamageAbsorbed",
1427
+ {
1428
+ get = function(self)
1429
+ local ____self__138_61 = self[138]
1430
+ if ____self__138_61 == nil then
1431
+ ____self__138_61 = true
1432
+ end
1433
+ return ____self__138_61
1434
+ end,
1435
+ set = function(self, destroysOnMaximumDamageAbsorbed)
1436
+ local ____destroysOnMaximumDamageAbsorbed_62
1437
+ if destroysOnMaximumDamageAbsorbed then
1438
+ ____destroysOnMaximumDamageAbsorbed_62 = nil
1439
+ else
1440
+ ____destroysOnMaximumDamageAbsorbed_62 = false
1441
+ end
1442
+ self[138] = ____destroysOnMaximumDamageAbsorbed_62
1443
+ end
1444
+ },
1445
+ true
1446
+ )
1447
+ __TS__SetDescriptor(
1448
+ Buff.prototype,
1449
+ "abilityCooldownFactor",
1450
+ {
1451
+ get = function(self)
1452
+ return self[147] or 1
1453
+ end,
1454
+ set = function(self, abilityCooldownFactor)
1455
+ local previousAbilityCooldownModifier = self[148]
1456
+ if previousAbilityCooldownModifier then
1457
+ for ____, ability in ipairs(self._unit.abilities) do
1458
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
1459
+ end
1460
+ end
1461
+ local function modifier(ability, level, cooldown)
1462
+ return cooldown * abilityCooldownFactor
1463
+ end
1464
+ for ____, ability in ipairs(self._unit.abilities) do
1465
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
1466
+ end
1467
+ self[148] = modifier
1468
+ self[147] = abilityCooldownFactor
1469
+ end
1470
+ },
1471
+ true
1472
+ )
1473
+ Buff.createdEvent = buffCreatedEvent
1474
+ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1037
1475
  (function(self)
1476
+ local function destroyBuffIfNeeded(buff)
1477
+ if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
1478
+ buff:destroy()
1479
+ end
1480
+ end
1038
1481
  ____exports.checkBuff = function(unit, buffTypeId)
1039
1482
  local buffByTypeId = buffByTypeIdByUnit[unit]
1040
1483
  if buffByTypeId ~= nil then
1041
1484
  local buff = buffByTypeId[buffTypeId]
1042
- if buff ~= nil and getUnitAbility(unit.handle, buffTypeId) ~= buff.handle then
1043
- buff:destroy()
1485
+ if buff ~= nil then
1486
+ destroyBuffIfNeeded(buff)
1044
1487
  end
1045
1488
  end
1046
1489
  end
1047
1490
  ____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
1491
+ ____exports.Buff:forAll(unit, destroyBuffIfNeeded)
1056
1492
  end
1057
1493
  Unit.abilityChannelingStartEvent:addListener(
1058
1494
  0,
@@ -1089,5 +1525,11 @@ __TS__SetDescriptor(
1089
1525
  ____exports.checkBuffs(target)
1090
1526
  end
1091
1527
  )
1528
+ buffCreatedEvent:addListener(function(buff)
1529
+ UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1530
+ end)
1531
+ buffBeingDestroyedEvent:addListener(function(buff)
1532
+ UnitBehavior:forAll(buff.unit, "onBuffLost", buff)
1533
+ end)
1092
1534
  end)(Buff)
1093
1535
  return ____exports