warscript 0.0.1-dev.e1acea3 → 0.0.1-dev.e27e5b1
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 -0
- package/attributes.lua +17 -1
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +2 -3
- package/core/types/effect.lua +95 -48
- package/core/types/frame.d.ts +1 -0
- package/core/types/frame.lua +136 -58
- package/core/types/handle.lua +6 -9
- package/core/types/item.d.ts +1 -0
- package/core/types/item.lua +1 -0
- package/core/types/player.d.ts +18 -1
- package/core/types/player.lua +76 -26
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/playerColor.lua +4 -3
- package/core/types/sound.d.ts +18 -25
- package/core/types/sound.lua +113 -33
- 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.d.ts +4 -0
- package/core/types/unit.lua +4 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +12 -1
- package/decl/native.d.ts +1718 -964
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +14 -1
- package/engine/behavior.lua +230 -70
- 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 +36 -4
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +12 -3
- package/engine/behaviour/ability/damage.lua +33 -39
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +21 -6
- package/engine/behaviour/ability/on-command-impact.lua +7 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +13 -1
- package/engine/behaviour/ability/remove-buffs.lua +29 -2
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.d.ts +23 -6
- package/engine/behaviour/ability.lua +115 -22
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +41 -2
- package/engine/behaviour/unit.lua +270 -6
- package/engine/buff.d.ts +113 -53
- package/engine/buff.lua +544 -288
- package/engine/internal/ability.d.ts +22 -2
- package/engine/internal/ability.lua +151 -27
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item/fields.d.ts +12 -0
- package/engine/internal/item/fields.lua +33 -0
- package/engine/internal/item+owner.d.ts +1 -0
- package/engine/internal/item+owner.lua +19 -6
- package/engine/internal/item.d.ts +30 -18
- package/engine/internal/item.lua +292 -102
- 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.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/armor-bonus.d.ts +2 -0
- package/engine/internal/object-data/attribute-bonus.lua +2 -2
- 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/health-bonus.d.ts +2 -0
- package/engine/internal/object-data/health-bonus.lua +16 -0
- package/engine/internal/object-data/mana-bonus.d.ts +2 -0
- package/engine/internal/object-data/mana-bonus.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 +35 -0
- package/engine/internal/unit/ability.lua +113 -12
- 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/appearance.d.ts +15 -0
- package/engine/internal/unit/appearance.lua +85 -0
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bag.d.ts +18 -0
- package/engine/internal/unit/bag.lua +63 -0
- package/engine/internal/unit/bonus.d.ts +8 -0
- package/engine/internal/unit/bonus.lua +50 -3
- package/engine/internal/unit/buff.d.ts +2 -2
- package/engine/internal/unit/buff.lua +32 -17
- package/engine/internal/unit/equipment.d.ts +36 -0
- package/engine/internal/unit/equipment.lua +169 -0
- 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 → inventory.d.ts} +3 -3
- package/engine/internal/unit/inventory.lua +77 -0
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/pseudo-passive-abilities.d.ts +2 -0
- package/engine/internal/unit/pseudo-passive-abilities.lua +11 -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 +10 -1
- package/engine/internal/unit+bonus.lua +3 -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-missile-launch.lua +52 -14
- package/engine/internal/unit.d.ts +45 -26
- package/engine/internal/unit.lua +443 -274
- 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 +21 -0
- package/engine/local-client.lua +150 -7
- 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 -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/equipment-slot.d.ts +12 -0
- package/engine/object-data/auxiliary/equipment-slot.lua +2 -0
- package/engine/object-data/auxiliary/equipment-type.d.ts +13 -0
- package/engine/object-data/auxiliary/equipment-type.lua +2 -0
- 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/item-tag.d.ts +12 -0
- package/engine/object-data/auxiliary/item-tag.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/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/{armor-increase.d.ts → armor-bonus.d.ts} +3 -3
- package/engine/object-data/entry/ability-type/{armor-increase.lua → armor-bonus.lua} +9 -9
- 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 +3 -0
- package/engine/object-data/entry/ability-type/blank-configurable.lua +42 -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/health-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
- 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/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/reincarnation.d.ts +8 -0
- package/engine/object-data/entry/ability-type/reincarnation.lua +26 -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 +21 -17
- package/engine/object-data/entry/ability-type.lua +177 -40
- package/engine/object-data/entry/buff-type/applicable.lua +122 -137
- 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 +28 -2
- package/engine/object-data/entry/destructible-type.lua +155 -0
- 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 +25 -5
- package/engine/object-data/entry/unit-type.lua +258 -93
- 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 +12 -6
- package/engine/object-field/ability.lua +10 -6
- package/engine/object-field/item.d.ts +22 -0
- package/engine/object-field/item.lua +118 -0
- package/engine/object-field/unit.d.ts +72 -3
- package/engine/object-field/unit.lua +268 -7
- package/engine/object-field.d.ts +26 -7
- package/engine/object-field.lua +362 -117
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +21 -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/fields/ability.d.ts +4 -2
- package/engine/standard/fields/ability.lua +4 -2
- package/engine/standard/fields/item.d.ts +4 -0
- package/engine/standard/fields/item.lua +6 -0
- 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 +11 -1
- package/engine/unit.lua +11 -1
- package/event.d.ts +1 -1
- package/lualib_bundle.lua +1 -1
- package/math.d.ts +2 -0
- package/math.lua +14 -0
- package/net/socket.lua +1 -1
- package/network.lua +25 -1
- package/objutil/buff.lua +11 -10
- package/objutil/object.lua +1 -1
- package/objutil/unit.lua +8 -0
- package/operation.d.ts +8 -1
- package/operation.lua +38 -18
- package/package.json +5 -5
- package/patch-lua.lua +15 -0
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +2 -0
- package/utility/arrays.lua +11 -0
- 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/linked-map.d.ts +35 -0
- package/utility/linked-map.lua +107 -0
- package/utility/linked-set.d.ts +5 -1
- package/utility/linked-set.lua +49 -1
- package/utility/lua-maps.d.ts +15 -2
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/utility/random.d.ts +102 -0
- package/utility/random.lua +273 -0
- package/utility/records.lua +20 -1
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +3 -0
- package/utility/unordered-map.d.ts +27 -0
- package/utility/unordered-map.lua +99 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
- package/engine/internal/unit/item.lua +0 -84
- /package/engine/internal/{object-data/armor-increase.d.ts → misc/ability-disable-counter.d.ts} +0 -0
- /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
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";
|
|
@@ -35,6 +35,9 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
35
35
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
36
36
|
get levelCount(): number;
|
|
37
37
|
abstract get level(): number;
|
|
38
|
+
abstract get cooldownRemaining(): number;
|
|
39
|
+
abstract set cooldownRemaining(cooldownRemaining: number);
|
|
40
|
+
abstract interruptCast(): void;
|
|
38
41
|
static get onCreate(): Event<[Ability]>;
|
|
39
42
|
static get destroyEvent(): Event<[Ability]>;
|
|
40
43
|
}
|
|
@@ -45,17 +48,30 @@ export declare class UnrecognizedAbility extends Ability {
|
|
|
45
48
|
readonly owner: Unit;
|
|
46
49
|
constructor(typeId: number, owner: Unit);
|
|
47
50
|
get level(): number;
|
|
51
|
+
get cooldownRemaining(): number;
|
|
52
|
+
set cooldownRemaining(_: number);
|
|
53
|
+
interruptCast(): void;
|
|
48
54
|
}
|
|
49
55
|
export declare class UnitAbility extends Ability {
|
|
50
56
|
readonly owner: Unit;
|
|
51
57
|
private readonly u;
|
|
58
|
+
private d?;
|
|
52
59
|
constructor(handle: jability, typeId: number, owner: Unit);
|
|
53
60
|
incrementHideCounter(): void;
|
|
54
61
|
decrementHideCounter(): void;
|
|
62
|
+
incrementDisableCounter(): void;
|
|
63
|
+
decrementDisableCounter(): void;
|
|
64
|
+
get isDisabled(): boolean;
|
|
55
65
|
get level(): number;
|
|
56
66
|
set level(v: number);
|
|
67
|
+
/** Uses the native percentage scale. */
|
|
68
|
+
get cooldownRemainingPercent(): number;
|
|
69
|
+
set cooldownRemainingPercent(percent: number);
|
|
57
70
|
get cooldownRemaining(): number;
|
|
58
|
-
set cooldownRemaining(
|
|
71
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
72
|
+
startCooldown(cooldown: number): void;
|
|
73
|
+
interruptCast(): void;
|
|
74
|
+
protected onDestroy(): HandleDestructor;
|
|
59
75
|
static get onCreate(): Event<[UnitAbility]>;
|
|
60
76
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
61
77
|
}
|
|
@@ -79,6 +95,10 @@ export declare class ItemAbility extends Ability {
|
|
|
79
95
|
setField(field: jabilitybooleanlevelfield, level: number, value: boolean): boolean;
|
|
80
96
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
81
97
|
get level(): number;
|
|
98
|
+
get cooldownRemaining(): number;
|
|
99
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
100
|
+
interruptCast(): void;
|
|
101
|
+
protected onDestroy(): HandleDestructor;
|
|
82
102
|
static get onCreate(): Event<[ItemAbility]>;
|
|
83
103
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
84
104
|
}
|
|
@@ -10,28 +10,36 @@ 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
|
|
14
|
-
local
|
|
15
|
-
local
|
|
16
|
-
local setAbilityIntegerField = BlzSetAbilityIntegerField
|
|
17
|
-
local setAbilityRealField = BlzSetAbilityRealField
|
|
18
|
-
local setAbilityBooleanField = BlzSetAbilityBooleanField
|
|
19
|
-
local setAbilityStringField = BlzSetAbilityStringField
|
|
20
|
-
local setAbilityIntegerLevelField = BlzSetAbilityIntegerLevelField
|
|
21
|
-
local setAbilityRealLevelField = BlzSetAbilityRealLevelField
|
|
22
|
-
local setAbilityBooleanLevelField = BlzSetAbilityBooleanLevelField
|
|
23
|
-
local setAbilityStringLevelField = BlzSetAbilityStringLevelField
|
|
24
|
-
local getAbilityIntegerField = BlzGetAbilityIntegerField
|
|
25
|
-
local getAbilityRealField = BlzGetAbilityRealField
|
|
15
|
+
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
16
|
+
local startItemCooldown = ____ability.startItemCooldown
|
|
26
17
|
local getAbilityBooleanField = BlzGetAbilityBooleanField
|
|
27
|
-
local
|
|
18
|
+
local getAbilityBooleanLevelField = BlzGetAbilityBooleanLevelField
|
|
19
|
+
local getAbilityIntegerField = BlzGetAbilityIntegerField
|
|
28
20
|
local getAbilityIntegerLevelField = BlzGetAbilityIntegerLevelField
|
|
21
|
+
local getAbilityRealField = BlzGetAbilityRealField
|
|
29
22
|
local getAbilityRealLevelField = BlzGetAbilityRealLevelField
|
|
30
|
-
local
|
|
23
|
+
local getAbilityStringField = BlzGetAbilityStringField
|
|
31
24
|
local getAbilityStringLevelField = BlzGetAbilityStringLevelField
|
|
25
|
+
local getHandleId = GetHandleId
|
|
26
|
+
local getUnitAbilityCooldownPercent = BlzGetUnitAbilityCooldownPercent
|
|
32
27
|
local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
|
|
28
|
+
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
29
|
+
local order2orderId = _G.OrderId
|
|
30
|
+
local setAbilityBooleanField = BlzSetAbilityBooleanField
|
|
31
|
+
local setAbilityBooleanLevelField = BlzSetAbilityBooleanLevelField
|
|
32
|
+
local setAbilityIntegerField = BlzSetAbilityIntegerField
|
|
33
|
+
local setAbilityIntegerLevelField = BlzSetAbilityIntegerLevelField
|
|
34
|
+
local setAbilityRealField = BlzSetAbilityRealField
|
|
35
|
+
local setAbilityRealLevelField = BlzSetAbilityRealLevelField
|
|
36
|
+
local setAbilityStringField = BlzSetAbilityStringField
|
|
37
|
+
local setAbilityStringLevelField = BlzSetAbilityStringLevelField
|
|
38
|
+
local setUnitAbilityCooldownPercent = BlzSetUnitAbilityCooldownPercent
|
|
39
|
+
local setUnitAbilityCooldownRemaining = BlzSetUnitAbilityCooldownRemaining
|
|
40
|
+
local setUnitAbilityLevel = SetUnitAbilityLevel
|
|
33
41
|
local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
|
|
34
|
-
local
|
|
42
|
+
local unitDisableAbility = BlzUnitDisableAbility
|
|
35
43
|
local unitHideAbility = BlzUnitHideAbility
|
|
36
44
|
local match = string.match
|
|
37
45
|
local ____type = _G.type
|
|
@@ -209,7 +217,6 @@ local levelRefreshFields = {
|
|
|
209
217
|
[fourCC("Neg1")] = true
|
|
210
218
|
}
|
|
211
219
|
local levelsField = ABILITY_IF_LEVELS
|
|
212
|
-
local order2orderId = _G.OrderId
|
|
213
220
|
local orderIdFieldByParentTypeId = {
|
|
214
221
|
[fourCC("ANcl")] = ABILITY_SLF_BASE_ORDER_ID_NCL6,
|
|
215
222
|
[fourCC("Aspb")] = ABILITY_SLF_BASE_ORDER_ID_SPB5,
|
|
@@ -226,6 +233,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
|
|
|
226
233
|
local parentTypeId = availableFields[abilityTypeId]
|
|
227
234
|
return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
|
|
228
235
|
end
|
|
236
|
+
---
|
|
237
|
+
-- @internal For use by internal systems only.
|
|
238
|
+
____exports.abilityTypeHasField = function(abilityTypeId, field)
|
|
239
|
+
field = ____type(field) == "number" and field or getHandleId(field)
|
|
240
|
+
if commonFields[field] then
|
|
241
|
+
return true
|
|
242
|
+
end
|
|
243
|
+
local id = availableFields[abilityTypeId]
|
|
244
|
+
if ____type(id) == "number" then
|
|
245
|
+
id = availableFields[id]
|
|
246
|
+
end
|
|
247
|
+
return not not (id and id[field])
|
|
248
|
+
end
|
|
229
249
|
____exports.Ability = __TS__Class()
|
|
230
250
|
local Ability = ____exports.Ability
|
|
231
251
|
Ability.name = "Ability"
|
|
@@ -241,15 +261,7 @@ function Ability.prototype.getSnapshot(self)
|
|
|
241
261
|
return nil
|
|
242
262
|
end
|
|
243
263
|
function Ability.prototype.hasField(self, field)
|
|
244
|
-
|
|
245
|
-
if commonFields[field] then
|
|
246
|
-
return true
|
|
247
|
-
end
|
|
248
|
-
local id = availableFields[self.typeId]
|
|
249
|
-
if ____type(id) == "number" then
|
|
250
|
-
id = availableFields[id]
|
|
251
|
-
end
|
|
252
|
-
return not not (id and id[field])
|
|
264
|
+
return ____exports.abilityTypeHasField(self.typeId, field)
|
|
253
265
|
end
|
|
254
266
|
function Ability.prototype.getField(self, field, level)
|
|
255
267
|
local fieldType = match(
|
|
@@ -326,6 +338,17 @@ __TS__SetDescriptor(
|
|
|
326
338
|
end},
|
|
327
339
|
true
|
|
328
340
|
)
|
|
341
|
+
__TS__SetDescriptor(
|
|
342
|
+
Ability.prototype,
|
|
343
|
+
"cooldownRemaining",
|
|
344
|
+
{
|
|
345
|
+
get = function(self)
|
|
346
|
+
end,
|
|
347
|
+
set = function(self, cooldownRemaining)
|
|
348
|
+
end
|
|
349
|
+
},
|
|
350
|
+
true
|
|
351
|
+
)
|
|
329
352
|
__TS__ObjectDefineProperty(
|
|
330
353
|
Ability,
|
|
331
354
|
"onCreate",
|
|
@@ -349,6 +372,8 @@ function UnrecognizedAbility.prototype.____constructor(self, typeId, owner)
|
|
|
349
372
|
UnrecognizedAbility.____super.prototype.____constructor(self, nil, typeId)
|
|
350
373
|
self.owner = owner
|
|
351
374
|
end
|
|
375
|
+
function UnrecognizedAbility.prototype.interruptCast(self)
|
|
376
|
+
end
|
|
352
377
|
__TS__SetDescriptor(
|
|
353
378
|
UnrecognizedAbility.prototype,
|
|
354
379
|
"level",
|
|
@@ -357,6 +382,18 @@ __TS__SetDescriptor(
|
|
|
357
382
|
end},
|
|
358
383
|
true
|
|
359
384
|
)
|
|
385
|
+
__TS__SetDescriptor(
|
|
386
|
+
UnrecognizedAbility.prototype,
|
|
387
|
+
"cooldownRemaining",
|
|
388
|
+
{
|
|
389
|
+
get = function(self)
|
|
390
|
+
return 0
|
|
391
|
+
end,
|
|
392
|
+
set = function(self, _)
|
|
393
|
+
end
|
|
394
|
+
},
|
|
395
|
+
true
|
|
396
|
+
)
|
|
360
397
|
____exports.UnitAbility = __TS__Class()
|
|
361
398
|
local UnitAbility = ____exports.UnitAbility
|
|
362
399
|
UnitAbility.name = "UnitAbility"
|
|
@@ -372,6 +409,40 @@ end
|
|
|
372
409
|
function UnitAbility.prototype.decrementHideCounter(self)
|
|
373
410
|
unitHideAbility(self.u, self.typeId, false)
|
|
374
411
|
end
|
|
412
|
+
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
413
|
+
local unit = self.u
|
|
414
|
+
local typeId = self.typeId
|
|
415
|
+
unitHideAbility(unit, typeId, true)
|
|
416
|
+
unitDisableAbility(unit, typeId, true, false)
|
|
417
|
+
self.d = (self.d or 0) + 1
|
|
418
|
+
end
|
|
419
|
+
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
420
|
+
local unit = self.u
|
|
421
|
+
local typeId = self.typeId
|
|
422
|
+
unitDisableAbility(unit, typeId, false, false)
|
|
423
|
+
unitHideAbility(unit, typeId, true)
|
|
424
|
+
self.d = (self.d or 0) - 1
|
|
425
|
+
end
|
|
426
|
+
function UnitAbility.prototype.startCooldown(self, cooldown)
|
|
427
|
+
startUnitAbilityCooldown(self.u, self.typeId, cooldown)
|
|
428
|
+
end
|
|
429
|
+
function UnitAbility.prototype.interruptCast(self)
|
|
430
|
+
self.owner:interruptCast(self.typeId)
|
|
431
|
+
end
|
|
432
|
+
function UnitAbility.prototype.onDestroy(self)
|
|
433
|
+
if self.owner.state ~= 2 then
|
|
434
|
+
self.owner:removeAbility(self.typeId)
|
|
435
|
+
end
|
|
436
|
+
return UnitAbility.____super.prototype.onDestroy(self)
|
|
437
|
+
end
|
|
438
|
+
__TS__SetDescriptor(
|
|
439
|
+
UnitAbility.prototype,
|
|
440
|
+
"isDisabled",
|
|
441
|
+
{get = function(self)
|
|
442
|
+
return self.d ~= nil and self.d > 0
|
|
443
|
+
end},
|
|
444
|
+
true
|
|
445
|
+
)
|
|
375
446
|
__TS__SetDescriptor(
|
|
376
447
|
UnitAbility.prototype,
|
|
377
448
|
"level",
|
|
@@ -385,6 +456,19 @@ __TS__SetDescriptor(
|
|
|
385
456
|
},
|
|
386
457
|
true
|
|
387
458
|
)
|
|
459
|
+
__TS__SetDescriptor(
|
|
460
|
+
UnitAbility.prototype,
|
|
461
|
+
"cooldownRemainingPercent",
|
|
462
|
+
{
|
|
463
|
+
get = function(self)
|
|
464
|
+
return getUnitAbilityCooldownPercent(self.u, self.typeId)
|
|
465
|
+
end,
|
|
466
|
+
set = function(self, percent)
|
|
467
|
+
setUnitAbilityCooldownPercent(self.u, self.typeId, percent)
|
|
468
|
+
end
|
|
469
|
+
},
|
|
470
|
+
true
|
|
471
|
+
)
|
|
388
472
|
__TS__SetDescriptor(
|
|
389
473
|
UnitAbility.prototype,
|
|
390
474
|
"cooldownRemaining",
|
|
@@ -392,8 +476,8 @@ __TS__SetDescriptor(
|
|
|
392
476
|
get = function(self)
|
|
393
477
|
return getUnitAbilityCooldownRemaining(self.u, self.typeId)
|
|
394
478
|
end,
|
|
395
|
-
set = function(self,
|
|
396
|
-
|
|
479
|
+
set = function(self, cooldownRemaining)
|
|
480
|
+
setUnitAbilityCooldownRemaining(self.u, self.typeId, cooldownRemaining)
|
|
397
481
|
end
|
|
398
482
|
},
|
|
399
483
|
true
|
|
@@ -418,6 +502,9 @@ end
|
|
|
418
502
|
local function setAbilityField(_, ability, field, levelOrValue, value)
|
|
419
503
|
return ____exports.Ability.prototype.setField(ability, field, levelOrValue, value)
|
|
420
504
|
end
|
|
505
|
+
local function getAbilityCooldown(_, abilityTypeId)
|
|
506
|
+
return getUnitAbilityCooldownRemaining(abilityActionDummy, abilityTypeId)
|
|
507
|
+
end
|
|
421
508
|
____exports.ItemAbility = __TS__Class()
|
|
422
509
|
local ItemAbility = ____exports.ItemAbility
|
|
423
510
|
ItemAbility.name = "ItemAbility"
|
|
@@ -445,6 +532,22 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
|
|
|
445
532
|
value
|
|
446
533
|
)
|
|
447
534
|
end
|
|
535
|
+
function ItemAbility.prototype.interruptCast(self)
|
|
536
|
+
local item = self.owner
|
|
537
|
+
local itemHandle = item.handle
|
|
538
|
+
local ____opt_1 = item.owner
|
|
539
|
+
local itemOwnerHandle = ____opt_1 and ____opt_1.handle
|
|
540
|
+
local cooldownRemaining = doAbilityActionForceDummy(itemHandle, itemOwnerHandle, getAbilityCooldown, self.typeId)
|
|
541
|
+
if cooldownRemaining == 0 then
|
|
542
|
+
startItemCooldown(itemHandle, itemOwnerHandle, 0.015625)
|
|
543
|
+
end
|
|
544
|
+
end
|
|
545
|
+
function ItemAbility.prototype.onDestroy(self)
|
|
546
|
+
if self.owner.state ~= 2 then
|
|
547
|
+
self.owner:removeAbility(self.typeId)
|
|
548
|
+
end
|
|
549
|
+
return ItemAbility.____super.prototype.onDestroy(self)
|
|
550
|
+
end
|
|
448
551
|
__TS__SetDescriptor(
|
|
449
552
|
ItemAbility.prototype,
|
|
450
553
|
"level",
|
|
@@ -453,6 +556,27 @@ __TS__SetDescriptor(
|
|
|
453
556
|
end},
|
|
454
557
|
true
|
|
455
558
|
)
|
|
559
|
+
__TS__SetDescriptor(
|
|
560
|
+
ItemAbility.prototype,
|
|
561
|
+
"cooldownRemaining",
|
|
562
|
+
{
|
|
563
|
+
get = function(self)
|
|
564
|
+
local item = self.owner
|
|
565
|
+
local ____doAbilityActionForceDummy_6 = doAbilityActionForceDummy
|
|
566
|
+
local ____item_handle_5 = item.handle
|
|
567
|
+
local ____opt_3 = item.owner
|
|
568
|
+
return ____doAbilityActionForceDummy_6(____item_handle_5, ____opt_3 and ____opt_3.handle, getAbilityCooldown, self.typeId)
|
|
569
|
+
end,
|
|
570
|
+
set = function(self, cooldownRemaining)
|
|
571
|
+
local item = self.owner
|
|
572
|
+
local ____startItemCooldown_10 = startItemCooldown
|
|
573
|
+
local ____item_handle_9 = item.handle
|
|
574
|
+
local ____opt_7 = item.owner
|
|
575
|
+
____startItemCooldown_10(____item_handle_9, ____opt_7 and ____opt_7.handle, cooldownRemaining)
|
|
576
|
+
end
|
|
577
|
+
},
|
|
578
|
+
true
|
|
579
|
+
)
|
|
456
580
|
__TS__ObjectDefineProperty(
|
|
457
581
|
ItemAbility,
|
|
458
582
|
"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
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____item = require("engine.internal.item")
|
|
5
|
+
local Item = ____item.Item
|
|
6
|
+
local ____item = require("engine.standard.fields.item")
|
|
7
|
+
local CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD = ____item.CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD
|
|
8
|
+
local IS_ACTIVELY_USED_ITEM_FIELD = ____item.IS_ACTIVELY_USED_ITEM_FIELD
|
|
9
|
+
__TS__ObjectDefineProperty(
|
|
10
|
+
Item.prototype,
|
|
11
|
+
"canBeSold",
|
|
12
|
+
{
|
|
13
|
+
get = function(self)
|
|
14
|
+
return CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD:getValue(self)
|
|
15
|
+
end,
|
|
16
|
+
set = function(self, value)
|
|
17
|
+
CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD:setValue(self, value)
|
|
18
|
+
end
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
__TS__ObjectDefineProperty(
|
|
22
|
+
Item.prototype,
|
|
23
|
+
"isActivelyUsed",
|
|
24
|
+
{
|
|
25
|
+
get = function(self)
|
|
26
|
+
return IS_ACTIVELY_USED_ITEM_FIELD:getValue(self)
|
|
27
|
+
end,
|
|
28
|
+
set = function(self, value)
|
|
29
|
+
IS_ACTIVELY_USED_ITEM_FIELD:setValue(self, value)
|
|
30
|
+
end
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
return ____exports
|
|
@@ -5,13 +5,26 @@ local ____item = require("engine.internal.item")
|
|
|
5
5
|
local Item = ____item.Item
|
|
6
6
|
local ____unit = require("engine.internal.unit")
|
|
7
7
|
local Unit = ____unit.Unit
|
|
8
|
+
require("engine.internal.unit.equipment")
|
|
8
9
|
local ownerByItem = setmetatable({}, {__mode = "kv"})
|
|
9
|
-
Unit.itemPickedUpEvent:addListener(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
Unit.itemPickedUpEvent:addListener(
|
|
11
|
+
4,
|
|
12
|
+
function(unit, item)
|
|
13
|
+
ownerByItem[item] = unit
|
|
14
|
+
end
|
|
15
|
+
)
|
|
16
|
+
Unit.itemEquippedEvent:addListener(
|
|
17
|
+
4,
|
|
18
|
+
function(unit, item)
|
|
19
|
+
ownerByItem[item] = unit
|
|
20
|
+
end
|
|
21
|
+
)
|
|
22
|
+
Unit.itemDroppedEvent:addListener(
|
|
23
|
+
4,
|
|
24
|
+
function(unit, item)
|
|
25
|
+
ownerByItem[item] = nil
|
|
26
|
+
end
|
|
27
|
+
)
|
|
15
28
|
__TS__ObjectDefineProperty(
|
|
16
29
|
Item.prototype,
|
|
17
30
|
"owner",
|