warscript 0.0.1-dev.7b00732 → 0.0.1-dev.7cd1850
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.
- package/core/types/effect.d.ts +13 -3
- package/core/types/effect.lua +116 -17
- package/core/types/frame.d.ts +3 -0
- package/core/types/frame.lua +59 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +6 -0
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +28 -0
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -19
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -0
- package/engine/behaviour/ability.d.ts +14 -3
- package/engine/behaviour/ability.lua +79 -33
- package/engine/buff.d.ts +6 -1
- package/engine/buff.lua +29 -18
- package/engine/internal/ability.d.ts +15 -2
- package/engine/internal/ability.lua +84 -4
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/unit/ability.d.ts +10 -1
- package/engine/internal/unit/ability.lua +36 -14
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +50 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.d.ts +1 -0
- package/engine/internal/unit/item.lua +8 -4
- package/engine/internal/unit/main-selected.d.ts +6 -0
- package/engine/internal/unit/main-selected.lua +12 -1
- package/engine/internal/unit.d.ts +8 -0
- package/engine/internal/unit.lua +85 -22
- package/engine/internal/utility.lua +12 -0
- package/engine/local-client.lua +2 -1
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/entry/ability-type.lua +8 -12
- package/engine/object-data/entry/item-type.d.ts +2 -0
- package/engine/object-data/entry/item-type.lua +13 -0
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +9 -3
- package/engine/object-field/ability.lua +3 -0
- package/engine/object-field.d.ts +2 -2
- package/engine/object-field.lua +4 -0
- package/engine/standard/fields/ability.d.ts +2 -0
- package/engine/standard/fields/ability.lua +2 -0
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +2 -2
- package/utility/arrays.d.ts +8 -1
- package/utility/arrays.lua +34 -3
- package/utility/lazy.d.ts +2 -0
- 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
|
|
30
|
-
local
|
|
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,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,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
|
|
@@ -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,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
|
|
@@ -30,6 +32,9 @@ UnitItems.name = "UnitItems"
|
|
|
30
32
|
function UnitItems.prototype.____constructor(self, handle)
|
|
31
33
|
handleByUnitItems[self] = handle
|
|
32
34
|
end
|
|
35
|
+
function UnitItems.prototype.findSlot(self, item)
|
|
36
|
+
return findUnitItemSlot(handleByUnitItems[self], item.handle)
|
|
37
|
+
end
|
|
33
38
|
function UnitItems.prototype.__newindex(self, slot, item)
|
|
34
39
|
local handle = handleByUnitItems[self]
|
|
35
40
|
if slot < 1 or slot > unitInventorySize(handle) then
|
|
@@ -42,8 +47,7 @@ function UnitItems.prototype.__newindex(self, slot, item)
|
|
|
42
47
|
if isPowerup then
|
|
43
48
|
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
44
49
|
end
|
|
45
|
-
|
|
46
|
-
unitDropItemSlot(handle, itemHandle, slot - 1)
|
|
50
|
+
unitAddItemToSlot(handle, itemHandle, slot - 1)
|
|
47
51
|
if isPowerup then
|
|
48
52
|
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
49
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
|
-
|
|
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,6 +333,13 @@ 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]>;
|
|
336
|
+
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
337
|
+
static get itemMoveOrderEvent(): Event<[
|
|
338
|
+
unit: Unit,
|
|
339
|
+
item: Item,
|
|
340
|
+
slotFrom: 0 | 1 | 2 | 3 | 4 | 5,
|
|
341
|
+
slotTo: 0 | 1 | 2 | 3 | 4 | 5
|
|
342
|
+
]>;
|
|
335
343
|
static get onCreate(): EventDispatcher<[Unit], [Unit]>;
|
|
336
344
|
static get destroyEvent(): EventDispatcher<[Unit], [Unit]>;
|
|
337
345
|
getField(field: junitintegerfield | junitrealfield): number;
|
package/engine/internal/unit.lua
CHANGED
|
@@ -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
|
-
|
|
944
|
-
unitDisableAbility(
|
|
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
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
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
|
-
|
|
2524
|
-
|
|
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
|
-
|
|
2535
|
-
|
|
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,13 +2551,65 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2540
2551
|
Unit.itemUsedEvent = __TS__New(
|
|
2541
2552
|
____exports.UnitTriggerEvent,
|
|
2542
2553
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2543
|
-
function()
|
|
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,
|
|
2547
2565
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2548
2566
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2549
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
|
+
)
|
|
2550
2613
|
__TS__ObjectDefineProperty(
|
|
2551
2614
|
Unit,
|
|
2552
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
|
package/engine/local-client.lua
CHANGED
|
@@ -131,8 +131,9 @@ __TS__ObjectDefineProperty(
|
|
|
131
131
|
localSelectedUnits[i] = nil
|
|
132
132
|
end
|
|
133
133
|
if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
|
|
134
|
-
|
|
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
|
|
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 =
|
|
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
|
|
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,
|
|
1014
|
-
Unit.abilityStopEvent[abilityTypeId]:addListener(4,
|
|
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
|
|
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,
|
|
1057
|
-
Unit.abilityStopEvent[abilityTypeId]:addListener(4,
|
|
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
|