warscript 0.0.1-dev.d842bb6 → 0.0.1-dev.da5fb2e

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 (153) 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 +10 -12
  8. package/core/types/player.lua +3 -1
  9. package/core/types/playerCamera.d.ts +2 -0
  10. package/core/types/playerCamera.lua +79 -5
  11. package/core/types/sound.d.ts +17 -25
  12. package/core/types/sound.lua +91 -46
  13. package/core/types/timer.d.ts +8 -8
  14. package/core/types/timer.lua +39 -23
  15. package/core/util.lua +6 -1
  16. package/decl/native.d.ts +844 -788
  17. package/engine/behavior.d.ts +5 -0
  18. package/engine/behavior.lua +106 -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 +32 -0
  32. package/engine/behaviour/unit.lua +185 -4
  33. package/engine/buff.d.ts +15 -12
  34. package/engine/buff.lua +133 -117
  35. package/engine/internal/ability.d.ts +7 -1
  36. package/engine/internal/ability.lua +48 -9
  37. package/engine/internal/item/ability.lua +63 -11
  38. package/engine/internal/item+owner.lua +12 -6
  39. package/engine/internal/item.d.ts +5 -2
  40. package/engine/internal/item.lua +85 -10
  41. package/engine/internal/mechanics/ability-duration.lua +1 -1
  42. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  43. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  44. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  45. package/engine/internal/misc/frame-coordinates.lua +21 -0
  46. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  47. package/engine/internal/misc/get-terrain-z.lua +11 -0
  48. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  49. package/engine/internal/misc/player-local-handle.lua +5 -0
  50. package/engine/internal/unit/ability.d.ts +35 -0
  51. package/engine/internal/unit/ability.lua +62 -0
  52. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  53. package/engine/internal/unit/allowed-targets.lua +9 -1
  54. package/engine/internal/unit/order.d.ts +20 -0
  55. package/engine/internal/unit/order.lua +136 -0
  56. package/engine/internal/unit+ability.lua +10 -1
  57. package/engine/internal/unit+damage.d.ts +2 -11
  58. package/engine/internal/unit+damage.lua +10 -14
  59. package/engine/internal/unit+spellSteal.lua +1 -2
  60. package/engine/internal/unit-missile-launch.lua +9 -2
  61. package/engine/internal/unit.d.ts +30 -8
  62. package/engine/internal/unit.lua +253 -107
  63. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  64. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  65. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  66. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  67. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  68. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  69. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  70. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  71. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  72. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  73. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  74. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  75. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  76. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  77. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  78. package/engine/object-data/entry/ability-type/blank-configurable.lua +0 -9
  79. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  80. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  81. package/engine/object-data/entry/ability-type/curse.lua +2 -2
  82. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  83. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  84. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  85. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  86. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  87. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  88. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  89. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  90. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  91. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  92. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  93. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  94. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  95. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  96. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  97. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  98. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  99. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  100. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  101. package/engine/object-data/entry/ability-type/web.lua +52 -0
  102. package/engine/object-data/entry/ability-type.d.ts +19 -17
  103. package/engine/object-data/entry/ability-type.lua +82 -24
  104. package/engine/object-data/entry/buff-type/applicable.lua +9 -4
  105. package/engine/object-data/entry/buff-type.d.ts +6 -12
  106. package/engine/object-data/entry/buff-type.lua +13 -29
  107. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  108. package/engine/object-data/entry/item-type.d.ts +1 -1
  109. package/engine/object-data/entry/item-type.lua +4 -4
  110. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  111. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  112. package/engine/object-data/entry/sound-preset.lua +140 -0
  113. package/engine/object-data/entry/unit-type.d.ts +21 -5
  114. package/engine/object-data/entry/unit-type.lua +214 -93
  115. package/engine/object-data/entry/upgrade.d.ts +1 -1
  116. package/engine/object-data/entry/upgrade.lua +4 -4
  117. package/engine/object-data/entry.d.ts +16 -14
  118. package/engine/object-data/entry.lua +60 -32
  119. package/engine/object-field/ability.d.ts +4 -4
  120. package/engine/object-field/ability.lua +7 -6
  121. package/engine/object-field/unit.d.ts +57 -3
  122. package/engine/object-field/unit.lua +207 -7
  123. package/engine/object-field.d.ts +17 -6
  124. package/engine/object-field.lua +188 -92
  125. package/engine/standard/entries/buff-type.d.ts +3 -0
  126. package/engine/standard/entries/buff-type.lua +3 -0
  127. package/engine/standard/entries/sound-preset.d.ts +10 -0
  128. package/engine/standard/entries/sound-preset.lua +10 -0
  129. package/engine/standard/fields/unit.d.ts +4 -0
  130. package/engine/standard/fields/unit.lua +7 -0
  131. package/engine/text-tag.d.ts +36 -2
  132. package/engine/text-tag.lua +249 -10
  133. package/engine/unit.d.ts +1 -0
  134. package/engine/unit.lua +1 -0
  135. package/objutil/buff.lua +1 -2
  136. package/objutil/unit.lua +8 -0
  137. package/package.json +2 -2
  138. package/patch-lualib.lua +1 -1
  139. package/utility/arrays.d.ts +1 -0
  140. package/utility/arrays.lua +3 -0
  141. package/utility/callback-array.d.ts +13 -0
  142. package/utility/callback-array.lua +46 -0
  143. package/utility/functions.d.ts +8 -0
  144. package/utility/functions.lua +13 -0
  145. package/utility/linked-set.d.ts +1 -0
  146. package/utility/linked-set.lua +3 -0
  147. package/utility/lua-maps.d.ts +4 -0
  148. package/utility/lua-maps.lua +20 -0
  149. package/utility/lua-sets.d.ts +2 -0
  150. package/utility/lua-sets.lua +7 -0
  151. package/utility/reflection.lua +11 -7
  152. package/core/types/order.d.ts +0 -25
  153. package/core/types/order.lua +0 -55
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
@@ -109,6 +106,7 @@ local buffParametersKeys = {
109
106
  durationIncreaseOnAutoAttack = true,
110
107
  maximumDuration = true,
111
108
  maximumRemainingDuration = true,
109
+ turnsIntoGhost = true,
112
110
  stuns = true,
113
111
  ignoresStunImmunity = true,
114
112
  providesStunImmunity = true,
@@ -174,6 +172,7 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
174
172
  end
175
173
  end
176
174
  local buffBooleanParameters = {
175
+ "turnsIntoGhost",
177
176
  "stuns",
178
177
  "ignoresStunImmunity",
179
178
  "disablesAutoAttack",
@@ -302,7 +301,8 @@ buffHealingIntervalTimerCallback = function(buff)
302
301
  source:healTarget(buff[101], healingPerInterval)
303
302
  end
304
303
  end
305
- local buffDestroyEvent = __TS__New(Event)
304
+ local buffCreatedEvent = __TS__New(Event)
305
+ local buffBeingDestroyedEvent = __TS__New(Event)
306
306
  ____exports.Buff = __TS__Class()
307
307
  local Buff = ____exports.Buff
308
308
  Buff.name = "Buff"
@@ -321,7 +321,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
321
321
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
322
322
  polarity = resistanceTypeOrPolarity
323
323
  resistanceType = abilityOrParametersOrResistanceType
324
- if __TS__InstanceOf(parametersOrAbility, Ability) then
324
+ if __TS__InstanceOf(parametersOrAbility, Ability) or parametersOrAbility == nil then
325
325
  ability = parametersOrAbility
326
326
  else
327
327
  ability = nil
@@ -331,7 +331,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
331
331
  typeId = typeIdOrTypeIds
332
332
  polarity = polarityOrTypeIdSelectionPolicy
333
333
  resistanceType = resistanceTypeOrPolarity
334
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
334
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) or abilityOrParametersOrResistanceType == nil then
335
335
  ability = abilityOrParametersOrResistanceType
336
336
  parameters = parametersOrAbility
337
337
  else
@@ -340,7 +340,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
340
340
  end
341
341
  end
342
342
  self.typeId = typeId
343
- if not __TS__InstanceOf(ability, Ability) then
343
+ if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
344
344
  parameters = ability
345
345
  ability = nil
346
346
  end
@@ -371,7 +371,7 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
371
371
  local missProbability = parameters and parameters.missProbability or defaultParameters.missProbability
372
372
  if missProbability ~= nil then
373
373
  missProbability = resolveNumberValue(ability, level, missProbability)
374
- self[141] = missProbability
374
+ self[142] = missProbability
375
375
  end
376
376
  local buffByTypeId = buffByTypeIdByUnit[_unit]
377
377
  if buffByTypeId == nil then
@@ -504,64 +504,52 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
504
504
  end
505
505
  self:onCreate()
506
506
  self[100] = 1
507
- end
508
- function Buff.prototype.getUnitBonus(self, bonusType)
509
- local ____opt_38 = self._bonusIdByBonusType
510
- local bonusId = ____opt_38 and ____opt_38[bonusType]
511
- return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
512
- end
513
- function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
514
- local bonusIdByBonusType = self._bonusIdByBonusType
515
- if bonusIdByBonusType == nil then
516
- bonusIdByBonusType = {}
517
- self._bonusIdByBonusType = bonusIdByBonusType
518
- end
519
- bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
507
+ Event.invoke(buffCreatedEvent, self)
520
508
  end
521
509
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
522
510
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
523
511
  Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
524
512
  else
525
513
  local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
526
- local ____Effect_42 = Effect
527
- local ____Effect_flash_43 = Effect.flash
528
- local ____array_41 = __TS__SparseArrayNew(
514
+ local ____Effect_40 = Effect
515
+ local ____Effect_flash_41 = Effect.flash
516
+ local ____array_39 = __TS__SparseArrayNew(
529
517
  self[105],
530
518
  isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
531
519
  stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
532
520
  )
533
- local ____isWidgetProvided_40
521
+ local ____isWidgetProvided_38
534
522
  if isWidgetProvided then
535
- ____isWidgetProvided_40 = yOrParametersOrDuration
523
+ ____isWidgetProvided_38 = yOrParametersOrDuration
536
524
  else
537
- ____isWidgetProvided_40 = widgetOrXOrParametersOrDuration
525
+ ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
538
526
  end
539
- __TS__SparseArrayPush(____array_41, ____isWidgetProvided_40)
540
- ____Effect_flash_43(
541
- ____Effect_42,
542
- __TS__SparseArraySpread(____array_41)
527
+ __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
528
+ ____Effect_flash_41(
529
+ ____Effect_40,
530
+ __TS__SparseArraySpread(____array_39)
543
531
  )
544
532
  end
545
533
  end
546
534
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
547
535
  local isWidgetProvided = type(widgetOrDuration) == "table"
548
- local ____Effect_46 = Effect
549
- local ____Effect_flash_47 = Effect.flash
550
- local ____array_45 = __TS__SparseArrayNew(
536
+ local ____Effect_44 = Effect
537
+ local ____Effect_flash_45 = Effect.flash
538
+ local ____array_43 = __TS__SparseArrayNew(
551
539
  self[106],
552
540
  isWidgetProvided and widgetOrDuration or self._unit,
553
541
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
554
542
  )
555
- local ____isWidgetProvided_44
543
+ local ____isWidgetProvided_42
556
544
  if isWidgetProvided then
557
- ____isWidgetProvided_44 = duration
545
+ ____isWidgetProvided_42 = duration
558
546
  else
559
- ____isWidgetProvided_44 = widgetOrDuration
547
+ ____isWidgetProvided_42 = widgetOrDuration
560
548
  end
561
- __TS__SparseArrayPush(____array_45, ____isWidgetProvided_44)
562
- ____Effect_flash_47(
563
- ____Effect_46,
564
- __TS__SparseArraySpread(____array_45)
549
+ __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
550
+ ____Effect_flash_45(
551
+ ____Effect_44,
552
+ __TS__SparseArraySpread(____array_43)
565
553
  )
566
554
  end
567
555
  function Buff.prototype.onCreate(self)
@@ -592,26 +580,27 @@ function Buff.prototype.onDestroy(self)
592
580
  behavior:destroy()
593
581
  end
594
582
  end
595
- if self[137] then
583
+ if self[139] then
584
+ unit:decrementInvulnerabilityCounter()
585
+ end
586
+ if self[138] then
596
587
  unit:decrementDisableAutoAttackCounter()
597
588
  end
598
- if self[135] then
599
- if self[136] then
589
+ if self[136] then
590
+ if self[137] then
600
591
  unit:decrementStunCounter()
601
592
  end
602
593
  unit:decrementStunCounter()
603
594
  end
595
+ if self[135] then
596
+ unit:decrementGhostCounter()
597
+ end
604
598
  if self._abilityTypeIds ~= nil then
605
599
  for abilityTypeId in pairs(self._abilityTypeIds) do
606
600
  unit:removeAbility(abilityTypeId)
607
601
  end
608
602
  end
609
- if self._bonusIdByBonusType ~= nil then
610
- for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
611
- removeUnitBonus(unit, bonusType, bonusId)
612
- end
613
- end
614
- Event.invoke(buffDestroyEvent, self)
603
+ Event.invoke(buffBeingDestroyedEvent, self)
615
604
  self[100] = 3
616
605
  return UnitBehavior.prototype.onDestroy(self)
617
606
  end
@@ -640,8 +629,8 @@ function Buff.apply(self, ...)
640
629
  end
641
630
  end
642
631
  function Buff.getByTypeId(self, unit, typeId)
643
- local ____opt_48 = buffByTypeIdByUnit[unit]
644
- local buff = ____opt_48 and ____opt_48[typeId]
632
+ local ____opt_46 = buffByTypeIdByUnit[unit]
633
+ local buff = ____opt_46 and ____opt_46[typeId]
645
634
  if __TS__InstanceOf(buff, self) then
646
635
  return buff
647
636
  end
@@ -655,9 +644,9 @@ function Buff.prototype.onExpiration(self)
655
644
  if self[121] ~= nil then
656
645
  (self[102] or unit):healTarget(unit, self[120] or 0)
657
646
  end
658
- if self[140] then
647
+ if self[141] then
659
648
  unit:explode()
660
- elseif self[139] then
649
+ elseif self[140] then
661
650
  unit:kill()
662
651
  end
663
652
  end
@@ -799,8 +788,8 @@ __TS__SetDescriptor(
799
788
  return
800
789
  end
801
790
  self[112] = damageInterval
802
- local ____opt_50 = self._timer
803
- 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
804
793
  local timer = self[114]
805
794
  if timer == nil then
806
795
  timer = Timer:create()
@@ -879,8 +868,8 @@ __TS__SetDescriptor(
879
868
  return
880
869
  end
881
870
  self[117] = healingInterval
882
- local ____opt_52 = self._timer
883
- 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
884
873
  local timer = self[119]
885
874
  if timer == nil then
886
875
  timer = Timer:create()
@@ -961,30 +950,53 @@ __TS__SetDescriptor(
961
950
  },
962
951
  true
963
952
  )
953
+ __TS__SetDescriptor(
954
+ Buff.prototype,
955
+ "turnsIntoGhost",
956
+ {
957
+ get = function(self)
958
+ local ____self__135_52 = self[135]
959
+ if ____self__135_52 == nil then
960
+ ____self__135_52 = false
961
+ end
962
+ return ____self__135_52
963
+ end,
964
+ set = function(self, turnsIntoGhost)
965
+ if not turnsIntoGhost and self[135] then
966
+ self.object:decrementGhostCounter()
967
+ self[135] = nil
968
+ elseif turnsIntoGhost and not self[135] then
969
+ self.object:incrementGhostCounter()
970
+ self[135] = true
971
+ end
972
+ end
973
+ },
974
+ true
975
+ )
964
976
  __TS__SetDescriptor(
965
977
  Buff.prototype,
966
978
  "stuns",
967
979
  {
968
980
  get = function(self)
969
- local ____self__135_54 = self[135]
970
- if ____self__135_54 == nil then
971
- ____self__135_54 = false
981
+ local ____self__136_53 = self[136]
982
+ if ____self__136_53 == nil then
983
+ ____self__136_53 = false
972
984
  end
973
- return ____self__135_54
985
+ return ____self__136_53
974
986
  end,
975
987
  set = function(self, stuns)
976
- if not stuns and self[135] then
977
- if self[136] then
988
+ if not stuns and self[136] then
989
+ if self[137] then
978
990
  self.object:decrementStunCounter()
979
991
  end
980
992
  self.object:decrementStunCounter()
981
- self[135] = nil
982
- elseif stuns and not self[135] then
983
- if self[136] then
993
+ self[136] = nil
994
+ elseif stuns and not self[136] then
995
+ if self[137] then
984
996
  self.object:incrementStunCounter()
985
997
  end
986
998
  self.object:incrementStunCounter()
987
- self[135] = true
999
+ self[136] = true
988
1000
  end
989
1001
  end
990
1002
  },
@@ -995,23 +1007,23 @@ __TS__SetDescriptor(
995
1007
  "ignoresStunImmunity",
996
1008
  {
997
1009
  get = function(self)
998
- local ____self__136_55 = self[136]
999
- if ____self__136_55 == nil then
1000
- ____self__136_55 = false
1010
+ local ____self__137_54 = self[137]
1011
+ if ____self__137_54 == nil then
1012
+ ____self__137_54 = false
1001
1013
  end
1002
- return ____self__136_55
1014
+ return ____self__137_54
1003
1015
  end,
1004
1016
  set = function(self, ignoresStunImmunity)
1005
- if not ignoresStunImmunity and self[136] then
1006
- if self[135] then
1017
+ if not ignoresStunImmunity and self[137] then
1018
+ if self[136] then
1007
1019
  self.object:decrementStunCounter()
1008
1020
  end
1009
- self[136] = nil
1010
- elseif ignoresStunImmunity and not self[136] then
1011
- if self[135] then
1021
+ self[137] = nil
1022
+ elseif ignoresStunImmunity and not self[137] then
1023
+ if self[136] then
1012
1024
  self.object:incrementStunCounter()
1013
1025
  end
1014
- self[136] = true
1026
+ self[137] = true
1015
1027
  end
1016
1028
  end
1017
1029
  },
@@ -1022,19 +1034,19 @@ __TS__SetDescriptor(
1022
1034
  "disablesAutoAttack",
1023
1035
  {
1024
1036
  get = function(self)
1025
- local ____self__137_56 = self[137]
1026
- if ____self__137_56 == nil then
1027
- ____self__137_56 = false
1037
+ local ____self__138_55 = self[138]
1038
+ if ____self__138_55 == nil then
1039
+ ____self__138_55 = false
1028
1040
  end
1029
- return ____self__137_56
1041
+ return ____self__138_55
1030
1042
  end,
1031
1043
  set = function(self, disablesAutoAttack)
1032
- if not disablesAutoAttack and self[137] then
1044
+ if not disablesAutoAttack and self[138] then
1033
1045
  self.object:decrementDisableAutoAttackCounter()
1034
- self[137] = nil
1035
- elseif disablesAutoAttack and not self[137] then
1046
+ self[138] = nil
1047
+ elseif disablesAutoAttack and not self[138] then
1036
1048
  self.object:incrementDisableAutoAttackCounter()
1037
- self[137] = true
1049
+ self[138] = true
1038
1050
  end
1039
1051
  end
1040
1052
  },
@@ -1045,19 +1057,19 @@ __TS__SetDescriptor(
1045
1057
  "providesInvulnerability",
1046
1058
  {
1047
1059
  get = function(self)
1048
- local ____self__138_57 = self[138]
1049
- if ____self__138_57 == nil then
1050
- ____self__138_57 = false
1060
+ local ____self__139_56 = self[139]
1061
+ if ____self__139_56 == nil then
1062
+ ____self__139_56 = false
1051
1063
  end
1052
- return ____self__138_57
1064
+ return ____self__139_56
1053
1065
  end,
1054
1066
  set = function(self, providesInvulnerability)
1055
- if not providesInvulnerability and self[138] then
1067
+ if not providesInvulnerability and self[139] then
1056
1068
  self.object:decrementInvulnerabilityCounter()
1057
- self[138] = nil
1058
- elseif providesInvulnerability and not self[138] then
1069
+ self[139] = nil
1070
+ elseif providesInvulnerability and not self[139] then
1059
1071
  self.object:incrementInvulnerabilityCounter()
1060
- self[138] = true
1072
+ self[139] = true
1061
1073
  end
1062
1074
  end
1063
1075
  },
@@ -1068,17 +1080,17 @@ __TS__SetDescriptor(
1068
1080
  "killsOnExpiration",
1069
1081
  {
1070
1082
  get = function(self)
1071
- local ____self__139_58 = self[139]
1072
- if ____self__139_58 == nil then
1073
- ____self__139_58 = false
1083
+ local ____self__140_57 = self[140]
1084
+ if ____self__140_57 == nil then
1085
+ ____self__140_57 = false
1074
1086
  end
1075
- return ____self__139_58
1087
+ return ____self__140_57
1076
1088
  end,
1077
1089
  set = function(self, killsOnExpiration)
1078
- if not killsOnExpiration and self[139] then
1079
- self[139] = nil
1080
- elseif killsOnExpiration and not self[139] then
1081
- self[139] = true
1090
+ if not killsOnExpiration and self[140] then
1091
+ self[140] = nil
1092
+ elseif killsOnExpiration and not self[140] then
1093
+ self[140] = true
1082
1094
  end
1083
1095
  end
1084
1096
  },
@@ -1089,17 +1101,17 @@ __TS__SetDescriptor(
1089
1101
  "explodesOnExpiration",
1090
1102
  {
1091
1103
  get = function(self)
1092
- local ____self__140_59 = self[140]
1093
- if ____self__140_59 == nil then
1094
- ____self__140_59 = false
1104
+ local ____self__141_58 = self[141]
1105
+ if ____self__141_58 == nil then
1106
+ ____self__141_58 = false
1095
1107
  end
1096
- return ____self__140_59
1108
+ return ____self__141_58
1097
1109
  end,
1098
1110
  set = function(self, killsOnExpiration)
1099
- if not killsOnExpiration and self[140] then
1100
- self[140] = nil
1101
- elseif killsOnExpiration and not self[140] then
1102
- self[140] = true
1111
+ if not killsOnExpiration and self[141] then
1112
+ self[141] = nil
1113
+ elseif killsOnExpiration and not self[141] then
1114
+ self[141] = true
1103
1115
  end
1104
1116
  end
1105
1117
  },
@@ -1221,13 +1233,13 @@ __TS__SetDescriptor(
1221
1233
  "remainingDuration",
1222
1234
  {
1223
1235
  get = function(self)
1224
- local ____opt_60 = self._timer
1225
- return ____opt_60 and ____opt_60.remaining or 0
1236
+ local ____opt_59 = self._timer
1237
+ return ____opt_59 and ____opt_59.remaining or 0
1226
1238
  end,
1227
1239
  set = function(self, remainingDuration)
1228
- local ____remainingDuration_64 = remainingDuration
1229
- local ____opt_62 = self._timer
1230
- local remainingDurationDelta = ____remainingDuration_64 - (____opt_62 and ____opt_62.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)
1231
1243
  if remainingDurationDelta ~= 0 then
1232
1244
  self[103] = self[103] + remainingDurationDelta
1233
1245
  if remainingDuration <= 0 then
@@ -1242,7 +1254,7 @@ __TS__SetDescriptor(
1242
1254
  remainingDuration,
1243
1255
  self._spellStealPriority,
1244
1256
  self._learnLevelMinimum,
1245
- self[141]
1257
+ self[142]
1246
1258
  ) then
1247
1259
  local timer = self._timer
1248
1260
  if timer == nil then
@@ -1257,7 +1269,8 @@ __TS__SetDescriptor(
1257
1269
  },
1258
1270
  true
1259
1271
  )
1260
- Buff.destroyEvent = buffDestroyEvent;
1272
+ Buff.createdEvent = buffCreatedEvent
1273
+ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1261
1274
  (function(self)
1262
1275
  local function destroyBuffIfNeeded(buff)
1263
1276
  if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
@@ -1311,5 +1324,8 @@ Buff.destroyEvent = buffDestroyEvent;
1311
1324
  ____exports.checkBuffs(target)
1312
1325
  end
1313
1326
  )
1327
+ buffCreatedEvent:addListener(function(buff)
1328
+ UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1329
+ end)
1314
1330
  end)(Buff)
1315
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
  }
@@ -13,6 +13,7 @@ local ____ability = require("engine.internal.item.ability")
13
13
  local abilityActionDummy = ____ability.abilityActionDummy
14
14
  local doAbilityAction = ____ability.doAbilityAction
15
15
  local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
16
+ local doUnitAbilityAction = ____ability.doUnitAbilityAction
16
17
  local startItemCooldown = ____ability.startItemCooldown
17
18
  local getUnitAbilityLevel = GetUnitAbilityLevel
18
19
  local setUnitAbilityLevel = SetUnitAbilityLevel
@@ -38,6 +39,9 @@ local getHandleId = GetHandleId
38
39
  local getItemBooleanField = BlzGetItemBooleanField
39
40
  local setItemBooleanField = BlzSetItemBooleanField
40
41
  local unitHideAbility = BlzUnitHideAbility
42
+ local unitDisableAbility = BlzUnitDisableAbility
43
+ local unitRemoveAbility = UnitRemoveAbility
44
+ local itemRemoveAbility = BlzItemRemoveAbility
41
45
  local match = string.match
42
46
  local ____type = _G.type
43
47
  local ____tostring = _G.tostring
@@ -231,6 +235,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
231
235
  local parentTypeId = availableFields[abilityTypeId]
232
236
  return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
233
237
  end
238
+ ---
239
+ -- @internal For use by internal systems only.
240
+ ____exports.abilityTypeHasField = function(abilityTypeId, field)
241
+ field = ____type(field) == "number" and field or getHandleId(field)
242
+ if commonFields[field] then
243
+ return true
244
+ end
245
+ local id = availableFields[abilityTypeId]
246
+ if ____type(id) == "number" then
247
+ id = availableFields[id]
248
+ end
249
+ return not not (id and id[field])
250
+ end
234
251
  ____exports.Ability = __TS__Class()
235
252
  local Ability = ____exports.Ability
236
253
  Ability.name = "Ability"
@@ -246,15 +263,7 @@ function Ability.prototype.getSnapshot(self)
246
263
  return nil
247
264
  end
248
265
  function Ability.prototype.hasField(self, field)
249
- field = ____type(field) == "number" and field or getHandleId(field)
250
- if commonFields[field] then
251
- return true
252
- end
253
- local id = availableFields[self.typeId]
254
- if ____type(id) == "number" then
255
- id = availableFields[id]
256
- end
257
- return not not (id and id[field])
266
+ return ____exports.abilityTypeHasField(self.typeId, field)
258
267
  end
259
268
  function Ability.prototype.getField(self, field, level)
260
269
  local fieldType = match(
@@ -402,9 +411,35 @@ end
402
411
  function UnitAbility.prototype.decrementHideCounter(self)
403
412
  unitHideAbility(self.u, self.typeId, false)
404
413
  end
414
+ function UnitAbility.prototype.incrementDisableCounter(self)
415
+ local unit = self.u
416
+ local typeId = self.typeId
417
+ unitHideAbility(unit, typeId, true)
418
+ unitDisableAbility(unit, typeId, true, false)
419
+ self.d = (self.d or 0) + 1
420
+ end
421
+ function UnitAbility.prototype.decrementDisableCounter(self)
422
+ local unit = self.u
423
+ local typeId = self.typeId
424
+ unitDisableAbility(unit, typeId, false, false)
425
+ unitHideAbility(unit, typeId, true)
426
+ self.d = (self.d or 0) - 1
427
+ end
405
428
  function UnitAbility.prototype.interruptCast(self)
406
429
  self.owner:interruptCast(self.typeId)
407
430
  end
431
+ function UnitAbility.prototype.onDestroy(self)
432
+ doUnitAbilityAction(self.owner.handle, self.typeId, unitRemoveAbility, self.typeId)
433
+ return UnitAbility.____super.prototype.onDestroy(self)
434
+ end
435
+ __TS__SetDescriptor(
436
+ UnitAbility.prototype,
437
+ "isDisabled",
438
+ {get = function(self)
439
+ return self.d ~= nil and self.d > 0
440
+ end},
441
+ true
442
+ )
408
443
  __TS__SetDescriptor(
409
444
  UnitAbility.prototype,
410
445
  "level",
@@ -489,6 +524,10 @@ function ItemAbility.prototype.interruptCast(self)
489
524
  setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
490
525
  end
491
526
  end
527
+ function ItemAbility.prototype.onDestroy(self)
528
+ doAbilityAction(self.owner.handle, itemRemoveAbility, self.typeId)
529
+ return ItemAbility.____super.prototype.onDestroy(self)
530
+ end
492
531
  __TS__SetDescriptor(
493
532
  ItemAbility.prototype,
494
533
  "level",