warscript 0.0.1-dev.a44a461 → 0.0.1-dev.a4646d1

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 (123) hide show
  1. package/attributes.d.ts +1 -2
  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 +11 -3
  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 +10 -18
  26. package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
  27. package/engine/behaviour/unit/stun-immunity.lua +57 -31
  28. package/engine/behaviour/unit.d.ts +39 -3
  29. package/engine/behaviour/unit.lua +269 -6
  30. package/engine/buff.d.ts +21 -8
  31. package/engine/buff.lua +187 -121
  32. package/engine/internal/ability.d.ts +7 -1
  33. package/engine/internal/ability.lua +49 -9
  34. package/engine/internal/item/ability.lua +63 -11
  35. package/engine/internal/item+owner.lua +12 -6
  36. package/engine/internal/item.d.ts +16 -16
  37. package/engine/internal/item.lua +135 -49
  38. package/engine/internal/mechanics/cast-ability.lua +6 -3
  39. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  40. package/engine/internal/misc/frame-coordinates.lua +21 -0
  41. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  42. package/engine/internal/misc/get-terrain-z.lua +11 -0
  43. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  44. package/engine/internal/misc/player-local-handle.lua +5 -0
  45. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  46. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  47. package/engine/internal/unit/ability.d.ts +35 -0
  48. package/engine/internal/unit/ability.lua +98 -9
  49. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  50. package/engine/internal/unit/allowed-targets.lua +9 -1
  51. package/engine/internal/unit/attributes.d.ts +17 -0
  52. package/engine/internal/unit/attributes.lua +46 -0
  53. package/engine/internal/unit/bonus.d.ts +2 -0
  54. package/engine/internal/unit/bonus.lua +10 -0
  55. package/engine/internal/unit/fly-height.d.ts +7 -0
  56. package/engine/internal/unit/fly-height.lua +20 -0
  57. package/engine/internal/unit/interrupts.d.ts +12 -0
  58. package/engine/internal/unit/interrupts.lua +28 -0
  59. package/engine/internal/unit/main-selected.lua +12 -27
  60. package/engine/internal/unit/order.d.ts +20 -0
  61. package/engine/internal/unit/order.lua +136 -0
  62. package/engine/internal/unit/scale.d.ts +7 -0
  63. package/engine/internal/unit/scale.lua +20 -0
  64. package/engine/internal/unit+ability.lua +10 -1
  65. package/engine/internal/unit-missile-launch.lua +52 -14
  66. package/engine/internal/unit.d.ts +27 -24
  67. package/engine/internal/unit.lua +298 -213
  68. package/engine/local-client.d.ts +2 -0
  69. package/engine/local-client.lua +30 -0
  70. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  71. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  72. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  73. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  74. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  75. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  76. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  77. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  78. package/engine/object-data/entry/ability-type.lua +5 -4
  79. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  80. package/engine/object-data/entry/destructible-type.lua +155 -0
  81. package/engine/object-data/entry/unit-type.d.ts +15 -2
  82. package/engine/object-data/entry/unit-type.lua +135 -33
  83. package/engine/object-field/ability.d.ts +3 -3
  84. package/engine/object-field/ability.lua +7 -6
  85. package/engine/object-field/unit.d.ts +31 -5
  86. package/engine/object-field/unit.lua +95 -0
  87. package/engine/object-field.d.ts +17 -6
  88. package/engine/object-field.lua +291 -134
  89. package/engine/random.d.ts +9 -0
  90. package/engine/random.lua +13 -0
  91. package/engine/standard/fields/ability.d.ts +2 -2
  92. package/engine/standard/fields/ability.lua +2 -2
  93. package/engine/standard/fields/unit.d.ts +12 -0
  94. package/engine/standard/fields/unit.lua +20 -0
  95. package/engine/synchronization.d.ts +11 -0
  96. package/engine/synchronization.lua +77 -0
  97. package/engine/text-tag.d.ts +36 -2
  98. package/engine/text-tag.lua +250 -10
  99. package/engine/unit.d.ts +5 -0
  100. package/engine/unit.lua +5 -0
  101. package/net/socket.lua +1 -1
  102. package/objutil/buff.lua +10 -8
  103. package/package.json +2 -2
  104. package/patch-lua.lua +9 -0
  105. package/patch-lualib.lua +1 -1
  106. package/utility/arrays.d.ts +1 -0
  107. package/utility/arrays.lua +8 -0
  108. package/utility/callback-array.d.ts +17 -0
  109. package/utility/callback-array.lua +61 -0
  110. package/utility/functions.d.ts +7 -0
  111. package/utility/functions.lua +12 -0
  112. package/utility/linked-map.d.ts +26 -0
  113. package/utility/linked-map.lua +66 -0
  114. package/utility/linked-set.d.ts +1 -0
  115. package/utility/linked-set.lua +23 -1
  116. package/utility/lua-maps.d.ts +12 -2
  117. package/utility/lua-maps.lua +37 -2
  118. package/utility/lua-sets.d.ts +1 -0
  119. package/utility/lua-sets.lua +4 -0
  120. package/utility/records.lua +20 -1
  121. package/utility/types.d.ts +3 -0
  122. package/core/types/order.d.ts +0 -25
  123. package/core/types/order.lua +0 -55
@@ -60,27 +60,27 @@ 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
67
+ local ____linked_2Dmap = require("utility.linked-map")
68
+ local LinkedMap = ____linked_2Dmap.LinkedMap
63
69
  local match = string.match
64
70
  local ____tostring = _G.tostring
65
71
  local setUnitAnimation = SetUnitAnimation
66
72
  local setUnitAnimationByIndex = SetUnitAnimationByIndex
67
- local resetUnitAnimation = ResetUnitAnimation
68
- local queueUnitAnimation = QueueUnitAnimation
69
73
  local getUnitIntegerField = BlzGetUnitIntegerField
70
74
  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
@@ -125,10 +124,6 @@ local getOrderedUnit = GetOrderedUnit
125
124
  local getIssuedOrderId = GetIssuedOrderId
126
125
  local isUnitInvulnerable = BlzIsUnitInvulnerable
127
126
  local unitAlive = UnitAlive
128
- local unitAddType = UnitAddType
129
- local unitRemoveType = UnitRemoveType
130
- local isUnitIllusion = IsUnitIllusion
131
- local isUnitType = IsUnitType
132
127
  local isUnitAlly = IsUnitAlly
133
128
  local isUnitEnemy = IsUnitEnemy
134
129
  local getOwningPlayer = GetOwningPlayer
@@ -141,6 +136,7 @@ do
141
136
  UnitClassification.GROUND = UNIT_TYPE_GROUND
142
137
  UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
143
138
  UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
139
+ UnitClassification.WORKER = UNIT_TYPE_PEON
144
140
  UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
145
141
  UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
146
142
  UnitClassification.TAUREN = UNIT_TYPE_TAUREN
@@ -348,6 +344,9 @@ local function dispatchAbility(event)
348
344
  }
349
345
  )
350
346
  end
347
+ local function damagingEventPreventRetaliation(self)
348
+ self[0] = true
349
+ end
351
350
  local function damageEventPreventDeath(self, callback, ...)
352
351
  if self[0] ~= nil then
353
352
  return
@@ -384,15 +383,27 @@ 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
+ unit
390
+ )
388
391
  end
389
- local ability = assert(BlzGetUnitAbility(unit, armorBonusAbilityId))
390
- assert(BlzSetAbilityRealLevelField(
391
- ability,
392
- armorBonusField,
393
- 0,
394
- BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
395
- ))
392
+ local ability = assert(
393
+ BlzGetUnitAbility(unit, armorBonusAbilityId),
394
+ "armor bonus ability must be existing",
395
+ unit
396
+ )
397
+ assert(
398
+ BlzSetAbilityRealLevelField(
399
+ ability,
400
+ armorBonusField,
401
+ 0,
402
+ BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
403
+ ),
404
+ "armor bonus ability field must be set",
405
+ unit
406
+ )
396
407
  end
397
408
  }
398
409
  local getters = {
@@ -410,6 +421,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
410
421
  self.unit = unit
411
422
  self.index = index
412
423
  end
424
+ __TS__SetDescriptor(
425
+ UnitWeapon.prototype,
426
+ "isEnabled",
427
+ {
428
+ get = function(self)
429
+ return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
430
+ end,
431
+ set = function(self, isEnabled)
432
+ BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
433
+ end
434
+ },
435
+ true
436
+ )
413
437
  __TS__SetDescriptor(
414
438
  UnitWeapon.prototype,
415
439
  "cooldown",
@@ -444,6 +468,19 @@ __TS__SetDescriptor(
444
468
  },
445
469
  true
446
470
  )
471
+ __TS__SetDescriptor(
472
+ UnitWeapon.prototype,
473
+ "allowedTargetCombatClassifications",
474
+ {
475
+ get = function(self)
476
+ return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
477
+ end,
478
+ set = function(self, allowedTargetCombatClassifications)
479
+ BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
480
+ end
481
+ },
482
+ true
483
+ )
447
484
  __TS__SetDescriptor(
448
485
  UnitWeapon.prototype,
449
486
  "damageBase",
@@ -620,26 +657,30 @@ local fieldSetters = {
620
657
  }
621
658
  local dummies = {}
622
659
  for ____, player in ipairs(Player.all) do
623
- local dummy = assert(createUnit(
624
- player.handle,
625
- dummyUnitId,
626
- 0,
627
- 0,
628
- 270
629
- ))
660
+ local dummy = assert(
661
+ createUnit(
662
+ player.handle,
663
+ dummyUnitId,
664
+ 0,
665
+ 0,
666
+ 270
667
+ ),
668
+ "dummy must be created",
669
+ player
670
+ )
630
671
  ShowUnit(dummy, false)
631
672
  dummies[player] = dummy
632
673
  end
633
674
  local function delayHealthChecksCallback(unit)
634
- local counter = (unit[103] or 0) - 1
675
+ local counter = (unit[104] or 0) - 1
635
676
  if counter ~= 0 then
636
- unit[103] = counter
677
+ unit[104] = counter
637
678
  return
638
679
  end
639
- unit[103] = nil
640
- local healthBonus = unit[104]
680
+ unit[104] = nil
681
+ local healthBonus = unit[105]
641
682
  if healthBonus ~= nil then
642
- unit[104] = nil
683
+ unit[105] = nil
643
684
  local handle = unit.handle
644
685
  BlzSetUnitMaxHP(
645
686
  handle,
@@ -650,48 +691,71 @@ end
650
691
  local nextSyncId = 1
651
692
  local unitBySyncId = setmetatable({}, {__mode = "v"})
652
693
  local damagingEventByTarget = setmetatable({}, {__mode = "k"})
694
+ local function addAbility(unit, abilityTypeId)
695
+ local ____unitAddAbility_result_0
696
+ if unitAddAbility(unit, abilityTypeId) then
697
+ ____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
698
+ else
699
+ ____unitAddAbility_result_0 = nil
700
+ end
701
+ return ____unitAddAbility_result_0
702
+ end
653
703
  ____exports.Unit = __TS__Class()
654
704
  local Unit = ____exports.Unit
655
705
  Unit.name = "Unit"
656
706
  __TS__ClassExtends(Unit, Handle)
657
707
  function Unit.prototype.____constructor(self, handle)
658
708
  Handle.prototype.____constructor(self, handle)
659
- local ____nextSyncId_0 = nextSyncId
660
- nextSyncId = ____nextSyncId_0 + 1
661
- self.syncId = ____nextSyncId_0
709
+ local ____nextSyncId_1 = nextSyncId
710
+ nextSyncId = ____nextSyncId_1 + 1
711
+ self.syncId = ____nextSyncId_1
662
712
  self._owner = Player:of(getOwningPlayer(handle))
663
- assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
664
- assert(unitAddAbility(handle, morphDetectAbilityId))
713
+ assert(
714
+ unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId),
715
+ "leave detection ability must be added",
716
+ self
717
+ )
718
+ assert(
719
+ unitAddAbility(handle, morphDetectAbilityId),
720
+ "morph detection ability must be added",
721
+ self
722
+ )
665
723
  if unitAddAbility(
666
724
  handle,
667
725
  fourCC("Amrf")
668
726
  ) then
669
- assert(unitRemoveAbility(
670
- handle,
671
- fourCC("Amrf")
672
- ))
727
+ assert(
728
+ unitRemoveAbility(
729
+ handle,
730
+ fourCC("Amrf")
731
+ ),
732
+ "fly ability must be removed after addition",
733
+ self
734
+ )
673
735
  end
674
736
  unitBySyncId[self.syncId] = self
675
737
  local ____ = self.abilities
676
738
  end
677
- function Unit.prototype.getEvent(self, event, collector)
678
- self.events = self.events or ({})
679
- local eventId = GetHandleId(event)
680
- if not self.events[eventId] then
681
- self.events[eventId] = __TS__New(
739
+ function Unit.prototype.getEvent(self, jevent, collector)
740
+ self.events = self.events or __TS__New(LinkedMap)
741
+ local eventId = GetHandleId(jevent)
742
+ local event = self.events:get(eventId)
743
+ if event == nil then
744
+ event = __TS__New(
682
745
  TriggerEvent,
683
746
  function(trigger)
684
- TriggerRegisterUnitEvent(trigger, self.handle, event)
747
+ TriggerRegisterUnitEvent(trigger, self.handle, jevent)
685
748
  end,
686
749
  collector or (function() return {} end)
687
750
  )
751
+ self.events:put(eventId, event)
688
752
  end
689
- return self.events[eventId]
753
+ return event
690
754
  end
691
755
  function Unit.prototype.onDestroy(self)
692
756
  local handle = self.handle
693
- self[107] = getUnitX(handle)
694
- self[108] = getUnitY(handle)
757
+ self[108] = getUnitX(handle)
758
+ self[109] = getUnitY(handle)
695
759
  if not self._owner then
696
760
  self._owner = Player:of(getOwningPlayer(handle))
697
761
  end
@@ -730,7 +794,11 @@ function Unit.prototype.addAttackHandler(self, condition, action)
730
794
  self._attackHandlers = handlers
731
795
  if #handlers == 1 then
732
796
  local handle = self.handle
733
- assert(unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId))
797
+ assert(
798
+ unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
799
+ "attack handler ability must be added",
800
+ self
801
+ )
734
802
  end
735
803
  return handler
736
804
  end
@@ -759,17 +827,17 @@ function Unit.prototype.addModifier(self, property, modifier)
759
827
  end}
760
828
  end
761
829
  function Unit.prototype.hasCombatClassification(self, combatClassification)
762
- local ____combatClassification_1 = combatClassification
763
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
830
+ local ____combatClassification_2 = combatClassification
831
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
764
832
  end
765
833
  function Unit.prototype.addClassification(self, classification)
766
- return unitAddType(self.handle, classification)
834
+ return UnitAddType(self.handle, classification)
767
835
  end
768
836
  function Unit.prototype.removeClassification(self, classification)
769
- return unitRemoveType(self.handle, classification)
837
+ return UnitRemoveType(self.handle, classification)
770
838
  end
771
839
  function Unit.prototype.hasClassification(self, classification)
772
- return isUnitType(self.handle, classification)
840
+ return IsUnitType(self.handle, classification)
773
841
  end
774
842
  function Unit.prototype.isVisibleTo(self, player)
775
843
  return isUnitVisible(self.handle, player.handle)
@@ -778,13 +846,13 @@ function Unit.prototype.isInvisibleTo(self, player)
778
846
  return isUnitInvisible(self.handle, player.handle)
779
847
  end
780
848
  function Unit.prototype.isInRangeOf(self, x, y, range)
781
- local ____temp_2
849
+ local ____temp_3
782
850
  if type(x) == "number" then
783
- ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
851
+ ____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
784
852
  else
785
- ____temp_2 = isUnitInRange(self.handle, x.handle, y)
853
+ ____temp_3 = isUnitInRange(self.handle, x.handle, y)
786
854
  end
787
- return ____temp_2
855
+ return ____temp_3
788
856
  end
789
857
  function Unit.prototype.isAllyOf(self, unit)
790
858
  return isUnitAlly(
@@ -808,13 +876,24 @@ function Unit.prototype.playAnimation(self, animation, rarity)
808
876
  end
809
877
  end
810
878
  function Unit.prototype.resetAnimation(self)
811
- resetUnitAnimation(self.handle)
879
+ ResetUnitAnimation(self.handle)
812
880
  end
813
881
  function Unit.prototype.queueAnimation(self, animation)
814
- queueUnitAnimation(self.handle, animation)
882
+ QueueUnitAnimation(self.handle, animation)
883
+ end
884
+ function Unit.prototype.chooseWeapon(self, target)
885
+ local firstWeapon = self.firstWeapon
886
+ if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
887
+ return firstWeapon
888
+ end
889
+ local secondWeapon = self.secondWeapon
890
+ if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
891
+ return secondWeapon
892
+ end
893
+ return nil
815
894
  end
816
895
  function Unit.prototype.delayHealthChecks(self)
817
- self[103] = (self[103] or 0) + 1
896
+ self[104] = (self[104] or 0) + 1
818
897
  Timer:run(delayHealthChecksCallback, self)
819
898
  end
820
899
  function Unit.prototype.setPosition(self, x, y)
@@ -831,14 +910,14 @@ function Unit.prototype.kill(self)
831
910
  killUnit(self.handle)
832
911
  end
833
912
  function Unit.prototype.revive(self, x, y, doEffect)
834
- local ____ReviveHero_5 = ReviveHero
835
- local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
836
- local ____doEffect_3 = doEffect
837
- if ____doEffect_3 == nil then
838
- ____doEffect_3 = false
913
+ local ____ReviveHero_6 = ReviveHero
914
+ local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
915
+ local ____doEffect_4 = doEffect
916
+ if ____doEffect_4 == nil then
917
+ ____doEffect_4 = false
839
918
  end
840
- __TS__SparseArrayPush(____array_4, ____doEffect_3)
841
- ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
919
+ __TS__SparseArrayPush(____array_5, ____doEffect_4)
920
+ ____ReviveHero_6(__TS__SparseArraySpread(____array_5))
842
921
  end
843
922
  function Unit.prototype.healTarget(self, target, amount)
844
923
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -881,17 +960,16 @@ function Unit.prototype.itemInSlot(self, slot)
881
960
  return Item:of(unitItemInSlot(self.handle, slot))
882
961
  end
883
962
  function Unit.prototype.addAbility(self, abilityId)
884
- if unitAddAbility(self.handle, abilityId) then
885
- local ability = UnitAbility:of(
886
- checkNotNull(getUnitAbility(self.handle, abilityId)),
887
- abilityId,
888
- self
889
- )
963
+ local ability = UnitAbility:of(
964
+ doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
965
+ abilityId,
966
+ self
967
+ )
968
+ if ability ~= nil then
890
969
  local abilities = self.abilities
891
970
  abilities[#abilities + 1] = ability
892
- return ability
893
971
  end
894
- return nil
972
+ return ability
895
973
  end
896
974
  function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
897
975
  return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
@@ -905,31 +983,21 @@ end
905
983
  function Unit.prototype.hasAbility(self, abilityId)
906
984
  return getUnitAbilityLevel(self.handle, abilityId) > 0
907
985
  end
908
- function Unit.prototype.getAbilityById(self, abilityId)
909
- local handle = self.handle
910
- if unitAddAbility(handle, abilityId) then
911
- assert(unitRemoveAbility(handle, abilityId))
912
- return nil
913
- end
914
- return UnitAbility:of(
915
- getUnitAbility(self.handle, abilityId),
916
- abilityId,
917
- self
918
- )
986
+ function Unit.prototype.getAbility(self, abilityId)
987
+ local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
988
+ return UnitAbility:of(ability, abilityId, self)
919
989
  end
920
- function Unit.prototype.removeAbility(self, abilityId)
921
- if unitRemoveAbility(self.handle, abilityId) then
922
- local abilities = self.abilities
923
- for i = 1, #abilities do
924
- if abilities[i].typeId == abilityId then
925
- abilities[i]:destroy()
926
- tremove(abilities, i)
927
- return true
928
- end
990
+ function Unit.prototype.removeAbility(self, abilityTypeId)
991
+ local abilities = self.abilities
992
+ for i = 1, #abilities do
993
+ if abilities[i].typeId == abilityTypeId then
994
+ local ability = abilities[i]
995
+ tremove(abilities, i)
996
+ ability:destroy()
997
+ return true
929
998
  end
930
- return true
931
999
  end
932
- return false
1000
+ return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
933
1001
  end
934
1002
  function Unit.prototype.hideAbility(self, abilityId, flag)
935
1003
  BlzUnitHideAbility(self.handle, abilityId, flag)
@@ -943,9 +1011,6 @@ end
943
1011
  function Unit.prototype.endAbilityCooldown(self, abilityId)
944
1012
  BlzEndUnitAbilityCooldown(self.handle, abilityId)
945
1013
  end
946
- function Unit.prototype.interruptAttack(self)
947
- unitInterruptAttack(self.handle)
948
- end
949
1014
  function Unit.prototype.interruptCast(self, abilityId)
950
1015
  local handle = self.handle
951
1016
  unitDisableAbility(handle, abilityId, true, false)
@@ -1016,18 +1081,44 @@ function Unit.prototype.unpauseEx(self)
1016
1081
  end
1017
1082
  function Unit.prototype.incrementStunCounter(self)
1018
1083
  local stunCounter = self[102] or 0
1019
- if not self[101] or stunCounter >= 0 then
1084
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
1020
1085
  BlzPauseUnitEx(self.handle, true)
1021
1086
  end
1022
1087
  self[102] = stunCounter + 1
1023
1088
  end
1024
1089
  function Unit.prototype.decrementStunCounter(self)
1025
1090
  local stunCounter = self[102] or 0
1026
- if not self[101] or stunCounter >= 1 then
1091
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
1027
1092
  BlzPauseUnitEx(self.handle, false)
1028
1093
  end
1029
1094
  self[102] = stunCounter - 1
1030
1095
  end
1096
+ function Unit.prototype.incrementForceStunCounter(self)
1097
+ local forceStunCounter = self[103] or 0
1098
+ if forceStunCounter == 0 then
1099
+ local handle = self.handle
1100
+ if not self[101] then
1101
+ for _ = self[102] or 0, -1 do
1102
+ BlzPauseUnitEx(handle, true)
1103
+ end
1104
+ end
1105
+ BlzPauseUnitEx(handle, true)
1106
+ end
1107
+ self[103] = forceStunCounter + 1
1108
+ end
1109
+ function Unit.prototype.decrementForceStunCounter(self)
1110
+ local forceStunCounter = self[103] or 0
1111
+ if forceStunCounter == 1 then
1112
+ local handle = self.handle
1113
+ if not self[101] then
1114
+ for _ = self[102] or 0, -1 do
1115
+ BlzPauseUnitEx(handle, false)
1116
+ end
1117
+ end
1118
+ BlzPauseUnitEx(handle, false)
1119
+ end
1120
+ self[103] = forceStunCounter - 1
1121
+ end
1031
1122
  function Unit.create(self, owner, id, x, y, facing, skinId)
1032
1123
  local handle = skinId and BlzCreateUnitWithSkin(
1033
1124
  owner.handle,
@@ -1216,7 +1307,7 @@ __TS__SetDescriptor(
1216
1307
  Unit.prototype,
1217
1308
  "isIllusion",
1218
1309
  {get = function(self)
1219
- return isUnitIllusion(self.handle)
1310
+ return IsUnitIllusion(self.handle)
1220
1311
  end},
1221
1312
  true
1222
1313
  )
@@ -1314,19 +1405,6 @@ __TS__SetDescriptor(
1314
1405
  },
1315
1406
  true
1316
1407
  )
1317
- __TS__SetDescriptor(
1318
- Unit.prototype,
1319
- "strengthBase",
1320
- {
1321
- get = function(self)
1322
- return getHeroStr(self.handle, false)
1323
- end,
1324
- set = function(self, strengthBase)
1325
- setHeroStr(self.handle, strengthBase, true)
1326
- end
1327
- },
1328
- true
1329
- )
1330
1408
  __TS__SetDescriptor(
1331
1409
  Unit.prototype,
1332
1410
  "strengthBonus",
@@ -1344,19 +1422,6 @@ __TS__SetDescriptor(
1344
1422
  end},
1345
1423
  true
1346
1424
  )
1347
- __TS__SetDescriptor(
1348
- Unit.prototype,
1349
- "agilityBase",
1350
- {
1351
- get = function(self)
1352
- return getHeroAgi(self.handle, false)
1353
- end,
1354
- set = function(self, agilityBase)
1355
- setHeroAgi(self.handle, agilityBase, true)
1356
- end
1357
- },
1358
- true
1359
- )
1360
1425
  __TS__SetDescriptor(
1361
1426
  Unit.prototype,
1362
1427
  "agilityBonus",
@@ -1374,19 +1439,6 @@ __TS__SetDescriptor(
1374
1439
  end},
1375
1440
  true
1376
1441
  )
1377
- __TS__SetDescriptor(
1378
- Unit.prototype,
1379
- "intelligenceBase",
1380
- {
1381
- get = function(self)
1382
- return getHeroInt(self.handle, false)
1383
- end,
1384
- set = function(self, intelligenceBase)
1385
- setHeroInt(self.handle, intelligenceBase, true)
1386
- end
1387
- },
1388
- true
1389
- )
1390
1442
  __TS__SetDescriptor(
1391
1443
  Unit.prototype,
1392
1444
  "intelligenceBonus",
@@ -1435,17 +1487,17 @@ __TS__SetDescriptor(
1435
1487
  "isTeamGlowVisible",
1436
1488
  {
1437
1489
  get = function(self)
1438
- return not self[106]
1490
+ return not self[107]
1439
1491
  end,
1440
1492
  set = function(self, isTeamGlowVisible)
1441
1493
  BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1442
- local ____temp_6
1494
+ local ____temp_7
1443
1495
  if not isTeamGlowVisible then
1444
- ____temp_6 = true
1496
+ ____temp_7 = true
1445
1497
  else
1446
- ____temp_6 = nil
1498
+ ____temp_7 = nil
1447
1499
  end
1448
- self[106] = ____temp_6
1500
+ self[107] = ____temp_7
1449
1501
  end
1450
1502
  },
1451
1503
  true
@@ -1455,7 +1507,7 @@ __TS__SetDescriptor(
1455
1507
  "color",
1456
1508
  {set = function(self, color)
1457
1509
  SetUnitColor(self.handle, color.handle)
1458
- if self[106] then
1510
+ if self[107] then
1459
1511
  BlzShowUnitTeamGlow(self.handle, false)
1460
1512
  end
1461
1513
  end},
@@ -1479,14 +1531,14 @@ __TS__SetDescriptor(
1479
1531
  "maxHealth",
1480
1532
  {
1481
1533
  get = function(self)
1482
- return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1534
+ return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
1483
1535
  end,
1484
1536
  set = function(self, maxHealth)
1485
- if maxHealth < 1 and self[103] ~= nil then
1486
- self[104] = (self[104] or 0) + (1 - maxHealth)
1537
+ if maxHealth < 1 and self[104] ~= nil then
1538
+ self[105] = (self[105] or 0) + (1 - maxHealth)
1487
1539
  maxHealth = 1
1488
1540
  end
1489
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1541
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
1490
1542
  end
1491
1543
  },
1492
1544
  true
@@ -1528,10 +1580,10 @@ __TS__SetDescriptor(
1528
1580
  "health",
1529
1581
  {
1530
1582
  get = function(self)
1531
- return GetWidgetLife(self.handle) - (self[105] or 0)
1583
+ return GetWidgetLife(self.handle) - (self[106] or 0)
1532
1584
  end,
1533
1585
  set = function(self, health)
1534
- SetWidgetLife(self.handle, health + (self[105] or 0))
1586
+ SetWidgetLife(self.handle, health + (self[106] or 0))
1535
1587
  end
1536
1588
  },
1537
1589
  true
@@ -1607,25 +1659,12 @@ __TS__SetDescriptor(
1607
1659
  },
1608
1660
  true
1609
1661
  )
1610
- __TS__SetDescriptor(
1611
- Unit.prototype,
1612
- "flyHeight",
1613
- {
1614
- get = function(self)
1615
- return getUnitFlyHeight(self.handle)
1616
- end,
1617
- set = function(self, v)
1618
- SetUnitFlyHeight(self.handle, v, 100000)
1619
- end
1620
- },
1621
- true
1622
- )
1623
1662
  __TS__SetDescriptor(
1624
1663
  Unit.prototype,
1625
1664
  "x",
1626
1665
  {
1627
1666
  get = function(self)
1628
- return self[107] or getUnitX(self.handle)
1667
+ return self[108] or getUnitX(self.handle)
1629
1668
  end,
1630
1669
  set = function(self, v)
1631
1670
  SetUnitX(self.handle, v)
@@ -1638,7 +1677,7 @@ __TS__SetDescriptor(
1638
1677
  "y",
1639
1678
  {
1640
1679
  get = function(self)
1641
- return self[108] or getUnitY(self.handle)
1680
+ return self[109] or getUnitY(self.handle)
1642
1681
  end,
1643
1682
  set = function(self, v)
1644
1683
  SetUnitY(self.handle, v)
@@ -1743,14 +1782,18 @@ __TS__SetDescriptor(
1743
1782
  local handle = self.handle
1744
1783
  if isPaused and not IsUnitPaused(handle) then
1745
1784
  self[101] = true
1746
- for _ = self[102] or 0, -1 do
1747
- BlzPauseUnitEx(handle, true)
1785
+ if (self[103] or 0) <= 0 then
1786
+ for _ = self[102] or 0, -1 do
1787
+ BlzPauseUnitEx(handle, true)
1788
+ end
1748
1789
  end
1749
1790
  PauseUnit(handle, true)
1750
1791
  elseif not isPaused and IsUnitPaused(handle) then
1751
1792
  PauseUnit(handle, false)
1752
- for _ = self[102] or 0, -1 do
1753
- BlzPauseUnitEx(handle, false)
1793
+ if (self[103] or 0) <= 0 then
1794
+ for _ = self[102] or 0, -1 do
1795
+ BlzPauseUnitEx(handle, false)
1796
+ end
1754
1797
  end
1755
1798
  self[101] = nil
1756
1799
  end
@@ -1808,20 +1851,6 @@ __TS__SetDescriptor(
1808
1851
  },
1809
1852
  true
1810
1853
  )
1811
- __TS__SetDescriptor(
1812
- Unit.prototype,
1813
- "scale",
1814
- {
1815
- get = function(self)
1816
- return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
1817
- end,
1818
- set = function(self, v)
1819
- setUnitScale(self.handle, v, v, v)
1820
- setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
1821
- end
1822
- },
1823
- true
1824
- )
1825
1854
  __TS__SetDescriptor(
1826
1855
  Unit.prototype,
1827
1856
  "timeScale",
@@ -2049,6 +2078,14 @@ __TS__SetDescriptor(
2049
2078
  end},
2050
2079
  true
2051
2080
  )
2081
+ __TS__SetDescriptor(
2082
+ Unit.prototype,
2083
+ "targetAcquiredEvent",
2084
+ {get = function(self)
2085
+ return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
2086
+ end},
2087
+ true
2088
+ )
2052
2089
  __TS__SetDescriptor(
2053
2090
  Unit.prototype,
2054
2091
  "onSelect",
@@ -2109,6 +2146,11 @@ __TS__SetDescriptor(
2109
2146
  end},
2110
2147
  true
2111
2148
  )
2149
+ Unit.levelChangedEvent = __TS__New(
2150
+ ____exports.UnitTriggerEvent,
2151
+ EVENT_PLAYER_HERO_LEVEL,
2152
+ function() return ____exports.Unit:of(getTriggerUnit()) end
2153
+ )
2112
2154
  Unit.deathEvent = __TS__New(
2113
2155
  ____exports.UnitTriggerEvent,
2114
2156
  EVENT_PLAYER_UNIT_DEATH,
@@ -2184,25 +2226,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2184
2226
  InitializingEvent,
2185
2227
  function(event)
2186
2228
  local function listener(unit, id)
2187
- local ____GetSpellTargetUnit_result_9
2229
+ local ____GetSpellTargetUnit_result_10
2188
2230
  if GetSpellTargetUnit() then
2189
- ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2231
+ ____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
2190
2232
  else
2191
- local ____GetSpellTargetItem_result_8
2233
+ local ____GetSpellTargetItem_result_9
2192
2234
  if GetSpellTargetItem() then
2193
- ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2235
+ ____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
2194
2236
  else
2195
- local ____GetSpellTargetDestructable_result_7
2237
+ local ____GetSpellTargetDestructable_result_8
2196
2238
  if GetSpellTargetDestructable() then
2197
- ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2239
+ ____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
2198
2240
  else
2199
- ____GetSpellTargetDestructable_result_7 = nil
2241
+ ____GetSpellTargetDestructable_result_8 = nil
2200
2242
  end
2201
- ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2243
+ ____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
2202
2244
  end
2203
- ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2245
+ ____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
2204
2246
  end
2205
- local target = ____GetSpellTargetUnit_result_9
2247
+ local target = ____GetSpellTargetUnit_result_10
2206
2248
  if target then
2207
2249
  invoke(event, unit, id, target)
2208
2250
  end
@@ -2421,15 +2463,11 @@ Unit.onDamaging = (function()
2421
2463
  metadata = metadata,
2422
2464
  isAttack = BlzGetEventIsAttack(),
2423
2465
  originalAmount = GetEventDamage(),
2424
- originalMetadata = metadata
2466
+ originalMetadata = metadata,
2467
+ preventRetaliation = damagingEventPreventRetaliation
2425
2468
  }
2426
2469
  if data.isAttack and source then
2427
- 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
2428
- if weapon == -1 then
2429
- local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
2430
- weapon = 0
2431
- end
2432
- data.weapon = assert(source.weapons[weapon + 1])
2470
+ data.weapon = source:chooseWeapon(target)
2433
2471
  end
2434
2472
  if not data.isAttack or not source or not source._attackHandlers then
2435
2473
  invoke(
@@ -2450,6 +2488,20 @@ Unit.onDamaging = (function()
2450
2488
  }
2451
2489
  )
2452
2490
  )
2491
+ if data[0] and source then
2492
+ local sourceOwner = source.owner.handle
2493
+ data[1] = sourceOwner
2494
+ local targetOwner = target.owner.handle
2495
+ data[2] = targetOwner
2496
+ if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2497
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2498
+ data[3] = true
2499
+ end
2500
+ if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
2501
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
2502
+ data[4] = true
2503
+ end
2504
+ end
2453
2505
  damagingEventByTarget[target] = data
2454
2506
  return
2455
2507
  end
@@ -2533,6 +2585,16 @@ Unit.onDamage = __TS__New(
2533
2585
  data[key] = value
2534
2586
  end
2535
2587
  end
2588
+ local sourceOwner = damagingEvent[1]
2589
+ if sourceOwner then
2590
+ local targetOwner = damagingEvent[2]
2591
+ if damagingEvent[3] then
2592
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
2593
+ end
2594
+ if damagingEvent[4] then
2595
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
2596
+ end
2597
+ end
2536
2598
  end
2537
2599
  local evData = setmetatable(
2538
2600
  {},
@@ -2550,7 +2612,7 @@ Unit.onDamage = __TS__New(
2550
2612
  invoke(event, source, target, evData)
2551
2613
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2552
2614
  local bonusHealth = math.ceil(evData.amount)
2553
- target[105] = (target[105] or 0) + bonusHealth
2615
+ target[106] = (target[106] or 0) + bonusHealth
2554
2616
  BlzSetUnitMaxHP(
2555
2617
  target.handle,
2556
2618
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2564,7 +2626,7 @@ Unit.onDamage = __TS__New(
2564
2626
  evData[0],
2565
2627
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2566
2628
  )
2567
- target[105] = (target[105] or 0) - bonusHealth
2629
+ target[106] = (target[106] or 0) - bonusHealth
2568
2630
  SetWidgetLife(
2569
2631
  target.handle,
2570
2632
  GetWidgetLife(target.handle) - bonusHealth
@@ -2600,10 +2662,14 @@ Unit.itemPickedUpEvent = __TS__New(
2600
2662
  ____exports.UnitTriggerEvent,
2601
2663
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2602
2664
  function()
2603
- local unit = getTriggerUnit()
2604
- local item = getManipulatedItem()
2605
- if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2606
- return ____exports.Unit:of(unit), Item:of(item)
2665
+ local unitHandle = getTriggerUnit()
2666
+ local itemHandle = getManipulatedItem()
2667
+ if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
2668
+ local unit = ____exports.Unit:of(unitHandle)
2669
+ local item = Item:of(itemHandle)
2670
+ if item.owner ~= unit then
2671
+ return unit, item
2672
+ end
2607
2673
  end
2608
2674
  return IgnoreEvent
2609
2675
  end
@@ -2623,7 +2689,22 @@ Unit.itemUsedEvent = __TS__New(
2623
2689
  Unit.itemStackedEvent = __TS__New(
2624
2690
  ____exports.UnitTriggerEvent,
2625
2691
  EVENT_PLAYER_UNIT_STACK_ITEM,
2626
- function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2692
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
2693
+ )
2694
+ __TS__ObjectDefineProperty(
2695
+ Unit,
2696
+ "itemChargesChangedEvent",
2697
+ {get = function(self)
2698
+ local event = __TS__New(Event)
2699
+ Item.chargesChangedEvent:addListener(function(item)
2700
+ local unit = item.owner
2701
+ if unit ~= nil then
2702
+ invoke(event, unit, item)
2703
+ end
2704
+ end)
2705
+ rawset(self, "itemChargesChangedEvent", event)
2706
+ return event
2707
+ end}
2627
2708
  )
2628
2709
  __TS__ObjectDefineProperty(
2629
2710
  Unit,
@@ -2695,6 +2776,10 @@ __TS__ObjectDefineProperty(
2695
2776
  rawset(self, "destroyEvent", destroyEvent)
2696
2777
  return destroyEvent
2697
2778
  end}
2779
+ )
2780
+ Unit.synchronize = synchronizer(
2781
+ function(unit) return unit.syncId end,
2782
+ function(syncId) return unitBySyncId[syncId] end
2698
2783
  );
2699
2784
  (function(self)
2700
2785
  local leaveAbilityIds = postcompile(function()