warscript 0.0.1-dev.4381d09 → 0.0.1-dev.4414935

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 (70) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/player.d.ts +16 -0
  4. package/core/types/player.lua +57 -14
  5. package/core/types/tileCell.d.ts +2 -1
  6. package/core/types/tileCell.lua +5 -0
  7. package/destroyable.d.ts +1 -0
  8. package/destroyable.lua +9 -0
  9. package/engine/behavior.d.ts +10 -2
  10. package/engine/behavior.lua +157 -76
  11. package/engine/behaviour/ability/apply-buff.lua +4 -4
  12. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  13. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  14. package/engine/behaviour/ability.d.ts +2 -1
  15. package/engine/behaviour/ability.lua +2 -1
  16. package/engine/behaviour/unit/stun-immunity.d.ts +7 -5
  17. package/engine/behaviour/unit/stun-immunity.lua +6 -5
  18. package/engine/behaviour/unit.d.ts +7 -3
  19. package/engine/behaviour/unit.lua +101 -24
  20. package/engine/buff.d.ts +19 -4
  21. package/engine/buff.lua +122 -41
  22. package/engine/internal/mechanics/cast-ability.lua +6 -3
  23. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  24. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  25. package/engine/internal/unit/ability.lua +3 -3
  26. package/engine/internal/unit/attributes.d.ts +17 -0
  27. package/engine/internal/unit/attributes.lua +46 -0
  28. package/engine/internal/unit/bonus.d.ts +2 -0
  29. package/engine/internal/unit/bonus.lua +10 -0
  30. package/engine/internal/unit/fly-height.d.ts +7 -0
  31. package/engine/internal/unit/fly-height.lua +20 -0
  32. package/engine/internal/unit/interrupts.d.ts +12 -0
  33. package/engine/internal/unit/interrupts.lua +28 -0
  34. package/engine/internal/unit/main-selected.lua +12 -27
  35. package/engine/internal/unit/scale.d.ts +7 -0
  36. package/engine/internal/unit/scale.lua +20 -0
  37. package/engine/internal/unit-missile-launch.lua +17 -7
  38. package/engine/internal/unit.d.ts +14 -18
  39. package/engine/internal/unit.lua +145 -155
  40. package/engine/local-client.d.ts +2 -0
  41. package/engine/local-client.lua +30 -0
  42. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  43. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  44. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  45. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  46. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  47. package/engine/object-data/entry/destructible-type.lua +155 -0
  48. package/engine/object-data/entry/unit-type.d.ts +4 -0
  49. package/engine/object-data/entry/unit-type.lua +76 -32
  50. package/engine/object-field/unit.d.ts +20 -5
  51. package/engine/object-field/unit.lua +61 -0
  52. package/engine/object-field.d.ts +9 -1
  53. package/engine/object-field.lua +265 -122
  54. package/engine/standard/fields/ability.d.ts +2 -2
  55. package/engine/standard/fields/ability.lua +2 -2
  56. package/engine/standard/fields/unit.d.ts +11 -3
  57. package/engine/standard/fields/unit.lua +15 -2
  58. package/engine/synchronization.d.ts +11 -0
  59. package/engine/synchronization.lua +77 -0
  60. package/engine/text-tag.lua +2 -1
  61. package/engine/unit.d.ts +4 -0
  62. package/engine/unit.lua +4 -0
  63. package/net/socket.lua +1 -1
  64. package/objutil/buff.lua +9 -7
  65. package/package.json +2 -2
  66. package/utility/linked-map.d.ts +26 -0
  67. package/utility/linked-map.lua +66 -0
  68. package/utility/linked-set.d.ts +1 -0
  69. package/utility/linked-set.lua +21 -0
  70. package/utility/records.lua +20 -1
@@ -62,6 +62,10 @@ 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
67
+ local ____linked_2Dmap = require("utility.linked-map")
68
+ local LinkedMap = ____linked_2Dmap.LinkedMap
65
69
  local match = string.match
66
70
  local ____tostring = _G.tostring
67
71
  local setUnitAnimation = SetUnitAnimation
@@ -71,16 +75,12 @@ local getUnitRealField = BlzGetUnitRealField
71
75
  local getHeroStr = GetHeroStr
72
76
  local getHeroAgi = GetHeroAgi
73
77
  local getHeroInt = GetHeroInt
74
- local setHeroStr = SetHeroStr
75
- local setHeroAgi = SetHeroAgi
76
- local setHeroInt = SetHeroInt
77
78
  local getUnitBooleanField = BlzGetUnitBooleanField
78
79
  local getUnitStringField = BlzGetUnitStringField
79
80
  local setUnitIntegerField = BlzSetUnitIntegerField
80
81
  local setUnitRealField = BlzSetUnitRealField
81
82
  local setUnitBooleanField = BlzSetUnitBooleanField
82
83
  local setUnitStringField = BlzSetUnitStringField
83
- local setUnitScale = SetUnitScale
84
84
  local setUnitPosition = SetUnitPosition
85
85
  local setUnitTimeScale = SetUnitTimeScale
86
86
  local getHandleId = GetHandleId
@@ -108,7 +108,6 @@ local getUnitWeaponStringField = BlzGetUnitWeaponStringField
108
108
  local setUnitWeaponStringField = BlzSetUnitWeaponStringField
109
109
  local getUnitAbilityLevel = GetUnitAbilityLevel
110
110
  local unitDisableAbility = BlzUnitDisableAbility
111
- local unitInterruptAttack = BlzUnitInterruptAttack
112
111
  local isUnitInvisible = IsUnitInvisible
113
112
  local isUnitVisible = IsUnitVisible
114
113
  local getUnitX = GetUnitX
@@ -384,15 +383,24 @@ local modifiers = {
384
383
  end,
385
384
  armor = function(unit, value)
386
385
  if UnitAddAbility(unit, armorBonusAbilityId) then
387
- assert(UnitMakeAbilityPermanent(unit, true, armorBonusAbilityId))
386
+ assert(
387
+ UnitMakeAbilityPermanent(unit, true, armorBonusAbilityId),
388
+ "armor bonus ability must be made permanent"
389
+ )
388
390
  end
389
- local ability = assert(BlzGetUnitAbility(unit, armorBonusAbilityId))
390
- assert(BlzSetAbilityRealLevelField(
391
- ability,
392
- armorBonusField,
393
- 0,
394
- BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
395
- ))
391
+ local ability = assert(
392
+ BlzGetUnitAbility(unit, armorBonusAbilityId),
393
+ "armor bonus ability must be existing"
394
+ )
395
+ assert(
396
+ BlzSetAbilityRealLevelField(
397
+ ability,
398
+ armorBonusField,
399
+ 0,
400
+ BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
401
+ ),
402
+ "armor bonus ability field must be set"
403
+ )
396
404
  end
397
405
  }
398
406
  local getters = {
@@ -410,6 +418,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
410
418
  self.unit = unit
411
419
  self.index = index
412
420
  end
421
+ __TS__SetDescriptor(
422
+ UnitWeapon.prototype,
423
+ "isEnabled",
424
+ {
425
+ get = function(self)
426
+ return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
427
+ end,
428
+ set = function(self, isEnabled)
429
+ BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
430
+ end
431
+ },
432
+ true
433
+ )
413
434
  __TS__SetDescriptor(
414
435
  UnitWeapon.prototype,
415
436
  "cooldown",
@@ -633,26 +654,29 @@ local fieldSetters = {
633
654
  }
634
655
  local dummies = {}
635
656
  for ____, player in ipairs(Player.all) do
636
- local dummy = assert(createUnit(
637
- player.handle,
638
- dummyUnitId,
639
- 0,
640
- 0,
641
- 270
642
- ))
657
+ local dummy = assert(
658
+ createUnit(
659
+ player.handle,
660
+ dummyUnitId,
661
+ 0,
662
+ 0,
663
+ 270
664
+ ),
665
+ "dummy must be created"
666
+ )
643
667
  ShowUnit(dummy, false)
644
668
  dummies[player] = dummy
645
669
  end
646
670
  local function delayHealthChecksCallback(unit)
647
- local counter = (unit[103] or 0) - 1
671
+ local counter = (unit[104] or 0) - 1
648
672
  if counter ~= 0 then
649
- unit[103] = counter
673
+ unit[104] = counter
650
674
  return
651
675
  end
652
- unit[103] = nil
653
- local healthBonus = unit[104]
676
+ unit[104] = nil
677
+ local healthBonus = unit[105]
654
678
  if healthBonus ~= nil then
655
- unit[104] = nil
679
+ unit[105] = nil
656
680
  local handle = unit.handle
657
681
  BlzSetUnitMaxHP(
658
682
  handle,
@@ -682,38 +706,49 @@ function Unit.prototype.____constructor(self, handle)
682
706
  nextSyncId = ____nextSyncId_1 + 1
683
707
  self.syncId = ____nextSyncId_1
684
708
  self._owner = Player:of(getOwningPlayer(handle))
685
- assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
686
- assert(unitAddAbility(handle, morphDetectAbilityId))
709
+ assert(
710
+ unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId),
711
+ "leave detection ability must be added"
712
+ )
713
+ assert(
714
+ unitAddAbility(handle, morphDetectAbilityId),
715
+ "morph detection ability must be added"
716
+ )
687
717
  if unitAddAbility(
688
718
  handle,
689
719
  fourCC("Amrf")
690
720
  ) then
691
- assert(unitRemoveAbility(
692
- handle,
693
- fourCC("Amrf")
694
- ))
721
+ assert(
722
+ unitRemoveAbility(
723
+ handle,
724
+ fourCC("Amrf")
725
+ ),
726
+ "fly ability must be removed after addition"
727
+ )
695
728
  end
696
729
  unitBySyncId[self.syncId] = self
697
730
  local ____ = self.abilities
698
731
  end
699
- function Unit.prototype.getEvent(self, event, collector)
700
- self.events = self.events or ({})
701
- local eventId = GetHandleId(event)
702
- if not self.events[eventId] then
703
- self.events[eventId] = __TS__New(
732
+ function Unit.prototype.getEvent(self, jevent, collector)
733
+ self.events = self.events or __TS__New(LinkedMap)
734
+ local eventId = GetHandleId(jevent)
735
+ local event = self.events:get(eventId)
736
+ if event == nil then
737
+ event = __TS__New(
704
738
  TriggerEvent,
705
739
  function(trigger)
706
- TriggerRegisterUnitEvent(trigger, self.handle, event)
740
+ TriggerRegisterUnitEvent(trigger, self.handle, jevent)
707
741
  end,
708
742
  collector or (function() return {} end)
709
743
  )
744
+ self.events:put(eventId, event)
710
745
  end
711
- return self.events[eventId]
746
+ return event
712
747
  end
713
748
  function Unit.prototype.onDestroy(self)
714
749
  local handle = self.handle
715
- self[107] = getUnitX(handle)
716
- self[108] = getUnitY(handle)
750
+ self[108] = getUnitX(handle)
751
+ self[109] = getUnitY(handle)
717
752
  if not self._owner then
718
753
  self._owner = Player:of(getOwningPlayer(handle))
719
754
  end
@@ -752,7 +787,10 @@ function Unit.prototype.addAttackHandler(self, condition, action)
752
787
  self._attackHandlers = handlers
753
788
  if #handlers == 1 then
754
789
  local handle = self.handle
755
- assert(unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId))
790
+ assert(
791
+ unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
792
+ "attack handler ability must be added"
793
+ )
756
794
  end
757
795
  return handler
758
796
  end
@@ -836,16 +874,18 @@ function Unit.prototype.queueAnimation(self, animation)
836
874
  QueueUnitAnimation(self.handle, animation)
837
875
  end
838
876
  function Unit.prototype.chooseWeapon(self, target)
839
- if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
840
- return self.firstWeapon
877
+ local firstWeapon = self.firstWeapon
878
+ if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
879
+ return firstWeapon
841
880
  end
842
- if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
843
- return self.secondWeapon
881
+ local secondWeapon = self.secondWeapon
882
+ if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
883
+ return secondWeapon
844
884
  end
845
885
  return nil
846
886
  end
847
887
  function Unit.prototype.delayHealthChecks(self)
848
- self[103] = (self[103] or 0) + 1
888
+ self[104] = (self[104] or 0) + 1
849
889
  Timer:run(delayHealthChecksCallback, self)
850
890
  end
851
891
  function Unit.prototype.setPosition(self, x, y)
@@ -963,24 +1003,6 @@ end
963
1003
  function Unit.prototype.endAbilityCooldown(self, abilityId)
964
1004
  BlzEndUnitAbilityCooldown(self.handle, abilityId)
965
1005
  end
966
- function Unit.prototype.interruptMovement(self)
967
- local handle = self.handle
968
- unitDisableAbility(
969
- handle,
970
- fourCC("Amov"),
971
- true,
972
- false
973
- )
974
- unitDisableAbility(
975
- handle,
976
- fourCC("Amov"),
977
- false,
978
- false
979
- )
980
- end
981
- function Unit.prototype.interruptAttack(self)
982
- unitInterruptAttack(self.handle)
983
- end
984
1006
  function Unit.prototype.interruptCast(self, abilityId)
985
1007
  local handle = self.handle
986
1008
  unitDisableAbility(handle, abilityId, true, false)
@@ -1051,18 +1073,44 @@ function Unit.prototype.unpauseEx(self)
1051
1073
  end
1052
1074
  function Unit.prototype.incrementStunCounter(self)
1053
1075
  local stunCounter = self[102] or 0
1054
- if not self[101] or stunCounter >= 0 then
1076
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
1055
1077
  BlzPauseUnitEx(self.handle, true)
1056
1078
  end
1057
1079
  self[102] = stunCounter + 1
1058
1080
  end
1059
1081
  function Unit.prototype.decrementStunCounter(self)
1060
1082
  local stunCounter = self[102] or 0
1061
- if not self[101] or stunCounter >= 1 then
1083
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
1062
1084
  BlzPauseUnitEx(self.handle, false)
1063
1085
  end
1064
1086
  self[102] = stunCounter - 1
1065
1087
  end
1088
+ function Unit.prototype.incrementForceStunCounter(self)
1089
+ local forceStunCounter = self[103] or 0
1090
+ if forceStunCounter == 0 then
1091
+ local handle = self.handle
1092
+ if not self[101] then
1093
+ for _ = self[102] or 0, -1 do
1094
+ BlzPauseUnitEx(handle, true)
1095
+ end
1096
+ end
1097
+ BlzPauseUnitEx(handle, true)
1098
+ end
1099
+ self[103] = forceStunCounter + 1
1100
+ end
1101
+ function Unit.prototype.decrementForceStunCounter(self)
1102
+ local forceStunCounter = self[103] or 0
1103
+ if forceStunCounter == 1 then
1104
+ local handle = self.handle
1105
+ if not self[101] then
1106
+ for _ = self[102] or 0, -1 do
1107
+ BlzPauseUnitEx(handle, false)
1108
+ end
1109
+ end
1110
+ BlzPauseUnitEx(handle, false)
1111
+ end
1112
+ self[103] = forceStunCounter - 1
1113
+ end
1066
1114
  function Unit.create(self, owner, id, x, y, facing, skinId)
1067
1115
  local handle = skinId and BlzCreateUnitWithSkin(
1068
1116
  owner.handle,
@@ -1349,19 +1397,6 @@ __TS__SetDescriptor(
1349
1397
  },
1350
1398
  true
1351
1399
  )
1352
- __TS__SetDescriptor(
1353
- Unit.prototype,
1354
- "strengthBase",
1355
- {
1356
- get = function(self)
1357
- return getHeroStr(self.handle, false)
1358
- end,
1359
- set = function(self, strengthBase)
1360
- setHeroStr(self.handle, strengthBase, true)
1361
- end
1362
- },
1363
- true
1364
- )
1365
1400
  __TS__SetDescriptor(
1366
1401
  Unit.prototype,
1367
1402
  "strengthBonus",
@@ -1379,19 +1414,6 @@ __TS__SetDescriptor(
1379
1414
  end},
1380
1415
  true
1381
1416
  )
1382
- __TS__SetDescriptor(
1383
- Unit.prototype,
1384
- "agilityBase",
1385
- {
1386
- get = function(self)
1387
- return getHeroAgi(self.handle, false)
1388
- end,
1389
- set = function(self, agilityBase)
1390
- setHeroAgi(self.handle, agilityBase, true)
1391
- end
1392
- },
1393
- true
1394
- )
1395
1417
  __TS__SetDescriptor(
1396
1418
  Unit.prototype,
1397
1419
  "agilityBonus",
@@ -1409,19 +1431,6 @@ __TS__SetDescriptor(
1409
1431
  end},
1410
1432
  true
1411
1433
  )
1412
- __TS__SetDescriptor(
1413
- Unit.prototype,
1414
- "intelligenceBase",
1415
- {
1416
- get = function(self)
1417
- return getHeroInt(self.handle, false)
1418
- end,
1419
- set = function(self, intelligenceBase)
1420
- setHeroInt(self.handle, intelligenceBase, true)
1421
- end
1422
- },
1423
- true
1424
- )
1425
1434
  __TS__SetDescriptor(
1426
1435
  Unit.prototype,
1427
1436
  "intelligenceBonus",
@@ -1470,7 +1479,7 @@ __TS__SetDescriptor(
1470
1479
  "isTeamGlowVisible",
1471
1480
  {
1472
1481
  get = function(self)
1473
- return not self[106]
1482
+ return not self[107]
1474
1483
  end,
1475
1484
  set = function(self, isTeamGlowVisible)
1476
1485
  BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
@@ -1480,7 +1489,7 @@ __TS__SetDescriptor(
1480
1489
  else
1481
1490
  ____temp_7 = nil
1482
1491
  end
1483
- self[106] = ____temp_7
1492
+ self[107] = ____temp_7
1484
1493
  end
1485
1494
  },
1486
1495
  true
@@ -1490,7 +1499,7 @@ __TS__SetDescriptor(
1490
1499
  "color",
1491
1500
  {set = function(self, color)
1492
1501
  SetUnitColor(self.handle, color.handle)
1493
- if self[106] then
1502
+ if self[107] then
1494
1503
  BlzShowUnitTeamGlow(self.handle, false)
1495
1504
  end
1496
1505
  end},
@@ -1514,14 +1523,14 @@ __TS__SetDescriptor(
1514
1523
  "maxHealth",
1515
1524
  {
1516
1525
  get = function(self)
1517
- return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1526
+ return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
1518
1527
  end,
1519
1528
  set = function(self, maxHealth)
1520
- if maxHealth < 1 and self[103] ~= nil then
1521
- self[104] = (self[104] or 0) + (1 - maxHealth)
1529
+ if maxHealth < 1 and self[104] ~= nil then
1530
+ self[105] = (self[105] or 0) + (1 - maxHealth)
1522
1531
  maxHealth = 1
1523
1532
  end
1524
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1533
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
1525
1534
  end
1526
1535
  },
1527
1536
  true
@@ -1563,10 +1572,10 @@ __TS__SetDescriptor(
1563
1572
  "health",
1564
1573
  {
1565
1574
  get = function(self)
1566
- return GetWidgetLife(self.handle) - (self[105] or 0)
1575
+ return GetWidgetLife(self.handle) - (self[106] or 0)
1567
1576
  end,
1568
1577
  set = function(self, health)
1569
- SetWidgetLife(self.handle, health + (self[105] or 0))
1578
+ SetWidgetLife(self.handle, health + (self[106] or 0))
1570
1579
  end
1571
1580
  },
1572
1581
  true
@@ -1642,25 +1651,12 @@ __TS__SetDescriptor(
1642
1651
  },
1643
1652
  true
1644
1653
  )
1645
- __TS__SetDescriptor(
1646
- Unit.prototype,
1647
- "flyHeight",
1648
- {
1649
- get = function(self)
1650
- return getUnitFlyHeight(self.handle)
1651
- end,
1652
- set = function(self, v)
1653
- SetUnitFlyHeight(self.handle, v, 100000)
1654
- end
1655
- },
1656
- true
1657
- )
1658
1654
  __TS__SetDescriptor(
1659
1655
  Unit.prototype,
1660
1656
  "x",
1661
1657
  {
1662
1658
  get = function(self)
1663
- return self[107] or getUnitX(self.handle)
1659
+ return self[108] or getUnitX(self.handle)
1664
1660
  end,
1665
1661
  set = function(self, v)
1666
1662
  SetUnitX(self.handle, v)
@@ -1673,7 +1669,7 @@ __TS__SetDescriptor(
1673
1669
  "y",
1674
1670
  {
1675
1671
  get = function(self)
1676
- return self[108] or getUnitY(self.handle)
1672
+ return self[109] or getUnitY(self.handle)
1677
1673
  end,
1678
1674
  set = function(self, v)
1679
1675
  SetUnitY(self.handle, v)
@@ -1778,14 +1774,18 @@ __TS__SetDescriptor(
1778
1774
  local handle = self.handle
1779
1775
  if isPaused and not IsUnitPaused(handle) then
1780
1776
  self[101] = true
1781
- for _ = self[102] or 0, -1 do
1782
- BlzPauseUnitEx(handle, true)
1777
+ if (self[103] or 0) <= 0 then
1778
+ for _ = self[102] or 0, -1 do
1779
+ BlzPauseUnitEx(handle, true)
1780
+ end
1783
1781
  end
1784
1782
  PauseUnit(handle, true)
1785
1783
  elseif not isPaused and IsUnitPaused(handle) then
1786
1784
  PauseUnit(handle, false)
1787
- for _ = self[102] or 0, -1 do
1788
- BlzPauseUnitEx(handle, false)
1785
+ if (self[103] or 0) <= 0 then
1786
+ for _ = self[102] or 0, -1 do
1787
+ BlzPauseUnitEx(handle, false)
1788
+ end
1789
1789
  end
1790
1790
  self[101] = nil
1791
1791
  end
@@ -1843,20 +1843,6 @@ __TS__SetDescriptor(
1843
1843
  },
1844
1844
  true
1845
1845
  )
1846
- __TS__SetDescriptor(
1847
- Unit.prototype,
1848
- "scale",
1849
- {
1850
- get = function(self)
1851
- return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
1852
- end,
1853
- set = function(self, v)
1854
- setUnitScale(self.handle, v, v, v)
1855
- setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
1856
- end
1857
- },
1858
- true
1859
- )
1860
1846
  __TS__SetDescriptor(
1861
1847
  Unit.prototype,
1862
1848
  "timeScale",
@@ -2152,6 +2138,11 @@ __TS__SetDescriptor(
2152
2138
  end},
2153
2139
  true
2154
2140
  )
2141
+ Unit.levelChangedEvent = __TS__New(
2142
+ ____exports.UnitTriggerEvent,
2143
+ EVENT_PLAYER_HERO_LEVEL,
2144
+ function() return ____exports.Unit:of(getTriggerUnit()) end
2145
+ )
2155
2146
  Unit.deathEvent = __TS__New(
2156
2147
  ____exports.UnitTriggerEvent,
2157
2148
  EVENT_PLAYER_UNIT_DEATH,
@@ -2468,12 +2459,7 @@ Unit.onDamaging = (function()
2468
2459
  preventRetaliation = damagingEventPreventRetaliation
2469
2460
  }
2470
2461
  if data.isAttack and source then
2471
- 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
2472
- if weapon == -1 then
2473
- local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
2474
- weapon = 0
2475
- end
2476
- data.weapon = assert(source.weapons[weapon + 1])
2462
+ data.weapon = source:chooseWeapon(target)
2477
2463
  end
2478
2464
  if not data.isAttack or not source or not source._attackHandlers then
2479
2465
  invoke(
@@ -2618,7 +2604,7 @@ Unit.onDamage = __TS__New(
2618
2604
  invoke(event, source, target, evData)
2619
2605
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2620
2606
  local bonusHealth = math.ceil(evData.amount)
2621
- target[105] = (target[105] or 0) + bonusHealth
2607
+ target[106] = (target[106] or 0) + bonusHealth
2622
2608
  BlzSetUnitMaxHP(
2623
2609
  target.handle,
2624
2610
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2632,7 +2618,7 @@ Unit.onDamage = __TS__New(
2632
2618
  evData[0],
2633
2619
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2634
2620
  )
2635
- target[105] = (target[105] or 0) - bonusHealth
2621
+ target[106] = (target[106] or 0) - bonusHealth
2636
2622
  SetWidgetLife(
2637
2623
  target.handle,
2638
2624
  GetWidgetLife(target.handle) - bonusHealth
@@ -2782,6 +2768,10 @@ __TS__ObjectDefineProperty(
2782
2768
  rawset(self, "destroyEvent", destroyEvent)
2783
2769
  return destroyEvent
2784
2770
  end}
2771
+ )
2772
+ Unit.synchronize = synchronizer(
2773
+ function(unit) return unit.syncId end,
2774
+ function(syncId) return unitBySyncId[syncId] end
2785
2775
  );
2786
2776
  (function(self)
2787
2777
  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,8 @@
1
+ /** @noSelfInFile */
2
+ export declare const enum HealthRegenerationType {
3
+ NONE = 0,
4
+ ALWAYS = 1,
5
+ BLIGHT = 2,
6
+ DAY = 3,
7
+ NIGHT = 4
8
+ }
@@ -0,0 +1,2 @@
1
+ local ____exports = {}
2
+ return ____exports
@@ -0,0 +1,8 @@
1
+ /** @noSelfInFile */
2
+ import { AbilityType, AbilityTypeId } from "../ability-type";
3
+ import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
4
+ export declare class ManaRegenerationAbilityType extends AbilityType {
5
+ static readonly BASE_ID: AbilityTypeId;
6
+ get manaRegenerationRateIncreaseFactor(): number[];
7
+ set manaRegenerationRateIncreaseFactor(manaRegenerationRateIncreaseFactor: ObjectDataEntryLevelFieldValueSupplier<number>);
8
+ }
@@ -0,0 +1,26 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
+ local ____exports = {}
6
+ local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
7
+ local AbilityType = ____ability_2Dtype.AbilityType
8
+ ____exports.ManaRegenerationAbilityType = __TS__Class()
9
+ local ManaRegenerationAbilityType = ____exports.ManaRegenerationAbilityType
10
+ ManaRegenerationAbilityType.name = "ManaRegenerationAbilityType"
11
+ __TS__ClassExtends(ManaRegenerationAbilityType, AbilityType)
12
+ ManaRegenerationAbilityType.BASE_ID = fourCC("AIrn")
13
+ __TS__SetDescriptor(
14
+ ManaRegenerationAbilityType.prototype,
15
+ "manaRegenerationRateIncreaseFactor",
16
+ {
17
+ get = function(self)
18
+ return self:getNumberLevelField("Imrp")
19
+ end,
20
+ set = function(self, manaRegenerationRateIncreaseFactor)
21
+ self:setNumberLevelField("Imrp", manaRegenerationRateIncreaseFactor)
22
+ end
23
+ },
24
+ true
25
+ )
26
+ return ____exports