warscript 0.0.1-dev.a9a8ba4 → 0.0.1-dev.a9f2494

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 (100) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/frame.lua +24 -21
  4. package/core/types/player.d.ts +16 -0
  5. package/core/types/player.lua +60 -15
  6. package/core/types/playerCamera.d.ts +2 -0
  7. package/core/types/playerCamera.lua +123 -5
  8. package/core/types/tileCell.d.ts +11 -1
  9. package/core/types/tileCell.lua +97 -0
  10. package/core/types/timer.d.ts +3 -1
  11. package/core/types/timer.lua +27 -2
  12. package/decl/native.d.ts +6 -4
  13. package/destroyable.d.ts +1 -0
  14. package/destroyable.lua +9 -0
  15. package/engine/behavior.d.ts +14 -1
  16. package/engine/behavior.lua +230 -70
  17. package/engine/behaviour/ability/apply-buff.lua +4 -4
  18. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  19. package/engine/behaviour/ability/emulate-impact.lua +2 -1
  20. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  21. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  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 +2 -1
  25. package/engine/behaviour/ability.lua +2 -1
  26. package/engine/behaviour/unit/stun-immunity.d.ts +8 -4
  27. package/engine/behaviour/unit/stun-immunity.lua +12 -3
  28. package/engine/behaviour/unit.d.ts +15 -5
  29. package/engine/behaviour/unit.lua +124 -27
  30. package/engine/buff.d.ts +12 -5
  31. package/engine/buff.lua +136 -94
  32. package/engine/internal/ability.d.ts +3 -1
  33. package/engine/internal/ability.lua +34 -11
  34. package/engine/internal/item/ability.lua +2 -1
  35. package/engine/internal/item+owner.lua +12 -6
  36. package/engine/internal/item.d.ts +13 -15
  37. package/engine/internal/item.lua +63 -49
  38. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  39. package/engine/internal/misc/frame-coordinates.lua +21 -0
  40. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  41. package/engine/internal/misc/get-terrain-z.lua +11 -0
  42. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  43. package/engine/internal/misc/player-local-handle.lua +5 -0
  44. package/engine/internal/unit/ability.d.ts +14 -14
  45. package/engine/internal/unit/ability.lua +72 -45
  46. package/engine/internal/unit/fly-height.d.ts +7 -0
  47. package/engine/internal/unit/fly-height.lua +20 -0
  48. package/engine/internal/unit/main-selected.lua +12 -27
  49. package/engine/internal/unit/scale.d.ts +7 -0
  50. package/engine/internal/unit/scale.lua +20 -0
  51. package/engine/internal/unit+ability.lua +10 -1
  52. package/engine/internal/unit-missile-launch.lua +45 -14
  53. package/engine/internal/unit.d.ts +17 -15
  54. package/engine/internal/unit.lua +150 -153
  55. package/engine/local-client.d.ts +2 -0
  56. package/engine/local-client.lua +30 -0
  57. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  58. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  59. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  60. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  61. package/engine/object-data/entry/ability-type.lua +5 -4
  62. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  63. package/engine/object-data/entry/destructible-type.lua +155 -0
  64. package/engine/object-data/entry/unit-type.d.ts +15 -2
  65. package/engine/object-data/entry/unit-type.lua +135 -33
  66. package/engine/object-field/ability.d.ts +3 -3
  67. package/engine/object-field/ability.lua +7 -6
  68. package/engine/object-field/unit.d.ts +27 -5
  69. package/engine/object-field/unit.lua +82 -0
  70. package/engine/object-field.d.ts +9 -3
  71. package/engine/object-field.lua +237 -114
  72. package/engine/random.d.ts +9 -0
  73. package/engine/random.lua +13 -0
  74. package/engine/standard/fields/ability.d.ts +2 -2
  75. package/engine/standard/fields/ability.lua +2 -2
  76. package/engine/standard/fields/unit.d.ts +5 -1
  77. package/engine/standard/fields/unit.lua +8 -0
  78. package/engine/synchronization.d.ts +11 -0
  79. package/engine/synchronization.lua +77 -0
  80. package/engine/text-tag.d.ts +1 -1
  81. package/engine/text-tag.lua +92 -17
  82. package/engine/unit.d.ts +2 -0
  83. package/engine/unit.lua +2 -0
  84. package/net/socket.lua +1 -1
  85. package/objutil/buff.lua +1 -1
  86. package/package.json +2 -2
  87. package/patch-lualib.lua +1 -1
  88. package/utility/arrays.d.ts +1 -0
  89. package/utility/arrays.lua +8 -0
  90. package/utility/callback-array.d.ts +17 -0
  91. package/utility/callback-array.lua +61 -0
  92. package/utility/functions.d.ts +7 -0
  93. package/utility/functions.lua +12 -0
  94. package/utility/linked-set.d.ts +1 -0
  95. package/utility/linked-set.lua +19 -1
  96. package/utility/lua-maps.d.ts +11 -2
  97. package/utility/lua-maps.lua +33 -2
  98. package/utility/lua-sets.d.ts +1 -0
  99. package/utility/lua-sets.lua +4 -0
  100. package/utility/types.d.ts +3 -0
package/engine/buff.lua CHANGED
@@ -16,6 +16,7 @@ local internalApplyBuff = ____applicable.internalApplyBuff
16
16
  local removeBuff = ____applicable.removeBuff
17
17
  local ____ability = require("engine.internal.ability")
18
18
  local Ability = ____ability.Ability
19
+ local UnitAbility = ____ability.UnitAbility
19
20
  local ____ability = require("engine.object-field.ability")
20
21
  local AbilityBooleanField = ____ability.AbilityBooleanField
21
22
  local AbilityNumberField = ____ability.AbilityNumberField
@@ -28,9 +29,6 @@ local ____math = require("math")
28
29
  local max = ____math.max
29
30
  local min = ____math.min
30
31
  local ____bonus = require("engine.internal.unit.bonus")
31
- local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
32
- local getUnitBonus = ____bonus.getUnitBonus
33
- local removeUnitBonus = ____bonus.removeUnitBonus
34
32
  local UnitBonusType = ____bonus.UnitBonusType
35
33
  local ____area_2Ddamage = require("engine.internal.mechanics.area-damage")
36
34
  local damageArea = ____area_2Ddamage.damageArea
@@ -53,6 +51,10 @@ local ____item = require("engine.internal.item")
53
51
  local Item = ____item.Item
54
52
  local ____destructable = require("core.types.destructable")
55
53
  local Destructable = ____destructable.Destructable
54
+ local ____ability = require("engine.standard.fields.ability")
55
+ local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
56
+ local ____ability = require("engine.behaviour.ability")
57
+ local AbilityBehavior = ____ability.AbilityBehavior
56
58
  local getUnitAbility = BlzGetUnitAbility
57
59
  local stringValueByBuffTypeIdByFieldId = postcompile(function()
58
60
  local stringValueByBuffTypeIdByFieldId = {}
@@ -124,7 +126,8 @@ local buffParametersKeys = {
124
126
  damageOnExpiration = true,
125
127
  healingOnExpiration = true,
126
128
  killsOnExpiration = true,
127
- explodesOnExpiration = true
129
+ explodesOnExpiration = true,
130
+ abilityCooldownFactor = true
128
131
  }
129
132
  local function resolveEnumValue(ability, level, value)
130
133
  if value == nil or type(value) == "number" then
@@ -201,7 +204,8 @@ local buffNumberParameters = {
201
204
  "healingPerInterval",
202
205
  "healingOverDuration",
203
206
  "damageOnExpiration",
204
- "healingOnExpiration"
207
+ "healingOnExpiration",
208
+ "abilityCooldownFactor"
205
209
  }
206
210
  local unsuccessfulApplicationMarker = {}
207
211
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -320,33 +324,38 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
320
324
  local polarity
321
325
  local resistanceType
322
326
  local ability
327
+ local abilityBehavior
323
328
  if type(typeIdOrTypeIds) ~= "number" then
324
329
  typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
325
330
  polarity = resistanceTypeOrPolarity
326
331
  resistanceType = abilityOrParametersOrResistanceType
327
- if __TS__InstanceOf(parametersOrAbility, Ability) or parametersOrAbility == nil then
332
+ if __TS__InstanceOf(parametersOrAbility, AbilityBehavior) then
333
+ abilityBehavior = parametersOrAbility
334
+ ability = abilityBehavior.ability
335
+ elseif __TS__InstanceOf(parametersOrAbility, Ability) then
328
336
  ability = parametersOrAbility
329
- else
330
- ability = nil
337
+ elseif parametersOrAbility ~= nil then
331
338
  parameters = parametersOrAbility
332
339
  end
333
340
  else
334
341
  typeId = typeIdOrTypeIds
335
342
  polarity = polarityOrTypeIdSelectionPolicy
336
343
  resistanceType = resistanceTypeOrPolarity
337
- if __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) or abilityOrParametersOrResistanceType == nil then
344
+ if __TS__InstanceOf(abilityOrParametersOrResistanceType, AbilityBehavior) then
345
+ abilityBehavior = abilityOrParametersOrResistanceType
346
+ ability = abilityBehavior.ability
347
+ parameters = parametersOrAbility
348
+ elseif __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
338
349
  ability = abilityOrParametersOrResistanceType
339
350
  parameters = parametersOrAbility
340
- else
341
- ability = nil
351
+ elseif abilityOrParametersOrResistanceType ~= nil then
342
352
  parameters = abilityOrParametersOrResistanceType
353
+ else
354
+ parameters = parametersOrAbility
343
355
  end
344
356
  end
357
+ self.sourceAbilityBehavior = abilityBehavior
345
358
  self.typeId = typeId
346
- if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
347
- parameters = ability
348
- ability = nil
349
- end
350
359
  local defaultParameters = self.constructor.defaultParameters
351
360
  local level = parameters and parameters.level or defaultParameters.level
352
361
  local spellStealPriority = parameters and parameters.spellStealPriority or defaultParameters.spellStealPriority
@@ -509,63 +518,66 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
509
518
  self[100] = 1
510
519
  Event.invoke(buffCreatedEvent, self)
511
520
  end
512
- function Buff.prototype.getUnitBonus(self, bonusType)
513
- local ____opt_38 = self._bonusIdByBonusType
514
- local bonusId = ____opt_38 and ____opt_38[bonusType]
515
- return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
521
+ function Buff.prototype.onAbilityGained(self, ability)
522
+ if __TS__InstanceOf(ability, UnitAbility) then
523
+ local abilityCooldownModifier = self[144]
524
+ if abilityCooldownModifier then
525
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
526
+ end
527
+ end
516
528
  end
517
- function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
518
- local bonusIdByBonusType = self._bonusIdByBonusType
519
- if bonusIdByBonusType == nil then
520
- bonusIdByBonusType = {}
521
- self._bonusIdByBonusType = bonusIdByBonusType
529
+ function Buff.prototype.onAbilityLost(self, ability)
530
+ if __TS__InstanceOf(ability, UnitAbility) then
531
+ local abilityCooldownModifier = self[144]
532
+ if abilityCooldownModifier then
533
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
534
+ end
522
535
  end
523
- bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
524
536
  end
525
537
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
526
538
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
527
539
  Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
528
540
  else
529
541
  local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
530
- local ____Effect_42 = Effect
531
- local ____Effect_flash_43 = Effect.flash
532
- local ____array_41 = __TS__SparseArrayNew(
542
+ local ____Effect_40 = Effect
543
+ local ____Effect_flash_41 = Effect.flash
544
+ local ____array_39 = __TS__SparseArrayNew(
533
545
  self[105],
534
546
  isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
535
547
  stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
536
548
  )
537
- local ____isWidgetProvided_40
549
+ local ____isWidgetProvided_38
538
550
  if isWidgetProvided then
539
- ____isWidgetProvided_40 = yOrParametersOrDuration
551
+ ____isWidgetProvided_38 = yOrParametersOrDuration
540
552
  else
541
- ____isWidgetProvided_40 = widgetOrXOrParametersOrDuration
553
+ ____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
542
554
  end
543
- __TS__SparseArrayPush(____array_41, ____isWidgetProvided_40)
544
- ____Effect_flash_43(
545
- ____Effect_42,
546
- __TS__SparseArraySpread(____array_41)
555
+ __TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
556
+ ____Effect_flash_41(
557
+ ____Effect_40,
558
+ __TS__SparseArraySpread(____array_39)
547
559
  )
548
560
  end
549
561
  end
550
562
  function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
551
563
  local isWidgetProvided = type(widgetOrDuration) == "table"
552
- local ____Effect_46 = Effect
553
- local ____Effect_flash_47 = Effect.flash
554
- local ____array_45 = __TS__SparseArrayNew(
564
+ local ____Effect_44 = Effect
565
+ local ____Effect_flash_45 = Effect.flash
566
+ local ____array_43 = __TS__SparseArrayNew(
555
567
  self[106],
556
568
  isWidgetProvided and widgetOrDuration or self._unit,
557
569
  stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
558
570
  )
559
- local ____isWidgetProvided_44
571
+ local ____isWidgetProvided_42
560
572
  if isWidgetProvided then
561
- ____isWidgetProvided_44 = duration
573
+ ____isWidgetProvided_42 = duration
562
574
  else
563
- ____isWidgetProvided_44 = widgetOrDuration
575
+ ____isWidgetProvided_42 = widgetOrDuration
564
576
  end
565
- __TS__SparseArrayPush(____array_45, ____isWidgetProvided_44)
566
- ____Effect_flash_47(
567
- ____Effect_46,
568
- __TS__SparseArraySpread(____array_45)
577
+ __TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
578
+ ____Effect_flash_45(
579
+ ____Effect_44,
580
+ __TS__SparseArraySpread(____array_43)
569
581
  )
570
582
  end
571
583
  function Buff.prototype.onCreate(self)
@@ -596,6 +608,12 @@ function Buff.prototype.onDestroy(self)
596
608
  behavior:destroy()
597
609
  end
598
610
  end
611
+ local previousAbilityCooldownModifier = self[144]
612
+ if previousAbilityCooldownModifier then
613
+ for ____, ability in ipairs(self._unit.abilities) do
614
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
615
+ end
616
+ end
599
617
  if self[139] then
600
618
  unit:decrementInvulnerabilityCounter()
601
619
  end
@@ -604,7 +622,7 @@ function Buff.prototype.onDestroy(self)
604
622
  end
605
623
  if self[136] then
606
624
  if self[137] then
607
- unit:decrementStunCounter()
625
+ unit:decrementForceStunCounter()
608
626
  end
609
627
  unit:decrementStunCounter()
610
628
  end
@@ -616,11 +634,6 @@ function Buff.prototype.onDestroy(self)
616
634
  unit:removeAbility(abilityTypeId)
617
635
  end
618
636
  end
619
- if self._bonusIdByBonusType ~= nil then
620
- for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
621
- removeUnitBonus(unit, bonusType, bonusId)
622
- end
623
- end
624
637
  Event.invoke(buffBeingDestroyedEvent, self)
625
638
  self[100] = 3
626
639
  return UnitBehavior.prototype.onDestroy(self)
@@ -650,8 +663,8 @@ function Buff.apply(self, ...)
650
663
  end
651
664
  end
652
665
  function Buff.getByTypeId(self, unit, typeId)
653
- local ____opt_48 = buffByTypeIdByUnit[unit]
654
- local buff = ____opt_48 and ____opt_48[typeId]
666
+ local ____opt_46 = buffByTypeIdByUnit[unit]
667
+ local buff = ____opt_46 and ____opt_46[typeId]
655
668
  if __TS__InstanceOf(buff, self) then
656
669
  return buff
657
670
  end
@@ -809,8 +822,8 @@ __TS__SetDescriptor(
809
822
  return
810
823
  end
811
824
  self[112] = damageInterval
812
- local ____opt_50 = self._timer
813
- local elapsed = ____opt_50 and ____opt_50.elapsed or 0
825
+ local ____opt_48 = self._timer
826
+ local elapsed = ____opt_48 and ____opt_48.elapsed or 0
814
827
  local timer = self[114]
815
828
  if timer == nil then
816
829
  timer = Timer:create()
@@ -889,8 +902,8 @@ __TS__SetDescriptor(
889
902
  return
890
903
  end
891
904
  self[117] = healingInterval
892
- local ____opt_52 = self._timer
893
- local elapsed = ____opt_52 and ____opt_52.elapsed or 0
905
+ local ____opt_50 = self._timer
906
+ local elapsed = ____opt_50 and ____opt_50.elapsed or 0
894
907
  local timer = self[119]
895
908
  if timer == nil then
896
909
  timer = Timer:create()
@@ -976,11 +989,11 @@ __TS__SetDescriptor(
976
989
  "turnsIntoGhost",
977
990
  {
978
991
  get = function(self)
979
- local ____self__135_54 = self[135]
980
- if ____self__135_54 == nil then
981
- ____self__135_54 = false
992
+ local ____self__135_52 = self[135]
993
+ if ____self__135_52 == nil then
994
+ ____self__135_52 = false
982
995
  end
983
- return ____self__135_54
996
+ return ____self__135_52
984
997
  end,
985
998
  set = function(self, turnsIntoGhost)
986
999
  if not turnsIntoGhost and self[135] then
@@ -999,22 +1012,22 @@ __TS__SetDescriptor(
999
1012
  "stuns",
1000
1013
  {
1001
1014
  get = function(self)
1002
- local ____self__136_55 = self[136]
1003
- if ____self__136_55 == nil then
1004
- ____self__136_55 = false
1015
+ local ____self__136_53 = self[136]
1016
+ if ____self__136_53 == nil then
1017
+ ____self__136_53 = false
1005
1018
  end
1006
- return ____self__136_55
1019
+ return ____self__136_53
1007
1020
  end,
1008
1021
  set = function(self, stuns)
1009
1022
  if not stuns and self[136] then
1010
1023
  if self[137] then
1011
- self.object:decrementStunCounter()
1024
+ self.object:decrementForceStunCounter()
1012
1025
  end
1013
1026
  self.object:decrementStunCounter()
1014
1027
  self[136] = nil
1015
1028
  elseif stuns and not self[136] then
1016
1029
  if self[137] then
1017
- self.object:incrementStunCounter()
1030
+ self.object:incrementForceStunCounter()
1018
1031
  end
1019
1032
  self.object:incrementStunCounter()
1020
1033
  self[136] = true
@@ -1028,21 +1041,21 @@ __TS__SetDescriptor(
1028
1041
  "ignoresStunImmunity",
1029
1042
  {
1030
1043
  get = function(self)
1031
- local ____self__137_56 = self[137]
1032
- if ____self__137_56 == nil then
1033
- ____self__137_56 = false
1044
+ local ____self__137_54 = self[137]
1045
+ if ____self__137_54 == nil then
1046
+ ____self__137_54 = false
1034
1047
  end
1035
- return ____self__137_56
1048
+ return ____self__137_54
1036
1049
  end,
1037
1050
  set = function(self, ignoresStunImmunity)
1038
1051
  if not ignoresStunImmunity and self[137] then
1039
1052
  if self[136] then
1040
- self.object:decrementStunCounter()
1053
+ self.object:decrementForceStunCounter()
1041
1054
  end
1042
1055
  self[137] = nil
1043
1056
  elseif ignoresStunImmunity and not self[137] then
1044
1057
  if self[136] then
1045
- self.object:incrementStunCounter()
1058
+ self.object:incrementForceStunCounter()
1046
1059
  end
1047
1060
  self[137] = true
1048
1061
  end
@@ -1055,11 +1068,11 @@ __TS__SetDescriptor(
1055
1068
  "disablesAutoAttack",
1056
1069
  {
1057
1070
  get = function(self)
1058
- local ____self__138_57 = self[138]
1059
- if ____self__138_57 == nil then
1060
- ____self__138_57 = false
1071
+ local ____self__138_55 = self[138]
1072
+ if ____self__138_55 == nil then
1073
+ ____self__138_55 = false
1061
1074
  end
1062
- return ____self__138_57
1075
+ return ____self__138_55
1063
1076
  end,
1064
1077
  set = function(self, disablesAutoAttack)
1065
1078
  if not disablesAutoAttack and self[138] then
@@ -1078,11 +1091,11 @@ __TS__SetDescriptor(
1078
1091
  "providesInvulnerability",
1079
1092
  {
1080
1093
  get = function(self)
1081
- local ____self__139_58 = self[139]
1082
- if ____self__139_58 == nil then
1083
- ____self__139_58 = false
1094
+ local ____self__139_56 = self[139]
1095
+ if ____self__139_56 == nil then
1096
+ ____self__139_56 = false
1084
1097
  end
1085
- return ____self__139_58
1098
+ return ____self__139_56
1086
1099
  end,
1087
1100
  set = function(self, providesInvulnerability)
1088
1101
  if not providesInvulnerability and self[139] then
@@ -1101,11 +1114,11 @@ __TS__SetDescriptor(
1101
1114
  "killsOnExpiration",
1102
1115
  {
1103
1116
  get = function(self)
1104
- local ____self__140_59 = self[140]
1105
- if ____self__140_59 == nil then
1106
- ____self__140_59 = false
1117
+ local ____self__140_57 = self[140]
1118
+ if ____self__140_57 == nil then
1119
+ ____self__140_57 = false
1107
1120
  end
1108
- return ____self__140_59
1121
+ return ____self__140_57
1109
1122
  end,
1110
1123
  set = function(self, killsOnExpiration)
1111
1124
  if not killsOnExpiration and self[140] then
@@ -1122,11 +1135,11 @@ __TS__SetDescriptor(
1122
1135
  "explodesOnExpiration",
1123
1136
  {
1124
1137
  get = function(self)
1125
- local ____self__141_60 = self[141]
1126
- if ____self__141_60 == nil then
1127
- ____self__141_60 = false
1138
+ local ____self__141_58 = self[141]
1139
+ if ____self__141_58 == nil then
1140
+ ____self__141_58 = false
1128
1141
  end
1129
- return ____self__141_60
1142
+ return ____self__141_58
1130
1143
  end,
1131
1144
  set = function(self, killsOnExpiration)
1132
1145
  if not killsOnExpiration and self[141] then
@@ -1254,13 +1267,13 @@ __TS__SetDescriptor(
1254
1267
  "remainingDuration",
1255
1268
  {
1256
1269
  get = function(self)
1257
- local ____opt_61 = self._timer
1258
- return ____opt_61 and ____opt_61.remaining or 0
1270
+ local ____opt_59 = self._timer
1271
+ return ____opt_59 and ____opt_59.remaining or 0
1259
1272
  end,
1260
1273
  set = function(self, remainingDuration)
1261
- local ____remainingDuration_65 = remainingDuration
1262
- local ____opt_63 = self._timer
1263
- local remainingDurationDelta = ____remainingDuration_65 - (____opt_63 and ____opt_63.remaining or 0)
1274
+ local ____remainingDuration_63 = remainingDuration
1275
+ local ____opt_61 = self._timer
1276
+ local remainingDurationDelta = ____remainingDuration_63 - (____opt_61 and ____opt_61.remaining or 0)
1264
1277
  if remainingDurationDelta ~= 0 then
1265
1278
  self[103] = self[103] + remainingDurationDelta
1266
1279
  if remainingDuration <= 0 then
@@ -1290,6 +1303,32 @@ __TS__SetDescriptor(
1290
1303
  },
1291
1304
  true
1292
1305
  )
1306
+ __TS__SetDescriptor(
1307
+ Buff.prototype,
1308
+ "abilityCooldownFactor",
1309
+ {
1310
+ get = function(self)
1311
+ return self[143] or 1
1312
+ end,
1313
+ set = function(self, abilityCooldownFactor)
1314
+ local previousAbilityCooldownModifier = self[144]
1315
+ if previousAbilityCooldownModifier then
1316
+ for ____, ability in ipairs(self._unit.abilities) do
1317
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
1318
+ end
1319
+ end
1320
+ local function modifier(ability, level, cooldown)
1321
+ return cooldown * abilityCooldownFactor
1322
+ end
1323
+ for ____, ability in ipairs(self._unit.abilities) do
1324
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
1325
+ end
1326
+ self[144] = modifier
1327
+ self[143] = abilityCooldownFactor
1328
+ end
1329
+ },
1330
+ true
1331
+ )
1293
1332
  Buff.createdEvent = buffCreatedEvent
1294
1333
  Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1295
1334
  (function(self)
@@ -1348,5 +1387,8 @@ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1348
1387
  buffCreatedEvent:addListener(function(buff)
1349
1388
  UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
1350
1389
  end)
1390
+ buffBeingDestroyedEvent:addListener(function(buff)
1391
+ UnitBehavior:forAll(buff.unit, "onBuffLost", buff)
1392
+ end)
1351
1393
  end)(Buff)
1352
1394
  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";
@@ -67,6 +67,7 @@ export declare class UnitAbility extends Ability {
67
67
  get cooldownRemaining(): number;
68
68
  set cooldownRemaining(cooldownRemaining: number);
69
69
  interruptCast(): void;
70
+ protected onDestroy(): HandleDestructor;
70
71
  static get onCreate(): Event<[UnitAbility]>;
71
72
  static get onDestroy(): Event<[UnitAbility]>;
72
73
  }
@@ -93,6 +94,7 @@ export declare class ItemAbility extends Ability {
93
94
  get cooldownRemaining(): number;
94
95
  set cooldownRemaining(cooldownRemaining: number);
95
96
  interruptCast(): void;
97
+ protected onDestroy(): HandleDestructor;
96
98
  static get onCreate(): Event<[ItemAbility]>;
97
99
  static get onDestroy(): Event<[ItemAbility]>;
98
100
  }
@@ -232,6 +232,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
232
232
  local parentTypeId = availableFields[abilityTypeId]
233
233
  return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
234
234
  end
235
+ ---
236
+ -- @internal For use by internal systems only.
237
+ ____exports.abilityTypeHasField = function(abilityTypeId, field)
238
+ field = ____type(field) == "number" and field or getHandleId(field)
239
+ if commonFields[field] then
240
+ return true
241
+ end
242
+ local id = availableFields[abilityTypeId]
243
+ if ____type(id) == "number" then
244
+ id = availableFields[id]
245
+ end
246
+ return not not (id and id[field])
247
+ end
235
248
  ____exports.Ability = __TS__Class()
236
249
  local Ability = ____exports.Ability
237
250
  Ability.name = "Ability"
@@ -247,15 +260,7 @@ function Ability.prototype.getSnapshot(self)
247
260
  return nil
248
261
  end
249
262
  function Ability.prototype.hasField(self, field)
250
- field = ____type(field) == "number" and field or getHandleId(field)
251
- if commonFields[field] then
252
- return true
253
- end
254
- local id = availableFields[self.typeId]
255
- if ____type(id) == "number" then
256
- id = availableFields[id]
257
- end
258
- return not not (id and id[field])
263
+ return ____exports.abilityTypeHasField(self.typeId, field)
259
264
  end
260
265
  function Ability.prototype.getField(self, field, level)
261
266
  local fieldType = match(
@@ -404,16 +409,28 @@ function UnitAbility.prototype.decrementHideCounter(self)
404
409
  unitHideAbility(self.u, self.typeId, false)
405
410
  end
406
411
  function UnitAbility.prototype.incrementDisableCounter(self)
407
- unitDisableAbility(self.u, self.typeId, true, false)
412
+ local unit = self.u
413
+ local typeId = self.typeId
414
+ unitHideAbility(unit, typeId, true)
415
+ unitDisableAbility(unit, typeId, true, false)
408
416
  self.d = (self.d or 0) + 1
409
417
  end
410
418
  function UnitAbility.prototype.decrementDisableCounter(self)
411
- unitDisableAbility(self.u, self.typeId, false, false)
419
+ local unit = self.u
420
+ local typeId = self.typeId
421
+ unitDisableAbility(unit, typeId, false, false)
422
+ unitHideAbility(unit, typeId, true)
412
423
  self.d = (self.d or 0) - 1
413
424
  end
414
425
  function UnitAbility.prototype.interruptCast(self)
415
426
  self.owner:interruptCast(self.typeId)
416
427
  end
428
+ function UnitAbility.prototype.onDestroy(self)
429
+ if self.owner.state ~= 2 then
430
+ self.owner:removeAbility(self.typeId)
431
+ end
432
+ return UnitAbility.____super.prototype.onDestroy(self)
433
+ end
417
434
  __TS__SetDescriptor(
418
435
  UnitAbility.prototype,
419
436
  "isDisabled",
@@ -506,6 +523,12 @@ function ItemAbility.prototype.interruptCast(self)
506
523
  setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
507
524
  end
508
525
  end
526
+ function ItemAbility.prototype.onDestroy(self)
527
+ if self.owner.state ~= 2 then
528
+ self.owner:removeAbility(self.typeId)
529
+ end
530
+ return ItemAbility.____super.prototype.onDestroy(self)
531
+ end
509
532
  __TS__SetDescriptor(
510
533
  ItemAbility.prototype,
511
534
  "level",
@@ -175,9 +175,10 @@ ____exports.doUnitAbilityAction = function(unit, abilityTypeId, action, ...)
175
175
  if not isAlreadyIgnoredInEvents then
176
176
  ignoreEventsItems[item] = nil
177
177
  end
178
+ itemBySlot[offset + slot] = item
178
179
  end
179
180
  end
180
- local result = action(...)
181
+ local result = action(unit, ...)
181
182
  for slot = 0, unitInventorySize(unit) - 1 do
182
183
  local item = itemBySlot[offset + slot]
183
184
  if item ~= nil then
@@ -6,12 +6,18 @@ local Item = ____item.Item
6
6
  local ____unit = require("engine.internal.unit")
7
7
  local Unit = ____unit.Unit
8
8
  local ownerByItem = setmetatable({}, {__mode = "kv"})
9
- Unit.itemPickedUpEvent:addListener(function(unit, item)
10
- ownerByItem[item] = unit
11
- end)
12
- Unit.itemDroppedEvent:addListener(function(unit, item)
13
- ownerByItem[item] = nil
14
- end)
9
+ Unit.itemPickedUpEvent:addListener(
10
+ 4,
11
+ function(unit, item)
12
+ ownerByItem[item] = unit
13
+ end
14
+ )
15
+ Unit.itemDroppedEvent:addListener(
16
+ 4,
17
+ function(unit, item)
18
+ ownerByItem[item] = nil
19
+ end
20
+ )
15
21
  __TS__ObjectDefineProperty(
16
22
  Item.prototype,
17
23
  "owner",
@@ -8,12 +8,10 @@ import { AbilityTypeId } from "../object-data/entry/ability-type";
8
8
  import type { ItemTypeId } from "../object-data/entry/item-type";
9
9
  type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
10
10
  declare const enum ItemPropertyKey {
11
- ABILITIES = 100,
12
- LUA_INDEX_BY_ABILITY_TYPE_ID = 101
11
+ ABILITIES = 100
13
12
  }
14
13
  export declare class Item extends Handle<jitem> {
15
14
  private readonly [ItemPropertyKey.ABILITIES];
16
- private readonly [ItemPropertyKey.LUA_INDEX_BY_ABILITY_TYPE_ID];
17
15
  constructor(handle: jitem);
18
16
  protected onDestroy(): HandleDestructor;
19
17
  static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
@@ -30,22 +28,22 @@ export declare class Item extends Handle<jitem> {
30
28
  get extendedTooltip(): string;
31
29
  set iconPath(v: string);
32
30
  get iconPath(): string;
33
- set dropOnDeath(v: boolean);
34
- get dropOnDeath(): boolean;
35
- set droppable(v: boolean);
36
- get droppable(): boolean;
37
- set pawnable(v: boolean);
38
- get pawnable(): boolean;
39
- set perishable(v: boolean);
40
- get perishable(): boolean;
41
- set powerup(v: boolean);
42
- get powerup(): boolean;
31
+ set dropsOnDeath(dropsOnDeath: boolean);
32
+ get dropsOnDeath(): boolean;
33
+ set canBeDropped(canBeDropped: boolean);
34
+ get canBeDropped(): boolean;
35
+ set canBeSold(canBeSold: boolean);
36
+ get canBeSold(): boolean;
37
+ set perishes(perishes: boolean);
38
+ get perishes(): boolean;
39
+ set isPowerUp(isPowerUp: boolean);
40
+ get isPowerUp(): boolean;
43
41
  get isAlive(): boolean;
44
42
  get isDead(): boolean;
45
43
  set isInvulnerable(isInvulnerable: boolean);
46
44
  get isInvulnerable(): boolean;
47
- set usable(v: boolean);
48
- get usable(): boolean;
45
+ set isActivelyUsed(isActivelyUsed: boolean);
46
+ get isActivelyUsed(): boolean;
49
47
  set visible(v: boolean);
50
48
  get visible(): boolean;
51
49
  set level(v: number);