warscript 0.0.1-dev.e196516 → 0.0.1-dev.e49ec00

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.
@@ -22,7 +22,7 @@ export declare class Timer extends AbstractDestroyable {
22
22
  pause(): void;
23
23
  resume(): void;
24
24
  static create(): Timer;
25
- static run<Args extends any[]>(callback: (...args: Args) => void, ...args: Args): void;
25
+ static run<Args extends any[]>(callback: (this: void, ...args: Args) => void, ...args: Args): void;
26
26
  static simple<Args extends any[]>(timeout: number, callback: (...args: Args) => void, ...args: Args): Timer;
27
27
  static periodic<Args extends any[]>(period: number, callback: (this: void, timer: Timer, ...args: Args) => void, ...args: Args): Timer;
28
28
  static counted(period: number, count: number, callback: (this: void, timer: Timer) => void): Timer;
@@ -148,7 +148,7 @@ function ApplyBuffChannelingTargetAbilityBehavior.prototype.onStop(self)
148
148
  self.buff = nil
149
149
  end
150
150
  end
151
- Buff.destroyEvent:addListener(function(buff)
151
+ Buff.beingDestroyedEvent:addListener(function(buff)
152
152
  local behavior = behaviorByBuff[buff]
153
153
  if behavior ~= nil then
154
154
  behaviorByBuff[buff] = nil
@@ -5,7 +5,6 @@ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
5
5
  local __TS__New = ____lualib.__TS__New
6
6
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
7
7
  local ____exports = {}
8
- local createUnitEventListener
9
8
  local ____behavior = require("engine.behavior")
10
9
  local Behavior = ____behavior.Behavior
11
10
  local ____unit = require("engine.unit")
@@ -30,17 +29,9 @@ local ____ability = require("engine.object-field.ability")
30
29
  local AbilityField = ____ability.AbilityField
31
30
  local AbilityLevelField = ____ability.AbilityLevelField
32
31
  local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
33
- local ____timer = require("core.types.timer")
34
- local Timer = ____timer.Timer
35
32
  local createBehaviorFunctionsByAbilityTypeId = {}
36
33
  local exclusiveOnImpactHandlerAbilityBehaviorByAbility = setmetatable({}, {__mode = "k"})
37
- local function createZeroTimerUnitEventListener(key)
38
- local unitEventListener = createUnitEventListener(key)
39
- return function(unit, ability, ...)
40
- Timer:run(unitEventListener, unit, ability, ...)
41
- end
42
- end
43
- createUnitEventListener = function(key)
34
+ local function createUnitEventListener(key)
44
35
  return function(unit, ability, ...)
45
36
  ____exports.AbilityBehavior:forAll(ability, key, unit, ...)
46
37
  end
@@ -275,12 +266,12 @@ __TS__SetDescriptor(
275
266
  Unit.abilityPointTargetChannelingStartEvent:addListener(createUnitEventListener("onPointTargetChannelingStart"))
276
267
  Unit.abilityNoTargetChannelingStartEvent:addListener(createUnitEventListener("onNoTargetChannelingStart"))
277
268
  Unit.abilityImpactEvent:addListener(createUnitEventListener("onImpact"))
278
- Unit.abilityWidgetTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onWidgetTargetImpact"))
279
- Unit.abilityUnitTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onUnitTargetImpact"))
280
- Unit.abilityItemTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onItemTargetImpact"))
281
- Unit.abilityDestructibleTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onDestructibleTargetImpact"))
282
- Unit.abilityPointTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onPointTargetImpact"))
283
- Unit.abilityNoTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onNoTargetImpact"))
269
+ Unit.abilityWidgetTargetImpactEvent:addListener(createUnitEventListener("onWidgetTargetImpact"))
270
+ Unit.abilityUnitTargetImpactEvent:addListener(createUnitEventListener("onUnitTargetImpact"))
271
+ Unit.abilityItemTargetImpactEvent:addListener(createUnitEventListener("onItemTargetImpact"))
272
+ Unit.abilityDestructibleTargetImpactEvent:addListener(createUnitEventListener("onDestructibleTargetImpact"))
273
+ Unit.abilityPointTargetImpactEvent:addListener(createUnitEventListener("onPointTargetImpact"))
274
+ Unit.abilityNoTargetImpactEvent:addListener(createUnitEventListener("onNoTargetImpact"))
284
275
  Unit.abilityChannelingFinishEvent:addListener(createUnitEventListener("onChannelingFinish"))
285
276
  Unit.abilityStopEvent:addListener(createUnitEventListener("onStop"))
286
277
  end)(AbilityBehavior)
@@ -10,9 +10,11 @@ export type StunImmunityUnitBehaviourParameters = {
10
10
  textTagText?: string;
11
11
  };
12
12
  export declare class StunImmunityUnitBehavior extends UnitBehavior {
13
- private readonly parameters;
13
+ readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
14
14
  static defaultParameters: StunImmunityUnitBehaviourParameters;
15
- constructor(unit: Unit, parameters?: StunImmunityUnitBehaviourParameters);
15
+ constructor(unit: Unit, parameters?: Readonly<StunImmunityUnitBehaviourParameters>);
16
16
  protected onDestroy(): Destructor;
17
- private onBuffsCheck;
17
+ onDamageReceived(): void;
18
+ onTargetingAbilityChannelingStart(): void;
19
+ onTargetingAbilityImpact(): void;
18
20
  }
@@ -12,31 +12,46 @@ local flatMapToLuaSet = ____arrays.flatMapToLuaSet
12
12
  local map = ____arrays.map
13
13
  local ____text_2Dtag = require("engine.text-tag")
14
14
  local TextTag = ____text_2Dtag.TextTag
15
+ local ____timer = require("core.types.timer")
16
+ local Timer = ____timer.Timer
15
17
  local DEFAULT_BUFF_TYPE_IDS = postcompile(function()
16
18
  return flatMapToLuaSet(
17
19
  AbilityType:getAllByBaseIds(map({
18
- "Aslo",
19
- "AHtc",
20
- "Aens",
21
- "Aprg",
22
- "Apg2",
23
- "AOeq",
24
- "SNeq",
25
- "Aweb",
26
- "Afra",
27
- "Afrb",
28
- "Afrc",
29
- "Afr2",
30
- "Acri",
31
- "Scri",
32
- "AUfn",
33
- "Aspo",
34
- "AEer",
35
- "ACwb"
20
+ "AHtb",
21
+ "AHbh",
22
+ "AOws",
23
+ "AOw2",
24
+ "AUim",
25
+ "Acyc",
26
+ "ANfb",
27
+ "ANsb",
28
+ "ANcs",
29
+ "ANc1",
30
+ "ANc2",
31
+ "ANc3",
32
+ "ACbh",
33
+ "ANbh",
34
+ "SCc1",
35
+ "ACcy",
36
+ "ANb2",
37
+ "Awrs",
38
+ "Awrh",
39
+ "Awrg",
40
+ "ACtb",
41
+ "ACcb"
36
42
  }, fourCC)),
37
43
  function(abilityType) return __TS__ArrayFlat(abilityType.buffTypeIds) end
38
44
  )
39
45
  end)
46
+ local function process(behavior)
47
+ local hasRemovedBuffs = false
48
+ for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
49
+ hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
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)
53
+ end
54
+ end
40
55
  ____exports.StunImmunityUnitBehavior = __TS__Class()
41
56
  local StunImmunityUnitBehavior = ____exports.StunImmunityUnitBehavior
42
57
  StunImmunityUnitBehavior.name = "StunImmunityUnitBehavior"
@@ -48,20 +63,21 @@ function StunImmunityUnitBehavior.prototype.____constructor(self, unit, paramete
48
63
  UnitBehavior.prototype.____constructor(self, unit)
49
64
  self.parameters = parameters
50
65
  unit:decrementStunCounter()
51
- self:onBuffsCheck()
66
+ process(self)
52
67
  end
53
68
  function StunImmunityUnitBehavior.prototype.onDestroy(self)
54
69
  self.unit:incrementStunCounter()
55
70
  return UnitBehavior.prototype.onDestroy(self)
56
71
  end
57
- function StunImmunityUnitBehavior.prototype.onBuffsCheck(self)
58
- local hasRemovedBuffs = false
59
- for buffTypeId in pairs(self.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
60
- hasRemovedBuffs = hasRemovedBuffs or self.unit:removeBuff(buffTypeId)
61
- end
62
- if hasRemovedBuffs and self.parameters.textTagText ~= nil then
63
- TextTag:flash(TextTag.MISS, self.parameters.textTagText, self.unit.x, self.unit.y)
64
- end
72
+ function StunImmunityUnitBehavior.prototype.onDamageReceived(self)
73
+ process(self)
74
+ Timer:run(process, self)
75
+ end
76
+ function StunImmunityUnitBehavior.prototype.onTargetingAbilityChannelingStart(self)
77
+ process(self)
78
+ end
79
+ function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
80
+ process(self)
65
81
  end
66
82
  StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
67
83
  return ____exports
@@ -9,13 +9,15 @@ import type { 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
+ import { Destructable } from "../../core/types/destructable";
13
+ import type { Buff } from "../buff";
12
14
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
13
15
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
14
16
  constructor(unit: Unit);
15
17
  protected onDestroy(): Destructor;
16
18
  readonly sourceAbilityBehavior?: AbilityBehavior;
17
19
  get unit(): Unit;
18
- registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, unit: Unit, ...args: Args) => unknown>, event: Event<[Unit, ...Args]>, range: number, listener: T): void;
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;
19
21
  onImmediateOrder(orderId: number): void;
20
22
  onTargetOrder(orderId: number, target: Widget): void;
21
23
  onPointOrder(orderId: number, x: number, y: number): void;
@@ -31,8 +33,17 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
31
33
  onAbilityLost(ability: Ability): void;
32
34
  onAbilityChannelingStart(ability: Ability): void;
33
35
  onAbilityImpact(ability: Ability): void;
36
+ onAbilityWidgetTargetImpact(ability: Ability, target: Widget): void;
37
+ onAbilityUnitTargetImpact(ability: Ability, target: Unit): void;
38
+ onAbilityItemTargetImpact(ability: Ability, target: Item): void;
39
+ onAbilityDestructibleTargetImpact(ability: Ability, target: Destructable): void;
40
+ onAbilityPointTargetImpact(ability: Ability, x: number, y: number): void;
41
+ onAbilityNoTargetImpact(ability: Ability): void;
34
42
  onAbilityChannelingFinish(ability: Ability): void;
35
43
  onAbilityStop(ability: Ability): void;
44
+ onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
45
+ onTargetingAbilityImpact(ability: Ability, source: Unit): void;
46
+ onBuffGained(buff: Buff): void;
36
47
  onItemDropped(item: Item): void;
37
48
  onItemPickedUp(item: Item): void;
38
49
  onItemUsed(item: Item): void;
@@ -49,7 +49,7 @@ function UnitBehavior.prototype.onDestroy(self)
49
49
  end
50
50
  return Behavior.prototype.onDestroy(self)
51
51
  end
52
- function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, range, listener)
52
+ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
53
53
  local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
54
54
  rangeByBehavior[self] = range
55
55
  local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
@@ -57,14 +57,17 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, range, lis
57
57
  getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
58
58
  local behaviors = behaviorsByEvent[event]
59
59
  if behaviors == nil then
60
- event:addListener(function(unit, ...)
60
+ event:addListener(function(...)
61
61
  local behaviors = behaviorsByEvent[event]
62
62
  if behaviors ~= nil then
63
- for behavior in pairs(behaviors) do
64
- local range = rangeByBehavior[behavior]
65
- if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
66
- local ____self_6 = behavior
67
- ____self_6[listenerByBehavior[behavior]](____self_6, unit, ...)
63
+ local unit = extractUnit(...)
64
+ if unit ~= nil then
65
+ for behavior in pairs(behaviors) do
66
+ local range = rangeByBehavior[behavior]
67
+ if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
68
+ local ____self_6 = behavior
69
+ ____self_6[listenerByBehavior[behavior]](____self_6, ...)
70
+ end
68
71
  end
69
72
  end
70
73
  end
@@ -104,10 +107,28 @@ function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
104
107
  end
105
108
  function UnitBehavior.prototype.onAbilityImpact(self, ability)
106
109
  end
110
+ function UnitBehavior.prototype.onAbilityWidgetTargetImpact(self, ability, target)
111
+ end
112
+ function UnitBehavior.prototype.onAbilityUnitTargetImpact(self, ability, target)
113
+ end
114
+ function UnitBehavior.prototype.onAbilityItemTargetImpact(self, ability, target)
115
+ end
116
+ function UnitBehavior.prototype.onAbilityDestructibleTargetImpact(self, ability, target)
117
+ end
118
+ function UnitBehavior.prototype.onAbilityPointTargetImpact(self, ability, x, y)
119
+ end
120
+ function UnitBehavior.prototype.onAbilityNoTargetImpact(self, ability)
121
+ end
107
122
  function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
108
123
  end
109
124
  function UnitBehavior.prototype.onAbilityStop(self, ability)
110
125
  end
126
+ function UnitBehavior.prototype.onTargetingAbilityChannelingStart(self, ability, source)
127
+ end
128
+ function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
129
+ end
130
+ function UnitBehavior.prototype.onBuffGained(self, buff)
131
+ end
111
132
  function UnitBehavior.prototype.onItemDropped(self, item)
112
133
  end
113
134
  function UnitBehavior.prototype.onItemPickedUp(self, item)
@@ -175,9 +196,37 @@ __TS__SetDescriptor(
175
196
  Unit.abilityChannelingStartEvent:addListener(function(source, ability)
176
197
  ____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
177
198
  end)
199
+ Unit.abilityUnitTargetChannelingStartEvent:addListener(function(source, ability, target)
200
+ ____exports.UnitBehavior:forAll(target, "onTargetingAbilityChannelingStart", ability, source)
201
+ end)
178
202
  Unit.abilityImpactEvent:addListener(function(source, ability)
179
203
  ____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
180
204
  end)
205
+ Unit.abilityWidgetTargetImpactEvent:addListener(function(source, ability, target)
206
+ ____exports.UnitBehavior:forAll(source, "onAbilityWidgetTargetImpact", ability, target)
207
+ end)
208
+ Unit.abilityUnitTargetImpactEvent:addListener(function(source, ability, target)
209
+ ____exports.UnitBehavior:forAll(source, "onAbilityUnitTargetImpact", ability, target)
210
+ ____exports.UnitBehavior:forAll(target, "onTargetingAbilityImpact", ability, source)
211
+ end)
212
+ Unit.abilityItemTargetImpactEvent:addListener(function(source, ability, target)
213
+ ____exports.UnitBehavior:forAll(source, "onAbilityItemTargetImpact", ability, target)
214
+ end)
215
+ Unit.abilityDestructibleTargetImpactEvent:addListener(function(source, ability, target)
216
+ ____exports.UnitBehavior:forAll(source, "onAbilityDestructibleTargetImpact", ability, target)
217
+ end)
218
+ Unit.abilityPointTargetImpactEvent:addListener(function(source, ability, x, y)
219
+ ____exports.UnitBehavior:forAll(
220
+ source,
221
+ "onAbilityPointTargetImpact",
222
+ ability,
223
+ x,
224
+ y
225
+ )
226
+ end)
227
+ Unit.abilityNoTargetImpactEvent:addListener(function(source, ability)
228
+ ____exports.UnitBehavior:forAll(source, "onAbilityNoTargetImpact", ability)
229
+ end)
181
230
  Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
182
231
  ____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
183
232
  end)
package/engine/buff.d.ts CHANGED
@@ -278,6 +278,7 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
278
278
  onDeath(source: Unit | undefined): void;
279
279
  onDamageDealt(target: Unit, event: DamageEvent): void;
280
280
  onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
281
- static readonly destroyEvent: Event<[Buff<object>]>;
281
+ static readonly createdEvent: Event<[Buff<object>]>;
282
+ static readonly beingDestroyedEvent: Event<[Buff<object>]>;
282
283
  }
283
284
  export {};
package/engine/buff.lua CHANGED
@@ -304,7 +304,8 @@ buffHealingIntervalTimerCallback = function(buff)
304
304
  source:healTarget(buff[101], healingPerInterval)
305
305
  end
306
306
  end
307
- local buffDestroyEvent = __TS__New(Event)
307
+ local buffCreatedEvent = __TS__New(Event)
308
+ local buffBeingDestroyedEvent = __TS__New(Event)
308
309
  ____exports.Buff = __TS__Class()
309
310
  local Buff = ____exports.Buff
310
311
  Buff.name = "Buff"
@@ -506,6 +507,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
506
507
  end
507
508
  self:onCreate()
508
509
  self[100] = 1
510
+ Event.invoke(buffCreatedEvent, self)
509
511
  end
510
512
  function Buff.prototype.getUnitBonus(self, bonusType)
511
513
  local ____opt_38 = self._bonusIdByBonusType
@@ -619,7 +621,7 @@ function Buff.prototype.onDestroy(self)
619
621
  removeUnitBonus(unit, bonusType, bonusId)
620
622
  end
621
623
  end
622
- Event.invoke(buffDestroyEvent, self)
624
+ Event.invoke(buffBeingDestroyedEvent, self)
623
625
  self[100] = 3
624
626
  return UnitBehavior.prototype.onDestroy(self)
625
627
  end
@@ -1288,7 +1290,8 @@ __TS__SetDescriptor(
1288
1290
  },
1289
1291
  true
1290
1292
  )
1291
- Buff.destroyEvent = buffDestroyEvent;
1293
+ Buff.createdEvent = buffCreatedEvent
1294
+ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1292
1295
  (function(self)
1293
1296
  local function destroyBuffIfNeeded(buff)
1294
1297
  if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
@@ -1342,5 +1345,8 @@ Buff.destroyEvent = buffDestroyEvent;
1342
1345
  ____exports.checkBuffs(target)
1343
1346
  end
1344
1347
  )
1348
+ buffCreatedEvent:addListener(function(buff)
1349
+ UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1350
+ end)
1345
1351
  end)(Buff)
1346
1352
  return ____exports
@@ -404,11 +404,17 @@ function UnitAbility.prototype.decrementHideCounter(self)
404
404
  unitHideAbility(self.u, self.typeId, false)
405
405
  end
406
406
  function UnitAbility.prototype.incrementDisableCounter(self)
407
- unitDisableAbility(self.u, self.typeId, true, false)
407
+ local unit = self.u
408
+ local typeId = self.typeId
409
+ unitHideAbility(unit, typeId, true)
410
+ unitDisableAbility(unit, typeId, true, false)
408
411
  self.d = (self.d or 0) + 1
409
412
  end
410
413
  function UnitAbility.prototype.decrementDisableCounter(self)
411
- unitDisableAbility(self.u, self.typeId, false, false)
414
+ local unit = self.u
415
+ local typeId = self.typeId
416
+ unitDisableAbility(unit, typeId, false, false)
417
+ unitHideAbility(unit, typeId, true)
412
418
  self.d = (self.d or 0) - 1
413
419
  end
414
420
  function UnitAbility.prototype.interruptCast(self)
@@ -20,6 +20,7 @@ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slo
20
20
  local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
21
21
  local isItemOwned = IsItemOwned
22
22
  local isItemPowerup = IsItemPowerup
23
+ local getItemAbility = BlzGetItemAbility
23
24
  local getItemX = GetItemX
24
25
  local getItemY = GetItemY
25
26
  local setAbilityRealLevelField = BlzSetAbilityRealLevelField
@@ -31,6 +32,8 @@ local unitAddItem = UnitAddItem
31
32
  local unitRemoveItem = UnitRemoveItem
32
33
  local unitUseItem = UnitUseItem
33
34
  local unitResetCooldown = UnitResetCooldown
35
+ local unitInventorySize = UnitInventorySize
36
+ local unitItemInSlot = UnitItemInSlot
34
37
  local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
35
38
  if not currentMap then
36
39
  return 0
@@ -65,7 +68,7 @@ ____exports.itemAbilityDummy = assert(CreateUnit(
65
68
  270
66
69
  ))
67
70
  local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
68
- local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
71
+ local cooldownStarterAbility = getItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
69
72
  ShowUnit(____exports.itemAbilityDummy, false)
70
73
  local function startItemCooldownInternal(handle, cooldown)
71
74
  local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
@@ -153,4 +156,51 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
153
156
  end
154
157
  return result
155
158
  end
159
+ local depth = 0
160
+ local itemBySlot = {}
161
+ ---
162
+ -- @internal For use by internal systems only.
163
+ ____exports.doUnitAbilityAction = function(unit, abilityTypeId, action, ...)
164
+ local ____depth_0 = depth
165
+ depth = ____depth_0 + 1
166
+ local offset = 6 * ____depth_0
167
+ for slot = 0, unitInventorySize(unit) - 1 do
168
+ local item = unitItemInSlot(unit, slot)
169
+ if getItemAbility(item, abilityTypeId) ~= nil then
170
+ local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
171
+ if not isAlreadyIgnoredInEvents then
172
+ ignoreEventsItems[item] = true
173
+ end
174
+ unitRemoveItem(unit, item)
175
+ if not isAlreadyIgnoredInEvents then
176
+ ignoreEventsItems[item] = nil
177
+ end
178
+ itemBySlot[offset + slot] = item
179
+ end
180
+ end
181
+ local result = action(unit, ...)
182
+ for slot = 0, unitInventorySize(unit) - 1 do
183
+ local item = itemBySlot[offset + slot]
184
+ if item ~= nil then
185
+ local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
186
+ if not isAlreadyIgnoredInEvents then
187
+ ignoreEventsItems[item] = true
188
+ end
189
+ local isPowerup = isItemPowerup(item)
190
+ if isPowerup then
191
+ setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
192
+ end
193
+ unitAddItemToSlot(unit, item, slot)
194
+ if isPowerup then
195
+ setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
196
+ end
197
+ if not isAlreadyIgnoredInEvents then
198
+ ignoreEventsItems[item] = nil
199
+ end
200
+ itemBySlot[offset + slot] = nil
201
+ end
202
+ end
203
+ depth = depth - 1
204
+ return result
205
+ end
156
206
  return ____exports
@@ -136,6 +136,36 @@ declare module "../unit" {
136
136
  const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
137
137
  }
138
138
  }
139
+ declare module "../unit" {
140
+ namespace Unit {
141
+ const abilityWidgetTargetImpactEvent: DispatchingEvent<[Unit, Ability, Widget]>;
142
+ }
143
+ }
144
+ declare module "../unit" {
145
+ namespace Unit {
146
+ const abilityUnitTargetImpactEvent: DispatchingEvent<[Unit, Ability, Unit]>;
147
+ }
148
+ }
149
+ declare module "../unit" {
150
+ namespace Unit {
151
+ const abilityItemTargetImpactEvent: DispatchingEvent<[Unit, Ability, Item]>;
152
+ }
153
+ }
154
+ declare module "../unit" {
155
+ namespace Unit {
156
+ const abilityDestructibleTargetImpactEvent: DispatchingEvent<[Unit, Ability, Destructable]>;
157
+ }
158
+ }
159
+ declare module "../unit" {
160
+ namespace Unit {
161
+ const abilityPointTargetImpactEvent: DispatchingEvent<[Unit, Ability, number, number]>;
162
+ }
163
+ }
164
+ declare module "../unit" {
165
+ namespace Unit {
166
+ const abilityNoTargetImpactEvent: DispatchingEvent<[Unit, Ability]>;
167
+ }
168
+ }
139
169
  declare module "../unit" {
140
170
  namespace Unit {
141
171
  const abilityChannelingFinishEvent: DispatchingEvent<[Unit, Ability]>;
@@ -359,6 +359,54 @@ rawset(
359
359
  extractAbilityTypeId
360
360
  )
361
361
  )
362
+ rawset(
363
+ Unit,
364
+ "abilityWidgetTargetImpactEvent",
365
+ createDispatchingEvent(
366
+ createWidgetTargetEvent(internalAbilityImpactEvent),
367
+ extractAbilityTypeId
368
+ )
369
+ )
370
+ rawset(
371
+ Unit,
372
+ "abilityUnitTargetImpactEvent",
373
+ createDispatchingEvent(
374
+ createUnitTargetEvent(internalAbilityImpactEvent),
375
+ extractAbilityTypeId
376
+ )
377
+ )
378
+ rawset(
379
+ Unit,
380
+ "abilityItemTargetImpactEvent",
381
+ createDispatchingEvent(
382
+ createItemTargetEvent(internalAbilityImpactEvent),
383
+ extractAbilityTypeId
384
+ )
385
+ )
386
+ rawset(
387
+ Unit,
388
+ "abilityDestructibleTargetImpactEvent",
389
+ createDispatchingEvent(
390
+ createDestructibleTargetEvent(internalAbilityImpactEvent),
391
+ extractAbilityTypeId
392
+ )
393
+ )
394
+ rawset(
395
+ Unit,
396
+ "abilityPointTargetImpactEvent",
397
+ createDispatchingEvent(
398
+ createPointTargetEvent(internalAbilityImpactEvent),
399
+ extractAbilityTypeId
400
+ )
401
+ )
402
+ rawset(
403
+ Unit,
404
+ "abilityNoTargetImpactEvent",
405
+ createDispatchingEvent(
406
+ createNoTargetEvent(internalAbilityImpactEvent),
407
+ extractAbilityTypeId
408
+ )
409
+ )
362
410
  rawset(
363
411
  Unit,
364
412
  "abilityChannelingFinishEvent",
@@ -0,0 +1,20 @@
1
+ /** @noSelfInFile */
2
+ import { Widget } from "../../../core/types/widget";
3
+ export declare const enum OrderType {
4
+ IMMEDIATE = 0,
5
+ POINT = 1,
6
+ TARGET = 2
7
+ }
8
+ declare module "../unit" {
9
+ interface Unit {
10
+ readonly currentOrderType: OrderType;
11
+ readonly currentOrderId: number;
12
+ readonly currentOrderStartTime: number;
13
+ readonly currentOrderStartX: number;
14
+ readonly currentOrderStartY: number;
15
+ readonly currentOrderTargetX: number;
16
+ readonly currentOrderTargetY: number;
17
+ readonly currentOrderTarget?: Widget;
18
+ issueOrder(...order: [orderType: OrderType.IMMEDIATE, orderId: number] | [orderType: OrderType.POINT, orderId: number, x: number, y: number] | [orderType: OrderType.TARGET, orderId: number, target: Widget]): boolean;
19
+ }
20
+ }