warscript 0.0.1-dev.d30161d → 0.0.1-dev.d3ce64a

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 (179) 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 +14 -6
  6. package/core/types/effect.lua +131 -35
  7. package/core/types/frame.d.ts +6 -0
  8. package/core/types/frame.lua +91 -1
  9. package/core/types/order.d.ts +1 -0
  10. package/core/types/order.lua +11 -1
  11. package/core/types/sound.d.ts +17 -24
  12. package/core/types/sound.lua +99 -24
  13. package/core/types/timer.d.ts +6 -7
  14. package/core/types/timer.lua +18 -21
  15. package/core/util.d.ts +1 -1
  16. package/core/util.lua +18 -1
  17. package/decl/native.d.ts +840 -786
  18. package/engine/behavior.d.ts +2 -2
  19. package/engine/behavior.lua +6 -6
  20. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  21. package/engine/behaviour/ability/always-enabled.lua +31 -0
  22. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  23. package/engine/behaviour/ability/apply-buff.lua +32 -0
  24. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  25. package/engine/behaviour/ability/damage.d.ts +9 -3
  26. package/engine/behaviour/ability/damage.lua +26 -38
  27. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  28. package/engine/behaviour/ability/emulate-impact.lua +35 -0
  29. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  30. package/engine/behaviour/ability/instant-impact.lua +4 -19
  31. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  32. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  33. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  34. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  35. package/engine/behaviour/ability.d.ts +20 -4
  36. package/engine/behaviour/ability.lua +111 -38
  37. package/engine/behaviour/unit.d.ts +17 -0
  38. package/engine/behaviour/unit.lua +105 -0
  39. package/engine/buff.d.ts +84 -43
  40. package/engine/buff.lua +385 -226
  41. package/engine/internal/ability.d.ts +18 -13
  42. package/engine/internal/ability.lua +87 -76
  43. package/engine/internal/item/ability.lua +106 -0
  44. package/engine/internal/item+owner.lua +2 -2
  45. package/engine/internal/item.d.ts +4 -3
  46. package/engine/internal/item.lua +56 -25
  47. package/engine/internal/mechanics/ability-duration.lua +1 -1
  48. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  49. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  50. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  51. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  52. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  53. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  54. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  55. package/engine/internal/object-data/evasion-probability.lua +16 -0
  56. package/engine/internal/unit/ability.d.ts +10 -1
  57. package/engine/internal/unit/ability.lua +36 -14
  58. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  59. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  60. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  61. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  62. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  63. package/engine/internal/unit/allowed-targets.lua +9 -1
  64. package/engine/internal/unit/bonus.d.ts +6 -2
  65. package/engine/internal/unit/bonus.lua +23 -1
  66. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  67. package/engine/internal/unit/ignore-events-items.lua +5 -0
  68. package/engine/internal/unit/item.d.ts +24 -0
  69. package/engine/internal/unit/item.lua +78 -0
  70. package/engine/internal/unit/main-selected.d.ts +13 -0
  71. package/engine/internal/unit/main-selected.lua +51 -0
  72. package/engine/internal/unit+ability.lua +2 -2
  73. package/engine/internal/unit+damage.d.ts +2 -11
  74. package/engine/internal/unit+damage.lua +10 -14
  75. package/engine/internal/unit+spellSteal.lua +1 -2
  76. package/engine/internal/unit-missile-launch.lua +25 -6
  77. package/engine/internal/unit.d.ts +50 -13
  78. package/engine/internal/unit.lua +314 -116
  79. package/engine/internal/utility.lua +12 -0
  80. package/engine/lightning.d.ts +12 -5
  81. package/engine/lightning.lua +48 -14
  82. package/engine/local-client.d.ts +7 -2
  83. package/engine/local-client.lua +82 -0
  84. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  85. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  86. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  87. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  88. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  89. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  90. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  91. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  92. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  93. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  94. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  95. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  96. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  97. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  98. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  99. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  100. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  101. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  102. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  103. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  104. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  105. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  106. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  107. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  108. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  109. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  110. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  111. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  112. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  113. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  114. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  115. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  116. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  117. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  118. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  119. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  120. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  121. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  122. package/engine/object-data/entry/ability-type/web.lua +52 -0
  123. package/engine/object-data/entry/ability-type.d.ts +19 -17
  124. package/engine/object-data/entry/ability-type.lua +89 -33
  125. package/engine/object-data/entry/buff-type/applicable.lua +18 -37
  126. package/engine/object-data/entry/buff-type.d.ts +6 -12
  127. package/engine/object-data/entry/buff-type.lua +13 -29
  128. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  129. package/engine/object-data/entry/item-type.d.ts +15 -1
  130. package/engine/object-data/entry/item-type.lua +93 -2
  131. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  132. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  133. package/engine/object-data/entry/sound-preset.lua +140 -0
  134. package/engine/object-data/entry/unit-type.d.ts +10 -3
  135. package/engine/object-data/entry/unit-type.lua +155 -92
  136. package/engine/object-data/entry/upgrade.d.ts +1 -1
  137. package/engine/object-data/entry/upgrade.lua +4 -4
  138. package/engine/object-data/entry.d.ts +16 -14
  139. package/engine/object-data/entry.lua +60 -32
  140. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  141. package/engine/object-field/ability.d.ts +26 -3
  142. package/engine/object-field/ability.lua +54 -1
  143. package/engine/object-field/unit.d.ts +46 -3
  144. package/engine/object-field/unit.lua +173 -7
  145. package/engine/object-field.d.ts +11 -3
  146. package/engine/object-field.lua +162 -76
  147. package/engine/standard/entries/buff-type.d.ts +3 -0
  148. package/engine/standard/entries/buff-type.lua +3 -0
  149. package/engine/standard/entries/sound-preset.d.ts +10 -0
  150. package/engine/standard/entries/sound-preset.lua +10 -0
  151. package/engine/standard/fields/ability.d.ts +2 -0
  152. package/engine/standard/fields/ability.lua +2 -0
  153. package/engine/unit.d.ts +3 -0
  154. package/engine/unit.lua +3 -0
  155. package/index.d.ts +1 -0
  156. package/index.lua +1 -0
  157. package/net/socket.d.ts +7 -1
  158. package/net/socket.lua +45 -4
  159. package/network.d.ts +1 -0
  160. package/network.lua +3 -2
  161. package/objutil/buff.lua +2 -3
  162. package/objutil/unit.lua +8 -0
  163. package/package.json +2 -2
  164. package/patch-lua.d.ts +0 -0
  165. package/patch-lua.lua +10 -0
  166. package/utility/arrays.d.ts +9 -1
  167. package/utility/arrays.lua +37 -3
  168. package/utility/functions.d.ts +1 -0
  169. package/utility/functions.lua +1 -0
  170. package/utility/lazy.d.ts +2 -0
  171. package/utility/lazy.lua +14 -0
  172. package/utility/linked-set.d.ts +12 -2
  173. package/utility/linked-set.lua +8 -2
  174. package/utility/lua-maps.d.ts +3 -0
  175. package/utility/lua-maps.lua +16 -0
  176. package/utility/lua-sets.d.ts +1 -0
  177. package/utility/lua-sets.lua +3 -0
  178. package/utility/reflection.lua +11 -7
  179. package/utility/types.d.ts +1 -0
@@ -51,12 +51,19 @@ local ____arrays = require("utility.arrays")
51
51
  local forEach = ____arrays.forEach
52
52
  local ____math = require("math")
53
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
61
+ local ____attributes = require("attributes")
62
+ local isAttribute = ____attributes.isAttribute
54
63
  local match = string.match
55
64
  local ____tostring = _G.tostring
56
65
  local setUnitAnimation = SetUnitAnimation
57
- local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
58
66
  local setUnitAnimationByIndex = SetUnitAnimationByIndex
59
- local queueUnitAnimation = QueueUnitAnimation
60
67
  local getUnitIntegerField = BlzGetUnitIntegerField
61
68
  local getUnitRealField = BlzGetUnitRealField
62
69
  local getHeroStr = GetHeroStr
@@ -75,9 +82,9 @@ local setUnitScale = SetUnitScale
75
82
  local setUnitPosition = SetUnitPosition
76
83
  local setUnitTimeScale = SetUnitTimeScale
77
84
  local getHandleId = GetHandleId
85
+ local getUnitCurrentOrder = GetUnitCurrentOrder
78
86
  local createUnit = CreateUnit
79
87
  local killUnit = KillUnit
80
- local setUnitExploded = SetUnitExploded
81
88
  local removeUnit = RemoveUnit
82
89
  local getUnitTypeId = GetUnitTypeId
83
90
  local isHeroUnitId = IsHeroUnitId
@@ -93,8 +100,6 @@ local getSpellTargetItem = GetSpellTargetItem
93
100
  local getSpellTargetDestructable = GetSpellTargetDestructable
94
101
  local isUnitInRangeXY = IsUnitInRangeXY
95
102
  local isUnitInRange = IsUnitInRange
96
- local setResourceAmount = SetResourceAmount
97
- local getResourceAmount = GetResourceAmount
98
103
  local getUnitWeaponRealField = BlzGetUnitWeaponRealField
99
104
  local setUnitWeaponRealField = BlzSetUnitWeaponRealField
100
105
  local getUnitWeaponStringField = BlzGetUnitWeaponStringField
@@ -125,8 +130,6 @@ local isUnitType = IsUnitType
125
130
  local isUnitAlly = IsUnitAlly
126
131
  local isUnitEnemy = IsUnitEnemy
127
132
  local getOwningPlayer = GetOwningPlayer
128
- local setUnitColor = SetUnitColor
129
- local showUnitTeamGlow = BlzShowUnitTeamGlow
130
133
  ____exports.UnitClassification = {}
131
134
  local UnitClassification = ____exports.UnitClassification
132
135
  do
@@ -136,6 +139,7 @@ do
136
139
  UnitClassification.GROUND = UNIT_TYPE_GROUND
137
140
  UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
138
141
  UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
142
+ UnitClassification.WORKER = UNIT_TYPE_PEON
139
143
  UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
140
144
  UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
141
145
  UnitClassification.TAUREN = UNIT_TYPE_TAUREN
@@ -343,6 +347,9 @@ local function dispatchAbility(event)
343
347
  }
344
348
  )
345
349
  end
350
+ local function damagingEventPreventRetaliation(self)
351
+ self[0] = true
352
+ end
346
353
  local function damageEventPreventDeath(self, callback, ...)
347
354
  if self[0] ~= nil then
348
355
  return
@@ -354,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
354
361
  rawset(self, 1 + i, (select(i, ...)))
355
362
  end
356
363
  end
357
- local damageSetters = {amount = BlzSetEventDamage, attackType = BlzSetEventAttackType, damageType = BlzSetEventDamageType, weaponType = BlzSetEventWeaponType}
364
+ local damageSetters = {
365
+ amount = BlzSetEventDamage,
366
+ attackType = function(attackType)
367
+ return BlzSetEventAttackType(attackTypeToNative(attackType))
368
+ end,
369
+ damageType = BlzSetEventDamageType,
370
+ weaponType = BlzSetEventWeaponType
371
+ }
358
372
  local jlimitopByOperator = {
359
373
  [0] = LESS_THAN_OR_EQUAL,
360
374
  [1] = LESS_THAN_OR_EQUAL,
@@ -432,6 +446,19 @@ __TS__SetDescriptor(
432
446
  },
433
447
  true
434
448
  )
449
+ __TS__SetDescriptor(
450
+ UnitWeapon.prototype,
451
+ "allowedTargetCombatClassifications",
452
+ {
453
+ get = function(self)
454
+ return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
455
+ end,
456
+ set = function(self, allowedTargetCombatClassifications)
457
+ BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
458
+ end
459
+ },
460
+ true
461
+ )
435
462
  __TS__SetDescriptor(
436
463
  UnitWeapon.prototype,
437
464
  "damageBase",
@@ -562,17 +589,6 @@ local function retrieveAbility(unit, ability, abilityId)
562
589
  ____exports.Unit:of(unit)
563
590
  )
564
591
  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
592
  for i = 0, unitInventorySize(unit) - 1 do
577
593
  local item = unitItemInSlot(unit, i)
578
594
  if getItemAbility(item, abilityId) == ability then
@@ -630,15 +646,15 @@ for ____, player in ipairs(Player.all) do
630
646
  dummies[player] = dummy
631
647
  end
632
648
  local function delayHealthChecksCallback(unit)
633
- local counter = (unit[102] or 0) - 1
649
+ local counter = (unit[103] or 0) - 1
634
650
  if counter ~= 0 then
635
- unit[102] = counter
651
+ unit[103] = counter
636
652
  return
637
653
  end
638
- unit[102] = nil
639
- local healthBonus = unit[103]
654
+ unit[103] = nil
655
+ local healthBonus = unit[104]
640
656
  if healthBonus ~= nil then
641
- unit[103] = nil
657
+ unit[104] = nil
642
658
  local handle = unit.handle
643
659
  BlzSetUnitMaxHP(
644
660
  handle,
@@ -646,12 +662,18 @@ local function delayHealthChecksCallback(unit)
646
662
  )
647
663
  end
648
664
  end
665
+ local nextSyncId = 1
666
+ local unitBySyncId = setmetatable({}, {__mode = "v"})
667
+ local damagingEventByTarget = setmetatable({}, {__mode = "k"})
649
668
  ____exports.Unit = __TS__Class()
650
669
  local Unit = ____exports.Unit
651
670
  Unit.name = "Unit"
652
671
  __TS__ClassExtends(Unit, Handle)
653
672
  function Unit.prototype.____constructor(self, handle)
654
673
  Handle.prototype.____constructor(self, handle)
674
+ local ____nextSyncId_0 = nextSyncId
675
+ nextSyncId = ____nextSyncId_0 + 1
676
+ self.syncId = ____nextSyncId_0
655
677
  self._owner = Player:of(getOwningPlayer(handle))
656
678
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
657
679
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -664,6 +686,7 @@ function Unit.prototype.____constructor(self, handle)
664
686
  fourCC("Amrf")
665
687
  ))
666
688
  end
689
+ unitBySyncId[self.syncId] = self
667
690
  local ____ = self.abilities
668
691
  end
669
692
  function Unit.prototype.getEvent(self, event, collector)
@@ -682,6 +705,8 @@ function Unit.prototype.getEvent(self, event, collector)
682
705
  end
683
706
  function Unit.prototype.onDestroy(self)
684
707
  local handle = self.handle
708
+ self[107] = getUnitX(handle)
709
+ self[108] = getUnitY(handle)
685
710
  if not self._owner then
686
711
  self._owner = Player:of(getOwningPlayer(handle))
687
712
  end
@@ -749,8 +774,8 @@ function Unit.prototype.addModifier(self, property, modifier)
749
774
  end}
750
775
  end
751
776
  function Unit.prototype.hasCombatClassification(self, combatClassification)
752
- local ____combatClassification_0 = combatClassification
753
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_0 == ____combatClassification_0
777
+ local ____combatClassification_1 = combatClassification
778
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
754
779
  end
755
780
  function Unit.prototype.addClassification(self, classification)
756
781
  return unitAddType(self.handle, classification)
@@ -768,13 +793,13 @@ function Unit.prototype.isInvisibleTo(self, player)
768
793
  return isUnitInvisible(self.handle, player.handle)
769
794
  end
770
795
  function Unit.prototype.isInRangeOf(self, x, y, range)
771
- local ____temp_1
796
+ local ____temp_2
772
797
  if type(x) == "number" then
773
- ____temp_1 = isUnitInRangeXY(self.handle, x, y, range)
798
+ ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
774
799
  else
775
- ____temp_1 = isUnitInRange(self.handle, x.handle, y)
800
+ ____temp_2 = isUnitInRange(self.handle, x.handle, y)
776
801
  end
777
- return ____temp_1
802
+ return ____temp_2
778
803
  end
779
804
  function Unit.prototype.isAllyOf(self, unit)
780
805
  return isUnitAlly(
@@ -792,16 +817,28 @@ function Unit.prototype.playAnimation(self, animation, rarity)
792
817
  if type(animation) == "number" then
793
818
  setUnitAnimationByIndex(self.handle, animation)
794
819
  elseif rarity then
795
- setUnitAnimationWithRarity(self.handle, animation, rarity)
820
+ SetUnitAnimationWithRarity(self.handle, animation, rarity)
796
821
  else
797
822
  setUnitAnimation(self.handle, animation)
798
823
  end
799
824
  end
825
+ function Unit.prototype.resetAnimation(self)
826
+ ResetUnitAnimation(self.handle)
827
+ end
800
828
  function Unit.prototype.queueAnimation(self, animation)
801
- queueUnitAnimation(self.handle, animation)
829
+ QueueUnitAnimation(self.handle, animation)
830
+ end
831
+ function Unit.prototype.chooseWeapon(self, target)
832
+ if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
833
+ return self.firstWeapon
834
+ end
835
+ if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
836
+ return self.secondWeapon
837
+ end
838
+ return nil
802
839
  end
803
840
  function Unit.prototype.delayHealthChecks(self)
804
- self[102] = (self[102] or 0) + 1
841
+ self[103] = (self[103] or 0) + 1
805
842
  Timer:run(delayHealthChecksCallback, self)
806
843
  end
807
844
  function Unit.prototype.setPosition(self, x, y)
@@ -811,21 +848,21 @@ function Unit.prototype.isSelected(self, player)
811
848
  return IsUnitSelected(self.handle, player.handle)
812
849
  end
813
850
  function Unit.prototype.explode(self)
814
- setUnitExploded(self.handle, true)
851
+ SetUnitExploded(self.handle, true)
815
852
  killUnit(self.handle)
816
853
  end
817
854
  function Unit.prototype.kill(self)
818
855
  killUnit(self.handle)
819
856
  end
820
857
  function Unit.prototype.revive(self, x, y, doEffect)
821
- local ____ReviveHero_4 = ReviveHero
822
- local ____array_3 = __TS__SparseArrayNew(self.handle, x, y)
823
- local ____doEffect_2 = doEffect
824
- if ____doEffect_2 == nil then
825
- ____doEffect_2 = false
858
+ local ____ReviveHero_5 = ReviveHero
859
+ local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
860
+ local ____doEffect_3 = doEffect
861
+ if ____doEffect_3 == nil then
862
+ ____doEffect_3 = false
826
863
  end
827
- __TS__SparseArrayPush(____array_3, ____doEffect_2)
828
- ____ReviveHero_4(__TS__SparseArraySpread(____array_3))
864
+ __TS__SparseArrayPush(____array_4, ____doEffect_3)
865
+ ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
829
866
  end
830
867
  function Unit.prototype.healTarget(self, target, amount)
831
868
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -865,7 +902,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
865
902
  return UnitDropItemSlot(self.handle, item.handle, slot)
866
903
  end
867
904
  function Unit.prototype.itemInSlot(self, slot)
868
- return Item:of(UnitItemInSlot(self.handle, slot))
905
+ return Item:of(unitItemInSlot(self.handle, slot))
869
906
  end
870
907
  function Unit.prototype.addAbility(self, abilityId)
871
908
  if unitAddAbility(self.handle, abilityId) then
@@ -934,8 +971,15 @@ function Unit.prototype.interruptAttack(self)
934
971
  unitInterruptAttack(self.handle)
935
972
  end
936
973
  function Unit.prototype.interruptCast(self, abilityId)
937
- unitDisableAbility(self.handle, abilityId, true, false)
938
- unitDisableAbility(self.handle, abilityId, false, false)
974
+ local handle = self.handle
975
+ unitDisableAbility(handle, abilityId, true, false)
976
+ Timer:run(
977
+ unitDisableAbility,
978
+ handle,
979
+ abilityId,
980
+ false,
981
+ false
982
+ )
939
983
  end
940
984
  function Unit.prototype.getDistanceTo(self, target)
941
985
  local handle = self.handle
@@ -995,18 +1039,18 @@ function Unit.prototype.unpauseEx(self)
995
1039
  self:decrementStunCounter()
996
1040
  end
997
1041
  function Unit.prototype.incrementStunCounter(self)
998
- local stunCounter = self[101] or 0
999
- if not self[100] or stunCounter >= 0 then
1042
+ local stunCounter = self[102] or 0
1043
+ if not self[101] or stunCounter >= 0 then
1000
1044
  BlzPauseUnitEx(self.handle, true)
1001
1045
  end
1002
- self[101] = stunCounter + 1
1046
+ self[102] = stunCounter + 1
1003
1047
  end
1004
1048
  function Unit.prototype.decrementStunCounter(self)
1005
- local stunCounter = self[101] or 0
1006
- if not self[100] or stunCounter >= 1 then
1049
+ local stunCounter = self[102] or 0
1050
+ if not self[101] or stunCounter >= 1 then
1007
1051
  BlzPauseUnitEx(self.handle, false)
1008
1052
  end
1009
- self[101] = stunCounter - 1
1053
+ self[102] = stunCounter - 1
1010
1054
  end
1011
1055
  function Unit.create(self, owner, id, x, y, facing, skinId)
1012
1056
  local handle = skinId and BlzCreateUnitWithSkin(
@@ -1108,8 +1152,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
1108
1152
  )
1109
1153
  return targetCollection
1110
1154
  end
1111
- function Unit.getSelectionOf(self, player)
1112
- targetCollection = {}
1155
+ function Unit.getSelectionOf(self, player, target)
1156
+ if target == nil then
1157
+ target = {}
1158
+ end
1159
+ targetCollection = target
1113
1160
  targetCollectionNextIndex = 1
1114
1161
  GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
1115
1162
  return targetCollection
@@ -1131,6 +1178,9 @@ end
1131
1178
  function Unit.prototype.__tostring(self)
1132
1179
  return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
1133
1180
  end
1181
+ function Unit.getBySyncId(self, syncId)
1182
+ return unitBySyncId[syncId]
1183
+ end
1134
1184
  __TS__SetDescriptor(
1135
1185
  Unit.prototype,
1136
1186
  "_deltas",
@@ -1194,6 +1244,14 @@ __TS__SetDescriptor(
1194
1244
  end},
1195
1245
  true
1196
1246
  )
1247
+ __TS__SetDescriptor(
1248
+ Unit.prototype,
1249
+ "isStunned",
1250
+ {get = function(self)
1251
+ return getUnitCurrentOrder(self.handle) == orderId("stunned")
1252
+ end},
1253
+ true
1254
+ )
1197
1255
  __TS__SetDescriptor(
1198
1256
  Unit.prototype,
1199
1257
  "combatClassifications",
@@ -1267,6 +1325,19 @@ __TS__SetDescriptor(
1267
1325
  },
1268
1326
  true
1269
1327
  )
1328
+ __TS__SetDescriptor(
1329
+ Unit.prototype,
1330
+ "primaryAttribute",
1331
+ {
1332
+ get = function(self)
1333
+ return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
1334
+ end,
1335
+ set = function(self, primaryAttribute)
1336
+ setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
1337
+ end
1338
+ },
1339
+ true
1340
+ )
1270
1341
  __TS__SetDescriptor(
1271
1342
  Unit.prototype,
1272
1343
  "strengthBase",
@@ -1388,17 +1459,17 @@ __TS__SetDescriptor(
1388
1459
  "isTeamGlowVisible",
1389
1460
  {
1390
1461
  get = function(self)
1391
- return not self[105]
1462
+ return not self[106]
1392
1463
  end,
1393
1464
  set = function(self, isTeamGlowVisible)
1394
- showUnitTeamGlow(self.handle, isTeamGlowVisible)
1395
- local ____temp_5
1465
+ BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1466
+ local ____temp_6
1396
1467
  if not isTeamGlowVisible then
1397
- ____temp_5 = true
1468
+ ____temp_6 = true
1398
1469
  else
1399
- ____temp_5 = nil
1470
+ ____temp_6 = nil
1400
1471
  end
1401
- self[105] = ____temp_5
1472
+ self[106] = ____temp_6
1402
1473
  end
1403
1474
  },
1404
1475
  true
@@ -1407,9 +1478,9 @@ __TS__SetDescriptor(
1407
1478
  Unit.prototype,
1408
1479
  "color",
1409
1480
  {set = function(self, color)
1410
- setUnitColor(self.handle, color.handle)
1411
- if self[105] then
1412
- showUnitTeamGlow(self.handle, false)
1481
+ SetUnitColor(self.handle, color.handle)
1482
+ if self[106] then
1483
+ BlzShowUnitTeamGlow(self.handle, false)
1413
1484
  end
1414
1485
  end},
1415
1486
  true
@@ -1432,14 +1503,14 @@ __TS__SetDescriptor(
1432
1503
  "maxHealth",
1433
1504
  {
1434
1505
  get = function(self)
1435
- return BlzGetUnitMaxHP(self.handle) - (self[103] or 0) - (self[104] or 0)
1506
+ return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1436
1507
  end,
1437
1508
  set = function(self, maxHealth)
1438
- if maxHealth < 1 and self[102] ~= nil then
1439
- self[103] = (self[103] or 0) + (1 - maxHealth)
1509
+ if maxHealth < 1 and self[103] ~= nil then
1510
+ self[104] = (self[104] or 0) + (1 - maxHealth)
1440
1511
  maxHealth = 1
1441
1512
  end
1442
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[104] or 0))
1513
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1443
1514
  end
1444
1515
  },
1445
1516
  true
@@ -1481,10 +1552,10 @@ __TS__SetDescriptor(
1481
1552
  "health",
1482
1553
  {
1483
1554
  get = function(self)
1484
- return GetWidgetLife(self.handle) - (self[104] or 0)
1555
+ return GetWidgetLife(self.handle) - (self[105] or 0)
1485
1556
  end,
1486
1557
  set = function(self, health)
1487
- SetWidgetLife(self.handle, health + (self[104] or 0))
1558
+ SetWidgetLife(self.handle, health + (self[105] or 0))
1488
1559
  end
1489
1560
  },
1490
1561
  true
@@ -1578,7 +1649,7 @@ __TS__SetDescriptor(
1578
1649
  "x",
1579
1650
  {
1580
1651
  get = function(self)
1581
- return getUnitX(self.handle)
1652
+ return self[107] or getUnitX(self.handle)
1582
1653
  end,
1583
1654
  set = function(self, v)
1584
1655
  SetUnitX(self.handle, v)
@@ -1591,7 +1662,7 @@ __TS__SetDescriptor(
1591
1662
  "y",
1592
1663
  {
1593
1664
  get = function(self)
1594
- return getUnitY(self.handle)
1665
+ return self[108] or getUnitY(self.handle)
1595
1666
  end,
1596
1667
  set = function(self, v)
1597
1668
  SetUnitY(self.handle, v)
@@ -1677,10 +1748,10 @@ __TS__SetDescriptor(
1677
1748
  "gold",
1678
1749
  {
1679
1750
  get = function(self)
1680
- return getResourceAmount(self.handle)
1751
+ return GetResourceAmount(self.handle)
1681
1752
  end,
1682
1753
  set = function(self, gold)
1683
- setResourceAmount(self.handle, gold)
1754
+ SetResourceAmount(self.handle, gold)
1684
1755
  end
1685
1756
  },
1686
1757
  true
@@ -1695,17 +1766,17 @@ __TS__SetDescriptor(
1695
1766
  set = function(self, isPaused)
1696
1767
  local handle = self.handle
1697
1768
  if isPaused and not IsUnitPaused(handle) then
1698
- self[100] = true
1699
- for _ = self[101] or 0, -1 do
1769
+ self[101] = true
1770
+ for _ = self[102] or 0, -1 do
1700
1771
  BlzPauseUnitEx(handle, true)
1701
1772
  end
1702
1773
  PauseUnit(handle, true)
1703
1774
  elseif not isPaused and IsUnitPaused(handle) then
1704
1775
  PauseUnit(handle, false)
1705
- for _ = self[101] or 0, -1 do
1776
+ for _ = self[102] or 0, -1 do
1706
1777
  BlzPauseUnitEx(handle, false)
1707
1778
  end
1708
- self[100] = nil
1779
+ self[101] = nil
1709
1780
  end
1710
1781
  end
1711
1782
  },
@@ -1808,6 +1879,19 @@ __TS__SetDescriptor(
1808
1879
  end},
1809
1880
  true
1810
1881
  )
1882
+ __TS__SetDescriptor(
1883
+ Unit.prototype,
1884
+ "movementType",
1885
+ {
1886
+ get = function(self)
1887
+ return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
1888
+ end,
1889
+ set = function(self, movementType)
1890
+ setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
1891
+ end
1892
+ },
1893
+ true
1894
+ )
1811
1895
  __TS__SetDescriptor(
1812
1896
  Unit.prototype,
1813
1897
  "pathing",
@@ -1989,6 +2073,14 @@ __TS__SetDescriptor(
1989
2073
  end},
1990
2074
  true
1991
2075
  )
2076
+ __TS__SetDescriptor(
2077
+ Unit.prototype,
2078
+ "targetAcquiredEvent",
2079
+ {get = function(self)
2080
+ return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
2081
+ end},
2082
+ true
2083
+ )
1992
2084
  __TS__SetDescriptor(
1993
2085
  Unit.prototype,
1994
2086
  "onSelect",
@@ -2124,25 +2216,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2124
2216
  InitializingEvent,
2125
2217
  function(event)
2126
2218
  local function listener(unit, id)
2127
- local ____GetSpellTargetUnit_result_8
2219
+ local ____GetSpellTargetUnit_result_9
2128
2220
  if GetSpellTargetUnit() then
2129
- ____GetSpellTargetUnit_result_8 = ____exports.Unit:of(GetSpellTargetUnit())
2221
+ ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2130
2222
  else
2131
- local ____GetSpellTargetItem_result_7
2223
+ local ____GetSpellTargetItem_result_8
2132
2224
  if GetSpellTargetItem() then
2133
- ____GetSpellTargetItem_result_7 = Item:of(GetSpellTargetItem())
2225
+ ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2134
2226
  else
2135
- local ____GetSpellTargetDestructable_result_6
2227
+ local ____GetSpellTargetDestructable_result_7
2136
2228
  if GetSpellTargetDestructable() then
2137
- ____GetSpellTargetDestructable_result_6 = Destructable:of(GetSpellTargetDestructable())
2229
+ ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2138
2230
  else
2139
- ____GetSpellTargetDestructable_result_6 = nil
2231
+ ____GetSpellTargetDestructable_result_7 = nil
2140
2232
  end
2141
- ____GetSpellTargetItem_result_7 = ____GetSpellTargetDestructable_result_6
2233
+ ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2142
2234
  end
2143
- ____GetSpellTargetUnit_result_8 = ____GetSpellTargetItem_result_7
2235
+ ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2144
2236
  end
2145
- local target = ____GetSpellTargetUnit_result_8
2237
+ local target = ____GetSpellTargetUnit_result_9
2146
2238
  if target then
2147
2239
  invoke(event, unit, id, target)
2148
2240
  end
@@ -2314,10 +2406,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2314
2406
  ____exports.UnitTriggerEvent,
2315
2407
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2316
2408
  function()
2317
- local unit = ____exports.Unit:of(getOrderedUnit())
2318
- local issuedOrderId = getIssuedOrderId()
2319
- if unit ~= nil and unit.state == 1 then
2320
- return unit, issuedOrderId
2409
+ local handle = getOrderedUnit()
2410
+ if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
2411
+ local unit = ____exports.Unit:of(handle)
2412
+ if unit.state == 1 then
2413
+ return unit, getIssuedOrderId()
2414
+ end
2321
2415
  end
2322
2416
  return IgnoreEvent
2323
2417
  end
@@ -2348,13 +2442,19 @@ Unit.onDamaging = (function()
2348
2442
  if source and source.typeId == dummyUnitId then
2349
2443
  source = nil
2350
2444
  end
2351
- local target = BlzGetEventDamageTarget()
2445
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2446
+ local metadata = damageMetadataByTarget[target]
2447
+ damageMetadataByTarget[target] = nil
2352
2448
  local data = {
2353
2449
  amount = GetEventDamage(),
2354
- attackType = BlzGetEventAttackType(),
2450
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2355
2451
  damageType = BlzGetEventDamageType(),
2356
2452
  weaponType = BlzGetEventWeaponType(),
2357
- isAttack = BlzGetEventIsAttack()
2453
+ metadata = metadata,
2454
+ isAttack = BlzGetEventIsAttack(),
2455
+ originalAmount = GetEventDamage(),
2456
+ originalMetadata = metadata,
2457
+ preventRetaliation = damagingEventPreventRetaliation
2358
2458
  }
2359
2459
  if data.isAttack and source then
2360
2460
  local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
@@ -2368,18 +2468,36 @@ Unit.onDamaging = (function()
2368
2468
  invoke(
2369
2469
  event,
2370
2470
  source,
2371
- ____exports.Unit:of(target),
2471
+ target,
2372
2472
  setmetatable(
2373
2473
  {},
2374
2474
  {
2375
2475
  __index = data,
2376
2476
  __newindex = function(self, key, value)
2377
- damageSetters[key](value)
2477
+ local damageSetter = damageSetters[key]
2478
+ if damageSetter ~= nil then
2479
+ damageSetter(value)
2480
+ end
2378
2481
  data[key] = value
2379
2482
  end
2380
2483
  }
2381
2484
  )
2382
2485
  )
2486
+ if data[0] and source then
2487
+ local sourceOwner = source.owner.handle
2488
+ data[1] = sourceOwner
2489
+ local targetOwner = target.owner.handle
2490
+ data[2] = targetOwner
2491
+ if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2492
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2493
+ data[3] = true
2494
+ end
2495
+ if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
2496
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
2497
+ data[4] = true
2498
+ end
2499
+ end
2500
+ damagingEventByTarget[target] = data
2383
2501
  return
2384
2502
  end
2385
2503
  BlzSetEventDamage(0)
@@ -2387,7 +2505,7 @@ Unit.onDamaging = (function()
2387
2505
  BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
2388
2506
  BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
2389
2507
  local sourceOwner = source.owner.handle
2390
- local targetOwner = GetOwningPlayer(target)
2508
+ local targetOwner = target.owner.handle
2391
2509
  if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2392
2510
  SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2393
2511
  Timer:run(function()
@@ -2403,23 +2521,19 @@ Unit.onDamaging = (function()
2403
2521
  for ____, ____value in ipairs(source._attackHandlers) do
2404
2522
  local condition = ____value[1]
2405
2523
  local action = ____value[2]
2406
- if condition(
2407
- source,
2408
- ____exports.Unit:of(target),
2409
- data
2410
- ) then
2524
+ if condition(source, target, data) then
2411
2525
  action(
2412
2526
  source,
2413
- ____exports.Unit:of(target),
2527
+ target,
2414
2528
  setmetatable(
2415
2529
  {fire = function()
2416
2530
  UnitDamageTarget(
2417
2531
  source.handle,
2418
- target,
2532
+ target.handle,
2419
2533
  data.amount,
2420
2534
  true,
2421
2535
  true,
2422
- data.attackType,
2536
+ attackTypeToNative(data.attackType),
2423
2537
  data.damageType,
2424
2538
  data.weaponType
2425
2539
  )
@@ -2446,29 +2560,54 @@ Unit.onDamage = __TS__New(
2446
2560
  if source and source.typeId == dummyUnitId then
2447
2561
  source = nil
2448
2562
  end
2563
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2564
+ local damagingEvent = damagingEventByTarget[target]
2565
+ damagingEventByTarget[target] = nil
2449
2566
  local data = {
2450
2567
  amount = GetEventDamage(),
2451
- attackType = BlzGetEventAttackType(),
2568
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2452
2569
  damageType = BlzGetEventDamageType(),
2453
2570
  weaponType = BlzGetEventWeaponType(),
2571
+ metadata = damagingEvent and damagingEvent.metadata,
2454
2572
  isAttack = BlzGetEventIsAttack(),
2573
+ originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
2574
+ originalMetadata = damagingEvent and damagingEvent.originalMetadata,
2455
2575
  preventDeath = damageEventPreventDeath
2456
2576
  }
2577
+ if damagingEvent then
2578
+ for key, value in pairs(damagingEvent) do
2579
+ if isAttribute(key) then
2580
+ data[key] = value
2581
+ end
2582
+ end
2583
+ local sourceOwner = damagingEvent[1]
2584
+ if sourceOwner then
2585
+ local targetOwner = damagingEvent[2]
2586
+ if damagingEvent[3] then
2587
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
2588
+ end
2589
+ if damagingEvent[4] then
2590
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
2591
+ end
2592
+ end
2593
+ end
2457
2594
  local evData = setmetatable(
2458
2595
  {},
2459
2596
  {
2460
2597
  __index = data,
2461
2598
  __newindex = function(self, key, value)
2462
- damageSetters[key](value)
2599
+ local damageSetter = damageSetters[key]
2600
+ if damageSetter ~= nil then
2601
+ damageSetter(value)
2602
+ end
2463
2603
  data[key] = value
2464
2604
  end
2465
2605
  }
2466
2606
  )
2467
- local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2468
2607
  invoke(event, source, target, evData)
2469
2608
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2470
2609
  local bonusHealth = math.ceil(evData.amount)
2471
- target[104] = (target[104] or 0) + bonusHealth
2610
+ target[105] = (target[105] or 0) + bonusHealth
2472
2611
  BlzSetUnitMaxHP(
2473
2612
  target.handle,
2474
2613
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2482,7 +2621,7 @@ Unit.onDamage = __TS__New(
2482
2621
  evData[0],
2483
2622
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2484
2623
  )
2485
- target[104] = (target[104] or 0) - bonusHealth
2624
+ target[105] = (target[105] or 0) - bonusHealth
2486
2625
  SetWidgetLife(
2487
2626
  target.handle,
2488
2627
  GetWidgetLife(target.handle) - bonusHealth
@@ -2502,32 +2641,91 @@ Unit.onDamage = __TS__New(
2502
2641
  DestroyTrigger(trigger)
2503
2642
  end
2504
2643
  )
2505
- Unit.onItemDrop = __TS__New(
2644
+ Unit.itemDroppedEvent = __TS__New(
2506
2645
  ____exports.UnitTriggerEvent,
2507
2646
  EVENT_PLAYER_UNIT_DROP_ITEM,
2508
2647
  function()
2509
2648
  local unit = getTriggerUnit()
2510
- if getUnitTypeId(unit) ~= dummyUnitId then
2511
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2649
+ local item = getManipulatedItem()
2650
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2651
+ return ____exports.Unit:of(unit), Item:of(item)
2512
2652
  end
2513
2653
  return IgnoreEvent
2514
2654
  end
2515
2655
  )
2516
- Unit.onItemPickup = __TS__New(
2656
+ Unit.itemPickedUpEvent = __TS__New(
2517
2657
  ____exports.UnitTriggerEvent,
2518
2658
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2519
2659
  function()
2520
2660
  local unit = getTriggerUnit()
2521
- if getUnitTypeId(unit) ~= dummyUnitId then
2522
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2661
+ local item = getManipulatedItem()
2662
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2663
+ return ____exports.Unit:of(unit), Item:of(item)
2523
2664
  end
2524
2665
  return IgnoreEvent
2525
2666
  end
2526
2667
  )
2527
- Unit.onItemUse = __TS__New(
2668
+ Unit.itemUsedEvent = __TS__New(
2528
2669
  ____exports.UnitTriggerEvent,
2529
2670
  EVENT_PLAYER_UNIT_USE_ITEM,
2530
- function() return ____exports.Unit:of(GetTriggerUnit()), Item:of(GetManipulatedItem()) end
2671
+ function()
2672
+ local unit = getTriggerUnit()
2673
+ local item = getManipulatedItem()
2674
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2675
+ return ____exports.Unit:of(unit), Item:of(item)
2676
+ end
2677
+ return IgnoreEvent
2678
+ end
2679
+ )
2680
+ Unit.itemStackedEvent = __TS__New(
2681
+ ____exports.UnitTriggerEvent,
2682
+ EVENT_PLAYER_UNIT_STACK_ITEM,
2683
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2684
+ )
2685
+ __TS__ObjectDefineProperty(
2686
+ Unit,
2687
+ "itemUseOrderEvent",
2688
+ {get = function(self)
2689
+ local event = __TS__New(Event)
2690
+ for order = orderId("useslot0"), orderId("useslot5") do
2691
+ local slot = order - orderId("useslot0")
2692
+ local function listener(unit)
2693
+ local item = unit.items[slot + 1]
2694
+ if item ~= nil then
2695
+ invoke(event, unit, item)
2696
+ end
2697
+ end
2698
+ self.onImmediateOrder[order]:addListener(listener)
2699
+ self.onTargetOrder[order]:addListener(listener)
2700
+ self.onPointOrder[order]:addListener(listener)
2701
+ end
2702
+ rawset(self, "itemUseOrderEvent", event)
2703
+ return event
2704
+ end}
2705
+ )
2706
+ __TS__ObjectDefineProperty(
2707
+ Unit,
2708
+ "itemMoveOrderEvent",
2709
+ {get = function(self)
2710
+ local event = __TS__New(Event)
2711
+ for order = orderId("moveslot0"), orderId("moveslot5") do
2712
+ local slotTo = order - orderId("moveslot0")
2713
+ self.onTargetOrder[order]:addListener(function(unit, item)
2714
+ local slotFrom = unit.items:findSlot(item)
2715
+ if slotFrom ~= nil then
2716
+ invoke(
2717
+ event,
2718
+ unit,
2719
+ item,
2720
+ slotFrom,
2721
+ slotTo
2722
+ )
2723
+ end
2724
+ end)
2725
+ end
2726
+ rawset(self, "itemMoveOrderEvent", event)
2727
+ return event
2728
+ end}
2531
2729
  )
2532
2730
  __TS__ObjectDefineProperty(
2533
2731
  Unit,