warscript 0.0.1-dev.ee2345e → 0.0.1-dev.ef189a5

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