warscript 0.0.1-dev.3d15d22 → 0.0.1-dev.3dad3ec

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 (144) hide show
  1. package/attributes.d.ts +5 -0
  2. package/attributes.lua +8 -1
  3. package/config.d.ts +5 -0
  4. package/config.lua +10 -0
  5. package/core/types/effect.d.ts +1 -3
  6. package/core/types/effect.lua +26 -29
  7. package/core/types/frame.lua +25 -12
  8. package/core/types/player.lua +4 -1
  9. package/core/types/playerCamera.d.ts +2 -0
  10. package/core/types/playerCamera.lua +76 -2
  11. package/core/types/sound.d.ts +17 -24
  12. package/core/types/sound.lua +99 -24
  13. package/core/types/timer.d.ts +8 -8
  14. package/core/types/timer.lua +25 -23
  15. package/core/util.lua +6 -1
  16. package/decl/native.d.ts +844 -788
  17. package/engine/behavior.d.ts +2 -0
  18. package/engine/behavior.lua +53 -27
  19. package/engine/behaviour/ability/apply-buff.lua +1 -1
  20. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  21. package/engine/behaviour/ability/damage.d.ts +9 -3
  22. package/engine/behaviour/ability/damage.lua +26 -38
  23. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  24. package/engine/behaviour/ability/emulate-impact.lua +18 -3
  25. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  26. package/engine/behaviour/ability/restore-mana.lua +6 -6
  27. package/engine/behaviour/ability.d.ts +5 -1
  28. package/engine/behaviour/ability.lua +26 -21
  29. package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
  30. package/engine/behaviour/unit/stun-immunity.lua +43 -27
  31. package/engine/behaviour/unit.d.ts +28 -0
  32. package/engine/behaviour/unit.lua +163 -4
  33. package/engine/buff.d.ts +15 -9
  34. package/engine/buff.lua +92 -53
  35. package/engine/internal/ability.d.ts +4 -0
  36. package/engine/internal/ability.lua +23 -0
  37. package/engine/internal/item/ability.lua +63 -11
  38. package/engine/internal/item.d.ts +5 -2
  39. package/engine/internal/item.lua +75 -3
  40. package/engine/internal/mechanics/ability-duration.lua +1 -1
  41. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  42. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  43. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  44. package/engine/internal/misc/get-terrain-z.lua +11 -0
  45. package/engine/internal/unit/ability.d.ts +35 -0
  46. package/engine/internal/unit/ability.lua +62 -0
  47. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  48. package/engine/internal/unit/allowed-targets.lua +9 -1
  49. package/engine/internal/unit/order.d.ts +20 -0
  50. package/engine/internal/unit/order.lua +136 -0
  51. package/engine/internal/unit+damage.d.ts +2 -11
  52. package/engine/internal/unit+damage.lua +10 -14
  53. package/engine/internal/unit+spellSteal.lua +1 -2
  54. package/engine/internal/unit-missile-launch.lua +9 -2
  55. package/engine/internal/unit.d.ts +29 -7
  56. package/engine/internal/unit.lua +239 -94
  57. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  58. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  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/sound-eax.d.ts +10 -0
  68. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  69. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  70. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  71. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  72. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  73. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  74. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  75. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  76. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  77. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  78. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  79. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  80. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  81. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  82. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  83. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  84. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  85. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  86. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  87. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  88. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  89. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  90. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  91. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  92. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  93. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  94. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  95. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  96. package/engine/object-data/entry/ability-type/web.lua +52 -0
  97. package/engine/object-data/entry/ability-type.d.ts +19 -17
  98. package/engine/object-data/entry/ability-type.lua +82 -24
  99. package/engine/object-data/entry/buff-type/applicable.lua +9 -4
  100. package/engine/object-data/entry/buff-type.d.ts +6 -12
  101. package/engine/object-data/entry/buff-type.lua +13 -29
  102. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  103. package/engine/object-data/entry/item-type.d.ts +1 -1
  104. package/engine/object-data/entry/item-type.lua +4 -4
  105. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  106. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  107. package/engine/object-data/entry/sound-preset.lua +140 -0
  108. package/engine/object-data/entry/unit-type.d.ts +21 -5
  109. package/engine/object-data/entry/unit-type.lua +214 -93
  110. package/engine/object-data/entry/upgrade.d.ts +1 -1
  111. package/engine/object-data/entry/upgrade.lua +4 -4
  112. package/engine/object-data/entry.d.ts +16 -14
  113. package/engine/object-data/entry.lua +60 -32
  114. package/engine/object-field/ability.d.ts +1 -1
  115. package/engine/object-field/unit.d.ts +57 -3
  116. package/engine/object-field/unit.lua +207 -7
  117. package/engine/object-field.d.ts +15 -4
  118. package/engine/object-field.lua +184 -90
  119. package/engine/standard/entries/buff-type.d.ts +3 -0
  120. package/engine/standard/entries/buff-type.lua +3 -0
  121. package/engine/standard/entries/sound-preset.d.ts +10 -0
  122. package/engine/standard/entries/sound-preset.lua +10 -0
  123. package/engine/standard/fields/unit.d.ts +4 -0
  124. package/engine/standard/fields/unit.lua +7 -0
  125. package/engine/text-tag.d.ts +36 -2
  126. package/engine/text-tag.lua +248 -10
  127. package/engine/unit.d.ts +1 -0
  128. package/engine/unit.lua +1 -0
  129. package/objutil/buff.lua +1 -2
  130. package/objutil/unit.lua +8 -0
  131. package/package.json +2 -2
  132. package/utility/arrays.d.ts +1 -0
  133. package/utility/arrays.lua +3 -0
  134. package/utility/functions.d.ts +8 -0
  135. package/utility/functions.lua +13 -0
  136. package/utility/linked-set.d.ts +1 -0
  137. package/utility/linked-set.lua +3 -0
  138. package/utility/lua-maps.d.ts +4 -0
  139. package/utility/lua-maps.lua +20 -0
  140. package/utility/lua-sets.d.ts +2 -0
  141. package/utility/lua-sets.lua +7 -0
  142. package/utility/reflection.lua +11 -7
  143. package/core/types/order.d.ts +0 -25
  144. package/core/types/order.lua +0 -55
@@ -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,69 @@ __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, extractUnit, 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(...)
61
+ local behaviors = behaviorsByEvent[event]
62
+ if behaviors ~= nil then
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
71
+ end
72
+ end
73
+ end
74
+ end)
75
+ behaviors = __TS__New(LinkedSet)
76
+ behaviorsByEvent[event] = behaviors
77
+ end
78
+ behaviors:add(self)
79
+ end
80
+ function UnitBehavior.prototype.onImmediateOrder(self, orderId)
81
+ end
82
+ function UnitBehavior.prototype.onTargetOrder(self, orderId, target)
83
+ end
84
+ function UnitBehavior.prototype.onPointOrder(self, orderId, x, y)
85
+ end
19
86
  function UnitBehavior.prototype.onAutoAttackStart(self, target)
20
87
  end
21
88
  function UnitBehavior.prototype.onAutoAttackFinish(self, target)
22
89
  end
90
+ function UnitBehavior.prototype.onTargetingAutoAttackStart(self, source)
91
+ end
92
+ function UnitBehavior.prototype.onTargetingAutoAttackFinish(self, source)
93
+ end
23
94
  function UnitBehavior.prototype.onDamageDealing(self, target, event)
24
95
  end
25
96
  function UnitBehavior.prototype.onDamageDealt(self, target, event)
@@ -32,6 +103,32 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
32
103
  end
33
104
  function UnitBehavior.prototype.onAbilityLost(self, ability)
34
105
  end
106
+ function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
107
+ end
108
+ function UnitBehavior.prototype.onAbilityImpact(self, ability)
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
122
+ function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
123
+ end
124
+ function UnitBehavior.prototype.onAbilityStop(self, ability)
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
35
132
  function UnitBehavior.prototype.onItemDropped(self, item)
36
133
  end
37
134
  function UnitBehavior.prototype.onItemPickedUp(self, item)
@@ -40,6 +137,8 @@ function UnitBehavior.prototype.onItemUsed(self, item)
40
137
  end
41
138
  function UnitBehavior.prototype.onItemStacked(self, item)
42
139
  end
140
+ function UnitBehavior.prototype.onItemChargesChanged(self, item)
141
+ end
43
142
  function UnitBehavior.prototype.onKill(self, target)
44
143
  end
45
144
  function UnitBehavior.prototype.onDeath(self, source)
@@ -53,11 +152,28 @@ __TS__SetDescriptor(
53
152
  true
54
153
  );
55
154
  (function(self)
155
+ Unit.onImmediateOrder:addListener(function(source, orderId)
156
+ ____exports.UnitBehavior:forAll(source, "onImmediateOrder", orderId)
157
+ end)
158
+ Unit.onTargetOrder:addListener(function(source, orderId, target)
159
+ ____exports.UnitBehavior:forAll(source, "onTargetOrder", orderId, target)
160
+ end)
161
+ Unit.onPointOrder:addListener(function(source, orderId, x, y)
162
+ ____exports.UnitBehavior:forAll(
163
+ source,
164
+ "onPointOrder",
165
+ orderId,
166
+ x,
167
+ y
168
+ )
169
+ end)
56
170
  Unit.autoAttackStartEvent:addListener(function(source, target)
57
171
  ____exports.UnitBehavior:forAll(source, "onAutoAttackStart", target)
172
+ ____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackStart", source)
58
173
  end)
59
174
  Unit.autoAttackFinishEvent:addListener(function(source, target)
60
175
  ____exports.UnitBehavior:forAll(source, "onAutoAttackFinish", target)
176
+ ____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackFinish", source)
61
177
  end)
62
178
  Unit.onDamaging:addListener(function(source, target, event)
63
179
  if source ~= nil then
@@ -71,11 +187,51 @@ __TS__SetDescriptor(
71
187
  end
72
188
  ____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
73
189
  end)
74
- Unit.abilityGainedEvent:addListener(function(source, target)
75
- ____exports.UnitBehavior:forAll(source, "onAbilityGained", target)
190
+ Unit.abilityGainedEvent:addListener(function(source, ability)
191
+ ____exports.UnitBehavior:forAll(source, "onAbilityGained", ability)
192
+ end)
193
+ Unit.abilityLostEvent:addListener(function(source, ability)
194
+ ____exports.UnitBehavior:forAll(source, "onAbilityLost", ability)
195
+ end)
196
+ Unit.abilityChannelingStartEvent:addListener(function(source, ability)
197
+ ____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
198
+ end)
199
+ Unit.abilityUnitTargetChannelingStartEvent:addListener(function(source, ability, target)
200
+ ____exports.UnitBehavior:forAll(target, "onTargetingAbilityChannelingStart", ability, source)
76
201
  end)
77
- Unit.abilityLostEvent:addListener(function(source, target)
78
- ____exports.UnitBehavior:forAll(source, "onAbilityLost", target)
202
+ Unit.abilityImpactEvent:addListener(function(source, ability)
203
+ ____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
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)
230
+ Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
231
+ ____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
232
+ end)
233
+ Unit.abilityStopEvent:addListener(function(source, ability)
234
+ ____exports.UnitBehavior:forAll(source, "onAbilityStop", ability)
79
235
  end)
80
236
  Unit.deathEvent:addListener(function(target, source)
81
237
  if source ~= nil then
@@ -95,6 +251,9 @@ __TS__SetDescriptor(
95
251
  Unit.itemStackedEvent:addListener(function(unit, item)
96
252
  ____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
97
253
  end)
254
+ Unit.itemChargesChangedEvent:addListener(function(unit, item)
255
+ ____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
256
+ end)
98
257
  end)(UnitBehavior)
99
258
  Unit.destroyEvent:addListener(function(unit)
100
259
  ____exports.UnitBehavior:forAll(unit, "destroy")
package/engine/buff.d.ts CHANGED
@@ -64,6 +64,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
64
64
  durationIncreaseOnAutoAttack?: NumberParameterValueType;
65
65
  maximumRemainingDuration?: NumberParameterValueType;
66
66
  maximumDuration?: NumberParameterValueType;
67
+ turnsIntoGhost?: BooleanParameterValueType;
67
68
  stuns?: BooleanParameterValueType;
68
69
  ignoresStunImmunity?: BooleanParameterValueType;
69
70
  providesStunImmunity?: BooleanParameterValueType;
@@ -116,13 +117,14 @@ declare const enum BuffPropertyKey {
116
117
  MAXIMUM_DAMAGE_DEALT_EVENT_COUNT = 132,
117
118
  DAMAGE_RECEIVED_EVENT_COUNT = 133,
118
119
  MAXIMUM_DAMAGE_RECEIVED_EVENT_COUNT = 134,
119
- STUNS = 135,
120
- IGNORES_STUN_IMMUNITY = 136,
121
- DISABLES_AUTO_ATTACK = 137,
122
- PROVIDES_INVULNERABILITY = 138,
123
- KILLS_ON_EXPIRATION = 139,
124
- EXPLODES_ON_EXPIRATION = 140,
125
- MISS_PROBABILITY = 141
120
+ TURNS_INTO_GHOST = 135,
121
+ STUNS = 136,
122
+ IGNORES_STUN_IMMUNITY = 137,
123
+ DISABLES_AUTO_ATTACK = 138,
124
+ PROVIDES_INVULNERABILITY = 139,
125
+ KILLS_ON_EXPIRATION = 140,
126
+ EXPLODES_ON_EXPIRATION = 141,
127
+ MISS_PROBABILITY = 142
126
128
  }
127
129
  export declare const enum BuffTypeIdSelectionPolicy {
128
130
  LEAST_DURATION = 0
@@ -136,7 +138,7 @@ export type BuffConstructorParameters<AdditionalParameters extends BuffAdditiona
136
138
  polarity: BuffPolarityParameterType,
137
139
  resistanceType: BuffResistanceTypeParameterType,
138
140
  ...abilityOrParameters: [
139
- ability: Ability,
141
+ ability?: Ability,
140
142
  parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
141
143
  ] | [parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>]
142
144
  ];
@@ -178,6 +180,7 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
178
180
  private [BuffPropertyKey.DAMAGE_DEALT_EVENT_COUNT]?;
179
181
  private [BuffPropertyKey.MAXIMUM_DAMAGE_RECEIVED_EVENT_COUNT]?;
180
182
  private [BuffPropertyKey.DAMAGE_RECEIVED_EVENT_COUNT]?;
183
+ private [BuffPropertyKey.TURNS_INTO_GHOST]?;
181
184
  private [BuffPropertyKey.STUNS]?;
182
185
  private [BuffPropertyKey.IGNORES_STUN_IMMUNITY]?;
183
186
  private [BuffPropertyKey.DISABLES_AUTO_ATTACK]?;
@@ -231,6 +234,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
231
234
  set receivedDamageFactor(receivedDamageFactor: number);
232
235
  get armorIncrease(): number;
233
236
  set armorIncrease(armorIncrease: number);
237
+ get turnsIntoGhost(): boolean;
238
+ set turnsIntoGhost(turnsIntoGhost: boolean);
234
239
  get stuns(): boolean;
235
240
  set stuns(stuns: boolean);
236
241
  get ignoresStunImmunity(): boolean;
@@ -273,6 +278,7 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
273
278
  onDeath(source: Unit | undefined): void;
274
279
  onDamageDealt(target: Unit, event: DamageEvent): void;
275
280
  onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
276
- static readonly destroyEvent: Event<[Buff<object>]>;
281
+ static readonly createdEvent: Event<[Buff<object>]>;
282
+ static readonly beingDestroyedEvent: Event<[Buff<object>]>;
277
283
  }
278
284
  export {};
package/engine/buff.lua CHANGED
@@ -109,6 +109,7 @@ local buffParametersKeys = {
109
109
  durationIncreaseOnAutoAttack = true,
110
110
  maximumDuration = true,
111
111
  maximumRemainingDuration = true,
112
+ turnsIntoGhost = true,
112
113
  stuns = true,
113
114
  ignoresStunImmunity = true,
114
115
  providesStunImmunity = true,
@@ -174,6 +175,7 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
174
175
  end
175
176
  end
176
177
  local buffBooleanParameters = {
178
+ "turnsIntoGhost",
177
179
  "stuns",
178
180
  "ignoresStunImmunity",
179
181
  "disablesAutoAttack",
@@ -302,7 +304,8 @@ buffHealingIntervalTimerCallback = function(buff)
302
304
  source:healTarget(buff[101], healingPerInterval)
303
305
  end
304
306
  end
305
- local buffDestroyEvent = __TS__New(Event)
307
+ local buffCreatedEvent = __TS__New(Event)
308
+ local buffBeingDestroyedEvent = __TS__New(Event)
306
309
  ____exports.Buff = __TS__Class()
307
310
  local Buff = ____exports.Buff
308
311
  Buff.name = "Buff"
@@ -321,7 +324,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
321
324
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
322
325
  polarity = resistanceTypeOrPolarity
323
326
  resistanceType = abilityOrParametersOrResistanceType
324
- if __TS__InstanceOf(parametersOrAbility, Ability) then
327
+ if __TS__InstanceOf(parametersOrAbility, Ability) or parametersOrAbility == nil then
325
328
  ability = parametersOrAbility
326
329
  else
327
330
  ability = nil
@@ -331,7 +334,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
331
334
  typeId = typeIdOrTypeIds
332
335
  polarity = polarityOrTypeIdSelectionPolicy
333
336
  resistanceType = resistanceTypeOrPolarity
334
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
337
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) or abilityOrParametersOrResistanceType == nil then
335
338
  ability = abilityOrParametersOrResistanceType
336
339
  parameters = parametersOrAbility
337
340
  else
@@ -340,7 +343,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
340
343
  end
341
344
  end
342
345
  self.typeId = typeId
343
- if not __TS__InstanceOf(ability, Ability) then
346
+ if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
344
347
  parameters = ability
345
348
  ability = nil
346
349
  end
@@ -371,7 +374,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
371
374
  local missProbability = parameters and parameters.missProbability or defaultParameters.missProbability
372
375
  if missProbability ~= nil then
373
376
  missProbability = resolveNumberValue(ability, level, missProbability)
374
- self[141] = missProbability
377
+ self[142] = missProbability
375
378
  end
376
379
  local buffByTypeId = buffByTypeIdByUnit[_unit]
377
380
  if buffByTypeId == nil then
@@ -397,11 +400,13 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
397
400
  learnLevelMinimum,
398
401
  missProbability
399
402
  ) then
403
+ self[100] = 1
400
404
  UnitBehavior.prototype.destroy(self)
401
405
  error(unsuccessfulApplicationMarker, 0)
402
406
  end
403
407
  local handle = BlzGetUnitAbility(_unit.handle, typeId)
404
408
  if handle == nil then
409
+ self[100] = 1
405
410
  UnitBehavior.prototype.destroy(self)
406
411
  error(unsuccessfulApplicationMarker, 0)
407
412
  end
@@ -502,6 +507,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
502
507
  end
503
508
  self:onCreate()
504
509
  self[100] = 1
510
+ Event.invoke(buffCreatedEvent, self)
505
511
  end
506
512
  function Buff.prototype.getUnitBonus(self, bonusType)
507
513
  local ____opt_38 = self._bonusIdByBonusType
@@ -590,15 +596,21 @@ function Buff.prototype.onDestroy(self)
590
596
  behavior:destroy()
591
597
  end
592
598
  end
593
- if self[137] then
599
+ if self[139] then
600
+ unit:decrementInvulnerabilityCounter()
601
+ end
602
+ if self[138] then
594
603
  unit:decrementDisableAutoAttackCounter()
595
604
  end
596
- if self[135] then
597
- if self[136] then
605
+ if self[136] then
606
+ if self[137] then
598
607
  unit:decrementStunCounter()
599
608
  end
600
609
  unit:decrementStunCounter()
601
610
  end
611
+ if self[135] then
612
+ unit:decrementGhostCounter()
613
+ end
602
614
  if self._abilityTypeIds ~= nil then
603
615
  for abilityTypeId in pairs(self._abilityTypeIds) do
604
616
  unit:removeAbility(abilityTypeId)
@@ -609,7 +621,7 @@ function Buff.prototype.onDestroy(self)
609
621
  removeUnitBonus(unit, bonusType, bonusId)
610
622
  end
611
623
  end
612
- Event.invoke(buffDestroyEvent, self)
624
+ Event.invoke(buffBeingDestroyedEvent, self)
613
625
  self[100] = 3
614
626
  return UnitBehavior.prototype.onDestroy(self)
615
627
  end
@@ -653,9 +665,9 @@ function Buff.prototype.onExpiration(self)
653
665
  if self[121] ~= nil then
654
666
  (self[102] or unit):healTarget(unit, self[120] or 0)
655
667
  end
656
- if self[140] then
668
+ if self[141] then
657
669
  unit:explode()
658
- elseif self[139] then
670
+ elseif self[140] then
659
671
  unit:kill()
660
672
  end
661
673
  end
@@ -961,7 +973,7 @@ __TS__SetDescriptor(
961
973
  )
962
974
  __TS__SetDescriptor(
963
975
  Buff.prototype,
964
- "stuns",
976
+ "turnsIntoGhost",
965
977
  {
966
978
  get = function(self)
967
979
  local ____self__135_54 = self[135]
@@ -970,18 +982,12 @@ __TS__SetDescriptor(
970
982
  end
971
983
  return ____self__135_54
972
984
  end,
973
- set = function(self, stuns)
974
- if not stuns and self[135] then
975
- if self[136] then
976
- self.object:decrementStunCounter()
977
- end
978
- self.object:decrementStunCounter()
985
+ set = function(self, turnsIntoGhost)
986
+ if not turnsIntoGhost and self[135] then
987
+ self.object:decrementGhostCounter()
979
988
  self[135] = nil
980
- elseif stuns and not self[135] then
981
- if self[136] then
982
- self.object:incrementStunCounter()
983
- end
984
- self.object:incrementStunCounter()
989
+ elseif turnsIntoGhost and not self[135] then
990
+ self.object:incrementGhostCounter()
985
991
  self[135] = true
986
992
  end
987
993
  end
@@ -990,7 +996,7 @@ __TS__SetDescriptor(
990
996
  )
991
997
  __TS__SetDescriptor(
992
998
  Buff.prototype,
993
- "ignoresStunImmunity",
999
+ "stuns",
994
1000
  {
995
1001
  get = function(self)
996
1002
  local ____self__136_55 = self[136]
@@ -999,16 +1005,18 @@ __TS__SetDescriptor(
999
1005
  end
1000
1006
  return ____self__136_55
1001
1007
  end,
1002
- set = function(self, ignoresStunImmunity)
1003
- if not ignoresStunImmunity and self[136] then
1004
- if self[135] then
1008
+ set = function(self, stuns)
1009
+ if not stuns and self[136] then
1010
+ if self[137] then
1005
1011
  self.object:decrementStunCounter()
1006
1012
  end
1013
+ self.object:decrementStunCounter()
1007
1014
  self[136] = nil
1008
- elseif ignoresStunImmunity and not self[136] then
1009
- if self[135] then
1015
+ elseif stuns and not self[136] then
1016
+ if self[137] then
1010
1017
  self.object:incrementStunCounter()
1011
1018
  end
1019
+ self.object:incrementStunCounter()
1012
1020
  self[136] = true
1013
1021
  end
1014
1022
  end
@@ -1017,7 +1025,7 @@ __TS__SetDescriptor(
1017
1025
  )
1018
1026
  __TS__SetDescriptor(
1019
1027
  Buff.prototype,
1020
- "disablesAutoAttack",
1028
+ "ignoresStunImmunity",
1021
1029
  {
1022
1030
  get = function(self)
1023
1031
  local ____self__137_56 = self[137]
@@ -1026,12 +1034,16 @@ __TS__SetDescriptor(
1026
1034
  end
1027
1035
  return ____self__137_56
1028
1036
  end,
1029
- set = function(self, disablesAutoAttack)
1030
- if not disablesAutoAttack and self[137] then
1031
- self.object:decrementDisableAutoAttackCounter()
1037
+ set = function(self, ignoresStunImmunity)
1038
+ if not ignoresStunImmunity and self[137] then
1039
+ if self[136] then
1040
+ self.object:decrementStunCounter()
1041
+ end
1032
1042
  self[137] = nil
1033
- elseif disablesAutoAttack and not self[137] then
1034
- self.object:incrementDisableAutoAttackCounter()
1043
+ elseif ignoresStunImmunity and not self[137] then
1044
+ if self[136] then
1045
+ self.object:incrementStunCounter()
1046
+ end
1035
1047
  self[137] = true
1036
1048
  end
1037
1049
  end
@@ -1040,7 +1052,7 @@ __TS__SetDescriptor(
1040
1052
  )
1041
1053
  __TS__SetDescriptor(
1042
1054
  Buff.prototype,
1043
- "providesInvulnerability",
1055
+ "disablesAutoAttack",
1044
1056
  {
1045
1057
  get = function(self)
1046
1058
  local ____self__138_57 = self[138]
@@ -1049,12 +1061,12 @@ __TS__SetDescriptor(
1049
1061
  end
1050
1062
  return ____self__138_57
1051
1063
  end,
1052
- set = function(self, providesInvulnerability)
1053
- if not providesInvulnerability and self[138] then
1054
- self.object:decrementInvulnerabilityCounter()
1064
+ set = function(self, disablesAutoAttack)
1065
+ if not disablesAutoAttack and self[138] then
1066
+ self.object:decrementDisableAutoAttackCounter()
1055
1067
  self[138] = nil
1056
- elseif providesInvulnerability and not self[138] then
1057
- self.object:incrementInvulnerabilityCounter()
1068
+ elseif disablesAutoAttack and not self[138] then
1069
+ self.object:incrementDisableAutoAttackCounter()
1058
1070
  self[138] = true
1059
1071
  end
1060
1072
  end
@@ -1063,7 +1075,7 @@ __TS__SetDescriptor(
1063
1075
  )
1064
1076
  __TS__SetDescriptor(
1065
1077
  Buff.prototype,
1066
- "killsOnExpiration",
1078
+ "providesInvulnerability",
1067
1079
  {
1068
1080
  get = function(self)
1069
1081
  local ____self__139_58 = self[139]
@@ -1072,10 +1084,12 @@ __TS__SetDescriptor(
1072
1084
  end
1073
1085
  return ____self__139_58
1074
1086
  end,
1075
- set = function(self, killsOnExpiration)
1076
- if not killsOnExpiration and self[139] then
1087
+ set = function(self, providesInvulnerability)
1088
+ if not providesInvulnerability and self[139] then
1089
+ self.object:decrementInvulnerabilityCounter()
1077
1090
  self[139] = nil
1078
- elseif killsOnExpiration and not self[139] then
1091
+ elseif providesInvulnerability and not self[139] then
1092
+ self.object:incrementInvulnerabilityCounter()
1079
1093
  self[139] = true
1080
1094
  end
1081
1095
  end
@@ -1084,7 +1098,7 @@ __TS__SetDescriptor(
1084
1098
  )
1085
1099
  __TS__SetDescriptor(
1086
1100
  Buff.prototype,
1087
- "explodesOnExpiration",
1101
+ "killsOnExpiration",
1088
1102
  {
1089
1103
  get = function(self)
1090
1104
  local ____self__140_59 = self[140]
@@ -1103,6 +1117,27 @@ __TS__SetDescriptor(
1103
1117
  },
1104
1118
  true
1105
1119
  )
1120
+ __TS__SetDescriptor(
1121
+ Buff.prototype,
1122
+ "explodesOnExpiration",
1123
+ {
1124
+ get = function(self)
1125
+ local ____self__141_60 = self[141]
1126
+ if ____self__141_60 == nil then
1127
+ ____self__141_60 = false
1128
+ end
1129
+ return ____self__141_60
1130
+ end,
1131
+ set = function(self, killsOnExpiration)
1132
+ if not killsOnExpiration and self[141] then
1133
+ self[141] = nil
1134
+ elseif killsOnExpiration and not self[141] then
1135
+ self[141] = true
1136
+ end
1137
+ end
1138
+ },
1139
+ true
1140
+ )
1106
1141
  __TS__SetDescriptor(
1107
1142
  Buff.prototype,
1108
1143
  "maximumDamageDealtEventCount",
@@ -1219,13 +1254,13 @@ __TS__SetDescriptor(
1219
1254
  "remainingDuration",
1220
1255
  {
1221
1256
  get = function(self)
1222
- local ____opt_60 = self._timer
1223
- return ____opt_60 and ____opt_60.remaining or 0
1257
+ local ____opt_61 = self._timer
1258
+ return ____opt_61 and ____opt_61.remaining or 0
1224
1259
  end,
1225
1260
  set = function(self, remainingDuration)
1226
- local ____remainingDuration_64 = remainingDuration
1227
- local ____opt_62 = self._timer
1228
- local remainingDurationDelta = ____remainingDuration_64 - (____opt_62 and ____opt_62.remaining or 0)
1261
+ local ____remainingDuration_65 = remainingDuration
1262
+ local ____opt_63 = self._timer
1263
+ local remainingDurationDelta = ____remainingDuration_65 - (____opt_63 and ____opt_63.remaining or 0)
1229
1264
  if remainingDurationDelta ~= 0 then
1230
1265
  self[103] = self[103] + remainingDurationDelta
1231
1266
  if remainingDuration <= 0 then
@@ -1240,7 +1275,7 @@ __TS__SetDescriptor(
1240
1275
  remainingDuration,
1241
1276
  self._spellStealPriority,
1242
1277
  self._learnLevelMinimum,
1243
- self[141]
1278
+ self[142]
1244
1279
  ) then
1245
1280
  local timer = self._timer
1246
1281
  if timer == nil then
@@ -1255,7 +1290,8 @@ __TS__SetDescriptor(
1255
1290
  },
1256
1291
  true
1257
1292
  )
1258
- Buff.destroyEvent = buffDestroyEvent;
1293
+ Buff.createdEvent = buffCreatedEvent
1294
+ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1259
1295
  (function(self)
1260
1296
  local function destroyBuffIfNeeded(buff)
1261
1297
  if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
@@ -1309,5 +1345,8 @@ Buff.destroyEvent = buffDestroyEvent;
1309
1345
  ____exports.checkBuffs(target)
1310
1346
  end
1311
1347
  )
1348
+ buffCreatedEvent:addListener(function(buff)
1349
+ UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1350
+ end)
1312
1351
  end)(Buff)
1313
1352
  return ____exports
@@ -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;