warscript 0.0.1-dev.2af030d → 0.0.1-dev.2bde093

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 (223) hide show
  1. package/attributes.d.ts +0 -1
  2. package/binaryreader.d.ts +1 -0
  3. package/binaryreader.lua +3 -0
  4. package/config.d.ts +5 -0
  5. package/config.lua +10 -0
  6. package/core/types/effect.d.ts +14 -6
  7. package/core/types/effect.lua +131 -35
  8. package/core/types/frame.d.ts +8 -1
  9. package/core/types/frame.lua +93 -1
  10. package/core/types/group.d.ts +0 -1
  11. package/core/types/image.d.ts +0 -1
  12. package/core/types/missile.d.ts +2 -2
  13. package/core/types/missile.lua +8 -2
  14. package/core/types/sound.d.ts +17 -24
  15. package/core/types/sound.lua +99 -24
  16. package/core/types/timer.d.ts +6 -7
  17. package/core/types/timer.lua +18 -21
  18. package/core/types/unit.lua +8 -0
  19. package/core/util.d.ts +1 -1
  20. package/core/util.lua +18 -1
  21. package/decl/index.d.ts +1 -0
  22. package/decl/native.d.ts +840 -786
  23. package/engine/ability.d.ts +1 -1
  24. package/engine/behavior.d.ts +10 -10
  25. package/engine/behavior.lua +6 -6
  26. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  27. package/engine/behaviour/ability/always-enabled.lua +31 -0
  28. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  29. package/engine/behaviour/ability/apply-buff.lua +32 -0
  30. package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
  31. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  32. package/engine/behaviour/ability/damage.d.ts +38 -11
  33. package/engine/behaviour/ability/damage.lua +93 -32
  34. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  35. package/engine/behaviour/ability/emulate-impact.lua +35 -0
  36. package/engine/behaviour/ability/heal.d.ts +33 -6
  37. package/engine/behaviour/ability/heal.lua +89 -10
  38. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  39. package/engine/behaviour/ability/instant-impact.lua +4 -15
  40. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  41. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  42. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  43. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  44. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  45. package/engine/behaviour/ability/restore-mana.lua +29 -0
  46. package/engine/behaviour/ability.d.ts +27 -4
  47. package/engine/behaviour/ability.lua +152 -17
  48. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  49. package/engine/behaviour/unit.d.ts +10 -2
  50. package/engine/behaviour/unit.lua +27 -0
  51. package/engine/buff.d.ts +103 -41
  52. package/engine/buff.lua +465 -212
  53. package/engine/game-map.d.ts +7 -0
  54. package/engine/game-map.lua +32 -0
  55. package/engine/internal/ability.d.ts +16 -13
  56. package/engine/internal/ability.lua +80 -76
  57. package/engine/internal/item/ability.lua +106 -0
  58. package/engine/internal/item+owner.lua +2 -2
  59. package/engine/internal/item.d.ts +4 -3
  60. package/engine/internal/item.lua +56 -25
  61. package/engine/internal/mechanics/ability-duration.lua +1 -1
  62. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  63. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  64. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  65. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  66. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  67. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  68. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  69. package/engine/internal/object-data/evasion-probability.lua +16 -0
  70. package/engine/internal/unit/ability.d.ts +10 -1
  71. package/engine/internal/unit/ability.lua +36 -14
  72. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  73. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  74. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  75. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  76. package/engine/internal/unit/bonus.d.ts +11 -8
  77. package/engine/internal/unit/bonus.lua +23 -1
  78. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  79. package/engine/internal/unit/ignore-events-items.lua +5 -0
  80. package/engine/internal/unit/item.d.ts +24 -0
  81. package/engine/internal/unit/item.lua +78 -0
  82. package/engine/internal/unit/main-selected.d.ts +13 -0
  83. package/engine/internal/unit/main-selected.lua +51 -0
  84. package/engine/internal/unit+ability.lua +2 -2
  85. package/engine/internal/unit+damage.d.ts +2 -11
  86. package/engine/internal/unit+damage.lua +10 -14
  87. package/engine/internal/unit+spellSteal.lua +1 -2
  88. package/engine/internal/unit+transport.lua +4 -10
  89. package/engine/internal/unit-missile-launch.lua +24 -5
  90. package/engine/internal/unit.d.ts +43 -13
  91. package/engine/internal/unit.lua +257 -116
  92. package/engine/internal/utility.lua +12 -0
  93. package/engine/lightning.d.ts +12 -5
  94. package/engine/lightning.lua +48 -14
  95. package/engine/local-client.d.ts +7 -2
  96. package/engine/local-client.lua +82 -0
  97. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  98. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  99. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -3
  100. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  101. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  102. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  103. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  104. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  105. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  106. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  107. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  108. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  109. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  110. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  111. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  112. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  113. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  114. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  115. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  116. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  117. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  118. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  119. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  120. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  121. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  122. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  123. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  124. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  125. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  126. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  127. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  128. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  129. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  130. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  131. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  132. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  133. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  134. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  135. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  136. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  137. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  138. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  139. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  140. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  141. package/engine/object-data/entry/ability-type/web.lua +52 -0
  142. package/engine/object-data/entry/ability-type.d.ts +19 -18
  143. package/engine/object-data/entry/ability-type.lua +89 -33
  144. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  145. package/engine/object-data/entry/buff-type/applicable.lua +18 -37
  146. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  147. package/engine/object-data/entry/buff-type.d.ts +6 -13
  148. package/engine/object-data/entry/buff-type.lua +13 -29
  149. package/engine/object-data/entry/destructible-type.d.ts +1 -2
  150. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  151. package/engine/object-data/entry/item-type.d.ts +15 -2
  152. package/engine/object-data/entry/item-type.lua +93 -2
  153. package/engine/object-data/entry/lightning-type.d.ts +1 -2
  154. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  155. package/engine/object-data/entry/sound-preset.lua +140 -0
  156. package/engine/object-data/entry/unit-type.d.ts +10 -4
  157. package/engine/object-data/entry/unit-type.lua +155 -92
  158. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  159. package/engine/object-data/entry/upgrade.d.ts +1 -2
  160. package/engine/object-data/entry/upgrade.lua +4 -4
  161. package/engine/object-data/entry.d.ts +18 -17
  162. package/engine/object-data/entry.lua +60 -32
  163. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  164. package/engine/object-field/ability.d.ts +26 -3
  165. package/engine/object-field/ability.lua +54 -1
  166. package/engine/object-field/unit.d.ts +46 -3
  167. package/engine/object-field/unit.lua +173 -7
  168. package/engine/object-field.d.ts +11 -4
  169. package/engine/object-field.lua +162 -76
  170. package/engine/random.d.ts +1 -0
  171. package/engine/random.lua +9 -0
  172. package/engine/standard/entries/buff-type.d.ts +3 -0
  173. package/engine/standard/entries/buff-type.lua +3 -0
  174. package/engine/standard/entries/sound-preset.d.ts +10 -0
  175. package/engine/standard/entries/sound-preset.lua +10 -0
  176. package/engine/standard/entries/unit-type.d.ts +18 -0
  177. package/engine/standard/entries/unit-type.lua +18 -0
  178. package/engine/standard/fields/ability.d.ts +3 -1
  179. package/engine/standard/fields/ability.lua +3 -1
  180. package/engine/unit.d.ts +3 -0
  181. package/engine/unit.lua +12 -2
  182. package/event.d.ts +2 -3
  183. package/event.lua +9 -5
  184. package/index.d.ts +1 -0
  185. package/index.lua +1 -0
  186. package/lualib_bundle.lua +146 -42
  187. package/math/vec2.d.ts +2 -9
  188. package/math.d.ts +0 -2
  189. package/net/socket.d.ts +7 -1
  190. package/net/socket.lua +45 -4
  191. package/network.d.ts +1 -0
  192. package/network.lua +3 -2
  193. package/objutil/ability.d.ts +0 -1
  194. package/objutil/buff.d.ts +0 -1
  195. package/objutil/buff.lua +2 -3
  196. package/objutil/object.d.ts +0 -1
  197. package/objutil/unit.d.ts +0 -1
  198. package/objutil/unit.lua +8 -0
  199. package/package.json +13 -13
  200. package/patch-lua.d.ts +0 -0
  201. package/patch-lua.lua +10 -0
  202. package/property.d.ts +55 -0
  203. package/property.lua +374 -0
  204. package/string.d.ts +16 -0
  205. package/string.lua +5 -0
  206. package/util/stream.d.ts +0 -1
  207. package/utility/arrays.d.ts +12 -5
  208. package/utility/arrays.lua +37 -3
  209. package/utility/bit-set.d.ts +0 -2
  210. package/utility/functions.d.ts +1 -0
  211. package/utility/functions.lua +1 -0
  212. package/utility/lazy.d.ts +2 -0
  213. package/utility/lazy.lua +14 -0
  214. package/utility/linked-set.d.ts +12 -3
  215. package/utility/linked-set.lua +8 -2
  216. package/utility/lua-maps.d.ts +4 -2
  217. package/utility/lua-maps.lua +16 -0
  218. package/utility/lua-sets.d.ts +2 -2
  219. package/utility/lua-sets.lua +3 -0
  220. package/utility/reflection.lua +11 -7
  221. package/utility/types.d.ts +1 -0
  222. package/core/mapbounds.d.ts +0 -8
  223. package/core/mapbounds.lua +0 -12
@@ -7,6 +7,9 @@ local __TS__Class = ____lualib.__TS__Class
7
7
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
8
8
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
9
9
  local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
10
+ local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
11
+ local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
12
+ local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
10
13
  local __TS__InstanceOf = ____lualib.__TS__InstanceOf
11
14
  local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
12
15
  local Set = ____lualib.Set
@@ -48,11 +51,19 @@ local ____arrays = require("utility.arrays")
48
51
  local forEach = ____arrays.forEach
49
52
  local ____math = require("math")
50
53
  local min = ____math.min
54
+ local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
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
51
61
  local match = string.match
52
62
  local ____tostring = _G.tostring
53
63
  local setUnitAnimation = SetUnitAnimation
54
64
  local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
55
65
  local setUnitAnimationByIndex = SetUnitAnimationByIndex
66
+ local resetUnitAnimation = ResetUnitAnimation
56
67
  local queueUnitAnimation = QueueUnitAnimation
57
68
  local getUnitIntegerField = BlzGetUnitIntegerField
58
69
  local getUnitRealField = BlzGetUnitRealField
@@ -72,9 +83,9 @@ local setUnitScale = SetUnitScale
72
83
  local setUnitPosition = SetUnitPosition
73
84
  local setUnitTimeScale = SetUnitTimeScale
74
85
  local getHandleId = GetHandleId
86
+ local getUnitCurrentOrder = GetUnitCurrentOrder
75
87
  local createUnit = CreateUnit
76
88
  local killUnit = KillUnit
77
- local setUnitExploded = SetUnitExploded
78
89
  local removeUnit = RemoveUnit
79
90
  local getUnitTypeId = GetUnitTypeId
80
91
  local isHeroUnitId = IsHeroUnitId
@@ -90,8 +101,6 @@ local getSpellTargetItem = GetSpellTargetItem
90
101
  local getSpellTargetDestructable = GetSpellTargetDestructable
91
102
  local isUnitInRangeXY = IsUnitInRangeXY
92
103
  local isUnitInRange = IsUnitInRange
93
- local setResourceAmount = SetResourceAmount
94
- local getResourceAmount = GetResourceAmount
95
104
  local getUnitWeaponRealField = BlzGetUnitWeaponRealField
96
105
  local setUnitWeaponRealField = BlzSetUnitWeaponRealField
97
106
  local getUnitWeaponStringField = BlzGetUnitWeaponStringField
@@ -122,8 +131,6 @@ local isUnitType = IsUnitType
122
131
  local isUnitAlly = IsUnitAlly
123
132
  local isUnitEnemy = IsUnitEnemy
124
133
  local getOwningPlayer = GetOwningPlayer
125
- local setUnitColor = SetUnitColor
126
- local showUnitTeamGlow = BlzShowUnitTeamGlow
127
134
  ____exports.UnitClassification = {}
128
135
  local UnitClassification = ____exports.UnitClassification
129
136
  do
@@ -279,16 +286,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
279
286
  end
280
287
  local function dispatch(event, idGetter, argsGetter)
281
288
  local initialized = false
282
- local x = {}
283
289
  return setmetatable(
284
- x,
290
+ {},
285
291
  {
286
292
  __index = function(self, id)
287
293
  if type(id) ~= "number" then
288
294
  return event[id]
289
295
  end
290
296
  if not initialized then
291
- local invoke = Event.invoke
292
297
  event:addListener(function(...)
293
298
  local id = idGetter(...)
294
299
  local dispatched = rawget(self, id)
@@ -326,7 +331,6 @@ local function dispatchAbility(event)
326
331
  return event[id]
327
332
  end
328
333
  if not initialized then
329
- local invoke = Event.invoke
330
334
  event:addListener(function(unit, ability, ...)
331
335
  local dispatched = rawget(self, ability.typeId)
332
336
  if dispatched ~= nil then
@@ -354,7 +358,14 @@ local function damageEventPreventDeath(self, callback, ...)
354
358
  rawset(self, 1 + i, (select(i, ...)))
355
359
  end
356
360
  end
357
- local damageSetters = {amount = BlzSetEventDamage, attackType = BlzSetEventAttackType, damageType = BlzSetEventDamageType, weaponType = BlzSetEventWeaponType}
361
+ local damageSetters = {
362
+ amount = BlzSetEventDamage,
363
+ attackType = function(attackType)
364
+ return BlzSetEventAttackType(attackTypeToNative(attackType))
365
+ end,
366
+ damageType = BlzSetEventDamageType,
367
+ weaponType = BlzSetEventWeaponType
368
+ }
358
369
  local jlimitopByOperator = {
359
370
  [0] = LESS_THAN_OR_EQUAL,
360
371
  [1] = LESS_THAN_OR_EQUAL,
@@ -562,17 +573,6 @@ local function retrieveAbility(unit, ability, abilityId)
562
573
  ____exports.Unit:of(unit)
563
574
  )
564
575
  end
565
- if not unitAddAbility(unit, abilityId) then
566
- if getUnitAbility(unit, abilityId) == ability then
567
- return UnitAbility:of(
568
- ability,
569
- abilityId,
570
- ____exports.Unit:of(unit)
571
- )
572
- end
573
- else
574
- unitRemoveAbility(unit, abilityId)
575
- end
576
576
  for i = 0, unitInventorySize(unit) - 1 do
577
577
  local item = unitItemInSlot(unit, i)
578
578
  if getItemAbility(item, abilityId) == ability then
@@ -630,15 +630,15 @@ for ____, player in ipairs(Player.all) do
630
630
  dummies[player] = dummy
631
631
  end
632
632
  local function delayHealthChecksCallback(unit)
633
- local counter = (unit[102] or 0) - 1
633
+ local counter = (unit[103] or 0) - 1
634
634
  if counter ~= 0 then
635
- unit[102] = counter
635
+ unit[103] = counter
636
636
  return
637
637
  end
638
- unit[102] = nil
639
- local healthBonus = unit[103]
638
+ unit[103] = nil
639
+ local healthBonus = unit[104]
640
640
  if healthBonus ~= nil then
641
- unit[103] = nil
641
+ unit[104] = nil
642
642
  local handle = unit.handle
643
643
  BlzSetUnitMaxHP(
644
644
  handle,
@@ -646,12 +646,18 @@ local function delayHealthChecksCallback(unit)
646
646
  )
647
647
  end
648
648
  end
649
+ local nextSyncId = 1
650
+ local unitBySyncId = setmetatable({}, {__mode = "v"})
651
+ local damagingEventByTarget = setmetatable({}, {__mode = "k"})
649
652
  ____exports.Unit = __TS__Class()
650
653
  local Unit = ____exports.Unit
651
654
  Unit.name = "Unit"
652
655
  __TS__ClassExtends(Unit, Handle)
653
656
  function Unit.prototype.____constructor(self, handle)
654
657
  Handle.prototype.____constructor(self, handle)
658
+ local ____nextSyncId_0 = nextSyncId
659
+ nextSyncId = ____nextSyncId_0 + 1
660
+ self.syncId = ____nextSyncId_0
655
661
  self._owner = Player:of(getOwningPlayer(handle))
656
662
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
657
663
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -664,6 +670,7 @@ function Unit.prototype.____constructor(self, handle)
664
670
  fourCC("Amrf")
665
671
  ))
666
672
  end
673
+ unitBySyncId[self.syncId] = self
667
674
  local ____ = self.abilities
668
675
  end
669
676
  function Unit.prototype.getEvent(self, event, collector)
@@ -682,6 +689,8 @@ function Unit.prototype.getEvent(self, event, collector)
682
689
  end
683
690
  function Unit.prototype.onDestroy(self)
684
691
  local handle = self.handle
692
+ self[107] = getUnitX(handle)
693
+ self[108] = getUnitY(handle)
685
694
  if not self._owner then
686
695
  self._owner = Player:of(getOwningPlayer(handle))
687
696
  end
@@ -749,8 +758,8 @@ function Unit.prototype.addModifier(self, property, modifier)
749
758
  end}
750
759
  end
751
760
  function Unit.prototype.hasCombatClassification(self, combatClassification)
752
- local ____combatClassification_0 = combatClassification
753
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_0 == ____combatClassification_0
761
+ local ____combatClassification_1 = combatClassification
762
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
754
763
  end
755
764
  function Unit.prototype.addClassification(self, classification)
756
765
  return unitAddType(self.handle, classification)
@@ -768,13 +777,13 @@ function Unit.prototype.isInvisibleTo(self, player)
768
777
  return isUnitInvisible(self.handle, player.handle)
769
778
  end
770
779
  function Unit.prototype.isInRangeOf(self, x, y, range)
771
- local ____temp_1
780
+ local ____temp_2
772
781
  if type(x) == "number" then
773
- ____temp_1 = isUnitInRangeXY(self.handle, x, y, range)
782
+ ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
774
783
  else
775
- ____temp_1 = isUnitInRange(self.handle, x.handle, y)
784
+ ____temp_2 = isUnitInRange(self.handle, x.handle, y)
776
785
  end
777
- return ____temp_1
786
+ return ____temp_2
778
787
  end
779
788
  function Unit.prototype.isAllyOf(self, unit)
780
789
  return isUnitAlly(
@@ -797,11 +806,14 @@ function Unit.prototype.playAnimation(self, animation, rarity)
797
806
  setUnitAnimation(self.handle, animation)
798
807
  end
799
808
  end
809
+ function Unit.prototype.resetAnimation(self)
810
+ resetUnitAnimation(self.handle)
811
+ end
800
812
  function Unit.prototype.queueAnimation(self, animation)
801
813
  queueUnitAnimation(self.handle, animation)
802
814
  end
803
815
  function Unit.prototype.delayHealthChecks(self)
804
- self[102] = (self[102] or 0) + 1
816
+ self[103] = (self[103] or 0) + 1
805
817
  Timer:run(delayHealthChecksCallback, self)
806
818
  end
807
819
  function Unit.prototype.setPosition(self, x, y)
@@ -811,14 +823,21 @@ function Unit.prototype.isSelected(self, player)
811
823
  return IsUnitSelected(self.handle, player.handle)
812
824
  end
813
825
  function Unit.prototype.explode(self)
814
- setUnitExploded(self.handle, true)
826
+ SetUnitExploded(self.handle, true)
815
827
  killUnit(self.handle)
816
828
  end
817
829
  function Unit.prototype.kill(self)
818
830
  killUnit(self.handle)
819
831
  end
820
- function Unit.prototype.revive(self, pos, doEffect)
821
- ReviveHero(self.handle, pos.x, pos.y, doEffect)
832
+ function Unit.prototype.revive(self, x, y, doEffect)
833
+ local ____ReviveHero_5 = ReviveHero
834
+ local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
835
+ local ____doEffect_3 = doEffect
836
+ if ____doEffect_3 == nil then
837
+ ____doEffect_3 = false
838
+ end
839
+ __TS__SparseArrayPush(____array_4, ____doEffect_3)
840
+ ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
822
841
  end
823
842
  function Unit.prototype.healTarget(self, target, amount)
824
843
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -858,7 +877,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
858
877
  return UnitDropItemSlot(self.handle, item.handle, slot)
859
878
  end
860
879
  function Unit.prototype.itemInSlot(self, slot)
861
- return Item:of(UnitItemInSlot(self.handle, slot))
880
+ return Item:of(unitItemInSlot(self.handle, slot))
862
881
  end
863
882
  function Unit.prototype.addAbility(self, abilityId)
864
883
  if unitAddAbility(self.handle, abilityId) then
@@ -914,6 +933,9 @@ end
914
933
  function Unit.prototype.hideAbility(self, abilityId, flag)
915
934
  BlzUnitHideAbility(self.handle, abilityId, flag)
916
935
  end
936
+ function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
937
+ return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
938
+ end
917
939
  function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
918
940
  BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
919
941
  end
@@ -924,8 +946,15 @@ function Unit.prototype.interruptAttack(self)
924
946
  unitInterruptAttack(self.handle)
925
947
  end
926
948
  function Unit.prototype.interruptCast(self, abilityId)
927
- unitDisableAbility(self.handle, abilityId, true, false)
928
- unitDisableAbility(self.handle, abilityId, false, false)
949
+ local handle = self.handle
950
+ unitDisableAbility(handle, abilityId, true, false)
951
+ Timer:run(
952
+ unitDisableAbility,
953
+ handle,
954
+ abilityId,
955
+ false,
956
+ false
957
+ )
929
958
  end
930
959
  function Unit.prototype.getDistanceTo(self, target)
931
960
  local handle = self.handle
@@ -985,18 +1014,18 @@ function Unit.prototype.unpauseEx(self)
985
1014
  self:decrementStunCounter()
986
1015
  end
987
1016
  function Unit.prototype.incrementStunCounter(self)
988
- local stunCounter = self[101] or 0
989
- if not self[100] or stunCounter >= 0 then
1017
+ local stunCounter = self[102] or 0
1018
+ if not self[101] or stunCounter >= 0 then
990
1019
  BlzPauseUnitEx(self.handle, true)
991
1020
  end
992
- self[101] = stunCounter + 1
1021
+ self[102] = stunCounter + 1
993
1022
  end
994
1023
  function Unit.prototype.decrementStunCounter(self)
995
- local stunCounter = self[101] or 0
996
- if not self[100] or stunCounter >= 1 then
1024
+ local stunCounter = self[102] or 0
1025
+ if not self[101] or stunCounter >= 1 then
997
1026
  BlzPauseUnitEx(self.handle, false)
998
1027
  end
999
- self[101] = stunCounter - 1
1028
+ self[102] = stunCounter - 1
1000
1029
  end
1001
1030
  function Unit.create(self, owner, id, x, y, facing, skinId)
1002
1031
  local handle = skinId and BlzCreateUnitWithSkin(
@@ -1098,8 +1127,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
1098
1127
  )
1099
1128
  return targetCollection
1100
1129
  end
1101
- function Unit.getSelectionOf(self, player)
1102
- targetCollection = {}
1130
+ function Unit.getSelectionOf(self, player, target)
1131
+ if target == nil then
1132
+ target = {}
1133
+ end
1134
+ targetCollection = target
1103
1135
  targetCollectionNextIndex = 1
1104
1136
  GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
1105
1137
  return targetCollection
@@ -1121,6 +1153,9 @@ end
1121
1153
  function Unit.prototype.__tostring(self)
1122
1154
  return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
1123
1155
  end
1156
+ function Unit.getBySyncId(self, syncId)
1157
+ return unitBySyncId[syncId]
1158
+ end
1124
1159
  __TS__SetDescriptor(
1125
1160
  Unit.prototype,
1126
1161
  "_deltas",
@@ -1184,6 +1219,14 @@ __TS__SetDescriptor(
1184
1219
  end},
1185
1220
  true
1186
1221
  )
1222
+ __TS__SetDescriptor(
1223
+ Unit.prototype,
1224
+ "isStunned",
1225
+ {get = function(self)
1226
+ return getUnitCurrentOrder(self.handle) == orderId("stunned")
1227
+ end},
1228
+ true
1229
+ )
1187
1230
  __TS__SetDescriptor(
1188
1231
  Unit.prototype,
1189
1232
  "combatClassifications",
@@ -1257,6 +1300,19 @@ __TS__SetDescriptor(
1257
1300
  },
1258
1301
  true
1259
1302
  )
1303
+ __TS__SetDescriptor(
1304
+ Unit.prototype,
1305
+ "primaryAttribute",
1306
+ {
1307
+ get = function(self)
1308
+ return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
1309
+ end,
1310
+ set = function(self, primaryAttribute)
1311
+ setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
1312
+ end
1313
+ },
1314
+ true
1315
+ )
1260
1316
  __TS__SetDescriptor(
1261
1317
  Unit.prototype,
1262
1318
  "strengthBase",
@@ -1378,17 +1434,17 @@ __TS__SetDescriptor(
1378
1434
  "isTeamGlowVisible",
1379
1435
  {
1380
1436
  get = function(self)
1381
- return not self[105]
1437
+ return not self[106]
1382
1438
  end,
1383
1439
  set = function(self, isTeamGlowVisible)
1384
- showUnitTeamGlow(self.handle, isTeamGlowVisible)
1385
- local ____temp_2
1440
+ BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1441
+ local ____temp_6
1386
1442
  if not isTeamGlowVisible then
1387
- ____temp_2 = true
1443
+ ____temp_6 = true
1388
1444
  else
1389
- ____temp_2 = nil
1445
+ ____temp_6 = nil
1390
1446
  end
1391
- self[105] = ____temp_2
1447
+ self[106] = ____temp_6
1392
1448
  end
1393
1449
  },
1394
1450
  true
@@ -1397,9 +1453,9 @@ __TS__SetDescriptor(
1397
1453
  Unit.prototype,
1398
1454
  "color",
1399
1455
  {set = function(self, color)
1400
- setUnitColor(self.handle, color.handle)
1401
- if self[105] then
1402
- showUnitTeamGlow(self.handle, false)
1456
+ SetUnitColor(self.handle, color.handle)
1457
+ if self[106] then
1458
+ BlzShowUnitTeamGlow(self.handle, false)
1403
1459
  end
1404
1460
  end},
1405
1461
  true
@@ -1422,14 +1478,14 @@ __TS__SetDescriptor(
1422
1478
  "maxHealth",
1423
1479
  {
1424
1480
  get = function(self)
1425
- return BlzGetUnitMaxHP(self.handle) - (self[103] or 0) - (self[104] or 0)
1481
+ return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1426
1482
  end,
1427
1483
  set = function(self, maxHealth)
1428
- if maxHealth < 1 and self[102] ~= nil then
1429
- self[103] = (self[103] or 0) + (1 - maxHealth)
1484
+ if maxHealth < 1 and self[103] ~= nil then
1485
+ self[104] = (self[104] or 0) + (1 - maxHealth)
1430
1486
  maxHealth = 1
1431
1487
  end
1432
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[104] or 0))
1488
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1433
1489
  end
1434
1490
  },
1435
1491
  true
@@ -1471,10 +1527,10 @@ __TS__SetDescriptor(
1471
1527
  "health",
1472
1528
  {
1473
1529
  get = function(self)
1474
- return GetWidgetLife(self.handle) - (self[104] or 0)
1530
+ return GetWidgetLife(self.handle) - (self[105] or 0)
1475
1531
  end,
1476
1532
  set = function(self, health)
1477
- SetWidgetLife(self.handle, health + (self[104] or 0))
1533
+ SetWidgetLife(self.handle, health + (self[105] or 0))
1478
1534
  end
1479
1535
  },
1480
1536
  true
@@ -1568,7 +1624,7 @@ __TS__SetDescriptor(
1568
1624
  "x",
1569
1625
  {
1570
1626
  get = function(self)
1571
- return getUnitX(self.handle)
1627
+ return self[107] or getUnitX(self.handle)
1572
1628
  end,
1573
1629
  set = function(self, v)
1574
1630
  SetUnitX(self.handle, v)
@@ -1581,7 +1637,7 @@ __TS__SetDescriptor(
1581
1637
  "y",
1582
1638
  {
1583
1639
  get = function(self)
1584
- return getUnitY(self.handle)
1640
+ return self[108] or getUnitY(self.handle)
1585
1641
  end,
1586
1642
  set = function(self, v)
1587
1643
  SetUnitY(self.handle, v)
@@ -1667,10 +1723,10 @@ __TS__SetDescriptor(
1667
1723
  "gold",
1668
1724
  {
1669
1725
  get = function(self)
1670
- return getResourceAmount(self.handle)
1726
+ return GetResourceAmount(self.handle)
1671
1727
  end,
1672
1728
  set = function(self, gold)
1673
- setResourceAmount(self.handle, gold)
1729
+ SetResourceAmount(self.handle, gold)
1674
1730
  end
1675
1731
  },
1676
1732
  true
@@ -1685,17 +1741,17 @@ __TS__SetDescriptor(
1685
1741
  set = function(self, isPaused)
1686
1742
  local handle = self.handle
1687
1743
  if isPaused and not IsUnitPaused(handle) then
1688
- self[100] = true
1689
- for _ = self[101] or 0, -1 do
1744
+ self[101] = true
1745
+ for _ = self[102] or 0, -1 do
1690
1746
  BlzPauseUnitEx(handle, true)
1691
1747
  end
1692
1748
  PauseUnit(handle, true)
1693
1749
  elseif not isPaused and IsUnitPaused(handle) then
1694
1750
  PauseUnit(handle, false)
1695
- for _ = self[101] or 0, -1 do
1751
+ for _ = self[102] or 0, -1 do
1696
1752
  BlzPauseUnitEx(handle, false)
1697
1753
  end
1698
- self[100] = nil
1754
+ self[101] = nil
1699
1755
  end
1700
1756
  end
1701
1757
  },
@@ -1798,6 +1854,19 @@ __TS__SetDescriptor(
1798
1854
  end},
1799
1855
  true
1800
1856
  )
1857
+ __TS__SetDescriptor(
1858
+ Unit.prototype,
1859
+ "movementType",
1860
+ {
1861
+ get = function(self)
1862
+ return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
1863
+ end,
1864
+ set = function(self, movementType)
1865
+ setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
1866
+ end
1867
+ },
1868
+ true
1869
+ )
1801
1870
  __TS__SetDescriptor(
1802
1871
  Unit.prototype,
1803
1872
  "pathing",
@@ -2052,7 +2121,6 @@ Unit.onDecay = __TS__New(
2052
2121
  Unit.onResurrect = __TS__New(
2053
2122
  InitializingEvent,
2054
2123
  function(event)
2055
- local invoke = Event.invoke
2056
2124
  local dead = setmetatable({}, {__mode = "k"})
2057
2125
  ____exports.Unit.deathEvent:addListener(function(unit)
2058
2126
  dead[unit] = true
@@ -2068,10 +2136,15 @@ Unit.onResurrect = __TS__New(
2068
2136
  Unit.morphEvent = __TS__New(
2069
2137
  InitializingEvent,
2070
2138
  function(event)
2139
+ local function ifNotLeft(unit)
2140
+ local handle = unit.handle
2141
+ if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
2142
+ invoke(event, unit)
2143
+ end
2144
+ end
2071
2145
  ____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
2072
2146
  if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
2073
- assert(unitAddAbility(unit.handle, morphDetectAbilityId))
2074
- Timer:run(Event.invoke, event, unit)
2147
+ Timer:run(ifNotLeft, unit)
2075
2148
  end
2076
2149
  end)
2077
2150
  end
@@ -2109,27 +2182,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
2109
2182
  Unit.onTargetCast = dispatchId(__TS__New(
2110
2183
  InitializingEvent,
2111
2184
  function(event)
2112
- local invoke = Event.invoke
2113
2185
  local function listener(unit, id)
2114
- local ____GetSpellTargetUnit_result_5
2186
+ local ____GetSpellTargetUnit_result_9
2115
2187
  if GetSpellTargetUnit() then
2116
- ____GetSpellTargetUnit_result_5 = ____exports.Unit:of(GetSpellTargetUnit())
2188
+ ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2117
2189
  else
2118
- local ____GetSpellTargetItem_result_4
2190
+ local ____GetSpellTargetItem_result_8
2119
2191
  if GetSpellTargetItem() then
2120
- ____GetSpellTargetItem_result_4 = Item:of(GetSpellTargetItem())
2192
+ ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2121
2193
  else
2122
- local ____GetSpellTargetDestructable_result_3
2194
+ local ____GetSpellTargetDestructable_result_7
2123
2195
  if GetSpellTargetDestructable() then
2124
- ____GetSpellTargetDestructable_result_3 = Destructable:of(GetSpellTargetDestructable())
2196
+ ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2125
2197
  else
2126
- ____GetSpellTargetDestructable_result_3 = nil
2198
+ ____GetSpellTargetDestructable_result_7 = nil
2127
2199
  end
2128
- ____GetSpellTargetItem_result_4 = ____GetSpellTargetDestructable_result_3
2200
+ ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2129
2201
  end
2130
- ____GetSpellTargetUnit_result_5 = ____GetSpellTargetItem_result_4
2202
+ ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2131
2203
  end
2132
- local target = ____GetSpellTargetUnit_result_5
2204
+ local target = ____GetSpellTargetUnit_result_9
2133
2205
  if target then
2134
2206
  invoke(event, unit, id, target)
2135
2207
  end
@@ -2301,10 +2373,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2301
2373
  ____exports.UnitTriggerEvent,
2302
2374
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2303
2375
  function()
2304
- local unit = ____exports.Unit:of(getOrderedUnit())
2305
- local issuedOrderId = getIssuedOrderId()
2306
- if unit ~= nil and unit.state == 1 then
2307
- return unit, issuedOrderId
2376
+ local handle = getOrderedUnit()
2377
+ if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
2378
+ local unit = ____exports.Unit:of(handle)
2379
+ if unit.state == 1 then
2380
+ return unit, getIssuedOrderId()
2381
+ end
2308
2382
  end
2309
2383
  return IgnoreEvent
2310
2384
  end
@@ -2326,7 +2400,6 @@ Unit.autoAttackStartEvent = __TS__New(
2326
2400
  )
2327
2401
  Unit.onDamaging = (function()
2328
2402
  local event = __TS__New(Event)
2329
- local invoke = Event.invoke
2330
2403
  local trigger = CreateTrigger()
2331
2404
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
2332
2405
  TriggerAddCondition(
@@ -2336,13 +2409,18 @@ Unit.onDamaging = (function()
2336
2409
  if source and source.typeId == dummyUnitId then
2337
2410
  source = nil
2338
2411
  end
2339
- local target = BlzGetEventDamageTarget()
2412
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2413
+ local metadata = damageMetadataByTarget[target]
2414
+ damageMetadataByTarget[target] = nil
2340
2415
  local data = {
2341
2416
  amount = GetEventDamage(),
2342
- attackType = BlzGetEventAttackType(),
2417
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2343
2418
  damageType = BlzGetEventDamageType(),
2344
2419
  weaponType = BlzGetEventWeaponType(),
2345
- isAttack = BlzGetEventIsAttack()
2420
+ metadata = metadata,
2421
+ isAttack = BlzGetEventIsAttack(),
2422
+ originalAmount = GetEventDamage(),
2423
+ originalMetadata = metadata
2346
2424
  }
2347
2425
  if data.isAttack and source then
2348
2426
  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
@@ -2356,18 +2434,22 @@ Unit.onDamaging = (function()
2356
2434
  invoke(
2357
2435
  event,
2358
2436
  source,
2359
- ____exports.Unit:of(target),
2437
+ target,
2360
2438
  setmetatable(
2361
2439
  {},
2362
2440
  {
2363
2441
  __index = data,
2364
2442
  __newindex = function(self, key, value)
2365
- damageSetters[key](value)
2443
+ local damageSetter = damageSetters[key]
2444
+ if damageSetter ~= nil then
2445
+ damageSetter(value)
2446
+ end
2366
2447
  data[key] = value
2367
2448
  end
2368
2449
  }
2369
2450
  )
2370
2451
  )
2452
+ damagingEventByTarget[target] = data
2371
2453
  return
2372
2454
  end
2373
2455
  BlzSetEventDamage(0)
@@ -2375,7 +2457,7 @@ Unit.onDamaging = (function()
2375
2457
  BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
2376
2458
  BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
2377
2459
  local sourceOwner = source.owner.handle
2378
- local targetOwner = GetOwningPlayer(target)
2460
+ local targetOwner = target.owner.handle
2379
2461
  if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2380
2462
  SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2381
2463
  Timer:run(function()
@@ -2391,23 +2473,19 @@ Unit.onDamaging = (function()
2391
2473
  for ____, ____value in ipairs(source._attackHandlers) do
2392
2474
  local condition = ____value[1]
2393
2475
  local action = ____value[2]
2394
- if condition(
2395
- source,
2396
- ____exports.Unit:of(target),
2397
- data
2398
- ) then
2476
+ if condition(source, target, data) then
2399
2477
  action(
2400
2478
  source,
2401
- ____exports.Unit:of(target),
2479
+ target,
2402
2480
  setmetatable(
2403
2481
  {fire = function()
2404
2482
  UnitDamageTarget(
2405
2483
  source.handle,
2406
- target,
2484
+ target.handle,
2407
2485
  data.amount,
2408
2486
  true,
2409
2487
  true,
2410
- data.attackType,
2488
+ attackTypeToNative(data.attackType),
2411
2489
  data.damageType,
2412
2490
  data.weaponType
2413
2491
  )
@@ -2425,7 +2503,6 @@ end)()
2425
2503
  Unit.onDamage = __TS__New(
2426
2504
  InitializingEvent,
2427
2505
  function(event)
2428
- local invoke = Event.invoke
2429
2506
  local trigger = CreateTrigger()
2430
2507
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
2431
2508
  TriggerAddCondition(
@@ -2435,12 +2512,18 @@ Unit.onDamage = __TS__New(
2435
2512
  if source and source.typeId == dummyUnitId then
2436
2513
  source = nil
2437
2514
  end
2515
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2516
+ local damagingEvent = damagingEventByTarget[target]
2517
+ damagingEventByTarget[target] = nil
2438
2518
  local data = {
2439
2519
  amount = GetEventDamage(),
2440
- attackType = BlzGetEventAttackType(),
2520
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2441
2521
  damageType = BlzGetEventDamageType(),
2442
2522
  weaponType = BlzGetEventWeaponType(),
2523
+ metadata = damagingEvent and damagingEvent.metadata,
2443
2524
  isAttack = BlzGetEventIsAttack(),
2525
+ originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
2526
+ originalMetadata = damagingEvent and damagingEvent.originalMetadata,
2444
2527
  preventDeath = damageEventPreventDeath
2445
2528
  }
2446
2529
  local evData = setmetatable(
@@ -2453,11 +2536,10 @@ Unit.onDamage = __TS__New(
2453
2536
  end
2454
2537
  }
2455
2538
  )
2456
- local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2457
2539
  invoke(event, source, target, evData)
2458
2540
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2459
2541
  local bonusHealth = math.ceil(evData.amount)
2460
- target[104] = (target[104] or 0) + bonusHealth
2542
+ target[105] = (target[105] or 0) + bonusHealth
2461
2543
  BlzSetUnitMaxHP(
2462
2544
  target.handle,
2463
2545
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2471,7 +2553,7 @@ Unit.onDamage = __TS__New(
2471
2553
  evData[0],
2472
2554
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2473
2555
  )
2474
- target[104] = (target[104] or 0) - bonusHealth
2556
+ target[105] = (target[105] or 0) - bonusHealth
2475
2557
  SetWidgetLife(
2476
2558
  target.handle,
2477
2559
  GetWidgetLife(target.handle) - bonusHealth
@@ -2491,32 +2573,91 @@ Unit.onDamage = __TS__New(
2491
2573
  DestroyTrigger(trigger)
2492
2574
  end
2493
2575
  )
2494
- Unit.onItemDrop = __TS__New(
2576
+ Unit.itemDroppedEvent = __TS__New(
2495
2577
  ____exports.UnitTriggerEvent,
2496
2578
  EVENT_PLAYER_UNIT_DROP_ITEM,
2497
2579
  function()
2498
2580
  local unit = getTriggerUnit()
2499
- if getUnitTypeId(unit) ~= dummyUnitId then
2500
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2581
+ local item = getManipulatedItem()
2582
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2583
+ return ____exports.Unit:of(unit), Item:of(item)
2501
2584
  end
2502
2585
  return IgnoreEvent
2503
2586
  end
2504
2587
  )
2505
- Unit.onItemPickup = __TS__New(
2588
+ Unit.itemPickedUpEvent = __TS__New(
2506
2589
  ____exports.UnitTriggerEvent,
2507
2590
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2508
2591
  function()
2509
2592
  local unit = getTriggerUnit()
2510
- if getUnitTypeId(unit) ~= dummyUnitId then
2511
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2593
+ local item = getManipulatedItem()
2594
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2595
+ return ____exports.Unit:of(unit), Item:of(item)
2512
2596
  end
2513
2597
  return IgnoreEvent
2514
2598
  end
2515
2599
  )
2516
- Unit.onItemUse = __TS__New(
2600
+ Unit.itemUsedEvent = __TS__New(
2517
2601
  ____exports.UnitTriggerEvent,
2518
2602
  EVENT_PLAYER_UNIT_USE_ITEM,
2519
- function() return ____exports.Unit:of(GetTriggerUnit()), Item:of(GetManipulatedItem()) end
2603
+ function()
2604
+ local unit = getTriggerUnit()
2605
+ local item = getManipulatedItem()
2606
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2607
+ return ____exports.Unit:of(unit), Item:of(item)
2608
+ end
2609
+ return IgnoreEvent
2610
+ end
2611
+ )
2612
+ Unit.itemStackedEvent = __TS__New(
2613
+ ____exports.UnitTriggerEvent,
2614
+ EVENT_PLAYER_UNIT_STACK_ITEM,
2615
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2616
+ )
2617
+ __TS__ObjectDefineProperty(
2618
+ Unit,
2619
+ "itemUseOrderEvent",
2620
+ {get = function(self)
2621
+ local event = __TS__New(Event)
2622
+ for order = orderId("useslot0"), orderId("useslot5") do
2623
+ local slot = order - orderId("useslot0")
2624
+ local function listener(unit)
2625
+ local item = unit.items[slot + 1]
2626
+ if item ~= nil then
2627
+ invoke(event, unit, item)
2628
+ end
2629
+ end
2630
+ self.onImmediateOrder[order]:addListener(listener)
2631
+ self.onTargetOrder[order]:addListener(listener)
2632
+ self.onPointOrder[order]:addListener(listener)
2633
+ end
2634
+ rawset(self, "itemUseOrderEvent", event)
2635
+ return event
2636
+ end}
2637
+ )
2638
+ __TS__ObjectDefineProperty(
2639
+ Unit,
2640
+ "itemMoveOrderEvent",
2641
+ {get = function(self)
2642
+ local event = __TS__New(Event)
2643
+ for order = orderId("moveslot0"), orderId("moveslot5") do
2644
+ local slotTo = order - orderId("moveslot0")
2645
+ self.onTargetOrder[order]:addListener(function(unit, item)
2646
+ local slotFrom = unit.items:findSlot(item)
2647
+ if slotFrom ~= nil then
2648
+ invoke(
2649
+ event,
2650
+ unit,
2651
+ item,
2652
+ slotFrom,
2653
+ slotTo
2654
+ )
2655
+ end
2656
+ end)
2657
+ end
2658
+ rawset(self, "itemMoveOrderEvent", event)
2659
+ return event
2660
+ end}
2520
2661
  )
2521
2662
  __TS__ObjectDefineProperty(
2522
2663
  Unit,