warscript 0.0.1-dev.eb24bc1 → 0.0.1-dev.eb6b18a

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 (37) hide show
  1. package/engine/behaviour/ability/emulate-impact.lua +9 -2
  2. package/engine/behaviour/ability.lua +8 -17
  3. package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
  4. package/engine/behaviour/unit/stun-immunity.lua +43 -27
  5. package/engine/behaviour/unit.d.ts +24 -0
  6. package/engine/behaviour/unit.lua +158 -4
  7. package/engine/internal/ability.d.ts +4 -0
  8. package/engine/internal/ability.lua +17 -0
  9. package/engine/internal/item/ability.lua +12 -10
  10. package/engine/internal/item.d.ts +3 -1
  11. package/engine/internal/item.lua +75 -3
  12. package/engine/internal/unit/ability.d.ts +35 -0
  13. package/engine/internal/unit/ability.lua +62 -0
  14. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  15. package/engine/internal/unit/allowed-targets.lua +9 -1
  16. package/engine/internal/unit/order.d.ts +20 -0
  17. package/engine/internal/unit/order.lua +136 -0
  18. package/engine/internal/unit-missile-launch.lua +1 -1
  19. package/engine/internal/unit.d.ts +9 -1
  20. package/engine/internal/unit.lua +90 -1
  21. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  22. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  23. package/engine/object-field/unit.d.ts +4 -0
  24. package/engine/object-field/unit.lua +13 -0
  25. package/engine/object-field.d.ts +6 -3
  26. package/engine/object-field.lua +85 -73
  27. package/engine/standard/fields/unit.d.ts +3 -0
  28. package/engine/standard/fields/unit.lua +5 -0
  29. package/engine/text-tag.d.ts +36 -2
  30. package/engine/text-tag.lua +175 -10
  31. package/engine/unit.d.ts +1 -0
  32. package/engine/unit.lua +1 -0
  33. package/package.json +1 -1
  34. package/utility/lua-maps.d.ts +1 -0
  35. package/utility/lua-maps.lua +4 -0
  36. package/core/types/order.d.ts +0 -25
  37. package/core/types/order.lua +0 -55
@@ -1,9 +1,12 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
4
5
  local ____exports = {}
5
6
  local ____ability = require("engine.behaviour.ability")
6
7
  local AbilityBehavior = ____ability.AbilityBehavior
8
+ local ____unit = require("engine.internal.unit")
9
+ local Unit = ____unit.Unit
7
10
  local ____ability = require("engine.standard.fields.ability")
8
11
  local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
9
12
  local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTEGER_LEVEL_FIELD
@@ -13,6 +16,10 @@ local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_F
13
16
  local ____sound = require("core.types.sound")
14
17
  local Sound3D = ____sound.Sound3D
15
18
  local SoundSettings = ____sound.SoundSettings
19
+ local ____ability = require("engine.internal.ability")
20
+ local UnitAbility = ____ability.UnitAbility
21
+ local ____event = require("event")
22
+ local Event = ____event.Event
16
23
  ____exports.EmulateImpactAbilityBehavior = __TS__Class()
17
24
  local EmulateImpactAbilityBehavior = ____exports.EmulateImpactAbilityBehavior
18
25
  EmulateImpactAbilityBehavior.name = "EmulateImpactAbilityBehavior"
@@ -20,7 +27,7 @@ __TS__ClassExtends(EmulateImpactAbilityBehavior, AbilityBehavior)
20
27
  function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
21
28
  local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
22
29
  local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
23
- if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost then
30
+ if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost or __TS__InstanceOf(self.ability, UnitAbility) and self.ability.isDisabled then
24
31
  return
25
32
  end
26
33
  caster.mana = caster.mana - manaCost
@@ -30,6 +37,6 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
30
37
  if soundPresetId ~= "" then
31
38
  Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
32
39
  end
33
- AbilityBehavior:forAll(self.ability, "onImpact", caster)
40
+ Event.invoke(Unit.abilityImpactEvent, caster, self.ability)
34
41
  end
35
42
  return ____exports
@@ -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
@@ -274,13 +265,13 @@ __TS__SetDescriptor(
274
265
  Unit.abilityDestructibleTargetChannelingStartEvent:addListener(createUnitEventListener("onDestructibleTargetChannelingStart"))
275
266
  Unit.abilityPointTargetChannelingStartEvent:addListener(createUnitEventListener("onPointTargetChannelingStart"))
276
267
  Unit.abilityNoTargetChannelingStartEvent:addListener(createUnitEventListener("onNoTargetChannelingStart"))
277
- Unit.abilityChannelingStartEvent:addListener(createZeroTimerUnitEventListener("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"))
268
+ Unit.abilityImpactEvent:addListener(createUnitEventListener("onImpact"))
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
@@ -6,23 +6,47 @@ import "../internal/unit+ability";
6
6
  import "../internal/unit-missile-launch";
7
7
  import { Item } from "../internal/item";
8
8
  import type { AbilityBehavior } from "./ability";
9
+ import { Event } from "../../event";
10
+ import { Destructor } from "../../destroyable";
11
+ import type { Widget } from "../../core/types/widget";
12
+ import { Destructable } from "../../core/types/destructable";
9
13
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
10
14
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
11
15
  constructor(unit: Unit);
16
+ protected onDestroy(): Destructor;
12
17
  readonly sourceAbilityBehavior?: AbilityBehavior;
13
18
  get unit(): Unit;
19
+ 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
+ onImmediateOrder(orderId: number): void;
21
+ onTargetOrder(orderId: number, target: Widget): void;
22
+ onPointOrder(orderId: number, x: number, y: number): void;
14
23
  onAutoAttackStart(target: Unit): void;
15
24
  onAutoAttackFinish(target: Unit): void;
25
+ onTargetingAutoAttackStart(source: Unit): void;
26
+ onTargetingAutoAttackFinish(source: Unit): void;
16
27
  onDamageDealing(target: Unit, event: DamagingEvent): void;
17
28
  onDamageDealt(target: Unit, event: DamageEvent): void;
18
29
  onDamageReceiving(source: Unit | undefined, event: DamagingEvent): void;
19
30
  onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
20
31
  onAbilityGained(ability: Ability): void;
21
32
  onAbilityLost(ability: Ability): void;
33
+ onAbilityChannelingStart(ability: Ability): void;
34
+ onAbilityImpact(ability: Ability): void;
35
+ onAbilityWidgetTargetImpact(ability: Ability, target: Widget): void;
36
+ onAbilityUnitTargetImpact(ability: Ability, target: Unit): void;
37
+ onAbilityItemTargetImpact(ability: Ability, target: Item): void;
38
+ onAbilityDestructibleTargetImpact(ability: Ability, target: Destructable): void;
39
+ onAbilityPointTargetImpact(ability: Ability, x: number, y: number): void;
40
+ onAbilityNoTargetImpact(ability: Ability): void;
41
+ onAbilityChannelingFinish(ability: Ability): void;
42
+ onAbilityStop(ability: Ability): void;
43
+ onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
44
+ onTargetingAbilityImpact(ability: Ability, source: Unit): void;
22
45
  onItemDropped(item: Item): void;
23
46
  onItemPickedUp(item: Item): void;
24
47
  onItemUsed(item: Item): void;
25
48
  onItemStacked(item: Item): void;
49
+ onItemChargesChanged(item: Item): void;
26
50
  onKill(target: Unit): void;
27
51
  onDeath(source: Unit | undefined): void;
28
52
  }
@@ -1,6 +1,7 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__New = ____lualib.__TS__New
4
5
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
6
  local ____exports = {}
6
7
  local ____behavior = require("engine.behavior")
@@ -9,6 +10,17 @@ local ____unit = require("engine.internal.unit")
9
10
  local Unit = ____unit.Unit
10
11
  require("engine.internal.unit+ability")
11
12
  require("engine.internal.unit-missile-launch")
13
+ local ____linked_2Dset = require("utility.linked-set")
14
+ local LinkedSet = ____linked_2Dset.LinkedSet
15
+ local ____lua_2Dmaps = require("utility.lua-maps")
16
+ local getOrPut = ____lua_2Dmaps.getOrPut
17
+ local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
18
+ local ____lua_2Dsets = require("utility.lua-sets")
19
+ local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
20
+ local behaviorsByEvent = {}
21
+ local rangeByBehaviorByEvent = {}
22
+ local listenerByBehaviorByEvent = {}
23
+ local eventsByBehavior = {}
12
24
  ____exports.UnitBehavior = __TS__Class()
13
25
  local UnitBehavior = ____exports.UnitBehavior
14
26
  UnitBehavior.name = "UnitBehavior"
@@ -16,10 +28,66 @@ __TS__ClassExtends(UnitBehavior, Behavior)
16
28
  function UnitBehavior.prototype.____constructor(self, unit)
17
29
  Behavior.prototype.____constructor(self, unit)
18
30
  end
31
+ 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]
36
+ if ____opt_0 ~= nil then
37
+ ____opt_0:remove(self)
38
+ end
39
+ local ____opt_2 = rangeByBehaviorByEvent[event]
40
+ if ____opt_2 ~= nil then
41
+ ____opt_2[self] = nil
42
+ end
43
+ local ____opt_4 = listenerByBehaviorByEvent[event]
44
+ if ____opt_4 ~= nil then
45
+ ____opt_4[self] = nil
46
+ end
47
+ end
48
+ eventsByBehavior[self] = nil
49
+ end
50
+ return Behavior.prototype.onDestroy(self)
51
+ end
52
+ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, range, listener)
53
+ local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
54
+ rangeByBehavior[self] = range
55
+ local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
56
+ listenerByBehavior[self] = listener
57
+ getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
58
+ local behaviors = behaviorsByEvent[event]
59
+ if behaviors == nil then
60
+ event:addListener(function(unit, ...)
61
+ local behaviors = behaviorsByEvent[event]
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, ...)
68
+ end
69
+ end
70
+ end
71
+ end)
72
+ behaviors = __TS__New(LinkedSet)
73
+ behaviorsByEvent[event] = behaviors
74
+ end
75
+ behaviors:add(self)
76
+ end
77
+ function UnitBehavior.prototype.onImmediateOrder(self, orderId)
78
+ end
79
+ function UnitBehavior.prototype.onTargetOrder(self, orderId, target)
80
+ end
81
+ function UnitBehavior.prototype.onPointOrder(self, orderId, x, y)
82
+ end
19
83
  function UnitBehavior.prototype.onAutoAttackStart(self, target)
20
84
  end
21
85
  function UnitBehavior.prototype.onAutoAttackFinish(self, target)
22
86
  end
87
+ function UnitBehavior.prototype.onTargetingAutoAttackStart(self, source)
88
+ end
89
+ function UnitBehavior.prototype.onTargetingAutoAttackFinish(self, source)
90
+ end
23
91
  function UnitBehavior.prototype.onDamageDealing(self, target, event)
24
92
  end
25
93
  function UnitBehavior.prototype.onDamageDealt(self, target, event)
@@ -32,6 +100,30 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
32
100
  end
33
101
  function UnitBehavior.prototype.onAbilityLost(self, ability)
34
102
  end
103
+ function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
104
+ end
105
+ function UnitBehavior.prototype.onAbilityImpact(self, ability)
106
+ end
107
+ function UnitBehavior.prototype.onAbilityWidgetTargetImpact(self, ability, target)
108
+ end
109
+ function UnitBehavior.prototype.onAbilityUnitTargetImpact(self, ability, target)
110
+ end
111
+ function UnitBehavior.prototype.onAbilityItemTargetImpact(self, ability, target)
112
+ end
113
+ function UnitBehavior.prototype.onAbilityDestructibleTargetImpact(self, ability, target)
114
+ end
115
+ function UnitBehavior.prototype.onAbilityPointTargetImpact(self, ability, x, y)
116
+ end
117
+ function UnitBehavior.prototype.onAbilityNoTargetImpact(self, ability)
118
+ end
119
+ function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
120
+ end
121
+ function UnitBehavior.prototype.onAbilityStop(self, ability)
122
+ end
123
+ function UnitBehavior.prototype.onTargetingAbilityChannelingStart(self, ability, source)
124
+ end
125
+ function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
126
+ end
35
127
  function UnitBehavior.prototype.onItemDropped(self, item)
36
128
  end
37
129
  function UnitBehavior.prototype.onItemPickedUp(self, item)
@@ -40,6 +132,8 @@ function UnitBehavior.prototype.onItemUsed(self, item)
40
132
  end
41
133
  function UnitBehavior.prototype.onItemStacked(self, item)
42
134
  end
135
+ function UnitBehavior.prototype.onItemChargesChanged(self, item)
136
+ end
43
137
  function UnitBehavior.prototype.onKill(self, target)
44
138
  end
45
139
  function UnitBehavior.prototype.onDeath(self, source)
@@ -53,11 +147,28 @@ __TS__SetDescriptor(
53
147
  true
54
148
  );
55
149
  (function(self)
150
+ Unit.onImmediateOrder:addListener(function(source, orderId)
151
+ ____exports.UnitBehavior:forAll(source, "onImmediateOrder", orderId)
152
+ end)
153
+ Unit.onTargetOrder:addListener(function(source, orderId, target)
154
+ ____exports.UnitBehavior:forAll(source, "onTargetOrder", orderId, target)
155
+ end)
156
+ Unit.onPointOrder:addListener(function(source, orderId, x, y)
157
+ ____exports.UnitBehavior:forAll(
158
+ source,
159
+ "onPointOrder",
160
+ orderId,
161
+ x,
162
+ y
163
+ )
164
+ end)
56
165
  Unit.autoAttackStartEvent:addListener(function(source, target)
57
166
  ____exports.UnitBehavior:forAll(source, "onAutoAttackStart", target)
167
+ ____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackStart", source)
58
168
  end)
59
169
  Unit.autoAttackFinishEvent:addListener(function(source, target)
60
170
  ____exports.UnitBehavior:forAll(source, "onAutoAttackFinish", target)
171
+ ____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackFinish", source)
61
172
  end)
62
173
  Unit.onDamaging:addListener(function(source, target, event)
63
174
  if source ~= nil then
@@ -71,11 +182,51 @@ __TS__SetDescriptor(
71
182
  end
72
183
  ____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
73
184
  end)
74
- Unit.abilityGainedEvent:addListener(function(source, target)
75
- ____exports.UnitBehavior:forAll(source, "onAbilityGained", target)
185
+ Unit.abilityGainedEvent:addListener(function(source, ability)
186
+ ____exports.UnitBehavior:forAll(source, "onAbilityGained", ability)
187
+ end)
188
+ Unit.abilityLostEvent:addListener(function(source, ability)
189
+ ____exports.UnitBehavior:forAll(source, "onAbilityLost", ability)
190
+ end)
191
+ Unit.abilityChannelingStartEvent:addListener(function(source, ability)
192
+ ____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
193
+ end)
194
+ Unit.abilityUnitTargetChannelingStartEvent:addListener(function(source, ability, target)
195
+ ____exports.UnitBehavior:forAll(target, "onTargetingAbilityChannelingStart", ability, source)
76
196
  end)
77
- Unit.abilityLostEvent:addListener(function(source, target)
78
- ____exports.UnitBehavior:forAll(source, "onAbilityLost", target)
197
+ Unit.abilityImpactEvent:addListener(function(source, ability)
198
+ ____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
199
+ end)
200
+ Unit.abilityWidgetTargetImpactEvent:addListener(function(source, ability, target)
201
+ ____exports.UnitBehavior:forAll(source, "onAbilityWidgetTargetImpact", ability, target)
202
+ end)
203
+ Unit.abilityUnitTargetImpactEvent:addListener(function(source, ability, target)
204
+ ____exports.UnitBehavior:forAll(source, "onAbilityUnitTargetImpact", ability, target)
205
+ ____exports.UnitBehavior:forAll(target, "onTargetingAbilityImpact", ability, source)
206
+ end)
207
+ Unit.abilityItemTargetImpactEvent:addListener(function(source, ability, target)
208
+ ____exports.UnitBehavior:forAll(source, "onAbilityItemTargetImpact", ability, target)
209
+ end)
210
+ Unit.abilityDestructibleTargetImpactEvent:addListener(function(source, ability, target)
211
+ ____exports.UnitBehavior:forAll(source, "onAbilityDestructibleTargetImpact", ability, target)
212
+ end)
213
+ Unit.abilityPointTargetImpactEvent:addListener(function(source, ability, x, y)
214
+ ____exports.UnitBehavior:forAll(
215
+ source,
216
+ "onAbilityPointTargetImpact",
217
+ ability,
218
+ x,
219
+ y
220
+ )
221
+ end)
222
+ Unit.abilityNoTargetImpactEvent:addListener(function(source, ability)
223
+ ____exports.UnitBehavior:forAll(source, "onAbilityNoTargetImpact", ability)
224
+ end)
225
+ Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
226
+ ____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
227
+ end)
228
+ Unit.abilityStopEvent:addListener(function(source, ability)
229
+ ____exports.UnitBehavior:forAll(source, "onAbilityStop", ability)
79
230
  end)
80
231
  Unit.deathEvent:addListener(function(target, source)
81
232
  if source ~= nil then
@@ -95,6 +246,9 @@ __TS__SetDescriptor(
95
246
  Unit.itemStackedEvent:addListener(function(unit, item)
96
247
  ____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
97
248
  end)
249
+ Unit.itemChargesChangedEvent:addListener(function(unit, item)
250
+ ____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
251
+ end)
98
252
  end)(UnitBehavior)
99
253
  Unit.destroyEvent:addListener(function(unit)
100
254
  ____exports.UnitBehavior:forAll(unit, "destroy")
@@ -55,9 +55,13 @@ export declare class UnrecognizedAbility extends Ability {
55
55
  export declare class UnitAbility extends Ability {
56
56
  readonly owner: Unit;
57
57
  private readonly u;
58
+ private d?;
58
59
  constructor(handle: jability, typeId: number, owner: Unit);
59
60
  incrementHideCounter(): void;
60
61
  decrementHideCounter(): void;
62
+ incrementDisableCounter(): void;
63
+ decrementDisableCounter(): void;
64
+ get isDisabled(): boolean;
61
65
  get level(): number;
62
66
  set level(v: number);
63
67
  get cooldownRemaining(): number;
@@ -38,6 +38,7 @@ local getHandleId = GetHandleId
38
38
  local getItemBooleanField = BlzGetItemBooleanField
39
39
  local setItemBooleanField = BlzSetItemBooleanField
40
40
  local unitHideAbility = BlzUnitHideAbility
41
+ local unitDisableAbility = BlzUnitDisableAbility
41
42
  local match = string.match
42
43
  local ____type = _G.type
43
44
  local ____tostring = _G.tostring
@@ -402,9 +403,25 @@ end
402
403
  function UnitAbility.prototype.decrementHideCounter(self)
403
404
  unitHideAbility(self.u, self.typeId, false)
404
405
  end
406
+ function UnitAbility.prototype.incrementDisableCounter(self)
407
+ unitDisableAbility(self.u, self.typeId, true, false)
408
+ self.d = (self.d or 0) + 1
409
+ end
410
+ function UnitAbility.prototype.decrementDisableCounter(self)
411
+ unitDisableAbility(self.u, self.typeId, false, false)
412
+ self.d = (self.d or 0) - 1
413
+ end
405
414
  function UnitAbility.prototype.interruptCast(self)
406
415
  self.owner:interruptCast(self.typeId)
407
416
  end
417
+ __TS__SetDescriptor(
418
+ UnitAbility.prototype,
419
+ "isDisabled",
420
+ {get = function(self)
421
+ return self.d ~= nil and self.d > 0
422
+ end},
423
+ true
424
+ )
408
425
  __TS__SetDescriptor(
409
426
  UnitAbility.prototype,
410
427
  "level",
@@ -55,22 +55,24 @@ local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
55
55
  itemType.activelyUsed = true
56
56
  return itemType.id
57
57
  end)
58
- local dummy = assert(CreateUnit(
58
+ ---
59
+ -- @internal For use by internal systems only.
60
+ ____exports.itemAbilityDummy = assert(CreateUnit(
59
61
  Player.neutralVictim.handle,
60
62
  dummyUnitId,
61
63
  0,
62
64
  0,
63
65
  270
64
66
  ))
65
- local cooldownStarterItem = UnitAddItemById(dummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
67
+ local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
66
68
  local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
67
- ShowUnit(dummy, false)
69
+ ShowUnit(____exports.itemAbilityDummy, false)
68
70
  local function startItemCooldownInternal(handle, cooldown)
69
71
  local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
70
72
  setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
71
73
  setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
72
- unitResetCooldown(dummy)
73
- unitUseItem(dummy, cooldownStarterItem)
74
+ unitResetCooldown(____exports.itemAbilityDummy)
75
+ unitUseItem(____exports.itemAbilityDummy, cooldownStarterItem)
74
76
  Timer:run(restoreCooldownGroup, handle, cooldownGroup)
75
77
  end
76
78
  restoreCooldownGroup = function(handle, cooldownGroup)
@@ -85,7 +87,7 @@ ____exports.startItemCooldown = function(handle, owner, cooldown)
85
87
  end
86
88
  ---
87
89
  -- @internal For use by internal systems only.
88
- ____exports.abilityActionDummy = dummy
90
+ ____exports.abilityActionDummy = ____exports.itemAbilityDummy
89
91
  ---
90
92
  -- @internal For use by internal systems only.
91
93
  ____exports.doAbilityAction = function(handle, action, ...)
@@ -104,11 +106,11 @@ ____exports.doAbilityAction = function(handle, action, ...)
104
106
  end
105
107
  x = getItemX(handle)
106
108
  y = getItemY(handle)
107
- unitAddItem(dummy, handle)
109
+ unitAddItem(____exports.itemAbilityDummy, handle)
108
110
  end
109
111
  local result = action(handle, ...)
110
112
  if not isOwned then
111
- unitRemoveItem(dummy, handle)
113
+ unitRemoveItem(____exports.itemAbilityDummy, handle)
112
114
  setItemPosition(handle, x, y)
113
115
  if isPowerup then
114
116
  setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
@@ -139,9 +141,9 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
139
141
  isPowerup = true
140
142
  end
141
143
  unitRemoveItem(owner, handle)
142
- unitAddItem(dummy, handle)
144
+ unitAddItem(____exports.itemAbilityDummy, handle)
143
145
  local result = action(handle, ...)
144
- unitRemoveItem(dummy, handle)
146
+ unitRemoveItem(____exports.itemAbilityDummy, handle)
145
147
  unitAddItemToSlot(owner, handle, slot)
146
148
  if isPowerup then
147
149
  setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
@@ -7,7 +7,6 @@ import { ItemAbility } from "./ability";
7
7
  import { AbilityTypeId } from "../object-data/entry/ability-type";
8
8
  import type { ItemTypeId } from "../object-data/entry/item-type";
9
9
  type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
10
- export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
11
10
  declare const enum ItemPropertyKey {
12
11
  ABILITIES = 100,
13
12
  LUA_INDEX_BY_ABILITY_TYPE_ID = 101
@@ -74,6 +73,8 @@ export declare class Item extends Handle<jitem> {
74
73
  set position(v: Vec2);
75
74
  set charges(v: number);
76
75
  get charges(): number;
76
+ consumeCharge(): boolean;
77
+ consumeCharges(count: number): boolean;
77
78
  addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
78
79
  removeAbility(abilityTypeId: AbilityTypeId): boolean;
79
80
  hasAbility(abilityTypeId: AbilityTypeId): boolean;
@@ -83,5 +84,6 @@ export declare class Item extends Handle<jitem> {
83
84
  static getInRect(rect: ReadonlyRect): Item[];
84
85
  static get onCreate(): Event<[Item]>;
85
86
  static get destroyEvent(): Event<[Item]>;
87
+ static readonly chargesChangedEvent: Event<[Item]>;
86
88
  }
87
89
  export {};