warscript 0.0.1-dev.b34a02b → 0.0.1-dev.b37c533

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 (55) 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 +86 -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/ignore-events-items.d.ts +2 -0
  29. package/engine/internal/unit/ignore-events-items.lua +5 -0
  30. package/engine/internal/unit/item.d.ts +1 -0
  31. package/engine/internal/unit/item.lua +56 -2
  32. package/engine/internal/unit/main-selected.d.ts +13 -0
  33. package/engine/internal/unit/main-selected.lua +51 -0
  34. package/engine/internal/unit.d.ts +12 -2
  35. package/engine/internal/unit.lua +80 -53
  36. package/engine/internal/utility.lua +12 -0
  37. package/engine/local-client.lua +2 -1
  38. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  39. package/engine/object-data/entry/ability-type.lua +8 -12
  40. package/engine/object-data/entry/item-type.d.ts +2 -0
  41. package/engine/object-data/entry/item-type.lua +13 -0
  42. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  43. package/engine/object-field/ability.d.ts +9 -3
  44. package/engine/object-field/ability.lua +3 -0
  45. package/engine/object-field.d.ts +2 -2
  46. package/engine/object-field.lua +4 -0
  47. package/engine/standard/fields/ability.d.ts +2 -0
  48. package/engine/standard/fields/ability.lua +2 -0
  49. package/engine/unit.d.ts +1 -0
  50. package/engine/unit.lua +1 -0
  51. package/package.json +1 -1
  52. package/utility/arrays.d.ts +8 -1
  53. package/utility/arrays.lua +34 -3
  54. package/utility/lazy.d.ts +2 -0
  55. package/utility/lazy.lua +14 -0
@@ -3,7 +3,7 @@ import { Ability } from "../ability";
3
3
  import { Destructable } from "../../../core/types/destructable";
4
4
  import { Item } from "../item";
5
5
  import { Widget } from "../../../core/types/widget";
6
- import { DispatchingEvent } from "../../../event";
6
+ import { DispatchingEvent, Event } from "../../../event";
7
7
  declare module "../unit" {
8
8
  namespace Unit {
9
9
  const abilityCastingStartEvent: DispatchingEvent<[Unit, Ability]>;
@@ -141,3 +141,12 @@ declare module "../unit" {
141
141
  const abilityStopEvent: DispatchingEvent<[Unit, Ability]>;
142
142
  }
143
143
  }
144
+ declare module "../unit" {
145
+ namespace Unit {
146
+ const abilityCommandEvent: {
147
+ readonly [abilityTypeId: number]: {
148
+ readonly [orderTypeStringId: string]: Event<[Unit, Ability, string]>;
149
+ };
150
+ };
151
+ }
152
+ }
@@ -15,8 +15,15 @@ local UnitTriggerEvent = ____unit.UnitTriggerEvent
15
15
  local ____event = require("event")
16
16
  local createDispatchingEvent = ____event.createDispatchingEvent
17
17
  local DependentInitializingEvent = ____event.DependentInitializingEvent
18
+ local Event = ____event.Event
19
+ local InitializingEvent = ____event.InitializingEvent
18
20
  local ____preconditions = require("utility.preconditions")
19
21
  local checkNotNull = ____preconditions.checkNotNull
22
+ local ____lazy = require("utility.lazy")
23
+ local lazyRecord = ____lazy.lazyRecord
24
+ local eventInvoke = Event.invoke
25
+ local condition = Condition
26
+ local createTrigger = CreateTrigger
20
27
  local getItemAbility = BlzGetItemAbility
21
28
  local getSpellAbility = GetSpellAbility
22
29
  local getSpellAbilityId = GetSpellAbilityId
@@ -26,11 +33,10 @@ local getSpellTargetUnit = GetSpellTargetUnit
26
33
  local getSpellTargetX = GetSpellTargetX
27
34
  local getSpellTargetY = GetSpellTargetY
28
35
  local getTriggerUnit = GetTriggerUnit
29
- local getUnitAbility = BlzGetUnitAbility
30
- local unitAddAbility = UnitAddAbility
36
+ local triggerAddCondition = TriggerAddCondition
37
+ local triggerRegisterCommandEvent = TriggerRegisterCommandEvent
31
38
  local unitInventorySize = UnitInventorySize
32
39
  local unitItemInSlot = UnitItemInSlot
33
- local unitRemoveAbility = UnitRemoveAbility
34
40
  local function retrieveAbility(unit, ability, abilityId)
35
41
  if ability == nil then
36
42
  return __TS__New(
@@ -39,17 +45,6 @@ local function retrieveAbility(unit, ability, abilityId)
39
45
  Unit:of(unit)
40
46
  )
41
47
  end
42
- if not unitAddAbility(unit, abilityId) then
43
- if getUnitAbility(unit, abilityId) == ability then
44
- return UnitAbility:of(
45
- ability,
46
- abilityId,
47
- Unit:of(unit)
48
- )
49
- end
50
- else
51
- unitRemoveAbility(unit, abilityId)
52
- end
53
48
  for i = 0, unitInventorySize(unit) - 1 do
54
49
  local item = unitItemInSlot(unit, i)
55
50
  if getItemAbility(item, abilityId) == ability then
@@ -366,4 +361,31 @@ rawset(
366
361
  extractAbilityTypeId
367
362
  )
368
363
  )
364
+ rawset(
365
+ Unit,
366
+ "abilityCommandEvent",
367
+ lazyRecord(function(abilityTypeId)
368
+ return lazyRecord(function(orderTypeStringId)
369
+ return __TS__New(
370
+ InitializingEvent,
371
+ function(event)
372
+ local trigger = createTrigger()
373
+ triggerRegisterCommandEvent(trigger, abilityTypeId, orderTypeStringId)
374
+ triggerAddCondition(
375
+ trigger,
376
+ condition(function()
377
+ local unit = Unit:of(getTriggerUnit())
378
+ if unit ~= nil then
379
+ local ability = unit:getAbilityById(abilityTypeId)
380
+ if ability ~= nil then
381
+ eventInvoke(event, unit, ability, orderTypeStringId)
382
+ end
383
+ end
384
+ end)
385
+ )
386
+ end
387
+ )
388
+ end)
389
+ end)
390
+ )
369
391
  return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,5 @@
1
+ local ____exports = {}
2
+ ---
3
+ -- @internal For use by internal systems only.
4
+ ____exports.ignoreEventsItems = {}
5
+ return ____exports
@@ -11,6 +11,7 @@ export interface UnitItems extends ReadonlyArray<Item | undefined> {
11
11
  }
12
12
  export declare class UnitItems {
13
13
  constructor(handle: junit);
14
+ findSlot(item: Item): 0 | 1 | 2 | 3 | 4 | 5 | undefined;
14
15
  protected __newindex(slot: number, item: Item | undefined): void;
15
16
  protected __index(key: string | number): unknown;
16
17
  protected __len(): number;
@@ -7,15 +7,39 @@ local ____item = require("engine.internal.item")
7
7
  local Item = ____item.Item
8
8
  local ____unit = require("engine.internal.unit")
9
9
  local Unit = ____unit.Unit
10
+ local ____utility = require("engine.internal.utility")
11
+ local findUnitItemSlot = ____utility.findUnitItemSlot
12
+ local ____blank = require("engine.object-data.entry.item-type.blank")
13
+ local BlankItemType = ____blank.BlankItemType
14
+ local ____arrays = require("utility.arrays")
15
+ local array = ____arrays.array
16
+ local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
17
+ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
10
18
  local rawset = _G.rawset
11
19
  local ____type = _G.type
12
20
  local isItemPowerup = IsItemPowerup
13
21
  local setItemBooleanField = BlzSetItemBooleanField
22
+ local setItemVisible = SetItemVisible
14
23
  local unitAddItem = UnitAddItem
15
- local unitDropItemSlot = UnitDropItemSlot
16
24
  local unitInventorySize = UnitInventorySize
17
25
  local unitItemInSlot = UnitItemInSlot
26
+ local unitRemoveItem = UnitRemoveItem
18
27
  local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
28
+ local FILLER_ITEM_TYPE_ID = compiletime(function()
29
+ local itemType = BlankItemType:create()
30
+ itemType.name = "[Warscript/Dummy] Slot Filler"
31
+ return itemType.id
32
+ end)
33
+ local fillerItems = array(
34
+ 6,
35
+ function()
36
+ local item = CreateItem(FILLER_ITEM_TYPE_ID, 0, 0)
37
+ setItemVisible(item, false)
38
+ ignoreEventsItems[item] = true
39
+ return item
40
+ end
41
+ )
42
+ local unitsWithFillerItems = {}
19
43
  local handleByUnitItems = setmetatable({}, {__mode = "k"})
20
44
  local function unitItemsNext(handle, index)
21
45
  local slot = index & 7
@@ -30,6 +54,9 @@ UnitItems.name = "UnitItems"
30
54
  function UnitItems.prototype.____constructor(self, handle)
31
55
  handleByUnitItems[self] = handle
32
56
  end
57
+ function UnitItems.prototype.findSlot(self, item)
58
+ return findUnitItemSlot(handleByUnitItems[self], item.handle)
59
+ end
33
60
  function UnitItems.prototype.__newindex(self, slot, item)
34
61
  local handle = handleByUnitItems[self]
35
62
  if slot < 1 or slot > unitInventorySize(handle) then
@@ -42,8 +69,21 @@ function UnitItems.prototype.__newindex(self, slot, item)
42
69
  if isPowerup then
43
70
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
44
71
  end
72
+ for previousSlot = 0, slot - 2 do
73
+ if unitItemInSlot(handle, previousSlot) == nil then
74
+ unitAddItem(handle, fillerItems[previousSlot + 1])
75
+ unitsWithFillerItems[handle] = true
76
+ end
77
+ end
45
78
  unitAddItem(handle, itemHandle)
46
- unitDropItemSlot(handle, itemHandle, slot - 1)
79
+ if unitsWithFillerItems[handle] ~= nil then
80
+ for previousSlot = 0, slot - 2 do
81
+ local fillerItem = fillerItems[previousSlot + 1]
82
+ unitRemoveItem(handle, fillerItem)
83
+ setItemVisible(fillerItem, false)
84
+ end
85
+ unitsWithFillerItems[handle] = nil
86
+ end
47
87
  if isPowerup then
48
88
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
49
89
  end
@@ -62,6 +102,20 @@ function UnitItems.prototype.__ipairs(self)
62
102
  local handle = handleByUnitItems[self]
63
103
  return unitItemsNext, handle, unitInventorySize(handle) << 3
64
104
  end
105
+ Unit.itemPickedUpEvent:addListener(
106
+ 4,
107
+ function(unit)
108
+ local handle = unit.handle
109
+ if unitsWithFillerItems[handle] ~= nil then
110
+ for previousSlot = 1, 6 do
111
+ local fillerItem = fillerItems[previousSlot]
112
+ unitRemoveItem(handle, fillerItem)
113
+ setItemVisible(fillerItem, false)
114
+ end
115
+ unitsWithFillerItems[handle] = nil
116
+ end
117
+ end
118
+ )
65
119
  __TS__ObjectDefineProperty(
66
120
  Unit.prototype,
67
121
  "items",
@@ -0,0 +1,13 @@
1
+ /** @noSelfInFile */
2
+ import { Player } from "../../../core/types/player";
3
+ import { Event } from "../../../event";
4
+ declare module "../unit" {
5
+ namespace Unit {
6
+ const mainSelectedUnitChangeEvent: Event<[Player]>;
7
+ }
8
+ }
9
+ declare module "../unit" {
10
+ namespace Unit {
11
+ const getMainSelectedOf: (player: Player) => Unit | undefined;
12
+ }
13
+ }
@@ -0,0 +1,51 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__New = ____lualib.__TS__New
3
+ local ____exports = {}
4
+ local ____player = require("core.types.player")
5
+ local Player = ____player.Player
6
+ local ____math = require("math")
7
+ local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
8
+ local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
9
+ local ____local_2Dclient = require("engine.local-client")
10
+ local LocalClient = ____local_2Dclient.LocalClient
11
+ local ____unit = require("engine.internal.unit")
12
+ local Unit = ____unit.Unit
13
+ local ____event = require("event")
14
+ local Event = ____event.Event
15
+ local mainSelectedUnitChangeEvent = __TS__New(Event)
16
+ rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
17
+ local mainSelectedUnitByPlayer = {}
18
+ local syncSlider = BlzCreateFrameByType(
19
+ "SLIDER",
20
+ "UnitSyncId",
21
+ BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
22
+ "",
23
+ 0
24
+ )
25
+ BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
26
+ LocalClient.mainSelectedUnitChangeEvent:addListener(function()
27
+ local ____opt_0 = LocalClient.mainSelectedUnit
28
+ local syncId = ____opt_0 and ____opt_0.syncId
29
+ BlzFrameSetValue(syncSlider, syncId or 0)
30
+ end)
31
+ local trg = CreateTrigger()
32
+ BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
33
+ TriggerAddAction(
34
+ trg,
35
+ function()
36
+ local player = Player:of(GetTriggerPlayer())
37
+ local mainSelectedUnit = Unit:getBySyncId(BlzGetTriggerFrameValue())
38
+ if mainSelectedUnit ~= mainSelectedUnitByPlayer[player] then
39
+ mainSelectedUnitByPlayer[player] = mainSelectedUnit
40
+ Event.invoke(mainSelectedUnitChangeEvent, player)
41
+ end
42
+ end
43
+ )
44
+ rawset(
45
+ Unit,
46
+ "getMainSelectedOf",
47
+ function(player)
48
+ return mainSelectedUnitByPlayer[player]
49
+ end
50
+ )
51
+ return ____exports
@@ -102,8 +102,11 @@ declare const enum UnitPropertyKey {
102
102
  PREVENT_DEATH_HEALTH_BONUS = 105,
103
103
  IS_TEAM_GLOW_HIDDEN = 106
104
104
  }
105
+ export type UnitSyncId = number & {
106
+ readonly __unitSyncId: unique symbol;
107
+ };
105
108
  export declare class Unit extends Handle<junit> {
106
- private [UnitPropertyKey.SYNC_ID];
109
+ readonly syncId: UnitSyncId;
107
110
  private [UnitPropertyKey.IS_PAUSED]?;
108
111
  private [UnitPropertyKey.STUN_COUNTER]?;
109
112
  private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
@@ -329,6 +332,13 @@ export declare class Unit extends Handle<junit> {
329
332
  static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
330
333
  static itemUsedEvent: UnitTriggerEvent<[Item]>;
331
334
  static itemStackedEvent: UnitTriggerEvent<[Item]>;
335
+ static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
336
+ static get itemMoveOrderEvent(): Event<[
337
+ unit: Unit,
338
+ item: Item,
339
+ slotFrom: 0 | 1 | 2 | 3 | 4 | 5,
340
+ slotTo: 0 | 1 | 2 | 3 | 4 | 5
341
+ ]>;
332
342
  static get onCreate(): EventDispatcher<[Unit], [Unit]>;
333
343
  static get destroyEvent(): EventDispatcher<[Unit], [Unit]>;
334
344
  getField(field: junitintegerfield | junitrealfield): number;
@@ -339,6 +349,6 @@ export declare class Unit extends Handle<junit> {
339
349
  setField(field: junitbooleanfield, value: boolean): boolean;
340
350
  setField(field: junitstringfield, value: string): boolean;
341
351
  toString(): string;
342
- static getMainSelectedOf(player: Player): Unit | undefined;
352
+ static getBySyncId(syncId: UnitSyncId): Unit | undefined;
343
353
  }
344
354
  export {};
@@ -15,7 +15,6 @@ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
15
15
  local Set = ____lualib.Set
16
16
  local __TS__Spread = ____lualib.__TS__Spread
17
17
  local ____exports = {}
18
- local mainSelectedUnitByPlayer
19
18
  local ____handle = require("core.types.handle")
20
19
  local Handle = ____handle.Handle
21
20
  local ____player = require("core.types.player")
@@ -51,11 +50,9 @@ local MANA_REGENERATION_RATE_BONUS_PER_INTELLIGENCE_POINT = ____constants.MANA_R
51
50
  local ____arrays = require("utility.arrays")
52
51
  local forEach = ____arrays.forEach
53
52
  local ____math = require("math")
54
- local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
55
53
  local min = ____math.min
56
- local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
57
- local ____local_2Dclient = require("engine.local-client")
58
- local LocalClient = ____local_2Dclient.LocalClient
54
+ local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
55
+ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
59
56
  local match = string.match
60
57
  local ____tostring = _G.tostring
61
58
  local setUnitAnimation = SetUnitAnimation
@@ -567,17 +564,6 @@ local function retrieveAbility(unit, ability, abilityId)
567
564
  ____exports.Unit:of(unit)
568
565
  )
569
566
  end
570
- if not unitAddAbility(unit, abilityId) then
571
- if getUnitAbility(unit, abilityId) == ability then
572
- return UnitAbility:of(
573
- ability,
574
- abilityId,
575
- ____exports.Unit:of(unit)
576
- )
577
- end
578
- else
579
- unitRemoveAbility(unit, abilityId)
580
- end
581
567
  for i = 0, unitInventorySize(unit) - 1 do
582
568
  local item = unitItemInSlot(unit, i)
583
569
  if getItemAbility(item, abilityId) == ability then
@@ -661,7 +647,7 @@ function Unit.prototype.____constructor(self, handle)
661
647
  Handle.prototype.____constructor(self, handle)
662
648
  local ____nextSyncId_0 = nextSyncId
663
649
  nextSyncId = ____nextSyncId_0 + 1
664
- self[100] = ____nextSyncId_0
650
+ self.syncId = ____nextSyncId_0
665
651
  self._owner = Player:of(getOwningPlayer(handle))
666
652
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
667
653
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -674,7 +660,7 @@ function Unit.prototype.____constructor(self, handle)
674
660
  fourCC("Amrf")
675
661
  ))
676
662
  end
677
- unitBySyncId[self[100]] = self
663
+ unitBySyncId[self.syncId] = self
678
664
  local ____ = self.abilities
679
665
  end
680
666
  function Unit.prototype.getEvent(self, event, collector)
@@ -945,8 +931,15 @@ function Unit.prototype.interruptAttack(self)
945
931
  unitInterruptAttack(self.handle)
946
932
  end
947
933
  function Unit.prototype.interruptCast(self, abilityId)
948
- unitDisableAbility(self.handle, abilityId, true, false)
949
- 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
+ )
950
943
  end
951
944
  function Unit.prototype.getDistanceTo(self, target)
952
945
  local handle = self.handle
@@ -1145,8 +1138,8 @@ end
1145
1138
  function Unit.prototype.__tostring(self)
1146
1139
  return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
1147
1140
  end
1148
- function Unit.getMainSelectedOf(self, player)
1149
- return mainSelectedUnitByPlayer[player]
1141
+ function Unit.getBySyncId(self, syncId)
1142
+ return unitBySyncId[syncId]
1150
1143
  end
1151
1144
  __TS__SetDescriptor(
1152
1145
  Unit.prototype,
@@ -2331,10 +2324,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2331
2324
  ____exports.UnitTriggerEvent,
2332
2325
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2333
2326
  function()
2334
- local unit = ____exports.Unit:of(getOrderedUnit())
2335
- local issuedOrderId = getIssuedOrderId()
2336
- if unit ~= nil and unit.state == 1 then
2337
- 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
2338
2333
  end
2339
2334
  return IgnoreEvent
2340
2335
  end
@@ -2525,8 +2520,9 @@ Unit.itemDroppedEvent = __TS__New(
2525
2520
  EVENT_PLAYER_UNIT_DROP_ITEM,
2526
2521
  function()
2527
2522
  local unit = getTriggerUnit()
2528
- if getUnitTypeId(unit) ~= dummyUnitId then
2529
- 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)
2530
2526
  end
2531
2527
  return IgnoreEvent
2532
2528
  end
@@ -2536,8 +2532,9 @@ Unit.itemPickedUpEvent = __TS__New(
2536
2532
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2537
2533
  function()
2538
2534
  local unit = getTriggerUnit()
2539
- if getUnitTypeId(unit) ~= dummyUnitId then
2540
- 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)
2541
2538
  end
2542
2539
  return IgnoreEvent
2543
2540
  end
@@ -2545,13 +2542,65 @@ Unit.itemPickedUpEvent = __TS__New(
2545
2542
  Unit.itemUsedEvent = __TS__New(
2546
2543
  ____exports.UnitTriggerEvent,
2547
2544
  EVENT_PLAYER_UNIT_USE_ITEM,
2548
- 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
2549
2553
  )
2550
2554
  Unit.itemStackedEvent = __TS__New(
2551
2555
  ____exports.UnitTriggerEvent,
2552
2556
  EVENT_PLAYER_UNIT_STACK_ITEM,
2553
2557
  function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2554
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}
2603
+ )
2555
2604
  __TS__ObjectDefineProperty(
2556
2605
  Unit,
2557
2606
  "onCreate",
@@ -2610,26 +2659,4 @@ __TS__ObjectDefineProperty(
2610
2659
  end)
2611
2660
  end
2612
2661
  end)(Unit)
2613
- mainSelectedUnitByPlayer = {}
2614
- local syncSlider = BlzCreateFrameByType(
2615
- "SLIDER",
2616
- "UnitSyncId",
2617
- BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
2618
- "",
2619
- 0
2620
- )
2621
- BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
2622
- LocalClient.mainSelectedUnitChangeEvent:addListener(function()
2623
- local ____opt_10 = LocalClient.mainSelectedUnit
2624
- local syncId = ____opt_10 and ____opt_10[100]
2625
- BlzFrameSetValue(syncSlider, syncId or 0)
2626
- end)
2627
- local trg = CreateTrigger()
2628
- BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
2629
- TriggerAddAction(
2630
- trg,
2631
- function()
2632
- mainSelectedUnitByPlayer[Player:of(GetTriggerPlayer())] = unitBySyncId[BlzGetTriggerFrameValue()]
2633
- end
2634
- )
2635
2662
  return ____exports
@@ -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
@@ -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;