warscript 0.0.1-dev.9ee7706 → 0.0.1-dev.9f30788

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 (117) hide show
  1. package/attributes.d.ts +5 -0
  2. package/attributes.lua +8 -1
  3. package/core/types/effect.d.ts +1 -3
  4. package/core/types/effect.lua +26 -29
  5. package/core/types/frame.lua +24 -21
  6. package/core/types/player.lua +3 -1
  7. package/core/types/playerCamera.d.ts +2 -0
  8. package/core/types/playerCamera.lua +123 -5
  9. package/core/types/sound.lua +5 -0
  10. package/core/types/tileCell.d.ts +9 -0
  11. package/core/types/tileCell.lua +92 -0
  12. package/core/types/timer.d.ts +9 -8
  13. package/core/types/timer.lua +45 -23
  14. package/decl/native.d.ts +846 -790
  15. package/engine/behavior.d.ts +5 -0
  16. package/engine/behavior.lua +106 -27
  17. package/engine/behaviour/ability/apply-buff.lua +1 -1
  18. package/engine/behaviour/ability/damage.d.ts +6 -3
  19. package/engine/behaviour/ability/damage.lua +24 -36
  20. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  21. package/engine/behaviour/ability/emulate-impact.lua +18 -3
  22. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  23. package/engine/behaviour/ability/restore-mana.lua +6 -6
  24. package/engine/behaviour/ability.d.ts +4 -1
  25. package/engine/behaviour/ability.lua +14 -21
  26. package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
  27. package/engine/behaviour/unit/stun-immunity.lua +52 -27
  28. package/engine/behaviour/unit.d.ts +33 -1
  29. package/engine/behaviour/unit.lua +190 -4
  30. package/engine/buff.d.ts +2 -4
  31. package/engine/buff.lua +68 -83
  32. package/engine/internal/ability.d.ts +7 -1
  33. package/engine/internal/ability.lua +49 -9
  34. package/engine/internal/item/ability.lua +63 -11
  35. package/engine/internal/item+owner.lua +12 -6
  36. package/engine/internal/item.d.ts +18 -17
  37. package/engine/internal/item.lua +135 -49
  38. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  39. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  40. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  41. package/engine/internal/misc/frame-coordinates.lua +21 -0
  42. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  43. package/engine/internal/misc/get-terrain-z.lua +11 -0
  44. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  45. package/engine/internal/misc/player-local-handle.lua +5 -0
  46. package/engine/internal/unit/ability.d.ts +35 -0
  47. package/engine/internal/unit/ability.lua +98 -9
  48. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  49. package/engine/internal/unit/allowed-targets.lua +9 -1
  50. package/engine/internal/unit/order.d.ts +20 -0
  51. package/engine/internal/unit/order.lua +136 -0
  52. package/engine/internal/unit+ability.lua +10 -1
  53. package/engine/internal/unit+damage.d.ts +2 -11
  54. package/engine/internal/unit+damage.lua +10 -14
  55. package/engine/internal/unit+spellSteal.lua +1 -2
  56. package/engine/internal/unit-missile-launch.lua +45 -8
  57. package/engine/internal/unit.d.ts +26 -9
  58. package/engine/internal/unit.lua +251 -110
  59. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  60. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  61. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  62. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  63. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  64. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  65. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  66. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  67. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  68. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  69. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  70. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  71. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  72. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  73. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  74. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  75. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  76. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  77. package/engine/object-data/entry/ability-type.d.ts +11 -11
  78. package/engine/object-data/entry/ability-type.lua +31 -9
  79. package/engine/object-data/entry/buff-type/applicable.lua +5 -0
  80. package/engine/object-data/entry/buff-type.d.ts +5 -11
  81. package/engine/object-data/entry/buff-type.lua +11 -27
  82. package/engine/object-data/entry/unit-type.d.ts +13 -4
  83. package/engine/object-data/entry/unit-type.lua +153 -85
  84. package/engine/object-field/ability.d.ts +4 -4
  85. package/engine/object-field/ability.lua +7 -6
  86. package/engine/object-field/unit.d.ts +57 -3
  87. package/engine/object-field/unit.lua +207 -7
  88. package/engine/object-field.d.ts +17 -6
  89. package/engine/object-field.lua +188 -92
  90. package/engine/random.d.ts +9 -0
  91. package/engine/random.lua +13 -0
  92. package/engine/standard/entries/buff-type.d.ts +3 -0
  93. package/engine/standard/entries/buff-type.lua +3 -0
  94. package/engine/standard/fields/unit.d.ts +4 -0
  95. package/engine/standard/fields/unit.lua +7 -0
  96. package/engine/text-tag.d.ts +36 -2
  97. package/engine/text-tag.lua +249 -10
  98. package/engine/unit.d.ts +1 -0
  99. package/engine/unit.lua +1 -0
  100. package/objutil/buff.lua +2 -3
  101. package/package.json +2 -2
  102. package/patch-lualib.lua +1 -1
  103. package/utility/arrays.d.ts +2 -0
  104. package/utility/arrays.lua +11 -0
  105. package/utility/callback-array.d.ts +17 -0
  106. package/utility/callback-array.lua +61 -0
  107. package/utility/functions.d.ts +8 -0
  108. package/utility/functions.lua +13 -0
  109. package/utility/linked-set.d.ts +1 -0
  110. package/utility/linked-set.lua +3 -0
  111. package/utility/lua-maps.d.ts +15 -2
  112. package/utility/lua-maps.lua +53 -2
  113. package/utility/lua-sets.d.ts +2 -0
  114. package/utility/lua-sets.lua +7 -0
  115. package/utility/types.d.ts +3 -0
  116. package/core/types/order.d.ts +0 -25
  117. package/core/types/order.lua +0 -55
@@ -6,23 +6,55 @@ 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";
13
+ import type { Buff } from "../buff";
14
+ import { UnitBonusType } from "../internal/unit/bonus";
15
+ import { Player } from "../../core/types/player";
9
16
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
10
17
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
11
- constructor(unit: Unit);
12
18
  readonly sourceAbilityBehavior?: AbilityBehavior;
19
+ private _bonusIdByBonusType?;
20
+ constructor(unit: Unit);
21
+ protected onDestroy(): Destructor;
13
22
  get unit(): Unit;
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;
26
+ onImmediateOrder(orderId: number): void;
27
+ onTargetOrder(orderId: number, target: Widget): void;
28
+ onPointOrder(orderId: number, x: number, y: number): void;
14
29
  onAutoAttackStart(target: Unit): void;
15
30
  onAutoAttackFinish(target: Unit): void;
31
+ onTargetingAutoAttackStart(source: Unit): void;
32
+ onTargetingAutoAttackFinish(source: Unit): void;
16
33
  onDamageDealing(target: Unit, event: DamagingEvent): void;
17
34
  onDamageDealt(target: Unit, event: DamageEvent): void;
18
35
  onDamageReceiving(source: Unit | undefined, event: DamagingEvent): void;
19
36
  onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
20
37
  onAbilityGained(ability: Ability): void;
21
38
  onAbilityLost(ability: Ability): void;
39
+ onAbilityChannelingStart(ability: Ability): void;
40
+ onAbilityImpact(ability: Ability): void;
41
+ onAbilityWidgetTargetImpact(ability: Ability, target: Widget): void;
42
+ onAbilityUnitTargetImpact(ability: Ability, target: Unit): void;
43
+ onAbilityItemTargetImpact(ability: Ability, target: Item): void;
44
+ onAbilityDestructibleTargetImpact(ability: Ability, target: Destructable): void;
45
+ onAbilityPointTargetImpact(ability: Ability, x: number, y: number): void;
46
+ onAbilityNoTargetImpact(ability: Ability): void;
47
+ onAbilityChannelingFinish(ability: Ability): void;
48
+ onAbilityStop(ability: Ability): void;
49
+ onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
50
+ onTargetingAbilityImpact(ability: Ability, source: Unit): void;
51
+ onBuffGained(buff: Buff): void;
22
52
  onItemDropped(item: Item): void;
23
53
  onItemPickedUp(item: Item): void;
24
54
  onItemUsed(item: Item): void;
25
55
  onItemStacked(item: Item): void;
56
+ onItemChargesChanged(item: Item): void;
26
57
  onKill(target: Unit): void;
27
58
  onDeath(source: Unit | undefined): void;
59
+ onOwnerChange(previousOwner: Player): void;
28
60
  }
@@ -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,22 @@ 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 ____bonus = require("engine.internal.unit.bonus")
21
+ local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
22
+ local getUnitBonus = ____bonus.getUnitBonus
23
+ local removeUnitBonus = ____bonus.removeUnitBonus
24
+ local safeCall = warpack.safeCall
25
+ local behaviorsByEvent = {}
26
+ local rangeByBehaviorByEvent = {}
27
+ local listenerByBehaviorByEvent = {}
28
+ local eventsByBehavior = {}
12
29
  ____exports.UnitBehavior = __TS__Class()
13
30
  local UnitBehavior = ____exports.UnitBehavior
14
31
  UnitBehavior.name = "UnitBehavior"
@@ -16,10 +33,86 @@ __TS__ClassExtends(UnitBehavior, Behavior)
16
33
  function UnitBehavior.prototype.____constructor(self, unit)
17
34
  Behavior.prototype.____constructor(self, unit)
18
35
  end
36
+ 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
+ if ____opt_0 ~= nil then
42
+ ____opt_0:remove(self)
43
+ end
44
+ local ____opt_2 = rangeByBehaviorByEvent[event]
45
+ if ____opt_2 ~= nil then
46
+ ____opt_2[self] = nil
47
+ end
48
+ local ____opt_4 = listenerByBehaviorByEvent[event]
49
+ if ____opt_4 ~= nil then
50
+ ____opt_4[self] = nil
51
+ end
52
+ end
53
+ eventsByBehavior[self] = nil
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
60
+ return Behavior.prototype.onDestroy(self)
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
75
+ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
76
+ local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
77
+ rangeByBehavior[self] = range
78
+ local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
79
+ listenerByBehavior[self] = listener
80
+ getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
81
+ local behaviors = behaviorsByEvent[event]
82
+ if behaviors == nil then
83
+ event:addListener(function(...)
84
+ local behaviors = behaviorsByEvent[event]
85
+ if behaviors ~= nil then
86
+ local unit = extractUnit(...)
87
+ if unit ~= nil then
88
+ for behavior in pairs(behaviors) do
89
+ local range = rangeByBehavior[behavior]
90
+ if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
91
+ safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end)
97
+ behaviors = __TS__New(LinkedSet)
98
+ behaviorsByEvent[event] = behaviors
99
+ end
100
+ behaviors:add(self)
101
+ end
102
+ function UnitBehavior.prototype.onImmediateOrder(self, orderId)
103
+ end
104
+ function UnitBehavior.prototype.onTargetOrder(self, orderId, target)
105
+ end
106
+ function UnitBehavior.prototype.onPointOrder(self, orderId, x, y)
107
+ end
19
108
  function UnitBehavior.prototype.onAutoAttackStart(self, target)
20
109
  end
21
110
  function UnitBehavior.prototype.onAutoAttackFinish(self, target)
22
111
  end
112
+ function UnitBehavior.prototype.onTargetingAutoAttackStart(self, source)
113
+ end
114
+ function UnitBehavior.prototype.onTargetingAutoAttackFinish(self, source)
115
+ end
23
116
  function UnitBehavior.prototype.onDamageDealing(self, target, event)
24
117
  end
25
118
  function UnitBehavior.prototype.onDamageDealt(self, target, event)
@@ -32,6 +125,32 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
32
125
  end
33
126
  function UnitBehavior.prototype.onAbilityLost(self, ability)
34
127
  end
128
+ function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
129
+ end
130
+ function UnitBehavior.prototype.onAbilityImpact(self, ability)
131
+ end
132
+ function UnitBehavior.prototype.onAbilityWidgetTargetImpact(self, ability, target)
133
+ end
134
+ function UnitBehavior.prototype.onAbilityUnitTargetImpact(self, ability, target)
135
+ end
136
+ function UnitBehavior.prototype.onAbilityItemTargetImpact(self, ability, target)
137
+ end
138
+ function UnitBehavior.prototype.onAbilityDestructibleTargetImpact(self, ability, target)
139
+ end
140
+ function UnitBehavior.prototype.onAbilityPointTargetImpact(self, ability, x, y)
141
+ end
142
+ function UnitBehavior.prototype.onAbilityNoTargetImpact(self, ability)
143
+ end
144
+ function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
145
+ end
146
+ function UnitBehavior.prototype.onAbilityStop(self, ability)
147
+ end
148
+ function UnitBehavior.prototype.onTargetingAbilityChannelingStart(self, ability, source)
149
+ end
150
+ function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
151
+ end
152
+ function UnitBehavior.prototype.onBuffGained(self, buff)
153
+ end
35
154
  function UnitBehavior.prototype.onItemDropped(self, item)
36
155
  end
37
156
  function UnitBehavior.prototype.onItemPickedUp(self, item)
@@ -40,10 +159,14 @@ function UnitBehavior.prototype.onItemUsed(self, item)
40
159
  end
41
160
  function UnitBehavior.prototype.onItemStacked(self, item)
42
161
  end
162
+ function UnitBehavior.prototype.onItemChargesChanged(self, item)
163
+ end
43
164
  function UnitBehavior.prototype.onKill(self, target)
44
165
  end
45
166
  function UnitBehavior.prototype.onDeath(self, source)
46
167
  end
168
+ function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
169
+ end
47
170
  __TS__SetDescriptor(
48
171
  UnitBehavior.prototype,
49
172
  "unit",
@@ -53,11 +176,28 @@ __TS__SetDescriptor(
53
176
  true
54
177
  );
55
178
  (function(self)
179
+ Unit.onImmediateOrder:addListener(function(source, orderId)
180
+ ____exports.UnitBehavior:forAll(source, "onImmediateOrder", orderId)
181
+ end)
182
+ Unit.onTargetOrder:addListener(function(source, orderId, target)
183
+ ____exports.UnitBehavior:forAll(source, "onTargetOrder", orderId, target)
184
+ end)
185
+ Unit.onPointOrder:addListener(function(source, orderId, x, y)
186
+ ____exports.UnitBehavior:forAll(
187
+ source,
188
+ "onPointOrder",
189
+ orderId,
190
+ x,
191
+ y
192
+ )
193
+ end)
56
194
  Unit.autoAttackStartEvent:addListener(function(source, target)
57
195
  ____exports.UnitBehavior:forAll(source, "onAutoAttackStart", target)
196
+ ____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackStart", source)
58
197
  end)
59
198
  Unit.autoAttackFinishEvent:addListener(function(source, target)
60
199
  ____exports.UnitBehavior:forAll(source, "onAutoAttackFinish", target)
200
+ ____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackFinish", source)
61
201
  end)
62
202
  Unit.onDamaging:addListener(function(source, target, event)
63
203
  if source ~= nil then
@@ -71,11 +211,51 @@ __TS__SetDescriptor(
71
211
  end
72
212
  ____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
73
213
  end)
74
- Unit.abilityGainedEvent:addListener(function(source, target)
75
- ____exports.UnitBehavior:forAll(source, "onAbilityGained", target)
214
+ Unit.abilityGainedEvent:addListener(function(source, ability)
215
+ ____exports.UnitBehavior:forAll(source, "onAbilityGained", ability)
216
+ end)
217
+ Unit.abilityLostEvent:addListener(function(source, ability)
218
+ ____exports.UnitBehavior:forAll(source, "onAbilityLost", ability)
219
+ end)
220
+ Unit.abilityChannelingStartEvent:addListener(function(source, ability)
221
+ ____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
222
+ end)
223
+ Unit.abilityUnitTargetChannelingStartEvent:addListener(function(source, ability, target)
224
+ ____exports.UnitBehavior:forAll(target, "onTargetingAbilityChannelingStart", ability, source)
76
225
  end)
77
- Unit.abilityLostEvent:addListener(function(source, target)
78
- ____exports.UnitBehavior:forAll(source, "onAbilityLost", target)
226
+ Unit.abilityImpactEvent:addListener(function(source, ability)
227
+ ____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
228
+ end)
229
+ Unit.abilityWidgetTargetImpactEvent:addListener(function(source, ability, target)
230
+ ____exports.UnitBehavior:forAll(source, "onAbilityWidgetTargetImpact", ability, target)
231
+ end)
232
+ Unit.abilityUnitTargetImpactEvent:addListener(function(source, ability, target)
233
+ ____exports.UnitBehavior:forAll(source, "onAbilityUnitTargetImpact", ability, target)
234
+ ____exports.UnitBehavior:forAll(target, "onTargetingAbilityImpact", ability, source)
235
+ end)
236
+ Unit.abilityItemTargetImpactEvent:addListener(function(source, ability, target)
237
+ ____exports.UnitBehavior:forAll(source, "onAbilityItemTargetImpact", ability, target)
238
+ end)
239
+ Unit.abilityDestructibleTargetImpactEvent:addListener(function(source, ability, target)
240
+ ____exports.UnitBehavior:forAll(source, "onAbilityDestructibleTargetImpact", ability, target)
241
+ end)
242
+ Unit.abilityPointTargetImpactEvent:addListener(function(source, ability, x, y)
243
+ ____exports.UnitBehavior:forAll(
244
+ source,
245
+ "onAbilityPointTargetImpact",
246
+ ability,
247
+ x,
248
+ y
249
+ )
250
+ end)
251
+ Unit.abilityNoTargetImpactEvent:addListener(function(source, ability)
252
+ ____exports.UnitBehavior:forAll(source, "onAbilityNoTargetImpact", ability)
253
+ end)
254
+ Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
255
+ ____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
256
+ end)
257
+ Unit.abilityStopEvent:addListener(function(source, ability)
258
+ ____exports.UnitBehavior:forAll(source, "onAbilityStop", ability)
79
259
  end)
80
260
  Unit.deathEvent:addListener(function(target, source)
81
261
  if source ~= nil then
@@ -95,6 +275,12 @@ __TS__SetDescriptor(
95
275
  Unit.itemStackedEvent:addListener(function(unit, item)
96
276
  ____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
97
277
  end)
278
+ Unit.itemChargesChangedEvent:addListener(function(unit, item)
279
+ ____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
280
+ end)
281
+ Unit.onOwnerChange:addListener(function(unit, previousOwner)
282
+ ____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
283
+ end)
98
284
  end)(UnitBehavior)
99
285
  Unit.destroyEvent:addListener(function(unit)
100
286
  ____exports.UnitBehavior:forAll(unit, "destroy")
package/engine/buff.d.ts CHANGED
@@ -201,11 +201,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
201
201
  private readonly _spellStealPriority?;
202
202
  private readonly _learnLevelMinimum?;
203
203
  private readonly [BuffPropertyKey.MISS_PROBABILITY]?;
204
- private _bonusIdByBonusType?;
205
204
  private readonly _abilityTypeIds?;
206
205
  private _behaviors?;
207
- private getUnitBonus;
208
- private addOrUpdateOrRemoveUnitBonus;
209
206
  constructor(target: Unit, ...parameters: BuffConstructorParameters<AdditionalParameters>);
210
207
  get level(): number;
211
208
  get remainingDamageOverDuration(): number;
@@ -278,6 +275,7 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
278
275
  onDeath(source: Unit | undefined): void;
279
276
  onDamageDealt(target: Unit, event: DamageEvent): void;
280
277
  onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
281
- static readonly destroyEvent: Event<[Buff<object>]>;
278
+ static readonly createdEvent: Event<[Buff<object>]>;
279
+ static readonly beingDestroyedEvent: Event<[Buff<object>]>;
282
280
  }
283
281
  export {};
package/engine/buff.lua CHANGED
@@ -28,9 +28,6 @@ local ____math = require("math")
28
28
  local max = ____math.max
29
29
  local min = ____math.min
30
30
  local ____bonus = require("engine.internal.unit.bonus")
31
- local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
32
- local getUnitBonus = ____bonus.getUnitBonus
33
- local removeUnitBonus = ____bonus.removeUnitBonus
34
31
  local UnitBonusType = ____bonus.UnitBonusType
35
32
  local ____area_2Ddamage = require("engine.internal.mechanics.area-damage")
36
33
  local damageArea = ____area_2Ddamage.damageArea
@@ -304,7 +301,8 @@ buffHealingIntervalTimerCallback = function(buff)
304
301
  source:healTarget(buff[101], healingPerInterval)
305
302
  end
306
303
  end
307
- local buffDestroyEvent = __TS__New(Event)
304
+ local buffCreatedEvent = __TS__New(Event)
305
+ local buffBeingDestroyedEvent = __TS__New(Event)
308
306
  ____exports.Buff = __TS__Class()
309
307
  local Buff = ____exports.Buff
310
308
  Buff.name = "Buff"
@@ -506,64 +504,52 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
506
504
  end
507
505
  self:onCreate()
508
506
  self[100] = 1
509
- end
510
- function Buff.prototype.getUnitBonus(self, bonusType)
511
- local ____opt_38 = self._bonusIdByBonusType
512
- local bonusId = ____opt_38 and ____opt_38[bonusType]
513
- return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
514
- end
515
- function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
516
- local bonusIdByBonusType = self._bonusIdByBonusType
517
- if bonusIdByBonusType == nil then
518
- bonusIdByBonusType = {}
519
- self._bonusIdByBonusType = bonusIdByBonusType
520
- end
521
- bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
507
+ Event.invoke(buffCreatedEvent, self)
522
508
  end
523
509
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
524
510
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
525
511
  Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
526
512
  else
527
513
  local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
528
- local ____Effect_42 = Effect
529
- local ____Effect_flash_43 = Effect.flash
530
- local ____array_41 = __TS__SparseArrayNew(
514
+ local ____Effect_40 = Effect
515
+ local ____Effect_flash_41 = Effect.flash
516
+ local ____array_39 = __TS__SparseArrayNew(
531
517
  self[105],
532
518
  isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
533
519
  stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
534
520
  )
535
- local ____isWidgetProvided_40
521
+ local ____isWidgetProvided_38
536
522
  if isWidgetProvided then
537
- ____isWidgetProvided_40 = yOrParametersOrDuration
523
+ ____isWidgetProvided_38 = yOrParametersOrDuration
538
524
  else
539
- ____isWidgetProvided_40 = widgetOrXOrParametersOrDuration
525
+ ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
540
526
  end
541
- __TS__SparseArrayPush(____array_41, ____isWidgetProvided_40)
542
- ____Effect_flash_43(
543
- ____Effect_42,
544
- __TS__SparseArraySpread(____array_41)
527
+ __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
528
+ ____Effect_flash_41(
529
+ ____Effect_40,
530
+ __TS__SparseArraySpread(____array_39)
545
531
  )
546
532
  end
547
533
  end
548
534
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
549
535
  local isWidgetProvided = type(widgetOrDuration) == "table"
550
- local ____Effect_46 = Effect
551
- local ____Effect_flash_47 = Effect.flash
552
- local ____array_45 = __TS__SparseArrayNew(
536
+ local ____Effect_44 = Effect
537
+ local ____Effect_flash_45 = Effect.flash
538
+ local ____array_43 = __TS__SparseArrayNew(
553
539
  self[106],
554
540
  isWidgetProvided and widgetOrDuration or self._unit,
555
541
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
556
542
  )
557
- local ____isWidgetProvided_44
543
+ local ____isWidgetProvided_42
558
544
  if isWidgetProvided then
559
- ____isWidgetProvided_44 = duration
545
+ ____isWidgetProvided_42 = duration
560
546
  else
561
- ____isWidgetProvided_44 = widgetOrDuration
547
+ ____isWidgetProvided_42 = widgetOrDuration
562
548
  end
563
- __TS__SparseArrayPush(____array_45, ____isWidgetProvided_44)
564
- ____Effect_flash_47(
565
- ____Effect_46,
566
- __TS__SparseArraySpread(____array_45)
549
+ __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
550
+ ____Effect_flash_45(
551
+ ____Effect_44,
552
+ __TS__SparseArraySpread(____array_43)
567
553
  )
568
554
  end
569
555
  function Buff.prototype.onCreate(self)
@@ -614,12 +600,7 @@ function Buff.prototype.onDestroy(self)
614
600
  unit:removeAbility(abilityTypeId)
615
601
  end
616
602
  end
617
- if self._bonusIdByBonusType ~= nil then
618
- for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
619
- removeUnitBonus(unit, bonusType, bonusId)
620
- end
621
- end
622
- Event.invoke(buffDestroyEvent, self)
603
+ Event.invoke(buffBeingDestroyedEvent, self)
623
604
  self[100] = 3
624
605
  return UnitBehavior.prototype.onDestroy(self)
625
606
  end
@@ -648,8 +629,8 @@ function Buff.apply(self, ...)
648
629
  end
649
630
  end
650
631
  function Buff.getByTypeId(self, unit, typeId)
651
- local ____opt_48 = buffByTypeIdByUnit[unit]
652
- local buff = ____opt_48 and ____opt_48[typeId]
632
+ local ____opt_46 = buffByTypeIdByUnit[unit]
633
+ local buff = ____opt_46 and ____opt_46[typeId]
653
634
  if __TS__InstanceOf(buff, self) then
654
635
  return buff
655
636
  end
@@ -807,8 +788,8 @@ __TS__SetDescriptor(
807
788
  return
808
789
  end
809
790
  self[112] = damageInterval
810
- local ____opt_50 = self._timer
811
- local elapsed = ____opt_50 and ____opt_50.elapsed or 0
791
+ local ____opt_48 = self._timer
792
+ local elapsed = ____opt_48 and ____opt_48.elapsed or 0
812
793
  local timer = self[114]
813
794
  if timer == nil then
814
795
  timer = Timer:create()
@@ -887,8 +868,8 @@ __TS__SetDescriptor(
887
868
  return
888
869
  end
889
870
  self[117] = healingInterval
890
- local ____opt_52 = self._timer
891
- local elapsed = ____opt_52 and ____opt_52.elapsed or 0
871
+ local ____opt_50 = self._timer
872
+ local elapsed = ____opt_50 and ____opt_50.elapsed or 0
892
873
  local timer = self[119]
893
874
  if timer == nil then
894
875
  timer = Timer:create()
@@ -974,11 +955,11 @@ __TS__SetDescriptor(
974
955
  "turnsIntoGhost",
975
956
  {
976
957
  get = function(self)
977
- local ____self__135_54 = self[135]
978
- if ____self__135_54 == nil then
979
- ____self__135_54 = false
958
+ local ____self__135_52 = self[135]
959
+ if ____self__135_52 == nil then
960
+ ____self__135_52 = false
980
961
  end
981
- return ____self__135_54
962
+ return ____self__135_52
982
963
  end,
983
964
  set = function(self, turnsIntoGhost)
984
965
  if not turnsIntoGhost and self[135] then
@@ -997,11 +978,11 @@ __TS__SetDescriptor(
997
978
  "stuns",
998
979
  {
999
980
  get = function(self)
1000
- local ____self__136_55 = self[136]
1001
- if ____self__136_55 == nil then
1002
- ____self__136_55 = false
981
+ local ____self__136_53 = self[136]
982
+ if ____self__136_53 == nil then
983
+ ____self__136_53 = false
1003
984
  end
1004
- return ____self__136_55
985
+ return ____self__136_53
1005
986
  end,
1006
987
  set = function(self, stuns)
1007
988
  if not stuns and self[136] then
@@ -1026,11 +1007,11 @@ __TS__SetDescriptor(
1026
1007
  "ignoresStunImmunity",
1027
1008
  {
1028
1009
  get = function(self)
1029
- local ____self__137_56 = self[137]
1030
- if ____self__137_56 == nil then
1031
- ____self__137_56 = false
1010
+ local ____self__137_54 = self[137]
1011
+ if ____self__137_54 == nil then
1012
+ ____self__137_54 = false
1032
1013
  end
1033
- return ____self__137_56
1014
+ return ____self__137_54
1034
1015
  end,
1035
1016
  set = function(self, ignoresStunImmunity)
1036
1017
  if not ignoresStunImmunity and self[137] then
@@ -1053,11 +1034,11 @@ __TS__SetDescriptor(
1053
1034
  "disablesAutoAttack",
1054
1035
  {
1055
1036
  get = function(self)
1056
- local ____self__138_57 = self[138]
1057
- if ____self__138_57 == nil then
1058
- ____self__138_57 = false
1037
+ local ____self__138_55 = self[138]
1038
+ if ____self__138_55 == nil then
1039
+ ____self__138_55 = false
1059
1040
  end
1060
- return ____self__138_57
1041
+ return ____self__138_55
1061
1042
  end,
1062
1043
  set = function(self, disablesAutoAttack)
1063
1044
  if not disablesAutoAttack and self[138] then
@@ -1076,11 +1057,11 @@ __TS__SetDescriptor(
1076
1057
  "providesInvulnerability",
1077
1058
  {
1078
1059
  get = function(self)
1079
- local ____self__139_58 = self[139]
1080
- if ____self__139_58 == nil then
1081
- ____self__139_58 = false
1060
+ local ____self__139_56 = self[139]
1061
+ if ____self__139_56 == nil then
1062
+ ____self__139_56 = false
1082
1063
  end
1083
- return ____self__139_58
1064
+ return ____self__139_56
1084
1065
  end,
1085
1066
  set = function(self, providesInvulnerability)
1086
1067
  if not providesInvulnerability and self[139] then
@@ -1099,11 +1080,11 @@ __TS__SetDescriptor(
1099
1080
  "killsOnExpiration",
1100
1081
  {
1101
1082
  get = function(self)
1102
- local ____self__140_59 = self[140]
1103
- if ____self__140_59 == nil then
1104
- ____self__140_59 = false
1083
+ local ____self__140_57 = self[140]
1084
+ if ____self__140_57 == nil then
1085
+ ____self__140_57 = false
1105
1086
  end
1106
- return ____self__140_59
1087
+ return ____self__140_57
1107
1088
  end,
1108
1089
  set = function(self, killsOnExpiration)
1109
1090
  if not killsOnExpiration and self[140] then
@@ -1120,11 +1101,11 @@ __TS__SetDescriptor(
1120
1101
  "explodesOnExpiration",
1121
1102
  {
1122
1103
  get = function(self)
1123
- local ____self__141_60 = self[141]
1124
- if ____self__141_60 == nil then
1125
- ____self__141_60 = false
1104
+ local ____self__141_58 = self[141]
1105
+ if ____self__141_58 == nil then
1106
+ ____self__141_58 = false
1126
1107
  end
1127
- return ____self__141_60
1108
+ return ____self__141_58
1128
1109
  end,
1129
1110
  set = function(self, killsOnExpiration)
1130
1111
  if not killsOnExpiration and self[141] then
@@ -1252,13 +1233,13 @@ __TS__SetDescriptor(
1252
1233
  "remainingDuration",
1253
1234
  {
1254
1235
  get = function(self)
1255
- local ____opt_61 = self._timer
1256
- return ____opt_61 and ____opt_61.remaining or 0
1236
+ local ____opt_59 = self._timer
1237
+ return ____opt_59 and ____opt_59.remaining or 0
1257
1238
  end,
1258
1239
  set = function(self, remainingDuration)
1259
- local ____remainingDuration_65 = remainingDuration
1260
- local ____opt_63 = self._timer
1261
- local remainingDurationDelta = ____remainingDuration_65 - (____opt_63 and ____opt_63.remaining or 0)
1240
+ local ____remainingDuration_63 = remainingDuration
1241
+ local ____opt_61 = self._timer
1242
+ local remainingDurationDelta = ____remainingDuration_63 - (____opt_61 and ____opt_61.remaining or 0)
1262
1243
  if remainingDurationDelta ~= 0 then
1263
1244
  self[103] = self[103] + remainingDurationDelta
1264
1245
  if remainingDuration <= 0 then
@@ -1288,7 +1269,8 @@ __TS__SetDescriptor(
1288
1269
  },
1289
1270
  true
1290
1271
  )
1291
- Buff.destroyEvent = buffDestroyEvent;
1272
+ Buff.createdEvent = buffCreatedEvent
1273
+ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1292
1274
  (function(self)
1293
1275
  local function destroyBuffIfNeeded(buff)
1294
1276
  if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
@@ -1342,5 +1324,8 @@ Buff.destroyEvent = buffDestroyEvent;
1342
1324
  ____exports.checkBuffs(target)
1343
1325
  end
1344
1326
  )
1327
+ buffCreatedEvent:addListener(function(buff)
1328
+ UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1329
+ end)
1345
1330
  end)(Buff)
1346
1331
  return ____exports
@@ -1,5 +1,5 @@
1
1
  /** @noSelfInFile */
2
- import { Handle } from "../../core/types/handle";
2
+ import { Handle, HandleDestructor } from "../../core/types/handle";
3
3
  import { Event } from "../../event";
4
4
  import type { Item } from "../../core/types/item";
5
5
  import type { Unit } from "./unit";
@@ -55,14 +55,19 @@ 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;
64
68
  set cooldownRemaining(cooldownRemaining: number);
65
69
  interruptCast(): void;
70
+ protected onDestroy(): HandleDestructor;
66
71
  static get onCreate(): Event<[UnitAbility]>;
67
72
  static get onDestroy(): Event<[UnitAbility]>;
68
73
  }
@@ -89,6 +94,7 @@ export declare class ItemAbility extends Ability {
89
94
  get cooldownRemaining(): number;
90
95
  set cooldownRemaining(cooldownRemaining: number);
91
96
  interruptCast(): void;
97
+ protected onDestroy(): HandleDestructor;
92
98
  static get onCreate(): Event<[ItemAbility]>;
93
99
  static get onDestroy(): Event<[ItemAbility]>;
94
100
  }