warscript 0.0.1-dev.a5f2d10 → 0.0.1-dev.a856ae3

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