warscript 0.0.1-dev.7912f28 → 0.0.1-dev.796a720

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 (169) hide show
  1. package/attributes.d.ts +5 -0
  2. package/attributes.lua +8 -1
  3. package/config.d.ts +5 -0
  4. package/config.lua +10 -0
  5. package/core/types/effect.d.ts +1 -3
  6. package/core/types/effect.lua +26 -29
  7. package/core/types/frame.lua +24 -21
  8. package/core/types/player.lua +3 -1
  9. package/core/types/playerCamera.d.ts +2 -0
  10. package/core/types/playerCamera.lua +123 -5
  11. package/core/types/sound.d.ts +17 -24
  12. package/core/types/sound.lua +99 -24
  13. package/core/types/tileCell.d.ts +9 -0
  14. package/core/types/tileCell.lua +92 -0
  15. package/core/types/timer.d.ts +9 -8
  16. package/core/types/timer.lua +45 -23
  17. package/core/util.lua +6 -1
  18. package/decl/native.d.ts +846 -790
  19. package/engine/behavior.d.ts +5 -0
  20. package/engine/behavior.lua +106 -27
  21. package/engine/behaviour/ability/apply-buff.d.ts +5 -0
  22. package/engine/behaviour/ability/apply-buff.lua +32 -0
  23. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  24. package/engine/behaviour/ability/damage.d.ts +9 -3
  25. package/engine/behaviour/ability/damage.lua +26 -38
  26. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  27. package/engine/behaviour/ability/emulate-impact.lua +18 -3
  28. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  29. package/engine/behaviour/ability/restore-mana.lua +6 -6
  30. package/engine/behaviour/ability.d.ts +7 -2
  31. package/engine/behaviour/ability.lua +42 -24
  32. package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
  33. package/engine/behaviour/unit/stun-immunity.lua +52 -27
  34. package/engine/behaviour/unit.d.ts +34 -0
  35. package/engine/behaviour/unit.lua +190 -4
  36. package/engine/buff.d.ts +57 -44
  37. package/engine/buff.lua +273 -221
  38. package/engine/internal/ability.d.ts +7 -1
  39. package/engine/internal/ability.lua +49 -9
  40. package/engine/internal/item/ability.lua +63 -11
  41. package/engine/internal/item+owner.lua +12 -6
  42. package/engine/internal/item.d.ts +20 -19
  43. package/engine/internal/item.lua +191 -74
  44. package/engine/internal/mechanics/ability-duration.lua +1 -1
  45. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  46. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  47. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  48. package/engine/internal/misc/frame-coordinates.lua +21 -0
  49. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  50. package/engine/internal/misc/get-terrain-z.lua +11 -0
  51. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  52. package/engine/internal/misc/player-local-handle.lua +5 -0
  53. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  54. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  55. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  56. package/engine/internal/object-data/evasion-probability.lua +16 -0
  57. package/engine/internal/unit/ability.d.ts +35 -0
  58. package/engine/internal/unit/ability.lua +98 -9
  59. package/engine/internal/unit/add-item-to-slot.lua +4 -2
  60. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  61. package/engine/internal/unit/allowed-targets.lua +9 -1
  62. package/engine/internal/unit/bonus.d.ts +2 -0
  63. package/engine/internal/unit/bonus.lua +17 -0
  64. package/engine/internal/unit/order.d.ts +20 -0
  65. package/engine/internal/unit/order.lua +136 -0
  66. package/engine/internal/unit+ability.lua +10 -1
  67. package/engine/internal/unit+damage.d.ts +2 -11
  68. package/engine/internal/unit+damage.lua +10 -14
  69. package/engine/internal/unit+spellSteal.lua +1 -2
  70. package/engine/internal/unit-missile-launch.lua +42 -14
  71. package/engine/internal/unit.d.ts +32 -10
  72. package/engine/internal/unit.lua +259 -111
  73. package/engine/lightning.d.ts +12 -5
  74. package/engine/lightning.lua +48 -14
  75. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  76. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  77. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  78. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  79. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  80. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  81. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  82. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  83. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  84. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  85. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  86. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  87. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  88. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  89. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  90. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  91. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  92. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  93. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  94. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  95. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  96. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  97. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  98. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  99. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  100. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  101. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  102. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  103. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  104. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  105. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  106. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  107. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  108. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  109. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  110. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  111. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  112. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  113. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  114. package/engine/object-data/entry/ability-type/web.lua +52 -0
  115. package/engine/object-data/entry/ability-type.d.ts +19 -17
  116. package/engine/object-data/entry/ability-type.lua +85 -24
  117. package/engine/object-data/entry/buff-type/applicable.lua +18 -37
  118. package/engine/object-data/entry/buff-type.d.ts +6 -12
  119. package/engine/object-data/entry/buff-type.lua +13 -29
  120. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  121. package/engine/object-data/entry/item-type.d.ts +1 -1
  122. package/engine/object-data/entry/item-type.lua +4 -4
  123. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  124. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  125. package/engine/object-data/entry/sound-preset.lua +140 -0
  126. package/engine/object-data/entry/unit-type.d.ts +21 -5
  127. package/engine/object-data/entry/unit-type.lua +214 -93
  128. package/engine/object-data/entry/upgrade.d.ts +1 -1
  129. package/engine/object-data/entry/upgrade.lua +4 -4
  130. package/engine/object-data/entry.d.ts +16 -14
  131. package/engine/object-data/entry.lua +60 -32
  132. package/engine/object-field/ability.d.ts +4 -4
  133. package/engine/object-field/ability.lua +7 -6
  134. package/engine/object-field/unit.d.ts +57 -3
  135. package/engine/object-field/unit.lua +207 -7
  136. package/engine/object-field.d.ts +17 -6
  137. package/engine/object-field.lua +188 -92
  138. package/engine/random.d.ts +9 -0
  139. package/engine/random.lua +13 -0
  140. package/engine/standard/entries/buff-type.d.ts +3 -0
  141. package/engine/standard/entries/buff-type.lua +3 -0
  142. package/engine/standard/entries/sound-preset.d.ts +10 -0
  143. package/engine/standard/entries/sound-preset.lua +10 -0
  144. package/engine/standard/fields/unit.d.ts +4 -0
  145. package/engine/standard/fields/unit.lua +7 -0
  146. package/engine/text-tag.d.ts +36 -2
  147. package/engine/text-tag.lua +249 -10
  148. package/engine/unit.d.ts +1 -0
  149. package/engine/unit.lua +1 -0
  150. package/objutil/buff.lua +2 -3
  151. package/objutil/unit.lua +8 -0
  152. package/package.json +2 -2
  153. package/patch-lualib.lua +1 -1
  154. package/utility/arrays.d.ts +2 -0
  155. package/utility/arrays.lua +11 -0
  156. package/utility/callback-array.d.ts +17 -0
  157. package/utility/callback-array.lua +61 -0
  158. package/utility/functions.d.ts +8 -0
  159. package/utility/functions.lua +13 -0
  160. package/utility/linked-set.d.ts +1 -0
  161. package/utility/linked-set.lua +5 -1
  162. package/utility/lua-maps.d.ts +15 -2
  163. package/utility/lua-maps.lua +53 -2
  164. package/utility/lua-sets.d.ts +2 -0
  165. package/utility/lua-sets.lua +7 -0
  166. package/utility/reflection.lua +11 -7
  167. package/utility/types.d.ts +3 -0
  168. package/core/types/order.d.ts +0 -25
  169. package/core/types/order.lua +0 -55
@@ -53,12 +53,19 @@ local ____math = require("math")
53
53
  local min = ____math.min
54
54
  local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
55
55
  local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
56
+ local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
57
+ local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
58
+ local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
59
+ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
60
+ local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
61
+ local ____attributes = require("attributes")
62
+ local isAttribute = ____attributes.isAttribute
63
+ local ____ability = require("engine.internal.item.ability")
64
+ local doUnitAbilityAction = ____ability.doUnitAbilityAction
56
65
  local match = string.match
57
66
  local ____tostring = _G.tostring
58
67
  local setUnitAnimation = SetUnitAnimation
59
- local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
60
68
  local setUnitAnimationByIndex = SetUnitAnimationByIndex
61
- local queueUnitAnimation = QueueUnitAnimation
62
69
  local getUnitIntegerField = BlzGetUnitIntegerField
63
70
  local getUnitRealField = BlzGetUnitRealField
64
71
  local getHeroStr = GetHeroStr
@@ -77,9 +84,9 @@ local setUnitScale = SetUnitScale
77
84
  local setUnitPosition = SetUnitPosition
78
85
  local setUnitTimeScale = SetUnitTimeScale
79
86
  local getHandleId = GetHandleId
87
+ local getUnitCurrentOrder = GetUnitCurrentOrder
80
88
  local createUnit = CreateUnit
81
89
  local killUnit = KillUnit
82
- local setUnitExploded = SetUnitExploded
83
90
  local removeUnit = RemoveUnit
84
91
  local getUnitTypeId = GetUnitTypeId
85
92
  local isHeroUnitId = IsHeroUnitId
@@ -95,8 +102,6 @@ local getSpellTargetItem = GetSpellTargetItem
95
102
  local getSpellTargetDestructable = GetSpellTargetDestructable
96
103
  local isUnitInRangeXY = IsUnitInRangeXY
97
104
  local isUnitInRange = IsUnitInRange
98
- local setResourceAmount = SetResourceAmount
99
- local getResourceAmount = GetResourceAmount
100
105
  local getUnitWeaponRealField = BlzGetUnitWeaponRealField
101
106
  local setUnitWeaponRealField = BlzSetUnitWeaponRealField
102
107
  local getUnitWeaponStringField = BlzGetUnitWeaponStringField
@@ -120,15 +125,9 @@ local getOrderedUnit = GetOrderedUnit
120
125
  local getIssuedOrderId = GetIssuedOrderId
121
126
  local isUnitInvulnerable = BlzIsUnitInvulnerable
122
127
  local unitAlive = UnitAlive
123
- local unitAddType = UnitAddType
124
- local unitRemoveType = UnitRemoveType
125
- local isUnitIllusion = IsUnitIllusion
126
- local isUnitType = IsUnitType
127
128
  local isUnitAlly = IsUnitAlly
128
129
  local isUnitEnemy = IsUnitEnemy
129
130
  local getOwningPlayer = GetOwningPlayer
130
- local setUnitColor = SetUnitColor
131
- local showUnitTeamGlow = BlzShowUnitTeamGlow
132
131
  ____exports.UnitClassification = {}
133
132
  local UnitClassification = ____exports.UnitClassification
134
133
  do
@@ -138,6 +137,7 @@ do
138
137
  UnitClassification.GROUND = UNIT_TYPE_GROUND
139
138
  UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
140
139
  UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
140
+ UnitClassification.WORKER = UNIT_TYPE_PEON
141
141
  UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
142
142
  UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
143
143
  UnitClassification.TAUREN = UNIT_TYPE_TAUREN
@@ -345,6 +345,9 @@ local function dispatchAbility(event)
345
345
  }
346
346
  )
347
347
  end
348
+ local function damagingEventPreventRetaliation(self)
349
+ self[0] = true
350
+ end
348
351
  local function damageEventPreventDeath(self, callback, ...)
349
352
  if self[0] ~= nil then
350
353
  return
@@ -356,7 +359,14 @@ local function damageEventPreventDeath(self, callback, ...)
356
359
  rawset(self, 1 + i, (select(i, ...)))
357
360
  end
358
361
  end
359
- local damageSetters = {amount = BlzSetEventDamage, attackType = BlzSetEventAttackType, damageType = BlzSetEventDamageType, weaponType = BlzSetEventWeaponType}
362
+ local damageSetters = {
363
+ amount = BlzSetEventDamage,
364
+ attackType = function(attackType)
365
+ return BlzSetEventAttackType(attackTypeToNative(attackType))
366
+ end,
367
+ damageType = BlzSetEventDamageType,
368
+ weaponType = BlzSetEventWeaponType
369
+ }
360
370
  local jlimitopByOperator = {
361
371
  [0] = LESS_THAN_OR_EQUAL,
362
372
  [1] = LESS_THAN_OR_EQUAL,
@@ -434,6 +444,19 @@ __TS__SetDescriptor(
434
444
  },
435
445
  true
436
446
  )
447
+ __TS__SetDescriptor(
448
+ UnitWeapon.prototype,
449
+ "allowedTargetCombatClassifications",
450
+ {
451
+ get = function(self)
452
+ return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
453
+ end,
454
+ set = function(self, allowedTargetCombatClassifications)
455
+ BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
456
+ end
457
+ },
458
+ true
459
+ )
437
460
  __TS__SetDescriptor(
438
461
  UnitWeapon.prototype,
439
462
  "damageBase",
@@ -638,16 +661,26 @@ local function delayHealthChecksCallback(unit)
638
661
  end
639
662
  end
640
663
  local nextSyncId = 1
641
- local unitBySyncId = setmetatable({}, {__mode = "k"})
664
+ local unitBySyncId = setmetatable({}, {__mode = "v"})
665
+ local damagingEventByTarget = setmetatable({}, {__mode = "k"})
666
+ local function addAbility(unit, abilityTypeId)
667
+ local ____unitAddAbility_result_0
668
+ if unitAddAbility(unit, abilityTypeId) then
669
+ ____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
670
+ else
671
+ ____unitAddAbility_result_0 = nil
672
+ end
673
+ return ____unitAddAbility_result_0
674
+ end
642
675
  ____exports.Unit = __TS__Class()
643
676
  local Unit = ____exports.Unit
644
677
  Unit.name = "Unit"
645
678
  __TS__ClassExtends(Unit, Handle)
646
679
  function Unit.prototype.____constructor(self, handle)
647
680
  Handle.prototype.____constructor(self, handle)
648
- local ____nextSyncId_0 = nextSyncId
649
- nextSyncId = ____nextSyncId_0 + 1
650
- self.syncId = ____nextSyncId_0
681
+ local ____nextSyncId_1 = nextSyncId
682
+ nextSyncId = ____nextSyncId_1 + 1
683
+ self.syncId = ____nextSyncId_1
651
684
  self._owner = Player:of(getOwningPlayer(handle))
652
685
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
653
686
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -679,6 +712,8 @@ function Unit.prototype.getEvent(self, event, collector)
679
712
  end
680
713
  function Unit.prototype.onDestroy(self)
681
714
  local handle = self.handle
715
+ self[107] = getUnitX(handle)
716
+ self[108] = getUnitY(handle)
682
717
  if not self._owner then
683
718
  self._owner = Player:of(getOwningPlayer(handle))
684
719
  end
@@ -746,17 +781,17 @@ function Unit.prototype.addModifier(self, property, modifier)
746
781
  end}
747
782
  end
748
783
  function Unit.prototype.hasCombatClassification(self, combatClassification)
749
- local ____combatClassification_1 = combatClassification
750
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
784
+ local ____combatClassification_2 = combatClassification
785
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
751
786
  end
752
787
  function Unit.prototype.addClassification(self, classification)
753
- return unitAddType(self.handle, classification)
788
+ return UnitAddType(self.handle, classification)
754
789
  end
755
790
  function Unit.prototype.removeClassification(self, classification)
756
- return unitRemoveType(self.handle, classification)
791
+ return UnitRemoveType(self.handle, classification)
757
792
  end
758
793
  function Unit.prototype.hasClassification(self, classification)
759
- return isUnitType(self.handle, classification)
794
+ return IsUnitType(self.handle, classification)
760
795
  end
761
796
  function Unit.prototype.isVisibleTo(self, player)
762
797
  return isUnitVisible(self.handle, player.handle)
@@ -765,13 +800,13 @@ function Unit.prototype.isInvisibleTo(self, player)
765
800
  return isUnitInvisible(self.handle, player.handle)
766
801
  end
767
802
  function Unit.prototype.isInRangeOf(self, x, y, range)
768
- local ____temp_2
803
+ local ____temp_3
769
804
  if type(x) == "number" then
770
- ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
805
+ ____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
771
806
  else
772
- ____temp_2 = isUnitInRange(self.handle, x.handle, y)
807
+ ____temp_3 = isUnitInRange(self.handle, x.handle, y)
773
808
  end
774
- return ____temp_2
809
+ return ____temp_3
775
810
  end
776
811
  function Unit.prototype.isAllyOf(self, unit)
777
812
  return isUnitAlly(
@@ -789,13 +824,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
789
824
  if type(animation) == "number" then
790
825
  setUnitAnimationByIndex(self.handle, animation)
791
826
  elseif rarity then
792
- setUnitAnimationWithRarity(self.handle, animation, rarity)
827
+ SetUnitAnimationWithRarity(self.handle, animation, rarity)
793
828
  else
794
829
  setUnitAnimation(self.handle, animation)
795
830
  end
796
831
  end
832
+ function Unit.prototype.resetAnimation(self)
833
+ ResetUnitAnimation(self.handle)
834
+ end
797
835
  function Unit.prototype.queueAnimation(self, animation)
798
- queueUnitAnimation(self.handle, animation)
836
+ QueueUnitAnimation(self.handle, animation)
837
+ end
838
+ function Unit.prototype.chooseWeapon(self, target)
839
+ if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
840
+ return self.firstWeapon
841
+ end
842
+ if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
843
+ return self.secondWeapon
844
+ end
845
+ return nil
799
846
  end
800
847
  function Unit.prototype.delayHealthChecks(self)
801
848
  self[103] = (self[103] or 0) + 1
@@ -808,21 +855,21 @@ function Unit.prototype.isSelected(self, player)
808
855
  return IsUnitSelected(self.handle, player.handle)
809
856
  end
810
857
  function Unit.prototype.explode(self)
811
- setUnitExploded(self.handle, true)
858
+ SetUnitExploded(self.handle, true)
812
859
  killUnit(self.handle)
813
860
  end
814
861
  function Unit.prototype.kill(self)
815
862
  killUnit(self.handle)
816
863
  end
817
864
  function Unit.prototype.revive(self, x, y, doEffect)
818
- local ____ReviveHero_5 = ReviveHero
819
- local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
820
- local ____doEffect_3 = doEffect
821
- if ____doEffect_3 == nil then
822
- ____doEffect_3 = false
865
+ local ____ReviveHero_6 = ReviveHero
866
+ local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
867
+ local ____doEffect_4 = doEffect
868
+ if ____doEffect_4 == nil then
869
+ ____doEffect_4 = false
823
870
  end
824
- __TS__SparseArrayPush(____array_4, ____doEffect_3)
825
- ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
871
+ __TS__SparseArrayPush(____array_5, ____doEffect_4)
872
+ ____ReviveHero_6(__TS__SparseArraySpread(____array_5))
826
873
  end
827
874
  function Unit.prototype.healTarget(self, target, amount)
828
875
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -865,17 +912,16 @@ function Unit.prototype.itemInSlot(self, slot)
865
912
  return Item:of(unitItemInSlot(self.handle, slot))
866
913
  end
867
914
  function Unit.prototype.addAbility(self, abilityId)
868
- if unitAddAbility(self.handle, abilityId) then
869
- local ability = UnitAbility:of(
870
- checkNotNull(getUnitAbility(self.handle, abilityId)),
871
- abilityId,
872
- self
873
- )
915
+ local ability = UnitAbility:of(
916
+ doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
917
+ abilityId,
918
+ self
919
+ )
920
+ if ability ~= nil then
874
921
  local abilities = self.abilities
875
922
  abilities[#abilities + 1] = ability
876
- return ability
877
923
  end
878
- return nil
924
+ return ability
879
925
  end
880
926
  function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
881
927
  return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
@@ -889,31 +935,21 @@ end
889
935
  function Unit.prototype.hasAbility(self, abilityId)
890
936
  return getUnitAbilityLevel(self.handle, abilityId) > 0
891
937
  end
892
- function Unit.prototype.getAbilityById(self, abilityId)
893
- local handle = self.handle
894
- if unitAddAbility(handle, abilityId) then
895
- assert(unitRemoveAbility(handle, abilityId))
896
- return nil
897
- end
898
- return UnitAbility:of(
899
- getUnitAbility(self.handle, abilityId),
900
- abilityId,
901
- self
902
- )
938
+ function Unit.prototype.getAbility(self, abilityId)
939
+ local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
940
+ return UnitAbility:of(ability, abilityId, self)
903
941
  end
904
- function Unit.prototype.removeAbility(self, abilityId)
905
- if unitRemoveAbility(self.handle, abilityId) then
906
- local abilities = self.abilities
907
- for i = 1, #abilities do
908
- if abilities[i].typeId == abilityId then
909
- abilities[i]:destroy()
910
- tremove(abilities, i)
911
- return true
912
- end
942
+ function Unit.prototype.removeAbility(self, abilityTypeId)
943
+ local abilities = self.abilities
944
+ for i = 1, #abilities do
945
+ if abilities[i].typeId == abilityTypeId then
946
+ local ability = abilities[i]
947
+ tremove(abilities, i)
948
+ ability:destroy()
949
+ return true
913
950
  end
914
- return true
915
951
  end
916
- return false
952
+ return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
917
953
  end
918
954
  function Unit.prototype.hideAbility(self, abilityId, flag)
919
955
  BlzUnitHideAbility(self.handle, abilityId, flag)
@@ -927,6 +963,21 @@ end
927
963
  function Unit.prototype.endAbilityCooldown(self, abilityId)
928
964
  BlzEndUnitAbilityCooldown(self.handle, abilityId)
929
965
  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
930
981
  function Unit.prototype.interruptAttack(self)
931
982
  unitInterruptAttack(self.handle)
932
983
  end
@@ -1200,7 +1251,7 @@ __TS__SetDescriptor(
1200
1251
  Unit.prototype,
1201
1252
  "isIllusion",
1202
1253
  {get = function(self)
1203
- return isUnitIllusion(self.handle)
1254
+ return IsUnitIllusion(self.handle)
1204
1255
  end},
1205
1256
  true
1206
1257
  )
@@ -1208,7 +1259,7 @@ __TS__SetDescriptor(
1208
1259
  Unit.prototype,
1209
1260
  "isStunned",
1210
1261
  {get = function(self)
1211
- return isUnitType(self.handle, UNIT_TYPE_STUNNED)
1262
+ return getUnitCurrentOrder(self.handle) == orderId("stunned")
1212
1263
  end},
1213
1264
  true
1214
1265
  )
@@ -1285,6 +1336,19 @@ __TS__SetDescriptor(
1285
1336
  },
1286
1337
  true
1287
1338
  )
1339
+ __TS__SetDescriptor(
1340
+ Unit.prototype,
1341
+ "primaryAttribute",
1342
+ {
1343
+ get = function(self)
1344
+ return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
1345
+ end,
1346
+ set = function(self, primaryAttribute)
1347
+ setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
1348
+ end
1349
+ },
1350
+ true
1351
+ )
1288
1352
  __TS__SetDescriptor(
1289
1353
  Unit.prototype,
1290
1354
  "strengthBase",
@@ -1409,14 +1473,14 @@ __TS__SetDescriptor(
1409
1473
  return not self[106]
1410
1474
  end,
1411
1475
  set = function(self, isTeamGlowVisible)
1412
- showUnitTeamGlow(self.handle, isTeamGlowVisible)
1413
- local ____temp_6
1476
+ BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1477
+ local ____temp_7
1414
1478
  if not isTeamGlowVisible then
1415
- ____temp_6 = true
1479
+ ____temp_7 = true
1416
1480
  else
1417
- ____temp_6 = nil
1481
+ ____temp_7 = nil
1418
1482
  end
1419
- self[106] = ____temp_6
1483
+ self[106] = ____temp_7
1420
1484
  end
1421
1485
  },
1422
1486
  true
@@ -1425,9 +1489,9 @@ __TS__SetDescriptor(
1425
1489
  Unit.prototype,
1426
1490
  "color",
1427
1491
  {set = function(self, color)
1428
- setUnitColor(self.handle, color.handle)
1492
+ SetUnitColor(self.handle, color.handle)
1429
1493
  if self[106] then
1430
- showUnitTeamGlow(self.handle, false)
1494
+ BlzShowUnitTeamGlow(self.handle, false)
1431
1495
  end
1432
1496
  end},
1433
1497
  true
@@ -1596,7 +1660,7 @@ __TS__SetDescriptor(
1596
1660
  "x",
1597
1661
  {
1598
1662
  get = function(self)
1599
- return getUnitX(self.handle)
1663
+ return self[107] or getUnitX(self.handle)
1600
1664
  end,
1601
1665
  set = function(self, v)
1602
1666
  SetUnitX(self.handle, v)
@@ -1609,7 +1673,7 @@ __TS__SetDescriptor(
1609
1673
  "y",
1610
1674
  {
1611
1675
  get = function(self)
1612
- return getUnitY(self.handle)
1676
+ return self[108] or getUnitY(self.handle)
1613
1677
  end,
1614
1678
  set = function(self, v)
1615
1679
  SetUnitY(self.handle, v)
@@ -1695,10 +1759,10 @@ __TS__SetDescriptor(
1695
1759
  "gold",
1696
1760
  {
1697
1761
  get = function(self)
1698
- return getResourceAmount(self.handle)
1762
+ return GetResourceAmount(self.handle)
1699
1763
  end,
1700
1764
  set = function(self, gold)
1701
- setResourceAmount(self.handle, gold)
1765
+ SetResourceAmount(self.handle, gold)
1702
1766
  end
1703
1767
  },
1704
1768
  true
@@ -1826,6 +1890,19 @@ __TS__SetDescriptor(
1826
1890
  end},
1827
1891
  true
1828
1892
  )
1893
+ __TS__SetDescriptor(
1894
+ Unit.prototype,
1895
+ "movementType",
1896
+ {
1897
+ get = function(self)
1898
+ return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
1899
+ end,
1900
+ set = function(self, movementType)
1901
+ setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
1902
+ end
1903
+ },
1904
+ true
1905
+ )
1829
1906
  __TS__SetDescriptor(
1830
1907
  Unit.prototype,
1831
1908
  "pathing",
@@ -2007,6 +2084,14 @@ __TS__SetDescriptor(
2007
2084
  end},
2008
2085
  true
2009
2086
  )
2087
+ __TS__SetDescriptor(
2088
+ Unit.prototype,
2089
+ "targetAcquiredEvent",
2090
+ {get = function(self)
2091
+ return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
2092
+ end},
2093
+ true
2094
+ )
2010
2095
  __TS__SetDescriptor(
2011
2096
  Unit.prototype,
2012
2097
  "onSelect",
@@ -2142,25 +2227,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2142
2227
  InitializingEvent,
2143
2228
  function(event)
2144
2229
  local function listener(unit, id)
2145
- local ____GetSpellTargetUnit_result_9
2230
+ local ____GetSpellTargetUnit_result_10
2146
2231
  if GetSpellTargetUnit() then
2147
- ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2232
+ ____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
2148
2233
  else
2149
- local ____GetSpellTargetItem_result_8
2234
+ local ____GetSpellTargetItem_result_9
2150
2235
  if GetSpellTargetItem() then
2151
- ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2236
+ ____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
2152
2237
  else
2153
- local ____GetSpellTargetDestructable_result_7
2238
+ local ____GetSpellTargetDestructable_result_8
2154
2239
  if GetSpellTargetDestructable() then
2155
- ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2240
+ ____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
2156
2241
  else
2157
- ____GetSpellTargetDestructable_result_7 = nil
2242
+ ____GetSpellTargetDestructable_result_8 = nil
2158
2243
  end
2159
- ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2244
+ ____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
2160
2245
  end
2161
- ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2246
+ ____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
2162
2247
  end
2163
- local target = ____GetSpellTargetUnit_result_9
2248
+ local target = ____GetSpellTargetUnit_result_10
2164
2249
  if target then
2165
2250
  invoke(event, unit, id, target)
2166
2251
  end
@@ -2368,13 +2453,19 @@ Unit.onDamaging = (function()
2368
2453
  if source and source.typeId == dummyUnitId then
2369
2454
  source = nil
2370
2455
  end
2371
- local target = BlzGetEventDamageTarget()
2456
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2457
+ local metadata = damageMetadataByTarget[target]
2458
+ damageMetadataByTarget[target] = nil
2372
2459
  local data = {
2373
2460
  amount = GetEventDamage(),
2374
- attackType = BlzGetEventAttackType(),
2461
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2375
2462
  damageType = BlzGetEventDamageType(),
2376
2463
  weaponType = BlzGetEventWeaponType(),
2377
- isAttack = BlzGetEventIsAttack()
2464
+ metadata = metadata,
2465
+ isAttack = BlzGetEventIsAttack(),
2466
+ originalAmount = GetEventDamage(),
2467
+ originalMetadata = metadata,
2468
+ preventRetaliation = damagingEventPreventRetaliation
2378
2469
  }
2379
2470
  if data.isAttack and source then
2380
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
@@ -2388,18 +2479,36 @@ Unit.onDamaging = (function()
2388
2479
  invoke(
2389
2480
  event,
2390
2481
  source,
2391
- ____exports.Unit:of(target),
2482
+ target,
2392
2483
  setmetatable(
2393
2484
  {},
2394
2485
  {
2395
2486
  __index = data,
2396
2487
  __newindex = function(self, key, value)
2397
- damageSetters[key](value)
2488
+ local damageSetter = damageSetters[key]
2489
+ if damageSetter ~= nil then
2490
+ damageSetter(value)
2491
+ end
2398
2492
  data[key] = value
2399
2493
  end
2400
2494
  }
2401
2495
  )
2402
2496
  )
2497
+ if data[0] and source then
2498
+ local sourceOwner = source.owner.handle
2499
+ data[1] = sourceOwner
2500
+ local targetOwner = target.owner.handle
2501
+ data[2] = targetOwner
2502
+ if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2503
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2504
+ data[3] = true
2505
+ end
2506
+ if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
2507
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
2508
+ data[4] = true
2509
+ end
2510
+ end
2511
+ damagingEventByTarget[target] = data
2403
2512
  return
2404
2513
  end
2405
2514
  BlzSetEventDamage(0)
@@ -2407,7 +2516,7 @@ Unit.onDamaging = (function()
2407
2516
  BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
2408
2517
  BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
2409
2518
  local sourceOwner = source.owner.handle
2410
- local targetOwner = GetOwningPlayer(target)
2519
+ local targetOwner = target.owner.handle
2411
2520
  if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2412
2521
  SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2413
2522
  Timer:run(function()
@@ -2423,23 +2532,19 @@ Unit.onDamaging = (function()
2423
2532
  for ____, ____value in ipairs(source._attackHandlers) do
2424
2533
  local condition = ____value[1]
2425
2534
  local action = ____value[2]
2426
- if condition(
2427
- source,
2428
- ____exports.Unit:of(target),
2429
- data
2430
- ) then
2535
+ if condition(source, target, data) then
2431
2536
  action(
2432
2537
  source,
2433
- ____exports.Unit:of(target),
2538
+ target,
2434
2539
  setmetatable(
2435
2540
  {fire = function()
2436
2541
  UnitDamageTarget(
2437
2542
  source.handle,
2438
- target,
2543
+ target.handle,
2439
2544
  data.amount,
2440
2545
  true,
2441
2546
  true,
2442
- data.attackType,
2547
+ attackTypeToNative(data.attackType),
2443
2548
  data.damageType,
2444
2549
  data.weaponType
2445
2550
  )
@@ -2466,26 +2571,50 @@ Unit.onDamage = __TS__New(
2466
2571
  if source and source.typeId == dummyUnitId then
2467
2572
  source = nil
2468
2573
  end
2574
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2575
+ local damagingEvent = damagingEventByTarget[target]
2576
+ damagingEventByTarget[target] = nil
2469
2577
  local data = {
2470
2578
  amount = GetEventDamage(),
2471
- attackType = BlzGetEventAttackType(),
2579
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2472
2580
  damageType = BlzGetEventDamageType(),
2473
2581
  weaponType = BlzGetEventWeaponType(),
2582
+ metadata = damagingEvent and damagingEvent.metadata,
2474
2583
  isAttack = BlzGetEventIsAttack(),
2475
- originalAmount = GetEventDamage(),
2584
+ originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
2585
+ originalMetadata = damagingEvent and damagingEvent.originalMetadata,
2476
2586
  preventDeath = damageEventPreventDeath
2477
2587
  }
2588
+ if damagingEvent then
2589
+ for key, value in pairs(damagingEvent) do
2590
+ if isAttribute(key) then
2591
+ data[key] = value
2592
+ end
2593
+ end
2594
+ local sourceOwner = damagingEvent[1]
2595
+ if sourceOwner then
2596
+ local targetOwner = damagingEvent[2]
2597
+ if damagingEvent[3] then
2598
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
2599
+ end
2600
+ if damagingEvent[4] then
2601
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
2602
+ end
2603
+ end
2604
+ end
2478
2605
  local evData = setmetatable(
2479
2606
  {},
2480
2607
  {
2481
2608
  __index = data,
2482
2609
  __newindex = function(self, key, value)
2483
- damageSetters[key](value)
2610
+ local damageSetter = damageSetters[key]
2611
+ if damageSetter ~= nil then
2612
+ damageSetter(value)
2613
+ end
2484
2614
  data[key] = value
2485
2615
  end
2486
2616
  }
2487
2617
  )
2488
- local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2489
2618
  invoke(event, source, target, evData)
2490
2619
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2491
2620
  local bonusHealth = math.ceil(evData.amount)
@@ -2539,10 +2668,14 @@ Unit.itemPickedUpEvent = __TS__New(
2539
2668
  ____exports.UnitTriggerEvent,
2540
2669
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2541
2670
  function()
2542
- local unit = getTriggerUnit()
2543
- local item = getManipulatedItem()
2544
- if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2545
- return ____exports.Unit:of(unit), Item:of(item)
2671
+ local unitHandle = getTriggerUnit()
2672
+ local itemHandle = getManipulatedItem()
2673
+ if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
2674
+ local unit = ____exports.Unit:of(unitHandle)
2675
+ local item = Item:of(itemHandle)
2676
+ if item.owner ~= unit then
2677
+ return unit, item
2678
+ end
2546
2679
  end
2547
2680
  return IgnoreEvent
2548
2681
  end
@@ -2562,7 +2695,22 @@ Unit.itemUsedEvent = __TS__New(
2562
2695
  Unit.itemStackedEvent = __TS__New(
2563
2696
  ____exports.UnitTriggerEvent,
2564
2697
  EVENT_PLAYER_UNIT_STACK_ITEM,
2565
- function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2698
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
2699
+ )
2700
+ __TS__ObjectDefineProperty(
2701
+ Unit,
2702
+ "itemChargesChangedEvent",
2703
+ {get = function(self)
2704
+ local event = __TS__New(Event)
2705
+ Item.chargesChangedEvent:addListener(function(item)
2706
+ local unit = item.owner
2707
+ if unit ~= nil then
2708
+ invoke(event, unit, item)
2709
+ end
2710
+ end)
2711
+ rawset(self, "itemChargesChangedEvent", event)
2712
+ return event
2713
+ end}
2566
2714
  )
2567
2715
  __TS__ObjectDefineProperty(
2568
2716
  Unit,