warscript 0.0.1-dev.d5f6f38 → 0.0.1-dev.d750e38
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 +1 -0
- package/core/types/effect.lua +82 -32
- 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.lua +1 -1
- package/engine/internal/ability.d.ts +13 -2
- package/engine/internal/ability.lua +77 -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 -0
- 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.lua +6 -12
- package/engine/internal/unit.d.ts +3 -1
- package/engine/internal/unit.lua +63 -13
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +8 -2
- package/engine/lightning.lua +29 -2
- 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/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
|
@@ -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
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -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
|
|
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,
|
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
|
|
@@ -929,8 +932,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
929
932
|
unitInterruptAttack(self.handle)
|
|
930
933
|
end
|
|
931
934
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
932
|
-
|
|
933
|
-
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
|
+
)
|
|
934
944
|
end
|
|
935
945
|
function Unit.prototype.getDistanceTo(self, target)
|
|
936
946
|
local handle = self.handle
|
|
@@ -1195,6 +1205,14 @@ __TS__SetDescriptor(
|
|
|
1195
1205
|
end},
|
|
1196
1206
|
true
|
|
1197
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
|
+
)
|
|
1198
1216
|
__TS__SetDescriptor(
|
|
1199
1217
|
Unit.prototype,
|
|
1200
1218
|
"combatClassifications",
|
|
@@ -2315,10 +2333,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2315
2333
|
____exports.UnitTriggerEvent,
|
|
2316
2334
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2317
2335
|
function()
|
|
2318
|
-
local
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
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
|
|
2322
2342
|
end
|
|
2323
2343
|
return IgnoreEvent
|
|
2324
2344
|
end
|
|
@@ -2509,8 +2529,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2509
2529
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2510
2530
|
function()
|
|
2511
2531
|
local unit = getTriggerUnit()
|
|
2512
|
-
|
|
2513
|
-
|
|
2532
|
+
local item = getManipulatedItem()
|
|
2533
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2534
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2514
2535
|
end
|
|
2515
2536
|
return IgnoreEvent
|
|
2516
2537
|
end
|
|
@@ -2520,8 +2541,9 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2520
2541
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2521
2542
|
function()
|
|
2522
2543
|
local unit = getTriggerUnit()
|
|
2523
|
-
|
|
2524
|
-
|
|
2544
|
+
local item = getManipulatedItem()
|
|
2545
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2546
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2525
2547
|
end
|
|
2526
2548
|
return IgnoreEvent
|
|
2527
2549
|
end
|
|
@@ -2529,7 +2551,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2529
2551
|
Unit.itemUsedEvent = __TS__New(
|
|
2530
2552
|
____exports.UnitTriggerEvent,
|
|
2531
2553
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
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
|
|
2533
2562
|
)
|
|
2534
2563
|
Unit.itemStackedEvent = __TS__New(
|
|
2535
2564
|
____exports.UnitTriggerEvent,
|
|
@@ -2538,7 +2567,28 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2538
2567
|
)
|
|
2539
2568
|
__TS__ObjectDefineProperty(
|
|
2540
2569
|
Unit,
|
|
2541
|
-
"
|
|
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",
|
|
2542
2592
|
{get = function(self)
|
|
2543
2593
|
local event = __TS__New(Event)
|
|
2544
2594
|
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
@@ -2556,7 +2606,7 @@ __TS__ObjectDefineProperty(
|
|
|
2556
2606
|
end
|
|
2557
2607
|
end)
|
|
2558
2608
|
end
|
|
2559
|
-
rawset(self, "
|
|
2609
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2560
2610
|
return event
|
|
2561
2611
|
end}
|
|
2562
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
|
package/engine/lightning.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ declare const enum LightningPropertyKey {
|
|
|
12
12
|
TARGET_X = 106,
|
|
13
13
|
TARGET_Y = 107,
|
|
14
14
|
TARGET_Z = 108,
|
|
15
|
-
DURATION = 109
|
|
15
|
+
DURATION = 109,
|
|
16
|
+
FADING = 110
|
|
16
17
|
}
|
|
17
18
|
export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
|
|
18
19
|
export declare class Lightning extends Handle<jlightning> {
|
|
@@ -27,6 +28,7 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
27
28
|
private [LightningPropertyKey.TARGET_Y]?;
|
|
28
29
|
private [LightningPropertyKey.TARGET_Z]?;
|
|
29
30
|
private [LightningPropertyKey.DURATION]?;
|
|
31
|
+
private [LightningPropertyKey.FADING]?;
|
|
30
32
|
constructor(handle: jlightning, typeId: LightningTypeId);
|
|
31
33
|
protected onDestroy(): HandleDestructor;
|
|
32
34
|
static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
|
|
@@ -46,6 +48,10 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
46
48
|
target: Unit
|
|
47
49
|
]
|
|
48
50
|
]): T;
|
|
49
|
-
static flash(...parameters: [
|
|
51
|
+
static flash(...parameters: [
|
|
52
|
+
...parameters: Parameters<(typeof Lightning)["create"]>,
|
|
53
|
+
duration: number,
|
|
54
|
+
fading?: boolean
|
|
55
|
+
]): void;
|
|
50
56
|
}
|
|
51
57
|
export {};
|
package/engine/lightning.lua
CHANGED
|
@@ -10,6 +10,8 @@ local ____functions = require("utility.functions")
|
|
|
10
10
|
local forwardByN = ____functions.forwardByN
|
|
11
11
|
local ____unit_2Dmissile_2Ddata = require("engine.internal.unit-missile-data")
|
|
12
12
|
local MISSILE_DATA_BY_UNIT_TYPE_ID = ____unit_2Dmissile_2Ddata.MISSILE_DATA_BY_UNIT_TYPE_ID
|
|
13
|
+
local ____math = require("math")
|
|
14
|
+
local ceil = ____math.ceil
|
|
13
15
|
local ____type = _G.type
|
|
14
16
|
local select = _G.select
|
|
15
17
|
local cos = math.cos
|
|
@@ -27,6 +29,11 @@ local getUnitZ = BlzGetUnitZ
|
|
|
27
29
|
local getUnitFlyHeight = GetUnitFlyHeight
|
|
28
30
|
local getLocationZ = GetLocationZ
|
|
29
31
|
local moveLocation = MoveLocation
|
|
32
|
+
local getLightningColorA = GetLightningColorA
|
|
33
|
+
local getLightningColorR = GetLightningColorR
|
|
34
|
+
local getLightningColorG = GetLightningColorG
|
|
35
|
+
local getLightningColorB = GetLightningColorB
|
|
36
|
+
local setLightningColor = SetLightningColor
|
|
30
37
|
local location = Location(0, 0)
|
|
31
38
|
local unitToUnitLightnings = setmetatable({}, {__mode = "k"})
|
|
32
39
|
local unitToPointLightnings = setmetatable({}, {__mode = "k"})
|
|
@@ -225,9 +232,19 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
|
|
|
225
232
|
return lightning
|
|
226
233
|
end
|
|
227
234
|
function Lightning.flash(self, ...)
|
|
228
|
-
local
|
|
235
|
+
local parameterOrDuration, durationOrFading = select(-2, ...)
|
|
236
|
+
local hasFading = ____type(durationOrFading) ~= "number"
|
|
237
|
+
local parametersToForwardCount = select("#", ...) - (hasFading and 2 or 1)
|
|
229
238
|
local lightning = forwardByN[parametersToForwardCount](____exports.Lightning.create, self, ...)
|
|
230
|
-
local duration
|
|
239
|
+
local duration
|
|
240
|
+
if hasFading then
|
|
241
|
+
duration = parameterOrDuration
|
|
242
|
+
if durationOrFading then
|
|
243
|
+
lightning[110] = true
|
|
244
|
+
end
|
|
245
|
+
else
|
|
246
|
+
duration = durationOrFading
|
|
247
|
+
end
|
|
231
248
|
lightning[109] = duration
|
|
232
249
|
temporaryLightningsCount = temporaryLightningsCount + 1
|
|
233
250
|
temporaryLightnings[temporaryLightningsCount] = lightning
|
|
@@ -295,6 +312,16 @@ Timer.onPeriod[UPDATE_PERIOD]:addListener(function()
|
|
|
295
312
|
temporaryLightnings[temporaryLightningsCount] = nil
|
|
296
313
|
temporaryLightningsCount = temporaryLightningsCount - 1
|
|
297
314
|
else
|
|
315
|
+
if lightning[110] then
|
|
316
|
+
local handle = lightning.handle
|
|
317
|
+
setLightningColor(
|
|
318
|
+
handle,
|
|
319
|
+
getLightningColorR(handle),
|
|
320
|
+
getLightningColorG(handle),
|
|
321
|
+
getLightningColorB(handle),
|
|
322
|
+
ceil(getLightningColorA(handle) * (1 - UPDATE_PERIOD / duration))
|
|
323
|
+
)
|
|
324
|
+
end
|
|
298
325
|
lightning[109] = duration - UPDATE_PERIOD
|
|
299
326
|
i = i + 1
|
|
300
327
|
end
|
|
@@ -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
|
|
@@ -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 =
|
|
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
|
|
134
|
-
export
|
|
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",
|
package/engine/object-field.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ declare abstract class ObjectFieldBase<ObjectDataEntryType extends ObjectDataEnt
|
|
|
16
16
|
readonly id: ObjectFieldId;
|
|
17
17
|
protected abstract getNativeFieldById(id: number): NativeFieldType;
|
|
18
18
|
protected abstract getObjectDataEntryId(instance: InstanceType): ObjectDataEntryIdType<ObjectDataEntryType>;
|
|
19
|
+
protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
|
|
20
|
+
hasValue(instance: InstanceType): boolean;
|
|
19
21
|
constructor(id: number);
|
|
20
22
|
static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number): T & symbol;
|
|
21
23
|
static of<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldAbstractConstructor<T>, id: number): T | undefined;
|
|
@@ -35,7 +37,6 @@ export type ReadonlyObjectFieldType<T extends ObjectField<any, any, any, any>> =
|
|
|
35
37
|
type ReadonlyObjectFieldConstructor<T extends ObjectField> = OmitConstructor<typeof ObjectField> & (abstract new (...args: any[]) => ReadonlyObjectFieldType<T>);
|
|
36
38
|
export declare abstract class ObjectField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType, NativeFieldType> {
|
|
37
39
|
protected abstract readonly defaultValue: ValueType;
|
|
38
|
-
protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
|
|
39
40
|
protected abstract getNativeFieldValue(instance: InstanceType): ValueType;
|
|
40
41
|
protected abstract setNativeFieldValue(instance: InstanceType, value: ValueType): boolean;
|
|
41
42
|
getValue(entry: ObjectDataEntryType | InstanceType): ValueType;
|
|
@@ -71,7 +72,6 @@ export declare abstract class ObjectArrayField<ObjectDataEntryType extends Objec
|
|
|
71
72
|
}
|
|
72
73
|
export declare abstract class ObjectLevelField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, InputValueType extends ValueType = never, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType[], NativeFieldType> {
|
|
73
74
|
protected abstract readonly defaultValue: ValueType;
|
|
74
|
-
protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
|
|
75
75
|
protected abstract getNativeFieldValue(instance: InstanceType, level: number): ValueType;
|
|
76
76
|
protected abstract setNativeFieldValue(instance: InstanceType, level: number, value: ValueType): boolean;
|
|
77
77
|
protected abstract getLevelCount(entry: ObjectDataEntryType | InstanceType): number;
|
package/engine/object-field.lua
CHANGED
|
@@ -46,6 +46,10 @@ end
|
|
|
46
46
|
function ObjectFieldBase.prototype.supports(self, instance)
|
|
47
47
|
return __TS__InstanceOf(instance, self.instanceClass)
|
|
48
48
|
end
|
|
49
|
+
function ObjectFieldBase.prototype.hasValue(self, instance)
|
|
50
|
+
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
51
|
+
return defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
52
|
+
end
|
|
49
53
|
function ObjectFieldBase.create(self, id)
|
|
50
54
|
return __TS__New(
|
|
51
55
|
self,
|
|
@@ -687,6 +687,8 @@ export declare const DISABLE_OTHER_ABILITIES_ABILITY_BOOLEAN_LEVEL_FIELD: Abilit
|
|
|
687
687
|
export declare const ALLOW_BOUNTY_ABILITY_BOOLEAN_LEVEL_FIELD: AbilityBooleanLevelField & symbol;
|
|
688
688
|
export declare const ICON_NORMAL_ABILITY_STRING_LEVEL_FIELD: AbilityStringLevelField & symbol;
|
|
689
689
|
export declare const CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD: AbilityStringArrayField & symbol;
|
|
690
|
+
export declare const CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
|
|
691
|
+
export declare const CASTER_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
|
|
690
692
|
export declare const TARGET_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD: AbilityStringArrayField & symbol;
|
|
691
693
|
export declare const TARGET_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
|
|
692
694
|
export declare const TARGET_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
|
|
@@ -698,6 +698,8 @@ ____exports.DISABLE_OTHER_ABILITIES_ABILITY_BOOLEAN_LEVEL_FIELD = AbilityBoolean
|
|
|
698
698
|
____exports.ALLOW_BOUNTY_ABILITY_BOOLEAN_LEVEL_FIELD = AbilityBooleanLevelField:create(fourCC("Ntm4"))
|
|
699
699
|
____exports.ICON_NORMAL_ABILITY_STRING_LEVEL_FIELD = AbilityStringLevelField:create(fourCC("aart"))
|
|
700
700
|
____exports.CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = AbilityStringArrayField:create(fourCC("acat"))
|
|
701
|
+
____exports.CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("acap"))
|
|
702
|
+
____exports.CASTER_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("aca1"))
|
|
701
703
|
____exports.TARGET_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = AbilityStringArrayField:create(fourCC("atat"))
|
|
702
704
|
____exports.TARGET_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("ata0"))
|
|
703
705
|
____exports.TARGET_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("ata1"))
|
package/engine/unit.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import "./internal/unit/ghost-counter";
|
|
|
17
17
|
import "./internal/unit/invulnerability-counter";
|
|
18
18
|
import "./internal/unit/detach-missiles";
|
|
19
19
|
import "./internal/unit/main-selected";
|
|
20
|
+
import "./internal/unit/add-item-to-slot-init";
|
|
20
21
|
import "./internal/unit/band-aids/ancestral-spirit-cannibalize";
|
|
21
22
|
export { Unit, DamagingEvent, DamageEvent } from "./internal/unit";
|
|
22
23
|
export * from "./internal/unit+damage";
|
package/engine/unit.lua
CHANGED
|
@@ -17,6 +17,7 @@ require("engine.internal.unit.ghost-counter")
|
|
|
17
17
|
require("engine.internal.unit.invulnerability-counter")
|
|
18
18
|
require("engine.internal.unit.detach-missiles")
|
|
19
19
|
require("engine.internal.unit.main-selected")
|
|
20
|
+
require("engine.internal.unit.add-item-to-slot-init")
|
|
20
21
|
require("engine.internal.unit.band-aids.ancestral-spirit-cannibalize")
|
|
21
22
|
do
|
|
22
23
|
local ____unit = require("engine.internal.unit")
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "warscript",
|
|
4
|
-
"version": "0.0.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.d750e38",
|
|
5
5
|
"description": "A typescript library for Warcraft III using Warpack.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"warcraft",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@warscript/language-extensions": "^0.0.1",
|
|
25
25
|
"@warscript/tstl-plugin": "^0.0.4",
|
|
26
26
|
"lua-types": "^2.13.1",
|
|
27
|
-
"warpack": "0.0.1-dev.
|
|
27
|
+
"warpack": "0.0.1-dev.1830aad"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
package/utility/lazy.lua
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local rawset = _G.rawset
|
|
3
|
+
local setmetatable = _G.setmetatable
|
|
4
|
+
____exports.lazyRecord = function(initializer)
|
|
5
|
+
return setmetatable(
|
|
6
|
+
{},
|
|
7
|
+
{__index = function(self, key)
|
|
8
|
+
local value = initializer(key)
|
|
9
|
+
rawset(self, key, value)
|
|
10
|
+
return value
|
|
11
|
+
end}
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
return ____exports
|