warscript 0.0.1-dev.ee2345e → 0.0.1-dev.ee6e396
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 +6 -1
- package/attributes.lua +17 -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 +117 -22
- package/core/types/group.d.ts +0 -1
- package/core/types/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +60 -15
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +9 -8
- package/core/types/timer.lua +45 -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 +846 -790
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +24 -11
- package/engine/behavior.lua +233 -73
- 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 +36 -4
- 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 -15
- 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 +25 -0
- package/engine/behaviour/ability/remove-buffs.lua +49 -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 +33 -5
- package/engine/behaviour/ability.lua +183 -27
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -7
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +48 -4
- package/engine/behaviour/unit.lua +292 -2
- package/engine/buff.d.ts +121 -46
- package/engine/buff.lua +567 -248
- 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 +129 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +20 -19
- package/engine/internal/item.lua +191 -74
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +45 -1
- package/engine/internal/unit/ability.lua +128 -17
- 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/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +13 -8
- package/engine/internal/unit/bonus.lua +33 -1
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -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/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -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 +36 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -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 +70 -13
- package/engine/internal/unit.d.ts +97 -36
- package/engine/internal/unit.lua +701 -336
- 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 +9 -2
- package/engine/local-client.lua +112 -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/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -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.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/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -0
- 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/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- 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 +93 -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 +28 -3
- package/engine/object-data/entry/destructible-type.lua +155 -0
- 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 +62 -7
- package/engine/object-data/entry/unit-type.lua +524 -75
- 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 +72 -3
- package/engine/object-field/unit.lua +268 -7
- package/engine/object-field.d.ts +25 -7
- package/engine/object-field.lua +359 -116
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +22 -0
- 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/entries/unit-type.d.ts +39 -1
- package/engine/standard/entries/unit-type.lua +39 -1
- package/engine/standard/fields/ability.d.ts +5 -3
- package/engine/standard/fields/ability.lua +5 -3
- package/engine/standard/fields/unit.d.ts +12 -0
- package/engine/standard/fields/unit.lua +20 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +250 -10
- package/engine/unit.d.ts +9 -0
- package/engine/unit.lua +18 -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 +12 -11
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/objutil/unit.lua +8 -0
- package/package.json +13 -14
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +25 -0
- package/patch-lualib.lua +1 -1
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +30 -0
- package/string.lua +14 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +13 -5
- package/utility/arrays.lua +45 -3
- package/utility/bit-set.d.ts +0 -2
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -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-map.d.ts +34 -0
- package/utility/linked-map.lua +101 -0
- package/utility/linked-set.d.ts +15 -4
- package/utility/linked-set.lua +48 -3
- package/utility/lua-maps.d.ts +16 -4
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +3 -2
- package/utility/lua-sets.lua +7 -0
- package/utility/records.lua +20 -1
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +4 -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,10 @@ 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 startItemCooldown = ____ability.startItemCooldown
|
|
15
17
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
16
18
|
local setUnitAbilityLevel = SetUnitAbilityLevel
|
|
17
19
|
local setAbilityIntegerField = BlzSetAbilityIntegerField
|
|
@@ -33,7 +35,10 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
|
|
|
33
35
|
local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
|
|
34
36
|
local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
|
|
35
37
|
local getHandleId = GetHandleId
|
|
36
|
-
local
|
|
38
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
39
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
40
|
+
local unitHideAbility = BlzUnitHideAbility
|
|
41
|
+
local unitDisableAbility = BlzUnitDisableAbility
|
|
37
42
|
local match = string.match
|
|
38
43
|
local ____type = _G.type
|
|
39
44
|
local ____tostring = _G.tostring
|
|
@@ -151,55 +156,6 @@ local orders = postcompile(function()
|
|
|
151
156
|
end
|
|
152
157
|
return orders
|
|
153
158
|
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
159
|
local fieldGetters = {
|
|
204
160
|
abilityintegerfield = function(ability, field)
|
|
205
161
|
return getAbilityIntegerField(ability.handle, field)
|
|
@@ -276,6 +232,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
|
|
|
276
232
|
local parentTypeId = availableFields[abilityTypeId]
|
|
277
233
|
return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
|
|
278
234
|
end
|
|
235
|
+
---
|
|
236
|
+
-- @internal For use by internal systems only.
|
|
237
|
+
____exports.abilityTypeHasField = function(abilityTypeId, field)
|
|
238
|
+
field = ____type(field) == "number" and field or getHandleId(field)
|
|
239
|
+
if commonFields[field] then
|
|
240
|
+
return true
|
|
241
|
+
end
|
|
242
|
+
local id = availableFields[abilityTypeId]
|
|
243
|
+
if ____type(id) == "number" then
|
|
244
|
+
id = availableFields[id]
|
|
245
|
+
end
|
|
246
|
+
return not not (id and id[field])
|
|
247
|
+
end
|
|
279
248
|
____exports.Ability = __TS__Class()
|
|
280
249
|
local Ability = ____exports.Ability
|
|
281
250
|
Ability.name = "Ability"
|
|
@@ -291,15 +260,7 @@ function Ability.prototype.getSnapshot(self)
|
|
|
291
260
|
return nil
|
|
292
261
|
end
|
|
293
262
|
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])
|
|
263
|
+
return ____exports.abilityTypeHasField(self.typeId, field)
|
|
303
264
|
end
|
|
304
265
|
function Ability.prototype.getField(self, field, level)
|
|
305
266
|
local fieldType = match(
|
|
@@ -346,43 +307,26 @@ __TS__SetDescriptor(
|
|
|
346
307
|
)
|
|
347
308
|
__TS__SetDescriptor(
|
|
348
309
|
Ability.prototype,
|
|
349
|
-
"
|
|
310
|
+
"orderTypeStringId",
|
|
350
311
|
{get = function(self)
|
|
351
312
|
local field = orderIdFieldByParentTypeId[self.parentTypeId]
|
|
352
|
-
return
|
|
313
|
+
return field ~= nil and getAbilityStringLevelField(self.handle, field, self.level) or (orders[self.parentTypeId] or "")
|
|
353
314
|
end},
|
|
354
315
|
true
|
|
355
316
|
)
|
|
356
317
|
__TS__SetDescriptor(
|
|
357
318
|
Ability.prototype,
|
|
358
|
-
"
|
|
319
|
+
"orderTypeId",
|
|
359
320
|
{get = function(self)
|
|
360
|
-
|
|
361
|
-
rawset(self, "realFields", realFields)
|
|
362
|
-
return realFields
|
|
321
|
+
return order2orderId(self.orderTypeStringId)
|
|
363
322
|
end},
|
|
364
323
|
true
|
|
365
324
|
)
|
|
366
325
|
__TS__SetDescriptor(
|
|
367
326
|
Ability.prototype,
|
|
368
|
-
"
|
|
327
|
+
"levelCount",
|
|
369
328
|
{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
|
|
329
|
+
return self:getField(ABILITY_IF_LEVELS)
|
|
386
330
|
end},
|
|
387
331
|
true
|
|
388
332
|
)
|
|
@@ -393,6 +337,17 @@ __TS__SetDescriptor(
|
|
|
393
337
|
end},
|
|
394
338
|
true
|
|
395
339
|
)
|
|
340
|
+
__TS__SetDescriptor(
|
|
341
|
+
Ability.prototype,
|
|
342
|
+
"cooldownRemaining",
|
|
343
|
+
{
|
|
344
|
+
get = function(self)
|
|
345
|
+
end,
|
|
346
|
+
set = function(self, cooldownRemaining)
|
|
347
|
+
end
|
|
348
|
+
},
|
|
349
|
+
true
|
|
350
|
+
)
|
|
396
351
|
__TS__ObjectDefineProperty(
|
|
397
352
|
Ability,
|
|
398
353
|
"onCreate",
|
|
@@ -416,6 +371,8 @@ function UnrecognizedAbility.prototype.____constructor(self, typeId, owner)
|
|
|
416
371
|
UnrecognizedAbility.____super.prototype.____constructor(self, nil, typeId)
|
|
417
372
|
self.owner = owner
|
|
418
373
|
end
|
|
374
|
+
function UnrecognizedAbility.prototype.interruptCast(self)
|
|
375
|
+
end
|
|
419
376
|
__TS__SetDescriptor(
|
|
420
377
|
UnrecognizedAbility.prototype,
|
|
421
378
|
"level",
|
|
@@ -424,6 +381,18 @@ __TS__SetDescriptor(
|
|
|
424
381
|
end},
|
|
425
382
|
true
|
|
426
383
|
)
|
|
384
|
+
__TS__SetDescriptor(
|
|
385
|
+
UnrecognizedAbility.prototype,
|
|
386
|
+
"cooldownRemaining",
|
|
387
|
+
{
|
|
388
|
+
get = function(self)
|
|
389
|
+
return 0
|
|
390
|
+
end,
|
|
391
|
+
set = function(self, _)
|
|
392
|
+
end
|
|
393
|
+
},
|
|
394
|
+
true
|
|
395
|
+
)
|
|
427
396
|
____exports.UnitAbility = __TS__Class()
|
|
428
397
|
local UnitAbility = ____exports.UnitAbility
|
|
429
398
|
UnitAbility.name = "UnitAbility"
|
|
@@ -433,6 +402,43 @@ function UnitAbility.prototype.____constructor(self, handle, typeId, owner)
|
|
|
433
402
|
self.owner = owner
|
|
434
403
|
self.u = owner.handle
|
|
435
404
|
end
|
|
405
|
+
function UnitAbility.prototype.incrementHideCounter(self)
|
|
406
|
+
unitHideAbility(self.u, self.typeId, true)
|
|
407
|
+
end
|
|
408
|
+
function UnitAbility.prototype.decrementHideCounter(self)
|
|
409
|
+
unitHideAbility(self.u, self.typeId, false)
|
|
410
|
+
end
|
|
411
|
+
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
412
|
+
local unit = self.u
|
|
413
|
+
local typeId = self.typeId
|
|
414
|
+
unitHideAbility(unit, typeId, true)
|
|
415
|
+
unitDisableAbility(unit, typeId, true, false)
|
|
416
|
+
self.d = (self.d or 0) + 1
|
|
417
|
+
end
|
|
418
|
+
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
419
|
+
local unit = self.u
|
|
420
|
+
local typeId = self.typeId
|
|
421
|
+
unitDisableAbility(unit, typeId, false, false)
|
|
422
|
+
unitHideAbility(unit, typeId, true)
|
|
423
|
+
self.d = (self.d or 0) - 1
|
|
424
|
+
end
|
|
425
|
+
function UnitAbility.prototype.interruptCast(self)
|
|
426
|
+
self.owner:interruptCast(self.typeId)
|
|
427
|
+
end
|
|
428
|
+
function UnitAbility.prototype.onDestroy(self)
|
|
429
|
+
if self.owner.state ~= 2 then
|
|
430
|
+
self.owner:removeAbility(self.typeId)
|
|
431
|
+
end
|
|
432
|
+
return UnitAbility.____super.prototype.onDestroy(self)
|
|
433
|
+
end
|
|
434
|
+
__TS__SetDescriptor(
|
|
435
|
+
UnitAbility.prototype,
|
|
436
|
+
"isDisabled",
|
|
437
|
+
{get = function(self)
|
|
438
|
+
return self.d ~= nil and self.d > 0
|
|
439
|
+
end},
|
|
440
|
+
true
|
|
441
|
+
)
|
|
436
442
|
__TS__SetDescriptor(
|
|
437
443
|
UnitAbility.prototype,
|
|
438
444
|
"level",
|
|
@@ -453,8 +459,8 @@ __TS__SetDescriptor(
|
|
|
453
459
|
get = function(self)
|
|
454
460
|
return getUnitAbilityCooldownRemaining(self.u, self.typeId)
|
|
455
461
|
end,
|
|
456
|
-
set = function(self,
|
|
457
|
-
startUnitAbilityCooldown(self.u, self.typeId,
|
|
462
|
+
set = function(self, cooldownRemaining)
|
|
463
|
+
startUnitAbilityCooldown(self.u, self.typeId, cooldownRemaining)
|
|
458
464
|
end
|
|
459
465
|
},
|
|
460
466
|
true
|
|
@@ -479,6 +485,9 @@ end
|
|
|
479
485
|
local function setAbilityField(_, ability, field, levelOrValue, value)
|
|
480
486
|
return ____exports.Ability.prototype.setField(ability, field, levelOrValue, value)
|
|
481
487
|
end
|
|
488
|
+
local function getAbilityCooldown(_, abilityTypeId)
|
|
489
|
+
return getUnitAbilityCooldownRemaining(abilityActionDummy, abilityTypeId)
|
|
490
|
+
end
|
|
482
491
|
____exports.ItemAbility = __TS__Class()
|
|
483
492
|
local ItemAbility = ____exports.ItemAbility
|
|
484
493
|
ItemAbility.name = "ItemAbility"
|
|
@@ -506,6 +515,20 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
|
|
|
506
515
|
value
|
|
507
516
|
)
|
|
508
517
|
end
|
|
518
|
+
function ItemAbility.prototype.interruptCast(self)
|
|
519
|
+
local handle = self.owner.handle
|
|
520
|
+
local activelyUsed = getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED)
|
|
521
|
+
if activelyUsed then
|
|
522
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, false)
|
|
523
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
function ItemAbility.prototype.onDestroy(self)
|
|
527
|
+
if self.owner.state ~= 2 then
|
|
528
|
+
self.owner:removeAbility(self.typeId)
|
|
529
|
+
end
|
|
530
|
+
return ItemAbility.____super.prototype.onDestroy(self)
|
|
531
|
+
end
|
|
509
532
|
__TS__SetDescriptor(
|
|
510
533
|
ItemAbility.prototype,
|
|
511
534
|
"level",
|
|
@@ -514,6 +537,27 @@ __TS__SetDescriptor(
|
|
|
514
537
|
end},
|
|
515
538
|
true
|
|
516
539
|
)
|
|
540
|
+
__TS__SetDescriptor(
|
|
541
|
+
ItemAbility.prototype,
|
|
542
|
+
"cooldownRemaining",
|
|
543
|
+
{
|
|
544
|
+
get = function(self)
|
|
545
|
+
local item = self.owner
|
|
546
|
+
local ____doAbilityActionForceDummy_4 = doAbilityActionForceDummy
|
|
547
|
+
local ____item_handle_3 = item.handle
|
|
548
|
+
local ____opt_1 = item.owner
|
|
549
|
+
return ____doAbilityActionForceDummy_4(____item_handle_3, ____opt_1 and ____opt_1.handle, getAbilityCooldown, self.typeId)
|
|
550
|
+
end,
|
|
551
|
+
set = function(self, cooldownRemaining)
|
|
552
|
+
local item = self.owner
|
|
553
|
+
local ____startItemCooldown_8 = startItemCooldown
|
|
554
|
+
local ____item_handle_7 = item.handle
|
|
555
|
+
local ____opt_5 = item.owner
|
|
556
|
+
____startItemCooldown_8(____item_handle_7, ____opt_5 and ____opt_5.handle, cooldownRemaining)
|
|
557
|
+
end
|
|
558
|
+
},
|
|
559
|
+
true
|
|
560
|
+
)
|
|
517
561
|
__TS__ObjectDefineProperty(
|
|
518
562
|
ItemAbility,
|
|
519
563
|
"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",
|