warscript 0.0.1-dev.1a5c0c0 → 0.0.1-dev.1bb9186

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 (61) hide show
  1. package/core/types/effect.d.ts +13 -3
  2. package/core/types/effect.lua +116 -17
  3. package/core/types/frame.d.ts +3 -0
  4. package/core/types/frame.lua +59 -0
  5. package/core/util.d.ts +1 -1
  6. package/core/util.lua +6 -0
  7. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  8. package/engine/behaviour/ability/always-enabled.lua +31 -0
  9. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  10. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  11. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  12. package/engine/behaviour/ability/instant-impact.lua +4 -19
  13. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  14. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  15. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  16. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  17. package/engine/behaviour/ability.d.ts +14 -3
  18. package/engine/behaviour/ability.lua +79 -33
  19. package/engine/buff.d.ts +6 -1
  20. package/engine/buff.lua +29 -18
  21. package/engine/internal/ability.d.ts +15 -2
  22. package/engine/internal/ability.lua +84 -4
  23. package/engine/internal/item/ability.lua +106 -0
  24. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  25. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  26. package/engine/internal/unit/ability.d.ts +10 -1
  27. package/engine/internal/unit/ability.lua +36 -14
  28. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  29. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  30. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  31. package/engine/internal/unit/add-item-to-slot.lua +50 -0
  32. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  33. package/engine/internal/unit/ignore-events-items.lua +5 -0
  34. package/engine/internal/unit/item.d.ts +1 -0
  35. package/engine/internal/unit/item.lua +8 -4
  36. package/engine/internal/unit/main-selected.d.ts +13 -0
  37. package/engine/internal/unit/main-selected.lua +51 -0
  38. package/engine/internal/unit.d.ts +20 -6
  39. package/engine/internal/unit.lua +147 -75
  40. package/engine/internal/utility.lua +12 -0
  41. package/engine/lightning.d.ts +8 -2
  42. package/engine/lightning.lua +27 -1
  43. package/engine/local-client.lua +3 -2
  44. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  45. package/engine/object-data/entry/ability-type.lua +8 -12
  46. package/engine/object-data/entry/item-type.d.ts +2 -0
  47. package/engine/object-data/entry/item-type.lua +13 -0
  48. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  49. package/engine/object-field/ability.d.ts +9 -3
  50. package/engine/object-field/ability.lua +3 -0
  51. package/engine/object-field.d.ts +2 -2
  52. package/engine/object-field.lua +4 -0
  53. package/engine/standard/fields/ability.d.ts +2 -0
  54. package/engine/standard/fields/ability.lua +2 -0
  55. package/engine/unit.d.ts +2 -0
  56. package/engine/unit.lua +2 -0
  57. package/package.json +2 -2
  58. package/utility/arrays.d.ts +8 -1
  59. package/utility/arrays.lua +34 -3
  60. package/utility/lazy.d.ts +2 -0
  61. package/utility/lazy.lua +14 -0
@@ -51,6 +51,8 @@ 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
54
56
  local match = string.match
55
57
  local ____tostring = _G.tostring
56
58
  local setUnitAnimation = SetUnitAnimation
@@ -75,6 +77,7 @@ local setUnitScale = SetUnitScale
75
77
  local setUnitPosition = SetUnitPosition
76
78
  local setUnitTimeScale = SetUnitTimeScale
77
79
  local getHandleId = GetHandleId
80
+ local getUnitCurrentOrder = GetUnitCurrentOrder
78
81
  local createUnit = CreateUnit
79
82
  local killUnit = KillUnit
80
83
  local setUnitExploded = SetUnitExploded
@@ -562,17 +565,6 @@ local function retrieveAbility(unit, ability, abilityId)
562
565
  ____exports.Unit:of(unit)
563
566
  )
564
567
  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
568
  for i = 0, unitInventorySize(unit) - 1 do
577
569
  local item = unitItemInSlot(unit, i)
578
570
  if getItemAbility(item, abilityId) == ability then
@@ -630,15 +622,15 @@ for ____, player in ipairs(Player.all) do
630
622
  dummies[player] = dummy
631
623
  end
632
624
  local function delayHealthChecksCallback(unit)
633
- local counter = (unit[102] or 0) - 1
625
+ local counter = (unit[103] or 0) - 1
634
626
  if counter ~= 0 then
635
- unit[102] = counter
627
+ unit[103] = counter
636
628
  return
637
629
  end
638
- unit[102] = nil
639
- local healthBonus = unit[103]
630
+ unit[103] = nil
631
+ local healthBonus = unit[104]
640
632
  if healthBonus ~= nil then
641
- unit[103] = nil
633
+ unit[104] = nil
642
634
  local handle = unit.handle
643
635
  BlzSetUnitMaxHP(
644
636
  handle,
@@ -646,12 +638,17 @@ local function delayHealthChecksCallback(unit)
646
638
  )
647
639
  end
648
640
  end
641
+ local nextSyncId = 1
642
+ local unitBySyncId = setmetatable({}, {__mode = "k"})
649
643
  ____exports.Unit = __TS__Class()
650
644
  local Unit = ____exports.Unit
651
645
  Unit.name = "Unit"
652
646
  __TS__ClassExtends(Unit, Handle)
653
647
  function Unit.prototype.____constructor(self, handle)
654
648
  Handle.prototype.____constructor(self, handle)
649
+ local ____nextSyncId_0 = nextSyncId
650
+ nextSyncId = ____nextSyncId_0 + 1
651
+ self.syncId = ____nextSyncId_0
655
652
  self._owner = Player:of(getOwningPlayer(handle))
656
653
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
657
654
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -664,6 +661,7 @@ function Unit.prototype.____constructor(self, handle)
664
661
  fourCC("Amrf")
665
662
  ))
666
663
  end
664
+ unitBySyncId[self.syncId] = self
667
665
  local ____ = self.abilities
668
666
  end
669
667
  function Unit.prototype.getEvent(self, event, collector)
@@ -749,8 +747,8 @@ function Unit.prototype.addModifier(self, property, modifier)
749
747
  end}
750
748
  end
751
749
  function Unit.prototype.hasCombatClassification(self, combatClassification)
752
- local ____combatClassification_0 = combatClassification
753
- 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
754
752
  end
755
753
  function Unit.prototype.addClassification(self, classification)
756
754
  return unitAddType(self.handle, classification)
@@ -768,13 +766,13 @@ function Unit.prototype.isInvisibleTo(self, player)
768
766
  return isUnitInvisible(self.handle, player.handle)
769
767
  end
770
768
  function Unit.prototype.isInRangeOf(self, x, y, range)
771
- local ____temp_1
769
+ local ____temp_2
772
770
  if type(x) == "number" then
773
- ____temp_1 = isUnitInRangeXY(self.handle, x, y, range)
771
+ ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
774
772
  else
775
- ____temp_1 = isUnitInRange(self.handle, x.handle, y)
773
+ ____temp_2 = isUnitInRange(self.handle, x.handle, y)
776
774
  end
777
- return ____temp_1
775
+ return ____temp_2
778
776
  end
779
777
  function Unit.prototype.isAllyOf(self, unit)
780
778
  return isUnitAlly(
@@ -801,7 +799,7 @@ function Unit.prototype.queueAnimation(self, animation)
801
799
  queueUnitAnimation(self.handle, animation)
802
800
  end
803
801
  function Unit.prototype.delayHealthChecks(self)
804
- self[102] = (self[102] or 0) + 1
802
+ self[103] = (self[103] or 0) + 1
805
803
  Timer:run(delayHealthChecksCallback, self)
806
804
  end
807
805
  function Unit.prototype.setPosition(self, x, y)
@@ -818,14 +816,14 @@ function Unit.prototype.kill(self)
818
816
  killUnit(self.handle)
819
817
  end
820
818
  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
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
826
824
  end
827
- __TS__SparseArrayPush(____array_3, ____doEffect_2)
828
- ____ReviveHero_4(__TS__SparseArraySpread(____array_3))
825
+ __TS__SparseArrayPush(____array_4, ____doEffect_3)
826
+ ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
829
827
  end
830
828
  function Unit.prototype.healTarget(self, target, amount)
831
829
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -934,8 +932,15 @@ function Unit.prototype.interruptAttack(self)
934
932
  unitInterruptAttack(self.handle)
935
933
  end
936
934
  function Unit.prototype.interruptCast(self, abilityId)
937
- unitDisableAbility(self.handle, abilityId, true, false)
938
- 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
+ )
939
944
  end
940
945
  function Unit.prototype.getDistanceTo(self, target)
941
946
  local handle = self.handle
@@ -995,18 +1000,18 @@ function Unit.prototype.unpauseEx(self)
995
1000
  self:decrementStunCounter()
996
1001
  end
997
1002
  function Unit.prototype.incrementStunCounter(self)
998
- local stunCounter = self[101] or 0
999
- if not self[100] or stunCounter >= 0 then
1003
+ local stunCounter = self[102] or 0
1004
+ if not self[101] or stunCounter >= 0 then
1000
1005
  BlzPauseUnitEx(self.handle, true)
1001
1006
  end
1002
- self[101] = stunCounter + 1
1007
+ self[102] = stunCounter + 1
1003
1008
  end
1004
1009
  function Unit.prototype.decrementStunCounter(self)
1005
- local stunCounter = self[101] or 0
1006
- if not self[100] or stunCounter >= 1 then
1010
+ local stunCounter = self[102] or 0
1011
+ if not self[101] or stunCounter >= 1 then
1007
1012
  BlzPauseUnitEx(self.handle, false)
1008
1013
  end
1009
- self[101] = stunCounter - 1
1014
+ self[102] = stunCounter - 1
1010
1015
  end
1011
1016
  function Unit.create(self, owner, id, x, y, facing, skinId)
1012
1017
  local handle = skinId and BlzCreateUnitWithSkin(
@@ -1134,6 +1139,9 @@ end
1134
1139
  function Unit.prototype.__tostring(self)
1135
1140
  return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
1136
1141
  end
1142
+ function Unit.getBySyncId(self, syncId)
1143
+ return unitBySyncId[syncId]
1144
+ end
1137
1145
  __TS__SetDescriptor(
1138
1146
  Unit.prototype,
1139
1147
  "_deltas",
@@ -1197,6 +1205,14 @@ __TS__SetDescriptor(
1197
1205
  end},
1198
1206
  true
1199
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
+ )
1200
1216
  __TS__SetDescriptor(
1201
1217
  Unit.prototype,
1202
1218
  "combatClassifications",
@@ -1391,17 +1407,17 @@ __TS__SetDescriptor(
1391
1407
  "isTeamGlowVisible",
1392
1408
  {
1393
1409
  get = function(self)
1394
- return not self[105]
1410
+ return not self[106]
1395
1411
  end,
1396
1412
  set = function(self, isTeamGlowVisible)
1397
1413
  showUnitTeamGlow(self.handle, isTeamGlowVisible)
1398
- local ____temp_5
1414
+ local ____temp_6
1399
1415
  if not isTeamGlowVisible then
1400
- ____temp_5 = true
1416
+ ____temp_6 = true
1401
1417
  else
1402
- ____temp_5 = nil
1418
+ ____temp_6 = nil
1403
1419
  end
1404
- self[105] = ____temp_5
1420
+ self[106] = ____temp_6
1405
1421
  end
1406
1422
  },
1407
1423
  true
@@ -1411,7 +1427,7 @@ __TS__SetDescriptor(
1411
1427
  "color",
1412
1428
  {set = function(self, color)
1413
1429
  setUnitColor(self.handle, color.handle)
1414
- if self[105] then
1430
+ if self[106] then
1415
1431
  showUnitTeamGlow(self.handle, false)
1416
1432
  end
1417
1433
  end},
@@ -1435,14 +1451,14 @@ __TS__SetDescriptor(
1435
1451
  "maxHealth",
1436
1452
  {
1437
1453
  get = function(self)
1438
- 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)
1439
1455
  end,
1440
1456
  set = function(self, maxHealth)
1441
- if maxHealth < 1 and self[102] ~= nil then
1442
- 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)
1443
1459
  maxHealth = 1
1444
1460
  end
1445
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[104] or 0))
1461
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1446
1462
  end
1447
1463
  },
1448
1464
  true
@@ -1484,10 +1500,10 @@ __TS__SetDescriptor(
1484
1500
  "health",
1485
1501
  {
1486
1502
  get = function(self)
1487
- return GetWidgetLife(self.handle) - (self[104] or 0)
1503
+ return GetWidgetLife(self.handle) - (self[105] or 0)
1488
1504
  end,
1489
1505
  set = function(self, health)
1490
- SetWidgetLife(self.handle, health + (self[104] or 0))
1506
+ SetWidgetLife(self.handle, health + (self[105] or 0))
1491
1507
  end
1492
1508
  },
1493
1509
  true
@@ -1698,17 +1714,17 @@ __TS__SetDescriptor(
1698
1714
  set = function(self, isPaused)
1699
1715
  local handle = self.handle
1700
1716
  if isPaused and not IsUnitPaused(handle) then
1701
- self[100] = true
1702
- for _ = self[101] or 0, -1 do
1717
+ self[101] = true
1718
+ for _ = self[102] or 0, -1 do
1703
1719
  BlzPauseUnitEx(handle, true)
1704
1720
  end
1705
1721
  PauseUnit(handle, true)
1706
1722
  elseif not isPaused and IsUnitPaused(handle) then
1707
1723
  PauseUnit(handle, false)
1708
- for _ = self[101] or 0, -1 do
1724
+ for _ = self[102] or 0, -1 do
1709
1725
  BlzPauseUnitEx(handle, false)
1710
1726
  end
1711
- self[100] = nil
1727
+ self[101] = nil
1712
1728
  end
1713
1729
  end
1714
1730
  },
@@ -2127,25 +2143,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2127
2143
  InitializingEvent,
2128
2144
  function(event)
2129
2145
  local function listener(unit, id)
2130
- local ____GetSpellTargetUnit_result_8
2146
+ local ____GetSpellTargetUnit_result_9
2131
2147
  if GetSpellTargetUnit() then
2132
- ____GetSpellTargetUnit_result_8 = ____exports.Unit:of(GetSpellTargetUnit())
2148
+ ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2133
2149
  else
2134
- local ____GetSpellTargetItem_result_7
2150
+ local ____GetSpellTargetItem_result_8
2135
2151
  if GetSpellTargetItem() then
2136
- ____GetSpellTargetItem_result_7 = Item:of(GetSpellTargetItem())
2152
+ ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2137
2153
  else
2138
- local ____GetSpellTargetDestructable_result_6
2154
+ local ____GetSpellTargetDestructable_result_7
2139
2155
  if GetSpellTargetDestructable() then
2140
- ____GetSpellTargetDestructable_result_6 = Destructable:of(GetSpellTargetDestructable())
2156
+ ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2141
2157
  else
2142
- ____GetSpellTargetDestructable_result_6 = nil
2158
+ ____GetSpellTargetDestructable_result_7 = nil
2143
2159
  end
2144
- ____GetSpellTargetItem_result_7 = ____GetSpellTargetDestructable_result_6
2160
+ ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2145
2161
  end
2146
- ____GetSpellTargetUnit_result_8 = ____GetSpellTargetItem_result_7
2162
+ ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2147
2163
  end
2148
- local target = ____GetSpellTargetUnit_result_8
2164
+ local target = ____GetSpellTargetUnit_result_9
2149
2165
  if target then
2150
2166
  invoke(event, unit, id, target)
2151
2167
  end
@@ -2317,10 +2333,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2317
2333
  ____exports.UnitTriggerEvent,
2318
2334
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2319
2335
  function()
2320
- local unit = ____exports.Unit:of(getOrderedUnit())
2321
- local issuedOrderId = getIssuedOrderId()
2322
- if unit ~= nil and unit.state == 1 then
2323
- 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
2324
2342
  end
2325
2343
  return IgnoreEvent
2326
2344
  end
@@ -2472,7 +2490,7 @@ Unit.onDamage = __TS__New(
2472
2490
  invoke(event, source, target, evData)
2473
2491
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2474
2492
  local bonusHealth = math.ceil(evData.amount)
2475
- target[104] = (target[104] or 0) + bonusHealth
2493
+ target[105] = (target[105] or 0) + bonusHealth
2476
2494
  BlzSetUnitMaxHP(
2477
2495
  target.handle,
2478
2496
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2486,7 +2504,7 @@ Unit.onDamage = __TS__New(
2486
2504
  evData[0],
2487
2505
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2488
2506
  )
2489
- target[104] = (target[104] or 0) - bonusHealth
2507
+ target[105] = (target[105] or 0) - bonusHealth
2490
2508
  SetWidgetLife(
2491
2509
  target.handle,
2492
2510
  GetWidgetLife(target.handle) - bonusHealth
@@ -2511,8 +2529,9 @@ Unit.itemDroppedEvent = __TS__New(
2511
2529
  EVENT_PLAYER_UNIT_DROP_ITEM,
2512
2530
  function()
2513
2531
  local unit = getTriggerUnit()
2514
- if getUnitTypeId(unit) ~= dummyUnitId then
2515
- 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)
2516
2535
  end
2517
2536
  return IgnoreEvent
2518
2537
  end
@@ -2522,8 +2541,9 @@ Unit.itemPickedUpEvent = __TS__New(
2522
2541
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2523
2542
  function()
2524
2543
  local unit = getTriggerUnit()
2525
- if getUnitTypeId(unit) ~= dummyUnitId then
2526
- 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)
2527
2547
  end
2528
2548
  return IgnoreEvent
2529
2549
  end
@@ -2531,13 +2551,65 @@ Unit.itemPickedUpEvent = __TS__New(
2531
2551
  Unit.itemUsedEvent = __TS__New(
2532
2552
  ____exports.UnitTriggerEvent,
2533
2553
  EVENT_PLAYER_UNIT_USE_ITEM,
2534
- 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
2535
2562
  )
2536
2563
  Unit.itemStackedEvent = __TS__New(
2537
2564
  ____exports.UnitTriggerEvent,
2538
2565
  EVENT_PLAYER_UNIT_STACK_ITEM,
2539
2566
  function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2540
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}
2612
+ )
2541
2613
  __TS__ObjectDefineProperty(
2542
2614
  Unit,
2543
2615
  "onCreate",
@@ -1,6 +1,8 @@
1
1
  local ____exports = {}
2
2
  local getUnitAbility = BlzGetUnitAbility
3
3
  local unitAddAbility = UnitAddAbility
4
+ local unitInventorySize = UnitInventorySize
5
+ local unitItemInSlot = UnitItemInSlot
4
6
  local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
5
7
  ---
6
8
  -- @internal For use by internal systems only.
@@ -10,4 +12,14 @@ ____exports.addInternalAbility = function(unit, abilityTypeId)
10
12
  end
11
13
  return getUnitAbility(unit, abilityTypeId)
12
14
  end
15
+ ---
16
+ -- @internal For use by internal systems only.
17
+ ____exports.findUnitItemSlot = function(unit, item)
18
+ for slot = 0, unitInventorySize(unit) - 1 do
19
+ if item == unitItemInSlot(unit, slot) then
20
+ return slot
21
+ end
22
+ end
23
+ return nil
24
+ end
13
25
  return ____exports
@@ -12,7 +12,8 @@ declare const enum LightningPropertyKey {
12
12
  TARGET_X = 106,
13
13
  TARGET_Y = 107,
14
14
  TARGET_Z = 108,
15
- DURATION = 109
15
+ DURATION = 109,
16
+ FADING = 110
16
17
  }
17
18
  export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
18
19
  export declare class Lightning extends Handle<jlightning> {
@@ -27,6 +28,7 @@ export declare class Lightning extends Handle<jlightning> {
27
28
  private [LightningPropertyKey.TARGET_Y]?;
28
29
  private [LightningPropertyKey.TARGET_Z]?;
29
30
  private [LightningPropertyKey.DURATION]?;
31
+ private [LightningPropertyKey.FADING]?;
30
32
  constructor(handle: jlightning, typeId: LightningTypeId);
31
33
  protected onDestroy(): HandleDestructor;
32
34
  static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
@@ -46,6 +48,10 @@ export declare class Lightning extends Handle<jlightning> {
46
48
  target: Unit
47
49
  ]
48
50
  ]): T;
49
- static flash(...parameters: [...parameters: Parameters<(typeof Lightning)["create"]>, duration: number]): void;
51
+ static flash(...parameters: [
52
+ ...parameters: Parameters<(typeof Lightning)["create"]>,
53
+ duration: number,
54
+ fading?: boolean
55
+ ]): void;
50
56
  }
51
57
  export {};
@@ -10,6 +10,8 @@ local ____functions = require("utility.functions")
10
10
  local forwardByN = ____functions.forwardByN
11
11
  local ____unit_2Dmissile_2Ddata = require("engine.internal.unit-missile-data")
12
12
  local MISSILE_DATA_BY_UNIT_TYPE_ID = ____unit_2Dmissile_2Ddata.MISSILE_DATA_BY_UNIT_TYPE_ID
13
+ local ____math = require("math")
14
+ local ceil = ____math.ceil
13
15
  local ____type = _G.type
14
16
  local select = _G.select
15
17
  local cos = math.cos
@@ -27,6 +29,11 @@ local getUnitZ = BlzGetUnitZ
27
29
  local getUnitFlyHeight = GetUnitFlyHeight
28
30
  local getLocationZ = GetLocationZ
29
31
  local moveLocation = MoveLocation
32
+ local getLightningColorA = GetLightningColorA
33
+ local getLightningColorR = GetLightningColorR
34
+ local getLightningColorG = GetLightningColorG
35
+ local getLightningColorB = GetLightningColorB
36
+ local setLightningColor = SetLightningColor
30
37
  local location = Location(0, 0)
31
38
  local unitToUnitLightnings = setmetatable({}, {__mode = "k"})
32
39
  local unitToPointLightnings = setmetatable({}, {__mode = "k"})
@@ -227,7 +234,16 @@ end
227
234
  function Lightning.flash(self, ...)
228
235
  local parametersToForwardCount = select("#", ...) - 1
229
236
  local lightning = forwardByN[parametersToForwardCount](____exports.Lightning.create, self, ...)
230
- local duration = select(-1, ...)
237
+ local parameterOrDuration, durationOrFading = select(-2, ...)
238
+ local duration
239
+ if ____type(durationOrFading) == "number" then
240
+ duration = durationOrFading
241
+ else
242
+ duration = parameterOrDuration
243
+ if durationOrFading then
244
+ lightning[110] = true
245
+ end
246
+ end
231
247
  lightning[109] = duration
232
248
  temporaryLightningsCount = temporaryLightningsCount + 1
233
249
  temporaryLightnings[temporaryLightningsCount] = lightning
@@ -295,6 +311,16 @@ Timer.onPeriod[UPDATE_PERIOD]:addListener(function()
295
311
  temporaryLightnings[temporaryLightningsCount] = nil
296
312
  temporaryLightningsCount = temporaryLightningsCount - 1
297
313
  else
314
+ if lightning[110] then
315
+ local handle = lightning.handle
316
+ setLightningColor(
317
+ handle,
318
+ getLightningColorR(handle),
319
+ getLightningColorG(handle),
320
+ getLightningColorB(handle),
321
+ ceil(getLightningColorA(handle) * (1 - UPDATE_PERIOD / duration))
322
+ )
323
+ end
298
324
  lightning[109] = duration - UPDATE_PERIOD
299
325
  i = i + 1
300
326
  end
@@ -115,7 +115,7 @@ __TS__ObjectDefineProperty(
115
115
  end
116
116
  tableSort(localSelectedUnits, compareUnitsSelectionPriority)
117
117
  local mainSelectedUnitIndex
118
- if selectionButtons then
118
+ if selectionButtons and #localSelectedUnits > 1 then
119
119
  local maxButtonWidth = 0
120
120
  for i = 0, #selectionButtons - 1 do
121
121
  local width = selectionButtons[i + 1].width
@@ -131,8 +131,9 @@ __TS__ObjectDefineProperty(
131
131
  localSelectedUnits[i] = nil
132
132
  end
133
133
  if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
134
- Event.invoke(mainSelectedUnitChangeEvent, previousMainSelectedUnit, mainSelectedUnit)
134
+ local previousPreviousMainSelectedUnit = previousMainSelectedUnit
135
135
  previousMainSelectedUnit = mainSelectedUnit
136
+ Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
136
137
  end
137
138
  return mainSelectedUnit
138
139
  end}
@@ -4,5 +4,9 @@ export declare const enum SoundPresetName {
4
4
  ABOMINATION_PISSED = "AbominationPissed",
5
5
  ABOMINATION_READY = "AbominationReady",
6
6
  ABOMINATION_WAR_CRY = "AbominationWarcry",
7
- AXE_MEDIUM_CHOP_WOOD = "AxeMediumChopWood"
7
+ AXE_MEDIUM_CHOP_WOOD = "AxeMediumChopWood",
8
+ IMPALE = "Impale",
9
+ IMPALE_HIT = "ImpaleHit",
10
+ IMPALE_LAND = "ImpaleLand",
11
+ IMPALE_CAST = "ImpaleCast"
8
12
  }
@@ -1,7 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
- local __TS__New = ____lualib.__TS__New
5
4
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
6
5
  local ____exports = {}
7
6
  local ____unit = require("engine.internal.unit")
@@ -31,7 +30,7 @@ local ____entry = require("engine.object-data.entry")
31
30
  local extractObjectDataEntryLevelFieldValue = ____entry.extractObjectDataEntryLevelFieldValue
32
31
  local ObjectDataEntry = ____entry.ObjectDataEntry
33
32
  local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
34
- local ObjectDataEntryIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.ObjectDataEntryIdGenerator
33
+ local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
35
34
  local ____upgrade = require("engine.object-data.entry.upgrade")
36
35
  local Upgrade = ____upgrade.Upgrade
37
36
  local castAnimationFQNByAbilityTypeId = {}
@@ -53,10 +52,7 @@ end
53
52
  function AbilityType.getObjectData(self, map)
54
53
  return map.objects.ability
55
54
  end
56
- AbilityType.idGenerator = __TS__New(
57
- ObjectDataEntryIdGenerator,
58
- fourCC("A000")
59
- )
55
+ AbilityType.idGenerator = abilityTypeIdGenerator
60
56
  __TS__SetDescriptor(
61
57
  AbilityType.prototype,
62
58
  "channelingAnimation",
@@ -999,7 +995,7 @@ local function handleAbilityCastingStartEvent(caster, ability)
999
995
  end
1000
996
  casterCastingEffectsByCaster[caster] = effects
1001
997
  end
1002
- local function handleAbilityStopEvent(caster)
998
+ local function handleAbilityStopCastingEvent(caster)
1003
999
  local effects = casterCastingEffectsByCaster[caster]
1004
1000
  if effects ~= nil then
1005
1001
  for i = 1, #effects do
@@ -1010,8 +1006,8 @@ local function handleAbilityStopEvent(caster)
1010
1006
  end
1011
1007
  for abilityTypeId in pairs(casterCastingEffectModelPathsByAbilityTypeId) do
1012
1008
  Unit.abilityCastingStartEvent[abilityTypeId]:addListener(4, handleAbilityCastingStartEvent)
1013
- Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityStopEvent)
1014
- Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopEvent)
1009
+ Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityStopCastingEvent)
1010
+ Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopCastingEvent)
1015
1011
  end
1016
1012
  local casterChannelingEffectModelPathsByAbilityTypeId = postcompile(function()
1017
1013
  return mapValues(
@@ -1042,7 +1038,7 @@ local function handleAbilityChannelingStartEvent(caster, ability)
1042
1038
  end
1043
1039
  casterChannelingEffectsByCaster[caster] = effects
1044
1040
  end
1045
- local function handleAbilityStopEventV2(caster)
1041
+ local function handleAbilityStopChannelingEvent(caster)
1046
1042
  local effects = casterChannelingEffectsByCaster[caster]
1047
1043
  if effects ~= nil then
1048
1044
  for i = 1, #effects do
@@ -1053,7 +1049,7 @@ local function handleAbilityStopEventV2(caster)
1053
1049
  end
1054
1050
  for abilityTypeId in pairs(casterChannelingEffectModelPathsByAbilityTypeId) do
1055
1051
  Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityChannelingStartEvent)
1056
- Unit.abilityChannelingFinishEvent[abilityTypeId]:addListener(4, handleAbilityStopEventV2)
1057
- Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopEventV2)
1052
+ Unit.abilityChannelingFinishEvent[abilityTypeId]:addListener(4, handleAbilityStopChannelingEvent)
1053
+ Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopChannelingEvent)
1058
1054
  end
1059
1055
  return ____exports
@@ -45,6 +45,8 @@ export declare class ItemType extends ObjectDataEntry<ItemTypeId> {
45
45
  set tooltipText(tooltipText: string);
46
46
  get tooltipExtendedText(): string;
47
47
  set tooltipExtendedText(tooltipText: string);
48
+ get cooldownGroupId(): number;
49
+ set cooldownGroupId(cooldownGroupId: number);
48
50
  get goldCost(): number;
49
51
  set goldCost(goldCost: number);
50
52
  get lumberCost(): number;