warscript 0.0.1-dev.e7b1f67 → 0.0.1-dev.ebee5b2
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/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/core/types/frame.d.ts +4 -0
- package/core/types/frame.lua +22 -1
- package/engine/behavior.d.ts +4 -4
- package/engine/behaviour/ability/apply-buff.d.ts +3 -5
- package/engine/behaviour/ability/damage.d.ts +33 -11
- package/engine/behaviour/ability/damage.lua +89 -31
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/unit.d.ts +5 -0
- package/engine/behaviour/unit.lua +20 -0
- package/engine/buff.d.ts +60 -18
- package/engine/buff.lua +239 -62
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/unit/bonus.d.ts +4 -2
- package/engine/internal/unit/bonus.lua +6 -1
- package/engine/internal/unit+ability.lua +2 -2
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit.d.ts +23 -4
- package/engine/internal/unit.lua +94 -33
- package/engine/object-field/ability.d.ts +17 -0
- package/engine/object-field/ability.lua +50 -0
- package/lualib_bundle.lua +7 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/buff.lua +1 -1
- package/package.json +2 -2
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/utility/linked-set.d.ts +11 -2
- package/utility/linked-set.lua +5 -2
- package/utility/types.d.ts +1 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
|
@@ -8,7 +8,8 @@ export type UnitBonusId<Brand extends string = any> = number & {
|
|
|
8
8
|
export type UnitArmorBonusId = UnitBonusId<"armor">;
|
|
9
9
|
export type UnitAttackSpeedFactorBonusId = UnitBonusId<"attackSpeedFactor">;
|
|
10
10
|
export type UnitMovementSpeedFactorBonusId = UnitBonusId<"movementSpeedFactor">;
|
|
11
|
-
export type
|
|
11
|
+
export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
|
|
12
|
+
export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
|
|
12
13
|
export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
|
|
13
14
|
export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
|
|
14
15
|
abilityTypeId: AbilityTypeId;
|
|
@@ -30,7 +31,8 @@ export declare namespace UnitBonusType {
|
|
|
30
31
|
const ARMOR: UnitBonusType<UnitArmorBonusId>;
|
|
31
32
|
const ATTACK_SPEED_FACTOR: UnitBonusType<UnitAttackSpeedFactorBonusId>;
|
|
32
33
|
const MOVEMENT_SPEED_FACTOR: UnitBonusType<UnitAttackSpeedFactorBonusId>;
|
|
33
|
-
const
|
|
34
|
+
const AUTO_ATTACK_DAMAGE: UnitBonusType<UnitAutoAttackDamageBonusId>;
|
|
35
|
+
const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
34
36
|
const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
35
37
|
}
|
|
36
38
|
export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
|
|
@@ -21,6 +21,7 @@ local AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID = ____auto_2Dattack_2Dda
|
|
|
21
21
|
local ____movement_2Dspeed_2Dincrease_2Dfactor = require("engine.internal.object-data.movement-speed-increase-factor")
|
|
22
22
|
local MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD
|
|
23
23
|
local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
|
|
24
|
+
local damageFactorByUnit = {}
|
|
24
25
|
local receivedDamageFactorByUnit = {}
|
|
25
26
|
____exports.UnitBonusType = {}
|
|
26
27
|
local UnitBonusType = ____exports.UnitBonusType
|
|
@@ -46,13 +47,14 @@ do
|
|
|
46
47
|
reduce = sum,
|
|
47
48
|
initialValue = 0
|
|
48
49
|
}
|
|
49
|
-
UnitBonusType.
|
|
50
|
+
UnitBonusType.AUTO_ATTACK_DAMAGE = {
|
|
50
51
|
abilityTypeId = AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID,
|
|
51
52
|
field = AUTO_ATTACK_DAMAGE_INCREASE_ABILITY_FIELD,
|
|
52
53
|
integer = false,
|
|
53
54
|
reduce = sum,
|
|
54
55
|
initialValue = 0
|
|
55
56
|
}
|
|
57
|
+
UnitBonusType.DAMAGE_FACTOR = {reduce = product, valueByUnit = damageFactorByUnit, initialValue = 1}
|
|
56
58
|
UnitBonusType.RECEIVED_DAMAGE_FACTOR = {reduce = product, valueByUnit = receivedDamageFactorByUnit, initialValue = 1}
|
|
57
59
|
end
|
|
58
60
|
local bonusesByUnitByBonusType = {}
|
|
@@ -180,6 +182,9 @@ end
|
|
|
180
182
|
Unit.onDamage:addListener(
|
|
181
183
|
4,
|
|
182
184
|
function(source, target, event)
|
|
185
|
+
if source ~= nil and damageFactorByUnit[source] ~= nil then
|
|
186
|
+
event.amount = event.amount * damageFactorByUnit[source]
|
|
187
|
+
end
|
|
183
188
|
if receivedDamageFactorByUnit[target] ~= nil then
|
|
184
189
|
event.amount = event.amount * receivedDamageFactorByUnit[target]
|
|
185
190
|
end
|
|
@@ -40,7 +40,7 @@ ItemAbility.onCreate:addListener(
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
)
|
|
43
|
-
Unit.
|
|
43
|
+
Unit.itemPickedUpEvent:addListener(
|
|
44
44
|
0,
|
|
45
45
|
function(unit, item)
|
|
46
46
|
for ____, ability in ipairs(item.abilities) do
|
|
@@ -48,7 +48,7 @@ Unit.onItemPickup:addListener(
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
)
|
|
51
|
-
Unit.
|
|
51
|
+
Unit.itemDroppedEvent:addListener(
|
|
52
52
|
4,
|
|
53
53
|
function(unit, item)
|
|
54
54
|
for ____, ability in ipairs(item.abilities) do
|
|
@@ -6,9 +6,8 @@ local ____unit = require("engine.internal.unit")
|
|
|
6
6
|
local Unit = ____unit.Unit
|
|
7
7
|
local ____event = require("event")
|
|
8
8
|
local Event = ____event.Event
|
|
9
|
-
local
|
|
10
|
-
local
|
|
11
|
-
local boundRegion = ____mapbounds.boundRegion
|
|
9
|
+
local ____game_2Dmap = require("engine.game-map")
|
|
10
|
+
local GameMap = ____game_2Dmap.GameMap
|
|
12
11
|
local eventInvoke = Event.invoke
|
|
13
12
|
local tableRemove = table.remove
|
|
14
13
|
local ____assert = _G.assert
|
|
@@ -58,8 +57,8 @@ triggerAddCondition(
|
|
|
58
57
|
deboard(unit)
|
|
59
58
|
end
|
|
60
59
|
if not unitAlive(handle) then
|
|
61
|
-
unit.x =
|
|
62
|
-
unit.y =
|
|
60
|
+
unit.x = GameMap.worldBoundsRect.maxX
|
|
61
|
+
unit.y = GameMap.worldBoundsRect.maxY
|
|
63
62
|
end
|
|
64
63
|
local transport = Unit:of(getTransportUnit())
|
|
65
64
|
transportByUnit[unit] = transport
|
|
@@ -68,11 +67,6 @@ triggerAddCondition(
|
|
|
68
67
|
eventInvoke(onBoardEvent, unit, transport)
|
|
69
68
|
end)
|
|
70
69
|
)
|
|
71
|
-
boundRegion.onUnitEnter:addListener(function(unit)
|
|
72
|
-
if transportByUnit[unit] ~= nil and not isUnitLoaded(unit.handle) then
|
|
73
|
-
deboard(unit)
|
|
74
|
-
end
|
|
75
|
-
end)
|
|
76
70
|
Unit.deathEvent:addListener(function(unit)
|
|
77
71
|
if transportByUnit[unit] ~= nil then
|
|
78
72
|
deboard(unit)
|
|
@@ -42,6 +42,7 @@ export interface DamagingEvent {
|
|
|
42
42
|
damageType: jdamagetype;
|
|
43
43
|
weaponType: jweapontype;
|
|
44
44
|
readonly isAttack: boolean;
|
|
45
|
+
readonly originalAmount: number;
|
|
45
46
|
}
|
|
46
47
|
export type DamageEvent = DamagingEvent & {
|
|
47
48
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
@@ -67,6 +68,22 @@ declare const modifiers: {
|
|
|
67
68
|
speed: (unit: junit, value: number) => void;
|
|
68
69
|
armor: (unit: junit, value: number) => void;
|
|
69
70
|
};
|
|
71
|
+
export interface UnitItems extends ReadonlyArray<Item | undefined> {
|
|
72
|
+
readonly length: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
73
|
+
[0]: Item | undefined;
|
|
74
|
+
[1]: Item | undefined;
|
|
75
|
+
[2]: Item | undefined;
|
|
76
|
+
[3]: Item | undefined;
|
|
77
|
+
[4]: Item | undefined;
|
|
78
|
+
[5]: Item | undefined;
|
|
79
|
+
}
|
|
80
|
+
export declare class UnitItems {
|
|
81
|
+
private readonly handle;
|
|
82
|
+
constructor(handle: junit);
|
|
83
|
+
protected __newindex(slot: number, item: Item | undefined): void;
|
|
84
|
+
protected __index(slot: number): Item | undefined;
|
|
85
|
+
protected __len(): number;
|
|
86
|
+
}
|
|
70
87
|
export declare class UnitWeapon {
|
|
71
88
|
readonly unit: Unit;
|
|
72
89
|
readonly index: 0 | 1;
|
|
@@ -227,7 +244,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
227
244
|
isSelected(player: Player): boolean;
|
|
228
245
|
explode(): void;
|
|
229
246
|
kill(): void;
|
|
230
|
-
revive(
|
|
247
|
+
revive(x: number, y: number, doEffect?: boolean): void;
|
|
231
248
|
healTarget(target: Widget, amount: number): void;
|
|
232
249
|
useItem(item: Item): boolean;
|
|
233
250
|
issueImmediateOrder(order: number): boolean;
|
|
@@ -240,6 +257,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
240
257
|
dropItemTarget(item: Item, target: Widget): boolean;
|
|
241
258
|
dropItemSlot(item: Item, slot: number): boolean;
|
|
242
259
|
itemInSlot(slot: number): Item | null;
|
|
260
|
+
get items(): UnitItems;
|
|
243
261
|
addAbility(abilityId: number): UnitAbility | null;
|
|
244
262
|
makeAbilityPermanent(abilityId: number, permanent: true): boolean;
|
|
245
263
|
setAbilityLevel(abilityId: number, level: number): number;
|
|
@@ -322,9 +340,10 @@ export declare class Unit extends Handle<junit> {
|
|
|
322
340
|
static readonly autoAttackStartEvent: UnitTriggerEvent<[Unit]>;
|
|
323
341
|
static readonly onDamaging: Event<[source: Unit | undefined, target: Unit, event: DamagingEvent]>;
|
|
324
342
|
static readonly onDamage: InitializingEvent<[source: Unit | undefined, target: Unit, event: DamageEvent], jtrigger>;
|
|
325
|
-
static
|
|
326
|
-
static
|
|
327
|
-
static
|
|
343
|
+
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
344
|
+
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
345
|
+
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
346
|
+
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
328
347
|
static get onCreate(): EventDispatcher<[Unit], [Unit]>;
|
|
329
348
|
static get destroyEvent(): EventDispatcher<[Unit], [Unit]>;
|
|
330
349
|
getField(field: junitintegerfield | junitrealfield): number;
|
package/engine/internal/unit.lua
CHANGED
|
@@ -7,11 +7,15 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
8
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
9
9
|
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
10
|
+
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
11
|
+
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
12
|
+
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
10
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
13
16
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
14
17
|
local ____exports = {}
|
|
18
|
+
local unitInventorySize, unitItemInSlot, unitDropItemSlot, unitRemoveItemFromSlot, unitAddItem, isItemPowerup, setItemBooleanField
|
|
15
19
|
local ____handle = require("core.types.handle")
|
|
16
20
|
local Handle = ____handle.Handle
|
|
17
21
|
local ____player = require("core.types.player")
|
|
@@ -279,16 +283,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
279
283
|
end
|
|
280
284
|
local function dispatch(event, idGetter, argsGetter)
|
|
281
285
|
local initialized = false
|
|
282
|
-
local x = {}
|
|
283
286
|
return setmetatable(
|
|
284
|
-
|
|
287
|
+
{},
|
|
285
288
|
{
|
|
286
289
|
__index = function(self, id)
|
|
287
290
|
if type(id) ~= "number" then
|
|
288
291
|
return event[id]
|
|
289
292
|
end
|
|
290
293
|
if not initialized then
|
|
291
|
-
local invoke = Event.invoke
|
|
292
294
|
event:addListener(function(...)
|
|
293
295
|
local id = idGetter(...)
|
|
294
296
|
local dispatched = rawget(self, id)
|
|
@@ -326,7 +328,6 @@ local function dispatchAbility(event)
|
|
|
326
328
|
return event[id]
|
|
327
329
|
end
|
|
328
330
|
if not initialized then
|
|
329
|
-
local invoke = Event.invoke
|
|
330
331
|
event:addListener(function(unit, ability, ...)
|
|
331
332
|
local dispatched = rawget(self, ability.typeId)
|
|
332
333
|
if dispatched ~= nil then
|
|
@@ -391,6 +392,37 @@ local getters = {
|
|
|
391
392
|
return BlzGetUnitArmor(unit)
|
|
392
393
|
end
|
|
393
394
|
}
|
|
395
|
+
____exports.UnitItems = __TS__Class()
|
|
396
|
+
local UnitItems = ____exports.UnitItems
|
|
397
|
+
UnitItems.name = "UnitItems"
|
|
398
|
+
function UnitItems.prototype.____constructor(self, handle)
|
|
399
|
+
self.handle = handle
|
|
400
|
+
end
|
|
401
|
+
function UnitItems.prototype.__newindex(self, slot, item)
|
|
402
|
+
local handle = self.handle
|
|
403
|
+
if slot < 0 or slot >= unitInventorySize(handle) then
|
|
404
|
+
return
|
|
405
|
+
end
|
|
406
|
+
unitRemoveItemFromSlot(handle, slot)
|
|
407
|
+
if item ~= nil then
|
|
408
|
+
local itemHandle = item.handle
|
|
409
|
+
local isPowerup = isItemPowerup(itemHandle)
|
|
410
|
+
if isPowerup then
|
|
411
|
+
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
412
|
+
end
|
|
413
|
+
unitAddItem(handle, itemHandle)
|
|
414
|
+
unitDropItemSlot(handle, itemHandle, slot)
|
|
415
|
+
if isPowerup then
|
|
416
|
+
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
function UnitItems.prototype.__index(self, slot)
|
|
421
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
422
|
+
end
|
|
423
|
+
function UnitItems.prototype.__len(self)
|
|
424
|
+
return unitInventorySize(self.handle)
|
|
425
|
+
end
|
|
394
426
|
____exports.UnitWeapon = __TS__Class()
|
|
395
427
|
local UnitWeapon = ____exports.UnitWeapon
|
|
396
428
|
UnitWeapon.name = "UnitWeapon"
|
|
@@ -543,8 +575,13 @@ __TS__SetDescriptor(
|
|
|
543
575
|
},
|
|
544
576
|
true
|
|
545
577
|
)
|
|
546
|
-
|
|
547
|
-
|
|
578
|
+
unitInventorySize = UnitInventorySize
|
|
579
|
+
unitItemInSlot = UnitItemInSlot
|
|
580
|
+
unitDropItemSlot = UnitDropItemSlot
|
|
581
|
+
unitRemoveItemFromSlot = UnitRemoveItemFromSlot
|
|
582
|
+
unitAddItem = UnitAddItem
|
|
583
|
+
isItemPowerup = IsItemPowerup
|
|
584
|
+
setItemBooleanField = BlzSetItemBooleanField
|
|
548
585
|
local getItemAbility = BlzGetItemAbility
|
|
549
586
|
local getUnitAbility = BlzGetUnitAbility
|
|
550
587
|
local getUnitAbilityByIndex = BlzGetUnitAbilityByIndex
|
|
@@ -817,8 +854,15 @@ end
|
|
|
817
854
|
function Unit.prototype.kill(self)
|
|
818
855
|
killUnit(self.handle)
|
|
819
856
|
end
|
|
820
|
-
function Unit.prototype.revive(self,
|
|
821
|
-
|
|
857
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
858
|
+
local ____ReviveHero_4 = ReviveHero
|
|
859
|
+
local ____array_3 = __TS__SparseArrayNew(self.handle, x, y)
|
|
860
|
+
local ____doEffect_2 = doEffect
|
|
861
|
+
if ____doEffect_2 == nil then
|
|
862
|
+
____doEffect_2 = false
|
|
863
|
+
end
|
|
864
|
+
__TS__SparseArrayPush(____array_3, ____doEffect_2)
|
|
865
|
+
____ReviveHero_4(__TS__SparseArraySpread(____array_3))
|
|
822
866
|
end
|
|
823
867
|
function Unit.prototype.healTarget(self, target, amount)
|
|
824
868
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -858,7 +902,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
858
902
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
859
903
|
end
|
|
860
904
|
function Unit.prototype.itemInSlot(self, slot)
|
|
861
|
-
return Item:of(
|
|
905
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
862
906
|
end
|
|
863
907
|
function Unit.prototype.addAbility(self, abilityId)
|
|
864
908
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -1385,13 +1429,13 @@ __TS__SetDescriptor(
|
|
|
1385
1429
|
end,
|
|
1386
1430
|
set = function(self, isTeamGlowVisible)
|
|
1387
1431
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1388
|
-
local
|
|
1432
|
+
local ____temp_5
|
|
1389
1433
|
if not isTeamGlowVisible then
|
|
1390
|
-
|
|
1434
|
+
____temp_5 = true
|
|
1391
1435
|
else
|
|
1392
|
-
|
|
1436
|
+
____temp_5 = nil
|
|
1393
1437
|
end
|
|
1394
|
-
self[105] =
|
|
1438
|
+
self[105] = ____temp_5
|
|
1395
1439
|
end
|
|
1396
1440
|
},
|
|
1397
1441
|
true
|
|
@@ -1809,6 +1853,16 @@ __TS__SetDescriptor(
|
|
|
1809
1853
|
end},
|
|
1810
1854
|
true
|
|
1811
1855
|
)
|
|
1856
|
+
__TS__SetDescriptor(
|
|
1857
|
+
Unit.prototype,
|
|
1858
|
+
"items",
|
|
1859
|
+
{get = function(self)
|
|
1860
|
+
local items = __TS__New(____exports.UnitItems, self.handle)
|
|
1861
|
+
rawset(self, "items", items)
|
|
1862
|
+
return items
|
|
1863
|
+
end},
|
|
1864
|
+
true
|
|
1865
|
+
)
|
|
1812
1866
|
__TS__SetDescriptor(
|
|
1813
1867
|
Unit.prototype,
|
|
1814
1868
|
"buffIds",
|
|
@@ -2055,7 +2109,6 @@ Unit.onDecay = __TS__New(
|
|
|
2055
2109
|
Unit.onResurrect = __TS__New(
|
|
2056
2110
|
InitializingEvent,
|
|
2057
2111
|
function(event)
|
|
2058
|
-
local invoke = Event.invoke
|
|
2059
2112
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2060
2113
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2061
2114
|
dead[unit] = true
|
|
@@ -2071,10 +2124,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2071
2124
|
Unit.morphEvent = __TS__New(
|
|
2072
2125
|
InitializingEvent,
|
|
2073
2126
|
function(event)
|
|
2127
|
+
local function ifNotLeft(unit)
|
|
2128
|
+
local handle = unit.handle
|
|
2129
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2130
|
+
invoke(event, unit)
|
|
2131
|
+
end
|
|
2132
|
+
end
|
|
2074
2133
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2075
2134
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2076
|
-
|
|
2077
|
-
Timer:run(Event.invoke, event, unit)
|
|
2135
|
+
Timer:run(ifNotLeft, unit)
|
|
2078
2136
|
end
|
|
2079
2137
|
end)
|
|
2080
2138
|
end
|
|
@@ -2112,27 +2170,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2112
2170
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2113
2171
|
InitializingEvent,
|
|
2114
2172
|
function(event)
|
|
2115
|
-
local invoke = Event.invoke
|
|
2116
2173
|
local function listener(unit, id)
|
|
2117
|
-
local
|
|
2174
|
+
local ____GetSpellTargetUnit_result_8
|
|
2118
2175
|
if GetSpellTargetUnit() then
|
|
2119
|
-
|
|
2176
|
+
____GetSpellTargetUnit_result_8 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2120
2177
|
else
|
|
2121
|
-
local
|
|
2178
|
+
local ____GetSpellTargetItem_result_7
|
|
2122
2179
|
if GetSpellTargetItem() then
|
|
2123
|
-
|
|
2180
|
+
____GetSpellTargetItem_result_7 = Item:of(GetSpellTargetItem())
|
|
2124
2181
|
else
|
|
2125
|
-
local
|
|
2182
|
+
local ____GetSpellTargetDestructable_result_6
|
|
2126
2183
|
if GetSpellTargetDestructable() then
|
|
2127
|
-
|
|
2184
|
+
____GetSpellTargetDestructable_result_6 = Destructable:of(GetSpellTargetDestructable())
|
|
2128
2185
|
else
|
|
2129
|
-
|
|
2186
|
+
____GetSpellTargetDestructable_result_6 = nil
|
|
2130
2187
|
end
|
|
2131
|
-
|
|
2188
|
+
____GetSpellTargetItem_result_7 = ____GetSpellTargetDestructable_result_6
|
|
2132
2189
|
end
|
|
2133
|
-
|
|
2190
|
+
____GetSpellTargetUnit_result_8 = ____GetSpellTargetItem_result_7
|
|
2134
2191
|
end
|
|
2135
|
-
local target =
|
|
2192
|
+
local target = ____GetSpellTargetUnit_result_8
|
|
2136
2193
|
if target then
|
|
2137
2194
|
invoke(event, unit, id, target)
|
|
2138
2195
|
end
|
|
@@ -2329,7 +2386,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2329
2386
|
)
|
|
2330
2387
|
Unit.onDamaging = (function()
|
|
2331
2388
|
local event = __TS__New(Event)
|
|
2332
|
-
local invoke = Event.invoke
|
|
2333
2389
|
local trigger = CreateTrigger()
|
|
2334
2390
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2335
2391
|
TriggerAddCondition(
|
|
@@ -2428,7 +2484,6 @@ end)()
|
|
|
2428
2484
|
Unit.onDamage = __TS__New(
|
|
2429
2485
|
InitializingEvent,
|
|
2430
2486
|
function(event)
|
|
2431
|
-
local invoke = Event.invoke
|
|
2432
2487
|
local trigger = CreateTrigger()
|
|
2433
2488
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2434
2489
|
TriggerAddCondition(
|
|
@@ -2444,6 +2499,7 @@ Unit.onDamage = __TS__New(
|
|
|
2444
2499
|
damageType = BlzGetEventDamageType(),
|
|
2445
2500
|
weaponType = BlzGetEventWeaponType(),
|
|
2446
2501
|
isAttack = BlzGetEventIsAttack(),
|
|
2502
|
+
originalAmount = GetEventDamage(),
|
|
2447
2503
|
preventDeath = damageEventPreventDeath
|
|
2448
2504
|
}
|
|
2449
2505
|
local evData = setmetatable(
|
|
@@ -2494,7 +2550,7 @@ Unit.onDamage = __TS__New(
|
|
|
2494
2550
|
DestroyTrigger(trigger)
|
|
2495
2551
|
end
|
|
2496
2552
|
)
|
|
2497
|
-
Unit.
|
|
2553
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2498
2554
|
____exports.UnitTriggerEvent,
|
|
2499
2555
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2500
2556
|
function()
|
|
@@ -2505,7 +2561,7 @@ Unit.onItemDrop = __TS__New(
|
|
|
2505
2561
|
return IgnoreEvent
|
|
2506
2562
|
end
|
|
2507
2563
|
)
|
|
2508
|
-
Unit.
|
|
2564
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2509
2565
|
____exports.UnitTriggerEvent,
|
|
2510
2566
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2511
2567
|
function()
|
|
@@ -2516,10 +2572,15 @@ Unit.onItemPickup = __TS__New(
|
|
|
2516
2572
|
return IgnoreEvent
|
|
2517
2573
|
end
|
|
2518
2574
|
)
|
|
2519
|
-
Unit.
|
|
2575
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2520
2576
|
____exports.UnitTriggerEvent,
|
|
2521
2577
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2522
|
-
function() return ____exports.Unit:of(
|
|
2578
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2579
|
+
)
|
|
2580
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2581
|
+
____exports.UnitTriggerEvent,
|
|
2582
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2583
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2523
2584
|
)
|
|
2524
2585
|
__TS__ObjectDefineProperty(
|
|
2525
2586
|
Unit,
|
|
@@ -6,6 +6,9 @@ import { ObjectDataEntryId } from "../object-data/entry";
|
|
|
6
6
|
import { LightningTypeId } from "../object-data/entry/lightning-type";
|
|
7
7
|
import { CombatClassifications } from "../object-data/auxiliary/combat-classification";
|
|
8
8
|
import { UnitTypeId } from "../object-data/entry/unit-type";
|
|
9
|
+
import { BuffResistanceType } from "../object-data/auxiliary/buff-resistance-type";
|
|
10
|
+
import { BuffPolarity } from "../object-data/auxiliary/buff-polarity";
|
|
11
|
+
import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
|
|
9
12
|
export declare abstract class AbilityField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectField<AbilityType, Ability, ValueType, NativeFieldType> {
|
|
10
13
|
protected get instanceClass(): typeof Ability;
|
|
11
14
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
@@ -107,6 +110,20 @@ export declare class AbilityAbilityTypeIdLevelField extends AbilityObjectDataEnt
|
|
|
107
110
|
}
|
|
108
111
|
export declare class AbilityUnitTypeIdLevelField extends AbilityObjectDataEntryIdLevelField<UnitTypeId> {
|
|
109
112
|
}
|
|
113
|
+
export declare abstract class AbilityEnumLevelField<T extends number> extends AbilityLevelField<T, T, jabilityintegerlevelfield> {
|
|
114
|
+
protected abstract values: ReadonlyNonEmptyLinkedSet<T>;
|
|
115
|
+
protected get defaultValue(): T;
|
|
116
|
+
protected getNativeFieldById(id: number): jabilityintegerlevelfield;
|
|
117
|
+
protected getNativeFieldValue(instance: Ability, level: number): T;
|
|
118
|
+
protected setNativeFieldValue(instance: Ability, level: number, value: T): boolean;
|
|
119
|
+
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<AbilityBooleanLevelField>;
|
|
120
|
+
}
|
|
121
|
+
export declare class AbilityBuffPolarityLevelField extends AbilityEnumLevelField<BuffPolarity> {
|
|
122
|
+
protected values: ReadonlyNonEmptyLinkedSet<BuffPolarity>;
|
|
123
|
+
}
|
|
124
|
+
export declare class AbilityBuffResistanceTypeLevelField extends AbilityEnumLevelField<BuffResistanceType> {
|
|
125
|
+
protected values: ReadonlyNonEmptyLinkedSet<BuffResistanceType>;
|
|
126
|
+
}
|
|
110
127
|
export declare class AbilityCombatClassificationsLevelField extends AbilityLevelField<CombatClassifications, CombatClassifications, jabilityintegerlevelfield> {
|
|
111
128
|
protected get defaultValue(): CombatClassifications;
|
|
112
129
|
protected getNativeFieldById(id: number): jabilityintegerlevelfield;
|
|
@@ -13,6 +13,8 @@ local ObjectField = ____object_2Dfield.ObjectField
|
|
|
13
13
|
local ObjectLevelField = ____object_2Dfield.ObjectLevelField
|
|
14
14
|
local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
|
|
15
15
|
local AbilityType = ____ability_2Dtype.AbilityType
|
|
16
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
17
|
+
local nonEmptyLinkedSetOf = ____linked_2Dset.nonEmptyLinkedSetOf
|
|
16
18
|
local convertAbilityBooleanField = _G.ConvertAbilityBooleanField
|
|
17
19
|
local convertAbilityIntegerField = _G.ConvertAbilityIntegerField
|
|
18
20
|
local convertAbilityRealField = _G.ConvertAbilityRealField
|
|
@@ -431,6 +433,54 @@ ____exports.AbilityUnitTypeIdLevelField = __TS__Class()
|
|
|
431
433
|
local AbilityUnitTypeIdLevelField = ____exports.AbilityUnitTypeIdLevelField
|
|
432
434
|
AbilityUnitTypeIdLevelField.name = "AbilityUnitTypeIdLevelField"
|
|
433
435
|
__TS__ClassExtends(AbilityUnitTypeIdLevelField, ____exports.AbilityObjectDataEntryIdLevelField)
|
|
436
|
+
____exports.AbilityEnumLevelField = __TS__Class()
|
|
437
|
+
local AbilityEnumLevelField = ____exports.AbilityEnumLevelField
|
|
438
|
+
AbilityEnumLevelField.name = "AbilityEnumLevelField"
|
|
439
|
+
__TS__ClassExtends(AbilityEnumLevelField, ____exports.AbilityLevelField)
|
|
440
|
+
function AbilityEnumLevelField.prototype.getNativeFieldById(self, id)
|
|
441
|
+
return convertAbilityIntegerLevelField(id)
|
|
442
|
+
end
|
|
443
|
+
function AbilityEnumLevelField.prototype.getNativeFieldValue(self, instance, level)
|
|
444
|
+
local value = instance:getField(self.nativeField, level)
|
|
445
|
+
if self.values:contains(value) then
|
|
446
|
+
return value
|
|
447
|
+
end
|
|
448
|
+
return self.values:first()
|
|
449
|
+
end
|
|
450
|
+
function AbilityEnumLevelField.prototype.setNativeFieldValue(self, instance, level, value)
|
|
451
|
+
return instance:setField(self.nativeField, level, value)
|
|
452
|
+
end
|
|
453
|
+
__TS__SetDescriptor(
|
|
454
|
+
AbilityEnumLevelField.prototype,
|
|
455
|
+
"defaultValue",
|
|
456
|
+
{get = function(self)
|
|
457
|
+
return self.values:first()
|
|
458
|
+
end},
|
|
459
|
+
true
|
|
460
|
+
)
|
|
461
|
+
__TS__ObjectDefineProperty(
|
|
462
|
+
AbilityEnumLevelField,
|
|
463
|
+
"valueChangeEvent",
|
|
464
|
+
{get = function(self)
|
|
465
|
+
return self:getOrCreateValueChangeEvent()
|
|
466
|
+
end}
|
|
467
|
+
)
|
|
468
|
+
____exports.AbilityBuffPolarityLevelField = __TS__Class()
|
|
469
|
+
local AbilityBuffPolarityLevelField = ____exports.AbilityBuffPolarityLevelField
|
|
470
|
+
AbilityBuffPolarityLevelField.name = "AbilityBuffPolarityLevelField"
|
|
471
|
+
__TS__ClassExtends(AbilityBuffPolarityLevelField, ____exports.AbilityEnumLevelField)
|
|
472
|
+
function AbilityBuffPolarityLevelField.prototype.____constructor(self, ...)
|
|
473
|
+
AbilityBuffPolarityLevelField.____super.prototype.____constructor(self, ...)
|
|
474
|
+
self.values = nonEmptyLinkedSetOf(0, 1, 2)
|
|
475
|
+
end
|
|
476
|
+
____exports.AbilityBuffResistanceTypeLevelField = __TS__Class()
|
|
477
|
+
local AbilityBuffResistanceTypeLevelField = ____exports.AbilityBuffResistanceTypeLevelField
|
|
478
|
+
AbilityBuffResistanceTypeLevelField.name = "AbilityBuffResistanceTypeLevelField"
|
|
479
|
+
__TS__ClassExtends(AbilityBuffResistanceTypeLevelField, ____exports.AbilityEnumLevelField)
|
|
480
|
+
function AbilityBuffResistanceTypeLevelField.prototype.____constructor(self, ...)
|
|
481
|
+
AbilityBuffResistanceTypeLevelField.____super.prototype.____constructor(self, ...)
|
|
482
|
+
self.values = nonEmptyLinkedSetOf(1, 2, 3)
|
|
483
|
+
end
|
|
434
484
|
local allowedTargetCombatClassificationsByLevelByAbilityTypeId = postcompile(function()
|
|
435
485
|
local allowedTargetCombatClassificationsByLevelByAbilityTypeId = {}
|
|
436
486
|
for ____, abilityType in ipairs(AbilityType:getAll()) do
|
package/lualib_bundle.lua
CHANGED
|
@@ -1094,6 +1094,11 @@ do
|
|
|
1094
1094
|
end
|
|
1095
1095
|
if __TS__StringIncludes(_VERSION, "Lua 5.0") then
|
|
1096
1096
|
return debug.traceback(("[Level " .. tostring(level)) .. "]")
|
|
1097
|
+
elseif _VERSION == "Lua 5.1" then
|
|
1098
|
+
return string.sub(
|
|
1099
|
+
debug.traceback("", level),
|
|
1100
|
+
2
|
|
1101
|
+
)
|
|
1097
1102
|
else
|
|
1098
1103
|
return debug.traceback(nil, level)
|
|
1099
1104
|
end
|
|
@@ -1102,7 +1107,7 @@ do
|
|
|
1102
1107
|
return function(self)
|
|
1103
1108
|
local description = getDescription(self)
|
|
1104
1109
|
local caller = debug.getinfo(3, "f")
|
|
1105
|
-
local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0")
|
|
1110
|
+
local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0")
|
|
1106
1111
|
if isClassicLua or caller and caller.func ~= error then
|
|
1107
1112
|
return description
|
|
1108
1113
|
else
|
|
@@ -1126,7 +1131,7 @@ do
|
|
|
1126
1131
|
end
|
|
1127
1132
|
self.message = message
|
|
1128
1133
|
self.name = "Error"
|
|
1129
|
-
self.stack = getErrorStack(nil,
|
|
1134
|
+
self.stack = getErrorStack(nil, __TS__New)
|
|
1130
1135
|
local metatable = getmetatable(self)
|
|
1131
1136
|
if metatable and not metatable.__errorToStringPatched then
|
|
1132
1137
|
metatable.__errorToStringPatched = true
|
package/net/socket.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Event } from "../event";
|
|
3
3
|
import { Player } from "../core/types/player";
|
|
4
|
+
declare const enum SocketPropertyKey {
|
|
5
|
+
ID = 0,
|
|
6
|
+
CHUNK_ID = 1
|
|
7
|
+
}
|
|
4
8
|
export declare class Socket {
|
|
5
|
-
private readonly
|
|
9
|
+
private readonly [SocketPropertyKey.ID];
|
|
10
|
+
private readonly [SocketPropertyKey.CHUNK_ID];
|
|
6
11
|
readonly onMessage: Event<[Player, string]>;
|
|
7
12
|
constructor();
|
|
8
13
|
send(data: string): void;
|
|
9
14
|
}
|
|
15
|
+
export {};
|
package/net/socket.lua
CHANGED
|
@@ -7,6 +7,11 @@ local Event = ____event.Event
|
|
|
7
7
|
local ____network = require("network")
|
|
8
8
|
local send = ____network.send
|
|
9
9
|
local onReceive = ____network.onReceive
|
|
10
|
+
local MAX_PAYLOAD_LENGTH = ____network.MAX_PAYLOAD_LENGTH
|
|
11
|
+
local ____math = require("math")
|
|
12
|
+
local ceil = ____math.ceil
|
|
13
|
+
local stringSub = string.sub
|
|
14
|
+
local tableConcat = table.concat
|
|
10
15
|
local nextId = 0
|
|
11
16
|
____exports.Socket = __TS__Class()
|
|
12
17
|
local Socket = ____exports.Socket
|
|
@@ -14,13 +19,49 @@ Socket.name = "Socket"
|
|
|
14
19
|
function Socket.prototype.____constructor(self)
|
|
15
20
|
local ____tostring_0 = tostring
|
|
16
21
|
nextId = nextId + 1
|
|
17
|
-
self
|
|
22
|
+
self[0] = ____tostring_0(nextId)
|
|
23
|
+
local ____tostring_1 = tostring
|
|
24
|
+
nextId = nextId + 1
|
|
25
|
+
self[1] = ____tostring_1(nextId)
|
|
18
26
|
self.onMessage = __TS__New(Event)
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
local chunksByPlayer = {}
|
|
28
|
+
onReceive[self[0]]:addListener(function(sender, data)
|
|
29
|
+
local chunks = chunksByPlayer[sender]
|
|
30
|
+
if chunks ~= nil then
|
|
31
|
+
chunks[#chunks + 1] = data
|
|
32
|
+
Event.invoke(
|
|
33
|
+
self.onMessage,
|
|
34
|
+
sender,
|
|
35
|
+
tableConcat(chunks)
|
|
36
|
+
)
|
|
37
|
+
chunksByPlayer[sender] = nil
|
|
38
|
+
else
|
|
39
|
+
Event.invoke(self.onMessage, sender, data)
|
|
40
|
+
end
|
|
41
|
+
end)
|
|
42
|
+
onReceive[self[1]]:addListener(function(sender, data)
|
|
43
|
+
local chunks = chunksByPlayer[sender]
|
|
44
|
+
if chunks == nil then
|
|
45
|
+
chunks = {}
|
|
46
|
+
chunksByPlayer[sender] = chunks
|
|
47
|
+
end
|
|
48
|
+
chunks[#chunks + 1] = data
|
|
21
49
|
end)
|
|
22
50
|
end
|
|
23
51
|
function Socket.prototype.send(self, data)
|
|
24
|
-
|
|
52
|
+
local chunks = ceil(#data / MAX_PAYLOAD_LENGTH) - 1
|
|
53
|
+
local offset = 1
|
|
54
|
+
for _ = 0, chunks - 1 do
|
|
55
|
+
local nextOffset = offset + MAX_PAYLOAD_LENGTH
|
|
56
|
+
send(
|
|
57
|
+
self[1],
|
|
58
|
+
stringSub(data, offset, nextOffset - 1)
|
|
59
|
+
)
|
|
60
|
+
offset = nextOffset
|
|
61
|
+
end
|
|
62
|
+
send(
|
|
63
|
+
self[0],
|
|
64
|
+
stringSub(data, offset)
|
|
65
|
+
)
|
|
25
66
|
end
|
|
26
67
|
return ____exports
|
package/network.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Event } from "./event";
|
|
3
3
|
import { Player } from "./core/types/player";
|
|
4
4
|
import { Operation, OperationContinue, OperationMonitor } from "./operation";
|
|
5
|
+
export declare const MAX_PAYLOAD_LENGTH = 255;
|
|
5
6
|
export declare const onReceive: {
|
|
6
7
|
[prefix: string]: Event<[Player, string]>;
|
|
7
8
|
} & {
|