warscript 0.0.1-dev.ee2345e → 0.0.1-dev.f024cc2

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