warscript 0.0.1-dev.e196516 → 0.0.1-dev.e3899e3

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 (110) 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/order.d.ts +20 -0
  54. package/engine/internal/unit/order.lua +136 -0
  55. package/engine/internal/unit/scale.d.ts +7 -0
  56. package/engine/internal/unit/scale.lua +20 -0
  57. package/engine/internal/unit+ability.lua +10 -1
  58. package/engine/internal/unit-missile-launch.lua +45 -14
  59. package/engine/internal/unit.d.ts +19 -16
  60. package/engine/internal/unit.lua +170 -136
  61. package/engine/local-client.d.ts +2 -0
  62. package/engine/local-client.lua +30 -0
  63. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  64. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  65. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  66. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  67. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  68. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  69. package/engine/object-data/entry/ability-type.lua +5 -4
  70. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  71. package/engine/object-data/entry/destructible-type.lua +155 -0
  72. package/engine/object-data/entry/unit-type.d.ts +15 -2
  73. package/engine/object-data/entry/unit-type.lua +135 -33
  74. package/engine/object-field/ability.d.ts +3 -3
  75. package/engine/object-field/ability.lua +7 -6
  76. package/engine/object-field/unit.d.ts +31 -5
  77. package/engine/object-field/unit.lua +95 -0
  78. package/engine/object-field.d.ts +9 -3
  79. package/engine/object-field.lua +242 -119
  80. package/engine/random.d.ts +9 -0
  81. package/engine/random.lua +13 -0
  82. package/engine/standard/fields/ability.d.ts +2 -2
  83. package/engine/standard/fields/ability.lua +2 -2
  84. package/engine/standard/fields/unit.d.ts +7 -0
  85. package/engine/standard/fields/unit.lua +13 -0
  86. package/engine/synchronization.d.ts +11 -0
  87. package/engine/synchronization.lua +77 -0
  88. package/engine/text-tag.d.ts +26 -3
  89. package/engine/text-tag.lua +217 -11
  90. package/engine/unit.d.ts +3 -0
  91. package/engine/unit.lua +3 -0
  92. package/net/socket.lua +1 -1
  93. package/objutil/buff.lua +1 -1
  94. package/package.json +2 -2
  95. package/patch-lualib.lua +1 -1
  96. package/utility/arrays.d.ts +1 -0
  97. package/utility/arrays.lua +8 -0
  98. package/utility/callback-array.d.ts +17 -0
  99. package/utility/callback-array.lua +61 -0
  100. package/utility/functions.d.ts +7 -0
  101. package/utility/functions.lua +12 -0
  102. package/utility/linked-set.d.ts +1 -0
  103. package/utility/linked-set.lua +19 -1
  104. package/utility/lua-maps.d.ts +11 -2
  105. package/utility/lua-maps.lua +33 -2
  106. package/utility/lua-sets.d.ts +1 -0
  107. package/utility/lua-sets.lua +4 -0
  108. package/utility/types.d.ts +3 -0
  109. package/core/types/order.d.ts +0 -26
  110. package/core/types/order.lua +0 -65
@@ -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)
@@ -967,6 +980,21 @@ end
967
980
  function Unit.prototype.endAbilityCooldown(self, abilityId)
968
981
  BlzEndUnitAbilityCooldown(self.handle, abilityId)
969
982
  end
983
+ function Unit.prototype.interruptMovement(self)
984
+ local handle = self.handle
985
+ unitDisableAbility(
986
+ handle,
987
+ fourCC("Amov"),
988
+ true,
989
+ false
990
+ )
991
+ unitDisableAbility(
992
+ handle,
993
+ fourCC("Amov"),
994
+ false,
995
+ false
996
+ )
997
+ end
970
998
  function Unit.prototype.interruptAttack(self)
971
999
  unitInterruptAttack(self.handle)
972
1000
  end
@@ -1040,18 +1068,44 @@ function Unit.prototype.unpauseEx(self)
1040
1068
  end
1041
1069
  function Unit.prototype.incrementStunCounter(self)
1042
1070
  local stunCounter = self[102] or 0
1043
- if not self[101] or stunCounter >= 0 then
1071
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
1044
1072
  BlzPauseUnitEx(self.handle, true)
1045
1073
  end
1046
1074
  self[102] = stunCounter + 1
1047
1075
  end
1048
1076
  function Unit.prototype.decrementStunCounter(self)
1049
1077
  local stunCounter = self[102] or 0
1050
- if not self[101] or stunCounter >= 1 then
1078
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
1051
1079
  BlzPauseUnitEx(self.handle, false)
1052
1080
  end
1053
1081
  self[102] = stunCounter - 1
1054
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
1055
1109
  function Unit.create(self, owner, id, x, y, facing, skinId)
1056
1110
  local handle = skinId and BlzCreateUnitWithSkin(
1057
1111
  owner.handle,
@@ -1240,7 +1294,7 @@ __TS__SetDescriptor(
1240
1294
  Unit.prototype,
1241
1295
  "isIllusion",
1242
1296
  {get = function(self)
1243
- return isUnitIllusion(self.handle)
1297
+ return IsUnitIllusion(self.handle)
1244
1298
  end},
1245
1299
  true
1246
1300
  )
@@ -1459,17 +1513,17 @@ __TS__SetDescriptor(
1459
1513
  "isTeamGlowVisible",
1460
1514
  {
1461
1515
  get = function(self)
1462
- return not self[106]
1516
+ return not self[107]
1463
1517
  end,
1464
1518
  set = function(self, isTeamGlowVisible)
1465
1519
  BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1466
- local ____temp_6
1520
+ local ____temp_7
1467
1521
  if not isTeamGlowVisible then
1468
- ____temp_6 = true
1522
+ ____temp_7 = true
1469
1523
  else
1470
- ____temp_6 = nil
1524
+ ____temp_7 = nil
1471
1525
  end
1472
- self[106] = ____temp_6
1526
+ self[107] = ____temp_7
1473
1527
  end
1474
1528
  },
1475
1529
  true
@@ -1479,7 +1533,7 @@ __TS__SetDescriptor(
1479
1533
  "color",
1480
1534
  {set = function(self, color)
1481
1535
  SetUnitColor(self.handle, color.handle)
1482
- if self[106] then
1536
+ if self[107] then
1483
1537
  BlzShowUnitTeamGlow(self.handle, false)
1484
1538
  end
1485
1539
  end},
@@ -1503,14 +1557,14 @@ __TS__SetDescriptor(
1503
1557
  "maxHealth",
1504
1558
  {
1505
1559
  get = function(self)
1506
- 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)
1507
1561
  end,
1508
1562
  set = function(self, maxHealth)
1509
- if maxHealth < 1 and self[103] ~= nil then
1510
- 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)
1511
1565
  maxHealth = 1
1512
1566
  end
1513
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1567
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
1514
1568
  end
1515
1569
  },
1516
1570
  true
@@ -1552,10 +1606,10 @@ __TS__SetDescriptor(
1552
1606
  "health",
1553
1607
  {
1554
1608
  get = function(self)
1555
- return GetWidgetLife(self.handle) - (self[105] or 0)
1609
+ return GetWidgetLife(self.handle) - (self[106] or 0)
1556
1610
  end,
1557
1611
  set = function(self, health)
1558
- SetWidgetLife(self.handle, health + (self[105] or 0))
1612
+ SetWidgetLife(self.handle, health + (self[106] or 0))
1559
1613
  end
1560
1614
  },
1561
1615
  true
@@ -1631,25 +1685,12 @@ __TS__SetDescriptor(
1631
1685
  },
1632
1686
  true
1633
1687
  )
1634
- __TS__SetDescriptor(
1635
- Unit.prototype,
1636
- "flyHeight",
1637
- {
1638
- get = function(self)
1639
- return getUnitFlyHeight(self.handle)
1640
- end,
1641
- set = function(self, v)
1642
- SetUnitFlyHeight(self.handle, v, 100000)
1643
- end
1644
- },
1645
- true
1646
- )
1647
1688
  __TS__SetDescriptor(
1648
1689
  Unit.prototype,
1649
1690
  "x",
1650
1691
  {
1651
1692
  get = function(self)
1652
- return self[107] or getUnitX(self.handle)
1693
+ return self[108] or getUnitX(self.handle)
1653
1694
  end,
1654
1695
  set = function(self, v)
1655
1696
  SetUnitX(self.handle, v)
@@ -1662,7 +1703,7 @@ __TS__SetDescriptor(
1662
1703
  "y",
1663
1704
  {
1664
1705
  get = function(self)
1665
- return self[108] or getUnitY(self.handle)
1706
+ return self[109] or getUnitY(self.handle)
1666
1707
  end,
1667
1708
  set = function(self, v)
1668
1709
  SetUnitY(self.handle, v)
@@ -1767,14 +1808,18 @@ __TS__SetDescriptor(
1767
1808
  local handle = self.handle
1768
1809
  if isPaused and not IsUnitPaused(handle) then
1769
1810
  self[101] = true
1770
- for _ = self[102] or 0, -1 do
1771
- 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
1772
1815
  end
1773
1816
  PauseUnit(handle, true)
1774
1817
  elseif not isPaused and IsUnitPaused(handle) then
1775
1818
  PauseUnit(handle, false)
1776
- for _ = self[102] or 0, -1 do
1777
- 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
1778
1823
  end
1779
1824
  self[101] = nil
1780
1825
  end
@@ -1832,20 +1877,6 @@ __TS__SetDescriptor(
1832
1877
  },
1833
1878
  true
1834
1879
  )
1835
- __TS__SetDescriptor(
1836
- Unit.prototype,
1837
- "scale",
1838
- {
1839
- get = function(self)
1840
- return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
1841
- end,
1842
- set = function(self, v)
1843
- setUnitScale(self.handle, v, v, v)
1844
- setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
1845
- end
1846
- },
1847
- true
1848
- )
1849
1880
  __TS__SetDescriptor(
1850
1881
  Unit.prototype,
1851
1882
  "timeScale",
@@ -2216,25 +2247,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2216
2247
  InitializingEvent,
2217
2248
  function(event)
2218
2249
  local function listener(unit, id)
2219
- local ____GetSpellTargetUnit_result_9
2250
+ local ____GetSpellTargetUnit_result_10
2220
2251
  if GetSpellTargetUnit() then
2221
- ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2252
+ ____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
2222
2253
  else
2223
- local ____GetSpellTargetItem_result_8
2254
+ local ____GetSpellTargetItem_result_9
2224
2255
  if GetSpellTargetItem() then
2225
- ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2256
+ ____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
2226
2257
  else
2227
- local ____GetSpellTargetDestructable_result_7
2258
+ local ____GetSpellTargetDestructable_result_8
2228
2259
  if GetSpellTargetDestructable() then
2229
- ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2260
+ ____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
2230
2261
  else
2231
- ____GetSpellTargetDestructable_result_7 = nil
2262
+ ____GetSpellTargetDestructable_result_8 = nil
2232
2263
  end
2233
- ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2264
+ ____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
2234
2265
  end
2235
- ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2266
+ ____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
2236
2267
  end
2237
- local target = ____GetSpellTargetUnit_result_9
2268
+ local target = ____GetSpellTargetUnit_result_10
2238
2269
  if target then
2239
2270
  invoke(event, unit, id, target)
2240
2271
  end
@@ -2457,12 +2488,7 @@ Unit.onDamaging = (function()
2457
2488
  preventRetaliation = damagingEventPreventRetaliation
2458
2489
  }
2459
2490
  if data.isAttack and source then
2460
- 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
2461
- if weapon == -1 then
2462
- local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
2463
- weapon = 0
2464
- end
2465
- data.weapon = assert(source.weapons[weapon + 1])
2491
+ data.weapon = source:chooseWeapon(target)
2466
2492
  end
2467
2493
  if not data.isAttack or not source or not source._attackHandlers then
2468
2494
  invoke(
@@ -2607,7 +2633,7 @@ Unit.onDamage = __TS__New(
2607
2633
  invoke(event, source, target, evData)
2608
2634
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2609
2635
  local bonusHealth = math.ceil(evData.amount)
2610
- target[105] = (target[105] or 0) + bonusHealth
2636
+ target[106] = (target[106] or 0) + bonusHealth
2611
2637
  BlzSetUnitMaxHP(
2612
2638
  target.handle,
2613
2639
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2621,7 +2647,7 @@ Unit.onDamage = __TS__New(
2621
2647
  evData[0],
2622
2648
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2623
2649
  )
2624
- target[105] = (target[105] or 0) - bonusHealth
2650
+ target[106] = (target[106] or 0) - bonusHealth
2625
2651
  SetWidgetLife(
2626
2652
  target.handle,
2627
2653
  GetWidgetLife(target.handle) - bonusHealth
@@ -2657,10 +2683,14 @@ Unit.itemPickedUpEvent = __TS__New(
2657
2683
  ____exports.UnitTriggerEvent,
2658
2684
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2659
2685
  function()
2660
- local unit = getTriggerUnit()
2661
- local item = getManipulatedItem()
2662
- if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2663
- 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
2664
2694
  end
2665
2695
  return IgnoreEvent
2666
2696
  end
@@ -2680,7 +2710,7 @@ Unit.itemUsedEvent = __TS__New(
2680
2710
  Unit.itemStackedEvent = __TS__New(
2681
2711
  ____exports.UnitTriggerEvent,
2682
2712
  EVENT_PLAYER_UNIT_STACK_ITEM,
2683
- function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2713
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
2684
2714
  )
2685
2715
  __TS__ObjectDefineProperty(
2686
2716
  Unit,
@@ -2767,6 +2797,10 @@ __TS__ObjectDefineProperty(
2767
2797
  rawset(self, "destroyEvent", destroyEvent)
2768
2798
  return destroyEvent
2769
2799
  end}
2800
+ )
2801
+ Unit.synchronize = synchronizer(
2802
+ function(unit) return unit.syncId end,
2803
+ function(syncId) return unitBySyncId[syncId] end
2770
2804
  );
2771
2805
  (function(self)
2772
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
+ }