warscript 0.0.1-dev.ccd5725 → 0.0.1-dev.ce2be36

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