warscript 0.0.1-dev.dbb3984 → 0.0.1-dev.dc37dce

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