warscript 0.0.1-dev.a4deb44 → 0.0.1-dev.a5a2f5e
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 +18 -0
- package/attributes.lua +32 -0
- 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 +164 -23
- package/core/types/group.d.ts +0 -1
- package/core/types/handle.d.ts +2 -1
- package/core/types/handle.lua +5 -0
- package/core/types/image.d.ts +0 -1
- package/core/types/item.d.ts +1 -0
- package/core/types/item.lua +1 -0
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/player.d.ts +17 -1
- package/core/types/player.lua +70 -24
- 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 +100 -25
- 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 +13 -4
- package/engine/behaviour/ability/apply-unit-behavior.lua +32 -9
- package/engine/behaviour/ability/damage.d.ts +42 -11
- package/engine/behaviour/ability/damage.lua +89 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +44 -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 +35 -7
- 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 +160 -53
- package/engine/buff.lua +711 -269
- 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/fields.d.ts +12 -0
- package/engine/internal/item/fields.lua +33 -0
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +16 -19
- package/engine/internal/item.lua +174 -94
- package/engine/internal/mechanics/ability-duration.d.ts +1 -3
- package/engine/internal/mechanics/ability-duration.lua +3 -1
- package/engine/internal/mechanics/cast-ability.lua +89 -0
- 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/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 +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 +17 -8
- package/engine/internal/unit/bonus.lua +56 -4
- package/engine/internal/unit/detach-missiles.d.ts +7 -0
- package/engine/internal/unit/detach-missiles.lua +30 -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 +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+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+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 +14 -2
- package/engine/local-client.lua +168 -1
- 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/{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 +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/blink.d.ts +10 -0
- package/engine/object-data/entry/ability-type/blink.lua +39 -0
- 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/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/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/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/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 +21 -18
- package/engine/object-data/entry/ability-type.lua +177 -40
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.lua +143 -202
- 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 +65 -5
- package/engine/object-data/entry/unit-type.lua +555 -62
- 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 +61 -7
- 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 -8
- package/engine/object-field.lua +362 -117
- package/engine/random.d.ts +11 -0
- package/engine/random.lua +30 -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 +42 -1
- package/engine/standard/entries/unit-type.lua +42 -1
- package/engine/standard/fields/ability.d.ts +5 -3
- package/engine/standard/fields/ability.lua +5 -3
- 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 +10 -0
- package/engine/unit.lua +19 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/global/vec2.lua +1 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +147 -43
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +2 -2
- package/math.lua +14 -0
- 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/object.lua +1 -1
- package/objutil/unit.d.ts +0 -1
- package/objutil/unit.lua +8 -0
- package/operation.lua +1 -4
- 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 +35 -0
- package/utility/linked-map.lua +107 -0
- package/utility/linked-set.d.ts +16 -4
- package/utility/linked-set.lua +54 -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 +6 -2
- package/utility/unordered-map.d.ts +27 -0
- package/utility/unordered-map.lua +99 -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
- /package/engine/internal/{object-data/armor-increase.d.ts → mechanics/cast-ability.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
|
@@ -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
|
|
@@ -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",
|
|
@@ -5,19 +5,17 @@ import { Event } from "../../event";
|
|
|
5
5
|
import { ReadonlyRect } from "../../core/types/rect";
|
|
6
6
|
import { ItemAbility } from "./ability";
|
|
7
7
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
8
|
+
import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
8
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
9
|
-
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
10
10
|
declare const enum ItemPropertyKey {
|
|
11
|
-
ABILITIES = 100
|
|
12
|
-
LUA_INDEX_BY_ABILITY_TYPE_ID = 101
|
|
11
|
+
ABILITIES = 100
|
|
13
12
|
}
|
|
14
13
|
export declare class Item extends Handle<jitem> {
|
|
15
14
|
private readonly [ItemPropertyKey.ABILITIES];
|
|
16
|
-
private readonly [ItemPropertyKey.LUA_INDEX_BY_ABILITY_TYPE_ID];
|
|
17
15
|
constructor(handle: jitem);
|
|
18
16
|
protected onDestroy(): HandleDestructor;
|
|
19
17
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
|
20
|
-
get typeId():
|
|
18
|
+
get typeId(): ItemTypeId;
|
|
21
19
|
set skinId(v: number);
|
|
22
20
|
get skinId(): number;
|
|
23
21
|
set name(v: string);
|
|
@@ -30,22 +28,18 @@ export declare class Item extends Handle<jitem> {
|
|
|
30
28
|
get extendedTooltip(): string;
|
|
31
29
|
set iconPath(v: string);
|
|
32
30
|
get iconPath(): string;
|
|
33
|
-
set
|
|
34
|
-
get
|
|
35
|
-
set
|
|
36
|
-
get
|
|
37
|
-
set
|
|
38
|
-
get
|
|
39
|
-
set
|
|
40
|
-
get
|
|
41
|
-
set powerup(v: boolean);
|
|
42
|
-
get powerup(): boolean;
|
|
31
|
+
set dropsOnDeath(dropsOnDeath: boolean);
|
|
32
|
+
get dropsOnDeath(): boolean;
|
|
33
|
+
set canBeDropped(canBeDropped: boolean);
|
|
34
|
+
get canBeDropped(): boolean;
|
|
35
|
+
set perishes(perishes: boolean);
|
|
36
|
+
get perishes(): boolean;
|
|
37
|
+
set isPowerUp(isPowerUp: boolean);
|
|
38
|
+
get isPowerUp(): boolean;
|
|
43
39
|
get isAlive(): boolean;
|
|
44
40
|
get isDead(): boolean;
|
|
45
41
|
set isInvulnerable(isInvulnerable: boolean);
|
|
46
42
|
get isInvulnerable(): boolean;
|
|
47
|
-
set usable(v: boolean);
|
|
48
|
-
get usable(): boolean;
|
|
49
43
|
set visible(v: boolean);
|
|
50
44
|
get visible(): boolean;
|
|
51
45
|
set level(v: number);
|
|
@@ -73,14 +67,17 @@ export declare class Item extends Handle<jitem> {
|
|
|
73
67
|
set position(v: Vec2);
|
|
74
68
|
set charges(v: number);
|
|
75
69
|
get charges(): number;
|
|
70
|
+
consumeCharge(): boolean;
|
|
71
|
+
consumeCharges(count: number): boolean;
|
|
76
72
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
77
73
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
78
74
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
79
75
|
getAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
80
76
|
get abilities(): readonly ItemAbility[];
|
|
81
|
-
static getInRange(
|
|
77
|
+
static getInRange(x: number, y: number, range: number): Item[];
|
|
82
78
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
83
79
|
static get onCreate(): Event<[Item]>;
|
|
84
|
-
static get
|
|
80
|
+
static get destroyEvent(): Event<[Item]>;
|
|
81
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
85
82
|
}
|
|
86
83
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
5
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
6
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
6
7
|
local __TS__Delete = ____lualib.__TS__Delete
|
|
7
8
|
local ____exports = {}
|
|
9
|
+
local invoke
|
|
8
10
|
local ____handle = require("core.types.handle")
|
|
9
11
|
local Handle = ____handle.Handle
|
|
10
12
|
local ____color = require("core.types.color")
|
|
11
13
|
local Color = ____color.Color
|
|
14
|
+
local ____event = require("event")
|
|
15
|
+
local Event = ____event.Event
|
|
12
16
|
local ____rect = require("core.types.rect")
|
|
13
17
|
local Rect = ____rect.Rect
|
|
14
18
|
local ____ability = require("engine.internal.ability")
|
|
15
19
|
local ItemAbility = ____ability.ItemAbility
|
|
16
20
|
local ____ability = require("engine.internal.item.ability")
|
|
17
21
|
local doAbilityAction = ____ability.doAbilityAction
|
|
22
|
+
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
23
|
+
local itemAbilityDummy = ____ability.itemAbilityDummy
|
|
24
|
+
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
25
|
+
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
26
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
27
|
+
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
28
|
+
local ____vec2 = require("math.vec2")
|
|
29
|
+
local distance = ____vec2.distance
|
|
30
|
+
local itemChargesChangeEvent = __TS__New(Event)
|
|
18
31
|
local itemAddAbility = BlzItemAddAbility
|
|
19
32
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
20
33
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -24,10 +37,38 @@ local getAbilityId = BlzGetAbilityId
|
|
|
24
37
|
local getWidgetLife = GetWidgetLife
|
|
25
38
|
local removeItem = RemoveItem
|
|
26
39
|
local getHandleId = GetHandleId
|
|
40
|
+
local setRect = SetRect
|
|
41
|
+
local enumItemsInRect = EnumItemsInRect
|
|
42
|
+
local getEnumItem = GetEnumItem
|
|
43
|
+
local getItemTypeId = GetItemTypeId
|
|
44
|
+
local getItemX = GetItemX
|
|
45
|
+
local getItemY = GetItemY
|
|
46
|
+
local getItemCharges = GetItemCharges
|
|
47
|
+
local setItemCharges = SetItemCharges
|
|
48
|
+
local unitRemoveAbility = UnitRemoveAbility
|
|
49
|
+
local unitRemoveItem = UnitRemoveItem
|
|
50
|
+
local unitUseItem = UnitUseItem
|
|
51
|
+
local unitUseItemPoint = UnitUseItemPoint
|
|
52
|
+
local unitUseItemTarget = UnitUseItemTarget
|
|
53
|
+
local setItemDropOnDeath = SetItemDropOnDeath
|
|
54
|
+
local setItemDroppable = SetItemDroppable
|
|
55
|
+
local setItemPawnable = SetItemPawnable
|
|
56
|
+
local isItemPawnable = IsItemPawnable
|
|
27
57
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
28
58
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
29
59
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
60
|
+
local tableRemove = table.remove
|
|
61
|
+
_G.SetItemCharges = function(whichItem, charges)
|
|
62
|
+
setItemCharges(whichItem, charges)
|
|
63
|
+
invoke(
|
|
64
|
+
itemChargesChangeEvent,
|
|
65
|
+
____exports.Item:of(whichItem)
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
invoke = Event.invoke
|
|
30
69
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
70
|
+
---
|
|
71
|
+
-- @internal For use by internal systems only.
|
|
31
72
|
____exports.addAndGetAbility = function(handle, abilityTypeId)
|
|
32
73
|
if itemAddAbility(handle, abilityTypeId) then
|
|
33
74
|
return getItemAbility(handle, abilityTypeId)
|
|
@@ -53,21 +94,62 @@ local function getItemAbilities(handle, item)
|
|
|
53
94
|
end
|
|
54
95
|
return abilities
|
|
55
96
|
end
|
|
97
|
+
local function consumeCharge(handle)
|
|
98
|
+
do
|
|
99
|
+
local i = 0
|
|
100
|
+
local ability = getItemAbilityByIndex(handle, i)
|
|
101
|
+
while ability ~= nil do
|
|
102
|
+
unitRemoveAbility(
|
|
103
|
+
itemAbilityDummy,
|
|
104
|
+
getAbilityId(ability)
|
|
105
|
+
)
|
|
106
|
+
do
|
|
107
|
+
i = i + 1
|
|
108
|
+
ability = getItemAbilityByIndex(handle, i)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
return unitUseItem(itemAbilityDummy, handle) or unitUseItemPoint(itemAbilityDummy, handle, 0, 0) or unitUseItemTarget(itemAbilityDummy, handle, itemAbilityDummy)
|
|
113
|
+
end
|
|
114
|
+
local targetCollection
|
|
115
|
+
local targetCollectionNextIndex
|
|
116
|
+
local centerX
|
|
117
|
+
local centerY
|
|
118
|
+
local enumRange
|
|
119
|
+
local function collectIntoTarget()
|
|
120
|
+
local item = getEnumItem()
|
|
121
|
+
local typeId = getItemTypeId(item)
|
|
122
|
+
if typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
|
|
123
|
+
targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
|
|
124
|
+
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
local function collectIntoTargetRange()
|
|
128
|
+
local item = getEnumItem()
|
|
129
|
+
local typeId = getItemTypeId(item)
|
|
130
|
+
if distance(
|
|
131
|
+
getItemX(item),
|
|
132
|
+
getItemY(item),
|
|
133
|
+
centerX,
|
|
134
|
+
centerY
|
|
135
|
+
) <= enumRange and typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
|
|
136
|
+
targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
|
|
137
|
+
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
138
|
+
end
|
|
139
|
+
end
|
|
56
140
|
____exports.Item = __TS__Class()
|
|
57
141
|
local Item = ____exports.Item
|
|
58
142
|
Item.name = "Item"
|
|
59
143
|
__TS__ClassExtends(Item, Handle)
|
|
60
144
|
function Item.prototype.____constructor(self, handle)
|
|
61
145
|
Handle.prototype.____constructor(self, handle)
|
|
62
|
-
|
|
63
|
-
self[100] = abilities
|
|
64
|
-
local luaIndexByAbilityTypeId = {}
|
|
65
|
-
for i = 1, #abilities do
|
|
66
|
-
luaIndexByAbilityTypeId[abilities[i].typeId] = i
|
|
67
|
-
end
|
|
68
|
-
self[101] = luaIndexByAbilityTypeId
|
|
146
|
+
self[100] = doAbilityAction(handle, getItemAbilities, self)
|
|
69
147
|
end
|
|
70
148
|
function Item.prototype.onDestroy(self)
|
|
149
|
+
local owner = self.owner
|
|
150
|
+
if owner ~= nil then
|
|
151
|
+
unitRemoveItem(owner.handle, self.handle)
|
|
152
|
+
end
|
|
71
153
|
local abilities = self[100]
|
|
72
154
|
for i = 1, #abilities do
|
|
73
155
|
abilities[i]:destroy()
|
|
@@ -78,67 +160,89 @@ end
|
|
|
78
160
|
function Item.create(self, id, x, y, skinId)
|
|
79
161
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
80
162
|
end
|
|
163
|
+
function Item.prototype.consumeCharge(self)
|
|
164
|
+
return self:consumeCharges(1)
|
|
165
|
+
end
|
|
166
|
+
function Item.prototype.consumeCharges(self, count)
|
|
167
|
+
local handle = self.handle
|
|
168
|
+
local charges = getItemCharges(handle)
|
|
169
|
+
if charges > count then
|
|
170
|
+
setItemCharges(handle, charges - count)
|
|
171
|
+
invoke(itemChargesChangeEvent, self)
|
|
172
|
+
return true
|
|
173
|
+
end
|
|
174
|
+
if charges == count then
|
|
175
|
+
if getItemBooleanField(handle, ITEM_BF_PERISHABLE) then
|
|
176
|
+
self:destroy()
|
|
177
|
+
return true
|
|
178
|
+
end
|
|
179
|
+
if not getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED) then
|
|
180
|
+
setItemCharges(handle, 0)
|
|
181
|
+
invoke(itemChargesChangeEvent, self)
|
|
182
|
+
return true
|
|
183
|
+
end
|
|
184
|
+
setItemCharges(handle, 1)
|
|
185
|
+
local ____doAbilityActionForceDummy_2 = doAbilityActionForceDummy
|
|
186
|
+
local ____opt_0 = self.owner
|
|
187
|
+
____doAbilityActionForceDummy_2(handle, ____opt_0 and ____opt_0.handle, consumeCharge)
|
|
188
|
+
invoke(itemChargesChangeEvent, self)
|
|
189
|
+
return true
|
|
190
|
+
end
|
|
191
|
+
return false
|
|
192
|
+
end
|
|
81
193
|
function Item.prototype.addAbility(self, abilityTypeId)
|
|
82
194
|
local nativeAbility = doAbilityAction(self.handle, ____exports.addAndGetAbility, abilityTypeId)
|
|
83
195
|
if nativeAbility ~= nil then
|
|
84
196
|
local ability = ItemAbility:of(nativeAbility, abilityTypeId, self)
|
|
85
197
|
local abilities = self[100]
|
|
86
|
-
|
|
87
|
-
abilities[luaIndex] = ability
|
|
88
|
-
self[101][abilityTypeId] = luaIndex
|
|
198
|
+
abilities[#abilities + 1] = ability
|
|
89
199
|
return ability
|
|
90
200
|
end
|
|
91
201
|
return nil
|
|
92
202
|
end
|
|
93
203
|
function Item.prototype.removeAbility(self, abilityTypeId)
|
|
94
|
-
local
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
for j = luaIndex, abilityTypeIdsLength do
|
|
102
|
-
abilities[j] = abilities[j + 1]
|
|
204
|
+
local abilities = self[100]
|
|
205
|
+
for i = 1, #abilities do
|
|
206
|
+
if abilities[i].typeId == abilityTypeId then
|
|
207
|
+
local ability = abilities[i]
|
|
208
|
+
tableRemove(abilities, i)
|
|
209
|
+
ability:destroy()
|
|
210
|
+
return true
|
|
103
211
|
end
|
|
104
212
|
end
|
|
105
|
-
return
|
|
213
|
+
return doAbilityAction(self.handle, itemRemoveAbility, abilityTypeId)
|
|
106
214
|
end
|
|
107
215
|
function Item.prototype.hasAbility(self, abilityTypeId)
|
|
108
|
-
return self
|
|
216
|
+
return doAbilityAction(self.handle, getItemAbility, abilityTypeId) ~= nil
|
|
109
217
|
end
|
|
110
218
|
function Item.prototype.getAbility(self, abilityTypeId)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
local collection = {}
|
|
116
|
-
SetRect(
|
|
117
|
-
enumRect,
|
|
118
|
-
pos.x - range,
|
|
119
|
-
pos.y - range,
|
|
120
|
-
pos.x + range,
|
|
121
|
-
pos.y + range
|
|
219
|
+
return ItemAbility:of(
|
|
220
|
+
doAbilityAction(self.handle, getItemAbility, abilityTypeId),
|
|
221
|
+
abilityTypeId,
|
|
222
|
+
self
|
|
122
223
|
)
|
|
123
|
-
|
|
224
|
+
end
|
|
225
|
+
function Item.getInRange(self, x, y, range)
|
|
226
|
+
targetCollection = {}
|
|
227
|
+
targetCollectionNextIndex = 1
|
|
228
|
+
centerX = x
|
|
229
|
+
centerY = y
|
|
230
|
+
enumRange = range
|
|
231
|
+
setRect(
|
|
124
232
|
enumRect,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
233
|
+
x - range,
|
|
234
|
+
y - range,
|
|
235
|
+
x + range,
|
|
236
|
+
y + range
|
|
129
237
|
)
|
|
130
|
-
|
|
238
|
+
enumItemsInRect(enumRect, nil, collectIntoTargetRange)
|
|
239
|
+
return targetCollection
|
|
131
240
|
end
|
|
132
241
|
function Item.getInRect(self, rect)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function()
|
|
138
|
-
collection[#collection + 1] = self:of(GetEnumItem())
|
|
139
|
-
end
|
|
140
|
-
)
|
|
141
|
-
return collection
|
|
242
|
+
targetCollection = {}
|
|
243
|
+
targetCollectionNextIndex = 1
|
|
244
|
+
enumItemsInRect(rect.handle, nil, collectIntoTarget)
|
|
245
|
+
return targetCollection
|
|
142
246
|
end
|
|
143
247
|
__TS__SetDescriptor(
|
|
144
248
|
Item.prototype,
|
|
@@ -228,65 +332,55 @@ __TS__SetDescriptor(
|
|
|
228
332
|
)
|
|
229
333
|
__TS__SetDescriptor(
|
|
230
334
|
Item.prototype,
|
|
231
|
-
"
|
|
232
|
-
{
|
|
233
|
-
get = function(self)
|
|
234
|
-
return BlzGetItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
235
|
-
end,
|
|
236
|
-
set = function(self, v)
|
|
237
|
-
SetItemDropOnDeath(self.handle, v)
|
|
238
|
-
end
|
|
239
|
-
},
|
|
240
|
-
true
|
|
241
|
-
)
|
|
242
|
-
__TS__SetDescriptor(
|
|
243
|
-
Item.prototype,
|
|
244
|
-
"droppable",
|
|
335
|
+
"dropsOnDeath",
|
|
245
336
|
{
|
|
246
337
|
get = function(self)
|
|
247
|
-
return
|
|
338
|
+
return getItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
248
339
|
end,
|
|
249
|
-
set = function(self,
|
|
250
|
-
|
|
340
|
+
set = function(self, dropsOnDeath)
|
|
341
|
+
setItemDropOnDeath(self.handle, dropsOnDeath)
|
|
251
342
|
end
|
|
252
343
|
},
|
|
253
344
|
true
|
|
254
345
|
)
|
|
255
346
|
__TS__SetDescriptor(
|
|
256
347
|
Item.prototype,
|
|
257
|
-
"
|
|
348
|
+
"canBeDropped",
|
|
258
349
|
{
|
|
259
350
|
get = function(self)
|
|
260
|
-
return
|
|
351
|
+
return getItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
|
|
261
352
|
end,
|
|
262
|
-
set = function(self,
|
|
263
|
-
|
|
353
|
+
set = function(self, canBeDropped)
|
|
354
|
+
setItemDroppable(self.handle, canBeDropped)
|
|
264
355
|
end
|
|
265
356
|
},
|
|
266
357
|
true
|
|
267
358
|
)
|
|
268
359
|
__TS__SetDescriptor(
|
|
269
360
|
Item.prototype,
|
|
270
|
-
"
|
|
361
|
+
"perishes",
|
|
271
362
|
{
|
|
272
363
|
get = function(self)
|
|
273
|
-
return
|
|
364
|
+
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
274
365
|
end,
|
|
275
|
-
set = function(self,
|
|
276
|
-
|
|
366
|
+
set = function(self, perishes)
|
|
367
|
+
local handle = self.handle
|
|
368
|
+
local powerUp = isItemPowerup(handle)
|
|
369
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
370
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
277
371
|
end
|
|
278
372
|
},
|
|
279
373
|
true
|
|
280
374
|
)
|
|
281
375
|
__TS__SetDescriptor(
|
|
282
376
|
Item.prototype,
|
|
283
|
-
"
|
|
377
|
+
"isPowerUp",
|
|
284
378
|
{
|
|
285
379
|
get = function(self)
|
|
286
380
|
return isItemPowerup(self.handle)
|
|
287
381
|
end,
|
|
288
|
-
set = function(self,
|
|
289
|
-
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED,
|
|
382
|
+
set = function(self, isPowerUp)
|
|
383
|
+
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, isPowerUp)
|
|
290
384
|
end
|
|
291
385
|
},
|
|
292
386
|
true
|
|
@@ -320,22 +414,6 @@ __TS__SetDescriptor(
|
|
|
320
414
|
},
|
|
321
415
|
true
|
|
322
416
|
)
|
|
323
|
-
__TS__SetDescriptor(
|
|
324
|
-
Item.prototype,
|
|
325
|
-
"usable",
|
|
326
|
-
{
|
|
327
|
-
get = function(self)
|
|
328
|
-
return getItemBooleanField(self.handle, ITEM_BF_ACTIVELY_USED)
|
|
329
|
-
end,
|
|
330
|
-
set = function(self, v)
|
|
331
|
-
local handle = self.handle
|
|
332
|
-
local powerup = isItemPowerup(handle)
|
|
333
|
-
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, v)
|
|
334
|
-
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerup)
|
|
335
|
-
end
|
|
336
|
-
},
|
|
337
|
-
true
|
|
338
|
-
)
|
|
339
417
|
__TS__SetDescriptor(
|
|
340
418
|
Item.prototype,
|
|
341
419
|
"visible",
|
|
@@ -526,10 +604,11 @@ __TS__SetDescriptor(
|
|
|
526
604
|
"charges",
|
|
527
605
|
{
|
|
528
606
|
get = function(self)
|
|
529
|
-
return
|
|
607
|
+
return getItemCharges(self.handle)
|
|
530
608
|
end,
|
|
531
609
|
set = function(self, v)
|
|
532
|
-
|
|
610
|
+
setItemCharges(self.handle, v)
|
|
611
|
+
invoke(itemChargesChangeEvent, self)
|
|
533
612
|
end
|
|
534
613
|
},
|
|
535
614
|
true
|
|
@@ -551,11 +630,12 @@ __TS__ObjectDefineProperty(
|
|
|
551
630
|
)
|
|
552
631
|
__TS__ObjectDefineProperty(
|
|
553
632
|
Item,
|
|
554
|
-
"
|
|
633
|
+
"destroyEvent",
|
|
555
634
|
{get = function(self)
|
|
556
635
|
return self.onDestroyEvent
|
|
557
636
|
end}
|
|
558
637
|
)
|
|
638
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
559
639
|
local getManipulatedItem = GetManipulatedItem
|
|
560
640
|
local trigger = CreateTrigger()
|
|
561
641
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_PICKUP_ITEM)
|
|
@@ -4,8 +4,10 @@ local UnitClassification = ____unit.UnitClassification
|
|
|
4
4
|
local ____ability = require("engine.standard.fields.ability")
|
|
5
5
|
local DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD
|
|
6
6
|
local DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD
|
|
7
|
+
---
|
|
8
|
+
-- @internal For use by internal systems only.
|
|
7
9
|
____exports.getAbilityDuration = function(ability, target)
|
|
8
10
|
local level = ability.level
|
|
9
|
-
return target ~= nil and target:hasClassification(UnitClassification.RESISTANT) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
11
|
+
return target ~= nil and (target.isHero or target:getField(UNIT_IF_LEVEL) >= 6 or target:hasClassification(UnitClassification.RESISTANT)) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
10
12
|
end
|
|
11
13
|
return ____exports
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
|
|
3
|
+
local AbilityType = ____ability_2Dtype.AbilityType
|
|
4
|
+
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
5
|
+
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
6
|
+
local ____dummy_2Dunits = require("engine.internal.misc.dummy-units")
|
|
7
|
+
local INVENTORY_DUMMY_NATIVE_UNIT = ____dummy_2Dunits.INVENTORY_DUMMY_NATIVE_UNIT
|
|
8
|
+
local ____preconditions = require("utility.preconditions")
|
|
9
|
+
local checkNotNull = ____preconditions.checkNotNull
|
|
10
|
+
local ____dummy_2Dinventory = require("engine.internal.object-data.dummy-inventory")
|
|
11
|
+
local INVENTORY_ABILITY_TYPE_ID = ____dummy_2Dinventory.INVENTORY_ABILITY_TYPE_ID
|
|
12
|
+
local ____arrays = require("utility.arrays")
|
|
13
|
+
local map = ____arrays.map
|
|
14
|
+
local toLuaSet = ____arrays.toLuaSet
|
|
15
|
+
local createItem = CreateItem
|
|
16
|
+
local getAbilityId = BlzGetAbilityId
|
|
17
|
+
local getItemAbility = BlzGetItemAbility
|
|
18
|
+
local getUnitAbilityByIndex = BlzGetUnitAbilityByIndex
|
|
19
|
+
local itemAddAbility = BlzItemAddAbility
|
|
20
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
21
|
+
local removeItem = RemoveItem
|
|
22
|
+
local unitAddAbility = UnitAddAbility
|
|
23
|
+
local unitAddItem = UnitAddItem
|
|
24
|
+
local unitDropItemSlot = UnitDropItemSlot
|
|
25
|
+
local unitInventorySize = UnitInventorySize
|
|
26
|
+
local unitRemoveAbility = UnitRemoveAbility
|
|
27
|
+
local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
|
|
28
|
+
local INVENTORY_ABILITY_TYPE_IDS = postcompile(function()
|
|
29
|
+
return toLuaSet(AbilityType:getAllIdsByBaseIds(map({
|
|
30
|
+
"AInv",
|
|
31
|
+
"Aihn",
|
|
32
|
+
"Aien",
|
|
33
|
+
"Aion",
|
|
34
|
+
"Aiun"
|
|
35
|
+
}, fourCC)))
|
|
36
|
+
end)
|
|
37
|
+
---
|
|
38
|
+
-- @internal For use by internal systems only.
|
|
39
|
+
____exports.castAbility = function(nativeUnit, abilityTypeId, prepareAbility, ...)
|
|
40
|
+
local nativeItem = createItem(DUMMY_ITEM_ID, 0, 0)
|
|
41
|
+
unitAddItem(INVENTORY_DUMMY_NATIVE_UNIT, nativeItem)
|
|
42
|
+
itemAddAbility(nativeItem, abilityTypeId)
|
|
43
|
+
local nativeAbility = checkNotNull(getItemAbility(nativeItem, abilityTypeId))
|
|
44
|
+
if prepareAbility ~= nil then
|
|
45
|
+
prepareAbility(nativeAbility, ...)
|
|
46
|
+
end
|
|
47
|
+
setItemBooleanField(nativeItem, ITEM_BF_ACTIVELY_USED, true)
|
|
48
|
+
setItemBooleanField(nativeItem, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
49
|
+
local success
|
|
50
|
+
if unitAddItem(nativeUnit, nativeItem) then
|
|
51
|
+
success = true
|
|
52
|
+
else
|
|
53
|
+
local latestInventoryAbilityTypeId = 0
|
|
54
|
+
local nativeItemBySlot = {}
|
|
55
|
+
local inventorySize = unitInventorySize(nativeUnit)
|
|
56
|
+
if inventorySize ~= 0 then
|
|
57
|
+
for slot = 0, inventorySize - 1 do
|
|
58
|
+
nativeItemBySlot[slot] = unitRemoveItemFromSlot(nativeUnit, slot)
|
|
59
|
+
end
|
|
60
|
+
local unitNativeAbility = getUnitAbilityByIndex(nativeUnit, 0)
|
|
61
|
+
local i = 1
|
|
62
|
+
while unitNativeAbility ~= nil do
|
|
63
|
+
local abilityTypeId = getAbilityId(unitNativeAbility)
|
|
64
|
+
if INVENTORY_ABILITY_TYPE_IDS[abilityTypeId] ~= nil then
|
|
65
|
+
latestInventoryAbilityTypeId = abilityTypeId
|
|
66
|
+
end
|
|
67
|
+
unitNativeAbility = getUnitAbilityByIndex(nativeUnit, i)
|
|
68
|
+
i = i + 1
|
|
69
|
+
end
|
|
70
|
+
unitRemoveAbility(nativeUnit, latestInventoryAbilityTypeId)
|
|
71
|
+
end
|
|
72
|
+
unitAddAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
|
|
73
|
+
success = unitAddItem(nativeUnit, nativeItem)
|
|
74
|
+
unitRemoveAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
|
|
75
|
+
if latestInventoryAbilityTypeId ~= 0 then
|
|
76
|
+
unitAddAbility(nativeUnit, latestInventoryAbilityTypeId)
|
|
77
|
+
for slot = 0, inventorySize - 1 do
|
|
78
|
+
local nativeItem = nativeItemBySlot[slot]
|
|
79
|
+
if nativeItem ~= nil then
|
|
80
|
+
unitAddItem(nativeUnit, nativeItem)
|
|
81
|
+
unitDropItemSlot(nativeUnit, nativeItem, slot)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
removeItem(nativeItem)
|
|
87
|
+
return success
|
|
88
|
+
end
|
|
89
|
+
return ____exports
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local disableAbility = BlzUnitDisableAbility
|
|
3
|
+
---
|
|
4
|
+
-- @internal For use by internal systems only.
|
|
5
|
+
____exports.increaseAbilityDisableCounter = function(unit, abilityTypeId, times)
|
|
6
|
+
for _ = 1, times do
|
|
7
|
+
disableAbility(unit, abilityTypeId, true, false)
|
|
8
|
+
end
|
|
9
|
+
for _ = times, -1 do
|
|
10
|
+
disableAbility(unit, abilityTypeId, false, false)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
return ____exports
|