warscript 0.0.1-dev.b026cc2 → 0.0.1-dev.b23de5c

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