warscript 0.0.1-dev.ee6f224 → 0.0.1-dev.ef189a5

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 (63) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/player.d.ts +16 -0
  4. package/core/types/player.lua +57 -14
  5. package/core/types/tileCell.d.ts +2 -1
  6. package/core/types/tileCell.lua +5 -0
  7. package/core/types/timer.d.ts +3 -2
  8. package/core/types/timer.lua +8 -2
  9. package/engine/behavior.d.ts +7 -1
  10. package/engine/behavior.lua +88 -65
  11. package/engine/behaviour/ability/apply-buff.lua +4 -4
  12. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  13. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  14. package/engine/behaviour/ability.d.ts +2 -1
  15. package/engine/behaviour/ability.lua +2 -1
  16. package/engine/behaviour/unit/stun-immunity.d.ts +8 -4
  17. package/engine/behaviour/unit/stun-immunity.lua +12 -3
  18. package/engine/behaviour/unit.d.ts +9 -3
  19. package/engine/behaviour/unit.lua +94 -22
  20. package/engine/buff.d.ts +12 -2
  21. package/engine/buff.lua +80 -17
  22. package/engine/internal/item.d.ts +12 -12
  23. package/engine/internal/item.lua +41 -26
  24. package/engine/internal/unit/ability.d.ts +14 -14
  25. package/engine/internal/unit/ability.lua +72 -45
  26. package/engine/internal/unit/fly-height.d.ts +7 -0
  27. package/engine/internal/unit/fly-height.lua +20 -0
  28. package/engine/internal/unit/main-selected.lua +12 -27
  29. package/engine/internal/unit/scale.d.ts +7 -0
  30. package/engine/internal/unit/scale.lua +20 -0
  31. package/engine/internal/unit-missile-launch.lua +44 -20
  32. package/engine/internal/unit.d.ts +13 -10
  33. package/engine/internal/unit.lua +83 -64
  34. package/engine/local-client.d.ts +2 -0
  35. package/engine/local-client.lua +30 -0
  36. package/engine/object-data/entry/ability-type.lua +4 -1
  37. package/engine/object-data/entry/destructible-type.d.ts +5 -1
  38. package/engine/object-data/entry/destructible-type.lua +12 -0
  39. package/engine/object-data/entry/unit-type.d.ts +4 -0
  40. package/engine/object-data/entry/unit-type.lua +76 -32
  41. package/engine/object-field/unit.d.ts +13 -1
  42. package/engine/object-field/unit.lua +57 -0
  43. package/engine/object-field.d.ts +7 -1
  44. package/engine/object-field.lua +199 -112
  45. package/engine/standard/fields/ability.d.ts +2 -2
  46. package/engine/standard/fields/ability.lua +2 -2
  47. package/engine/standard/fields/unit.d.ts +3 -1
  48. package/engine/standard/fields/unit.lua +4 -0
  49. package/engine/synchronization.d.ts +11 -0
  50. package/engine/synchronization.lua +77 -0
  51. package/engine/text-tag.lua +3 -2
  52. package/engine/unit.d.ts +2 -0
  53. package/engine/unit.lua +2 -0
  54. package/net/socket.lua +1 -1
  55. package/objutil/buff.lua +1 -1
  56. package/package.json +2 -2
  57. package/utility/arrays.d.ts +1 -0
  58. package/utility/arrays.lua +8 -0
  59. package/utility/callback-array.d.ts +5 -1
  60. package/utility/callback-array.lua +16 -1
  61. package/utility/linked-set.d.ts +1 -0
  62. package/utility/linked-set.lua +19 -1
  63. package/utility/types.d.ts +3 -0
@@ -7,8 +7,9 @@ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
7
7
  local ____exports = {}
8
8
  local ____behavior = require("engine.behavior")
9
9
  local Behavior = ____behavior.Behavior
10
- local ____unit = require("engine.unit")
10
+ local ____unit = require("engine.internal.unit")
11
11
  local Unit = ____unit.Unit
12
+ require("engine.internal.unit.ability")
12
13
  local ____ability = require("engine.internal.ability")
13
14
  local Ability = ____ability.Ability
14
15
  local ____effect = require("core.types.effect")
@@ -4,17 +4,21 @@ import { Unit } from "../../unit";
4
4
  import { BuffTypeId } from "../../object-data/entry/buff-type";
5
5
  import { TextTagPreset } from "../../text-tag";
6
6
  import { Destructor } from "../../../destroyable";
7
- export type StunImmunityUnitBehaviourParameters = {
7
+ import { BehaviorPriority } from "../../behavior";
8
+ export type StunImmunityUnitBehaviorParameters = {
9
+ readonly priority?: BehaviorPriority;
8
10
  buffTypeIds?: LuaSet<BuffTypeId>;
9
11
  textTagPreset?: TextTagPreset;
10
12
  textTagText?: string;
13
+ additionalAction?: (this: void, unit: Unit) => void;
11
14
  };
12
15
  export declare class StunImmunityUnitBehavior extends UnitBehavior {
13
- readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
14
- static defaultParameters: StunImmunityUnitBehaviourParameters;
15
- constructor(unit: Unit, parameters?: Readonly<StunImmunityUnitBehaviourParameters>);
16
+ readonly parameters: Readonly<StunImmunityUnitBehaviorParameters>;
17
+ static defaultParameters: StunImmunityUnitBehaviorParameters;
18
+ constructor(unit: Unit, parameters?: Readonly<StunImmunityUnitBehaviorParameters>);
16
19
  protected onDestroy(): Destructor;
17
20
  onDamageReceived(): void;
18
21
  onTargetingAbilityChannelingStart(): void;
19
22
  onTargetingAbilityImpact(): void;
23
+ protected onEffect(): void;
20
24
  }
@@ -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()
@@ -60,7 +67,7 @@ function StunImmunityUnitBehavior.prototype.____constructor(self, unit, paramete
60
67
  if parameters == nil then
61
68
  parameters = ____exports.StunImmunityUnitBehavior.defaultParameters
62
69
  end
63
- UnitBehavior.prototype.____constructor(self, unit)
70
+ UnitBehavior.prototype.____constructor(self, unit, parameters.priority)
64
71
  self.parameters = parameters
65
72
  unit:decrementStunCounter()
66
73
  process(self)
@@ -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
@@ -1,26 +1,29 @@
1
1
  /** @noSelfInFile */
2
- import { Behavior } from "../behavior";
2
+ import { Behavior, BehaviorPriority } from "../behavior";
3
3
  import { Ability } from "../internal/ability";
4
4
  import { DamageEvent, DamagingEvent, Unit } from "../internal/unit";
5
5
  import "../internal/unit+ability";
6
6
  import "../internal/unit-missile-launch";
7
7
  import { Item } from "../internal/item";
8
- import type { AbilityBehavior } from "./ability";
8
+ import { AbilityBehavior } from "./ability";
9
9
  import { Event } from "../../event";
10
10
  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
14
  import { UnitBonusType } from "../internal/unit/bonus";
15
+ import { Player } from "../../core/types/player";
16
+ import { UnitTypeId } from "../object-data/entry/unit-type";
15
17
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
16
18
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
17
19
  readonly sourceAbilityBehavior?: AbilityBehavior;
18
20
  private _bonusIdByBonusType?;
19
- constructor(unit: Unit);
21
+ constructor(unit: Unit, priority?: BehaviorPriority);
20
22
  protected onDestroy(): Destructor;
21
23
  get unit(): Unit;
22
24
  protected getUnitBonus(bonusType: UnitBonusType): number;
23
25
  protected addOrUpdateOrRemoveUnitBonus(bonusType: UnitBonusType, value: number): void;
26
+ protected registerOwningPlayerEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractPlayer: (...args: Args) => Player | undefined, listener: T): void;
24
27
  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;
25
28
  onImmediateOrder(orderId: number): void;
26
29
  onTargetOrder(orderId: number, target: Widget): void;
@@ -48,6 +51,7 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
48
51
  onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
49
52
  onTargetingAbilityImpact(ability: Ability, source: Unit): void;
50
53
  onBuffGained(buff: Buff): void;
54
+ onBuffLost(buff: Buff): void;
51
55
  onItemDropped(item: Item): void;
52
56
  onItemPickedUp(item: Item): void;
53
57
  onItemUsed(item: Item): void;
@@ -55,4 +59,6 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
55
59
  onItemChargesChanged(item: Item): void;
56
60
  onKill(target: Unit): void;
57
61
  onDeath(source: Unit | undefined): void;
62
+ onOwnerChange(previousOwner: Player): void;
63
+ static bindUnitType<Args extends any[]>(this: UnitBehaviorConstructor<Args>, unitTypeId: UnitTypeId, ...args: Args): void;
58
64
  }
@@ -22,35 +22,53 @@ local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
22
22
  local getUnitBonus = ____bonus.getUnitBonus
23
23
  local removeUnitBonus = ____bonus.removeUnitBonus
24
24
  local safeCall = warpack.safeCall
25
- local behaviorsByEvent = {}
26
- local rangeByBehaviorByEvent = {}
27
- local listenerByBehaviorByEvent = {}
28
- local eventsByBehavior = {}
25
+ local createBehaviorFunctionsByUnitTypeId = {}
26
+ local behaviorsByOwningPlayerEvent = {}
27
+ local listenerByBehaviorByOwningPlayerEvent = {}
28
+ local owningPlayerEventsByBehavior = {}
29
+ local behaviorsByInRangeUnitEvent = {}
30
+ local rangeByBehaviorByInRangeUnitEvent = {}
31
+ local listenerByBehaviorByInRangeUnitEvent = {}
32
+ local inRangeUnitEventsByBehavior = {}
29
33
  ____exports.UnitBehavior = __TS__Class()
30
34
  local UnitBehavior = ____exports.UnitBehavior
31
35
  UnitBehavior.name = "UnitBehavior"
32
36
  __TS__ClassExtends(UnitBehavior, Behavior)
33
- function UnitBehavior.prototype.____constructor(self, unit)
34
- Behavior.prototype.____constructor(self, unit)
37
+ function UnitBehavior.prototype.____constructor(self, unit, priority)
38
+ Behavior.prototype.____constructor(self, unit, priority)
35
39
  end
36
40
  function UnitBehavior.prototype.onDestroy(self)
37
- local events = eventsByBehavior[self]
38
- if events ~= nil then
39
- for event in pairs(events) do
40
- 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]
41
45
  if ____opt_0 ~= nil then
42
46
  ____opt_0:remove(self)
43
47
  end
44
- local ____opt_2 = rangeByBehaviorByEvent[event]
48
+ local ____opt_2 = listenerByBehaviorByOwningPlayerEvent[event]
45
49
  if ____opt_2 ~= nil then
46
50
  ____opt_2[self] = nil
47
51
  end
48
- 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]
49
59
  if ____opt_4 ~= nil then
50
- ____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
51
69
  end
52
70
  end
53
- eventsByBehavior[self] = nil
71
+ inRangeUnitEventsByBehavior[self] = nil
54
72
  end
55
73
  if self._bonusIdByBonusType ~= nil then
56
74
  for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
@@ -60,8 +78,8 @@ function UnitBehavior.prototype.onDestroy(self)
60
78
  return Behavior.prototype.onDestroy(self)
61
79
  end
62
80
  function UnitBehavior.prototype.getUnitBonus(self, bonusType)
63
- local ____opt_6 = self._bonusIdByBonusType
64
- local bonusId = ____opt_6 and ____opt_6[bonusType]
81
+ local ____opt_10 = self._bonusIdByBonusType
82
+ local bonusId = ____opt_10 and ____opt_10[bonusType]
65
83
  return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
66
84
  end
67
85
  function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
@@ -72,16 +90,40 @@ function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, va
72
90
  end
73
91
  bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self.object, bonusType, bonusIdByBonusType[bonusType], value)
74
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
75
117
  function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
76
- local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
118
+ local rangeByBehavior = getOrPut(rangeByBehaviorByInRangeUnitEvent, event, mutableLuaMap)
77
119
  rangeByBehavior[self] = range
78
- local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
120
+ local listenerByBehavior = getOrPut(listenerByBehaviorByInRangeUnitEvent, event, mutableLuaMap)
79
121
  listenerByBehavior[self] = listener
80
- getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
81
- local behaviors = behaviorsByEvent[event]
122
+ getOrPut(inRangeUnitEventsByBehavior, self, mutableLuaSet)[event] = true
123
+ local behaviors = behaviorsByInRangeUnitEvent[event]
82
124
  if behaviors == nil then
83
125
  event:addListener(function(...)
84
- local behaviors = behaviorsByEvent[event]
126
+ local behaviors = behaviorsByInRangeUnitEvent[event]
85
127
  if behaviors ~= nil then
86
128
  local unit = extractUnit(...)
87
129
  if unit ~= nil then
@@ -95,7 +137,7 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUni
95
137
  end
96
138
  end)
97
139
  behaviors = __TS__New(LinkedSet)
98
- behaviorsByEvent[event] = behaviors
140
+ behaviorsByInRangeUnitEvent[event] = behaviors
99
141
  end
100
142
  behaviors:add(self)
101
143
  end
@@ -151,6 +193,8 @@ function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
151
193
  end
152
194
  function UnitBehavior.prototype.onBuffGained(self, buff)
153
195
  end
196
+ function UnitBehavior.prototype.onBuffLost(self, buff)
197
+ end
154
198
  function UnitBehavior.prototype.onItemDropped(self, item)
155
199
  end
156
200
  function UnitBehavior.prototype.onItemPickedUp(self, item)
@@ -165,6 +209,23 @@ function UnitBehavior.prototype.onKill(self, target)
165
209
  end
166
210
  function UnitBehavior.prototype.onDeath(self, source)
167
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
168
229
  __TS__SetDescriptor(
169
230
  UnitBehavior.prototype,
170
231
  "unit",
@@ -276,7 +337,18 @@ __TS__SetDescriptor(
276
337
  Unit.itemChargesChangedEvent:addListener(function(unit, item)
277
338
  ____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
278
339
  end)
340
+ Unit.onOwnerChange:addListener(function(unit, previousOwner)
341
+ ____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
342
+ end)
279
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)
280
352
  Unit.destroyEvent:addListener(function(unit)
281
353
  ____exports.UnitBehavior:forAll(unit, "destroy")
282
354
  end)
package/engine/buff.d.ts CHANGED
@@ -13,6 +13,7 @@ import { UnitBehavior } from "./behaviour/unit";
13
13
  import type { Widget } from "../core/types/widget";
14
14
  import { Destructor } from "../destroyable";
15
15
  import { Event } from "../event";
16
+ import { AbilityBehavior } from "./behaviour/ability";
16
17
  export type BuffConstructor<T extends Buff<any> = Buff<any>, Args extends any[] = any> = OmitConstructor<typeof Buff<any>> & (new (...args: Args) => T);
17
18
  type EnumParameterValueType<T extends number> = T | AbilityEnumLevelField<T>;
18
19
  type NumberParameterValueType = number | AbilityNumberField | AbilityNumberLevelField;
@@ -79,6 +80,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
79
80
  healingOnExpiration?: NumberParameterValueType;
80
81
  killsOnExpiration?: BooleanParameterValueType;
81
82
  explodesOnExpiration?: BooleanParameterValueType;
83
+ abilityCooldownFactor?: NumberParameterValueType;
82
84
  uniqueGroup?: BuffUniqueGroup;
83
85
  } : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
84
86
  declare const enum BuffPropertyKey {
@@ -124,7 +126,9 @@ declare const enum BuffPropertyKey {
124
126
  PROVIDES_INVULNERABILITY = 139,
125
127
  KILLS_ON_EXPIRATION = 140,
126
128
  EXPLODES_ON_EXPIRATION = 141,
127
- MISS_PROBABILITY = 142
129
+ MISS_PROBABILITY = 142,
130
+ ABILITY_COOLDOWN_FACTOR = 143,
131
+ ABILITY_COOLDOWN_MODIFIER = 144
128
132
  }
129
133
  export declare const enum BuffTypeIdSelectionPolicy {
130
134
  LEAST_DURATION = 0
@@ -138,7 +142,7 @@ export type BuffConstructorParameters<AdditionalParameters extends BuffAdditiona
138
142
  polarity: BuffPolarityParameterType,
139
143
  resistanceType: BuffResistanceTypeParameterType,
140
144
  ...abilityOrParameters: [
141
- ability?: Ability,
145
+ ability?: Ability | AbilityBehavior,
142
146
  parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
143
147
  ] | [parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>]
144
148
  ];
@@ -187,6 +191,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
187
191
  private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
188
192
  private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
189
193
  private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
194
+ private [BuffPropertyKey.ABILITY_COOLDOWN_FACTOR]?;
195
+ private [BuffPropertyKey.ABILITY_COOLDOWN_MODIFIER]?;
190
196
  protected static readonly defaultParameters: BuffParameters;
191
197
  get source(): Unit;
192
198
  readonly typeId: ApplicableBuffTypeId;
@@ -262,6 +268,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
262
268
  get duration(): number;
263
269
  get remainingDuration(): number;
264
270
  set remainingDuration(remainingDuration: number);
271
+ get abilityCooldownFactor(): number;
272
+ set abilityCooldownFactor(abilityCooldownFactor: number);
273
+ onAbilityGained(ability: Ability): void;
274
+ onAbilityLost(ability: Ability): void;
265
275
  flashEffect(...parameters: [
266
276
  ...widgetOrXY: [] | [Widget] | [x: number, x: number],
267
277
  ...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
@@ -50,6 +51,10 @@ local ____item = require("engine.internal.item")
50
51
  local Item = ____item.Item
51
52
  local ____destructable = require("core.types.destructable")
52
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
+ local ____ability = require("engine.behaviour.ability")
57
+ local AbilityBehavior = ____ability.AbilityBehavior
53
58
  local getUnitAbility = BlzGetUnitAbility
54
59
  local stringValueByBuffTypeIdByFieldId = postcompile(function()
55
60
  local stringValueByBuffTypeIdByFieldId = {}
@@ -121,7 +126,8 @@ local buffParametersKeys = {
121
126
  damageOnExpiration = true,
122
127
  healingOnExpiration = true,
123
128
  killsOnExpiration = true,
124
- explodesOnExpiration = true
129
+ explodesOnExpiration = true,
130
+ abilityCooldownFactor = true
125
131
  }
126
132
  local function resolveEnumValue(ability, level, value)
127
133
  if value == nil or type(value) == "number" then
@@ -198,7 +204,8 @@ local buffNumberParameters = {
198
204
  "healingPerInterval",
199
205
  "healingOverDuration",
200
206
  "damageOnExpiration",
201
- "healingOnExpiration"
207
+ "healingOnExpiration",
208
+ "abilityCooldownFactor"
202
209
  }
203
210
  local unsuccessfulApplicationMarker = {}
204
211
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -317,33 +324,38 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
317
324
  local polarity
318
325
  local resistanceType
319
326
  local ability
327
+ local abilityBehavior
320
328
  if type(typeIdOrTypeIds) ~= "number" then
321
329
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
322
330
  polarity = resistanceTypeOrPolarity
323
331
  resistanceType = abilityOrParametersOrResistanceType
324
- if __TS__InstanceOf(parametersOrAbility, Ability) or parametersOrAbility == nil then
332
+ if __TS__InstanceOf(parametersOrAbility, AbilityBehavior) then
333
+ abilityBehavior = parametersOrAbility
334
+ ability = abilityBehavior.ability
335
+ elseif __TS__InstanceOf(parametersOrAbility, Ability) then
325
336
  ability = parametersOrAbility
326
- else
327
- ability = nil
337
+ elseif parametersOrAbility ~= nil then
328
338
  parameters = parametersOrAbility
329
339
  end
330
340
  else
331
341
  typeId = typeIdOrTypeIds
332
342
  polarity = polarityOrTypeIdSelectionPolicy
333
343
  resistanceType = resistanceTypeOrPolarity
334
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) or abilityOrParametersOrResistanceType == nil then
344
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, AbilityBehavior) then
345
+ abilityBehavior = abilityOrParametersOrResistanceType
346
+ ability = abilityBehavior.ability
347
+ parameters = parametersOrAbility
348
+ elseif __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
335
349
  ability = abilityOrParametersOrResistanceType
336
350
  parameters = parametersOrAbility
337
- else
338
- ability = nil
351
+ elseif abilityOrParametersOrResistanceType ~= nil then
339
352
  parameters = abilityOrParametersOrResistanceType
353
+ else
354
+ parameters = parametersOrAbility
340
355
  end
341
356
  end
357
+ self.sourceAbilityBehavior = abilityBehavior
342
358
  self.typeId = typeId
343
- if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
344
- parameters = ability
345
- ability = nil
346
- end
347
359
  local defaultParameters = self.constructor.defaultParameters
348
360
  local level = parameters and parameters.level or defaultParameters.level
349
361
  local spellStealPriority = parameters and parameters.spellStealPriority or defaultParameters.spellStealPriority
@@ -506,6 +518,22 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
506
518
  self[100] = 1
507
519
  Event.invoke(buffCreatedEvent, self)
508
520
  end
521
+ function Buff.prototype.onAbilityGained(self, ability)
522
+ if __TS__InstanceOf(ability, UnitAbility) then
523
+ local abilityCooldownModifier = self[144]
524
+ if abilityCooldownModifier then
525
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
526
+ end
527
+ end
528
+ end
529
+ function Buff.prototype.onAbilityLost(self, ability)
530
+ if __TS__InstanceOf(ability, UnitAbility) then
531
+ local abilityCooldownModifier = self[144]
532
+ if abilityCooldownModifier then
533
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
534
+ end
535
+ end
536
+ end
509
537
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
510
538
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
511
539
  Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
@@ -580,6 +608,12 @@ function Buff.prototype.onDestroy(self)
580
608
  behavior:destroy()
581
609
  end
582
610
  end
611
+ local previousAbilityCooldownModifier = self[144]
612
+ if previousAbilityCooldownModifier then
613
+ for ____, ability in ipairs(self._unit.abilities) do
614
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
615
+ end
616
+ end
583
617
  if self[139] then
584
618
  unit:decrementInvulnerabilityCounter()
585
619
  end
@@ -588,7 +622,7 @@ function Buff.prototype.onDestroy(self)
588
622
  end
589
623
  if self[136] then
590
624
  if self[137] then
591
- unit:decrementStunCounter()
625
+ unit:decrementForceStunCounter()
592
626
  end
593
627
  unit:decrementStunCounter()
594
628
  end
@@ -987,13 +1021,13 @@ __TS__SetDescriptor(
987
1021
  set = function(self, stuns)
988
1022
  if not stuns and self[136] then
989
1023
  if self[137] then
990
- self.object:decrementStunCounter()
1024
+ self.object:decrementForceStunCounter()
991
1025
  end
992
1026
  self.object:decrementStunCounter()
993
1027
  self[136] = nil
994
1028
  elseif stuns and not self[136] then
995
1029
  if self[137] then
996
- self.object:incrementStunCounter()
1030
+ self.object:incrementForceStunCounter()
997
1031
  end
998
1032
  self.object:incrementStunCounter()
999
1033
  self[136] = true
@@ -1016,12 +1050,12 @@ __TS__SetDescriptor(
1016
1050
  set = function(self, ignoresStunImmunity)
1017
1051
  if not ignoresStunImmunity and self[137] then
1018
1052
  if self[136] then
1019
- self.object:decrementStunCounter()
1053
+ self.object:decrementForceStunCounter()
1020
1054
  end
1021
1055
  self[137] = nil
1022
1056
  elseif ignoresStunImmunity and not self[137] then
1023
1057
  if self[136] then
1024
- self.object:incrementStunCounter()
1058
+ self.object:incrementForceStunCounter()
1025
1059
  end
1026
1060
  self[137] = true
1027
1061
  end
@@ -1269,6 +1303,32 @@ __TS__SetDescriptor(
1269
1303
  },
1270
1304
  true
1271
1305
  )
1306
+ __TS__SetDescriptor(
1307
+ Buff.prototype,
1308
+ "abilityCooldownFactor",
1309
+ {
1310
+ get = function(self)
1311
+ return self[143] or 1
1312
+ end,
1313
+ set = function(self, abilityCooldownFactor)
1314
+ local previousAbilityCooldownModifier = self[144]
1315
+ if previousAbilityCooldownModifier then
1316
+ for ____, ability in ipairs(self._unit.abilities) do
1317
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
1318
+ end
1319
+ end
1320
+ local function modifier(ability, level, cooldown)
1321
+ return cooldown * abilityCooldownFactor
1322
+ end
1323
+ for ____, ability in ipairs(self._unit.abilities) do
1324
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
1325
+ end
1326
+ self[144] = modifier
1327
+ self[143] = abilityCooldownFactor
1328
+ end
1329
+ },
1330
+ true
1331
+ )
1272
1332
  Buff.createdEvent = buffCreatedEvent
1273
1333
  Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1274
1334
  (function(self)
@@ -1327,5 +1387,8 @@ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1327
1387
  buffCreatedEvent:addListener(function(buff)
1328
1388
  UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1329
1389
  end)
1390
+ buffBeingDestroyedEvent:addListener(function(buff)
1391
+ UnitBehavior:forAll(buff.unit, "onBuffLost", buff)
1392
+ end)
1330
1393
  end)(Buff)
1331
1394
  return ____exports
@@ -28,22 +28,22 @@ export declare class Item extends Handle<jitem> {
28
28
  get extendedTooltip(): string;
29
29
  set iconPath(v: string);
30
30
  get iconPath(): string;
31
- set dropOnDeath(v: boolean);
32
- get dropOnDeath(): boolean;
33
- set droppable(v: boolean);
34
- get droppable(): boolean;
35
- set pawnable(v: boolean);
36
- get pawnable(): boolean;
37
- set perishable(v: boolean);
38
- get perishable(): boolean;
39
- set powerup(v: boolean);
40
- get powerup(): boolean;
31
+ set dropsOnDeath(dropsOnDeath: boolean);
32
+ get dropsOnDeath(): boolean;
33
+ set canBeDropped(canBeDropped: boolean);
34
+ get canBeDropped(): boolean;
35
+ set canBeSold(canBeSold: boolean);
36
+ get canBeSold(): boolean;
37
+ set perishes(perishes: boolean);
38
+ get perishes(): boolean;
39
+ set isPowerUp(isPowerUp: boolean);
40
+ get isPowerUp(): boolean;
41
41
  get isAlive(): boolean;
42
42
  get isDead(): boolean;
43
43
  set isInvulnerable(isInvulnerable: boolean);
44
44
  get isInvulnerable(): boolean;
45
- set usable(v: boolean);
46
- get usable(): boolean;
45
+ set isActivelyUsed(isActivelyUsed: boolean);
46
+ get isActivelyUsed(): boolean;
47
47
  set visible(v: boolean);
48
48
  get visible(): boolean;
49
49
  set level(v: number);