warscript 0.0.1-dev.ea69747 → 0.0.1-dev.ebee5b2

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 (124) hide show
  1. package/attributes.d.ts +12 -0
  2. package/attributes.lua +16 -0
  3. package/binaryreader.d.ts +1 -0
  4. package/binaryreader.lua +3 -0
  5. package/core/types/frame.d.ts +4 -1
  6. package/core/types/frame.lua +22 -1
  7. package/core/types/group.d.ts +0 -1
  8. package/core/types/handle.d.ts +2 -1
  9. package/core/types/handle.lua +5 -0
  10. package/core/types/image.d.ts +0 -1
  11. package/core/types/missile.d.ts +2 -2
  12. package/core/types/missile.lua +8 -2
  13. package/core/types/unit.lua +8 -0
  14. package/decl/index.d.ts +1 -0
  15. package/engine/ability.d.ts +1 -1
  16. package/engine/behavior.d.ts +10 -10
  17. package/engine/behaviour/ability/apply-buff.d.ts +3 -5
  18. package/engine/behaviour/ability/apply-unit-behavior.d.ts +13 -4
  19. package/engine/behaviour/ability/apply-unit-behavior.lua +31 -9
  20. package/engine/behaviour/ability/damage.d.ts +33 -11
  21. package/engine/behaviour/ability/damage.lua +89 -31
  22. package/engine/behaviour/ability/heal.d.ts +33 -6
  23. package/engine/behaviour/ability/heal.lua +89 -10
  24. package/engine/behaviour/ability/instant-impact.lua +4 -0
  25. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  26. package/engine/behaviour/ability/restore-mana.lua +29 -0
  27. package/engine/behaviour/ability.d.ts +8 -1
  28. package/engine/behaviour/ability.lua +62 -0
  29. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  30. package/engine/behaviour/unit.d.ts +8 -2
  31. package/engine/behaviour/unit.lua +27 -0
  32. package/engine/buff.d.ts +62 -20
  33. package/engine/buff.lua +247 -72
  34. package/engine/game-map.d.ts +7 -0
  35. package/engine/game-map.lua +32 -0
  36. package/engine/internal/ability.d.ts +1 -1
  37. package/engine/internal/item+owner.lua +2 -2
  38. package/engine/internal/mechanics/ability-duration.d.ts +1 -3
  39. package/engine/internal/mechanics/ability-duration.lua +2 -0
  40. package/engine/internal/mechanics/cast-ability.d.ts +2 -0
  41. package/engine/internal/mechanics/cast-ability.lua +86 -0
  42. package/engine/internal/unit/bonus.d.ts +9 -8
  43. package/engine/internal/unit/bonus.lua +6 -1
  44. package/engine/internal/unit/detach-missiles.d.ts +7 -0
  45. package/engine/internal/unit/detach-missiles.lua +30 -0
  46. package/engine/internal/unit+ability.lua +2 -2
  47. package/engine/internal/unit+transport.lua +4 -10
  48. package/engine/internal/unit-missile-launch.lua +1 -1
  49. package/engine/internal/unit.d.ts +59 -13
  50. package/engine/internal/unit.lua +306 -93
  51. package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
  52. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  53. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  54. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  55. package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
  56. package/engine/object-data/entry/ability-type/blink.lua +39 -0
  57. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  58. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  59. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  60. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  61. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  62. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  63. package/engine/object-data/entry/ability-type.d.ts +1 -1
  64. package/engine/object-data/entry/ability-type.lua +1 -0
  65. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  66. package/engine/object-data/entry/buff-type/applicable.lua +27 -71
  67. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  68. package/engine/object-data/entry/buff-type.d.ts +0 -1
  69. package/engine/object-data/entry/destructible-type.d.ts +0 -1
  70. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  71. package/engine/object-data/entry/item-type.d.ts +0 -1
  72. package/engine/object-data/entry/lightning-type.d.ts +0 -1
  73. package/engine/object-data/entry/unit-type.d.ts +42 -2
  74. package/engine/object-data/entry/unit-type.lua +378 -50
  75. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  76. package/engine/object-data/entry/upgrade.d.ts +0 -1
  77. package/engine/object-data/entry.d.ts +2 -3
  78. package/engine/object-field/ability.d.ts +25 -6
  79. package/engine/object-field/ability.lua +56 -0
  80. package/engine/object-field/unit.d.ts +1 -0
  81. package/engine/object-field/unit.lua +3 -0
  82. package/engine/object-field.d.ts +6 -4
  83. package/engine/object-field.lua +38 -12
  84. package/engine/random.d.ts +1 -0
  85. package/engine/random.lua +9 -0
  86. package/engine/standard/entries/unit-type.d.ts +42 -1
  87. package/engine/standard/entries/unit-type.lua +42 -1
  88. package/engine/standard/fields/ability.d.ts +1 -1
  89. package/engine/standard/fields/ability.lua +1 -1
  90. package/engine/unit.d.ts +1 -0
  91. package/engine/unit.lua +10 -2
  92. package/event.d.ts +2 -3
  93. package/event.lua +9 -5
  94. package/exception.d.ts +2 -0
  95. package/exception.lua +4 -0
  96. package/global/vec2.lua +1 -0
  97. package/lualib_bundle.lua +146 -42
  98. package/math/vec2.d.ts +2 -9
  99. package/math.d.ts +0 -2
  100. package/net/socket.d.ts +7 -1
  101. package/net/socket.lua +45 -4
  102. package/network.d.ts +1 -0
  103. package/network.lua +3 -2
  104. package/objutil/ability.d.ts +0 -1
  105. package/objutil/buff.d.ts +0 -1
  106. package/objutil/buff.lua +1 -1
  107. package/objutil/object.d.ts +0 -1
  108. package/objutil/unit.d.ts +0 -1
  109. package/package.json +13 -14
  110. package/property.d.ts +55 -0
  111. package/property.lua +374 -0
  112. package/string.d.ts +30 -0
  113. package/string.lua +14 -0
  114. package/util/stream.d.ts +0 -1
  115. package/utility/arrays.d.ts +4 -5
  116. package/utility/arrays.lua +4 -1
  117. package/utility/bit-set.d.ts +0 -2
  118. package/utility/linked-set.d.ts +31 -9
  119. package/utility/linked-set.lua +21 -2
  120. package/utility/lua-maps.d.ts +1 -2
  121. package/utility/lua-sets.d.ts +1 -2
  122. package/utility/types.d.ts +3 -2
  123. package/core/mapbounds.d.ts +0 -8
  124. package/core/mapbounds.lua +0 -12
package/engine/buff.lua CHANGED
@@ -94,6 +94,7 @@ local buffParametersKeys = {
94
94
  armorIncreaseFactor = true,
95
95
  attackSpeedIncreaseFactor = true,
96
96
  movementSpeedIncreaseFactor = true,
97
+ damageFactor = true,
97
98
  receivedDamageFactor = true,
98
99
  receivedMagicDamageFactor = true,
99
100
  durationIncreaseOnAutoAttack = true,
@@ -107,8 +108,26 @@ local buffParametersKeys = {
107
108
  disablesAutoAttack = true,
108
109
  destroysOnDamage = true,
109
110
  maximumAutoAttackCount = true,
110
- uniqueGroup = true
111
+ maximumDamageDealtEventCount = true,
112
+ maximumDamageReceivedEventCount = true,
113
+ uniqueGroup = true,
114
+ damageOnExpiration = true,
115
+ healingOnExpiration = true,
116
+ killsOnExpiration = true,
117
+ explodesOnExpiration = true
111
118
  }
119
+ local function resolveEnumValue(ability, level, value)
120
+ if value == nil or type(value) == "number" then
121
+ return value
122
+ end
123
+ if ability == nil then
124
+ error(
125
+ __TS__New(IllegalArgumentException),
126
+ 0
127
+ )
128
+ end
129
+ return value:getValue(ability, level or ability.level)
130
+ end
112
131
  local function resolveNumberValue(ability, level, value)
113
132
  if value == nil or type(value) == "number" then
114
133
  return value
@@ -145,20 +164,32 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
145
164
  buff[property] = resolvedValue
146
165
  end
147
166
  end
148
- local buffBooleanParameters = {"stuns", "ignoresStunImmunity", "disablesAutoAttack", "providesInvulnerability"}
167
+ local buffBooleanParameters = {
168
+ "stuns",
169
+ "ignoresStunImmunity",
170
+ "disablesAutoAttack",
171
+ "providesInvulnerability",
172
+ "killsOnExpiration",
173
+ "explodesOnExpiration"
174
+ }
149
175
  local buffNumberParameters = {
150
176
  "durationIncreaseOnAutoAttack",
151
177
  "attackSpeedIncreaseFactor",
152
178
  "movementSpeedIncreaseFactor",
153
179
  "armorIncrease",
180
+ "damageFactor",
154
181
  "receivedDamageFactor",
155
182
  "maximumAutoAttackCount",
183
+ "maximumDamageDealtEventCount",
184
+ "maximumDamageReceivedEventCount",
156
185
  "damageInterval",
157
186
  "damagePerInterval",
158
187
  "damageOverDuration",
159
188
  "healingInterval",
160
189
  "healingPerInterval",
161
- "healingOverDuration"
190
+ "healingOverDuration",
191
+ "damageOnExpiration",
192
+ "healingOnExpiration"
162
193
  }
163
194
  local unsuccessfulApplicationMarker = {}
164
195
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -207,6 +238,7 @@ local function expireBuff(buff)
207
238
  end
208
239
  end
209
240
  Timer:run(destroyBuff, buff)
241
+ buff:onExpiration()
210
242
  end
211
243
  local function buffDamageIntervalInitialTimerCallback(buff)
212
244
  buffDamageIntervalTimerCallback(buff)
@@ -296,8 +328,6 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
296
328
  end
297
329
  end
298
330
  self.typeId = typeId
299
- self.polarity = polarity
300
- self.resistanceType = resistanceType
301
331
  if not __TS__InstanceOf(ability, Ability) then
302
332
  parameters = ability
303
333
  ability = nil
@@ -324,6 +354,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
324
354
  learnLevelMinimum = learnLevelMinimum or ability:getField(ABILITY_IF_REQUIRED_LEVEL)
325
355
  duration = duration or getAbilityDuration(ability, _unit)
326
356
  end
357
+ self.polarity = resolveEnumValue(ability, level, polarity)
358
+ self.resistanceType = resolveEnumValue(ability, level, resistanceType)
327
359
  local buffByTypeId = buffByTypeIdByUnit[_unit]
328
360
  if buffByTypeId == nil then
329
361
  buffByTypeId = {}
@@ -340,8 +372,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
340
372
  if not internalApplyBuff(
341
373
  _unit,
342
374
  typeId,
343
- polarity,
344
- resistanceType,
375
+ self.polarity,
376
+ self.resistanceType,
345
377
  level,
346
378
  duration,
347
379
  spellStealPriority,
@@ -530,11 +562,11 @@ function Buff.prototype.onDestroy(self)
530
562
  behavior:destroy()
531
563
  end
532
564
  end
533
- if self[130] then
565
+ if self[136] then
534
566
  unit:decrementDisableAutoAttackCounter()
535
567
  end
536
- if self[128] then
537
- if self[129] then
568
+ if self[134] then
569
+ if self[135] then
538
570
  unit:decrementStunCounter()
539
571
  end
540
572
  unit:decrementStunCounter()
@@ -583,20 +615,34 @@ function Buff.getByTypeId(self, unit, typeId)
583
615
  end
584
616
  return nil
585
617
  end
586
- function Buff.prototype.onDeath(self, source)
618
+ function Buff.prototype.onExpiration(self)
587
619
  local unit = self.unit
588
620
  if self[119] ~= nil then
621
+ (self[101] or unit):damageTarget(unit, self[119] or 0)
622
+ end
623
+ if self[120] ~= nil then
624
+ (self[101] or unit):healTarget(unit, self[119] or 0)
625
+ end
626
+ if self[139] then
627
+ unit:explode()
628
+ elseif self[138] then
629
+ unit:kill()
630
+ end
631
+ end
632
+ function Buff.prototype.onDeath(self, source)
633
+ local unit = self.unit
634
+ if self[121] ~= nil then
589
635
  damageArea(
590
636
  self[101] or unit,
591
- self[119],
637
+ self[121],
592
638
  unit.x,
593
639
  unit.y,
594
- self[121] or 0,
595
- self[120] or 0,
596
640
  self[123] or 0,
597
641
  self[122] or 0,
598
642
  self[125] or 0,
599
- self[124] or 0
643
+ self[124] or 0,
644
+ self[127] or 0,
645
+ self[126] or 0
600
646
  )
601
647
  end
602
648
  end
@@ -618,9 +664,25 @@ function Buff.prototype.onDamageDealt(self, target, event)
618
664
  end
619
665
  self.remainingDuration = remainingDuration
620
666
  end
621
- local autoAttackCount = (self[126] or 0) + 1
622
- self[126] = autoAttackCount
623
- if autoAttackCount == self[127] then
667
+ local autoAttackCount = (self[128] or 0) + 1
668
+ self[128] = autoAttackCount
669
+ if autoAttackCount == self[129] then
670
+ self:destroy()
671
+ end
672
+ end
673
+ if event.originalAmount ~= 0 then
674
+ local damageDealtEventCount = (self[130] or 0) + 1
675
+ self[130] = damageDealtEventCount
676
+ if damageDealtEventCount == self[131] then
677
+ self:destroy()
678
+ end
679
+ end
680
+ end
681
+ function Buff.prototype.onDamageReceived(self, source, event)
682
+ if event.originalAmount ~= 0 then
683
+ local damageReceivedEventCount = (self[132] or 0) + 1
684
+ self[132] = damageReceivedEventCount
685
+ if damageReceivedEventCount == self[133] then
624
686
  self:destroy()
625
687
  end
626
688
  end
@@ -802,6 +864,45 @@ __TS__SetDescriptor(
802
864
  },
803
865
  true
804
866
  )
867
+ __TS__SetDescriptor(
868
+ Buff.prototype,
869
+ "damageOnExpiration",
870
+ {
871
+ get = function(self)
872
+ return self[119] or 0
873
+ end,
874
+ set = function(self, damageOnExpiration)
875
+ self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
876
+ end
877
+ },
878
+ true
879
+ )
880
+ __TS__SetDescriptor(
881
+ Buff.prototype,
882
+ "healingOnExpiration",
883
+ {
884
+ get = function(self)
885
+ return self[120] or 0
886
+ end,
887
+ set = function(self, healingOnExpiration)
888
+ self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
889
+ end
890
+ },
891
+ true
892
+ )
893
+ __TS__SetDescriptor(
894
+ Buff.prototype,
895
+ "damageFactor",
896
+ {
897
+ get = function(self)
898
+ return self:getUnitBonus(UnitBonusType.DAMAGE_FACTOR)
899
+ end,
900
+ set = function(self, damageFactor)
901
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.DAMAGE_FACTOR, damageFactor)
902
+ end
903
+ },
904
+ true
905
+ )
805
906
  __TS__SetDescriptor(
806
907
  Buff.prototype,
807
908
  "receivedDamageFactor",
@@ -833,25 +934,25 @@ __TS__SetDescriptor(
833
934
  "stuns",
834
935
  {
835
936
  get = function(self)
836
- local ____self__128_52 = self[128]
837
- if ____self__128_52 == nil then
838
- ____self__128_52 = false
937
+ local ____self__134_52 = self[134]
938
+ if ____self__134_52 == nil then
939
+ ____self__134_52 = false
839
940
  end
840
- return ____self__128_52
941
+ return ____self__134_52
841
942
  end,
842
943
  set = function(self, stuns)
843
- if not stuns and self[128] then
844
- if self[129] then
944
+ if not stuns and self[134] then
945
+ if self[135] then
845
946
  self.object:decrementStunCounter()
846
947
  end
847
948
  self.object:decrementStunCounter()
848
- self[128] = nil
849
- elseif stuns and not self[128] then
850
- if self[129] then
949
+ self[134] = nil
950
+ elseif stuns and not self[134] then
951
+ if self[135] then
851
952
  self.object:incrementStunCounter()
852
953
  end
853
954
  self.object:incrementStunCounter()
854
- self[128] = true
955
+ self[134] = true
855
956
  end
856
957
  end
857
958
  },
@@ -862,23 +963,23 @@ __TS__SetDescriptor(
862
963
  "ignoresStunImmunity",
863
964
  {
864
965
  get = function(self)
865
- local ____self__129_53 = self[129]
866
- if ____self__129_53 == nil then
867
- ____self__129_53 = false
966
+ local ____self__135_53 = self[135]
967
+ if ____self__135_53 == nil then
968
+ ____self__135_53 = false
868
969
  end
869
- return ____self__129_53
970
+ return ____self__135_53
870
971
  end,
871
972
  set = function(self, ignoresStunImmunity)
872
- if not ignoresStunImmunity and self[129] then
873
- if self[128] then
973
+ if not ignoresStunImmunity and self[135] then
974
+ if self[134] then
874
975
  self.object:decrementStunCounter()
875
976
  end
876
- self[129] = nil
877
- elseif ignoresStunImmunity and not self[129] then
878
- if self[128] then
977
+ self[135] = nil
978
+ elseif ignoresStunImmunity and not self[135] then
979
+ if self[134] then
879
980
  self.object:incrementStunCounter()
880
981
  end
881
- self[129] = true
982
+ self[135] = true
882
983
  end
883
984
  end
884
985
  },
@@ -889,19 +990,19 @@ __TS__SetDescriptor(
889
990
  "disablesAutoAttack",
890
991
  {
891
992
  get = function(self)
892
- local ____self__130_54 = self[130]
893
- if ____self__130_54 == nil then
894
- ____self__130_54 = false
993
+ local ____self__136_54 = self[136]
994
+ if ____self__136_54 == nil then
995
+ ____self__136_54 = false
895
996
  end
896
- return ____self__130_54
997
+ return ____self__136_54
897
998
  end,
898
999
  set = function(self, disablesAutoAttack)
899
- if not disablesAutoAttack and self[130] then
1000
+ if not disablesAutoAttack and self[136] then
900
1001
  self.object:decrementDisableAutoAttackCounter()
901
- self[130] = nil
902
- elseif disablesAutoAttack and not self[130] then
1002
+ self[136] = nil
1003
+ elseif disablesAutoAttack and not self[136] then
903
1004
  self.object:incrementDisableAutoAttackCounter()
904
- self[130] = true
1005
+ self[136] = true
905
1006
  end
906
1007
  end
907
1008
  },
@@ -912,19 +1013,95 @@ __TS__SetDescriptor(
912
1013
  "providesInvulnerability",
913
1014
  {
914
1015
  get = function(self)
915
- local ____self__131_55 = self[131]
916
- if ____self__131_55 == nil then
917
- ____self__131_55 = false
1016
+ local ____self__137_55 = self[137]
1017
+ if ____self__137_55 == nil then
1018
+ ____self__137_55 = false
918
1019
  end
919
- return ____self__131_55
1020
+ return ____self__137_55
920
1021
  end,
921
1022
  set = function(self, providesInvulnerability)
922
- if not providesInvulnerability and self[131] then
1023
+ if not providesInvulnerability and self[137] then
923
1024
  self.object:decrementInvulnerabilityCounter()
924
- self[131] = nil
925
- elseif providesInvulnerability and not self[131] then
1025
+ self[137] = nil
1026
+ elseif providesInvulnerability and not self[137] then
926
1027
  self.object:incrementInvulnerabilityCounter()
927
- self[131] = true
1028
+ self[137] = true
1029
+ end
1030
+ end
1031
+ },
1032
+ true
1033
+ )
1034
+ __TS__SetDescriptor(
1035
+ Buff.prototype,
1036
+ "killsOnExpiration",
1037
+ {
1038
+ get = function(self)
1039
+ local ____self__138_56 = self[138]
1040
+ if ____self__138_56 == nil then
1041
+ ____self__138_56 = false
1042
+ end
1043
+ return ____self__138_56
1044
+ end,
1045
+ set = function(self, killsOnExpiration)
1046
+ if not killsOnExpiration and self[138] then
1047
+ self[138] = nil
1048
+ elseif killsOnExpiration and not self[138] then
1049
+ self[138] = true
1050
+ end
1051
+ end
1052
+ },
1053
+ true
1054
+ )
1055
+ __TS__SetDescriptor(
1056
+ Buff.prototype,
1057
+ "explodesOnExpiration",
1058
+ {
1059
+ get = function(self)
1060
+ local ____self__139_57 = self[139]
1061
+ if ____self__139_57 == nil then
1062
+ ____self__139_57 = false
1063
+ end
1064
+ return ____self__139_57
1065
+ end,
1066
+ set = function(self, killsOnExpiration)
1067
+ if not killsOnExpiration and self[139] then
1068
+ self[139] = nil
1069
+ elseif killsOnExpiration and not self[139] then
1070
+ self[139] = true
1071
+ end
1072
+ end
1073
+ },
1074
+ true
1075
+ )
1076
+ __TS__SetDescriptor(
1077
+ Buff.prototype,
1078
+ "maximumDamageDealtEventCount",
1079
+ {
1080
+ get = function(self)
1081
+ return self[131] or 0
1082
+ end,
1083
+ set = function(self, maximumDamageDealtEventCount)
1084
+ if maximumDamageDealtEventCount == 0 then
1085
+ self[131] = nil
1086
+ else
1087
+ self[131] = maximumDamageDealtEventCount
1088
+ end
1089
+ end
1090
+ },
1091
+ true
1092
+ )
1093
+ __TS__SetDescriptor(
1094
+ Buff.prototype,
1095
+ "maximumDamageReceivedEventCount",
1096
+ {
1097
+ get = function(self)
1098
+ return self[133] or 0
1099
+ end,
1100
+ set = function(self, maximumDamageReceivedEventCount)
1101
+ if maximumDamageReceivedEventCount == 0 then
1102
+ self[133] = nil
1103
+ else
1104
+ self[133] = maximumDamageReceivedEventCount
928
1105
  end
929
1106
  end
930
1107
  },
@@ -935,13 +1112,13 @@ __TS__SetDescriptor(
935
1112
  "maximumAutoAttackCount",
936
1113
  {
937
1114
  get = function(self)
938
- return self[127] or 0
1115
+ return self[129] or 0
939
1116
  end,
940
1117
  set = function(self, maximumAutoAttackCount)
941
1118
  if maximumAutoAttackCount == 0 then
942
- self[127] = nil
1119
+ self[129] = nil
943
1120
  else
944
- self[127] = maximumAutoAttackCount
1121
+ self[129] = maximumAutoAttackCount
945
1122
  end
946
1123
  end
947
1124
  },
@@ -999,13 +1176,13 @@ __TS__SetDescriptor(
999
1176
  "remainingDuration",
1000
1177
  {
1001
1178
  get = function(self)
1002
- local ____opt_56 = self._timer
1003
- return ____opt_56 and ____opt_56.remaining or 0
1179
+ local ____opt_58 = self._timer
1180
+ return ____opt_58 and ____opt_58.remaining or 0
1004
1181
  end,
1005
1182
  set = function(self, remainingDuration)
1006
- local ____remainingDuration_60 = remainingDuration
1007
- local ____opt_58 = self._timer
1008
- local remainingDurationDelta = ____remainingDuration_60 - (____opt_58 and ____opt_58.remaining or 0)
1183
+ local ____remainingDuration_62 = remainingDuration
1184
+ local ____opt_60 = self._timer
1185
+ local remainingDurationDelta = ____remainingDuration_62 - (____opt_60 and ____opt_60.remaining or 0)
1009
1186
  if remainingDurationDelta ~= 0 then
1010
1187
  self[102] = self[102] + remainingDurationDelta
1011
1188
  if remainingDuration <= 0 then
@@ -1035,24 +1212,22 @@ __TS__SetDescriptor(
1035
1212
  true
1036
1213
  );
1037
1214
  (function(self)
1215
+ local function destroyBuffIfNeeded(buff)
1216
+ if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1217
+ buff:destroy()
1218
+ end
1219
+ end
1038
1220
  ____exports.checkBuff = function(unit, buffTypeId)
1039
1221
  local buffByTypeId = buffByTypeIdByUnit[unit]
1040
1222
  if buffByTypeId ~= nil then
1041
1223
  local buff = buffByTypeId[buffTypeId]
1042
- if buff ~= nil and getUnitAbility(unit.handle, buffTypeId) ~= buff.handle then
1043
- buff:destroy()
1224
+ if buff ~= nil then
1225
+ destroyBuffIfNeeded(buff)
1044
1226
  end
1045
1227
  end
1046
1228
  end
1047
1229
  ____exports.checkBuffs = function(unit)
1048
- local buffByTypeId = buffByTypeIdByUnit[unit]
1049
- if buffByTypeId ~= nil then
1050
- for ____, buff in pairs(buffByTypeId) do
1051
- if getUnitAbility(unit.handle, buff.typeId) ~= buff.handle then
1052
- buff:destroy()
1053
- end
1054
- end
1055
- end
1230
+ ____exports.Buff:forAll(unit, destroyBuffIfNeeded)
1056
1231
  end
1057
1232
  Unit.abilityChannelingStartEvent:addListener(
1058
1233
  0,
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ import { Rect } from "../core/types/rect";
3
+ import { Region } from "../core/types/region";
4
+ export declare class GameMap {
5
+ static get worldBoundsRect(): Rect;
6
+ static get worldBoundsRegion(): Region;
7
+ }
@@ -0,0 +1,32 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
4
+ local ____exports = {}
5
+ local ____rect = require("core.types.rect")
6
+ local Rect = ____rect.Rect
7
+ local ____region = require("core.types.region")
8
+ local Region = ____region.Region
9
+ ____exports.GameMap = __TS__Class()
10
+ local GameMap = ____exports.GameMap
11
+ GameMap.name = "GameMap"
12
+ function GameMap.prototype.____constructor(self)
13
+ end
14
+ __TS__ObjectDefineProperty(
15
+ GameMap,
16
+ "worldBoundsRect",
17
+ {get = function(self)
18
+ local rect = Rect:of(GetWorldBounds())
19
+ rawset(self, "worldBoundsRect", rect)
20
+ return rect
21
+ end}
22
+ )
23
+ __TS__ObjectDefineProperty(
24
+ GameMap,
25
+ "worldBoundsRegion",
26
+ {get = function(self)
27
+ local region = Region:create(self.worldBoundsRect)
28
+ rawset(self, "worldBoundsRegion", region)
29
+ return region
30
+ end}
31
+ )
32
+ return ____exports
@@ -12,7 +12,7 @@ interface Fields<K, V> {
12
12
  interface AbilityLevel {
13
13
  realFields: Fields<jabilityreallevelfield, number>;
14
14
  }
15
- type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
15
+ export type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
16
16
  export declare class AbilitySnapshot {
17
17
  }
18
18
  export declare abstract class Ability extends Handle<jability> {
@@ -6,10 +6,10 @@ 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.onItemPickup:addListener(function(unit, item)
9
+ Unit.itemPickedUpEvent:addListener(function(unit, item)
10
10
  ownerByItem[item] = unit
11
11
  end)
12
- Unit.onItemDrop:addListener(function(unit, item)
12
+ Unit.itemDroppedEvent:addListener(function(unit, item)
13
13
  ownerByItem[item] = nil
14
14
  end)
15
15
  __TS__ObjectDefineProperty(
@@ -1,4 +1,2 @@
1
1
  /** @noSelfInFile */
2
- import { Ability } from "../ability";
3
- import { Unit } from "../unit";
4
- export declare const getAbilityDuration: (ability: Ability, target?: Unit) => number;
2
+ export {};
@@ -4,6 +4,8 @@ local UnitClassification = ____unit.UnitClassification
4
4
  local ____ability = require("engine.standard.fields.ability")
5
5
  local DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD
6
6
  local DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD
7
+ ---
8
+ -- @internal For use by internal systems only.
7
9
  ____exports.getAbilityDuration = function(ability, target)
8
10
  local level = ability.level
9
11
  return target ~= nil and target:hasClassification(UnitClassification.RESISTANT) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,86 @@
1
+ local ____exports = {}
2
+ local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
3
+ local AbilityType = ____ability_2Dtype.AbilityType
4
+ local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
5
+ local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
6
+ local ____dummy_2Dunits = require("engine.internal.misc.dummy-units")
7
+ local INVENTORY_DUMMY_NATIVE_UNIT = ____dummy_2Dunits.INVENTORY_DUMMY_NATIVE_UNIT
8
+ local ____preconditions = require("utility.preconditions")
9
+ local checkNotNull = ____preconditions.checkNotNull
10
+ local ____dummy_2Dinventory = require("engine.internal.object-data.dummy-inventory")
11
+ local INVENTORY_ABILITY_TYPE_ID = ____dummy_2Dinventory.INVENTORY_ABILITY_TYPE_ID
12
+ local ____arrays = require("utility.arrays")
13
+ local map = ____arrays.map
14
+ local toLuaSet = ____arrays.toLuaSet
15
+ local createItem = CreateItem
16
+ local getAbilityId = BlzGetAbilityId
17
+ local getItemAbility = BlzGetItemAbility
18
+ local getUnitAbilityByIndex = BlzGetUnitAbilityByIndex
19
+ local itemAddAbility = BlzItemAddAbility
20
+ local setItemBooleanField = BlzSetItemBooleanField
21
+ local removeItem = RemoveItem
22
+ local unitAddAbility = UnitAddAbility
23
+ local unitAddItem = UnitAddItem
24
+ local unitDropItemSlot = UnitDropItemSlot
25
+ local unitInventorySize = UnitInventorySize
26
+ local unitRemoveAbility = UnitRemoveAbility
27
+ local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
28
+ local INVENTORY_ABILITY_TYPE_IDS = postcompile(function()
29
+ return toLuaSet(AbilityType:getAllIdsByBaseIds(map({
30
+ "AInv",
31
+ "Aihn",
32
+ "Aien",
33
+ "Aion",
34
+ "Aiun"
35
+ }, fourCC)))
36
+ end)
37
+ ---
38
+ -- @internal For use by internal systems only.
39
+ ____exports.castAbility = function(nativeUnit, abilityTypeId, prepareAbility, ...)
40
+ local nativeItem = createItem(DUMMY_ITEM_ID, 0, 0)
41
+ unitAddItem(INVENTORY_DUMMY_NATIVE_UNIT, nativeItem)
42
+ itemAddAbility(nativeItem, abilityTypeId)
43
+ local nativeAbility = checkNotNull(getItemAbility(nativeItem, abilityTypeId))
44
+ if prepareAbility ~= nil then
45
+ prepareAbility(nativeAbility, ...)
46
+ end
47
+ setItemBooleanField(nativeItem, ITEM_BF_ACTIVELY_USED, true)
48
+ setItemBooleanField(nativeItem, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
49
+ local success
50
+ if unitAddItem(nativeUnit, nativeItem) then
51
+ success = true
52
+ else
53
+ local latestInventoryAbilityTypeId = 0
54
+ local nativeItemBySlot = {}
55
+ local inventorySize = unitInventorySize(nativeUnit)
56
+ if inventorySize ~= 0 then
57
+ for slot = 0, inventorySize - 1 do
58
+ nativeItemBySlot[slot] = unitRemoveItemFromSlot(nativeUnit, slot)
59
+ end
60
+ local unitNativeAbility = getUnitAbilityByIndex(nativeUnit, 0)
61
+ local i = 1
62
+ while unitNativeAbility ~= nil do
63
+ local abilityTypeId = getAbilityId(unitNativeAbility)
64
+ if INVENTORY_ABILITY_TYPE_IDS[abilityTypeId] ~= nil then
65
+ latestInventoryAbilityTypeId = abilityTypeId
66
+ end
67
+ unitNativeAbility = getUnitAbilityByIndex(nativeUnit, i)
68
+ i = i + 1
69
+ end
70
+ unitRemoveAbility(nativeUnit, latestInventoryAbilityTypeId)
71
+ end
72
+ unitAddAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
73
+ success = unitAddItem(nativeUnit, nativeItem)
74
+ unitRemoveAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
75
+ if latestInventoryAbilityTypeId ~= 0 then
76
+ unitAddAbility(nativeUnit, latestInventoryAbilityTypeId)
77
+ for slot, nativeItem in pairs(nativeItemBySlot) do
78
+ unitAddItem(nativeUnit, nativeItem)
79
+ unitDropItemSlot(nativeUnit, nativeItem, slot)
80
+ end
81
+ end
82
+ end
83
+ removeItem(nativeItem)
84
+ return success
85
+ end
86
+ return ____exports