warscript 0.0.1-dev.3370e98 → 0.0.1-dev.352d2b1

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 (65) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/frame.lua +14 -9
  4. package/core/types/player.d.ts +15 -0
  5. package/core/types/player.lua +53 -13
  6. package/core/types/playerCamera.lua +44 -0
  7. package/core/types/tileCell.d.ts +11 -1
  8. package/core/types/tileCell.lua +97 -0
  9. package/core/types/timer.d.ts +3 -2
  10. package/core/types/timer.lua +22 -2
  11. package/decl/native.d.ts +2 -2
  12. package/engine/behavior.d.ts +3 -0
  13. package/engine/behavior.lua +53 -0
  14. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  15. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  16. package/engine/behaviour/unit/stun-immunity.d.ts +2 -0
  17. package/engine/behaviour/unit/stun-immunity.lua +11 -2
  18. package/engine/behaviour/unit.d.ts +8 -2
  19. package/engine/behaviour/unit.lua +29 -2
  20. package/engine/buff.d.ts +10 -4
  21. package/engine/buff.lua +116 -84
  22. package/engine/internal/ability.d.ts +3 -1
  23. package/engine/internal/ability.lua +26 -9
  24. package/engine/internal/item.d.ts +13 -15
  25. package/engine/internal/item.lua +63 -49
  26. package/engine/internal/unit/ability.d.ts +14 -14
  27. package/engine/internal/unit/ability.lua +72 -45
  28. package/engine/internal/unit/fly-height.d.ts +7 -0
  29. package/engine/internal/unit/fly-height.lua +20 -0
  30. package/engine/internal/unit/main-selected.lua +12 -27
  31. package/engine/internal/unit+ability.lua +9 -0
  32. package/engine/internal/unit-missile-launch.lua +44 -20
  33. package/engine/internal/unit.d.ts +16 -11
  34. package/engine/internal/unit.lua +94 -63
  35. package/engine/local-client.d.ts +2 -0
  36. package/engine/local-client.lua +30 -0
  37. package/engine/object-data/entry/ability-type.lua +4 -1
  38. package/engine/object-field/ability.d.ts +3 -3
  39. package/engine/object-field/ability.lua +7 -6
  40. package/engine/object-field/unit.d.ts +4 -0
  41. package/engine/object-field/unit.lua +13 -0
  42. package/engine/object-field.d.ts +9 -3
  43. package/engine/object-field.lua +198 -115
  44. package/engine/random.d.ts +9 -0
  45. package/engine/random.lua +13 -0
  46. package/engine/standard/fields/unit.d.ts +2 -1
  47. package/engine/standard/fields/unit.lua +2 -0
  48. package/engine/synchronization.d.ts +11 -0
  49. package/engine/synchronization.lua +77 -0
  50. package/engine/text-tag.lua +3 -2
  51. package/engine/unit.d.ts +1 -0
  52. package/engine/unit.lua +1 -0
  53. package/net/socket.lua +1 -1
  54. package/objutil/buff.lua +1 -1
  55. package/package.json +2 -2
  56. package/patch-lualib.lua +1 -1
  57. package/utility/arrays.d.ts +1 -0
  58. package/utility/arrays.lua +8 -0
  59. package/utility/callback-array.d.ts +17 -0
  60. package/utility/callback-array.lua +61 -0
  61. package/utility/linked-set.d.ts +1 -0
  62. package/utility/linked-set.lua +19 -1
  63. package/utility/lua-maps.d.ts +11 -2
  64. package/utility/lua-maps.lua +33 -2
  65. package/utility/types.d.ts +3 -0
@@ -25,4 +25,25 @@ function RemoveBuffsSelfAbilityBehavior.prototype.onImpact(self, caster)
25
25
  self:resolveCurrentAbilityDependentValue(self.autoDispel)
26
26
  )
27
27
  end
28
+ ____exports.RemoveBuffsTargetAbilityBehavior = __TS__Class()
29
+ local RemoveBuffsTargetAbilityBehavior = ____exports.RemoveBuffsTargetAbilityBehavior
30
+ RemoveBuffsTargetAbilityBehavior.name = "RemoveBuffsTargetAbilityBehavior"
31
+ __TS__ClassExtends(RemoveBuffsTargetAbilityBehavior, AbilityBehavior)
32
+ function RemoveBuffsTargetAbilityBehavior.prototype.____constructor(self, ability, polarity, resistanceType, includeExpirationTimers, includeAuras, autoDispel)
33
+ AbilityBehavior.prototype.____constructor(self, ability)
34
+ self.polarity = polarity
35
+ self.resistanceType = resistanceType
36
+ self.includeExpirationTimers = includeExpirationTimers
37
+ self.includeAuras = includeAuras
38
+ self.autoDispel = autoDispel
39
+ end
40
+ function RemoveBuffsTargetAbilityBehavior.prototype.onUnitTargetImpact(self, _, target)
41
+ target:removeBuffs(
42
+ self:resolveCurrentAbilityDependentValue(self.polarity),
43
+ self:resolveCurrentAbilityDependentValue(self.resistanceType),
44
+ self:resolveCurrentAbilityDependentValue(self.includeExpirationTimers),
45
+ self:resolveCurrentAbilityDependentValue(self.includeAuras),
46
+ self:resolveCurrentAbilityDependentValue(self.autoDispel)
47
+ )
48
+ end
28
49
  return ____exports
@@ -8,6 +8,7 @@ export type StunImmunityUnitBehaviourParameters = {
8
8
  buffTypeIds?: LuaSet<BuffTypeId>;
9
9
  textTagPreset?: TextTagPreset;
10
10
  textTagText?: string;
11
+ additionalAction?: (this: void, unit: Unit) => void;
11
12
  };
12
13
  export declare class StunImmunityUnitBehavior extends UnitBehavior {
13
14
  readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
@@ -17,4 +18,5 @@ export declare class StunImmunityUnitBehavior extends UnitBehavior {
17
18
  onDamageReceived(): void;
18
19
  onTargetingAbilityChannelingStart(): void;
19
20
  onTargetingAbilityImpact(): void;
21
+ protected onEffect(): void;
20
22
  }
@@ -48,8 +48,15 @@ local function process(behavior)
48
48
  for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
49
49
  hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
50
50
  end
51
- if hasRemovedBuffs and behavior.parameters.textTagText ~= nil then
52
- TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
51
+ if hasRemovedBuffs then
52
+ behavior.onEffect(behavior)
53
+ if behavior.parameters.textTagText ~= nil then
54
+ TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
55
+ end
56
+ local ____opt_0 = behavior.parameters.additionalAction
57
+ if ____opt_0 ~= nil then
58
+ ____opt_0(behavior.unit)
59
+ end
53
60
  end
54
61
  end
55
62
  ____exports.StunImmunityUnitBehavior = __TS__Class()
@@ -79,5 +86,7 @@ end
79
86
  function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
80
87
  process(self)
81
88
  end
89
+ function StunImmunityUnitBehavior.prototype.onEffect(self)
90
+ end
82
91
  StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
83
92
  return ____exports
@@ -11,13 +11,18 @@ import { Destructor } from "../../destroyable";
11
11
  import type { Widget } from "../../core/types/widget";
12
12
  import { Destructable } from "../../core/types/destructable";
13
13
  import type { Buff } from "../buff";
14
+ import { UnitBonusType } from "../internal/unit/bonus";
15
+ import { Player } from "../../core/types/player";
14
16
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
15
17
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
18
+ readonly sourceAbilityBehavior?: AbilityBehavior;
19
+ private _bonusIdByBonusType?;
16
20
  constructor(unit: Unit);
17
21
  protected onDestroy(): Destructor;
18
- readonly sourceAbilityBehavior?: AbilityBehavior;
19
22
  get unit(): Unit;
20
- registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractUnit: (...args: Args) => Unit | undefined, range: number, listener: T): void;
23
+ protected getUnitBonus(bonusType: UnitBonusType): number;
24
+ protected addOrUpdateOrRemoveUnitBonus(bonusType: UnitBonusType, value: number): void;
25
+ protected registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractUnit: (...args: Args) => Unit | undefined, range: number, listener: T): void;
21
26
  onImmediateOrder(orderId: number): void;
22
27
  onTargetOrder(orderId: number, target: Widget): void;
23
28
  onPointOrder(orderId: number, x: number, y: number): void;
@@ -51,4 +56,5 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
51
56
  onItemChargesChanged(item: Item): void;
52
57
  onKill(target: Unit): void;
53
58
  onDeath(source: Unit | undefined): void;
59
+ onOwnerChange(previousOwner: Player): void;
54
60
  }
@@ -17,6 +17,11 @@ 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 ____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
20
25
  local behaviorsByEvent = {}
21
26
  local rangeByBehaviorByEvent = {}
22
27
  local listenerByBehaviorByEvent = {}
@@ -47,8 +52,26 @@ function UnitBehavior.prototype.onDestroy(self)
47
52
  end
48
53
  eventsByBehavior[self] = nil
49
54
  end
55
+ if self._bonusIdByBonusType ~= nil then
56
+ for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
57
+ removeUnitBonus(self.object, bonusType, bonusId)
58
+ end
59
+ end
50
60
  return Behavior.prototype.onDestroy(self)
51
61
  end
62
+ function UnitBehavior.prototype.getUnitBonus(self, bonusType)
63
+ local ____opt_6 = self._bonusIdByBonusType
64
+ local bonusId = ____opt_6 and ____opt_6[bonusType]
65
+ return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
66
+ end
67
+ function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
68
+ local bonusIdByBonusType = self._bonusIdByBonusType
69
+ if bonusIdByBonusType == nil then
70
+ bonusIdByBonusType = {}
71
+ self._bonusIdByBonusType = bonusIdByBonusType
72
+ end
73
+ bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self.object, bonusType, bonusIdByBonusType[bonusType], value)
74
+ end
52
75
  function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
53
76
  local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
54
77
  rangeByBehavior[self] = range
@@ -65,8 +88,7 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUni
65
88
  for behavior in pairs(behaviors) do
66
89
  local range = rangeByBehavior[behavior]
67
90
  if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
68
- local ____self_6 = behavior
69
- ____self_6[listenerByBehavior[behavior]](____self_6, ...)
91
+ safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
70
92
  end
71
93
  end
72
94
  end
@@ -143,6 +165,8 @@ function UnitBehavior.prototype.onKill(self, target)
143
165
  end
144
166
  function UnitBehavior.prototype.onDeath(self, source)
145
167
  end
168
+ function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
169
+ end
146
170
  __TS__SetDescriptor(
147
171
  UnitBehavior.prototype,
148
172
  "unit",
@@ -254,6 +278,9 @@ __TS__SetDescriptor(
254
278
  Unit.itemChargesChangedEvent:addListener(function(unit, item)
255
279
  ____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
256
280
  end)
281
+ Unit.onOwnerChange:addListener(function(unit, previousOwner)
282
+ ____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
283
+ end)
257
284
  end)(UnitBehavior)
258
285
  Unit.destroyEvent:addListener(function(unit)
259
286
  ____exports.UnitBehavior:forAll(unit, "destroy")
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)
@@ -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
  }