warscript 0.0.1-dev.ee2345e → 0.0.1-dev.ee6f224

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