warscript 0.0.1-dev.ec4cf89 → 0.0.1-dev.f967846

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 (45) hide show
  1. package/core/types/frame.d.ts +6 -0
  2. package/core/types/frame.lua +91 -1
  3. package/core/util.d.ts +1 -1
  4. package/core/util.lua +6 -0
  5. package/engine/behavior.d.ts +2 -2
  6. package/engine/behavior.lua +6 -6
  7. package/engine/behaviour/ability/apply-buff.d.ts +3 -5
  8. package/engine/behaviour/unit.d.ts +5 -0
  9. package/engine/behaviour/unit.lua +20 -0
  10. package/engine/buff.d.ts +32 -11
  11. package/engine/buff.lua +142 -61
  12. package/engine/internal/ability.d.ts +3 -11
  13. package/engine/internal/ability.lua +9 -78
  14. package/engine/internal/item+owner.lua +2 -2
  15. package/engine/internal/unit/bonus.d.ts +4 -2
  16. package/engine/internal/unit/bonus.lua +6 -1
  17. package/engine/internal/unit/item.d.ts +24 -0
  18. package/engine/internal/unit/item.lua +84 -0
  19. package/engine/internal/unit/main-selected.d.ts +7 -0
  20. package/engine/internal/unit/main-selected.lua +40 -0
  21. package/engine/internal/unit+ability.lua +2 -2
  22. package/engine/internal/unit-missile-launch.lua +24 -5
  23. package/engine/internal/unit.d.ts +24 -10
  24. package/engine/internal/unit.lua +106 -60
  25. package/engine/local-client.d.ts +7 -2
  26. package/engine/local-client.lua +82 -0
  27. package/engine/object-data/entry/item-type.d.ts +12 -0
  28. package/engine/object-data/entry/item-type.lua +78 -0
  29. package/engine/object-field/ability.d.ts +17 -0
  30. package/engine/object-field/ability.lua +51 -1
  31. package/engine/unit.d.ts +2 -0
  32. package/engine/unit.lua +2 -0
  33. package/index.d.ts +1 -0
  34. package/index.lua +1 -0
  35. package/net/socket.d.ts +7 -1
  36. package/net/socket.lua +45 -4
  37. package/network.d.ts +1 -0
  38. package/network.lua +3 -2
  39. package/objutil/buff.lua +1 -1
  40. package/package.json +2 -2
  41. package/patch-lua.d.ts +0 -0
  42. package/patch-lua.lua +10 -0
  43. package/utility/linked-set.d.ts +11 -2
  44. package/utility/linked-set.lua +5 -2
  45. package/utility/types.d.ts +1 -0
@@ -0,0 +1,84 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__New = ____lualib.__TS__New
4
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
5
+ local ____exports = {}
6
+ local ____item = require("engine.internal.item")
7
+ local Item = ____item.Item
8
+ local ____unit = require("engine.internal.unit")
9
+ local Unit = ____unit.Unit
10
+ local rawset = _G.rawset
11
+ local ____type = _G.type
12
+ local isItemPowerup = IsItemPowerup
13
+ local setItemBooleanField = BlzSetItemBooleanField
14
+ local unitAddItem = UnitAddItem
15
+ local unitDropItemSlot = UnitDropItemSlot
16
+ local unitInventorySize = UnitInventorySize
17
+ local unitItemInSlot = UnitItemInSlot
18
+ local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
19
+ local handleByUnitItems = setmetatable({}, {__mode = "k"})
20
+ local function unitItemsNext(handle, index)
21
+ local slot = index & 7
22
+ if index >> 3 == slot then
23
+ return nil, nil
24
+ end
25
+ return index + 1, Item:of(unitItemInSlot(handle, slot))
26
+ end
27
+ ____exports.UnitItems = __TS__Class()
28
+ local UnitItems = ____exports.UnitItems
29
+ UnitItems.name = "UnitItems"
30
+ function UnitItems.prototype.____constructor(self, handle)
31
+ handleByUnitItems[self] = handle
32
+ end
33
+ function UnitItems.prototype.findSlot(self, item)
34
+ local handle = handleByUnitItems[self]
35
+ local itemHandle = item.handle
36
+ for slot = 0, unitInventorySize(handle) - 1 do
37
+ if itemHandle == unitItemInSlot(handle, slot) then
38
+ return slot
39
+ end
40
+ end
41
+ return nil
42
+ end
43
+ function UnitItems.prototype.__newindex(self, slot, item)
44
+ local handle = handleByUnitItems[self]
45
+ if slot < 1 or slot > unitInventorySize(handle) then
46
+ return
47
+ end
48
+ unitRemoveItemFromSlot(handle, slot - 1)
49
+ if item ~= nil then
50
+ local itemHandle = item.handle
51
+ local isPowerup = isItemPowerup(itemHandle)
52
+ if isPowerup then
53
+ setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
54
+ end
55
+ unitAddItem(handle, itemHandle)
56
+ unitDropItemSlot(handle, itemHandle, slot - 1)
57
+ if isPowerup then
58
+ setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
59
+ end
60
+ end
61
+ end
62
+ function UnitItems.prototype.__index(self, key)
63
+ if ____type(key) == "number" then
64
+ return Item:of(unitItemInSlot(handleByUnitItems[self], key - 1))
65
+ end
66
+ return rawget(____exports.UnitItems.prototype, key)
67
+ end
68
+ function UnitItems.prototype.__len(self)
69
+ return unitInventorySize(handleByUnitItems[self])
70
+ end
71
+ function UnitItems.prototype.__ipairs(self)
72
+ local handle = handleByUnitItems[self]
73
+ return unitItemsNext, handle, unitInventorySize(handle) << 3
74
+ end
75
+ __TS__ObjectDefineProperty(
76
+ Unit.prototype,
77
+ "items",
78
+ {get = function(self)
79
+ local items = __TS__New(____exports.UnitItems, self.handle)
80
+ rawset(self, "items", items)
81
+ return items
82
+ end}
83
+ )
84
+ return ____exports
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ import { Player } from "../../../core/types/player";
3
+ declare module "../unit" {
4
+ namespace Unit {
5
+ const getMainSelectedOf: (player: Player) => Unit | undefined;
6
+ }
7
+ }
@@ -0,0 +1,40 @@
1
+ local ____exports = {}
2
+ local ____player = require("core.types.player")
3
+ local Player = ____player.Player
4
+ local ____math = require("math")
5
+ local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
6
+ local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
7
+ local ____local_2Dclient = require("engine.local-client")
8
+ local LocalClient = ____local_2Dclient.LocalClient
9
+ local ____unit = require("engine.internal.unit")
10
+ local Unit = ____unit.Unit
11
+ local mainSelectedUnitByPlayer = {}
12
+ local syncSlider = BlzCreateFrameByType(
13
+ "SLIDER",
14
+ "UnitSyncId",
15
+ BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
16
+ "",
17
+ 0
18
+ )
19
+ BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
20
+ LocalClient.mainSelectedUnitChangeEvent:addListener(function()
21
+ local ____opt_0 = LocalClient.mainSelectedUnit
22
+ local syncId = ____opt_0 and ____opt_0.syncId
23
+ BlzFrameSetValue(syncSlider, syncId or 0)
24
+ end)
25
+ local trg = CreateTrigger()
26
+ BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
27
+ TriggerAddAction(
28
+ trg,
29
+ function()
30
+ mainSelectedUnitByPlayer[Player:of(GetTriggerPlayer())] = Unit:getBySyncId(BlzGetTriggerFrameValue())
31
+ end
32
+ )
33
+ rawset(
34
+ Unit,
35
+ "getMainSelectedOf",
36
+ function(player)
37
+ return mainSelectedUnitByPlayer[player]
38
+ end
39
+ )
40
+ return ____exports
@@ -40,7 +40,7 @@ ItemAbility.onCreate:addListener(
40
40
  end
41
41
  end
42
42
  )
43
- Unit.onItemPickup:addListener(
43
+ Unit.itemPickedUpEvent:addListener(
44
44
  0,
45
45
  function(unit, item)
46
46
  for ____, ability in ipairs(item.abilities) do
@@ -48,7 +48,7 @@ Unit.onItemPickup:addListener(
48
48
  end
49
49
  end
50
50
  )
51
- Unit.onItemDrop:addListener(
51
+ Unit.itemDroppedEvent:addListener(
52
52
  4,
53
53
  function(unit, item)
54
54
  for ____, ability in ipairs(item.abilities) do
@@ -7,14 +7,33 @@ local ____event = require("event")
7
7
  local Event = ____event.Event
8
8
  local ____timer = require("core.types.timer")
9
9
  local Timer = ____timer.Timer
10
+ local ____lua_2Dsets = require("utility.lua-sets")
11
+ local luaSetOf = ____lua_2Dsets.luaSetOf
10
12
  local autoAttackFinishEvent = __TS__New(Event)
11
13
  rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
12
14
  local eventTimerByUnit = {}
13
- local function reset(source)
14
- local eventTimer = eventTimerByUnit[source]
15
- if eventTimer then
16
- eventTimer:destroy()
17
- eventTimerByUnit[source] = nil
15
+ local instantOrderIds = luaSetOf(
16
+ orderId("avatar"),
17
+ orderId("berserk"),
18
+ orderId("divineshield"),
19
+ orderId("immolation"),
20
+ orderId("moveslot0"),
21
+ orderId("moveslot1"),
22
+ orderId("moveslot2"),
23
+ orderId("moveslot3"),
24
+ orderId("moveslot4"),
25
+ orderId("moveslot5"),
26
+ orderId("unavatar"),
27
+ orderId("undivineshield"),
28
+ orderId("unimmolation")
29
+ )
30
+ local function reset(source, orderId)
31
+ if not (instantOrderIds[orderId] ~= nil) then
32
+ local eventTimer = eventTimerByUnit[source]
33
+ if eventTimer then
34
+ eventTimer:destroy()
35
+ eventTimerByUnit[source] = nil
36
+ end
18
37
  end
19
38
  end
20
39
  Unit.onImmediateOrder:addListener(reset)
@@ -42,6 +42,7 @@ export interface DamagingEvent {
42
42
  damageType: jdamagetype;
43
43
  weaponType: jweapontype;
44
44
  readonly isAttack: boolean;
45
+ readonly originalAmount: number;
45
46
  }
46
47
  export type DamageEvent = DamagingEvent & {
47
48
  preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
@@ -93,14 +94,19 @@ export declare class UnitWeapon {
93
94
  set missileSpeed(missileSpeed: number);
94
95
  }
95
96
  declare const enum UnitPropertyKey {
96
- IS_PAUSED = 100,
97
- STUN_COUNTER = 101,
98
- DELAY_HEALTH_CHECKS_COUNTER = 102,
99
- DELAY_HEALTH_CHECKS_HEALTH_BONUS = 103,
100
- PREVENT_DEATH_HEALTH_BONUS = 104,
101
- IS_TEAM_GLOW_HIDDEN = 105
97
+ SYNC_ID = 100,
98
+ IS_PAUSED = 101,
99
+ STUN_COUNTER = 102,
100
+ DELAY_HEALTH_CHECKS_COUNTER = 103,
101
+ DELAY_HEALTH_CHECKS_HEALTH_BONUS = 104,
102
+ PREVENT_DEATH_HEALTH_BONUS = 105,
103
+ IS_TEAM_GLOW_HIDDEN = 106
102
104
  }
105
+ export type UnitSyncId = number & {
106
+ readonly __unitSyncId: unique symbol;
107
+ };
103
108
  export declare class Unit extends Handle<junit> {
109
+ readonly syncId: UnitSyncId;
104
110
  private [UnitPropertyKey.IS_PAUSED]?;
105
111
  private [UnitPropertyKey.STUN_COUNTER]?;
106
112
  private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
@@ -287,7 +293,7 @@ export declare class Unit extends Handle<junit> {
287
293
  static getInRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
288
294
  static getInCollisionRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
289
295
  static getInSector(pos: Vec2, range: number, offsetAngle: number, centralAngle: number): Unit[];
290
- static getSelectionOf(player: Player): Unit[];
296
+ static getSelectionOf(player: Player, target?: Unit[]): Unit[];
291
297
  static readonly deathEvent: UnitTriggerEvent<[Unit]>;
292
298
  static readonly onDecay: UnitTriggerEvent<[]>;
293
299
  static readonly onResurrect: InitializingEvent<[Unit], void>;
@@ -322,9 +328,16 @@ export declare class Unit extends Handle<junit> {
322
328
  static readonly autoAttackStartEvent: UnitTriggerEvent<[Unit]>;
323
329
  static readonly onDamaging: Event<[source: Unit | undefined, target: Unit, event: DamagingEvent]>;
324
330
  static readonly onDamage: InitializingEvent<[source: Unit | undefined, target: Unit, event: DamageEvent], jtrigger>;
325
- static onItemDrop: UnitTriggerEvent<[Item]>;
326
- static onItemPickup: UnitTriggerEvent<[Item]>;
327
- static onItemUse: UnitTriggerEvent<[Item]>;
331
+ static itemDroppedEvent: UnitTriggerEvent<[Item]>;
332
+ static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
333
+ static itemUsedEvent: UnitTriggerEvent<[Item]>;
334
+ static itemStackedEvent: UnitTriggerEvent<[Item]>;
335
+ static get itemMovedEvent(): Event<[
336
+ unit: Unit,
337
+ item: Item,
338
+ slotFrom: 0 | 1 | 2 | 3 | 4 | 5,
339
+ slotTo: 0 | 1 | 2 | 3 | 4 | 5
340
+ ]>;
328
341
  static get onCreate(): EventDispatcher<[Unit], [Unit]>;
329
342
  static get destroyEvent(): EventDispatcher<[Unit], [Unit]>;
330
343
  getField(field: junitintegerfield | junitrealfield): number;
@@ -335,5 +348,6 @@ export declare class Unit extends Handle<junit> {
335
348
  setField(field: junitbooleanfield, value: boolean): boolean;
336
349
  setField(field: junitstringfield, value: string): boolean;
337
350
  toString(): string;
351
+ static getBySyncId(syncId: UnitSyncId): Unit | undefined;
338
352
  }
339
353
  export {};
@@ -630,15 +630,15 @@ for ____, player in ipairs(Player.all) do
630
630
  dummies[player] = dummy
631
631
  end
632
632
  local function delayHealthChecksCallback(unit)
633
- local counter = (unit[102] or 0) - 1
633
+ local counter = (unit[103] or 0) - 1
634
634
  if counter ~= 0 then
635
- unit[102] = counter
635
+ unit[103] = counter
636
636
  return
637
637
  end
638
- unit[102] = nil
639
- local healthBonus = unit[103]
638
+ unit[103] = nil
639
+ local healthBonus = unit[104]
640
640
  if healthBonus ~= nil then
641
- unit[103] = nil
641
+ unit[104] = nil
642
642
  local handle = unit.handle
643
643
  BlzSetUnitMaxHP(
644
644
  handle,
@@ -646,12 +646,17 @@ local function delayHealthChecksCallback(unit)
646
646
  )
647
647
  end
648
648
  end
649
+ local nextSyncId = 1
650
+ local unitBySyncId = setmetatable({}, {__mode = "k"})
649
651
  ____exports.Unit = __TS__Class()
650
652
  local Unit = ____exports.Unit
651
653
  Unit.name = "Unit"
652
654
  __TS__ClassExtends(Unit, Handle)
653
655
  function Unit.prototype.____constructor(self, handle)
654
656
  Handle.prototype.____constructor(self, handle)
657
+ local ____nextSyncId_0 = nextSyncId
658
+ nextSyncId = ____nextSyncId_0 + 1
659
+ self.syncId = ____nextSyncId_0
655
660
  self._owner = Player:of(getOwningPlayer(handle))
656
661
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
657
662
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -664,6 +669,7 @@ function Unit.prototype.____constructor(self, handle)
664
669
  fourCC("Amrf")
665
670
  ))
666
671
  end
672
+ unitBySyncId[self.syncId] = self
667
673
  local ____ = self.abilities
668
674
  end
669
675
  function Unit.prototype.getEvent(self, event, collector)
@@ -749,8 +755,8 @@ function Unit.prototype.addModifier(self, property, modifier)
749
755
  end}
750
756
  end
751
757
  function Unit.prototype.hasCombatClassification(self, combatClassification)
752
- local ____combatClassification_0 = combatClassification
753
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_0 == ____combatClassification_0
758
+ local ____combatClassification_1 = combatClassification
759
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
754
760
  end
755
761
  function Unit.prototype.addClassification(self, classification)
756
762
  return unitAddType(self.handle, classification)
@@ -768,13 +774,13 @@ function Unit.prototype.isInvisibleTo(self, player)
768
774
  return isUnitInvisible(self.handle, player.handle)
769
775
  end
770
776
  function Unit.prototype.isInRangeOf(self, x, y, range)
771
- local ____temp_1
777
+ local ____temp_2
772
778
  if type(x) == "number" then
773
- ____temp_1 = isUnitInRangeXY(self.handle, x, y, range)
779
+ ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
774
780
  else
775
- ____temp_1 = isUnitInRange(self.handle, x.handle, y)
781
+ ____temp_2 = isUnitInRange(self.handle, x.handle, y)
776
782
  end
777
- return ____temp_1
783
+ return ____temp_2
778
784
  end
779
785
  function Unit.prototype.isAllyOf(self, unit)
780
786
  return isUnitAlly(
@@ -801,7 +807,7 @@ function Unit.prototype.queueAnimation(self, animation)
801
807
  queueUnitAnimation(self.handle, animation)
802
808
  end
803
809
  function Unit.prototype.delayHealthChecks(self)
804
- self[102] = (self[102] or 0) + 1
810
+ self[103] = (self[103] or 0) + 1
805
811
  Timer:run(delayHealthChecksCallback, self)
806
812
  end
807
813
  function Unit.prototype.setPosition(self, x, y)
@@ -818,14 +824,14 @@ function Unit.prototype.kill(self)
818
824
  killUnit(self.handle)
819
825
  end
820
826
  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
827
+ local ____ReviveHero_5 = ReviveHero
828
+ local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
829
+ local ____doEffect_3 = doEffect
830
+ if ____doEffect_3 == nil then
831
+ ____doEffect_3 = false
826
832
  end
827
- __TS__SparseArrayPush(____array_3, ____doEffect_2)
828
- ____ReviveHero_4(__TS__SparseArraySpread(____array_3))
833
+ __TS__SparseArrayPush(____array_4, ____doEffect_3)
834
+ ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
829
835
  end
830
836
  function Unit.prototype.healTarget(self, target, amount)
831
837
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -865,7 +871,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
865
871
  return UnitDropItemSlot(self.handle, item.handle, slot)
866
872
  end
867
873
  function Unit.prototype.itemInSlot(self, slot)
868
- return Item:of(UnitItemInSlot(self.handle, slot))
874
+ return Item:of(unitItemInSlot(self.handle, slot))
869
875
  end
870
876
  function Unit.prototype.addAbility(self, abilityId)
871
877
  if unitAddAbility(self.handle, abilityId) then
@@ -995,18 +1001,18 @@ function Unit.prototype.unpauseEx(self)
995
1001
  self:decrementStunCounter()
996
1002
  end
997
1003
  function Unit.prototype.incrementStunCounter(self)
998
- local stunCounter = self[101] or 0
999
- if not self[100] or stunCounter >= 0 then
1004
+ local stunCounter = self[102] or 0
1005
+ if not self[101] or stunCounter >= 0 then
1000
1006
  BlzPauseUnitEx(self.handle, true)
1001
1007
  end
1002
- self[101] = stunCounter + 1
1008
+ self[102] = stunCounter + 1
1003
1009
  end
1004
1010
  function Unit.prototype.decrementStunCounter(self)
1005
- local stunCounter = self[101] or 0
1006
- if not self[100] or stunCounter >= 1 then
1011
+ local stunCounter = self[102] or 0
1012
+ if not self[101] or stunCounter >= 1 then
1007
1013
  BlzPauseUnitEx(self.handle, false)
1008
1014
  end
1009
- self[101] = stunCounter - 1
1015
+ self[102] = stunCounter - 1
1010
1016
  end
1011
1017
  function Unit.create(self, owner, id, x, y, facing, skinId)
1012
1018
  local handle = skinId and BlzCreateUnitWithSkin(
@@ -1108,8 +1114,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
1108
1114
  )
1109
1115
  return targetCollection
1110
1116
  end
1111
- function Unit.getSelectionOf(self, player)
1112
- targetCollection = {}
1117
+ function Unit.getSelectionOf(self, player, target)
1118
+ if target == nil then
1119
+ target = {}
1120
+ end
1121
+ targetCollection = target
1113
1122
  targetCollectionNextIndex = 1
1114
1123
  GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
1115
1124
  return targetCollection
@@ -1131,6 +1140,9 @@ end
1131
1140
  function Unit.prototype.__tostring(self)
1132
1141
  return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
1133
1142
  end
1143
+ function Unit.getBySyncId(self, syncId)
1144
+ return unitBySyncId[syncId]
1145
+ end
1134
1146
  __TS__SetDescriptor(
1135
1147
  Unit.prototype,
1136
1148
  "_deltas",
@@ -1388,17 +1400,17 @@ __TS__SetDescriptor(
1388
1400
  "isTeamGlowVisible",
1389
1401
  {
1390
1402
  get = function(self)
1391
- return not self[105]
1403
+ return not self[106]
1392
1404
  end,
1393
1405
  set = function(self, isTeamGlowVisible)
1394
1406
  showUnitTeamGlow(self.handle, isTeamGlowVisible)
1395
- local ____temp_5
1407
+ local ____temp_6
1396
1408
  if not isTeamGlowVisible then
1397
- ____temp_5 = true
1409
+ ____temp_6 = true
1398
1410
  else
1399
- ____temp_5 = nil
1411
+ ____temp_6 = nil
1400
1412
  end
1401
- self[105] = ____temp_5
1413
+ self[106] = ____temp_6
1402
1414
  end
1403
1415
  },
1404
1416
  true
@@ -1408,7 +1420,7 @@ __TS__SetDescriptor(
1408
1420
  "color",
1409
1421
  {set = function(self, color)
1410
1422
  setUnitColor(self.handle, color.handle)
1411
- if self[105] then
1423
+ if self[106] then
1412
1424
  showUnitTeamGlow(self.handle, false)
1413
1425
  end
1414
1426
  end},
@@ -1432,14 +1444,14 @@ __TS__SetDescriptor(
1432
1444
  "maxHealth",
1433
1445
  {
1434
1446
  get = function(self)
1435
- return BlzGetUnitMaxHP(self.handle) - (self[103] or 0) - (self[104] or 0)
1447
+ return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1436
1448
  end,
1437
1449
  set = function(self, maxHealth)
1438
- if maxHealth < 1 and self[102] ~= nil then
1439
- self[103] = (self[103] or 0) + (1 - maxHealth)
1450
+ if maxHealth < 1 and self[103] ~= nil then
1451
+ self[104] = (self[104] or 0) + (1 - maxHealth)
1440
1452
  maxHealth = 1
1441
1453
  end
1442
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[104] or 0))
1454
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1443
1455
  end
1444
1456
  },
1445
1457
  true
@@ -1481,10 +1493,10 @@ __TS__SetDescriptor(
1481
1493
  "health",
1482
1494
  {
1483
1495
  get = function(self)
1484
- return GetWidgetLife(self.handle) - (self[104] or 0)
1496
+ return GetWidgetLife(self.handle) - (self[105] or 0)
1485
1497
  end,
1486
1498
  set = function(self, health)
1487
- SetWidgetLife(self.handle, health + (self[104] or 0))
1499
+ SetWidgetLife(self.handle, health + (self[105] or 0))
1488
1500
  end
1489
1501
  },
1490
1502
  true
@@ -1695,17 +1707,17 @@ __TS__SetDescriptor(
1695
1707
  set = function(self, isPaused)
1696
1708
  local handle = self.handle
1697
1709
  if isPaused and not IsUnitPaused(handle) then
1698
- self[100] = true
1699
- for _ = self[101] or 0, -1 do
1710
+ self[101] = true
1711
+ for _ = self[102] or 0, -1 do
1700
1712
  BlzPauseUnitEx(handle, true)
1701
1713
  end
1702
1714
  PauseUnit(handle, true)
1703
1715
  elseif not isPaused and IsUnitPaused(handle) then
1704
1716
  PauseUnit(handle, false)
1705
- for _ = self[101] or 0, -1 do
1717
+ for _ = self[102] or 0, -1 do
1706
1718
  BlzPauseUnitEx(handle, false)
1707
1719
  end
1708
- self[100] = nil
1720
+ self[101] = nil
1709
1721
  end
1710
1722
  end
1711
1723
  },
@@ -2124,25 +2136,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2124
2136
  InitializingEvent,
2125
2137
  function(event)
2126
2138
  local function listener(unit, id)
2127
- local ____GetSpellTargetUnit_result_8
2139
+ local ____GetSpellTargetUnit_result_9
2128
2140
  if GetSpellTargetUnit() then
2129
- ____GetSpellTargetUnit_result_8 = ____exports.Unit:of(GetSpellTargetUnit())
2141
+ ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2130
2142
  else
2131
- local ____GetSpellTargetItem_result_7
2143
+ local ____GetSpellTargetItem_result_8
2132
2144
  if GetSpellTargetItem() then
2133
- ____GetSpellTargetItem_result_7 = Item:of(GetSpellTargetItem())
2145
+ ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2134
2146
  else
2135
- local ____GetSpellTargetDestructable_result_6
2147
+ local ____GetSpellTargetDestructable_result_7
2136
2148
  if GetSpellTargetDestructable() then
2137
- ____GetSpellTargetDestructable_result_6 = Destructable:of(GetSpellTargetDestructable())
2149
+ ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2138
2150
  else
2139
- ____GetSpellTargetDestructable_result_6 = nil
2151
+ ____GetSpellTargetDestructable_result_7 = nil
2140
2152
  end
2141
- ____GetSpellTargetItem_result_7 = ____GetSpellTargetDestructable_result_6
2153
+ ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2142
2154
  end
2143
- ____GetSpellTargetUnit_result_8 = ____GetSpellTargetItem_result_7
2155
+ ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2144
2156
  end
2145
- local target = ____GetSpellTargetUnit_result_8
2157
+ local target = ____GetSpellTargetUnit_result_9
2146
2158
  if target then
2147
2159
  invoke(event, unit, id, target)
2148
2160
  end
@@ -2452,6 +2464,7 @@ Unit.onDamage = __TS__New(
2452
2464
  damageType = BlzGetEventDamageType(),
2453
2465
  weaponType = BlzGetEventWeaponType(),
2454
2466
  isAttack = BlzGetEventIsAttack(),
2467
+ originalAmount = GetEventDamage(),
2455
2468
  preventDeath = damageEventPreventDeath
2456
2469
  }
2457
2470
  local evData = setmetatable(
@@ -2468,7 +2481,7 @@ Unit.onDamage = __TS__New(
2468
2481
  invoke(event, source, target, evData)
2469
2482
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2470
2483
  local bonusHealth = math.ceil(evData.amount)
2471
- target[104] = (target[104] or 0) + bonusHealth
2484
+ target[105] = (target[105] or 0) + bonusHealth
2472
2485
  BlzSetUnitMaxHP(
2473
2486
  target.handle,
2474
2487
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2482,7 +2495,7 @@ Unit.onDamage = __TS__New(
2482
2495
  evData[0],
2483
2496
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2484
2497
  )
2485
- target[104] = (target[104] or 0) - bonusHealth
2498
+ target[105] = (target[105] or 0) - bonusHealth
2486
2499
  SetWidgetLife(
2487
2500
  target.handle,
2488
2501
  GetWidgetLife(target.handle) - bonusHealth
@@ -2502,7 +2515,7 @@ Unit.onDamage = __TS__New(
2502
2515
  DestroyTrigger(trigger)
2503
2516
  end
2504
2517
  )
2505
- Unit.onItemDrop = __TS__New(
2518
+ Unit.itemDroppedEvent = __TS__New(
2506
2519
  ____exports.UnitTriggerEvent,
2507
2520
  EVENT_PLAYER_UNIT_DROP_ITEM,
2508
2521
  function()
@@ -2513,7 +2526,7 @@ Unit.onItemDrop = __TS__New(
2513
2526
  return IgnoreEvent
2514
2527
  end
2515
2528
  )
2516
- Unit.onItemPickup = __TS__New(
2529
+ Unit.itemPickedUpEvent = __TS__New(
2517
2530
  ____exports.UnitTriggerEvent,
2518
2531
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2519
2532
  function()
@@ -2524,10 +2537,43 @@ Unit.onItemPickup = __TS__New(
2524
2537
  return IgnoreEvent
2525
2538
  end
2526
2539
  )
2527
- Unit.onItemUse = __TS__New(
2540
+ Unit.itemUsedEvent = __TS__New(
2528
2541
  ____exports.UnitTriggerEvent,
2529
2542
  EVENT_PLAYER_UNIT_USE_ITEM,
2530
- function() return ____exports.Unit:of(GetTriggerUnit()), Item:of(GetManipulatedItem()) end
2543
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2544
+ )
2545
+ Unit.itemStackedEvent = __TS__New(
2546
+ ____exports.UnitTriggerEvent,
2547
+ EVENT_PLAYER_UNIT_STACK_ITEM,
2548
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2549
+ )
2550
+ __TS__ObjectDefineProperty(
2551
+ Unit,
2552
+ "itemMovedEvent",
2553
+ {get = function(self)
2554
+ local event = __TS__New(Event)
2555
+ do
2556
+ local order = orderId("moveslot1")
2557
+ while order <= orderId("moveslot5") do
2558
+ self.onTargetOrder[order]:addListener(function(unit, item)
2559
+ local slotFrom = unit.items:findSlot(item)
2560
+ if slotFrom ~= nil then
2561
+ local slotTo = order - orderId("moveslot1")
2562
+ invoke(
2563
+ event,
2564
+ unit,
2565
+ item,
2566
+ slotFrom,
2567
+ slotTo
2568
+ )
2569
+ end
2570
+ end)
2571
+ order = order + 1
2572
+ end
2573
+ end
2574
+ rawset(self, "itemMovedEvent", event)
2575
+ return event
2576
+ end}
2531
2577
  )
2532
2578
  __TS__ObjectDefineProperty(
2533
2579
  Unit,
@@ -1,7 +1,7 @@
1
1
  /** @noSelfInFile */
2
2
  import { Unit } from "../core/types/unit";
3
3
  import { Async } from "../core/types/async";
4
- import { TriggerEvent } from "../event";
4
+ import { Event, TriggerEvent } from "../event";
5
5
  import { GraphicsMode } from "./index";
6
6
  export declare class LocalClient {
7
7
  private constructor();
@@ -11,6 +11,11 @@ export declare class LocalClient {
11
11
  static get isHD(): boolean;
12
12
  static get graphicsMode(): GraphicsMode;
13
13
  static get isActive(): boolean;
14
- static get mouseFocusUnit(): Async<Unit>;
14
+ static get mouseFocusUnit(): Async<Unit> | undefined;
15
+ static get mainSelectedUnit(): Async<Unit> | undefined;
16
+ static get mainSelectedUnitChangeEvent(): Event<[
17
+ previousMainSelectedUnit: Unit | undefined,
18
+ newMainSelectedUnit: Unit | undefined
19
+ ]>;
15
20
  static readonly onDisconnect: TriggerEvent<[]>;
16
21
  }