warscript 0.0.1-dev.c59dd14 → 0.0.1-dev.c60b168
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 -1
- package/attributes.lua +8 -1
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- 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/frame.d.ts +8 -1
- package/core/types/frame.lua +103 -13
- package/core/types/group.d.ts +0 -1
- package/core/types/image.d.ts +0 -1
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +79 -5
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +8 -8
- package/core/types/timer.lua +39 -23
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/index.d.ts +1 -0
- package/decl/native.d.ts +844 -788
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +15 -10
- package/engine/behavior.lua +112 -33
- 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 +8 -5
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +39 -11
- package/engine/behaviour/ability/damage.lua +83 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +43 -0
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- 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/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +20 -4
- package/engine/behaviour/ability.lua +111 -47
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -4
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +40 -2
- package/engine/behaviour/unit.lua +208 -0
- package/engine/buff.d.ts +104 -44
- package/engine/buff.lua +453 -215
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +23 -14
- package/engine/internal/ability.lua +128 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +7 -4
- package/engine/internal/item.lua +141 -35
- 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/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.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 +45 -1
- package/engine/internal/unit/ability.lua +98 -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/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/bonus.d.ts +11 -8
- package/engine/internal/unit/bonus.lua +23 -1
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +51 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit+ability.lua +12 -3
- 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+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +33 -7
- package/engine/internal/unit.d.ts +55 -18
- package/engine/internal/unit.lua +392 -157
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- 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/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -3
- 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/combat-classification.d.ts +0 -2
- 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.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -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/channel.d.ts +0 -1
- 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 -18
- package/engine/object-data/entry/ability-type.lua +90 -36
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +6 -13
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -2
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +15 -2
- package/engine/object-data/entry/item-type.lua +93 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -2
- 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 +21 -6
- package/engine/object-data/entry/unit-type.lua +214 -93
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +1 -2
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +18 -17
- 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 +28 -5
- package/engine/object-field/ability.lua +59 -5
- package/engine/object-field/unit.d.ts +57 -3
- package/engine/object-field/unit.lua +207 -7
- package/engine/object-field.d.ts +17 -7
- package/engine/object-field.lua +190 -90
- package/engine/random.d.ts +1 -5
- 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/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +249 -10
- package/engine/unit.d.ts +4 -0
- package/engine/unit.lua +13 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -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/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +2 -3
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/objutil/unit.lua +8 -0
- package/package.json +13 -13
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +16 -0
- package/string.lua +5 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +12 -5
- package/utility/arrays.lua +37 -3
- package/utility/bit-set.d.ts +0 -2
- package/utility/callback-array.d.ts +13 -0
- package/utility/callback-array.lua +46 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +12 -3
- package/utility/linked-set.lua +8 -2
- package/utility/lua-maps.d.ts +5 -2
- package/utility/lua-maps.lua +20 -0
- package/utility/lua-sets.d.ts +3 -2
- package/utility/lua-sets.lua +7 -0
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +1 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____rect = require("core.types.rect")
|
|
6
|
+
local Rect = ____rect.Rect
|
|
7
|
+
local ____region = require("core.types.region")
|
|
8
|
+
local Region = ____region.Region
|
|
9
|
+
____exports.GameMap = __TS__Class()
|
|
10
|
+
local GameMap = ____exports.GameMap
|
|
11
|
+
GameMap.name = "GameMap"
|
|
12
|
+
function GameMap.prototype.____constructor(self)
|
|
13
|
+
end
|
|
14
|
+
__TS__ObjectDefineProperty(
|
|
15
|
+
GameMap,
|
|
16
|
+
"worldBoundsRect",
|
|
17
|
+
{get = function(self)
|
|
18
|
+
local rect = Rect:of(GetWorldBounds())
|
|
19
|
+
rawset(self, "worldBoundsRect", rect)
|
|
20
|
+
return rect
|
|
21
|
+
end}
|
|
22
|
+
)
|
|
23
|
+
__TS__ObjectDefineProperty(
|
|
24
|
+
GameMap,
|
|
25
|
+
"worldBoundsRegion",
|
|
26
|
+
{get = function(self)
|
|
27
|
+
local region = Region:create(self.worldBoundsRect)
|
|
28
|
+
rawset(self, "worldBoundsRegion", region)
|
|
29
|
+
return region
|
|
30
|
+
end}
|
|
31
|
+
)
|
|
32
|
+
return ____exports
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import { Handle } from "../../core/types/handle";
|
|
2
|
+
import { Handle, HandleDestructor } from "../../core/types/handle";
|
|
3
3
|
import { Event } from "../../event";
|
|
4
4
|
import type { Item } from "../../core/types/item";
|
|
5
5
|
import type { Unit } from "./unit";
|
|
6
6
|
import type { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
7
|
-
interface Fields<K, V> {
|
|
8
|
-
set(field: K, value: V): boolean;
|
|
9
|
-
get(field: K): V;
|
|
10
|
-
has(field: K): boolean;
|
|
11
|
-
}
|
|
12
|
-
interface AbilityLevel {
|
|
13
|
-
realFields: Fields<jabilityreallevelfield, number>;
|
|
14
|
-
}
|
|
15
7
|
export type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
|
|
16
8
|
export declare class AbilitySnapshot {
|
|
17
9
|
}
|
|
@@ -20,7 +12,8 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
20
12
|
protected constructor(handle: jability, typeId: number);
|
|
21
13
|
toString(): string;
|
|
22
14
|
get parentTypeId(): number;
|
|
23
|
-
get
|
|
15
|
+
get orderTypeStringId(): string;
|
|
16
|
+
get orderTypeId(): number;
|
|
24
17
|
abstract readonly owner: Unit | Item;
|
|
25
18
|
getSnapshot(): AbilitySnapshot;
|
|
26
19
|
hasField(field: jabilityfield | number): boolean;
|
|
@@ -40,9 +33,11 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
40
33
|
setField(field: jabilityintegerlevelfield | jabilityreallevelfield, level: number, value: number): boolean;
|
|
41
34
|
setField(field: jabilitybooleanlevelfield, level: number, value: boolean): boolean;
|
|
42
35
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
43
|
-
get
|
|
44
|
-
get levels(): readonly AbilityLevel[];
|
|
36
|
+
get levelCount(): number;
|
|
45
37
|
abstract get level(): number;
|
|
38
|
+
abstract get cooldownRemaining(): number;
|
|
39
|
+
abstract set cooldownRemaining(cooldownRemaining: number);
|
|
40
|
+
abstract interruptCast(): void;
|
|
46
41
|
static get onCreate(): Event<[Ability]>;
|
|
47
42
|
static get destroyEvent(): Event<[Ability]>;
|
|
48
43
|
}
|
|
@@ -53,15 +48,26 @@ export declare class UnrecognizedAbility extends Ability {
|
|
|
53
48
|
readonly owner: Unit;
|
|
54
49
|
constructor(typeId: number, owner: Unit);
|
|
55
50
|
get level(): number;
|
|
51
|
+
get cooldownRemaining(): number;
|
|
52
|
+
set cooldownRemaining(_: number);
|
|
53
|
+
interruptCast(): void;
|
|
56
54
|
}
|
|
57
55
|
export declare class UnitAbility extends Ability {
|
|
58
56
|
readonly owner: Unit;
|
|
59
57
|
private readonly u;
|
|
58
|
+
private d?;
|
|
60
59
|
constructor(handle: jability, typeId: number, owner: Unit);
|
|
60
|
+
incrementHideCounter(): void;
|
|
61
|
+
decrementHideCounter(): void;
|
|
62
|
+
incrementDisableCounter(): void;
|
|
63
|
+
decrementDisableCounter(): void;
|
|
64
|
+
get isDisabled(): boolean;
|
|
61
65
|
get level(): number;
|
|
62
66
|
set level(v: number);
|
|
63
67
|
get cooldownRemaining(): number;
|
|
64
|
-
set cooldownRemaining(
|
|
68
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
69
|
+
interruptCast(): void;
|
|
70
|
+
protected onDestroy(): HandleDestructor;
|
|
65
71
|
static get onCreate(): Event<[UnitAbility]>;
|
|
66
72
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
67
73
|
}
|
|
@@ -85,7 +91,10 @@ export declare class ItemAbility extends Ability {
|
|
|
85
91
|
setField(field: jabilitybooleanlevelfield, level: number, value: boolean): boolean;
|
|
86
92
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
87
93
|
get level(): number;
|
|
94
|
+
get cooldownRemaining(): number;
|
|
95
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
96
|
+
interruptCast(): void;
|
|
97
|
+
protected onDestroy(): HandleDestructor;
|
|
88
98
|
static get onCreate(): Event<[ItemAbility]>;
|
|
89
99
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
90
100
|
}
|
|
91
|
-
export {};
|
|
@@ -2,7 +2,6 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
3
3
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
4
4
|
local __TS__Class = ____lualib.__TS__Class
|
|
5
|
-
local __TS__New = ____lualib.__TS__New
|
|
6
5
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
7
6
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
8
7
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
@@ -11,7 +10,11 @@ local ____exports = {}
|
|
|
11
10
|
local ____handle = require("core.types.handle")
|
|
12
11
|
local Handle = ____handle.Handle
|
|
13
12
|
local ____ability = require("engine.internal.item.ability")
|
|
13
|
+
local abilityActionDummy = ____ability.abilityActionDummy
|
|
14
14
|
local doAbilityAction = ____ability.doAbilityAction
|
|
15
|
+
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
16
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
17
|
+
local startItemCooldown = ____ability.startItemCooldown
|
|
15
18
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
16
19
|
local setUnitAbilityLevel = SetUnitAbilityLevel
|
|
17
20
|
local setAbilityIntegerField = BlzSetAbilityIntegerField
|
|
@@ -33,7 +36,12 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
|
|
|
33
36
|
local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
|
|
34
37
|
local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
|
|
35
38
|
local getHandleId = GetHandleId
|
|
36
|
-
local
|
|
39
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
40
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
41
|
+
local unitHideAbility = BlzUnitHideAbility
|
|
42
|
+
local unitDisableAbility = BlzUnitDisableAbility
|
|
43
|
+
local unitRemoveAbility = UnitRemoveAbility
|
|
44
|
+
local itemRemoveAbility = BlzItemRemoveAbility
|
|
37
45
|
local match = string.match
|
|
38
46
|
local ____type = _G.type
|
|
39
47
|
local ____tostring = _G.tostring
|
|
@@ -151,55 +159,6 @@ local orders = postcompile(function()
|
|
|
151
159
|
end
|
|
152
160
|
return orders
|
|
153
161
|
end)
|
|
154
|
-
local RealFields = __TS__Class()
|
|
155
|
-
RealFields.name = "RealFields"
|
|
156
|
-
function RealFields.prototype.____constructor(self, handle)
|
|
157
|
-
self.handle = handle
|
|
158
|
-
end
|
|
159
|
-
function RealFields.prototype.set(self, field, value)
|
|
160
|
-
return BlzSetAbilityRealField(self.handle, field, value)
|
|
161
|
-
end
|
|
162
|
-
function RealFields.prototype.get(self, field)
|
|
163
|
-
return BlzGetAbilityRealField(self.handle, field)
|
|
164
|
-
end
|
|
165
|
-
function RealFields.prototype.has(self, field)
|
|
166
|
-
local handle = self.handle
|
|
167
|
-
return BlzSetAbilityRealField(
|
|
168
|
-
handle,
|
|
169
|
-
field,
|
|
170
|
-
BlzGetAbilityRealField(handle, field)
|
|
171
|
-
)
|
|
172
|
-
end
|
|
173
|
-
local RealLevelFields = __TS__Class()
|
|
174
|
-
RealLevelFields.name = "RealLevelFields"
|
|
175
|
-
function RealLevelFields.prototype.____constructor(self, handle, level)
|
|
176
|
-
self.handle = handle
|
|
177
|
-
self.level = level
|
|
178
|
-
end
|
|
179
|
-
function RealLevelFields.prototype.set(self, field, value)
|
|
180
|
-
return BlzSetAbilityRealLevelField(self.handle, field, self.level, value)
|
|
181
|
-
end
|
|
182
|
-
function RealLevelFields.prototype.get(self, field)
|
|
183
|
-
return BlzGetAbilityRealLevelField(self.handle, field, self.level)
|
|
184
|
-
end
|
|
185
|
-
function RealLevelFields.prototype.has(self, field)
|
|
186
|
-
local handle = self.handle
|
|
187
|
-
return BlzSetAbilityRealLevelField(
|
|
188
|
-
handle,
|
|
189
|
-
field,
|
|
190
|
-
0,
|
|
191
|
-
BlzGetAbilityRealLevelField(handle, field, 0)
|
|
192
|
-
)
|
|
193
|
-
end
|
|
194
|
-
local realLevelMetatable = {__index = self}
|
|
195
|
-
local levelDescriptors = {realFields = function(self, handle, level)
|
|
196
|
-
return __TS__New(RealLevelFields, handle, level)
|
|
197
|
-
end}
|
|
198
|
-
local levelMetatable = {__index = function(self, key)
|
|
199
|
-
local fields = levelDescriptors[key](levelDescriptors, self.handle, self.level)
|
|
200
|
-
rawset(self, key, fields)
|
|
201
|
-
return fields
|
|
202
|
-
end}
|
|
203
162
|
local fieldGetters = {
|
|
204
163
|
abilityintegerfield = function(ability, field)
|
|
205
164
|
return getAbilityIntegerField(ability.handle, field)
|
|
@@ -276,6 +235,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
|
|
|
276
235
|
local parentTypeId = availableFields[abilityTypeId]
|
|
277
236
|
return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
|
|
278
237
|
end
|
|
238
|
+
---
|
|
239
|
+
-- @internal For use by internal systems only.
|
|
240
|
+
____exports.abilityTypeHasField = function(abilityTypeId, field)
|
|
241
|
+
field = ____type(field) == "number" and field or getHandleId(field)
|
|
242
|
+
if commonFields[field] then
|
|
243
|
+
return true
|
|
244
|
+
end
|
|
245
|
+
local id = availableFields[abilityTypeId]
|
|
246
|
+
if ____type(id) == "number" then
|
|
247
|
+
id = availableFields[id]
|
|
248
|
+
end
|
|
249
|
+
return not not (id and id[field])
|
|
250
|
+
end
|
|
279
251
|
____exports.Ability = __TS__Class()
|
|
280
252
|
local Ability = ____exports.Ability
|
|
281
253
|
Ability.name = "Ability"
|
|
@@ -291,15 +263,7 @@ function Ability.prototype.getSnapshot(self)
|
|
|
291
263
|
return nil
|
|
292
264
|
end
|
|
293
265
|
function Ability.prototype.hasField(self, field)
|
|
294
|
-
|
|
295
|
-
if commonFields[field] then
|
|
296
|
-
return true
|
|
297
|
-
end
|
|
298
|
-
local id = availableFields[self.typeId]
|
|
299
|
-
if ____type(id) == "number" then
|
|
300
|
-
id = availableFields[id]
|
|
301
|
-
end
|
|
302
|
-
return not not (id and id[field])
|
|
266
|
+
return ____exports.abilityTypeHasField(self.typeId, field)
|
|
303
267
|
end
|
|
304
268
|
function Ability.prototype.getField(self, field, level)
|
|
305
269
|
local fieldType = match(
|
|
@@ -346,43 +310,26 @@ __TS__SetDescriptor(
|
|
|
346
310
|
)
|
|
347
311
|
__TS__SetDescriptor(
|
|
348
312
|
Ability.prototype,
|
|
349
|
-
"
|
|
313
|
+
"orderTypeStringId",
|
|
350
314
|
{get = function(self)
|
|
351
315
|
local field = orderIdFieldByParentTypeId[self.parentTypeId]
|
|
352
|
-
return
|
|
316
|
+
return field ~= nil and getAbilityStringLevelField(self.handle, field, self.level) or (orders[self.parentTypeId] or "")
|
|
353
317
|
end},
|
|
354
318
|
true
|
|
355
319
|
)
|
|
356
320
|
__TS__SetDescriptor(
|
|
357
321
|
Ability.prototype,
|
|
358
|
-
"
|
|
322
|
+
"orderTypeId",
|
|
359
323
|
{get = function(self)
|
|
360
|
-
|
|
361
|
-
rawset(self, "realFields", realFields)
|
|
362
|
-
return realFields
|
|
324
|
+
return order2orderId(self.orderTypeStringId)
|
|
363
325
|
end},
|
|
364
326
|
true
|
|
365
327
|
)
|
|
366
328
|
__TS__SetDescriptor(
|
|
367
329
|
Ability.prototype,
|
|
368
|
-
"
|
|
330
|
+
"levelCount",
|
|
369
331
|
{get = function(self)
|
|
370
|
-
|
|
371
|
-
local levels = setmetatable(
|
|
372
|
-
{},
|
|
373
|
-
{
|
|
374
|
-
__len = function(self)
|
|
375
|
-
return BlzGetAbilityIntegerField(handle, ABILITY_IF_LEVELS)
|
|
376
|
-
end,
|
|
377
|
-
__index = function(self, i)
|
|
378
|
-
local level = setmetatable({handle = handle, level = i - 1}, levelMetatable)
|
|
379
|
-
self[i] = level
|
|
380
|
-
return level
|
|
381
|
-
end
|
|
382
|
-
}
|
|
383
|
-
)
|
|
384
|
-
rawset(self, "levels", levels)
|
|
385
|
-
return levels
|
|
332
|
+
return self:getField(ABILITY_IF_LEVELS)
|
|
386
333
|
end},
|
|
387
334
|
true
|
|
388
335
|
)
|
|
@@ -393,6 +340,17 @@ __TS__SetDescriptor(
|
|
|
393
340
|
end},
|
|
394
341
|
true
|
|
395
342
|
)
|
|
343
|
+
__TS__SetDescriptor(
|
|
344
|
+
Ability.prototype,
|
|
345
|
+
"cooldownRemaining",
|
|
346
|
+
{
|
|
347
|
+
get = function(self)
|
|
348
|
+
end,
|
|
349
|
+
set = function(self, cooldownRemaining)
|
|
350
|
+
end
|
|
351
|
+
},
|
|
352
|
+
true
|
|
353
|
+
)
|
|
396
354
|
__TS__ObjectDefineProperty(
|
|
397
355
|
Ability,
|
|
398
356
|
"onCreate",
|
|
@@ -416,6 +374,8 @@ function UnrecognizedAbility.prototype.____constructor(self, typeId, owner)
|
|
|
416
374
|
UnrecognizedAbility.____super.prototype.____constructor(self, nil, typeId)
|
|
417
375
|
self.owner = owner
|
|
418
376
|
end
|
|
377
|
+
function UnrecognizedAbility.prototype.interruptCast(self)
|
|
378
|
+
end
|
|
419
379
|
__TS__SetDescriptor(
|
|
420
380
|
UnrecognizedAbility.prototype,
|
|
421
381
|
"level",
|
|
@@ -424,6 +384,18 @@ __TS__SetDescriptor(
|
|
|
424
384
|
end},
|
|
425
385
|
true
|
|
426
386
|
)
|
|
387
|
+
__TS__SetDescriptor(
|
|
388
|
+
UnrecognizedAbility.prototype,
|
|
389
|
+
"cooldownRemaining",
|
|
390
|
+
{
|
|
391
|
+
get = function(self)
|
|
392
|
+
return 0
|
|
393
|
+
end,
|
|
394
|
+
set = function(self, _)
|
|
395
|
+
end
|
|
396
|
+
},
|
|
397
|
+
true
|
|
398
|
+
)
|
|
427
399
|
____exports.UnitAbility = __TS__Class()
|
|
428
400
|
local UnitAbility = ____exports.UnitAbility
|
|
429
401
|
UnitAbility.name = "UnitAbility"
|
|
@@ -433,6 +405,41 @@ function UnitAbility.prototype.____constructor(self, handle, typeId, owner)
|
|
|
433
405
|
self.owner = owner
|
|
434
406
|
self.u = owner.handle
|
|
435
407
|
end
|
|
408
|
+
function UnitAbility.prototype.incrementHideCounter(self)
|
|
409
|
+
unitHideAbility(self.u, self.typeId, true)
|
|
410
|
+
end
|
|
411
|
+
function UnitAbility.prototype.decrementHideCounter(self)
|
|
412
|
+
unitHideAbility(self.u, self.typeId, false)
|
|
413
|
+
end
|
|
414
|
+
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
415
|
+
local unit = self.u
|
|
416
|
+
local typeId = self.typeId
|
|
417
|
+
unitHideAbility(unit, typeId, true)
|
|
418
|
+
unitDisableAbility(unit, typeId, true, false)
|
|
419
|
+
self.d = (self.d or 0) + 1
|
|
420
|
+
end
|
|
421
|
+
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
422
|
+
local unit = self.u
|
|
423
|
+
local typeId = self.typeId
|
|
424
|
+
unitDisableAbility(unit, typeId, false, false)
|
|
425
|
+
unitHideAbility(unit, typeId, true)
|
|
426
|
+
self.d = (self.d or 0) - 1
|
|
427
|
+
end
|
|
428
|
+
function UnitAbility.prototype.interruptCast(self)
|
|
429
|
+
self.owner:interruptCast(self.typeId)
|
|
430
|
+
end
|
|
431
|
+
function UnitAbility.prototype.onDestroy(self)
|
|
432
|
+
doUnitAbilityAction(self.owner.handle, self.typeId, unitRemoveAbility, self.typeId)
|
|
433
|
+
return UnitAbility.____super.prototype.onDestroy(self)
|
|
434
|
+
end
|
|
435
|
+
__TS__SetDescriptor(
|
|
436
|
+
UnitAbility.prototype,
|
|
437
|
+
"isDisabled",
|
|
438
|
+
{get = function(self)
|
|
439
|
+
return self.d ~= nil and self.d > 0
|
|
440
|
+
end},
|
|
441
|
+
true
|
|
442
|
+
)
|
|
436
443
|
__TS__SetDescriptor(
|
|
437
444
|
UnitAbility.prototype,
|
|
438
445
|
"level",
|
|
@@ -453,8 +460,8 @@ __TS__SetDescriptor(
|
|
|
453
460
|
get = function(self)
|
|
454
461
|
return getUnitAbilityCooldownRemaining(self.u, self.typeId)
|
|
455
462
|
end,
|
|
456
|
-
set = function(self,
|
|
457
|
-
startUnitAbilityCooldown(self.u, self.typeId,
|
|
463
|
+
set = function(self, cooldownRemaining)
|
|
464
|
+
startUnitAbilityCooldown(self.u, self.typeId, cooldownRemaining)
|
|
458
465
|
end
|
|
459
466
|
},
|
|
460
467
|
true
|
|
@@ -479,6 +486,9 @@ end
|
|
|
479
486
|
local function setAbilityField(_, ability, field, levelOrValue, value)
|
|
480
487
|
return ____exports.Ability.prototype.setField(ability, field, levelOrValue, value)
|
|
481
488
|
end
|
|
489
|
+
local function getAbilityCooldown(_, abilityTypeId)
|
|
490
|
+
return getUnitAbilityCooldownRemaining(abilityActionDummy, abilityTypeId)
|
|
491
|
+
end
|
|
482
492
|
____exports.ItemAbility = __TS__Class()
|
|
483
493
|
local ItemAbility = ____exports.ItemAbility
|
|
484
494
|
ItemAbility.name = "ItemAbility"
|
|
@@ -506,6 +516,18 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
|
|
|
506
516
|
value
|
|
507
517
|
)
|
|
508
518
|
end
|
|
519
|
+
function ItemAbility.prototype.interruptCast(self)
|
|
520
|
+
local handle = self.owner.handle
|
|
521
|
+
local activelyUsed = getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED)
|
|
522
|
+
if activelyUsed then
|
|
523
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, false)
|
|
524
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
function ItemAbility.prototype.onDestroy(self)
|
|
528
|
+
doAbilityAction(self.owner.handle, itemRemoveAbility, self.typeId)
|
|
529
|
+
return ItemAbility.____super.prototype.onDestroy(self)
|
|
530
|
+
end
|
|
509
531
|
__TS__SetDescriptor(
|
|
510
532
|
ItemAbility.prototype,
|
|
511
533
|
"level",
|
|
@@ -514,6 +536,27 @@ __TS__SetDescriptor(
|
|
|
514
536
|
end},
|
|
515
537
|
true
|
|
516
538
|
)
|
|
539
|
+
__TS__SetDescriptor(
|
|
540
|
+
ItemAbility.prototype,
|
|
541
|
+
"cooldownRemaining",
|
|
542
|
+
{
|
|
543
|
+
get = function(self)
|
|
544
|
+
local item = self.owner
|
|
545
|
+
local ____doAbilityActionForceDummy_4 = doAbilityActionForceDummy
|
|
546
|
+
local ____item_handle_3 = item.handle
|
|
547
|
+
local ____opt_1 = item.owner
|
|
548
|
+
return ____doAbilityActionForceDummy_4(____item_handle_3, ____opt_1 and ____opt_1.handle, getAbilityCooldown, self.typeId)
|
|
549
|
+
end,
|
|
550
|
+
set = function(self, cooldownRemaining)
|
|
551
|
+
local item = self.owner
|
|
552
|
+
local ____startItemCooldown_8 = startItemCooldown
|
|
553
|
+
local ____item_handle_7 = item.handle
|
|
554
|
+
local ____opt_5 = item.owner
|
|
555
|
+
____startItemCooldown_8(____item_handle_7, ____opt_5 and ____opt_5.handle, cooldownRemaining)
|
|
556
|
+
end
|
|
557
|
+
},
|
|
558
|
+
true
|
|
559
|
+
)
|
|
517
560
|
__TS__ObjectDefineProperty(
|
|
518
561
|
ItemAbility,
|
|
519
562
|
"onCreate",
|
|
@@ -1,27 +1,103 @@
|
|
|
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
|
|
23
|
+
local getItemAbility = BlzGetItemAbility
|
|
8
24
|
local getItemX = GetItemX
|
|
9
25
|
local getItemY = GetItemY
|
|
26
|
+
local setAbilityRealLevelField = BlzSetAbilityRealLevelField
|
|
27
|
+
local setItemIntegerField = BlzSetItemIntegerField
|
|
28
|
+
local getItemIntegerField = BlzGetItemIntegerField
|
|
10
29
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
11
30
|
local setItemPosition = SetItemPosition
|
|
12
31
|
local unitAddItem = UnitAddItem
|
|
13
32
|
local unitRemoveItem = UnitRemoveItem
|
|
14
|
-
local
|
|
33
|
+
local unitUseItem = UnitUseItem
|
|
34
|
+
local unitResetCooldown = UnitResetCooldown
|
|
35
|
+
local unitInventorySize = UnitInventorySize
|
|
36
|
+
local unitItemInSlot = UnitItemInSlot
|
|
37
|
+
local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
|
|
38
|
+
if not currentMap then
|
|
39
|
+
return 0
|
|
40
|
+
end
|
|
41
|
+
local abilityType = currentMap.objects.ability:newObject(
|
|
42
|
+
util.id2s(abilityTypeIdGenerator:next()),
|
|
43
|
+
"Absk"
|
|
44
|
+
)
|
|
45
|
+
abilityType["bsk1+0"] = 0
|
|
46
|
+
abilityType["bsk2+0"] = 0
|
|
47
|
+
abilityType["bsk3+0"] = 0
|
|
48
|
+
abilityType["amcs+0"] = 0
|
|
49
|
+
abilityType["adur+0"] = MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
50
|
+
abilityType["ahdu+0"] = MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
51
|
+
return util.s2id(abilityType.id)
|
|
52
|
+
end)
|
|
53
|
+
local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
|
|
54
|
+
local itemType = BlankItemType:create()
|
|
55
|
+
itemType.name = "[Warscript/Dummy] Item Cooldown Starter"
|
|
56
|
+
itemType.abilityTypeIds = {COOLDOWN_STARTER_ABILITY_TYPE_ID}
|
|
57
|
+
itemType.cooldownGroupId = COOLDOWN_STARTER_ABILITY_TYPE_ID
|
|
58
|
+
itemType.activelyUsed = true
|
|
59
|
+
return itemType.id
|
|
60
|
+
end)
|
|
61
|
+
---
|
|
62
|
+
-- @internal For use by internal systems only.
|
|
63
|
+
____exports.itemAbilityDummy = assert(CreateUnit(
|
|
15
64
|
Player.neutralVictim.handle,
|
|
16
65
|
dummyUnitId,
|
|
17
66
|
0,
|
|
18
67
|
0,
|
|
19
68
|
270
|
|
20
69
|
))
|
|
21
|
-
|
|
70
|
+
local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
71
|
+
local cooldownStarterAbility = getItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
72
|
+
ShowUnit(____exports.itemAbilityDummy, false)
|
|
73
|
+
local function startItemCooldownInternal(handle, cooldown)
|
|
74
|
+
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
75
|
+
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
76
|
+
setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
|
|
77
|
+
unitResetCooldown(____exports.itemAbilityDummy)
|
|
78
|
+
unitUseItem(____exports.itemAbilityDummy, cooldownStarterItem)
|
|
79
|
+
Timer:run(restoreCooldownGroup, handle, cooldownGroup)
|
|
80
|
+
end
|
|
81
|
+
restoreCooldownGroup = function(handle, cooldownGroup)
|
|
82
|
+
if getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP) == COOLDOWN_STARTER_ABILITY_TYPE_ID then
|
|
83
|
+
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, cooldownGroup)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
---
|
|
87
|
+
-- @internal For use by internal systems only.
|
|
88
|
+
____exports.startItemCooldown = function(handle, owner, cooldown)
|
|
89
|
+
____exports.doAbilityActionForceDummy(handle, owner, startItemCooldownInternal, cooldown)
|
|
90
|
+
end
|
|
91
|
+
---
|
|
92
|
+
-- @internal For use by internal systems only.
|
|
93
|
+
____exports.abilityActionDummy = ____exports.itemAbilityDummy
|
|
22
94
|
---
|
|
23
95
|
-- @internal For use by internal systems only.
|
|
24
96
|
____exports.doAbilityAction = function(handle, action, ...)
|
|
97
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
|
|
98
|
+
if not isAlreadyIgnoredInEvents then
|
|
99
|
+
ignoreEventsItems[handle] = true
|
|
100
|
+
end
|
|
25
101
|
local isOwned = isItemOwned(handle)
|
|
26
102
|
local isPowerup
|
|
27
103
|
local x
|
|
@@ -33,16 +109,98 @@ ____exports.doAbilityAction = function(handle, action, ...)
|
|
|
33
109
|
end
|
|
34
110
|
x = getItemX(handle)
|
|
35
111
|
y = getItemY(handle)
|
|
36
|
-
unitAddItem(
|
|
112
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
37
113
|
end
|
|
38
114
|
local result = action(handle, ...)
|
|
39
115
|
if not isOwned then
|
|
40
|
-
unitRemoveItem(
|
|
116
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
41
117
|
setItemPosition(handle, x, y)
|
|
42
118
|
if isPowerup then
|
|
43
119
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
44
120
|
end
|
|
45
121
|
end
|
|
122
|
+
if not isAlreadyIgnoredInEvents then
|
|
123
|
+
ignoreEventsItems[handle] = nil
|
|
124
|
+
end
|
|
125
|
+
return result
|
|
126
|
+
end
|
|
127
|
+
---
|
|
128
|
+
-- @internal For use by internal systems only.
|
|
129
|
+
____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
130
|
+
if owner == nil then
|
|
131
|
+
return ____exports.doAbilityAction(handle, action, ...)
|
|
132
|
+
end
|
|
133
|
+
local slot = findUnitItemSlot(owner, handle)
|
|
134
|
+
if slot == nil then
|
|
135
|
+
return ____exports.doAbilityAction(handle, action, ...)
|
|
136
|
+
end
|
|
137
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
|
|
138
|
+
if not isAlreadyIgnoredInEvents then
|
|
139
|
+
ignoreEventsItems[handle] = true
|
|
140
|
+
end
|
|
141
|
+
local isPowerup
|
|
142
|
+
if isItemPowerup(handle) then
|
|
143
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
144
|
+
isPowerup = true
|
|
145
|
+
end
|
|
146
|
+
unitRemoveItem(owner, handle)
|
|
147
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
148
|
+
local result = action(handle, ...)
|
|
149
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
150
|
+
unitAddItemToSlot(owner, handle, slot)
|
|
151
|
+
if isPowerup then
|
|
152
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
153
|
+
end
|
|
154
|
+
if not isAlreadyIgnoredInEvents then
|
|
155
|
+
ignoreEventsItems[handle] = nil
|
|
156
|
+
end
|
|
157
|
+
return result
|
|
158
|
+
end
|
|
159
|
+
local depth = 0
|
|
160
|
+
local itemBySlot = {}
|
|
161
|
+
---
|
|
162
|
+
-- @internal For use by internal systems only.
|
|
163
|
+
____exports.doUnitAbilityAction = function(unit, abilityTypeId, action, ...)
|
|
164
|
+
local ____depth_0 = depth
|
|
165
|
+
depth = ____depth_0 + 1
|
|
166
|
+
local offset = 6 * ____depth_0
|
|
167
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
168
|
+
local item = unitItemInSlot(unit, slot)
|
|
169
|
+
if getItemAbility(item, abilityTypeId) ~= nil then
|
|
170
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
|
|
171
|
+
if not isAlreadyIgnoredInEvents then
|
|
172
|
+
ignoreEventsItems[item] = true
|
|
173
|
+
end
|
|
174
|
+
unitRemoveItem(unit, item)
|
|
175
|
+
if not isAlreadyIgnoredInEvents then
|
|
176
|
+
ignoreEventsItems[item] = nil
|
|
177
|
+
end
|
|
178
|
+
itemBySlot[offset + slot] = item
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
local result = action(unit, ...)
|
|
182
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
183
|
+
local item = itemBySlot[offset + slot]
|
|
184
|
+
if item ~= nil then
|
|
185
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
|
|
186
|
+
if not isAlreadyIgnoredInEvents then
|
|
187
|
+
ignoreEventsItems[item] = true
|
|
188
|
+
end
|
|
189
|
+
local isPowerup = isItemPowerup(item)
|
|
190
|
+
if isPowerup then
|
|
191
|
+
setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
192
|
+
end
|
|
193
|
+
unitAddItemToSlot(unit, item, slot)
|
|
194
|
+
if isPowerup then
|
|
195
|
+
setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
196
|
+
end
|
|
197
|
+
if not isAlreadyIgnoredInEvents then
|
|
198
|
+
ignoreEventsItems[item] = nil
|
|
199
|
+
end
|
|
200
|
+
itemBySlot[offset + slot] = nil
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
depth = depth - 1
|
|
46
204
|
return result
|
|
47
205
|
end
|
|
48
206
|
return ____exports
|
|
@@ -6,12 +6,18 @@ local Item = ____item.Item
|
|
|
6
6
|
local ____unit = require("engine.internal.unit")
|
|
7
7
|
local Unit = ____unit.Unit
|
|
8
8
|
local ownerByItem = setmetatable({}, {__mode = "kv"})
|
|
9
|
-
Unit.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
Unit.itemPickedUpEvent:addListener(
|
|
10
|
+
4,
|
|
11
|
+
function(unit, item)
|
|
12
|
+
ownerByItem[item] = unit
|
|
13
|
+
end
|
|
14
|
+
)
|
|
15
|
+
Unit.itemDroppedEvent:addListener(
|
|
16
|
+
4,
|
|
17
|
+
function(unit, item)
|
|
18
|
+
ownerByItem[item] = nil
|
|
19
|
+
end
|
|
20
|
+
)
|
|
15
21
|
__TS__ObjectDefineProperty(
|
|
16
22
|
Item.prototype,
|
|
17
23
|
"owner",
|