warscript 0.0.1-dev.f9efacb → 0.0.1-dev.fa24390
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/attributes.d.ts +5 -0
- package/attributes.lua +8 -1
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +14 -6
- package/core/types/effect.lua +131 -35
- package/core/types/order.d.ts +1 -0
- package/core/types/order.lua +11 -1
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/core/util.d.ts +1 -1
- package/core/util.lua +12 -1
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +5 -0
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +26 -38
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +35 -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 +20 -4
- package/engine/behaviour/ability.lua +111 -38
- package/engine/behaviour/unit.d.ts +2 -0
- package/engine/buff.d.ts +62 -42
- package/engine/buff.lua +312 -234
- 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/item.d.ts +4 -3
- package/engine/internal/item.lua +56 -25
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -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 +52 -0
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +17 -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/main-selected.d.ts +6 -0
- package/engine/internal/unit/main-selected.lua +12 -1
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit.d.ts +25 -5
- package/engine/internal/unit.lua +195 -61
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -17
- package/engine/object-data/entry/ability-type.lua +89 -33
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +3 -1
- package/engine/object-data/entry/item-type.lua +15 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +10 -3
- package/engine/object-data/entry/unit-type.lua +155 -92
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +10 -4
- package/engine/object-field/ability.lua +3 -0
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +11 -3
- package/engine/object-field.lua +162 -76
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -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/objutil/buff.lua +1 -2
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/utility/arrays.d.ts +9 -1
- package/utility/arrays.lua +37 -3
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +3 -0
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
|
@@ -12,7 +12,8 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
12
12
|
protected constructor(handle: jability, typeId: number);
|
|
13
13
|
toString(): string;
|
|
14
14
|
get parentTypeId(): number;
|
|
15
|
-
get
|
|
15
|
+
get orderTypeStringId(): string;
|
|
16
|
+
get orderTypeId(): number;
|
|
16
17
|
abstract readonly owner: Unit | Item;
|
|
17
18
|
getSnapshot(): AbilitySnapshot;
|
|
18
19
|
hasField(field: jabilityfield | number): boolean;
|
|
@@ -34,6 +35,9 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
34
35
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
35
36
|
get levelCount(): number;
|
|
36
37
|
abstract get level(): number;
|
|
38
|
+
abstract get cooldownRemaining(): number;
|
|
39
|
+
abstract set cooldownRemaining(cooldownRemaining: number);
|
|
40
|
+
abstract interruptCast(): void;
|
|
37
41
|
static get onCreate(): Event<[Ability]>;
|
|
38
42
|
static get destroyEvent(): Event<[Ability]>;
|
|
39
43
|
}
|
|
@@ -44,6 +48,9 @@ export declare class UnrecognizedAbility extends Ability {
|
|
|
44
48
|
readonly owner: Unit;
|
|
45
49
|
constructor(typeId: number, owner: Unit);
|
|
46
50
|
get level(): number;
|
|
51
|
+
get cooldownRemaining(): number;
|
|
52
|
+
set cooldownRemaining(_: number);
|
|
53
|
+
interruptCast(): void;
|
|
47
54
|
}
|
|
48
55
|
export declare class UnitAbility extends Ability {
|
|
49
56
|
readonly owner: Unit;
|
|
@@ -51,10 +58,13 @@ export declare class UnitAbility extends Ability {
|
|
|
51
58
|
constructor(handle: jability, typeId: number, owner: Unit);
|
|
52
59
|
incrementHideCounter(): void;
|
|
53
60
|
decrementHideCounter(): void;
|
|
61
|
+
incrementDisableCounter(): void;
|
|
62
|
+
decrementDisableCounter(): void;
|
|
54
63
|
get level(): number;
|
|
55
64
|
set level(v: number);
|
|
56
65
|
get cooldownRemaining(): number;
|
|
57
|
-
set cooldownRemaining(
|
|
66
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
67
|
+
interruptCast(): void;
|
|
58
68
|
static get onCreate(): Event<[UnitAbility]>;
|
|
59
69
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
60
70
|
}
|
|
@@ -78,6 +88,9 @@ export declare class ItemAbility extends Ability {
|
|
|
78
88
|
setField(field: jabilitybooleanlevelfield, level: number, value: boolean): boolean;
|
|
79
89
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
80
90
|
get level(): number;
|
|
91
|
+
get cooldownRemaining(): number;
|
|
92
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
93
|
+
interruptCast(): void;
|
|
81
94
|
static get onCreate(): Event<[ItemAbility]>;
|
|
82
95
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
83
96
|
}
|
|
@@ -10,7 +10,10 @@ local ____exports = {}
|
|
|
10
10
|
local ____handle = require("core.types.handle")
|
|
11
11
|
local Handle = ____handle.Handle
|
|
12
12
|
local ____ability = require("engine.internal.item.ability")
|
|
13
|
+
local abilityActionDummy = ____ability.abilityActionDummy
|
|
13
14
|
local doAbilityAction = ____ability.doAbilityAction
|
|
15
|
+
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
16
|
+
local startItemCooldown = ____ability.startItemCooldown
|
|
14
17
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
15
18
|
local setUnitAbilityLevel = SetUnitAbilityLevel
|
|
16
19
|
local setAbilityIntegerField = BlzSetAbilityIntegerField
|
|
@@ -32,7 +35,10 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
|
|
|
32
35
|
local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
|
|
33
36
|
local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
|
|
34
37
|
local getHandleId = GetHandleId
|
|
38
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
39
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
35
40
|
local unitHideAbility = BlzUnitHideAbility
|
|
41
|
+
local unitDisableAbility = BlzUnitDisableAbility
|
|
36
42
|
local match = string.match
|
|
37
43
|
local ____type = _G.type
|
|
38
44
|
local ____tostring = _G.tostring
|
|
@@ -296,10 +302,18 @@ __TS__SetDescriptor(
|
|
|
296
302
|
)
|
|
297
303
|
__TS__SetDescriptor(
|
|
298
304
|
Ability.prototype,
|
|
299
|
-
"
|
|
305
|
+
"orderTypeStringId",
|
|
300
306
|
{get = function(self)
|
|
301
307
|
local field = orderIdFieldByParentTypeId[self.parentTypeId]
|
|
302
|
-
return
|
|
308
|
+
return field ~= nil and getAbilityStringLevelField(self.handle, field, self.level) or (orders[self.parentTypeId] or "")
|
|
309
|
+
end},
|
|
310
|
+
true
|
|
311
|
+
)
|
|
312
|
+
__TS__SetDescriptor(
|
|
313
|
+
Ability.prototype,
|
|
314
|
+
"orderTypeId",
|
|
315
|
+
{get = function(self)
|
|
316
|
+
return order2orderId(self.orderTypeStringId)
|
|
303
317
|
end},
|
|
304
318
|
true
|
|
305
319
|
)
|
|
@@ -318,6 +332,17 @@ __TS__SetDescriptor(
|
|
|
318
332
|
end},
|
|
319
333
|
true
|
|
320
334
|
)
|
|
335
|
+
__TS__SetDescriptor(
|
|
336
|
+
Ability.prototype,
|
|
337
|
+
"cooldownRemaining",
|
|
338
|
+
{
|
|
339
|
+
get = function(self)
|
|
340
|
+
end,
|
|
341
|
+
set = function(self, cooldownRemaining)
|
|
342
|
+
end
|
|
343
|
+
},
|
|
344
|
+
true
|
|
345
|
+
)
|
|
321
346
|
__TS__ObjectDefineProperty(
|
|
322
347
|
Ability,
|
|
323
348
|
"onCreate",
|
|
@@ -341,6 +366,8 @@ function UnrecognizedAbility.prototype.____constructor(self, typeId, owner)
|
|
|
341
366
|
UnrecognizedAbility.____super.prototype.____constructor(self, nil, typeId)
|
|
342
367
|
self.owner = owner
|
|
343
368
|
end
|
|
369
|
+
function UnrecognizedAbility.prototype.interruptCast(self)
|
|
370
|
+
end
|
|
344
371
|
__TS__SetDescriptor(
|
|
345
372
|
UnrecognizedAbility.prototype,
|
|
346
373
|
"level",
|
|
@@ -349,6 +376,18 @@ __TS__SetDescriptor(
|
|
|
349
376
|
end},
|
|
350
377
|
true
|
|
351
378
|
)
|
|
379
|
+
__TS__SetDescriptor(
|
|
380
|
+
UnrecognizedAbility.prototype,
|
|
381
|
+
"cooldownRemaining",
|
|
382
|
+
{
|
|
383
|
+
get = function(self)
|
|
384
|
+
return 0
|
|
385
|
+
end,
|
|
386
|
+
set = function(self, _)
|
|
387
|
+
end
|
|
388
|
+
},
|
|
389
|
+
true
|
|
390
|
+
)
|
|
352
391
|
____exports.UnitAbility = __TS__Class()
|
|
353
392
|
local UnitAbility = ____exports.UnitAbility
|
|
354
393
|
UnitAbility.name = "UnitAbility"
|
|
@@ -364,6 +403,15 @@ end
|
|
|
364
403
|
function UnitAbility.prototype.decrementHideCounter(self)
|
|
365
404
|
unitHideAbility(self.u, self.typeId, false)
|
|
366
405
|
end
|
|
406
|
+
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
407
|
+
unitDisableAbility(self.u, self.typeId, true, false)
|
|
408
|
+
end
|
|
409
|
+
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
410
|
+
unitDisableAbility(self.u, self.typeId, false, false)
|
|
411
|
+
end
|
|
412
|
+
function UnitAbility.prototype.interruptCast(self)
|
|
413
|
+
self.owner:interruptCast(self.typeId)
|
|
414
|
+
end
|
|
367
415
|
__TS__SetDescriptor(
|
|
368
416
|
UnitAbility.prototype,
|
|
369
417
|
"level",
|
|
@@ -384,8 +432,8 @@ __TS__SetDescriptor(
|
|
|
384
432
|
get = function(self)
|
|
385
433
|
return getUnitAbilityCooldownRemaining(self.u, self.typeId)
|
|
386
434
|
end,
|
|
387
|
-
set = function(self,
|
|
388
|
-
startUnitAbilityCooldown(self.u, self.typeId,
|
|
435
|
+
set = function(self, cooldownRemaining)
|
|
436
|
+
startUnitAbilityCooldown(self.u, self.typeId, cooldownRemaining)
|
|
389
437
|
end
|
|
390
438
|
},
|
|
391
439
|
true
|
|
@@ -410,6 +458,9 @@ end
|
|
|
410
458
|
local function setAbilityField(_, ability, field, levelOrValue, value)
|
|
411
459
|
return ____exports.Ability.prototype.setField(ability, field, levelOrValue, value)
|
|
412
460
|
end
|
|
461
|
+
local function getAbilityCooldown(_, abilityTypeId)
|
|
462
|
+
return getUnitAbilityCooldownRemaining(abilityActionDummy, abilityTypeId)
|
|
463
|
+
end
|
|
413
464
|
____exports.ItemAbility = __TS__Class()
|
|
414
465
|
local ItemAbility = ____exports.ItemAbility
|
|
415
466
|
ItemAbility.name = "ItemAbility"
|
|
@@ -437,6 +488,14 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
|
|
|
437
488
|
value
|
|
438
489
|
)
|
|
439
490
|
end
|
|
491
|
+
function ItemAbility.prototype.interruptCast(self)
|
|
492
|
+
local handle = self.owner.handle
|
|
493
|
+
local activelyUsed = getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED)
|
|
494
|
+
if activelyUsed then
|
|
495
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, false)
|
|
496
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
497
|
+
end
|
|
498
|
+
end
|
|
440
499
|
__TS__SetDescriptor(
|
|
441
500
|
ItemAbility.prototype,
|
|
442
501
|
"level",
|
|
@@ -445,6 +504,27 @@ __TS__SetDescriptor(
|
|
|
445
504
|
end},
|
|
446
505
|
true
|
|
447
506
|
)
|
|
507
|
+
__TS__SetDescriptor(
|
|
508
|
+
ItemAbility.prototype,
|
|
509
|
+
"cooldownRemaining",
|
|
510
|
+
{
|
|
511
|
+
get = function(self)
|
|
512
|
+
local item = self.owner
|
|
513
|
+
local ____doAbilityActionForceDummy_4 = doAbilityActionForceDummy
|
|
514
|
+
local ____item_handle_3 = item.handle
|
|
515
|
+
local ____opt_1 = item.owner
|
|
516
|
+
return ____doAbilityActionForceDummy_4(____item_handle_3, ____opt_1 and ____opt_1.handle, getAbilityCooldown, self.typeId)
|
|
517
|
+
end,
|
|
518
|
+
set = function(self, cooldownRemaining)
|
|
519
|
+
local item = self.owner
|
|
520
|
+
local ____startItemCooldown_8 = startItemCooldown
|
|
521
|
+
local ____item_handle_7 = item.handle
|
|
522
|
+
local ____opt_5 = item.owner
|
|
523
|
+
____startItemCooldown_8(____item_handle_7, ____opt_5 and ____opt_5.handle, cooldownRemaining)
|
|
524
|
+
end
|
|
525
|
+
},
|
|
526
|
+
true
|
|
527
|
+
)
|
|
448
528
|
__TS__ObjectDefineProperty(
|
|
449
529
|
ItemAbility,
|
|
450
530
|
"onCreate",
|
|
@@ -1,16 +1,60 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
local restoreCooldownGroup
|
|
2
3
|
local ____player = require("core.types.player")
|
|
3
4
|
local Player = ____player.Player
|
|
4
5
|
local ____dummy = require("objutil.dummy")
|
|
5
6
|
local dummyUnitId = ____dummy.dummyUnitId
|
|
7
|
+
local ____utility = require("engine.internal.utility")
|
|
8
|
+
local findUnitItemSlot = ____utility.findUnitItemSlot
|
|
9
|
+
local ____blank = require("engine.object-data.entry.item-type.blank")
|
|
10
|
+
local BlankItemType = ____blank.BlankItemType
|
|
11
|
+
local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
|
|
12
|
+
local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
|
|
13
|
+
local ____math = require("math")
|
|
14
|
+
local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
15
|
+
local ____timer = require("core.types.timer")
|
|
16
|
+
local Timer = ____timer.Timer
|
|
17
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
18
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
19
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
20
|
+
local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
|
|
6
21
|
local isItemOwned = IsItemOwned
|
|
7
22
|
local isItemPowerup = IsItemPowerup
|
|
8
23
|
local getItemX = GetItemX
|
|
9
24
|
local getItemY = GetItemY
|
|
25
|
+
local setAbilityRealLevelField = BlzSetAbilityRealLevelField
|
|
26
|
+
local setItemIntegerField = BlzSetItemIntegerField
|
|
27
|
+
local getItemIntegerField = BlzGetItemIntegerField
|
|
10
28
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
11
29
|
local setItemPosition = SetItemPosition
|
|
12
30
|
local unitAddItem = UnitAddItem
|
|
13
31
|
local unitRemoveItem = UnitRemoveItem
|
|
32
|
+
local unitUseItem = UnitUseItem
|
|
33
|
+
local unitResetCooldown = UnitResetCooldown
|
|
34
|
+
local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
|
|
35
|
+
if not currentMap then
|
|
36
|
+
return 0
|
|
37
|
+
end
|
|
38
|
+
local abilityType = currentMap.objects.ability:newObject(
|
|
39
|
+
util.id2s(abilityTypeIdGenerator:next()),
|
|
40
|
+
"Absk"
|
|
41
|
+
)
|
|
42
|
+
abilityType["bsk1+0"] = 0
|
|
43
|
+
abilityType["bsk2+0"] = 0
|
|
44
|
+
abilityType["bsk3+0"] = 0
|
|
45
|
+
abilityType["amcs+0"] = 0
|
|
46
|
+
abilityType["adur+0"] = MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
47
|
+
abilityType["ahdu+0"] = MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
48
|
+
return util.s2id(abilityType.id)
|
|
49
|
+
end)
|
|
50
|
+
local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
|
|
51
|
+
local itemType = BlankItemType:create()
|
|
52
|
+
itemType.name = "[Warscript/Dummy] Item Cooldown Starter"
|
|
53
|
+
itemType.abilityTypeIds = {COOLDOWN_STARTER_ABILITY_TYPE_ID}
|
|
54
|
+
itemType.cooldownGroupId = COOLDOWN_STARTER_ABILITY_TYPE_ID
|
|
55
|
+
itemType.activelyUsed = true
|
|
56
|
+
return itemType.id
|
|
57
|
+
end)
|
|
14
58
|
local dummy = assert(CreateUnit(
|
|
15
59
|
Player.neutralVictim.handle,
|
|
16
60
|
dummyUnitId,
|
|
@@ -18,10 +62,37 @@ local dummy = assert(CreateUnit(
|
|
|
18
62
|
0,
|
|
19
63
|
270
|
|
20
64
|
))
|
|
65
|
+
local cooldownStarterItem = UnitAddItemById(dummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
66
|
+
local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
21
67
|
ShowUnit(dummy, false)
|
|
68
|
+
local function startItemCooldownInternal(handle, cooldown)
|
|
69
|
+
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
70
|
+
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
71
|
+
setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
|
|
72
|
+
unitResetCooldown(dummy)
|
|
73
|
+
unitUseItem(dummy, cooldownStarterItem)
|
|
74
|
+
Timer:run(restoreCooldownGroup, handle, cooldownGroup)
|
|
75
|
+
end
|
|
76
|
+
restoreCooldownGroup = function(handle, cooldownGroup)
|
|
77
|
+
if getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP) == COOLDOWN_STARTER_ABILITY_TYPE_ID then
|
|
78
|
+
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, cooldownGroup)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
---
|
|
82
|
+
-- @internal For use by internal systems only.
|
|
83
|
+
____exports.startItemCooldown = function(handle, owner, cooldown)
|
|
84
|
+
____exports.doAbilityActionForceDummy(handle, owner, startItemCooldownInternal, cooldown)
|
|
85
|
+
end
|
|
86
|
+
---
|
|
87
|
+
-- @internal For use by internal systems only.
|
|
88
|
+
____exports.abilityActionDummy = dummy
|
|
22
89
|
---
|
|
23
90
|
-- @internal For use by internal systems only.
|
|
24
91
|
____exports.doAbilityAction = function(handle, action, ...)
|
|
92
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
|
|
93
|
+
if not isAlreadyIgnoredInEvents then
|
|
94
|
+
ignoreEventsItems[handle] = true
|
|
95
|
+
end
|
|
25
96
|
local isOwned = isItemOwned(handle)
|
|
26
97
|
local isPowerup
|
|
27
98
|
local x
|
|
@@ -43,6 +114,41 @@ ____exports.doAbilityAction = function(handle, action, ...)
|
|
|
43
114
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
44
115
|
end
|
|
45
116
|
end
|
|
117
|
+
if not isAlreadyIgnoredInEvents then
|
|
118
|
+
ignoreEventsItems[handle] = nil
|
|
119
|
+
end
|
|
120
|
+
return result
|
|
121
|
+
end
|
|
122
|
+
---
|
|
123
|
+
-- @internal For use by internal systems only.
|
|
124
|
+
____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
125
|
+
if owner == nil then
|
|
126
|
+
return ____exports.doAbilityAction(handle, action, ...)
|
|
127
|
+
end
|
|
128
|
+
local slot = findUnitItemSlot(owner, handle)
|
|
129
|
+
if slot == nil then
|
|
130
|
+
return ____exports.doAbilityAction(handle, action, ...)
|
|
131
|
+
end
|
|
132
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
|
|
133
|
+
if not isAlreadyIgnoredInEvents then
|
|
134
|
+
ignoreEventsItems[handle] = true
|
|
135
|
+
end
|
|
136
|
+
local isPowerup
|
|
137
|
+
if isItemPowerup(handle) then
|
|
138
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
139
|
+
isPowerup = true
|
|
140
|
+
end
|
|
141
|
+
unitRemoveItem(owner, handle)
|
|
142
|
+
unitAddItem(dummy, handle)
|
|
143
|
+
local result = action(handle, ...)
|
|
144
|
+
unitRemoveItem(dummy, handle)
|
|
145
|
+
unitAddItemToSlot(owner, handle, slot)
|
|
146
|
+
if isPowerup then
|
|
147
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
148
|
+
end
|
|
149
|
+
if not isAlreadyIgnoredInEvents then
|
|
150
|
+
ignoreEventsItems[handle] = nil
|
|
151
|
+
end
|
|
46
152
|
return result
|
|
47
153
|
end
|
|
48
154
|
return ____exports
|
|
@@ -5,6 +5,7 @@ import { Event } from "../../event";
|
|
|
5
5
|
import { ReadonlyRect } from "../../core/types/rect";
|
|
6
6
|
import { ItemAbility } from "./ability";
|
|
7
7
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
8
|
+
import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
8
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
9
10
|
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
10
11
|
declare const enum ItemPropertyKey {
|
|
@@ -17,7 +18,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
17
18
|
constructor(handle: jitem);
|
|
18
19
|
protected onDestroy(): HandleDestructor;
|
|
19
20
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
|
20
|
-
get typeId():
|
|
21
|
+
get typeId(): ItemTypeId;
|
|
21
22
|
set skinId(v: number);
|
|
22
23
|
get skinId(): number;
|
|
23
24
|
set name(v: string);
|
|
@@ -78,9 +79,9 @@ export declare class Item extends Handle<jitem> {
|
|
|
78
79
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
79
80
|
getAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
80
81
|
get abilities(): readonly ItemAbility[];
|
|
81
|
-
static getInRange(
|
|
82
|
+
static getInRange(x: number, y: number, range: number): Item[];
|
|
82
83
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
83
84
|
static get onCreate(): Event<[Item]>;
|
|
84
|
-
static get
|
|
85
|
+
static get destroyEvent(): Event<[Item]>;
|
|
85
86
|
}
|
|
86
87
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -15,6 +15,12 @@ local ____ability = require("engine.internal.ability")
|
|
|
15
15
|
local ItemAbility = ____ability.ItemAbility
|
|
16
16
|
local ____ability = require("engine.internal.item.ability")
|
|
17
17
|
local doAbilityAction = ____ability.doAbilityAction
|
|
18
|
+
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
19
|
+
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
20
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
21
|
+
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
22
|
+
local ____vec2 = require("math.vec2")
|
|
23
|
+
local distance = ____vec2.distance
|
|
18
24
|
local itemAddAbility = BlzItemAddAbility
|
|
19
25
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
20
26
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -24,6 +30,12 @@ local getAbilityId = BlzGetAbilityId
|
|
|
24
30
|
local getWidgetLife = GetWidgetLife
|
|
25
31
|
local removeItem = RemoveItem
|
|
26
32
|
local getHandleId = GetHandleId
|
|
33
|
+
local setRect = SetRect
|
|
34
|
+
local enumItemsInRect = EnumItemsInRect
|
|
35
|
+
local getEnumItem = GetEnumItem
|
|
36
|
+
local getItemTypeId = GetItemTypeId
|
|
37
|
+
local getItemX = GetItemX
|
|
38
|
+
local getItemY = GetItemY
|
|
27
39
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
28
40
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
29
41
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
@@ -53,6 +65,32 @@ local function getItemAbilities(handle, item)
|
|
|
53
65
|
end
|
|
54
66
|
return abilities
|
|
55
67
|
end
|
|
68
|
+
local targetCollection
|
|
69
|
+
local targetCollectionNextIndex
|
|
70
|
+
local centerX
|
|
71
|
+
local centerY
|
|
72
|
+
local enumRange
|
|
73
|
+
local function collectIntoTarget()
|
|
74
|
+
local item = getEnumItem()
|
|
75
|
+
local typeId = getItemTypeId(item)
|
|
76
|
+
if typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
|
|
77
|
+
targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
|
|
78
|
+
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
local function collectIntoTargetRange()
|
|
82
|
+
local item = getEnumItem()
|
|
83
|
+
local typeId = getItemTypeId(item)
|
|
84
|
+
if distance(
|
|
85
|
+
getItemX(item),
|
|
86
|
+
getItemY(item),
|
|
87
|
+
centerX,
|
|
88
|
+
centerY
|
|
89
|
+
) <= enumRange and typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
|
|
90
|
+
targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
|
|
91
|
+
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
92
|
+
end
|
|
93
|
+
end
|
|
56
94
|
____exports.Item = __TS__Class()
|
|
57
95
|
local Item = ____exports.Item
|
|
58
96
|
Item.name = "Item"
|
|
@@ -111,34 +149,27 @@ function Item.prototype.getAbility(self, abilityTypeId)
|
|
|
111
149
|
local ability = self[101][abilityTypeId] ~= nil and doAbilityAction(self.handle, getItemAbility, abilityTypeId)
|
|
112
150
|
return ability and ItemAbility:of(ability, abilityTypeId, self) or nil
|
|
113
151
|
end
|
|
114
|
-
function Item.getInRange(self,
|
|
115
|
-
|
|
116
|
-
|
|
152
|
+
function Item.getInRange(self, x, y, range)
|
|
153
|
+
targetCollection = {}
|
|
154
|
+
targetCollectionNextIndex = 1
|
|
155
|
+
centerX = x
|
|
156
|
+
centerY = y
|
|
157
|
+
enumRange = range
|
|
158
|
+
setRect(
|
|
117
159
|
enumRect,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
160
|
+
x - range,
|
|
161
|
+
y - range,
|
|
162
|
+
x + range,
|
|
163
|
+
y + range
|
|
122
164
|
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
nil,
|
|
126
|
-
function()
|
|
127
|
-
collection[#collection + 1] = self:of(GetEnumItem())
|
|
128
|
-
end
|
|
129
|
-
)
|
|
130
|
-
return collection
|
|
165
|
+
enumItemsInRect(enumRect, nil, collectIntoTargetRange)
|
|
166
|
+
return targetCollection
|
|
131
167
|
end
|
|
132
168
|
function Item.getInRect(self, rect)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function()
|
|
138
|
-
collection[#collection + 1] = self:of(GetEnumItem())
|
|
139
|
-
end
|
|
140
|
-
)
|
|
141
|
-
return collection
|
|
169
|
+
targetCollection = {}
|
|
170
|
+
targetCollectionNextIndex = 1
|
|
171
|
+
enumItemsInRect(rect.handle, nil, collectIntoTarget)
|
|
172
|
+
return targetCollection
|
|
142
173
|
end
|
|
143
174
|
__TS__SetDescriptor(
|
|
144
175
|
Item.prototype,
|
|
@@ -551,7 +582,7 @@ __TS__ObjectDefineProperty(
|
|
|
551
582
|
)
|
|
552
583
|
__TS__ObjectDefineProperty(
|
|
553
584
|
Item,
|
|
554
|
-
"
|
|
585
|
+
"destroyEvent",
|
|
555
586
|
{get = function(self)
|
|
556
587
|
return self.onDestroyEvent
|
|
557
588
|
end}
|
|
@@ -8,6 +8,6 @@ local DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_NORMAL_AB
|
|
|
8
8
|
-- @internal For use by internal systems only.
|
|
9
9
|
____exports.getAbilityDuration = function(ability, target)
|
|
10
10
|
local level = ability.level
|
|
11
|
-
return target ~= nil and target:hasClassification(UnitClassification.RESISTANT) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
11
|
+
return target ~= nil and (target.isHero or target:getField(UNIT_IF_LEVEL) >= 6 or target:hasClassification(UnitClassification.RESISTANT)) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
12
12
|
end
|
|
13
13
|
return ____exports
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local disableAbility = BlzUnitDisableAbility
|
|
3
|
+
---
|
|
4
|
+
-- @internal For use by internal systems only.
|
|
5
|
+
____exports.increaseAbilityDisableCounter = function(unit, abilityTypeId, times)
|
|
6
|
+
for _ = 1, times do
|
|
7
|
+
disableAbility(unit, abilityTypeId, true, false)
|
|
8
|
+
end
|
|
9
|
+
for _ = times, -1 do
|
|
10
|
+
disableAbility(unit, abilityTypeId, false, false)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
return ____exports
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
export
|
|
2
|
+
export {};
|
|
@@ -10,5 +10,7 @@ ____exports.AUTO_ATTACK_SPEED_INCREASE_DUMMY_ABILITY_TYPE_ID = compiletime(funct
|
|
|
10
10
|
abilityType.autoAttackSpeedIncreaseFactor = 0
|
|
11
11
|
return abilityType.id
|
|
12
12
|
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems.
|
|
13
15
|
____exports.AUTO_ATTACK_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ABILITY_RLF_ATTACK_SPEED_INCREASE_ISX1
|
|
14
16
|
return ____exports
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____evasion = require("engine.object-data.entry.ability-type.evasion")
|
|
3
|
+
local EvasionAbilityType = ____evasion.EvasionAbilityType
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems.
|
|
6
|
+
____exports.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = compiletime(function()
|
|
7
|
+
local abilityType = EvasionAbilityType:create()
|
|
8
|
+
abilityType.isInternal = true
|
|
9
|
+
abilityType.isButtonVisible = false
|
|
10
|
+
abilityType.evasionProbability = 0
|
|
11
|
+
return abilityType.id
|
|
12
|
+
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems.
|
|
15
|
+
____exports.EVASION_PROBABILITY_ABILITY_FIELD = ABILITY_RLF_CHANCE_TO_EVADE_EEV1
|
|
16
|
+
return ____exports
|
|
@@ -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
|