warscript 0.0.1-dev.ee2345e → 0.0.1-dev.f48f7bb

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 (143) 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 +3 -5
  22. package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
  23. package/engine/behaviour/ability/damage.d.ts +33 -11
  24. package/engine/behaviour/ability/damage.lua +89 -31
  25. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  26. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  27. package/engine/behaviour/ability/heal.d.ts +33 -6
  28. package/engine/behaviour/ability/heal.lua +89 -10
  29. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  30. package/engine/behaviour/ability/instant-impact.lua +4 -15
  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/restore-mana.d.ts +15 -0
  36. package/engine/behaviour/ability/restore-mana.lua +29 -0
  37. package/engine/behaviour/ability.d.ts +21 -3
  38. package/engine/behaviour/ability.lua +120 -12
  39. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  40. package/engine/behaviour/unit.d.ts +8 -2
  41. package/engine/behaviour/unit.lua +27 -0
  42. package/engine/buff.d.ts +68 -21
  43. package/engine/buff.lua +276 -90
  44. package/engine/game-map.d.ts +7 -0
  45. package/engine/game-map.lua +32 -0
  46. package/engine/internal/ability.d.ts +16 -13
  47. package/engine/internal/ability.lua +82 -76
  48. package/engine/internal/item/ability.lua +106 -0
  49. package/engine/internal/item+owner.lua +2 -2
  50. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  51. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  52. package/engine/internal/unit/ability.d.ts +10 -1
  53. package/engine/internal/unit/ability.lua +36 -14
  54. package/engine/internal/unit/bonus.d.ts +9 -8
  55. package/engine/internal/unit/bonus.lua +6 -1
  56. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  57. package/engine/internal/unit/ignore-events-items.lua +5 -0
  58. package/engine/internal/unit/item.d.ts +24 -0
  59. package/engine/internal/unit/item.lua +123 -0
  60. package/engine/internal/unit/main-selected.d.ts +13 -0
  61. package/engine/internal/unit/main-selected.lua +51 -0
  62. package/engine/internal/unit+ability.lua +2 -2
  63. package/engine/internal/unit+transport.lua +4 -10
  64. package/engine/internal/unit-missile-launch.lua +25 -6
  65. package/engine/internal/unit.d.ts +58 -16
  66. package/engine/internal/unit.lua +364 -132
  67. package/engine/internal/utility.lua +12 -0
  68. package/engine/local-client.d.ts +7 -2
  69. package/engine/local-client.lua +82 -0
  70. package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
  71. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  72. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  73. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  74. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  75. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  76. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  77. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  78. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  79. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  80. package/engine/object-data/entry/ability-type.d.ts +0 -1
  81. package/engine/object-data/entry/ability-type.lua +8 -12
  82. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  83. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  84. package/engine/object-data/entry/buff-type.d.ts +0 -1
  85. package/engine/object-data/entry/destructible-type.d.ts +0 -1
  86. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  87. package/engine/object-data/entry/item-type.d.ts +14 -1
  88. package/engine/object-data/entry/item-type.lua +91 -0
  89. package/engine/object-data/entry/lightning-type.d.ts +0 -1
  90. package/engine/object-data/entry/unit-type.d.ts +37 -2
  91. package/engine/object-data/entry/unit-type.lua +333 -49
  92. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  93. package/engine/object-data/entry/upgrade.d.ts +0 -1
  94. package/engine/object-data/entry.d.ts +2 -3
  95. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  96. package/engine/object-field/ability.d.ts +26 -3
  97. package/engine/object-field/ability.lua +54 -1
  98. package/engine/object-field.d.ts +2 -3
  99. package/engine/object-field.lua +4 -0
  100. package/engine/random.d.ts +1 -0
  101. package/engine/random.lua +9 -0
  102. package/engine/standard/entries/unit-type.d.ts +39 -1
  103. package/engine/standard/entries/unit-type.lua +39 -1
  104. package/engine/standard/fields/ability.d.ts +3 -1
  105. package/engine/standard/fields/ability.lua +3 -1
  106. package/engine/unit.d.ts +2 -0
  107. package/engine/unit.lua +11 -2
  108. package/event.d.ts +2 -3
  109. package/event.lua +9 -5
  110. package/index.d.ts +1 -0
  111. package/index.lua +1 -0
  112. package/lualib_bundle.lua +146 -42
  113. package/math/vec2.d.ts +2 -9
  114. package/math.d.ts +0 -2
  115. package/net/socket.d.ts +7 -1
  116. package/net/socket.lua +45 -4
  117. package/network.d.ts +1 -0
  118. package/network.lua +3 -2
  119. package/objutil/ability.d.ts +0 -1
  120. package/objutil/buff.d.ts +0 -1
  121. package/objutil/buff.lua +1 -1
  122. package/objutil/object.d.ts +0 -1
  123. package/objutil/unit.d.ts +0 -1
  124. package/package.json +13 -14
  125. package/patch-lua.d.ts +0 -0
  126. package/patch-lua.lua +10 -0
  127. package/property.d.ts +55 -0
  128. package/property.lua +374 -0
  129. package/string.d.ts +30 -0
  130. package/string.lua +14 -0
  131. package/util/stream.d.ts +0 -1
  132. package/utility/arrays.d.ts +11 -5
  133. package/utility/arrays.lua +34 -3
  134. package/utility/bit-set.d.ts +0 -2
  135. package/utility/lazy.d.ts +2 -0
  136. package/utility/lazy.lua +14 -0
  137. package/utility/linked-set.d.ts +11 -3
  138. package/utility/linked-set.lua +5 -2
  139. package/utility/lua-maps.d.ts +1 -2
  140. package/utility/lua-sets.d.ts +1 -2
  141. package/utility/types.d.ts +1 -0
  142. package/core/mapbounds.d.ts +0 -8
  143. 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
@@ -92,6 +97,10 @@ local isUnitInRangeXY = IsUnitInRangeXY
92
97
  local isUnitInRange = IsUnitInRange
93
98
  local setResourceAmount = SetResourceAmount
94
99
  local getResourceAmount = GetResourceAmount
100
+ local getUnitWeaponRealField = BlzGetUnitWeaponRealField
101
+ local setUnitWeaponRealField = BlzSetUnitWeaponRealField
102
+ local getUnitWeaponStringField = BlzGetUnitWeaponStringField
103
+ local setUnitWeaponStringField = BlzSetUnitWeaponStringField
95
104
  local getUnitAbilityLevel = GetUnitAbilityLevel
96
105
  local unitDisableAbility = BlzUnitDisableAbility
97
106
  local unitInterruptAttack = BlzUnitInterruptAttack
@@ -275,16 +284,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
275
284
  end
276
285
  local function dispatch(event, idGetter, argsGetter)
277
286
  local initialized = false
278
- local x = {}
279
287
  return setmetatable(
280
- x,
288
+ {},
281
289
  {
282
290
  __index = function(self, id)
283
291
  if type(id) ~= "number" then
284
292
  return event[id]
285
293
  end
286
294
  if not initialized then
287
- local invoke = Event.invoke
288
295
  event:addListener(function(...)
289
296
  local id = idGetter(...)
290
297
  local dispatched = rawget(self, id)
@@ -322,7 +329,6 @@ local function dispatchAbility(event)
322
329
  return event[id]
323
330
  end
324
331
  if not initialized then
325
- local invoke = Event.invoke
326
332
  event:addListener(function(unit, ability, ...)
327
333
  local dispatched = rawget(self, ability.typeId)
328
334
  if dispatched ~= nil then
@@ -387,51 +393,158 @@ local getters = {
387
393
  return BlzGetUnitArmor(unit)
388
394
  end
389
395
  }
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
- }
396
+ ____exports.UnitWeapon = __TS__Class()
397
+ local UnitWeapon = ____exports.UnitWeapon
398
+ UnitWeapon.name = "UnitWeapon"
399
+ function UnitWeapon.prototype.____constructor(self, unit, index)
400
+ self.unit = unit
401
+ self.index = index
402
+ end
403
+ __TS__SetDescriptor(
404
+ UnitWeapon.prototype,
405
+ "cooldown",
406
+ {
407
+ get = function(self)
408
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
409
+ end,
410
+ set = function(self, cooldown)
411
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
412
+ end
413
+ },
414
+ true
415
+ )
416
+ __TS__SetDescriptor(
417
+ UnitWeapon.prototype,
418
+ "damage",
419
+ {
420
+ get = function(self)
421
+ local minimumDamage = self.damageBase + self.damageDiceCount
422
+ local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
423
+ return {minimumDamage, maximumDamage}
424
+ end,
425
+ set = function(self, ____bindingPattern0)
426
+ local maximumDamage
427
+ local minimumDamage
428
+ minimumDamage = ____bindingPattern0[1]
429
+ maximumDamage = ____bindingPattern0[2]
430
+ self.damageBase = minimumDamage - 1
431
+ self.damageDiceCount = 1
432
+ self.damageDiceSideCount = maximumDamage - minimumDamage + 1
433
+ end
434
+ },
435
+ true
436
+ )
437
+ __TS__SetDescriptor(
438
+ UnitWeapon.prototype,
439
+ "damageBase",
440
+ {
441
+ get = function(self)
442
+ return BlzGetUnitBaseDamage(self.unit.handle, self.index)
443
+ end,
444
+ set = function(self, damageBase)
445
+ BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
446
+ end
447
+ },
448
+ true
449
+ )
450
+ __TS__SetDescriptor(
451
+ UnitWeapon.prototype,
452
+ "damageDiceCount",
453
+ {
454
+ get = function(self)
455
+ return BlzGetUnitDiceNumber(self.unit.handle, self.index)
456
+ end,
457
+ set = function(self, damageDiceCount)
458
+ BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
459
+ end
460
+ },
461
+ true
462
+ )
463
+ __TS__SetDescriptor(
464
+ UnitWeapon.prototype,
465
+ "damageDiceSideCount",
466
+ {
467
+ get = function(self)
468
+ return BlzGetUnitDiceSides(self.unit.handle, self.index)
469
+ end,
470
+ set = function(self, damageDiceSideCount)
471
+ BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
472
+ end
473
+ },
474
+ true
475
+ )
476
+ __TS__SetDescriptor(
477
+ UnitWeapon.prototype,
478
+ "range",
479
+ {
480
+ get = function(self)
481
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
482
+ end,
483
+ set = function(self, range)
484
+ local handle = self.unit.handle
485
+ local index = self.index
486
+ setUnitWeaponRealField(
487
+ handle,
488
+ UNIT_WEAPON_RF_ATTACK_RANGE,
489
+ index + 1,
490
+ getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
491
+ )
492
+ end
493
+ },
494
+ true
495
+ )
496
+ __TS__SetDescriptor(
497
+ UnitWeapon.prototype,
498
+ "impactDelay",
499
+ {
500
+ get = function(self)
501
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
502
+ end,
503
+ set = function(self, impactDelay)
504
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
505
+ end
506
+ },
507
+ true
508
+ )
509
+ __TS__SetDescriptor(
510
+ UnitWeapon.prototype,
511
+ "missileArc",
512
+ {
513
+ get = function(self)
514
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
515
+ end,
516
+ set = function(self, missileArc)
517
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
518
+ end
519
+ },
520
+ true
521
+ )
522
+ __TS__SetDescriptor(
523
+ UnitWeapon.prototype,
524
+ "missileModelPath",
525
+ {
526
+ get = function(self)
527
+ return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
528
+ end,
529
+ set = function(self, missileModelPath)
530
+ setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
531
+ end
532
+ },
533
+ true
534
+ )
535
+ __TS__SetDescriptor(
536
+ UnitWeapon.prototype,
537
+ "missileSpeed",
538
+ {
539
+ get = function(self)
540
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
541
+ end,
542
+ set = function(self, missileSpeed)
543
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
544
+ end
545
+ },
546
+ true
547
+ )
435
548
  local unitInventorySize = UnitInventorySize
436
549
  local unitItemInSlot = UnitItemInSlot
437
550
  local getItemAbility = BlzGetItemAbility
@@ -442,8 +555,6 @@ local getAbilityName = GetAbilityName
442
555
  local unitAddAbility = UnitAddAbility
443
556
  local getUnitGoldCost = GetUnitGoldCost
444
557
  local getUnitLumberCost = GetUnitWoodCost
445
- local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
446
- local unitAddItem = UnitAddItem
447
558
  local unitRemoveAbility = UnitRemoveAbility
448
559
  local function retrieveAbility(unit, ability, abilityId)
449
560
  if ability == nil then
@@ -453,17 +564,6 @@ local function retrieveAbility(unit, ability, abilityId)
453
564
  ____exports.Unit:of(unit)
454
565
  )
455
566
  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
567
  for i = 0, unitInventorySize(unit) - 1 do
468
568
  local item = unitItemInSlot(unit, i)
469
569
  if getItemAbility(item, abilityId) == ability then
@@ -520,12 +620,34 @@ for ____, player in ipairs(Player.all) do
520
620
  ShowUnit(dummy, false)
521
621
  dummies[player] = dummy
522
622
  end
623
+ local function delayHealthChecksCallback(unit)
624
+ local counter = (unit[103] or 0) - 1
625
+ if counter ~= 0 then
626
+ unit[103] = counter
627
+ return
628
+ end
629
+ unit[103] = nil
630
+ local healthBonus = unit[104]
631
+ if healthBonus ~= nil then
632
+ unit[104] = nil
633
+ local handle = unit.handle
634
+ BlzSetUnitMaxHP(
635
+ handle,
636
+ BlzGetUnitMaxHP(handle) - healthBonus
637
+ )
638
+ end
639
+ end
640
+ local nextSyncId = 1
641
+ local unitBySyncId = setmetatable({}, {__mode = "k"})
523
642
  ____exports.Unit = __TS__Class()
524
643
  local Unit = ____exports.Unit
525
644
  Unit.name = "Unit"
526
645
  __TS__ClassExtends(Unit, Handle)
527
646
  function Unit.prototype.____constructor(self, handle)
528
647
  Handle.prototype.____constructor(self, handle)
648
+ local ____nextSyncId_0 = nextSyncId
649
+ nextSyncId = ____nextSyncId_0 + 1
650
+ self.syncId = ____nextSyncId_0
529
651
  self._owner = Player:of(getOwningPlayer(handle))
530
652
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
531
653
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -538,6 +660,7 @@ function Unit.prototype.____constructor(self, handle)
538
660
  fourCC("Amrf")
539
661
  ))
540
662
  end
663
+ unitBySyncId[self.syncId] = self
541
664
  local ____ = self.abilities
542
665
  end
543
666
  function Unit.prototype.getEvent(self, event, collector)
@@ -623,8 +746,8 @@ function Unit.prototype.addModifier(self, property, modifier)
623
746
  end}
624
747
  end
625
748
  function Unit.prototype.hasCombatClassification(self, combatClassification)
626
- local ____combatClassification_0 = combatClassification
627
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_0 == ____combatClassification_0
749
+ local ____combatClassification_1 = combatClassification
750
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
628
751
  end
629
752
  function Unit.prototype.addClassification(self, classification)
630
753
  return unitAddType(self.handle, classification)
@@ -642,13 +765,13 @@ function Unit.prototype.isInvisibleTo(self, player)
642
765
  return isUnitInvisible(self.handle, player.handle)
643
766
  end
644
767
  function Unit.prototype.isInRangeOf(self, x, y, range)
645
- local ____temp_1
768
+ local ____temp_2
646
769
  if type(x) == "number" then
647
- ____temp_1 = isUnitInRangeXY(self.handle, x, y, range)
770
+ ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
648
771
  else
649
- ____temp_1 = isUnitInRange(self.handle, x.handle, y)
772
+ ____temp_2 = isUnitInRange(self.handle, x.handle, y)
650
773
  end
651
- return ____temp_1
774
+ return ____temp_2
652
775
  end
653
776
  function Unit.prototype.isAllyOf(self, unit)
654
777
  return isUnitAlly(
@@ -674,6 +797,10 @@ end
674
797
  function Unit.prototype.queueAnimation(self, animation)
675
798
  queueUnitAnimation(self.handle, animation)
676
799
  end
800
+ function Unit.prototype.delayHealthChecks(self)
801
+ self[103] = (self[103] or 0) + 1
802
+ Timer:run(delayHealthChecksCallback, self)
803
+ end
677
804
  function Unit.prototype.setPosition(self, x, y)
678
805
  setUnitPosition(self.handle, x, y)
679
806
  end
@@ -687,8 +814,15 @@ end
687
814
  function Unit.prototype.kill(self)
688
815
  killUnit(self.handle)
689
816
  end
690
- function Unit.prototype.revive(self, pos, doEffect)
691
- ReviveHero(self.handle, pos.x, pos.y, doEffect)
817
+ function Unit.prototype.revive(self, x, y, doEffect)
818
+ local ____ReviveHero_5 = ReviveHero
819
+ local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
820
+ local ____doEffect_3 = doEffect
821
+ if ____doEffect_3 == nil then
822
+ ____doEffect_3 = false
823
+ end
824
+ __TS__SparseArrayPush(____array_4, ____doEffect_3)
825
+ ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
692
826
  end
693
827
  function Unit.prototype.healTarget(self, target, amount)
694
828
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -728,7 +862,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
728
862
  return UnitDropItemSlot(self.handle, item.handle, slot)
729
863
  end
730
864
  function Unit.prototype.itemInSlot(self, slot)
731
- return Item:of(UnitItemInSlot(self.handle, slot))
865
+ return Item:of(unitItemInSlot(self.handle, slot))
732
866
  end
733
867
  function Unit.prototype.addAbility(self, abilityId)
734
868
  if unitAddAbility(self.handle, abilityId) then
@@ -784,6 +918,9 @@ end
784
918
  function Unit.prototype.hideAbility(self, abilityId, flag)
785
919
  BlzUnitHideAbility(self.handle, abilityId, flag)
786
920
  end
921
+ function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
922
+ return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
923
+ end
787
924
  function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
788
925
  BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
789
926
  end
@@ -794,8 +931,15 @@ function Unit.prototype.interruptAttack(self)
794
931
  unitInterruptAttack(self.handle)
795
932
  end
796
933
  function Unit.prototype.interruptCast(self, abilityId)
797
- unitDisableAbility(self.handle, abilityId, true, false)
798
- unitDisableAbility(self.handle, abilityId, false, false)
934
+ local handle = self.handle
935
+ unitDisableAbility(handle, abilityId, true, false)
936
+ Timer:run(
937
+ unitDisableAbility,
938
+ handle,
939
+ abilityId,
940
+ false,
941
+ false
942
+ )
799
943
  end
800
944
  function Unit.prototype.getDistanceTo(self, target)
801
945
  local handle = self.handle
@@ -855,18 +999,18 @@ function Unit.prototype.unpauseEx(self)
855
999
  self:decrementStunCounter()
856
1000
  end
857
1001
  function Unit.prototype.incrementStunCounter(self)
858
- local stunCounter = self[101] or 0
859
- if not self[100] or stunCounter >= 0 then
1002
+ local stunCounter = self[102] or 0
1003
+ if not self[101] or stunCounter >= 0 then
860
1004
  BlzPauseUnitEx(self.handle, true)
861
1005
  end
862
- self[101] = stunCounter + 1
1006
+ self[102] = stunCounter + 1
863
1007
  end
864
1008
  function Unit.prototype.decrementStunCounter(self)
865
- local stunCounter = self[101] or 0
866
- if not self[100] or stunCounter >= 1 then
1009
+ local stunCounter = self[102] or 0
1010
+ if not self[101] or stunCounter >= 1 then
867
1011
  BlzPauseUnitEx(self.handle, false)
868
1012
  end
869
- self[101] = stunCounter - 1
1013
+ self[102] = stunCounter - 1
870
1014
  end
871
1015
  function Unit.create(self, owner, id, x, y, facing, skinId)
872
1016
  local handle = skinId and BlzCreateUnitWithSkin(
@@ -968,8 +1112,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
968
1112
  )
969
1113
  return targetCollection
970
1114
  end
971
- function Unit.getSelectionOf(self, player)
972
- targetCollection = {}
1115
+ function Unit.getSelectionOf(self, player, target)
1116
+ if target == nil then
1117
+ target = {}
1118
+ end
1119
+ targetCollection = target
973
1120
  targetCollectionNextIndex = 1
974
1121
  GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
975
1122
  return targetCollection
@@ -991,6 +1138,9 @@ end
991
1138
  function Unit.prototype.__tostring(self)
992
1139
  return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
993
1140
  end
1141
+ function Unit.getBySyncId(self, syncId)
1142
+ return unitBySyncId[syncId]
1143
+ end
994
1144
  __TS__SetDescriptor(
995
1145
  Unit.prototype,
996
1146
  "_deltas",
@@ -1071,12 +1221,27 @@ __TS__SetDescriptor(
1071
1221
  Unit.prototype,
1072
1222
  "weapons",
1073
1223
  {get = function(self)
1074
- local weapons = {
1075
- setmetatable({h = self.handle, i = 0}, weaponMetatable),
1076
- setmetatable({h = self.handle, i = 1}, weaponMetatable)
1077
- }
1078
- rawset(self, "weapons", weapons)
1079
- return weapons
1224
+ return {self.firstWeapon, self.secondWeapon}
1225
+ end},
1226
+ true
1227
+ )
1228
+ __TS__SetDescriptor(
1229
+ Unit.prototype,
1230
+ "firstWeapon",
1231
+ {get = function(self)
1232
+ local weapon = __TS__New(____exports.UnitWeapon, self, 0)
1233
+ rawset(self, "firstWeapon", weapon)
1234
+ return weapon
1235
+ end},
1236
+ true
1237
+ )
1238
+ __TS__SetDescriptor(
1239
+ Unit.prototype,
1240
+ "secondWeapon",
1241
+ {get = function(self)
1242
+ local weapon = __TS__New(____exports.UnitWeapon, self, 1)
1243
+ rawset(self, "secondWeapon", weapon)
1244
+ return weapon
1080
1245
  end},
1081
1246
  true
1082
1247
  )
@@ -1233,17 +1398,17 @@ __TS__SetDescriptor(
1233
1398
  "isTeamGlowVisible",
1234
1399
  {
1235
1400
  get = function(self)
1236
- return not self[103]
1401
+ return not self[106]
1237
1402
  end,
1238
1403
  set = function(self, isTeamGlowVisible)
1239
1404
  showUnitTeamGlow(self.handle, isTeamGlowVisible)
1240
- local ____temp_2
1405
+ local ____temp_6
1241
1406
  if not isTeamGlowVisible then
1242
- ____temp_2 = true
1407
+ ____temp_6 = true
1243
1408
  else
1244
- ____temp_2 = nil
1409
+ ____temp_6 = nil
1245
1410
  end
1246
- self[103] = ____temp_2
1411
+ self[106] = ____temp_6
1247
1412
  end
1248
1413
  },
1249
1414
  true
@@ -1253,7 +1418,7 @@ __TS__SetDescriptor(
1253
1418
  "color",
1254
1419
  {set = function(self, color)
1255
1420
  setUnitColor(self.handle, color.handle)
1256
- if self[103] then
1421
+ if self[106] then
1257
1422
  showUnitTeamGlow(self.handle, false)
1258
1423
  end
1259
1424
  end},
@@ -1277,10 +1442,14 @@ __TS__SetDescriptor(
1277
1442
  "maxHealth",
1278
1443
  {
1279
1444
  get = function(self)
1280
- return BlzGetUnitMaxHP(self.handle) - (self[102] or 0)
1445
+ return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1281
1446
  end,
1282
1447
  set = function(self, maxHealth)
1283
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[102] or 0))
1448
+ if maxHealth < 1 and self[103] ~= nil then
1449
+ self[104] = (self[104] or 0) + (1 - maxHealth)
1450
+ maxHealth = 1
1451
+ end
1452
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1284
1453
  end
1285
1454
  },
1286
1455
  true
@@ -1322,10 +1491,10 @@ __TS__SetDescriptor(
1322
1491
  "health",
1323
1492
  {
1324
1493
  get = function(self)
1325
- return GetWidgetLife(self.handle) - (self[102] or 0)
1494
+ return GetWidgetLife(self.handle) - (self[105] or 0)
1326
1495
  end,
1327
1496
  set = function(self, health)
1328
- SetWidgetLife(self.handle, health + (self[102] or 0))
1497
+ SetWidgetLife(self.handle, health + (self[105] or 0))
1329
1498
  end
1330
1499
  },
1331
1500
  true
@@ -1536,17 +1705,17 @@ __TS__SetDescriptor(
1536
1705
  set = function(self, isPaused)
1537
1706
  local handle = self.handle
1538
1707
  if isPaused and not IsUnitPaused(handle) then
1539
- self[100] = true
1540
- for _ = self[101] or 0, -1 do
1708
+ self[101] = true
1709
+ for _ = self[102] or 0, -1 do
1541
1710
  BlzPauseUnitEx(handle, true)
1542
1711
  end
1543
1712
  PauseUnit(handle, true)
1544
1713
  elseif not isPaused and IsUnitPaused(handle) then
1545
1714
  PauseUnit(handle, false)
1546
- for _ = self[101] or 0, -1 do
1715
+ for _ = self[102] or 0, -1 do
1547
1716
  BlzPauseUnitEx(handle, false)
1548
1717
  end
1549
- self[100] = nil
1718
+ self[101] = nil
1550
1719
  end
1551
1720
  end
1552
1721
  },
@@ -1903,7 +2072,6 @@ Unit.onDecay = __TS__New(
1903
2072
  Unit.onResurrect = __TS__New(
1904
2073
  InitializingEvent,
1905
2074
  function(event)
1906
- local invoke = Event.invoke
1907
2075
  local dead = setmetatable({}, {__mode = "k"})
1908
2076
  ____exports.Unit.deathEvent:addListener(function(unit)
1909
2077
  dead[unit] = true
@@ -1919,10 +2087,15 @@ Unit.onResurrect = __TS__New(
1919
2087
  Unit.morphEvent = __TS__New(
1920
2088
  InitializingEvent,
1921
2089
  function(event)
2090
+ local function ifNotLeft(unit)
2091
+ local handle = unit.handle
2092
+ if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
2093
+ invoke(event, unit)
2094
+ end
2095
+ end
1922
2096
  ____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
1923
2097
  if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
1924
- assert(unitAddAbility(unit.handle, morphDetectAbilityId))
1925
- Timer:run(Event.invoke, event, unit)
2098
+ Timer:run(ifNotLeft, unit)
1926
2099
  end
1927
2100
  end)
1928
2101
  end
@@ -1960,27 +2133,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
1960
2133
  Unit.onTargetCast = dispatchId(__TS__New(
1961
2134
  InitializingEvent,
1962
2135
  function(event)
1963
- local invoke = Event.invoke
1964
2136
  local function listener(unit, id)
1965
- local ____GetSpellTargetUnit_result_5
2137
+ local ____GetSpellTargetUnit_result_9
1966
2138
  if GetSpellTargetUnit() then
1967
- ____GetSpellTargetUnit_result_5 = ____exports.Unit:of(GetSpellTargetUnit())
2139
+ ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
1968
2140
  else
1969
- local ____GetSpellTargetItem_result_4
2141
+ local ____GetSpellTargetItem_result_8
1970
2142
  if GetSpellTargetItem() then
1971
- ____GetSpellTargetItem_result_4 = Item:of(GetSpellTargetItem())
2143
+ ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
1972
2144
  else
1973
- local ____GetSpellTargetDestructable_result_3
2145
+ local ____GetSpellTargetDestructable_result_7
1974
2146
  if GetSpellTargetDestructable() then
1975
- ____GetSpellTargetDestructable_result_3 = Destructable:of(GetSpellTargetDestructable())
2147
+ ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
1976
2148
  else
1977
- ____GetSpellTargetDestructable_result_3 = nil
2149
+ ____GetSpellTargetDestructable_result_7 = nil
1978
2150
  end
1979
- ____GetSpellTargetItem_result_4 = ____GetSpellTargetDestructable_result_3
2151
+ ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
1980
2152
  end
1981
- ____GetSpellTargetUnit_result_5 = ____GetSpellTargetItem_result_4
2153
+ ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
1982
2154
  end
1983
- local target = ____GetSpellTargetUnit_result_5
2155
+ local target = ____GetSpellTargetUnit_result_9
1984
2156
  if target then
1985
2157
  invoke(event, unit, id, target)
1986
2158
  end
@@ -2152,10 +2324,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2152
2324
  ____exports.UnitTriggerEvent,
2153
2325
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2154
2326
  function()
2155
- local unit = ____exports.Unit:of(getOrderedUnit())
2156
- local issuedOrderId = getIssuedOrderId()
2157
- if unit ~= nil and unit.state == 1 then
2158
- return unit, issuedOrderId
2327
+ local handle = getOrderedUnit()
2328
+ if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
2329
+ local unit = ____exports.Unit:of(handle)
2330
+ if unit.state == 1 then
2331
+ return unit, getIssuedOrderId()
2332
+ end
2159
2333
  end
2160
2334
  return IgnoreEvent
2161
2335
  end
@@ -2177,7 +2351,6 @@ Unit.autoAttackStartEvent = __TS__New(
2177
2351
  )
2178
2352
  Unit.onDamaging = (function()
2179
2353
  local event = __TS__New(Event)
2180
- local invoke = Event.invoke
2181
2354
  local trigger = CreateTrigger()
2182
2355
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
2183
2356
  TriggerAddCondition(
@@ -2276,7 +2449,6 @@ end)()
2276
2449
  Unit.onDamage = __TS__New(
2277
2450
  InitializingEvent,
2278
2451
  function(event)
2279
- local invoke = Event.invoke
2280
2452
  local trigger = CreateTrigger()
2281
2453
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
2282
2454
  TriggerAddCondition(
@@ -2292,6 +2464,7 @@ Unit.onDamage = __TS__New(
2292
2464
  damageType = BlzGetEventDamageType(),
2293
2465
  weaponType = BlzGetEventWeaponType(),
2294
2466
  isAttack = BlzGetEventIsAttack(),
2467
+ originalAmount = GetEventDamage(),
2295
2468
  preventDeath = damageEventPreventDeath
2296
2469
  }
2297
2470
  local evData = setmetatable(
@@ -2308,7 +2481,7 @@ Unit.onDamage = __TS__New(
2308
2481
  invoke(event, source, target, evData)
2309
2482
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2310
2483
  local bonusHealth = math.ceil(evData.amount)
2311
- target[102] = (target[102] or 0) + bonusHealth
2484
+ target[105] = (target[105] or 0) + bonusHealth
2312
2485
  BlzSetUnitMaxHP(
2313
2486
  target.handle,
2314
2487
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2322,7 +2495,7 @@ Unit.onDamage = __TS__New(
2322
2495
  evData[0],
2323
2496
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2324
2497
  )
2325
- target[102] = (target[102] or 0) - bonusHealth
2498
+ target[105] = (target[105] or 0) - bonusHealth
2326
2499
  SetWidgetLife(
2327
2500
  target.handle,
2328
2501
  GetWidgetLife(target.handle) - bonusHealth
@@ -2342,32 +2515,91 @@ Unit.onDamage = __TS__New(
2342
2515
  DestroyTrigger(trigger)
2343
2516
  end
2344
2517
  )
2345
- Unit.onItemDrop = __TS__New(
2518
+ Unit.itemDroppedEvent = __TS__New(
2346
2519
  ____exports.UnitTriggerEvent,
2347
2520
  EVENT_PLAYER_UNIT_DROP_ITEM,
2348
2521
  function()
2349
2522
  local unit = getTriggerUnit()
2350
- if getUnitTypeId(unit) ~= dummyUnitId then
2351
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2523
+ local item = getManipulatedItem()
2524
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2525
+ return ____exports.Unit:of(unit), Item:of(item)
2352
2526
  end
2353
2527
  return IgnoreEvent
2354
2528
  end
2355
2529
  )
2356
- Unit.onItemPickup = __TS__New(
2530
+ Unit.itemPickedUpEvent = __TS__New(
2357
2531
  ____exports.UnitTriggerEvent,
2358
2532
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2359
2533
  function()
2360
2534
  local unit = getTriggerUnit()
2361
- if getUnitTypeId(unit) ~= dummyUnitId then
2362
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2535
+ local item = getManipulatedItem()
2536
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2537
+ return ____exports.Unit:of(unit), Item:of(item)
2363
2538
  end
2364
2539
  return IgnoreEvent
2365
2540
  end
2366
2541
  )
2367
- Unit.onItemUse = __TS__New(
2542
+ Unit.itemUsedEvent = __TS__New(
2368
2543
  ____exports.UnitTriggerEvent,
2369
2544
  EVENT_PLAYER_UNIT_USE_ITEM,
2370
- function() return ____exports.Unit:of(GetTriggerUnit()), Item:of(GetManipulatedItem()) end
2545
+ function()
2546
+ local unit = getTriggerUnit()
2547
+ local item = getManipulatedItem()
2548
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2549
+ return ____exports.Unit:of(unit), Item:of(item)
2550
+ end
2551
+ return IgnoreEvent
2552
+ end
2553
+ )
2554
+ Unit.itemStackedEvent = __TS__New(
2555
+ ____exports.UnitTriggerEvent,
2556
+ EVENT_PLAYER_UNIT_STACK_ITEM,
2557
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2558
+ )
2559
+ __TS__ObjectDefineProperty(
2560
+ Unit,
2561
+ "itemUseOrderEvent",
2562
+ {get = function(self)
2563
+ local event = __TS__New(Event)
2564
+ for order = orderId("useslot0"), orderId("useslot5") do
2565
+ local slot = order - orderId("useslot0")
2566
+ local function listener(unit)
2567
+ local item = unit.items[slot + 1]
2568
+ if item ~= nil then
2569
+ invoke(event, unit, item)
2570
+ end
2571
+ end
2572
+ self.onImmediateOrder[order]:addListener(listener)
2573
+ self.onTargetOrder[order]:addListener(listener)
2574
+ self.onPointOrder[order]:addListener(listener)
2575
+ end
2576
+ rawset(self, "itemUseOrderEvent", event)
2577
+ return event
2578
+ end}
2579
+ )
2580
+ __TS__ObjectDefineProperty(
2581
+ Unit,
2582
+ "itemMoveOrderEvent",
2583
+ {get = function(self)
2584
+ local event = __TS__New(Event)
2585
+ for order = orderId("moveslot0"), orderId("moveslot5") do
2586
+ local slotTo = order - orderId("moveslot0")
2587
+ self.onTargetOrder[order]:addListener(function(unit, item)
2588
+ local slotFrom = unit.items:findSlot(item)
2589
+ if slotFrom ~= nil then
2590
+ invoke(
2591
+ event,
2592
+ unit,
2593
+ item,
2594
+ slotFrom,
2595
+ slotTo
2596
+ )
2597
+ end
2598
+ end)
2599
+ end
2600
+ rawset(self, "itemMoveOrderEvent", event)
2601
+ return event
2602
+ end}
2371
2603
  )
2372
2604
  __TS__ObjectDefineProperty(
2373
2605
  Unit,