warscript 0.0.1-dev.58c74da → 0.0.1-dev.59106b6

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 (158) hide show
  1. package/attributes.d.ts +0 -1
  2. package/binaryreader.d.ts +1 -0
  3. package/binaryreader.lua +3 -0
  4. package/core/types/effect.d.ts +13 -3
  5. package/core/types/effect.lua +116 -17
  6. package/core/types/frame.d.ts +8 -1
  7. package/core/types/frame.lua +93 -1
  8. package/core/types/group.d.ts +0 -1
  9. package/core/types/image.d.ts +0 -1
  10. package/core/types/missile.d.ts +2 -2
  11. package/core/types/missile.lua +8 -2
  12. package/core/types/unit.lua +8 -0
  13. package/core/util.d.ts +1 -1
  14. package/core/util.lua +12 -0
  15. package/decl/index.d.ts +1 -0
  16. package/engine/ability.d.ts +1 -1
  17. package/engine/behavior.d.ts +10 -10
  18. package/engine/behavior.lua +6 -6
  19. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  20. package/engine/behaviour/ability/always-enabled.lua +31 -0
  21. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  22. package/engine/behaviour/ability/apply-buff.lua +32 -0
  23. package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
  24. package/engine/behaviour/ability/damage.d.ts +33 -11
  25. package/engine/behaviour/ability/damage.lua +89 -31
  26. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  27. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  28. package/engine/behaviour/ability/heal.d.ts +33 -6
  29. package/engine/behaviour/ability/heal.lua +89 -10
  30. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  31. package/engine/behaviour/ability/instant-impact.lua +4 -15
  32. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  33. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  34. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  35. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  36. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  37. package/engine/behaviour/ability/restore-mana.lua +29 -0
  38. package/engine/behaviour/ability.d.ts +22 -3
  39. package/engine/behaviour/ability.lua +134 -13
  40. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  41. package/engine/behaviour/unit.d.ts +8 -2
  42. package/engine/behaviour/unit.lua +27 -0
  43. package/engine/buff.d.ts +97 -40
  44. package/engine/buff.lua +431 -209
  45. package/engine/game-map.d.ts +7 -0
  46. package/engine/game-map.lua +32 -0
  47. package/engine/internal/ability.d.ts +16 -13
  48. package/engine/internal/ability.lua +80 -76
  49. package/engine/internal/item/ability.lua +106 -0
  50. package/engine/internal/item+owner.lua +2 -2
  51. package/engine/internal/item.d.ts +2 -2
  52. package/engine/internal/item.lua +56 -25
  53. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  54. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  55. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  56. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  57. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  58. package/engine/internal/object-data/evasion-probability.lua +16 -0
  59. package/engine/internal/unit/ability.d.ts +10 -1
  60. package/engine/internal/unit/ability.lua +36 -14
  61. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  62. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  63. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  64. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  65. package/engine/internal/unit/bonus.d.ts +11 -8
  66. package/engine/internal/unit/bonus.lua +23 -1
  67. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  68. package/engine/internal/unit/ignore-events-items.lua +5 -0
  69. package/engine/internal/unit/item.d.ts +24 -0
  70. package/engine/internal/unit/item.lua +78 -0
  71. package/engine/internal/unit/main-selected.d.ts +13 -0
  72. package/engine/internal/unit/main-selected.lua +51 -0
  73. package/engine/internal/unit+ability.lua +2 -2
  74. package/engine/internal/unit+transport.lua +4 -10
  75. package/engine/internal/unit-missile-launch.lua +25 -6
  76. package/engine/internal/unit.d.ts +53 -18
  77. package/engine/internal/unit.lua +356 -140
  78. package/engine/internal/utility.lua +12 -0
  79. package/engine/lightning.d.ts +12 -5
  80. package/engine/lightning.lua +48 -14
  81. package/engine/local-client.d.ts +7 -2
  82. package/engine/local-client.lua +82 -0
  83. package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
  84. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  85. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  86. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  87. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  88. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  89. package/engine/object-data/entry/ability-type/curse.lua +2 -2
  90. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  91. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  92. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  93. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  94. package/engine/object-data/entry/ability-type.d.ts +0 -1
  95. package/engine/object-data/entry/ability-type.lua +8 -12
  96. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  97. package/engine/object-data/entry/buff-type/applicable.lua +10 -34
  98. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  99. package/engine/object-data/entry/buff-type.d.ts +0 -1
  100. package/engine/object-data/entry/destructible-type.d.ts +0 -1
  101. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  102. package/engine/object-data/entry/item-type.d.ts +14 -1
  103. package/engine/object-data/entry/item-type.lua +91 -0
  104. package/engine/object-data/entry/lightning-type.d.ts +0 -1
  105. package/engine/object-data/entry/unit-type.d.ts +21 -2
  106. package/engine/object-data/entry/unit-type.lua +223 -49
  107. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  108. package/engine/object-data/entry/upgrade.d.ts +0 -1
  109. package/engine/object-data/entry.d.ts +2 -3
  110. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  111. package/engine/object-field/ability.d.ts +26 -3
  112. package/engine/object-field/ability.lua +54 -1
  113. package/engine/object-field.d.ts +2 -3
  114. package/engine/object-field.lua +4 -0
  115. package/engine/random.d.ts +1 -0
  116. package/engine/random.lua +9 -0
  117. package/engine/standard/entries/unit-type.d.ts +18 -0
  118. package/engine/standard/entries/unit-type.lua +18 -0
  119. package/engine/standard/fields/ability.d.ts +3 -1
  120. package/engine/standard/fields/ability.lua +3 -1
  121. package/engine/unit.d.ts +3 -0
  122. package/engine/unit.lua +12 -2
  123. package/event.d.ts +2 -3
  124. package/event.lua +9 -5
  125. package/index.d.ts +1 -0
  126. package/index.lua +1 -0
  127. package/lualib_bundle.lua +146 -42
  128. package/math/vec2.d.ts +2 -9
  129. package/math.d.ts +0 -2
  130. package/net/socket.d.ts +7 -1
  131. package/net/socket.lua +45 -4
  132. package/network.d.ts +1 -0
  133. package/network.lua +3 -2
  134. package/objutil/ability.d.ts +0 -1
  135. package/objutil/buff.d.ts +0 -1
  136. package/objutil/buff.lua +1 -1
  137. package/objutil/object.d.ts +0 -1
  138. package/objutil/unit.d.ts +0 -1
  139. package/package.json +13 -13
  140. package/patch-lua.d.ts +0 -0
  141. package/patch-lua.lua +10 -0
  142. package/property.d.ts +55 -0
  143. package/property.lua +374 -0
  144. package/string.d.ts +16 -0
  145. package/string.lua +5 -0
  146. package/util/stream.d.ts +0 -1
  147. package/utility/arrays.d.ts +11 -5
  148. package/utility/arrays.lua +34 -3
  149. package/utility/bit-set.d.ts +0 -2
  150. package/utility/lazy.d.ts +2 -0
  151. package/utility/lazy.lua +14 -0
  152. package/utility/linked-set.d.ts +11 -3
  153. package/utility/linked-set.lua +5 -2
  154. package/utility/lua-maps.d.ts +1 -2
  155. package/utility/lua-sets.d.ts +1 -2
  156. package/utility/types.d.ts +1 -0
  157. package/core/mapbounds.d.ts +0 -8
  158. package/core/mapbounds.lua +0 -12
@@ -5,9 +5,12 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
5
5
  local __TS__New = ____lualib.__TS__New
6
6
  local __TS__Class = ____lualib.__TS__Class
7
7
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
8
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
8
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
9
13
  local __TS__InstanceOf = ____lualib.__TS__InstanceOf
10
- local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
11
14
  local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
12
15
  local Set = ____lualib.Set
13
16
  local __TS__Spread = ____lualib.__TS__Spread
@@ -48,6 +51,8 @@ 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
51
56
  local match = string.match
52
57
  local ____tostring = _G.tostring
53
58
  local setUnitAnimation = SetUnitAnimation
@@ -72,6 +77,7 @@ local setUnitScale = SetUnitScale
72
77
  local setUnitPosition = SetUnitPosition
73
78
  local setUnitTimeScale = SetUnitTimeScale
74
79
  local getHandleId = GetHandleId
80
+ local getUnitCurrentOrder = GetUnitCurrentOrder
75
81
  local createUnit = CreateUnit
76
82
  local killUnit = KillUnit
77
83
  local setUnitExploded = SetUnitExploded
@@ -92,6 +98,10 @@ local isUnitInRangeXY = IsUnitInRangeXY
92
98
  local isUnitInRange = IsUnitInRange
93
99
  local setResourceAmount = SetResourceAmount
94
100
  local getResourceAmount = GetResourceAmount
101
+ local getUnitWeaponRealField = BlzGetUnitWeaponRealField
102
+ local setUnitWeaponRealField = BlzSetUnitWeaponRealField
103
+ local getUnitWeaponStringField = BlzGetUnitWeaponStringField
104
+ local setUnitWeaponStringField = BlzSetUnitWeaponStringField
95
105
  local getUnitAbilityLevel = GetUnitAbilityLevel
96
106
  local unitDisableAbility = BlzUnitDisableAbility
97
107
  local unitInterruptAttack = BlzUnitInterruptAttack
@@ -275,16 +285,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
275
285
  end
276
286
  local function dispatch(event, idGetter, argsGetter)
277
287
  local initialized = false
278
- local x = {}
279
288
  return setmetatable(
280
- x,
289
+ {},
281
290
  {
282
291
  __index = function(self, id)
283
292
  if type(id) ~= "number" then
284
293
  return event[id]
285
294
  end
286
295
  if not initialized then
287
- local invoke = Event.invoke
288
296
  event:addListener(function(...)
289
297
  local id = idGetter(...)
290
298
  local dispatched = rawget(self, id)
@@ -322,7 +330,6 @@ local function dispatchAbility(event)
322
330
  return event[id]
323
331
  end
324
332
  if not initialized then
325
- local invoke = Event.invoke
326
333
  event:addListener(function(unit, ability, ...)
327
334
  local dispatched = rawget(self, ability.typeId)
328
335
  if dispatched ~= nil then
@@ -387,51 +394,158 @@ local getters = {
387
394
  return BlzGetUnitArmor(unit)
388
395
  end
389
396
  }
390
- local weaponGetters = {
391
- index = function(self, handle, index)
392
- return index
393
- end,
394
- cooldown = function(self, handle, index)
395
- return BlzGetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, index)
396
- end,
397
- projectileArc = function(self, handle, index)
398
- return BlzGetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, index)
399
- end,
400
- projectileArt = function(self, handle, index)
401
- return BlzGetUnitWeaponStringField(handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, index)
402
- end,
403
- projectileSpeed = function(self, handle, index)
404
- return BlzGetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, index)
405
- end,
406
- attackPoint = function(self, handle, index)
407
- return BlzGetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, index)
408
- end
409
- }
410
- local weaponSetters = {
411
- cooldown = function(self, handle, index, value)
412
- assert(BlzSetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, index, value))
413
- end,
414
- projectileArc = function(self, handle, index, value)
415
- assert(BlzSetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, index, value))
416
- end,
417
- projectileArt = function(self, handle, index, value)
418
- assert(BlzSetUnitWeaponStringField(handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, index, value))
419
- end,
420
- projectileSpeed = function(self, handle, index, value)
421
- assert(BlzSetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, index, value))
422
- end,
423
- attackPoint = function(self, handle, index, value)
424
- assert(BlzSetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, index, value))
425
- end
426
- }
427
- local weaponMetatable = {
428
- __index = function(self, key)
429
- return weaponGetters[key](weaponGetters, self.h, self.i)
430
- end,
431
- __newindex = function(self, key, value)
432
- weaponSetters[key](weaponSetters, self.h, self.i, value)
433
- end
434
- }
397
+ ____exports.UnitWeapon = __TS__Class()
398
+ local UnitWeapon = ____exports.UnitWeapon
399
+ UnitWeapon.name = "UnitWeapon"
400
+ function UnitWeapon.prototype.____constructor(self, unit, index)
401
+ self.unit = unit
402
+ self.index = index
403
+ end
404
+ __TS__SetDescriptor(
405
+ UnitWeapon.prototype,
406
+ "cooldown",
407
+ {
408
+ get = function(self)
409
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
410
+ end,
411
+ set = function(self, cooldown)
412
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
413
+ end
414
+ },
415
+ true
416
+ )
417
+ __TS__SetDescriptor(
418
+ UnitWeapon.prototype,
419
+ "damage",
420
+ {
421
+ get = function(self)
422
+ local minimumDamage = self.damageBase + self.damageDiceCount
423
+ local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
424
+ return {minimumDamage, maximumDamage}
425
+ end,
426
+ set = function(self, ____bindingPattern0)
427
+ local maximumDamage
428
+ local minimumDamage
429
+ minimumDamage = ____bindingPattern0[1]
430
+ maximumDamage = ____bindingPattern0[2]
431
+ self.damageBase = minimumDamage - 1
432
+ self.damageDiceCount = 1
433
+ self.damageDiceSideCount = maximumDamage - minimumDamage + 1
434
+ end
435
+ },
436
+ true
437
+ )
438
+ __TS__SetDescriptor(
439
+ UnitWeapon.prototype,
440
+ "damageBase",
441
+ {
442
+ get = function(self)
443
+ return BlzGetUnitBaseDamage(self.unit.handle, self.index)
444
+ end,
445
+ set = function(self, damageBase)
446
+ BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
447
+ end
448
+ },
449
+ true
450
+ )
451
+ __TS__SetDescriptor(
452
+ UnitWeapon.prototype,
453
+ "damageDiceCount",
454
+ {
455
+ get = function(self)
456
+ return BlzGetUnitDiceNumber(self.unit.handle, self.index)
457
+ end,
458
+ set = function(self, damageDiceCount)
459
+ BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
460
+ end
461
+ },
462
+ true
463
+ )
464
+ __TS__SetDescriptor(
465
+ UnitWeapon.prototype,
466
+ "damageDiceSideCount",
467
+ {
468
+ get = function(self)
469
+ return BlzGetUnitDiceSides(self.unit.handle, self.index)
470
+ end,
471
+ set = function(self, damageDiceSideCount)
472
+ BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
473
+ end
474
+ },
475
+ true
476
+ )
477
+ __TS__SetDescriptor(
478
+ UnitWeapon.prototype,
479
+ "range",
480
+ {
481
+ get = function(self)
482
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
483
+ end,
484
+ set = function(self, range)
485
+ local handle = self.unit.handle
486
+ local index = self.index
487
+ setUnitWeaponRealField(
488
+ handle,
489
+ UNIT_WEAPON_RF_ATTACK_RANGE,
490
+ index + 1,
491
+ getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
492
+ )
493
+ end
494
+ },
495
+ true
496
+ )
497
+ __TS__SetDescriptor(
498
+ UnitWeapon.prototype,
499
+ "impactDelay",
500
+ {
501
+ get = function(self)
502
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
503
+ end,
504
+ set = function(self, impactDelay)
505
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
506
+ end
507
+ },
508
+ true
509
+ )
510
+ __TS__SetDescriptor(
511
+ UnitWeapon.prototype,
512
+ "missileArc",
513
+ {
514
+ get = function(self)
515
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
516
+ end,
517
+ set = function(self, missileArc)
518
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
519
+ end
520
+ },
521
+ true
522
+ )
523
+ __TS__SetDescriptor(
524
+ UnitWeapon.prototype,
525
+ "missileModelPath",
526
+ {
527
+ get = function(self)
528
+ return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
529
+ end,
530
+ set = function(self, missileModelPath)
531
+ setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
532
+ end
533
+ },
534
+ true
535
+ )
536
+ __TS__SetDescriptor(
537
+ UnitWeapon.prototype,
538
+ "missileSpeed",
539
+ {
540
+ get = function(self)
541
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
542
+ end,
543
+ set = function(self, missileSpeed)
544
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
545
+ end
546
+ },
547
+ true
548
+ )
435
549
  local unitInventorySize = UnitInventorySize
436
550
  local unitItemInSlot = UnitItemInSlot
437
551
  local getItemAbility = BlzGetItemAbility
@@ -442,8 +556,6 @@ local getAbilityName = GetAbilityName
442
556
  local unitAddAbility = UnitAddAbility
443
557
  local getUnitGoldCost = GetUnitGoldCost
444
558
  local getUnitLumberCost = GetUnitWoodCost
445
- local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
446
- local unitAddItem = UnitAddItem
447
559
  local unitRemoveAbility = UnitRemoveAbility
448
560
  local function retrieveAbility(unit, ability, abilityId)
449
561
  if ability == nil then
@@ -453,17 +565,6 @@ local function retrieveAbility(unit, ability, abilityId)
453
565
  ____exports.Unit:of(unit)
454
566
  )
455
567
  end
456
- if not unitAddAbility(unit, abilityId) then
457
- if getUnitAbility(unit, abilityId) == ability then
458
- return UnitAbility:of(
459
- ability,
460
- abilityId,
461
- ____exports.Unit:of(unit)
462
- )
463
- end
464
- else
465
- unitRemoveAbility(unit, abilityId)
466
- end
467
568
  for i = 0, unitInventorySize(unit) - 1 do
468
569
  local item = unitItemInSlot(unit, i)
469
570
  if getItemAbility(item, abilityId) == ability then
@@ -521,15 +622,15 @@ for ____, player in ipairs(Player.all) do
521
622
  dummies[player] = dummy
522
623
  end
523
624
  local function delayHealthChecksCallback(unit)
524
- local counter = (unit[102] or 0) - 1
625
+ local counter = (unit[103] or 0) - 1
525
626
  if counter ~= 0 then
526
- unit[102] = counter
627
+ unit[103] = counter
527
628
  return
528
629
  end
529
- unit[102] = nil
530
- local healthBonus = unit[103]
630
+ unit[103] = nil
631
+ local healthBonus = unit[104]
531
632
  if healthBonus ~= nil then
532
- unit[103] = nil
633
+ unit[104] = nil
533
634
  local handle = unit.handle
534
635
  BlzSetUnitMaxHP(
535
636
  handle,
@@ -537,12 +638,17 @@ local function delayHealthChecksCallback(unit)
537
638
  )
538
639
  end
539
640
  end
641
+ local nextSyncId = 1
642
+ local unitBySyncId = setmetatable({}, {__mode = "k"})
540
643
  ____exports.Unit = __TS__Class()
541
644
  local Unit = ____exports.Unit
542
645
  Unit.name = "Unit"
543
646
  __TS__ClassExtends(Unit, Handle)
544
647
  function Unit.prototype.____constructor(self, handle)
545
648
  Handle.prototype.____constructor(self, handle)
649
+ local ____nextSyncId_0 = nextSyncId
650
+ nextSyncId = ____nextSyncId_0 + 1
651
+ self.syncId = ____nextSyncId_0
546
652
  self._owner = Player:of(getOwningPlayer(handle))
547
653
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
548
654
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -555,6 +661,7 @@ function Unit.prototype.____constructor(self, handle)
555
661
  fourCC("Amrf")
556
662
  ))
557
663
  end
664
+ unitBySyncId[self.syncId] = self
558
665
  local ____ = self.abilities
559
666
  end
560
667
  function Unit.prototype.getEvent(self, event, collector)
@@ -640,8 +747,8 @@ function Unit.prototype.addModifier(self, property, modifier)
640
747
  end}
641
748
  end
642
749
  function Unit.prototype.hasCombatClassification(self, combatClassification)
643
- local ____combatClassification_0 = combatClassification
644
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_0 == ____combatClassification_0
750
+ local ____combatClassification_1 = combatClassification
751
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
645
752
  end
646
753
  function Unit.prototype.addClassification(self, classification)
647
754
  return unitAddType(self.handle, classification)
@@ -659,13 +766,13 @@ function Unit.prototype.isInvisibleTo(self, player)
659
766
  return isUnitInvisible(self.handle, player.handle)
660
767
  end
661
768
  function Unit.prototype.isInRangeOf(self, x, y, range)
662
- local ____temp_1
769
+ local ____temp_2
663
770
  if type(x) == "number" then
664
- ____temp_1 = isUnitInRangeXY(self.handle, x, y, range)
771
+ ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
665
772
  else
666
- ____temp_1 = isUnitInRange(self.handle, x.handle, y)
773
+ ____temp_2 = isUnitInRange(self.handle, x.handle, y)
667
774
  end
668
- return ____temp_1
775
+ return ____temp_2
669
776
  end
670
777
  function Unit.prototype.isAllyOf(self, unit)
671
778
  return isUnitAlly(
@@ -692,7 +799,7 @@ function Unit.prototype.queueAnimation(self, animation)
692
799
  queueUnitAnimation(self.handle, animation)
693
800
  end
694
801
  function Unit.prototype.delayHealthChecks(self)
695
- self[102] = (self[102] or 0) + 1
802
+ self[103] = (self[103] or 0) + 1
696
803
  Timer:run(delayHealthChecksCallback, self)
697
804
  end
698
805
  function Unit.prototype.setPosition(self, x, y)
@@ -708,8 +815,15 @@ end
708
815
  function Unit.prototype.kill(self)
709
816
  killUnit(self.handle)
710
817
  end
711
- function Unit.prototype.revive(self, pos, doEffect)
712
- ReviveHero(self.handle, pos.x, pos.y, doEffect)
818
+ function Unit.prototype.revive(self, x, y, doEffect)
819
+ local ____ReviveHero_5 = ReviveHero
820
+ local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
821
+ local ____doEffect_3 = doEffect
822
+ if ____doEffect_3 == nil then
823
+ ____doEffect_3 = false
824
+ end
825
+ __TS__SparseArrayPush(____array_4, ____doEffect_3)
826
+ ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
713
827
  end
714
828
  function Unit.prototype.healTarget(self, target, amount)
715
829
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -749,7 +863,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
749
863
  return UnitDropItemSlot(self.handle, item.handle, slot)
750
864
  end
751
865
  function Unit.prototype.itemInSlot(self, slot)
752
- return Item:of(UnitItemInSlot(self.handle, slot))
866
+ return Item:of(unitItemInSlot(self.handle, slot))
753
867
  end
754
868
  function Unit.prototype.addAbility(self, abilityId)
755
869
  if unitAddAbility(self.handle, abilityId) then
@@ -805,6 +919,9 @@ end
805
919
  function Unit.prototype.hideAbility(self, abilityId, flag)
806
920
  BlzUnitHideAbility(self.handle, abilityId, flag)
807
921
  end
922
+ function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
923
+ return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
924
+ end
808
925
  function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
809
926
  BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
810
927
  end
@@ -815,8 +932,15 @@ function Unit.prototype.interruptAttack(self)
815
932
  unitInterruptAttack(self.handle)
816
933
  end
817
934
  function Unit.prototype.interruptCast(self, abilityId)
818
- unitDisableAbility(self.handle, abilityId, true, false)
819
- unitDisableAbility(self.handle, abilityId, false, false)
935
+ local handle = self.handle
936
+ unitDisableAbility(handle, abilityId, true, false)
937
+ Timer:run(
938
+ unitDisableAbility,
939
+ handle,
940
+ abilityId,
941
+ false,
942
+ false
943
+ )
820
944
  end
821
945
  function Unit.prototype.getDistanceTo(self, target)
822
946
  local handle = self.handle
@@ -876,18 +1000,18 @@ function Unit.prototype.unpauseEx(self)
876
1000
  self:decrementStunCounter()
877
1001
  end
878
1002
  function Unit.prototype.incrementStunCounter(self)
879
- local stunCounter = self[101] or 0
880
- if not self[100] or stunCounter >= 0 then
1003
+ local stunCounter = self[102] or 0
1004
+ if not self[101] or stunCounter >= 0 then
881
1005
  BlzPauseUnitEx(self.handle, true)
882
1006
  end
883
- self[101] = stunCounter + 1
1007
+ self[102] = stunCounter + 1
884
1008
  end
885
1009
  function Unit.prototype.decrementStunCounter(self)
886
- local stunCounter = self[101] or 0
887
- if not self[100] or stunCounter >= 1 then
1010
+ local stunCounter = self[102] or 0
1011
+ if not self[101] or stunCounter >= 1 then
888
1012
  BlzPauseUnitEx(self.handle, false)
889
1013
  end
890
- self[101] = stunCounter - 1
1014
+ self[102] = stunCounter - 1
891
1015
  end
892
1016
  function Unit.create(self, owner, id, x, y, facing, skinId)
893
1017
  local handle = skinId and BlzCreateUnitWithSkin(
@@ -989,8 +1113,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
989
1113
  )
990
1114
  return targetCollection
991
1115
  end
992
- function Unit.getSelectionOf(self, player)
993
- targetCollection = {}
1116
+ function Unit.getSelectionOf(self, player, target)
1117
+ if target == nil then
1118
+ target = {}
1119
+ end
1120
+ targetCollection = target
994
1121
  targetCollectionNextIndex = 1
995
1122
  GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
996
1123
  return targetCollection
@@ -1012,6 +1139,9 @@ end
1012
1139
  function Unit.prototype.__tostring(self)
1013
1140
  return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
1014
1141
  end
1142
+ function Unit.getBySyncId(self, syncId)
1143
+ return unitBySyncId[syncId]
1144
+ end
1015
1145
  __TS__SetDescriptor(
1016
1146
  Unit.prototype,
1017
1147
  "_deltas",
@@ -1075,6 +1205,14 @@ __TS__SetDescriptor(
1075
1205
  end},
1076
1206
  true
1077
1207
  )
1208
+ __TS__SetDescriptor(
1209
+ Unit.prototype,
1210
+ "isStunned",
1211
+ {get = function(self)
1212
+ return getUnitCurrentOrder(self.handle) == orderId("stunned")
1213
+ end},
1214
+ true
1215
+ )
1078
1216
  __TS__SetDescriptor(
1079
1217
  Unit.prototype,
1080
1218
  "combatClassifications",
@@ -1092,12 +1230,27 @@ __TS__SetDescriptor(
1092
1230
  Unit.prototype,
1093
1231
  "weapons",
1094
1232
  {get = function(self)
1095
- local weapons = {
1096
- setmetatable({h = self.handle, i = 0}, weaponMetatable),
1097
- setmetatable({h = self.handle, i = 1}, weaponMetatable)
1098
- }
1099
- rawset(self, "weapons", weapons)
1100
- return weapons
1233
+ return {self.firstWeapon, self.secondWeapon}
1234
+ end},
1235
+ true
1236
+ )
1237
+ __TS__SetDescriptor(
1238
+ Unit.prototype,
1239
+ "firstWeapon",
1240
+ {get = function(self)
1241
+ local weapon = __TS__New(____exports.UnitWeapon, self, 0)
1242
+ rawset(self, "firstWeapon", weapon)
1243
+ return weapon
1244
+ end},
1245
+ true
1246
+ )
1247
+ __TS__SetDescriptor(
1248
+ Unit.prototype,
1249
+ "secondWeapon",
1250
+ {get = function(self)
1251
+ local weapon = __TS__New(____exports.UnitWeapon, self, 1)
1252
+ rawset(self, "secondWeapon", weapon)
1253
+ return weapon
1101
1254
  end},
1102
1255
  true
1103
1256
  )
@@ -1254,17 +1407,17 @@ __TS__SetDescriptor(
1254
1407
  "isTeamGlowVisible",
1255
1408
  {
1256
1409
  get = function(self)
1257
- return not self[105]
1410
+ return not self[106]
1258
1411
  end,
1259
1412
  set = function(self, isTeamGlowVisible)
1260
1413
  showUnitTeamGlow(self.handle, isTeamGlowVisible)
1261
- local ____temp_2
1414
+ local ____temp_6
1262
1415
  if not isTeamGlowVisible then
1263
- ____temp_2 = true
1416
+ ____temp_6 = true
1264
1417
  else
1265
- ____temp_2 = nil
1418
+ ____temp_6 = nil
1266
1419
  end
1267
- self[105] = ____temp_2
1420
+ self[106] = ____temp_6
1268
1421
  end
1269
1422
  },
1270
1423
  true
@@ -1274,7 +1427,7 @@ __TS__SetDescriptor(
1274
1427
  "color",
1275
1428
  {set = function(self, color)
1276
1429
  setUnitColor(self.handle, color.handle)
1277
- if self[105] then
1430
+ if self[106] then
1278
1431
  showUnitTeamGlow(self.handle, false)
1279
1432
  end
1280
1433
  end},
@@ -1298,14 +1451,14 @@ __TS__SetDescriptor(
1298
1451
  "maxHealth",
1299
1452
  {
1300
1453
  get = function(self)
1301
- return BlzGetUnitMaxHP(self.handle) - (self[103] or 0) - (self[104] or 0)
1454
+ return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1302
1455
  end,
1303
1456
  set = function(self, maxHealth)
1304
- if maxHealth < 1 and self[102] ~= nil then
1305
- self[103] = (self[103] or 0) + (1 - maxHealth)
1457
+ if maxHealth < 1 and self[103] ~= nil then
1458
+ self[104] = (self[104] or 0) + (1 - maxHealth)
1306
1459
  maxHealth = 1
1307
1460
  end
1308
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[104] or 0))
1461
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1309
1462
  end
1310
1463
  },
1311
1464
  true
@@ -1347,10 +1500,10 @@ __TS__SetDescriptor(
1347
1500
  "health",
1348
1501
  {
1349
1502
  get = function(self)
1350
- return GetWidgetLife(self.handle) - (self[104] or 0)
1503
+ return GetWidgetLife(self.handle) - (self[105] or 0)
1351
1504
  end,
1352
1505
  set = function(self, health)
1353
- SetWidgetLife(self.handle, health + (self[104] or 0))
1506
+ SetWidgetLife(self.handle, health + (self[105] or 0))
1354
1507
  end
1355
1508
  },
1356
1509
  true
@@ -1561,17 +1714,17 @@ __TS__SetDescriptor(
1561
1714
  set = function(self, isPaused)
1562
1715
  local handle = self.handle
1563
1716
  if isPaused and not IsUnitPaused(handle) then
1564
- self[100] = true
1565
- for _ = self[101] or 0, -1 do
1717
+ self[101] = true
1718
+ for _ = self[102] or 0, -1 do
1566
1719
  BlzPauseUnitEx(handle, true)
1567
1720
  end
1568
1721
  PauseUnit(handle, true)
1569
1722
  elseif not isPaused and IsUnitPaused(handle) then
1570
1723
  PauseUnit(handle, false)
1571
- for _ = self[101] or 0, -1 do
1724
+ for _ = self[102] or 0, -1 do
1572
1725
  BlzPauseUnitEx(handle, false)
1573
1726
  end
1574
- self[100] = nil
1727
+ self[101] = nil
1575
1728
  end
1576
1729
  end
1577
1730
  },
@@ -1928,7 +2081,6 @@ Unit.onDecay = __TS__New(
1928
2081
  Unit.onResurrect = __TS__New(
1929
2082
  InitializingEvent,
1930
2083
  function(event)
1931
- local invoke = Event.invoke
1932
2084
  local dead = setmetatable({}, {__mode = "k"})
1933
2085
  ____exports.Unit.deathEvent:addListener(function(unit)
1934
2086
  dead[unit] = true
@@ -1944,10 +2096,15 @@ Unit.onResurrect = __TS__New(
1944
2096
  Unit.morphEvent = __TS__New(
1945
2097
  InitializingEvent,
1946
2098
  function(event)
2099
+ local function ifNotLeft(unit)
2100
+ local handle = unit.handle
2101
+ if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
2102
+ invoke(event, unit)
2103
+ end
2104
+ end
1947
2105
  ____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
1948
2106
  if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
1949
- assert(unitAddAbility(unit.handle, morphDetectAbilityId))
1950
- Timer:run(Event.invoke, event, unit)
2107
+ Timer:run(ifNotLeft, unit)
1951
2108
  end
1952
2109
  end)
1953
2110
  end
@@ -1985,27 +2142,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
1985
2142
  Unit.onTargetCast = dispatchId(__TS__New(
1986
2143
  InitializingEvent,
1987
2144
  function(event)
1988
- local invoke = Event.invoke
1989
2145
  local function listener(unit, id)
1990
- local ____GetSpellTargetUnit_result_5
2146
+ local ____GetSpellTargetUnit_result_9
1991
2147
  if GetSpellTargetUnit() then
1992
- ____GetSpellTargetUnit_result_5 = ____exports.Unit:of(GetSpellTargetUnit())
2148
+ ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
1993
2149
  else
1994
- local ____GetSpellTargetItem_result_4
2150
+ local ____GetSpellTargetItem_result_8
1995
2151
  if GetSpellTargetItem() then
1996
- ____GetSpellTargetItem_result_4 = Item:of(GetSpellTargetItem())
2152
+ ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
1997
2153
  else
1998
- local ____GetSpellTargetDestructable_result_3
2154
+ local ____GetSpellTargetDestructable_result_7
1999
2155
  if GetSpellTargetDestructable() then
2000
- ____GetSpellTargetDestructable_result_3 = Destructable:of(GetSpellTargetDestructable())
2156
+ ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2001
2157
  else
2002
- ____GetSpellTargetDestructable_result_3 = nil
2158
+ ____GetSpellTargetDestructable_result_7 = nil
2003
2159
  end
2004
- ____GetSpellTargetItem_result_4 = ____GetSpellTargetDestructable_result_3
2160
+ ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2005
2161
  end
2006
- ____GetSpellTargetUnit_result_5 = ____GetSpellTargetItem_result_4
2162
+ ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2007
2163
  end
2008
- local target = ____GetSpellTargetUnit_result_5
2164
+ local target = ____GetSpellTargetUnit_result_9
2009
2165
  if target then
2010
2166
  invoke(event, unit, id, target)
2011
2167
  end
@@ -2177,10 +2333,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2177
2333
  ____exports.UnitTriggerEvent,
2178
2334
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2179
2335
  function()
2180
- local unit = ____exports.Unit:of(getOrderedUnit())
2181
- local issuedOrderId = getIssuedOrderId()
2182
- if unit ~= nil and unit.state == 1 then
2183
- return unit, issuedOrderId
2336
+ local handle = getOrderedUnit()
2337
+ if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
2338
+ local unit = ____exports.Unit:of(handle)
2339
+ if unit.state == 1 then
2340
+ return unit, getIssuedOrderId()
2341
+ end
2184
2342
  end
2185
2343
  return IgnoreEvent
2186
2344
  end
@@ -2202,7 +2360,6 @@ Unit.autoAttackStartEvent = __TS__New(
2202
2360
  )
2203
2361
  Unit.onDamaging = (function()
2204
2362
  local event = __TS__New(Event)
2205
- local invoke = Event.invoke
2206
2363
  local trigger = CreateTrigger()
2207
2364
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
2208
2365
  TriggerAddCondition(
@@ -2301,7 +2458,6 @@ end)()
2301
2458
  Unit.onDamage = __TS__New(
2302
2459
  InitializingEvent,
2303
2460
  function(event)
2304
- local invoke = Event.invoke
2305
2461
  local trigger = CreateTrigger()
2306
2462
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
2307
2463
  TriggerAddCondition(
@@ -2317,6 +2473,7 @@ Unit.onDamage = __TS__New(
2317
2473
  damageType = BlzGetEventDamageType(),
2318
2474
  weaponType = BlzGetEventWeaponType(),
2319
2475
  isAttack = BlzGetEventIsAttack(),
2476
+ originalAmount = GetEventDamage(),
2320
2477
  preventDeath = damageEventPreventDeath
2321
2478
  }
2322
2479
  local evData = setmetatable(
@@ -2333,7 +2490,7 @@ Unit.onDamage = __TS__New(
2333
2490
  invoke(event, source, target, evData)
2334
2491
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2335
2492
  local bonusHealth = math.ceil(evData.amount)
2336
- target[104] = (target[104] or 0) + bonusHealth
2493
+ target[105] = (target[105] or 0) + bonusHealth
2337
2494
  BlzSetUnitMaxHP(
2338
2495
  target.handle,
2339
2496
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2347,7 +2504,7 @@ Unit.onDamage = __TS__New(
2347
2504
  evData[0],
2348
2505
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2349
2506
  )
2350
- target[104] = (target[104] or 0) - bonusHealth
2507
+ target[105] = (target[105] or 0) - bonusHealth
2351
2508
  SetWidgetLife(
2352
2509
  target.handle,
2353
2510
  GetWidgetLife(target.handle) - bonusHealth
@@ -2367,32 +2524,91 @@ Unit.onDamage = __TS__New(
2367
2524
  DestroyTrigger(trigger)
2368
2525
  end
2369
2526
  )
2370
- Unit.onItemDrop = __TS__New(
2527
+ Unit.itemDroppedEvent = __TS__New(
2371
2528
  ____exports.UnitTriggerEvent,
2372
2529
  EVENT_PLAYER_UNIT_DROP_ITEM,
2373
2530
  function()
2374
2531
  local unit = getTriggerUnit()
2375
- if getUnitTypeId(unit) ~= dummyUnitId then
2376
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2532
+ local item = getManipulatedItem()
2533
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2534
+ return ____exports.Unit:of(unit), Item:of(item)
2377
2535
  end
2378
2536
  return IgnoreEvent
2379
2537
  end
2380
2538
  )
2381
- Unit.onItemPickup = __TS__New(
2539
+ Unit.itemPickedUpEvent = __TS__New(
2382
2540
  ____exports.UnitTriggerEvent,
2383
2541
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2384
2542
  function()
2385
2543
  local unit = getTriggerUnit()
2386
- if getUnitTypeId(unit) ~= dummyUnitId then
2387
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2544
+ local item = getManipulatedItem()
2545
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2546
+ return ____exports.Unit:of(unit), Item:of(item)
2388
2547
  end
2389
2548
  return IgnoreEvent
2390
2549
  end
2391
2550
  )
2392
- Unit.onItemUse = __TS__New(
2551
+ Unit.itemUsedEvent = __TS__New(
2393
2552
  ____exports.UnitTriggerEvent,
2394
2553
  EVENT_PLAYER_UNIT_USE_ITEM,
2395
- function() return ____exports.Unit:of(GetTriggerUnit()), Item:of(GetManipulatedItem()) end
2554
+ function()
2555
+ local unit = getTriggerUnit()
2556
+ local item = getManipulatedItem()
2557
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2558
+ return ____exports.Unit:of(unit), Item:of(item)
2559
+ end
2560
+ return IgnoreEvent
2561
+ end
2562
+ )
2563
+ Unit.itemStackedEvent = __TS__New(
2564
+ ____exports.UnitTriggerEvent,
2565
+ EVENT_PLAYER_UNIT_STACK_ITEM,
2566
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2567
+ )
2568
+ __TS__ObjectDefineProperty(
2569
+ Unit,
2570
+ "itemUseOrderEvent",
2571
+ {get = function(self)
2572
+ local event = __TS__New(Event)
2573
+ for order = orderId("useslot0"), orderId("useslot5") do
2574
+ local slot = order - orderId("useslot0")
2575
+ local function listener(unit)
2576
+ local item = unit.items[slot + 1]
2577
+ if item ~= nil then
2578
+ invoke(event, unit, item)
2579
+ end
2580
+ end
2581
+ self.onImmediateOrder[order]:addListener(listener)
2582
+ self.onTargetOrder[order]:addListener(listener)
2583
+ self.onPointOrder[order]:addListener(listener)
2584
+ end
2585
+ rawset(self, "itemUseOrderEvent", event)
2586
+ return event
2587
+ end}
2588
+ )
2589
+ __TS__ObjectDefineProperty(
2590
+ Unit,
2591
+ "itemMoveOrderEvent",
2592
+ {get = function(self)
2593
+ local event = __TS__New(Event)
2594
+ for order = orderId("moveslot0"), orderId("moveslot5") do
2595
+ local slotTo = order - orderId("moveslot0")
2596
+ self.onTargetOrder[order]:addListener(function(unit, item)
2597
+ local slotFrom = unit.items:findSlot(item)
2598
+ if slotFrom ~= nil then
2599
+ invoke(
2600
+ event,
2601
+ unit,
2602
+ item,
2603
+ slotFrom,
2604
+ slotTo
2605
+ )
2606
+ end
2607
+ end)
2608
+ end
2609
+ rawset(self, "itemMoveOrderEvent", event)
2610
+ return event
2611
+ end}
2396
2612
  )
2397
2613
  __TS__ObjectDefineProperty(
2398
2614
  Unit,