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
@@ -62,6 +62,8 @@ local ____attributes = require("attributes")
62
62
  local isAttribute = ____attributes.isAttribute
63
63
  local ____ability = require("engine.internal.item.ability")
64
64
  local doUnitAbilityAction = ____ability.doUnitAbilityAction
65
+ local ____synchronization = require("engine.synchronization")
66
+ local synchronizer = ____synchronization.synchronizer
65
67
  local match = string.match
66
68
  local ____tostring = _G.tostring
67
69
  local setUnitAnimation = SetUnitAnimation
@@ -125,7 +127,6 @@ local getOrderedUnit = GetOrderedUnit
125
127
  local getIssuedOrderId = GetIssuedOrderId
126
128
  local isUnitInvulnerable = BlzIsUnitInvulnerable
127
129
  local unitAlive = UnitAlive
128
- local isUnitType = IsUnitType
129
130
  local isUnitAlly = IsUnitAlly
130
131
  local isUnitEnemy = IsUnitEnemy
131
132
  local getOwningPlayer = GetOwningPlayer
@@ -411,6 +412,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
411
412
  self.unit = unit
412
413
  self.index = index
413
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
+ )
414
428
  __TS__SetDescriptor(
415
429
  UnitWeapon.prototype,
416
430
  "cooldown",
@@ -645,15 +659,15 @@ for ____, player in ipairs(Player.all) do
645
659
  dummies[player] = dummy
646
660
  end
647
661
  local function delayHealthChecksCallback(unit)
648
- local counter = (unit[103] or 0) - 1
662
+ local counter = (unit[104] or 0) - 1
649
663
  if counter ~= 0 then
650
- unit[103] = counter
664
+ unit[104] = counter
651
665
  return
652
666
  end
653
- unit[103] = nil
654
- local healthBonus = unit[104]
667
+ unit[104] = nil
668
+ local healthBonus = unit[105]
655
669
  if healthBonus ~= nil then
656
- unit[104] = nil
670
+ unit[105] = nil
657
671
  local handle = unit.handle
658
672
  BlzSetUnitMaxHP(
659
673
  handle,
@@ -665,39 +679,13 @@ local nextSyncId = 1
665
679
  local unitBySyncId = setmetatable({}, {__mode = "v"})
666
680
  local damagingEventByTarget = setmetatable({}, {__mode = "k"})
667
681
  local function addAbility(unit, abilityTypeId)
668
- local handle = unit.handle
669
- if unitAddAbility(handle, abilityTypeId) then
670
- local ability = UnitAbility:of(
671
- checkNotNull(getUnitAbility(handle, abilityTypeId)),
672
- abilityTypeId,
673
- unit
674
- )
675
- local abilities = unit.abilities
676
- abilities[#abilities + 1] = ability
677
- return ability
678
- end
679
- return nil
680
- end
681
- local function getAbility(unit, abilityTypeId)
682
- return UnitAbility:of(
683
- getUnitAbility(unit.handle, abilityTypeId),
684
- abilityTypeId,
685
- unit
686
- )
687
- end
688
- local function removeAbility(unit, abilityTypeId)
689
- if unitRemoveAbility(unit.handle, abilityTypeId) then
690
- local abilities = unit.abilities
691
- for i = 1, #abilities do
692
- if abilities[i].typeId == abilityTypeId then
693
- abilities[i]:destroy()
694
- tremove(abilities, i)
695
- return true
696
- end
697
- end
698
- return true
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
699
687
  end
700
- return false
688
+ return ____unitAddAbility_result_0
701
689
  end
702
690
  ____exports.Unit = __TS__Class()
703
691
  local Unit = ____exports.Unit
@@ -705,9 +693,9 @@ Unit.name = "Unit"
705
693
  __TS__ClassExtends(Unit, Handle)
706
694
  function Unit.prototype.____constructor(self, handle)
707
695
  Handle.prototype.____constructor(self, handle)
708
- local ____nextSyncId_0 = nextSyncId
709
- nextSyncId = ____nextSyncId_0 + 1
710
- self.syncId = ____nextSyncId_0
696
+ local ____nextSyncId_1 = nextSyncId
697
+ nextSyncId = ____nextSyncId_1 + 1
698
+ self.syncId = ____nextSyncId_1
711
699
  self._owner = Player:of(getOwningPlayer(handle))
712
700
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
713
701
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -739,8 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
739
727
  end
740
728
  function Unit.prototype.onDestroy(self)
741
729
  local handle = self.handle
742
- self[107] = getUnitX(handle)
743
- self[108] = getUnitY(handle)
730
+ self[108] = getUnitX(handle)
731
+ self[109] = getUnitY(handle)
744
732
  if not self._owner then
745
733
  self._owner = Player:of(getOwningPlayer(handle))
746
734
  end
@@ -808,8 +796,8 @@ function Unit.prototype.addModifier(self, property, modifier)
808
796
  end}
809
797
  end
810
798
  function Unit.prototype.hasCombatClassification(self, combatClassification)
811
- local ____combatClassification_1 = combatClassification
812
- 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
813
801
  end
814
802
  function Unit.prototype.addClassification(self, classification)
815
803
  return UnitAddType(self.handle, classification)
@@ -818,7 +806,7 @@ function Unit.prototype.removeClassification(self, classification)
818
806
  return UnitRemoveType(self.handle, classification)
819
807
  end
820
808
  function Unit.prototype.hasClassification(self, classification)
821
- return isUnitType(self.handle, classification)
809
+ return IsUnitType(self.handle, classification)
822
810
  end
823
811
  function Unit.prototype.isVisibleTo(self, player)
824
812
  return isUnitVisible(self.handle, player.handle)
@@ -827,13 +815,13 @@ function Unit.prototype.isInvisibleTo(self, player)
827
815
  return isUnitInvisible(self.handle, player.handle)
828
816
  end
829
817
  function Unit.prototype.isInRangeOf(self, x, y, range)
830
- local ____temp_2
818
+ local ____temp_3
831
819
  if type(x) == "number" then
832
- ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
820
+ ____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
833
821
  else
834
- ____temp_2 = isUnitInRange(self.handle, x.handle, y)
822
+ ____temp_3 = isUnitInRange(self.handle, x.handle, y)
835
823
  end
836
- return ____temp_2
824
+ return ____temp_3
837
825
  end
838
826
  function Unit.prototype.isAllyOf(self, unit)
839
827
  return isUnitAlly(
@@ -863,16 +851,18 @@ function Unit.prototype.queueAnimation(self, animation)
863
851
  QueueUnitAnimation(self.handle, animation)
864
852
  end
865
853
  function Unit.prototype.chooseWeapon(self, target)
866
- if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
867
- return self.firstWeapon
854
+ local firstWeapon = self.firstWeapon
855
+ if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
856
+ return firstWeapon
868
857
  end
869
- if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
870
- return self.secondWeapon
858
+ local secondWeapon = self.secondWeapon
859
+ if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
860
+ return secondWeapon
871
861
  end
872
862
  return nil
873
863
  end
874
864
  function Unit.prototype.delayHealthChecks(self)
875
- self[103] = (self[103] or 0) + 1
865
+ self[104] = (self[104] or 0) + 1
876
866
  Timer:run(delayHealthChecksCallback, self)
877
867
  end
878
868
  function Unit.prototype.setPosition(self, x, y)
@@ -889,14 +879,14 @@ function Unit.prototype.kill(self)
889
879
  killUnit(self.handle)
890
880
  end
891
881
  function Unit.prototype.revive(self, x, y, doEffect)
892
- local ____ReviveHero_5 = ReviveHero
893
- local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
894
- local ____doEffect_3 = doEffect
895
- if ____doEffect_3 == nil then
896
- ____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
897
887
  end
898
- __TS__SparseArrayPush(____array_4, ____doEffect_3)
899
- ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
888
+ __TS__SparseArrayPush(____array_5, ____doEffect_4)
889
+ ____ReviveHero_6(__TS__SparseArraySpread(____array_5))
900
890
  end
901
891
  function Unit.prototype.healTarget(self, target, amount)
902
892
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -939,13 +929,16 @@ function Unit.prototype.itemInSlot(self, slot)
939
929
  return Item:of(unitItemInSlot(self.handle, slot))
940
930
  end
941
931
  function Unit.prototype.addAbility(self, abilityId)
942
- return doUnitAbilityAction(
943
- self.handle,
932
+ local ability = UnitAbility:of(
933
+ doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
944
934
  abilityId,
945
- addAbility,
946
- self,
947
- abilityId
935
+ self
948
936
  )
937
+ if ability ~= nil then
938
+ local abilities = self.abilities
939
+ abilities[#abilities + 1] = ability
940
+ end
941
+ return ability
949
942
  end
950
943
  function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
951
944
  return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
@@ -959,23 +952,21 @@ end
959
952
  function Unit.prototype.hasAbility(self, abilityId)
960
953
  return getUnitAbilityLevel(self.handle, abilityId) > 0
961
954
  end
962
- function Unit.prototype.getAbilityById(self, abilityId)
963
- return doUnitAbilityAction(
964
- self.handle,
965
- abilityId,
966
- getAbility,
967
- self,
968
- abilityId
969
- )
955
+ function Unit.prototype.getAbility(self, abilityId)
956
+ local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
957
+ return UnitAbility:of(ability, abilityId, self)
970
958
  end
971
- function Unit.prototype.removeAbility(self, abilityId)
972
- return doUnitAbilityAction(
973
- self.handle,
974
- abilityId,
975
- removeAbility,
976
- self,
977
- abilityId
978
- )
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
967
+ end
968
+ end
969
+ return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
979
970
  end
980
971
  function Unit.prototype.hideAbility(self, abilityId, flag)
981
972
  BlzUnitHideAbility(self.handle, abilityId, flag)
@@ -1077,18 +1068,44 @@ function Unit.prototype.unpauseEx(self)
1077
1068
  end
1078
1069
  function Unit.prototype.incrementStunCounter(self)
1079
1070
  local stunCounter = self[102] or 0
1080
- if not self[101] or stunCounter >= 0 then
1071
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
1081
1072
  BlzPauseUnitEx(self.handle, true)
1082
1073
  end
1083
1074
  self[102] = stunCounter + 1
1084
1075
  end
1085
1076
  function Unit.prototype.decrementStunCounter(self)
1086
1077
  local stunCounter = self[102] or 0
1087
- if not self[101] or stunCounter >= 1 then
1078
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
1088
1079
  BlzPauseUnitEx(self.handle, false)
1089
1080
  end
1090
1081
  self[102] = stunCounter - 1
1091
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
1092
1109
  function Unit.create(self, owner, id, x, y, facing, skinId)
1093
1110
  local handle = skinId and BlzCreateUnitWithSkin(
1094
1111
  owner.handle,
@@ -1496,17 +1513,17 @@ __TS__SetDescriptor(
1496
1513
  "isTeamGlowVisible",
1497
1514
  {
1498
1515
  get = function(self)
1499
- return not self[106]
1516
+ return not self[107]
1500
1517
  end,
1501
1518
  set = function(self, isTeamGlowVisible)
1502
1519
  BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1503
- local ____temp_6
1520
+ local ____temp_7
1504
1521
  if not isTeamGlowVisible then
1505
- ____temp_6 = true
1522
+ ____temp_7 = true
1506
1523
  else
1507
- ____temp_6 = nil
1524
+ ____temp_7 = nil
1508
1525
  end
1509
- self[106] = ____temp_6
1526
+ self[107] = ____temp_7
1510
1527
  end
1511
1528
  },
1512
1529
  true
@@ -1516,7 +1533,7 @@ __TS__SetDescriptor(
1516
1533
  "color",
1517
1534
  {set = function(self, color)
1518
1535
  SetUnitColor(self.handle, color.handle)
1519
- if self[106] then
1536
+ if self[107] then
1520
1537
  BlzShowUnitTeamGlow(self.handle, false)
1521
1538
  end
1522
1539
  end},
@@ -1540,14 +1557,14 @@ __TS__SetDescriptor(
1540
1557
  "maxHealth",
1541
1558
  {
1542
1559
  get = function(self)
1543
- 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)
1544
1561
  end,
1545
1562
  set = function(self, maxHealth)
1546
- if maxHealth < 1 and self[103] ~= nil then
1547
- 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)
1548
1565
  maxHealth = 1
1549
1566
  end
1550
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1567
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
1551
1568
  end
1552
1569
  },
1553
1570
  true
@@ -1589,10 +1606,10 @@ __TS__SetDescriptor(
1589
1606
  "health",
1590
1607
  {
1591
1608
  get = function(self)
1592
- return GetWidgetLife(self.handle) - (self[105] or 0)
1609
+ return GetWidgetLife(self.handle) - (self[106] or 0)
1593
1610
  end,
1594
1611
  set = function(self, health)
1595
- SetWidgetLife(self.handle, health + (self[105] or 0))
1612
+ SetWidgetLife(self.handle, health + (self[106] or 0))
1596
1613
  end
1597
1614
  },
1598
1615
  true
@@ -1668,25 +1685,12 @@ __TS__SetDescriptor(
1668
1685
  },
1669
1686
  true
1670
1687
  )
1671
- __TS__SetDescriptor(
1672
- Unit.prototype,
1673
- "flyHeight",
1674
- {
1675
- get = function(self)
1676
- return getUnitFlyHeight(self.handle)
1677
- end,
1678
- set = function(self, v)
1679
- SetUnitFlyHeight(self.handle, v, 100000)
1680
- end
1681
- },
1682
- true
1683
- )
1684
1688
  __TS__SetDescriptor(
1685
1689
  Unit.prototype,
1686
1690
  "x",
1687
1691
  {
1688
1692
  get = function(self)
1689
- return self[107] or getUnitX(self.handle)
1693
+ return self[108] or getUnitX(self.handle)
1690
1694
  end,
1691
1695
  set = function(self, v)
1692
1696
  SetUnitX(self.handle, v)
@@ -1699,7 +1703,7 @@ __TS__SetDescriptor(
1699
1703
  "y",
1700
1704
  {
1701
1705
  get = function(self)
1702
- return self[108] or getUnitY(self.handle)
1706
+ return self[109] or getUnitY(self.handle)
1703
1707
  end,
1704
1708
  set = function(self, v)
1705
1709
  SetUnitY(self.handle, v)
@@ -1804,14 +1808,18 @@ __TS__SetDescriptor(
1804
1808
  local handle = self.handle
1805
1809
  if isPaused and not IsUnitPaused(handle) then
1806
1810
  self[101] = true
1807
- for _ = self[102] or 0, -1 do
1808
- 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
1809
1815
  end
1810
1816
  PauseUnit(handle, true)
1811
1817
  elseif not isPaused and IsUnitPaused(handle) then
1812
1818
  PauseUnit(handle, false)
1813
- for _ = self[102] or 0, -1 do
1814
- 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
1815
1823
  end
1816
1824
  self[101] = nil
1817
1825
  end
@@ -1869,20 +1877,6 @@ __TS__SetDescriptor(
1869
1877
  },
1870
1878
  true
1871
1879
  )
1872
- __TS__SetDescriptor(
1873
- Unit.prototype,
1874
- "scale",
1875
- {
1876
- get = function(self)
1877
- return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
1878
- end,
1879
- set = function(self, v)
1880
- setUnitScale(self.handle, v, v, v)
1881
- setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
1882
- end
1883
- },
1884
- true
1885
- )
1886
1880
  __TS__SetDescriptor(
1887
1881
  Unit.prototype,
1888
1882
  "timeScale",
@@ -2253,25 +2247,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2253
2247
  InitializingEvent,
2254
2248
  function(event)
2255
2249
  local function listener(unit, id)
2256
- local ____GetSpellTargetUnit_result_9
2250
+ local ____GetSpellTargetUnit_result_10
2257
2251
  if GetSpellTargetUnit() then
2258
- ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2252
+ ____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
2259
2253
  else
2260
- local ____GetSpellTargetItem_result_8
2254
+ local ____GetSpellTargetItem_result_9
2261
2255
  if GetSpellTargetItem() then
2262
- ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2256
+ ____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
2263
2257
  else
2264
- local ____GetSpellTargetDestructable_result_7
2258
+ local ____GetSpellTargetDestructable_result_8
2265
2259
  if GetSpellTargetDestructable() then
2266
- ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2260
+ ____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
2267
2261
  else
2268
- ____GetSpellTargetDestructable_result_7 = nil
2262
+ ____GetSpellTargetDestructable_result_8 = nil
2269
2263
  end
2270
- ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2264
+ ____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
2271
2265
  end
2272
- ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2266
+ ____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
2273
2267
  end
2274
- local target = ____GetSpellTargetUnit_result_9
2268
+ local target = ____GetSpellTargetUnit_result_10
2275
2269
  if target then
2276
2270
  invoke(event, unit, id, target)
2277
2271
  end
@@ -2494,12 +2488,7 @@ Unit.onDamaging = (function()
2494
2488
  preventRetaliation = damagingEventPreventRetaliation
2495
2489
  }
2496
2490
  if data.isAttack and source then
2497
- 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
2498
- if weapon == -1 then
2499
- local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
2500
- weapon = 0
2501
- end
2502
- data.weapon = assert(source.weapons[weapon + 1])
2491
+ data.weapon = source:chooseWeapon(target)
2503
2492
  end
2504
2493
  if not data.isAttack or not source or not source._attackHandlers then
2505
2494
  invoke(
@@ -2644,7 +2633,7 @@ Unit.onDamage = __TS__New(
2644
2633
  invoke(event, source, target, evData)
2645
2634
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2646
2635
  local bonusHealth = math.ceil(evData.amount)
2647
- target[105] = (target[105] or 0) + bonusHealth
2636
+ target[106] = (target[106] or 0) + bonusHealth
2648
2637
  BlzSetUnitMaxHP(
2649
2638
  target.handle,
2650
2639
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2658,7 +2647,7 @@ Unit.onDamage = __TS__New(
2658
2647
  evData[0],
2659
2648
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2660
2649
  )
2661
- target[105] = (target[105] or 0) - bonusHealth
2650
+ target[106] = (target[106] or 0) - bonusHealth
2662
2651
  SetWidgetLife(
2663
2652
  target.handle,
2664
2653
  GetWidgetLife(target.handle) - bonusHealth
@@ -2694,10 +2683,14 @@ Unit.itemPickedUpEvent = __TS__New(
2694
2683
  ____exports.UnitTriggerEvent,
2695
2684
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2696
2685
  function()
2697
- local unit = getTriggerUnit()
2698
- local item = getManipulatedItem()
2699
- if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2700
- 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
2701
2694
  end
2702
2695
  return IgnoreEvent
2703
2696
  end
@@ -2717,7 +2710,7 @@ Unit.itemUsedEvent = __TS__New(
2717
2710
  Unit.itemStackedEvent = __TS__New(
2718
2711
  ____exports.UnitTriggerEvent,
2719
2712
  EVENT_PLAYER_UNIT_STACK_ITEM,
2720
- function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2713
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
2721
2714
  )
2722
2715
  __TS__ObjectDefineProperty(
2723
2716
  Unit,
@@ -2804,6 +2797,10 @@ __TS__ObjectDefineProperty(
2804
2797
  rawset(self, "destroyEvent", destroyEvent)
2805
2798
  return destroyEvent
2806
2799
  end}
2800
+ )
2801
+ Unit.synchronize = synchronizer(
2802
+ function(unit) return unit.syncId end,
2803
+ function(syncId) return unitBySyncId[syncId] end
2807
2804
  );
2808
2805
  (function(self)
2809
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, extraEffects?: boolean] | [color: Color, extraEffects?: 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, greenOrExtraEffects, blue, extraEffects)
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
+ greenOrExtraEffects or false
82
+ )
83
+ else
84
+ pingMinimapEx(
85
+ x,
86
+ y,
87
+ duration,
88
+ redOrColor,
89
+ greenOrExtraEffects,
90
+ blue,
91
+ extraEffects 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
+ }