warscript 0.0.1-dev.475a555 → 0.0.1-dev.47e7849

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 (106) 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 +5 -5
  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 +9 -17
  26. package/engine/behaviour/unit/stun-immunity.d.ts +11 -5
  27. package/engine/behaviour/unit/stun-immunity.lua +53 -28
  28. package/engine/behaviour/unit.d.ts +26 -5
  29. package/engine/behaviour/unit.lua +170 -27
  30. package/engine/buff.d.ts +17 -6
  31. package/engine/buff.lua +160 -97
  32. package/engine/internal/ability.d.ts +3 -1
  33. package/engine/internal/ability.lua +34 -11
  34. package/engine/internal/item/ability.lua +51 -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/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  45. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  46. package/engine/internal/unit/ability.d.ts +35 -5
  47. package/engine/internal/unit/ability.lua +96 -21
  48. package/engine/internal/unit/bonus.d.ts +2 -0
  49. package/engine/internal/unit/bonus.lua +10 -0
  50. package/engine/internal/unit/fly-height.d.ts +7 -0
  51. package/engine/internal/unit/fly-height.lua +20 -0
  52. package/engine/internal/unit/main-selected.lua +12 -27
  53. package/engine/internal/unit/scale.d.ts +7 -0
  54. package/engine/internal/unit/scale.lua +20 -0
  55. package/engine/internal/unit+ability.lua +10 -1
  56. package/engine/internal/unit-missile-launch.lua +45 -14
  57. package/engine/internal/unit.d.ts +18 -16
  58. package/engine/internal/unit.lua +155 -136
  59. package/engine/local-client.d.ts +2 -0
  60. package/engine/local-client.lua +30 -0
  61. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  62. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  63. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  64. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  65. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  66. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  67. package/engine/object-data/entry/ability-type.lua +5 -4
  68. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  69. package/engine/object-data/entry/destructible-type.lua +155 -0
  70. package/engine/object-data/entry/unit-type.d.ts +15 -2
  71. package/engine/object-data/entry/unit-type.lua +135 -33
  72. package/engine/object-field/ability.d.ts +3 -3
  73. package/engine/object-field/ability.lua +7 -6
  74. package/engine/object-field/unit.d.ts +31 -5
  75. package/engine/object-field/unit.lua +95 -0
  76. package/engine/object-field.d.ts +9 -3
  77. package/engine/object-field.lua +237 -114
  78. package/engine/random.d.ts +9 -0
  79. package/engine/random.lua +13 -0
  80. package/engine/standard/fields/ability.d.ts +2 -2
  81. package/engine/standard/fields/ability.lua +2 -2
  82. package/engine/standard/fields/unit.d.ts +7 -0
  83. package/engine/standard/fields/unit.lua +13 -0
  84. package/engine/synchronization.d.ts +11 -0
  85. package/engine/synchronization.lua +77 -0
  86. package/engine/text-tag.d.ts +26 -3
  87. package/engine/text-tag.lua +217 -11
  88. package/engine/unit.d.ts +2 -0
  89. package/engine/unit.lua +2 -0
  90. package/net/socket.lua +1 -1
  91. package/objutil/buff.lua +1 -1
  92. package/package.json +2 -2
  93. package/patch-lualib.lua +1 -1
  94. package/utility/arrays.d.ts +1 -0
  95. package/utility/arrays.lua +8 -0
  96. package/utility/callback-array.d.ts +17 -0
  97. package/utility/callback-array.lua +61 -0
  98. package/utility/functions.d.ts +7 -0
  99. package/utility/functions.lua +12 -0
  100. package/utility/linked-set.d.ts +1 -0
  101. package/utility/linked-set.lua +19 -1
  102. package/utility/lua-maps.d.ts +11 -2
  103. package/utility/lua-maps.lua +33 -2
  104. package/utility/lua-sets.d.ts +1 -0
  105. package/utility/lua-sets.lua +4 -0
  106. package/utility/types.d.ts +3 -0
@@ -60,6 +60,10 @@ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage
60
60
  local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
61
61
  local ____attributes = require("attributes")
62
62
  local isAttribute = ____attributes.isAttribute
63
+ local ____ability = require("engine.internal.item.ability")
64
+ local doUnitAbilityAction = ____ability.doUnitAbilityAction
65
+ local ____synchronization = require("engine.synchronization")
66
+ local synchronizer = ____synchronization.synchronizer
63
67
  local match = string.match
64
68
  local ____tostring = _G.tostring
65
69
  local setUnitAnimation = SetUnitAnimation
@@ -123,10 +127,6 @@ local getOrderedUnit = GetOrderedUnit
123
127
  local getIssuedOrderId = GetIssuedOrderId
124
128
  local isUnitInvulnerable = BlzIsUnitInvulnerable
125
129
  local unitAlive = UnitAlive
126
- local unitAddType = UnitAddType
127
- local unitRemoveType = UnitRemoveType
128
- local isUnitIllusion = IsUnitIllusion
129
- local isUnitType = IsUnitType
130
130
  local isUnitAlly = IsUnitAlly
131
131
  local isUnitEnemy = IsUnitEnemy
132
132
  local getOwningPlayer = GetOwningPlayer
@@ -412,6 +412,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
412
412
  self.unit = unit
413
413
  self.index = index
414
414
  end
415
+ __TS__SetDescriptor(
416
+ UnitWeapon.prototype,
417
+ "isEnabled",
418
+ {
419
+ get = function(self)
420
+ return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
421
+ end,
422
+ set = function(self, isEnabled)
423
+ BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
424
+ end
425
+ },
426
+ true
427
+ )
415
428
  __TS__SetDescriptor(
416
429
  UnitWeapon.prototype,
417
430
  "cooldown",
@@ -646,15 +659,15 @@ for ____, player in ipairs(Player.all) do
646
659
  dummies[player] = dummy
647
660
  end
648
661
  local function delayHealthChecksCallback(unit)
649
- local counter = (unit[103] or 0) - 1
662
+ local counter = (unit[104] or 0) - 1
650
663
  if counter ~= 0 then
651
- unit[103] = counter
664
+ unit[104] = counter
652
665
  return
653
666
  end
654
- unit[103] = nil
655
- local healthBonus = unit[104]
667
+ unit[104] = nil
668
+ local healthBonus = unit[105]
656
669
  if healthBonus ~= nil then
657
- unit[104] = nil
670
+ unit[105] = nil
658
671
  local handle = unit.handle
659
672
  BlzSetUnitMaxHP(
660
673
  handle,
@@ -665,15 +678,24 @@ end
665
678
  local nextSyncId = 1
666
679
  local unitBySyncId = setmetatable({}, {__mode = "v"})
667
680
  local damagingEventByTarget = setmetatable({}, {__mode = "k"})
681
+ local function addAbility(unit, abilityTypeId)
682
+ local ____unitAddAbility_result_0
683
+ if unitAddAbility(unit, abilityTypeId) then
684
+ ____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
685
+ else
686
+ ____unitAddAbility_result_0 = nil
687
+ end
688
+ return ____unitAddAbility_result_0
689
+ end
668
690
  ____exports.Unit = __TS__Class()
669
691
  local Unit = ____exports.Unit
670
692
  Unit.name = "Unit"
671
693
  __TS__ClassExtends(Unit, Handle)
672
694
  function Unit.prototype.____constructor(self, handle)
673
695
  Handle.prototype.____constructor(self, handle)
674
- local ____nextSyncId_0 = nextSyncId
675
- nextSyncId = ____nextSyncId_0 + 1
676
- self.syncId = ____nextSyncId_0
696
+ local ____nextSyncId_1 = nextSyncId
697
+ nextSyncId = ____nextSyncId_1 + 1
698
+ self.syncId = ____nextSyncId_1
677
699
  self._owner = Player:of(getOwningPlayer(handle))
678
700
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
679
701
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -705,8 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
705
727
  end
706
728
  function Unit.prototype.onDestroy(self)
707
729
  local handle = self.handle
708
- self[107] = getUnitX(handle)
709
- self[108] = getUnitY(handle)
730
+ self[108] = getUnitX(handle)
731
+ self[109] = getUnitY(handle)
710
732
  if not self._owner then
711
733
  self._owner = Player:of(getOwningPlayer(handle))
712
734
  end
@@ -774,17 +796,17 @@ function Unit.prototype.addModifier(self, property, modifier)
774
796
  end}
775
797
  end
776
798
  function Unit.prototype.hasCombatClassification(self, combatClassification)
777
- local ____combatClassification_1 = combatClassification
778
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
799
+ local ____combatClassification_2 = combatClassification
800
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
779
801
  end
780
802
  function Unit.prototype.addClassification(self, classification)
781
- return unitAddType(self.handle, classification)
803
+ return UnitAddType(self.handle, classification)
782
804
  end
783
805
  function Unit.prototype.removeClassification(self, classification)
784
- return unitRemoveType(self.handle, classification)
806
+ return UnitRemoveType(self.handle, classification)
785
807
  end
786
808
  function Unit.prototype.hasClassification(self, classification)
787
- return isUnitType(self.handle, classification)
809
+ return IsUnitType(self.handle, classification)
788
810
  end
789
811
  function Unit.prototype.isVisibleTo(self, player)
790
812
  return isUnitVisible(self.handle, player.handle)
@@ -793,13 +815,13 @@ function Unit.prototype.isInvisibleTo(self, player)
793
815
  return isUnitInvisible(self.handle, player.handle)
794
816
  end
795
817
  function Unit.prototype.isInRangeOf(self, x, y, range)
796
- local ____temp_2
818
+ local ____temp_3
797
819
  if type(x) == "number" then
798
- ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
820
+ ____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
799
821
  else
800
- ____temp_2 = isUnitInRange(self.handle, x.handle, y)
822
+ ____temp_3 = isUnitInRange(self.handle, x.handle, y)
801
823
  end
802
- return ____temp_2
824
+ return ____temp_3
803
825
  end
804
826
  function Unit.prototype.isAllyOf(self, unit)
805
827
  return isUnitAlly(
@@ -829,16 +851,18 @@ function Unit.prototype.queueAnimation(self, animation)
829
851
  QueueUnitAnimation(self.handle, animation)
830
852
  end
831
853
  function Unit.prototype.chooseWeapon(self, target)
832
- if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
833
- return self.firstWeapon
854
+ local firstWeapon = self.firstWeapon
855
+ if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
856
+ return firstWeapon
834
857
  end
835
- if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
836
- return self.secondWeapon
858
+ local secondWeapon = self.secondWeapon
859
+ if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
860
+ return secondWeapon
837
861
  end
838
862
  return nil
839
863
  end
840
864
  function Unit.prototype.delayHealthChecks(self)
841
- self[103] = (self[103] or 0) + 1
865
+ self[104] = (self[104] or 0) + 1
842
866
  Timer:run(delayHealthChecksCallback, self)
843
867
  end
844
868
  function Unit.prototype.setPosition(self, x, y)
@@ -855,14 +879,14 @@ function Unit.prototype.kill(self)
855
879
  killUnit(self.handle)
856
880
  end
857
881
  function Unit.prototype.revive(self, x, y, doEffect)
858
- local ____ReviveHero_5 = ReviveHero
859
- local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
860
- local ____doEffect_3 = doEffect
861
- if ____doEffect_3 == nil then
862
- ____doEffect_3 = false
882
+ local ____ReviveHero_6 = ReviveHero
883
+ local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
884
+ local ____doEffect_4 = doEffect
885
+ if ____doEffect_4 == nil then
886
+ ____doEffect_4 = false
863
887
  end
864
- __TS__SparseArrayPush(____array_4, ____doEffect_3)
865
- ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
888
+ __TS__SparseArrayPush(____array_5, ____doEffect_4)
889
+ ____ReviveHero_6(__TS__SparseArraySpread(____array_5))
866
890
  end
867
891
  function Unit.prototype.healTarget(self, target, amount)
868
892
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -905,17 +929,16 @@ function Unit.prototype.itemInSlot(self, slot)
905
929
  return Item:of(unitItemInSlot(self.handle, slot))
906
930
  end
907
931
  function Unit.prototype.addAbility(self, abilityId)
908
- if unitAddAbility(self.handle, abilityId) then
909
- local ability = UnitAbility:of(
910
- checkNotNull(getUnitAbility(self.handle, abilityId)),
911
- abilityId,
912
- self
913
- )
932
+ local ability = UnitAbility:of(
933
+ doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
934
+ abilityId,
935
+ self
936
+ )
937
+ if ability ~= nil then
914
938
  local abilities = self.abilities
915
939
  abilities[#abilities + 1] = ability
916
- return ability
917
940
  end
918
- return nil
941
+ return ability
919
942
  end
920
943
  function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
921
944
  return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
@@ -929,31 +952,21 @@ end
929
952
  function Unit.prototype.hasAbility(self, abilityId)
930
953
  return getUnitAbilityLevel(self.handle, abilityId) > 0
931
954
  end
932
- function Unit.prototype.getAbilityById(self, abilityId)
933
- local handle = self.handle
934
- if unitAddAbility(handle, abilityId) then
935
- assert(unitRemoveAbility(handle, abilityId))
936
- return nil
937
- end
938
- return UnitAbility:of(
939
- getUnitAbility(self.handle, abilityId),
940
- abilityId,
941
- self
942
- )
955
+ function Unit.prototype.getAbility(self, abilityId)
956
+ local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
957
+ return UnitAbility:of(ability, abilityId, self)
943
958
  end
944
- function Unit.prototype.removeAbility(self, abilityId)
945
- if unitRemoveAbility(self.handle, abilityId) then
946
- local abilities = self.abilities
947
- for i = 1, #abilities do
948
- if abilities[i].typeId == abilityId then
949
- abilities[i]:destroy()
950
- tremove(abilities, i)
951
- return true
952
- end
959
+ function Unit.prototype.removeAbility(self, abilityTypeId)
960
+ local abilities = self.abilities
961
+ for i = 1, #abilities do
962
+ if abilities[i].typeId == abilityTypeId then
963
+ local ability = abilities[i]
964
+ tremove(abilities, i)
965
+ ability:destroy()
966
+ return true
953
967
  end
954
- return true
955
968
  end
956
- return false
969
+ return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
957
970
  end
958
971
  function Unit.prototype.hideAbility(self, abilityId, flag)
959
972
  BlzUnitHideAbility(self.handle, abilityId, flag)
@@ -1055,18 +1068,44 @@ function Unit.prototype.unpauseEx(self)
1055
1068
  end
1056
1069
  function Unit.prototype.incrementStunCounter(self)
1057
1070
  local stunCounter = self[102] or 0
1058
- if not self[101] or stunCounter >= 0 then
1071
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
1059
1072
  BlzPauseUnitEx(self.handle, true)
1060
1073
  end
1061
1074
  self[102] = stunCounter + 1
1062
1075
  end
1063
1076
  function Unit.prototype.decrementStunCounter(self)
1064
1077
  local stunCounter = self[102] or 0
1065
- if not self[101] or stunCounter >= 1 then
1078
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
1066
1079
  BlzPauseUnitEx(self.handle, false)
1067
1080
  end
1068
1081
  self[102] = stunCounter - 1
1069
1082
  end
1083
+ function Unit.prototype.incrementForceStunCounter(self)
1084
+ local forceStunCounter = self[103] or 0
1085
+ if forceStunCounter == 0 then
1086
+ local handle = self.handle
1087
+ if not self[101] then
1088
+ for _ = self[102] or 0, -1 do
1089
+ BlzPauseUnitEx(handle, true)
1090
+ end
1091
+ end
1092
+ BlzPauseUnitEx(handle, true)
1093
+ end
1094
+ self[103] = forceStunCounter + 1
1095
+ end
1096
+ function Unit.prototype.decrementForceStunCounter(self)
1097
+ local forceStunCounter = self[103] or 0
1098
+ if forceStunCounter == 1 then
1099
+ local handle = self.handle
1100
+ if not self[101] then
1101
+ for _ = self[102] or 0, -1 do
1102
+ BlzPauseUnitEx(handle, false)
1103
+ end
1104
+ end
1105
+ BlzPauseUnitEx(handle, false)
1106
+ end
1107
+ self[103] = forceStunCounter - 1
1108
+ end
1070
1109
  function Unit.create(self, owner, id, x, y, facing, skinId)
1071
1110
  local handle = skinId and BlzCreateUnitWithSkin(
1072
1111
  owner.handle,
@@ -1255,7 +1294,7 @@ __TS__SetDescriptor(
1255
1294
  Unit.prototype,
1256
1295
  "isIllusion",
1257
1296
  {get = function(self)
1258
- return isUnitIllusion(self.handle)
1297
+ return IsUnitIllusion(self.handle)
1259
1298
  end},
1260
1299
  true
1261
1300
  )
@@ -1474,17 +1513,17 @@ __TS__SetDescriptor(
1474
1513
  "isTeamGlowVisible",
1475
1514
  {
1476
1515
  get = function(self)
1477
- return not self[106]
1516
+ return not self[107]
1478
1517
  end,
1479
1518
  set = function(self, isTeamGlowVisible)
1480
1519
  BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1481
- local ____temp_6
1520
+ local ____temp_7
1482
1521
  if not isTeamGlowVisible then
1483
- ____temp_6 = true
1522
+ ____temp_7 = true
1484
1523
  else
1485
- ____temp_6 = nil
1524
+ ____temp_7 = nil
1486
1525
  end
1487
- self[106] = ____temp_6
1526
+ self[107] = ____temp_7
1488
1527
  end
1489
1528
  },
1490
1529
  true
@@ -1494,7 +1533,7 @@ __TS__SetDescriptor(
1494
1533
  "color",
1495
1534
  {set = function(self, color)
1496
1535
  SetUnitColor(self.handle, color.handle)
1497
- if self[106] then
1536
+ if self[107] then
1498
1537
  BlzShowUnitTeamGlow(self.handle, false)
1499
1538
  end
1500
1539
  end},
@@ -1518,14 +1557,14 @@ __TS__SetDescriptor(
1518
1557
  "maxHealth",
1519
1558
  {
1520
1559
  get = function(self)
1521
- return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1560
+ return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
1522
1561
  end,
1523
1562
  set = function(self, maxHealth)
1524
- if maxHealth < 1 and self[103] ~= nil then
1525
- self[104] = (self[104] or 0) + (1 - maxHealth)
1563
+ if maxHealth < 1 and self[104] ~= nil then
1564
+ self[105] = (self[105] or 0) + (1 - maxHealth)
1526
1565
  maxHealth = 1
1527
1566
  end
1528
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1567
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
1529
1568
  end
1530
1569
  },
1531
1570
  true
@@ -1567,10 +1606,10 @@ __TS__SetDescriptor(
1567
1606
  "health",
1568
1607
  {
1569
1608
  get = function(self)
1570
- return GetWidgetLife(self.handle) - (self[105] or 0)
1609
+ return GetWidgetLife(self.handle) - (self[106] or 0)
1571
1610
  end,
1572
1611
  set = function(self, health)
1573
- SetWidgetLife(self.handle, health + (self[105] or 0))
1612
+ SetWidgetLife(self.handle, health + (self[106] or 0))
1574
1613
  end
1575
1614
  },
1576
1615
  true
@@ -1646,25 +1685,12 @@ __TS__SetDescriptor(
1646
1685
  },
1647
1686
  true
1648
1687
  )
1649
- __TS__SetDescriptor(
1650
- Unit.prototype,
1651
- "flyHeight",
1652
- {
1653
- get = function(self)
1654
- return getUnitFlyHeight(self.handle)
1655
- end,
1656
- set = function(self, v)
1657
- SetUnitFlyHeight(self.handle, v, 100000)
1658
- end
1659
- },
1660
- true
1661
- )
1662
1688
  __TS__SetDescriptor(
1663
1689
  Unit.prototype,
1664
1690
  "x",
1665
1691
  {
1666
1692
  get = function(self)
1667
- return self[107] or getUnitX(self.handle)
1693
+ return self[108] or getUnitX(self.handle)
1668
1694
  end,
1669
1695
  set = function(self, v)
1670
1696
  SetUnitX(self.handle, v)
@@ -1677,7 +1703,7 @@ __TS__SetDescriptor(
1677
1703
  "y",
1678
1704
  {
1679
1705
  get = function(self)
1680
- return self[108] or getUnitY(self.handle)
1706
+ return self[109] or getUnitY(self.handle)
1681
1707
  end,
1682
1708
  set = function(self, v)
1683
1709
  SetUnitY(self.handle, v)
@@ -1782,14 +1808,18 @@ __TS__SetDescriptor(
1782
1808
  local handle = self.handle
1783
1809
  if isPaused and not IsUnitPaused(handle) then
1784
1810
  self[101] = true
1785
- for _ = self[102] or 0, -1 do
1786
- BlzPauseUnitEx(handle, true)
1811
+ if (self[103] or 0) <= 0 then
1812
+ for _ = self[102] or 0, -1 do
1813
+ BlzPauseUnitEx(handle, true)
1814
+ end
1787
1815
  end
1788
1816
  PauseUnit(handle, true)
1789
1817
  elseif not isPaused and IsUnitPaused(handle) then
1790
1818
  PauseUnit(handle, false)
1791
- for _ = self[102] or 0, -1 do
1792
- BlzPauseUnitEx(handle, false)
1819
+ if (self[103] or 0) <= 0 then
1820
+ for _ = self[102] or 0, -1 do
1821
+ BlzPauseUnitEx(handle, false)
1822
+ end
1793
1823
  end
1794
1824
  self[101] = nil
1795
1825
  end
@@ -1847,20 +1877,6 @@ __TS__SetDescriptor(
1847
1877
  },
1848
1878
  true
1849
1879
  )
1850
- __TS__SetDescriptor(
1851
- Unit.prototype,
1852
- "scale",
1853
- {
1854
- get = function(self)
1855
- return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
1856
- end,
1857
- set = function(self, v)
1858
- setUnitScale(self.handle, v, v, v)
1859
- setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
1860
- end
1861
- },
1862
- true
1863
- )
1864
1880
  __TS__SetDescriptor(
1865
1881
  Unit.prototype,
1866
1882
  "timeScale",
@@ -2231,25 +2247,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2231
2247
  InitializingEvent,
2232
2248
  function(event)
2233
2249
  local function listener(unit, id)
2234
- local ____GetSpellTargetUnit_result_9
2250
+ local ____GetSpellTargetUnit_result_10
2235
2251
  if GetSpellTargetUnit() then
2236
- ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2252
+ ____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
2237
2253
  else
2238
- local ____GetSpellTargetItem_result_8
2254
+ local ____GetSpellTargetItem_result_9
2239
2255
  if GetSpellTargetItem() then
2240
- ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2256
+ ____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
2241
2257
  else
2242
- local ____GetSpellTargetDestructable_result_7
2258
+ local ____GetSpellTargetDestructable_result_8
2243
2259
  if GetSpellTargetDestructable() then
2244
- ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2260
+ ____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
2245
2261
  else
2246
- ____GetSpellTargetDestructable_result_7 = nil
2262
+ ____GetSpellTargetDestructable_result_8 = nil
2247
2263
  end
2248
- ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2264
+ ____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
2249
2265
  end
2250
- ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2266
+ ____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
2251
2267
  end
2252
- local target = ____GetSpellTargetUnit_result_9
2268
+ local target = ____GetSpellTargetUnit_result_10
2253
2269
  if target then
2254
2270
  invoke(event, unit, id, target)
2255
2271
  end
@@ -2472,12 +2488,7 @@ Unit.onDamaging = (function()
2472
2488
  preventRetaliation = damagingEventPreventRetaliation
2473
2489
  }
2474
2490
  if data.isAttack and source then
2475
- local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
2476
- if weapon == -1 then
2477
- local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
2478
- weapon = 0
2479
- end
2480
- data.weapon = assert(source.weapons[weapon + 1])
2491
+ data.weapon = source:chooseWeapon(target)
2481
2492
  end
2482
2493
  if not data.isAttack or not source or not source._attackHandlers then
2483
2494
  invoke(
@@ -2622,7 +2633,7 @@ Unit.onDamage = __TS__New(
2622
2633
  invoke(event, source, target, evData)
2623
2634
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2624
2635
  local bonusHealth = math.ceil(evData.amount)
2625
- target[105] = (target[105] or 0) + bonusHealth
2636
+ target[106] = (target[106] or 0) + bonusHealth
2626
2637
  BlzSetUnitMaxHP(
2627
2638
  target.handle,
2628
2639
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2636,7 +2647,7 @@ Unit.onDamage = __TS__New(
2636
2647
  evData[0],
2637
2648
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2638
2649
  )
2639
- target[105] = (target[105] or 0) - bonusHealth
2650
+ target[106] = (target[106] or 0) - bonusHealth
2640
2651
  SetWidgetLife(
2641
2652
  target.handle,
2642
2653
  GetWidgetLife(target.handle) - bonusHealth
@@ -2672,10 +2683,14 @@ Unit.itemPickedUpEvent = __TS__New(
2672
2683
  ____exports.UnitTriggerEvent,
2673
2684
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2674
2685
  function()
2675
- local unit = getTriggerUnit()
2676
- local item = getManipulatedItem()
2677
- if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2678
- return ____exports.Unit:of(unit), Item:of(item)
2686
+ local unitHandle = getTriggerUnit()
2687
+ local itemHandle = getManipulatedItem()
2688
+ if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
2689
+ local unit = ____exports.Unit:of(unitHandle)
2690
+ local item = Item:of(itemHandle)
2691
+ if item.owner ~= unit then
2692
+ return unit, item
2693
+ end
2679
2694
  end
2680
2695
  return IgnoreEvent
2681
2696
  end
@@ -2695,7 +2710,7 @@ Unit.itemUsedEvent = __TS__New(
2695
2710
  Unit.itemStackedEvent = __TS__New(
2696
2711
  ____exports.UnitTriggerEvent,
2697
2712
  EVENT_PLAYER_UNIT_STACK_ITEM,
2698
- function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2713
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
2699
2714
  )
2700
2715
  __TS__ObjectDefineProperty(
2701
2716
  Unit,
@@ -2782,6 +2797,10 @@ __TS__ObjectDefineProperty(
2782
2797
  rawset(self, "destroyEvent", destroyEvent)
2783
2798
  return destroyEvent
2784
2799
  end}
2800
+ )
2801
+ Unit.synchronize = synchronizer(
2802
+ function(unit) return unit.syncId end,
2803
+ function(syncId) return unitBySyncId[syncId] end
2785
2804
  );
2786
2805
  (function(self)
2787
2806
  local leaveAbilityIds = postcompile(function()
@@ -3,6 +3,7 @@ import { Unit } from "../core/types/unit";
3
3
  import { Async } from "../core/types/async";
4
4
  import { Event, TriggerEvent } from "../event";
5
5
  import { GraphicsMode } from "./index";
6
+ import { Color } from "../core/types/color";
6
7
  export declare class LocalClient {
7
8
  private constructor();
8
9
  static readonly locale: string;
@@ -11,6 +12,7 @@ export declare class LocalClient {
11
12
  static get isHD(): boolean;
12
13
  static get graphicsMode(): GraphicsMode;
13
14
  static get isActive(): boolean;
15
+ static pingMinimap(x: number, y: number, duration: number, ...parameters: [] | [red: number, green: number, blue: number, flashy?: boolean] | [color: Color, flashy?: boolean]): void;
14
16
  static get mouseFocusUnit(): Async<Unit> | undefined;
15
17
  static get mainSelectedUnit(): Async<Unit> | undefined;
16
18
  static get mainSelectedUnitChangeEvent(): Event<[
@@ -1,6 +1,7 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
3
3
  local __TS__Class = ____lualib.__TS__Class
4
+ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
4
5
  local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
5
6
  local __TS__New = ____lualib.__TS__New
6
7
  local ____exports = {}
@@ -15,6 +16,8 @@ local ____player = require("core.types.player")
15
16
  local Player = ____player.Player
16
17
  local ____timer = require("core.types.timer")
17
18
  local Timer = ____timer.Timer
19
+ local ____color = require("core.types.color")
20
+ local Color = ____color.Color
18
21
  local loadTOCFile = BlzLoadTOCFile
19
22
  local getLocalClientWidth = BlzGetLocalClientWidth
20
23
  local getLocalClientHeight = BlzGetLocalClientHeight
@@ -25,6 +28,8 @@ local getMouseFocusUnit = BlzGetMouseFocusUnit
25
28
  local getUnitRealField = BlzGetUnitRealField
26
29
  local getUnitTypeId = GetUnitTypeId
27
30
  local getLocale = BlzGetLocale
31
+ local pingMinimap = PingMinimap
32
+ local pingMinimapEx = PingMinimapEx
28
33
  local tableSort = table.sort
29
34
  local tocPath = "_warscript\\IsHD.toc"
30
35
  compiletime(function()
@@ -62,6 +67,31 @@ local LocalClient = ____exports.LocalClient
62
67
  LocalClient.name = "LocalClient"
63
68
  function LocalClient.prototype.____constructor(self)
64
69
  end
70
+ function LocalClient.pingMinimap(self, x, y, duration, redOrColor, greenOrFlashy, blue, flashy)
71
+ if redOrColor == nil then
72
+ pingMinimap(x, y, duration)
73
+ elseif __TS__InstanceOf(redOrColor, Color) then
74
+ pingMinimapEx(
75
+ x,
76
+ y,
77
+ duration,
78
+ redOrColor.r,
79
+ redOrColor.g,
80
+ redOrColor.b,
81
+ greenOrFlashy or false
82
+ )
83
+ else
84
+ pingMinimapEx(
85
+ x,
86
+ y,
87
+ duration,
88
+ redOrColor,
89
+ greenOrFlashy,
90
+ blue,
91
+ flashy or false
92
+ )
93
+ end
94
+ end
65
95
  LocalClient.locale = getLocale()
66
96
  __TS__ObjectDefineProperty(
67
97
  LocalClient,
@@ -0,0 +1,11 @@
1
+ /** @noSelfInFile */
2
+ export declare const enum ArmorType {
3
+ LIGHT = 0,
4
+ MEDIUM = 1,
5
+ HEAVY = 2,
6
+ FORTIFIED = 3,
7
+ NORMAL = 4,
8
+ HERO = 5,
9
+ DIVINE = 6,
10
+ UNARMORED = 7
11
+ }