warscript 0.0.1-dev.e561d29 → 0.0.1-dev.e698bed

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 (87) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/frame.lua +24 -21
  4. package/core/types/player.d.ts +16 -0
  5. package/core/types/player.lua +60 -15
  6. package/core/types/playerCamera.d.ts +2 -0
  7. package/core/types/playerCamera.lua +123 -5
  8. package/core/types/tileCell.d.ts +11 -1
  9. package/core/types/tileCell.lua +97 -0
  10. package/core/types/timer.d.ts +3 -2
  11. package/core/types/timer.lua +22 -2
  12. package/decl/native.d.ts +2 -2
  13. package/engine/behavior.d.ts +10 -1
  14. package/engine/behavior.lua +141 -65
  15. package/engine/behaviour/ability/apply-buff.lua +12 -4
  16. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  17. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  18. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  19. package/engine/behaviour/ability/restore-mana.lua +6 -6
  20. package/engine/behaviour/unit/stun-immunity.d.ts +8 -4
  21. package/engine/behaviour/unit/stun-immunity.lua +12 -3
  22. package/engine/behaviour/unit.d.ts +15 -5
  23. package/engine/behaviour/unit.lua +116 -22
  24. package/engine/buff.d.ts +10 -4
  25. package/engine/buff.lua +119 -84
  26. package/engine/internal/ability.d.ts +3 -1
  27. package/engine/internal/ability.lua +26 -9
  28. package/engine/internal/item+owner.lua +12 -6
  29. package/engine/internal/item.d.ts +13 -15
  30. package/engine/internal/item.lua +63 -49
  31. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  32. package/engine/internal/misc/frame-coordinates.lua +21 -0
  33. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  34. package/engine/internal/misc/get-terrain-z.lua +11 -0
  35. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  36. package/engine/internal/misc/player-local-handle.lua +5 -0
  37. package/engine/internal/unit/ability.d.ts +14 -14
  38. package/engine/internal/unit/ability.lua +72 -45
  39. package/engine/internal/unit/fly-height.d.ts +7 -0
  40. package/engine/internal/unit/fly-height.lua +20 -0
  41. package/engine/internal/unit/main-selected.lua +12 -27
  42. package/engine/internal/unit/scale.d.ts +7 -0
  43. package/engine/internal/unit/scale.lua +20 -0
  44. package/engine/internal/unit+ability.lua +10 -1
  45. package/engine/internal/unit-missile-launch.lua +44 -20
  46. package/engine/internal/unit.d.ts +16 -13
  47. package/engine/internal/unit.lua +102 -81
  48. package/engine/local-client.d.ts +2 -0
  49. package/engine/local-client.lua +30 -0
  50. package/engine/object-data/entry/ability-type.lua +4 -1
  51. package/engine/object-data/entry/unit-type.d.ts +4 -0
  52. package/engine/object-data/entry/unit-type.lua +76 -32
  53. package/engine/object-field/ability.d.ts +3 -3
  54. package/engine/object-field/ability.lua +7 -6
  55. package/engine/object-field/unit.d.ts +13 -1
  56. package/engine/object-field/unit.lua +57 -0
  57. package/engine/object-field.d.ts +9 -3
  58. package/engine/object-field.lua +204 -115
  59. package/engine/random.d.ts +9 -0
  60. package/engine/random.lua +13 -0
  61. package/engine/standard/fields/ability.d.ts +2 -2
  62. package/engine/standard/fields/ability.lua +2 -2
  63. package/engine/standard/fields/unit.d.ts +3 -1
  64. package/engine/standard/fields/unit.lua +4 -0
  65. package/engine/synchronization.d.ts +11 -0
  66. package/engine/synchronization.lua +77 -0
  67. package/engine/text-tag.d.ts +1 -1
  68. package/engine/text-tag.lua +92 -17
  69. package/engine/unit.d.ts +2 -0
  70. package/engine/unit.lua +2 -0
  71. package/net/socket.lua +1 -1
  72. package/objutil/buff.lua +1 -1
  73. package/package.json +2 -2
  74. package/patch-lualib.lua +1 -1
  75. package/utility/arrays.d.ts +1 -0
  76. package/utility/arrays.lua +8 -0
  77. package/utility/callback-array.d.ts +17 -0
  78. package/utility/callback-array.lua +61 -0
  79. package/utility/functions.d.ts +2 -0
  80. package/utility/functions.lua +7 -0
  81. package/utility/linked-set.d.ts +1 -0
  82. package/utility/linked-set.lua +19 -1
  83. package/utility/lua-maps.d.ts +11 -2
  84. package/utility/lua-maps.lua +33 -2
  85. package/utility/lua-sets.d.ts +1 -0
  86. package/utility/lua-sets.lua +4 -0
  87. package/utility/types.d.ts +3 -0
@@ -17,63 +17,127 @@ local getOrPut = ____lua_2Dmaps.getOrPut
17
17
  local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
18
18
  local ____lua_2Dsets = require("utility.lua-sets")
19
19
  local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
20
- local behaviorsByEvent = {}
21
- local rangeByBehaviorByEvent = {}
22
- local listenerByBehaviorByEvent = {}
23
- local eventsByBehavior = {}
20
+ local ____bonus = require("engine.internal.unit.bonus")
21
+ local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
22
+ local getUnitBonus = ____bonus.getUnitBonus
23
+ local removeUnitBonus = ____bonus.removeUnitBonus
24
+ local safeCall = warpack.safeCall
25
+ local createBehaviorFunctionsByUnitTypeId = {}
26
+ local behaviorsByOwningPlayerEvent = {}
27
+ local listenerByBehaviorByOwningPlayerEvent = {}
28
+ local owningPlayerEventsByBehavior = {}
29
+ local behaviorsByInRangeUnitEvent = {}
30
+ local rangeByBehaviorByInRangeUnitEvent = {}
31
+ local listenerByBehaviorByInRangeUnitEvent = {}
32
+ local inRangeUnitEventsByBehavior = {}
24
33
  ____exports.UnitBehavior = __TS__Class()
25
34
  local UnitBehavior = ____exports.UnitBehavior
26
35
  UnitBehavior.name = "UnitBehavior"
27
36
  __TS__ClassExtends(UnitBehavior, Behavior)
28
- function UnitBehavior.prototype.____constructor(self, unit)
29
- Behavior.prototype.____constructor(self, unit)
37
+ function UnitBehavior.prototype.____constructor(self, unit, priority)
38
+ Behavior.prototype.____constructor(self, unit, priority)
30
39
  end
31
40
  function UnitBehavior.prototype.onDestroy(self)
32
- local events = eventsByBehavior[self]
33
- if events ~= nil then
34
- for event in pairs(events) do
35
- local ____opt_0 = behaviorsByEvent[event]
41
+ local owningPlayerEvents = owningPlayerEventsByBehavior[self]
42
+ if owningPlayerEvents ~= nil then
43
+ for event in pairs(owningPlayerEvents) do
44
+ local ____opt_0 = behaviorsByOwningPlayerEvent[event]
36
45
  if ____opt_0 ~= nil then
37
46
  ____opt_0:remove(self)
38
47
  end
39
- local ____opt_2 = rangeByBehaviorByEvent[event]
48
+ local ____opt_2 = listenerByBehaviorByOwningPlayerEvent[event]
40
49
  if ____opt_2 ~= nil then
41
50
  ____opt_2[self] = nil
42
51
  end
43
- local ____opt_4 = listenerByBehaviorByEvent[event]
52
+ end
53
+ owningPlayerEventsByBehavior[self] = nil
54
+ end
55
+ local inRangeUnitEvents = inRangeUnitEventsByBehavior[self]
56
+ if inRangeUnitEvents ~= nil then
57
+ for event in pairs(inRangeUnitEvents) do
58
+ local ____opt_4 = behaviorsByInRangeUnitEvent[event]
44
59
  if ____opt_4 ~= nil then
45
- ____opt_4[self] = nil
60
+ ____opt_4:remove(self)
61
+ end
62
+ local ____opt_6 = rangeByBehaviorByInRangeUnitEvent[event]
63
+ if ____opt_6 ~= nil then
64
+ ____opt_6[self] = nil
65
+ end
66
+ local ____opt_8 = listenerByBehaviorByInRangeUnitEvent[event]
67
+ if ____opt_8 ~= nil then
68
+ ____opt_8[self] = nil
46
69
  end
47
70
  end
48
- eventsByBehavior[self] = nil
71
+ inRangeUnitEventsByBehavior[self] = nil
72
+ end
73
+ if self._bonusIdByBonusType ~= nil then
74
+ for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
75
+ removeUnitBonus(self.object, bonusType, bonusId)
76
+ end
49
77
  end
50
78
  return Behavior.prototype.onDestroy(self)
51
79
  end
80
+ function UnitBehavior.prototype.getUnitBonus(self, bonusType)
81
+ local ____opt_10 = self._bonusIdByBonusType
82
+ local bonusId = ____opt_10 and ____opt_10[bonusType]
83
+ return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
84
+ end
85
+ function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
86
+ local bonusIdByBonusType = self._bonusIdByBonusType
87
+ if bonusIdByBonusType == nil then
88
+ bonusIdByBonusType = {}
89
+ self._bonusIdByBonusType = bonusIdByBonusType
90
+ end
91
+ bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self.object, bonusType, bonusIdByBonusType[bonusType], value)
92
+ end
93
+ function UnitBehavior.prototype.registerOwningPlayerEvent(self, event, extractPlayer, listener)
94
+ local listenerByBehavior = getOrPut(listenerByBehaviorByOwningPlayerEvent, event, mutableLuaMap)
95
+ listenerByBehavior[self] = listener
96
+ getOrPut(inRangeUnitEventsByBehavior, self, mutableLuaSet)[event] = true
97
+ local behaviors = behaviorsByOwningPlayerEvent[event]
98
+ if behaviors == nil then
99
+ event:addListener(function(...)
100
+ local behaviors = behaviorsByOwningPlayerEvent[event]
101
+ if behaviors ~= nil then
102
+ local player = extractPlayer(...)
103
+ if player ~= nil then
104
+ for behavior in pairs(behaviors) do
105
+ if behavior.unit.owner == player then
106
+ safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end)
112
+ behaviors = __TS__New(LinkedSet)
113
+ behaviorsByOwningPlayerEvent[event] = behaviors
114
+ end
115
+ behaviors:add(self)
116
+ end
52
117
  function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
53
- local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
118
+ local rangeByBehavior = getOrPut(rangeByBehaviorByInRangeUnitEvent, event, mutableLuaMap)
54
119
  rangeByBehavior[self] = range
55
- local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
120
+ local listenerByBehavior = getOrPut(listenerByBehaviorByInRangeUnitEvent, event, mutableLuaMap)
56
121
  listenerByBehavior[self] = listener
57
- getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
58
- local behaviors = behaviorsByEvent[event]
122
+ getOrPut(inRangeUnitEventsByBehavior, self, mutableLuaSet)[event] = true
123
+ local behaviors = behaviorsByInRangeUnitEvent[event]
59
124
  if behaviors == nil then
60
125
  event:addListener(function(...)
61
- local behaviors = behaviorsByEvent[event]
126
+ local behaviors = behaviorsByInRangeUnitEvent[event]
62
127
  if behaviors ~= nil then
63
128
  local unit = extractUnit(...)
64
129
  if unit ~= nil then
65
130
  for behavior in pairs(behaviors) do
66
131
  local range = rangeByBehavior[behavior]
67
132
  if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
68
- local ____self_6 = behavior
69
- ____self_6[listenerByBehavior[behavior]](____self_6, ...)
133
+ safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
70
134
  end
71
135
  end
72
136
  end
73
137
  end
74
138
  end)
75
139
  behaviors = __TS__New(LinkedSet)
76
- behaviorsByEvent[event] = behaviors
140
+ behaviorsByInRangeUnitEvent[event] = behaviors
77
141
  end
78
142
  behaviors:add(self)
79
143
  end
@@ -129,6 +193,8 @@ function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
129
193
  end
130
194
  function UnitBehavior.prototype.onBuffGained(self, buff)
131
195
  end
196
+ function UnitBehavior.prototype.onBuffLost(self, buff)
197
+ end
132
198
  function UnitBehavior.prototype.onItemDropped(self, item)
133
199
  end
134
200
  function UnitBehavior.prototype.onItemPickedUp(self, item)
@@ -143,6 +209,23 @@ function UnitBehavior.prototype.onKill(self, target)
143
209
  end
144
210
  function UnitBehavior.prototype.onDeath(self, source)
145
211
  end
212
+ function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
213
+ end
214
+ function UnitBehavior.bindUnitType(self, unitTypeId, ...)
215
+ local args = {...}
216
+ local createBehaviorFunctions = createBehaviorFunctionsByUnitTypeId[unitTypeId]
217
+ if createBehaviorFunctions == nil then
218
+ createBehaviorFunctions = {}
219
+ createBehaviorFunctionsByUnitTypeId[unitTypeId] = createBehaviorFunctions
220
+ end
221
+ createBehaviorFunctions[#createBehaviorFunctions + 1] = function(unit)
222
+ return __TS__New(
223
+ self,
224
+ unit,
225
+ table.unpack(args)
226
+ )
227
+ end
228
+ end
146
229
  __TS__SetDescriptor(
147
230
  UnitBehavior.prototype,
148
231
  "unit",
@@ -254,7 +337,18 @@ __TS__SetDescriptor(
254
337
  Unit.itemChargesChangedEvent:addListener(function(unit, item)
255
338
  ____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
256
339
  end)
340
+ Unit.onOwnerChange:addListener(function(unit, previousOwner)
341
+ ____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
342
+ end)
257
343
  end)(UnitBehavior)
344
+ Unit.onCreate:addListener(function(unit)
345
+ local createBehaviorFunctions = createBehaviorFunctionsByUnitTypeId[unit.typeId]
346
+ if createBehaviorFunctions ~= nil then
347
+ for ____, createBehavior in ipairs(createBehaviorFunctions) do
348
+ createBehavior(unit)
349
+ end
350
+ end
351
+ end)
258
352
  Unit.destroyEvent:addListener(function(unit)
259
353
  ____exports.UnitBehavior:forAll(unit, "destroy")
260
354
  end)
package/engine/buff.d.ts CHANGED
@@ -79,6 +79,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
79
79
  healingOnExpiration?: NumberParameterValueType;
80
80
  killsOnExpiration?: BooleanParameterValueType;
81
81
  explodesOnExpiration?: BooleanParameterValueType;
82
+ abilityCooldownFactor?: NumberParameterValueType;
82
83
  uniqueGroup?: BuffUniqueGroup;
83
84
  } : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
84
85
  declare const enum BuffPropertyKey {
@@ -124,7 +125,9 @@ declare const enum BuffPropertyKey {
124
125
  PROVIDES_INVULNERABILITY = 139,
125
126
  KILLS_ON_EXPIRATION = 140,
126
127
  EXPLODES_ON_EXPIRATION = 141,
127
- MISS_PROBABILITY = 142
128
+ MISS_PROBABILITY = 142,
129
+ ABILITY_COOLDOWN_FACTOR = 143,
130
+ ABILITY_COOLDOWN_MODIFIER = 144
128
131
  }
129
132
  export declare const enum BuffTypeIdSelectionPolicy {
130
133
  LEAST_DURATION = 0
@@ -187,6 +190,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
187
190
  private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
188
191
  private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
189
192
  private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
193
+ private [BuffPropertyKey.ABILITY_COOLDOWN_FACTOR]?;
194
+ private [BuffPropertyKey.ABILITY_COOLDOWN_MODIFIER]?;
190
195
  protected static readonly defaultParameters: BuffParameters;
191
196
  get source(): Unit;
192
197
  readonly typeId: ApplicableBuffTypeId;
@@ -201,11 +206,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
201
206
  private readonly _spellStealPriority?;
202
207
  private readonly _learnLevelMinimum?;
203
208
  private readonly [BuffPropertyKey.MISS_PROBABILITY]?;
204
- private _bonusIdByBonusType?;
205
209
  private readonly _abilityTypeIds?;
206
210
  private _behaviors?;
207
- private getUnitBonus;
208
- private addOrUpdateOrRemoveUnitBonus;
209
211
  constructor(target: Unit, ...parameters: BuffConstructorParameters<AdditionalParameters>);
210
212
  get level(): number;
211
213
  get remainingDamageOverDuration(): number;
@@ -265,6 +267,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
265
267
  get duration(): number;
266
268
  get remainingDuration(): number;
267
269
  set remainingDuration(remainingDuration: number);
270
+ get abilityCooldownFactor(): number;
271
+ set abilityCooldownFactor(abilityCooldownFactor: number);
272
+ onAbilityGained(ability: Ability): void;
273
+ onAbilityLost(ability: Ability): void;
268
274
  flashEffect(...parameters: [
269
275
  ...widgetOrXY: [] | [Widget] | [x: number, x: number],
270
276
  ...parametersOrDuration: [] | [EffectParameters] | [number]
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,9 +29,6 @@ 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
@@ -53,6 +51,8 @@ local ____item = require("engine.internal.item")
53
51
  local Item = ____item.Item
54
52
  local ____destructable = require("core.types.destructable")
55
53
  local Destructable = ____destructable.Destructable
54
+ local ____ability = require("engine.standard.fields.ability")
55
+ local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
56
56
  local getUnitAbility = BlzGetUnitAbility
57
57
  local stringValueByBuffTypeIdByFieldId = postcompile(function()
58
58
  local stringValueByBuffTypeIdByFieldId = {}
@@ -124,7 +124,8 @@ local buffParametersKeys = {
124
124
  damageOnExpiration = true,
125
125
  healingOnExpiration = true,
126
126
  killsOnExpiration = true,
127
- explodesOnExpiration = true
127
+ explodesOnExpiration = true,
128
+ abilityCooldownFactor = true
128
129
  }
129
130
  local function resolveEnumValue(ability, level, value)
130
131
  if value == nil or type(value) == "number" then
@@ -201,7 +202,8 @@ local buffNumberParameters = {
201
202
  "healingPerInterval",
202
203
  "healingOverDuration",
203
204
  "damageOnExpiration",
204
- "healingOnExpiration"
205
+ "healingOnExpiration",
206
+ "abilityCooldownFactor"
205
207
  }
206
208
  local unsuccessfulApplicationMarker = {}
207
209
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -509,63 +511,66 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
509
511
  self[100] = 1
510
512
  Event.invoke(buffCreatedEvent, self)
511
513
  end
512
- function Buff.prototype.getUnitBonus(self, bonusType)
513
- local ____opt_38 = self._bonusIdByBonusType
514
- local bonusId = ____opt_38 and ____opt_38[bonusType]
515
- return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
514
+ function Buff.prototype.onAbilityGained(self, ability)
515
+ if __TS__InstanceOf(ability, UnitAbility) then
516
+ local abilityCooldownModifier = self[144]
517
+ if abilityCooldownModifier then
518
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
519
+ end
520
+ end
516
521
  end
517
- function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
518
- local bonusIdByBonusType = self._bonusIdByBonusType
519
- if bonusIdByBonusType == nil then
520
- bonusIdByBonusType = {}
521
- self._bonusIdByBonusType = bonusIdByBonusType
522
+ function Buff.prototype.onAbilityLost(self, ability)
523
+ if __TS__InstanceOf(ability, UnitAbility) then
524
+ local abilityCooldownModifier = self[144]
525
+ if abilityCooldownModifier then
526
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
527
+ end
522
528
  end
523
- bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
524
529
  end
525
530
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
526
531
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
527
532
  Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
528
533
  else
529
534
  local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
530
- local ____Effect_42 = Effect
531
- local ____Effect_flash_43 = Effect.flash
532
- local ____array_41 = __TS__SparseArrayNew(
535
+ local ____Effect_40 = Effect
536
+ local ____Effect_flash_41 = Effect.flash
537
+ local ____array_39 = __TS__SparseArrayNew(
533
538
  self[105],
534
539
  isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
535
540
  stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
536
541
  )
537
- local ____isWidgetProvided_40
542
+ local ____isWidgetProvided_38
538
543
  if isWidgetProvided then
539
- ____isWidgetProvided_40 = yOrParametersOrDuration
544
+ ____isWidgetProvided_38 = yOrParametersOrDuration
540
545
  else
541
- ____isWidgetProvided_40 = widgetOrXOrParametersOrDuration
546
+ ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
542
547
  end
543
- __TS__SparseArrayPush(____array_41, ____isWidgetProvided_40)
544
- ____Effect_flash_43(
545
- ____Effect_42,
546
- __TS__SparseArraySpread(____array_41)
548
+ __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
549
+ ____Effect_flash_41(
550
+ ____Effect_40,
551
+ __TS__SparseArraySpread(____array_39)
547
552
  )
548
553
  end
549
554
  end
550
555
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
551
556
  local isWidgetProvided = type(widgetOrDuration) == "table"
552
- local ____Effect_46 = Effect
553
- local ____Effect_flash_47 = Effect.flash
554
- local ____array_45 = __TS__SparseArrayNew(
557
+ local ____Effect_44 = Effect
558
+ local ____Effect_flash_45 = Effect.flash
559
+ local ____array_43 = __TS__SparseArrayNew(
555
560
  self[106],
556
561
  isWidgetProvided and widgetOrDuration or self._unit,
557
562
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
558
563
  )
559
- local ____isWidgetProvided_44
564
+ local ____isWidgetProvided_42
560
565
  if isWidgetProvided then
561
- ____isWidgetProvided_44 = duration
566
+ ____isWidgetProvided_42 = duration
562
567
  else
563
- ____isWidgetProvided_44 = widgetOrDuration
568
+ ____isWidgetProvided_42 = widgetOrDuration
564
569
  end
565
- __TS__SparseArrayPush(____array_45, ____isWidgetProvided_44)
566
- ____Effect_flash_47(
567
- ____Effect_46,
568
- __TS__SparseArraySpread(____array_45)
570
+ __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
571
+ ____Effect_flash_45(
572
+ ____Effect_44,
573
+ __TS__SparseArraySpread(____array_43)
569
574
  )
570
575
  end
571
576
  function Buff.prototype.onCreate(self)
@@ -596,6 +601,12 @@ function Buff.prototype.onDestroy(self)
596
601
  behavior:destroy()
597
602
  end
598
603
  end
604
+ local previousAbilityCooldownModifier = self[144]
605
+ if previousAbilityCooldownModifier then
606
+ for ____, ability in ipairs(self._unit.abilities) do
607
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
608
+ end
609
+ end
599
610
  if self[139] then
600
611
  unit:decrementInvulnerabilityCounter()
601
612
  end
@@ -604,7 +615,7 @@ function Buff.prototype.onDestroy(self)
604
615
  end
605
616
  if self[136] then
606
617
  if self[137] then
607
- unit:decrementStunCounter()
618
+ unit:decrementForceStunCounter()
608
619
  end
609
620
  unit:decrementStunCounter()
610
621
  end
@@ -616,11 +627,6 @@ function Buff.prototype.onDestroy(self)
616
627
  unit:removeAbility(abilityTypeId)
617
628
  end
618
629
  end
619
- if self._bonusIdByBonusType ~= nil then
620
- for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
621
- removeUnitBonus(unit, bonusType, bonusId)
622
- end
623
- end
624
630
  Event.invoke(buffBeingDestroyedEvent, self)
625
631
  self[100] = 3
626
632
  return UnitBehavior.prototype.onDestroy(self)
@@ -650,8 +656,8 @@ function Buff.apply(self, ...)
650
656
  end
651
657
  end
652
658
  function Buff.getByTypeId(self, unit, typeId)
653
- local ____opt_48 = buffByTypeIdByUnit[unit]
654
- local buff = ____opt_48 and ____opt_48[typeId]
659
+ local ____opt_46 = buffByTypeIdByUnit[unit]
660
+ local buff = ____opt_46 and ____opt_46[typeId]
655
661
  if __TS__InstanceOf(buff, self) then
656
662
  return buff
657
663
  end
@@ -809,8 +815,8 @@ __TS__SetDescriptor(
809
815
  return
810
816
  end
811
817
  self[112] = damageInterval
812
- local ____opt_50 = self._timer
813
- local elapsed = ____opt_50 and ____opt_50.elapsed or 0
818
+ local ____opt_48 = self._timer
819
+ local elapsed = ____opt_48 and ____opt_48.elapsed or 0
814
820
  local timer = self[114]
815
821
  if timer == nil then
816
822
  timer = Timer:create()
@@ -889,8 +895,8 @@ __TS__SetDescriptor(
889
895
  return
890
896
  end
891
897
  self[117] = healingInterval
892
- local ____opt_52 = self._timer
893
- local elapsed = ____opt_52 and ____opt_52.elapsed or 0
898
+ local ____opt_50 = self._timer
899
+ local elapsed = ____opt_50 and ____opt_50.elapsed or 0
894
900
  local timer = self[119]
895
901
  if timer == nil then
896
902
  timer = Timer:create()
@@ -976,11 +982,11 @@ __TS__SetDescriptor(
976
982
  "turnsIntoGhost",
977
983
  {
978
984
  get = function(self)
979
- local ____self__135_54 = self[135]
980
- if ____self__135_54 == nil then
981
- ____self__135_54 = false
985
+ local ____self__135_52 = self[135]
986
+ if ____self__135_52 == nil then
987
+ ____self__135_52 = false
982
988
  end
983
- return ____self__135_54
989
+ return ____self__135_52
984
990
  end,
985
991
  set = function(self, turnsIntoGhost)
986
992
  if not turnsIntoGhost and self[135] then
@@ -999,22 +1005,22 @@ __TS__SetDescriptor(
999
1005
  "stuns",
1000
1006
  {
1001
1007
  get = function(self)
1002
- local ____self__136_55 = self[136]
1003
- if ____self__136_55 == nil then
1004
- ____self__136_55 = false
1008
+ local ____self__136_53 = self[136]
1009
+ if ____self__136_53 == nil then
1010
+ ____self__136_53 = false
1005
1011
  end
1006
- return ____self__136_55
1012
+ return ____self__136_53
1007
1013
  end,
1008
1014
  set = function(self, stuns)
1009
1015
  if not stuns and self[136] then
1010
1016
  if self[137] then
1011
- self.object:decrementStunCounter()
1017
+ self.object:decrementForceStunCounter()
1012
1018
  end
1013
1019
  self.object:decrementStunCounter()
1014
1020
  self[136] = nil
1015
1021
  elseif stuns and not self[136] then
1016
1022
  if self[137] then
1017
- self.object:incrementStunCounter()
1023
+ self.object:incrementForceStunCounter()
1018
1024
  end
1019
1025
  self.object:incrementStunCounter()
1020
1026
  self[136] = true
@@ -1028,21 +1034,21 @@ __TS__SetDescriptor(
1028
1034
  "ignoresStunImmunity",
1029
1035
  {
1030
1036
  get = function(self)
1031
- local ____self__137_56 = self[137]
1032
- if ____self__137_56 == nil then
1033
- ____self__137_56 = false
1037
+ local ____self__137_54 = self[137]
1038
+ if ____self__137_54 == nil then
1039
+ ____self__137_54 = false
1034
1040
  end
1035
- return ____self__137_56
1041
+ return ____self__137_54
1036
1042
  end,
1037
1043
  set = function(self, ignoresStunImmunity)
1038
1044
  if not ignoresStunImmunity and self[137] then
1039
1045
  if self[136] then
1040
- self.object:decrementStunCounter()
1046
+ self.object:decrementForceStunCounter()
1041
1047
  end
1042
1048
  self[137] = nil
1043
1049
  elseif ignoresStunImmunity and not self[137] then
1044
1050
  if self[136] then
1045
- self.object:incrementStunCounter()
1051
+ self.object:incrementForceStunCounter()
1046
1052
  end
1047
1053
  self[137] = true
1048
1054
  end
@@ -1055,11 +1061,11 @@ __TS__SetDescriptor(
1055
1061
  "disablesAutoAttack",
1056
1062
  {
1057
1063
  get = function(self)
1058
- local ____self__138_57 = self[138]
1059
- if ____self__138_57 == nil then
1060
- ____self__138_57 = false
1064
+ local ____self__138_55 = self[138]
1065
+ if ____self__138_55 == nil then
1066
+ ____self__138_55 = false
1061
1067
  end
1062
- return ____self__138_57
1068
+ return ____self__138_55
1063
1069
  end,
1064
1070
  set = function(self, disablesAutoAttack)
1065
1071
  if not disablesAutoAttack and self[138] then
@@ -1078,11 +1084,11 @@ __TS__SetDescriptor(
1078
1084
  "providesInvulnerability",
1079
1085
  {
1080
1086
  get = function(self)
1081
- local ____self__139_58 = self[139]
1082
- if ____self__139_58 == nil then
1083
- ____self__139_58 = false
1087
+ local ____self__139_56 = self[139]
1088
+ if ____self__139_56 == nil then
1089
+ ____self__139_56 = false
1084
1090
  end
1085
- return ____self__139_58
1091
+ return ____self__139_56
1086
1092
  end,
1087
1093
  set = function(self, providesInvulnerability)
1088
1094
  if not providesInvulnerability and self[139] then
@@ -1101,11 +1107,11 @@ __TS__SetDescriptor(
1101
1107
  "killsOnExpiration",
1102
1108
  {
1103
1109
  get = function(self)
1104
- local ____self__140_59 = self[140]
1105
- if ____self__140_59 == nil then
1106
- ____self__140_59 = false
1110
+ local ____self__140_57 = self[140]
1111
+ if ____self__140_57 == nil then
1112
+ ____self__140_57 = false
1107
1113
  end
1108
- return ____self__140_59
1114
+ return ____self__140_57
1109
1115
  end,
1110
1116
  set = function(self, killsOnExpiration)
1111
1117
  if not killsOnExpiration and self[140] then
@@ -1122,11 +1128,11 @@ __TS__SetDescriptor(
1122
1128
  "explodesOnExpiration",
1123
1129
  {
1124
1130
  get = function(self)
1125
- local ____self__141_60 = self[141]
1126
- if ____self__141_60 == nil then
1127
- ____self__141_60 = false
1131
+ local ____self__141_58 = self[141]
1132
+ if ____self__141_58 == nil then
1133
+ ____self__141_58 = false
1128
1134
  end
1129
- return ____self__141_60
1135
+ return ____self__141_58
1130
1136
  end,
1131
1137
  set = function(self, killsOnExpiration)
1132
1138
  if not killsOnExpiration and self[141] then
@@ -1254,13 +1260,13 @@ __TS__SetDescriptor(
1254
1260
  "remainingDuration",
1255
1261
  {
1256
1262
  get = function(self)
1257
- local ____opt_61 = self._timer
1258
- return ____opt_61 and ____opt_61.remaining or 0
1263
+ local ____opt_59 = self._timer
1264
+ return ____opt_59 and ____opt_59.remaining or 0
1259
1265
  end,
1260
1266
  set = function(self, remainingDuration)
1261
- local ____remainingDuration_65 = remainingDuration
1262
- local ____opt_63 = self._timer
1263
- local remainingDurationDelta = ____remainingDuration_65 - (____opt_63 and ____opt_63.remaining or 0)
1267
+ local ____remainingDuration_63 = remainingDuration
1268
+ local ____opt_61 = self._timer
1269
+ local remainingDurationDelta = ____remainingDuration_63 - (____opt_61 and ____opt_61.remaining or 0)
1264
1270
  if remainingDurationDelta ~= 0 then
1265
1271
  self[103] = self[103] + remainingDurationDelta
1266
1272
  if remainingDuration <= 0 then
@@ -1290,6 +1296,32 @@ __TS__SetDescriptor(
1290
1296
  },
1291
1297
  true
1292
1298
  )
1299
+ __TS__SetDescriptor(
1300
+ Buff.prototype,
1301
+ "abilityCooldownFactor",
1302
+ {
1303
+ get = function(self)
1304
+ return self[143] or 1
1305
+ end,
1306
+ set = function(self, abilityCooldownFactor)
1307
+ local previousAbilityCooldownModifier = self[144]
1308
+ if previousAbilityCooldownModifier then
1309
+ for ____, ability in ipairs(self._unit.abilities) do
1310
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
1311
+ end
1312
+ end
1313
+ local function modifier(ability, level, cooldown)
1314
+ return cooldown * abilityCooldownFactor
1315
+ end
1316
+ for ____, ability in ipairs(self._unit.abilities) do
1317
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
1318
+ end
1319
+ self[144] = modifier
1320
+ self[143] = abilityCooldownFactor
1321
+ end
1322
+ },
1323
+ true
1324
+ )
1293
1325
  Buff.createdEvent = buffCreatedEvent
1294
1326
  Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1295
1327
  (function(self)
@@ -1348,5 +1380,8 @@ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1348
1380
  buffCreatedEvent:addListener(function(buff)
1349
1381
  UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1350
1382
  end)
1383
+ buffBeingDestroyedEvent:addListener(function(buff)
1384
+ UnitBehavior:forAll(buff.unit, "onBuffLost", buff)
1385
+ end)
1351
1386
  end)(Buff)
1352
1387
  return ____exports
@@ -1,5 +1,5 @@
1
1
  /** @noSelfInFile */
2
- import { Handle } from "../../core/types/handle";
2
+ import { Handle, HandleDestructor } from "../../core/types/handle";
3
3
  import { Event } from "../../event";
4
4
  import type { Item } from "../../core/types/item";
5
5
  import type { Unit } from "./unit";
@@ -67,6 +67,7 @@ export declare class UnitAbility extends Ability {
67
67
  get cooldownRemaining(): number;
68
68
  set cooldownRemaining(cooldownRemaining: number);
69
69
  interruptCast(): void;
70
+ protected onDestroy(): HandleDestructor;
70
71
  static get onCreate(): Event<[UnitAbility]>;
71
72
  static get onDestroy(): Event<[UnitAbility]>;
72
73
  }
@@ -93,6 +94,7 @@ export declare class ItemAbility extends Ability {
93
94
  get cooldownRemaining(): number;
94
95
  set cooldownRemaining(cooldownRemaining: number);
95
96
  interruptCast(): void;
97
+ protected onDestroy(): HandleDestructor;
96
98
  static get onCreate(): Event<[ItemAbility]>;
97
99
  static get onDestroy(): Event<[ItemAbility]>;
98
100
  }