warscript 0.0.1-dev.29b3feb → 0.0.1-dev.3094932

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/util.d.ts +1 -1
  4. package/core/util.lua +6 -0
  5. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  6. package/engine/behaviour/ability/always-enabled.lua +31 -0
  7. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  8. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  9. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  10. package/engine/behaviour/ability/instant-impact.lua +4 -19
  11. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  12. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  13. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  14. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  15. package/engine/behaviour/ability.d.ts +14 -3
  16. package/engine/behaviour/ability.lua +79 -33
  17. package/engine/buff.d.ts +6 -1
  18. package/engine/buff.lua +29 -18
  19. package/engine/internal/ability.d.ts +13 -2
  20. package/engine/internal/ability.lua +77 -4
  21. package/engine/internal/item/ability.lua +106 -0
  22. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  23. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  24. package/engine/internal/unit/ability.d.ts +10 -1
  25. package/engine/internal/unit/ability.lua +36 -14
  26. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  27. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  28. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  29. package/engine/internal/unit/add-item-to-slot.lua +50 -0
  30. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  31. package/engine/internal/unit/ignore-events-items.lua +5 -0
  32. package/engine/internal/unit/item.lua +6 -12
  33. package/engine/internal/unit/main-selected.d.ts +6 -0
  34. package/engine/internal/unit/main-selected.lua +12 -1
  35. package/engine/internal/unit.d.ts +3 -1
  36. package/engine/internal/unit.lua +65 -26
  37. package/engine/internal/utility.lua +12 -0
  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,23 @@
1
+ local ____exports = {}
2
+ local ____unit = require("engine.internal.unit")
3
+ local Unit = ____unit.Unit
4
+ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
5
+ local fillerItems = ____add_2Ditem_2Dto_2Dslot.fillerItems
6
+ local unitsWithFillerItems = ____add_2Ditem_2Dto_2Dslot.unitsWithFillerItems
7
+ local setItemVisible = SetItemVisible
8
+ local unitRemoveItem = UnitRemoveItem
9
+ Unit.itemPickedUpEvent:addListener(
10
+ 4,
11
+ function(unit)
12
+ local handle = unit.handle
13
+ if unitsWithFillerItems[handle] ~= nil then
14
+ for previousSlot = 1, 6 do
15
+ local fillerItem = fillerItems[previousSlot]
16
+ unitRemoveItem(handle, fillerItem)
17
+ setItemVisible(fillerItem, false)
18
+ end
19
+ unitsWithFillerItems[handle] = nil
20
+ end
21
+ end
22
+ )
23
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,50 @@
1
+ local ____exports = {}
2
+ local ____blank = require("engine.object-data.entry.item-type.blank")
3
+ local BlankItemType = ____blank.BlankItemType
4
+ local ____arrays = require("utility.arrays")
5
+ local array = ____arrays.array
6
+ local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
7
+ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
8
+ local setItemVisible = SetItemVisible
9
+ local unitAddItem = UnitAddItem
10
+ local unitItemInSlot = UnitItemInSlot
11
+ local unitRemoveItem = UnitRemoveItem
12
+ local FILLER_ITEM_TYPE_ID = compiletime(function()
13
+ local itemType = BlankItemType:create()
14
+ itemType.name = "[Warscript/Dummy] Slot Filler"
15
+ return itemType.id
16
+ end)
17
+ ---
18
+ -- @internal For use by internal systems only.
19
+ ____exports.fillerItems = array(
20
+ 6,
21
+ function()
22
+ local item = CreateItem(FILLER_ITEM_TYPE_ID, 0, 0)
23
+ setItemVisible(item, false)
24
+ ignoreEventsItems[item] = true
25
+ return item
26
+ end
27
+ )
28
+ ---
29
+ -- @internal For use by internal systems only.
30
+ ____exports.unitsWithFillerItems = {}
31
+ ---
32
+ -- @internal For use by internal systems only.
33
+ ____exports.unitAddItemToSlot = function(unit, item, slot)
34
+ for previousSlot = 0, slot - 1 do
35
+ if unitItemInSlot(unit, previousSlot) == nil then
36
+ unitAddItem(unit, ____exports.fillerItems[previousSlot + 1])
37
+ ____exports.unitsWithFillerItems[unit] = true
38
+ end
39
+ end
40
+ unitAddItem(unit, item)
41
+ if ____exports.unitsWithFillerItems[unit] ~= nil then
42
+ for previousSlot = 0, slot - 1 do
43
+ local fillerItem = ____exports.fillerItems[previousSlot + 1]
44
+ unitRemoveItem(unit, fillerItem)
45
+ setItemVisible(fillerItem, false)
46
+ end
47
+ ____exports.unitsWithFillerItems[unit] = nil
48
+ end
49
+ end
50
+ 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
@@ -7,12 +7,14 @@ 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 ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
13
+ local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
10
14
  local rawset = _G.rawset
11
15
  local ____type = _G.type
12
16
  local isItemPowerup = IsItemPowerup
13
17
  local setItemBooleanField = BlzSetItemBooleanField
14
- local unitAddItem = UnitAddItem
15
- local unitDropItemSlot = UnitDropItemSlot
16
18
  local unitInventorySize = UnitInventorySize
17
19
  local unitItemInSlot = UnitItemInSlot
18
20
  local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
@@ -31,14 +33,7 @@ function UnitItems.prototype.____constructor(self, handle)
31
33
  handleByUnitItems[self] = handle
32
34
  end
33
35
  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
36
+ return findUnitItemSlot(handleByUnitItems[self], item.handle)
42
37
  end
43
38
  function UnitItems.prototype.__newindex(self, slot, item)
44
39
  local handle = handleByUnitItems[self]
@@ -52,8 +47,7 @@ function UnitItems.prototype.__newindex(self, slot, item)
52
47
  if isPowerup then
53
48
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
54
49
  end
55
- unitAddItem(handle, itemHandle)
56
- unitDropItemSlot(handle, itemHandle, slot - 1)
50
+ unitAddItemToSlot(handle, itemHandle, slot - 1)
57
51
  if isPowerup then
58
52
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
59
53
  end
@@ -1,5 +1,11 @@
1
1
  /** @noSelfInFile */
2
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
+ }
3
9
  declare module "../unit" {
4
10
  namespace Unit {
5
11
  const getMainSelectedOf: (player: Player) => Unit | undefined;
@@ -1,3 +1,5 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__New = ____lualib.__TS__New
1
3
  local ____exports = {}
2
4
  local ____player = require("core.types.player")
3
5
  local Player = ____player.Player
@@ -8,6 +10,10 @@ local ____local_2Dclient = require("engine.local-client")
8
10
  local LocalClient = ____local_2Dclient.LocalClient
9
11
  local ____unit = require("engine.internal.unit")
10
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)
11
17
  local mainSelectedUnitByPlayer = {}
12
18
  local syncSlider = BlzCreateFrameByType(
13
19
  "SLIDER",
@@ -27,7 +33,12 @@ BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
27
33
  TriggerAddAction(
28
34
  trg,
29
35
  function()
30
- mainSelectedUnitByPlayer[Player:of(GetTriggerPlayer())] = Unit:getBySyncId(BlzGetTriggerFrameValue())
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
31
42
  end
32
43
  )
33
44
  rawset(
@@ -133,6 +133,7 @@ export declare class Unit extends Handle<junit> {
133
133
  get isAlive(): boolean;
134
134
  get isDead(): boolean;
135
135
  get isIllusion(): boolean;
136
+ get isStunned(): boolean;
136
137
  get combatClassifications(): CombatClassifications;
137
138
  set combatClassifications(combatClassifications: CombatClassifications);
138
139
  hasCombatClassification(combatClassification: CombatClassification): boolean;
@@ -332,7 +333,8 @@ export declare class Unit extends Handle<junit> {
332
333
  static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
333
334
  static itemUsedEvent: UnitTriggerEvent<[Item]>;
334
335
  static itemStackedEvent: UnitTriggerEvent<[Item]>;
335
- static get itemMovedEvent(): Event<[
336
+ static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
337
+ static get itemMoveOrderEvent(): Event<[
336
338
  unit: Unit,
337
339
  item: Item,
338
340
  slotFrom: 0 | 1 | 2 | 3 | 4 | 5,
@@ -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
@@ -940,8 +932,15 @@ function Unit.prototype.interruptAttack(self)
940
932
  unitInterruptAttack(self.handle)
941
933
  end
942
934
  function Unit.prototype.interruptCast(self, abilityId)
943
- unitDisableAbility(self.handle, abilityId, true, false)
944
- 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
+ )
945
944
  end
946
945
  function Unit.prototype.getDistanceTo(self, target)
947
946
  local handle = self.handle
@@ -1206,6 +1205,14 @@ __TS__SetDescriptor(
1206
1205
  end},
1207
1206
  true
1208
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
+ )
1209
1216
  __TS__SetDescriptor(
1210
1217
  Unit.prototype,
1211
1218
  "combatClassifications",
@@ -2326,10 +2333,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2326
2333
  ____exports.UnitTriggerEvent,
2327
2334
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2328
2335
  function()
2329
- local unit = ____exports.Unit:of(getOrderedUnit())
2330
- local issuedOrderId = getIssuedOrderId()
2331
- if unit ~= nil and unit.state == 1 then
2332
- 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
2333
2342
  end
2334
2343
  return IgnoreEvent
2335
2344
  end
@@ -2520,8 +2529,9 @@ Unit.itemDroppedEvent = __TS__New(
2520
2529
  EVENT_PLAYER_UNIT_DROP_ITEM,
2521
2530
  function()
2522
2531
  local unit = getTriggerUnit()
2523
- if getUnitTypeId(unit) ~= dummyUnitId then
2524
- 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)
2525
2535
  end
2526
2536
  return IgnoreEvent
2527
2537
  end
@@ -2531,8 +2541,9 @@ Unit.itemPickedUpEvent = __TS__New(
2531
2541
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2532
2542
  function()
2533
2543
  local unit = getTriggerUnit()
2534
- if getUnitTypeId(unit) ~= dummyUnitId then
2535
- 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)
2536
2547
  end
2537
2548
  return IgnoreEvent
2538
2549
  end
@@ -2540,7 +2551,14 @@ Unit.itemPickedUpEvent = __TS__New(
2540
2551
  Unit.itemUsedEvent = __TS__New(
2541
2552
  ____exports.UnitTriggerEvent,
2542
2553
  EVENT_PLAYER_UNIT_USE_ITEM,
2543
- 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
2544
2562
  )
2545
2563
  Unit.itemStackedEvent = __TS__New(
2546
2564
  ____exports.UnitTriggerEvent,
@@ -2549,11 +2567,32 @@ Unit.itemStackedEvent = __TS__New(
2549
2567
  )
2550
2568
  __TS__ObjectDefineProperty(
2551
2569
  Unit,
2552
- "itemMovedEvent",
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",
2553
2592
  {get = function(self)
2554
2593
  local event = __TS__New(Event)
2555
- for order = orderId("moveslot1"), orderId("moveslot5") do
2556
- local slotTo = order - orderId("moveslot1")
2594
+ for order = orderId("moveslot0"), orderId("moveslot5") do
2595
+ local slotTo = order - orderId("moveslot0")
2557
2596
  self.onTargetOrder[order]:addListener(function(unit, item)
2558
2597
  local slotFrom = unit.items:findSlot(item)
2559
2598
  if slotFrom ~= nil then
@@ -2567,7 +2606,7 @@ __TS__ObjectDefineProperty(
2567
2606
  end
2568
2607
  end)
2569
2608
  end
2570
- rawset(self, "itemMovedEvent", event)
2609
+ rawset(self, "itemMoveOrderEvent", event)
2571
2610
  return event
2572
2611
  end}
2573
2612
  )
@@ -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
@@ -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;
@@ -256,6 +256,19 @@ __TS__SetDescriptor(
256
256
  },
257
257
  true
258
258
  )
259
+ __TS__SetDescriptor(
260
+ ItemType.prototype,
261
+ "cooldownGroupId",
262
+ {
263
+ get = function(self)
264
+ return self:getObjectDataEntryIdField("icid")
265
+ end,
266
+ set = function(self, cooldownGroupId)
267
+ self:setObjectDataEntryIdField("icid", cooldownGroupId)
268
+ end
269
+ },
270
+ true
271
+ )
259
272
  __TS__SetDescriptor(
260
273
  ItemType.prototype,
261
274
  "goldCost",
@@ -1,5 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__New = ____lualib.__TS__New
3
4
  local ____exports = {}
4
5
  local ____preconditions = require("utility.preconditions")
5
6
  local checkNotNull = ____preconditions.checkNotNull
@@ -60,4 +61,10 @@ function ObjectDataEntryIdGenerator.prototype.next(self)
60
61
  self.id = id
61
62
  return id
62
63
  end
64
+ ---
65
+ -- @internal For use by internal systems only.
66
+ ____exports.abilityTypeIdGenerator = __TS__New(
67
+ ____exports.ObjectDataEntryIdGenerator,
68
+ fourCC("A000")
69
+ )
63
70
  return ____exports
@@ -45,9 +45,10 @@ export declare class AbilityStringField extends AbilityField<string, jabilitystr
45
45
  protected setNativeFieldValue(instance: Ability, value: string): boolean;
46
46
  static get valueChangeEvent(): ObjectFieldValueChangeEvent<AbilityStringField>;
47
47
  }
48
- export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectArrayField<AbilityType, Ability, ValueType, NativeFieldType> {
48
+ export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectArrayField<AbilityType, Ability, ValueType, NativeFieldType> {
49
49
  protected get instanceClass(): typeof Ability;
50
50
  protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
51
+ protected hasNativeFieldValue(instance: Ability): boolean;
51
52
  }
52
53
  export declare class AbilityStringArrayField extends AbilityArrayField<string, jabilitystringlevelfield> {
53
54
  protected get defaultValue(): string;
@@ -130,5 +131,10 @@ export declare class AbilityCombatClassificationsLevelField extends AbilityLevel
130
131
  protected getNativeFieldValue(instance: Ability, level: number): CombatClassifications;
131
132
  protected setNativeFieldValue(instance: Ability, level: number, value: CombatClassifications): boolean;
132
133
  }
133
- export type AbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType> | ((ability: Ability) => ValueType);
134
- export declare const resolveCurrentAbilityDependentValue: <ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>) => ValueType;
134
+ export type ReadonlySubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | ReadonlyObjectFieldType<AbilityField<ValueType>> | ReadonlyObjectLevelFieldType<AbilityLevelField<ValueType>>;
135
+ export type SubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType>;
136
+ export type AbilityDependentValue<ValueType extends boolean | number | string> = SubscribableAbilityDependentValue<ValueType> | ((ability: Ability) => ValueType);
137
+ export declare const resolveCurrentAbilityDependentValue: {
138
+ <ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>): ValueType;
139
+ <ValueType extends boolean | number | string>(ability: Ability, value?: AbilityDependentValue<ValueType>): ValueType | undefined;
140
+ };
@@ -197,6 +197,9 @@ __TS__ClassExtends(AbilityArrayField, ObjectArrayField)
197
197
  function AbilityArrayField.prototype.getObjectDataEntryId(self, instance)
198
198
  return instance.typeId
199
199
  end
200
+ function AbilityArrayField.prototype.hasNativeFieldValue(self, instance)
201
+ return instance:hasField(self.nativeField)
202
+ end
200
203
  __TS__SetDescriptor(
201
204
  AbilityArrayField.prototype,
202
205
  "instanceClass",