warscript 0.0.1-dev.f5421e8 → 0.0.1-dev.f70428f
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/core/types/frame.lua +24 -21
- package/core/types/player.d.ts +15 -0
- package/core/types/player.lua +56 -14
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/sound.lua +5 -0
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +3 -1
- package/core/types/timer.lua +27 -2
- package/decl/native.d.ts +846 -790
- package/engine/behavior.d.ts +12 -1
- package/engine/behavior.lua +172 -70
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/damage.d.ts +6 -3
- package/engine/behaviour/ability/damage.lua +24 -36
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +18 -3
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.lua +8 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +11 -5
- package/engine/behaviour/unit/stun-immunity.lua +53 -28
- package/engine/behaviour/unit.d.ts +34 -2
- package/engine/behaviour/unit.lua +192 -6
- package/engine/buff.d.ts +12 -5
- package/engine/buff.lua +125 -87
- package/engine/internal/ability.d.ts +7 -1
- package/engine/internal/ability.lua +49 -9
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +18 -17
- package/engine/internal/item.lua +135 -49
- 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/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +98 -9
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -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/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+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 +45 -14
- package/engine/internal/unit.d.ts +39 -19
- package/engine/internal/unit.lua +329 -169
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -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/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/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/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/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.lua +11 -3
- package/engine/object-data/entry/buff-type/applicable.lua +5 -0
- package/engine/object-data/entry/buff-type.d.ts +5 -11
- package/engine/object-data/entry/buff-type.lua +11 -27
- package/engine/object-data/entry/unit-type.d.ts +13 -4
- package/engine/object-data/entry/unit-type.lua +153 -85
- package/engine/object-field/ability.d.ts +4 -4
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +69 -3
- package/engine/object-field/unit.lua +264 -7
- package/engine/object-field.d.ts +23 -6
- package/engine/object-field.lua +309 -126
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/fields/unit.d.ts +6 -0
- package/engine/standard/fields/unit.lua +11 -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 +3 -0
- package/engine/unit.lua +3 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +2 -3
- package/package.json +2 -2
- 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-set.d.ts +2 -0
- package/utility/linked-set.lua +22 -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/types.d.ts +3 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
|
@@ -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.itemPickedUpEvent:addListener(
|
|
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,22 @@ 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
|
|
42
|
-
get
|
|
31
|
+
set dropsOnDeath(dropsOnDeath: boolean);
|
|
32
|
+
get dropsOnDeath(): boolean;
|
|
33
|
+
set canBeDropped(canBeDropped: boolean);
|
|
34
|
+
get canBeDropped(): boolean;
|
|
35
|
+
set canBeSold(canBeSold: boolean);
|
|
36
|
+
get canBeSold(): boolean;
|
|
37
|
+
set perishes(perishes: boolean);
|
|
38
|
+
get perishes(): boolean;
|
|
39
|
+
set isPowerUp(isPowerUp: boolean);
|
|
40
|
+
get isPowerUp(): boolean;
|
|
43
41
|
get isAlive(): boolean;
|
|
44
42
|
get isDead(): boolean;
|
|
45
43
|
set isInvulnerable(isInvulnerable: boolean);
|
|
46
44
|
get isInvulnerable(): boolean;
|
|
47
|
-
set
|
|
48
|
-
get
|
|
45
|
+
set isActivelyUsed(isActivelyUsed: boolean);
|
|
46
|
+
get isActivelyUsed(): boolean;
|
|
49
47
|
set visible(v: boolean);
|
|
50
48
|
get visible(): boolean;
|
|
51
49
|
set level(v: number);
|
|
@@ -73,6 +71,8 @@ export declare class Item extends Handle<jitem> {
|
|
|
73
71
|
set position(v: Vec2);
|
|
74
72
|
set charges(v: number);
|
|
75
73
|
get charges(): number;
|
|
74
|
+
consumeCharge(): boolean;
|
|
75
|
+
consumeCharges(count: number): boolean;
|
|
76
76
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
77
77
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
78
78
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
@@ -82,5 +82,6 @@ export declare class Item extends Handle<jitem> {
|
|
|
82
82
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
83
83
|
static get onCreate(): Event<[Item]>;
|
|
84
84
|
static get destroyEvent(): Event<[Item]>;
|
|
85
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
85
86
|
}
|
|
86
87
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -1,26 +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
|
|
18
24
|
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
19
25
|
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
20
26
|
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
21
27
|
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
22
28
|
local ____vec2 = require("math.vec2")
|
|
23
29
|
local distance = ____vec2.distance
|
|
30
|
+
local itemChargesChangeEvent = __TS__New(Event)
|
|
24
31
|
local itemAddAbility = BlzItemAddAbility
|
|
25
32
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
26
33
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -36,10 +43,32 @@ local getEnumItem = GetEnumItem
|
|
|
36
43
|
local getItemTypeId = GetItemTypeId
|
|
37
44
|
local getItemX = GetItemX
|
|
38
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
|
|
39
57
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
40
58
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
41
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
|
|
42
69
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
70
|
+
---
|
|
71
|
+
-- @internal For use by internal systems only.
|
|
43
72
|
____exports.addAndGetAbility = function(handle, abilityTypeId)
|
|
44
73
|
if itemAddAbility(handle, abilityTypeId) then
|
|
45
74
|
return getItemAbility(handle, abilityTypeId)
|
|
@@ -65,6 +94,23 @@ local function getItemAbilities(handle, item)
|
|
|
65
94
|
end
|
|
66
95
|
return abilities
|
|
67
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
|
|
68
114
|
local targetCollection
|
|
69
115
|
local targetCollectionNextIndex
|
|
70
116
|
local centerX
|
|
@@ -97,15 +143,13 @@ Item.name = "Item"
|
|
|
97
143
|
__TS__ClassExtends(Item, Handle)
|
|
98
144
|
function Item.prototype.____constructor(self, handle)
|
|
99
145
|
Handle.prototype.____constructor(self, handle)
|
|
100
|
-
|
|
101
|
-
self[100] = abilities
|
|
102
|
-
local luaIndexByAbilityTypeId = {}
|
|
103
|
-
for i = 1, #abilities do
|
|
104
|
-
luaIndexByAbilityTypeId[abilities[i].typeId] = i
|
|
105
|
-
end
|
|
106
|
-
self[101] = luaIndexByAbilityTypeId
|
|
146
|
+
self[100] = doAbilityAction(handle, getItemAbilities, self)
|
|
107
147
|
end
|
|
108
148
|
function Item.prototype.onDestroy(self)
|
|
149
|
+
local owner = self.owner
|
|
150
|
+
if owner ~= nil then
|
|
151
|
+
unitRemoveItem(owner.handle, self.handle)
|
|
152
|
+
end
|
|
109
153
|
local abilities = self[100]
|
|
110
154
|
for i = 1, #abilities do
|
|
111
155
|
abilities[i]:destroy()
|
|
@@ -116,38 +160,67 @@ end
|
|
|
116
160
|
function Item.create(self, id, x, y, skinId)
|
|
117
161
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
118
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
|
|
119
193
|
function Item.prototype.addAbility(self, abilityTypeId)
|
|
120
194
|
local nativeAbility = doAbilityAction(self.handle, ____exports.addAndGetAbility, abilityTypeId)
|
|
121
195
|
if nativeAbility ~= nil then
|
|
122
196
|
local ability = ItemAbility:of(nativeAbility, abilityTypeId, self)
|
|
123
197
|
local abilities = self[100]
|
|
124
|
-
|
|
125
|
-
abilities[luaIndex] = ability
|
|
126
|
-
self[101][abilityTypeId] = luaIndex
|
|
198
|
+
abilities[#abilities + 1] = ability
|
|
127
199
|
return ability
|
|
128
200
|
end
|
|
129
201
|
return nil
|
|
130
202
|
end
|
|
131
203
|
function Item.prototype.removeAbility(self, abilityTypeId)
|
|
132
|
-
local
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
for j = luaIndex, abilityTypeIdsLength do
|
|
140
|
-
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
|
|
141
211
|
end
|
|
142
212
|
end
|
|
143
|
-
return
|
|
213
|
+
return doAbilityAction(self.handle, itemRemoveAbility, abilityTypeId)
|
|
144
214
|
end
|
|
145
215
|
function Item.prototype.hasAbility(self, abilityTypeId)
|
|
146
|
-
return self
|
|
216
|
+
return doAbilityAction(self.handle, getItemAbility, abilityTypeId) ~= nil
|
|
147
217
|
end
|
|
148
218
|
function Item.prototype.getAbility(self, abilityTypeId)
|
|
149
|
-
|
|
150
|
-
|
|
219
|
+
return ItemAbility:of(
|
|
220
|
+
doAbilityAction(self.handle, getItemAbility, abilityTypeId),
|
|
221
|
+
abilityTypeId,
|
|
222
|
+
self
|
|
223
|
+
)
|
|
151
224
|
end
|
|
152
225
|
function Item.getInRange(self, x, y, range)
|
|
153
226
|
targetCollection = {}
|
|
@@ -259,65 +332,68 @@ __TS__SetDescriptor(
|
|
|
259
332
|
)
|
|
260
333
|
__TS__SetDescriptor(
|
|
261
334
|
Item.prototype,
|
|
262
|
-
"
|
|
335
|
+
"dropsOnDeath",
|
|
263
336
|
{
|
|
264
337
|
get = function(self)
|
|
265
|
-
return
|
|
338
|
+
return getItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
266
339
|
end,
|
|
267
|
-
set = function(self,
|
|
268
|
-
|
|
340
|
+
set = function(self, dropsOnDeath)
|
|
341
|
+
setItemDropOnDeath(self.handle, dropsOnDeath)
|
|
269
342
|
end
|
|
270
343
|
},
|
|
271
344
|
true
|
|
272
345
|
)
|
|
273
346
|
__TS__SetDescriptor(
|
|
274
347
|
Item.prototype,
|
|
275
|
-
"
|
|
348
|
+
"canBeDropped",
|
|
276
349
|
{
|
|
277
350
|
get = function(self)
|
|
278
|
-
return
|
|
351
|
+
return getItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
|
|
279
352
|
end,
|
|
280
|
-
set = function(self,
|
|
281
|
-
|
|
353
|
+
set = function(self, canBeDropped)
|
|
354
|
+
setItemDroppable(self.handle, canBeDropped)
|
|
282
355
|
end
|
|
283
356
|
},
|
|
284
357
|
true
|
|
285
358
|
)
|
|
286
359
|
__TS__SetDescriptor(
|
|
287
360
|
Item.prototype,
|
|
288
|
-
"
|
|
361
|
+
"canBeSold",
|
|
289
362
|
{
|
|
290
363
|
get = function(self)
|
|
291
|
-
return
|
|
364
|
+
return isItemPawnable(self.handle)
|
|
292
365
|
end,
|
|
293
|
-
set = function(self,
|
|
294
|
-
|
|
366
|
+
set = function(self, canBeSold)
|
|
367
|
+
setItemPawnable(self.handle, canBeSold)
|
|
295
368
|
end
|
|
296
369
|
},
|
|
297
370
|
true
|
|
298
371
|
)
|
|
299
372
|
__TS__SetDescriptor(
|
|
300
373
|
Item.prototype,
|
|
301
|
-
"
|
|
374
|
+
"perishes",
|
|
302
375
|
{
|
|
303
376
|
get = function(self)
|
|
304
|
-
return
|
|
377
|
+
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
305
378
|
end,
|
|
306
|
-
set = function(self,
|
|
307
|
-
|
|
379
|
+
set = function(self, perishes)
|
|
380
|
+
local handle = self.handle
|
|
381
|
+
local powerUp = isItemPowerup(handle)
|
|
382
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
383
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
308
384
|
end
|
|
309
385
|
},
|
|
310
386
|
true
|
|
311
387
|
)
|
|
312
388
|
__TS__SetDescriptor(
|
|
313
389
|
Item.prototype,
|
|
314
|
-
"
|
|
390
|
+
"isPowerUp",
|
|
315
391
|
{
|
|
316
392
|
get = function(self)
|
|
317
393
|
return isItemPowerup(self.handle)
|
|
318
394
|
end,
|
|
319
|
-
set = function(self,
|
|
320
|
-
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED,
|
|
395
|
+
set = function(self, isPowerUp)
|
|
396
|
+
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, isPowerUp)
|
|
321
397
|
end
|
|
322
398
|
},
|
|
323
399
|
true
|
|
@@ -353,16 +429,24 @@ __TS__SetDescriptor(
|
|
|
353
429
|
)
|
|
354
430
|
__TS__SetDescriptor(
|
|
355
431
|
Item.prototype,
|
|
356
|
-
"
|
|
432
|
+
"isActivelyUsed",
|
|
357
433
|
{
|
|
358
434
|
get = function(self)
|
|
359
435
|
return getItemBooleanField(self.handle, ITEM_BF_ACTIVELY_USED)
|
|
360
436
|
end,
|
|
361
|
-
set = function(self,
|
|
437
|
+
set = function(self, isActivelyUsed)
|
|
362
438
|
local handle = self.handle
|
|
363
|
-
local
|
|
364
|
-
|
|
365
|
-
|
|
439
|
+
local powerUp = isItemPowerup(handle)
|
|
440
|
+
local perishes = getItemBooleanField(handle, ITEM_BF_PERISHABLE)
|
|
441
|
+
local dropsOnDeath = getItemBooleanField(handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
442
|
+
local canBeDropped = getItemBooleanField(handle, ITEM_BF_CAN_BE_DROPPED)
|
|
443
|
+
local canBeSold = isItemPawnable(handle)
|
|
444
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, isActivelyUsed)
|
|
445
|
+
setItemPawnable(handle, canBeSold)
|
|
446
|
+
setItemDroppable(handle, canBeDropped)
|
|
447
|
+
setItemDropOnDeath(handle, dropsOnDeath)
|
|
448
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
449
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
366
450
|
end
|
|
367
451
|
},
|
|
368
452
|
true
|
|
@@ -557,10 +641,11 @@ __TS__SetDescriptor(
|
|
|
557
641
|
"charges",
|
|
558
642
|
{
|
|
559
643
|
get = function(self)
|
|
560
|
-
return
|
|
644
|
+
return getItemCharges(self.handle)
|
|
561
645
|
end,
|
|
562
646
|
set = function(self, v)
|
|
563
|
-
|
|
647
|
+
setItemCharges(self.handle, v)
|
|
648
|
+
invoke(itemChargesChangeEvent, self)
|
|
564
649
|
end
|
|
565
650
|
},
|
|
566
651
|
true
|
|
@@ -587,6 +672,7 @@ __TS__ObjectDefineProperty(
|
|
|
587
672
|
return self.onDestroyEvent
|
|
588
673
|
end}
|
|
589
674
|
)
|
|
675
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
590
676
|
local getManipulatedItem = GetManipulatedItem
|
|
591
677
|
local trigger = CreateTrigger()
|
|
592
678
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_PICKUP_ITEM)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
3
|
+
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems only.
|
|
6
|
+
____exports.getFrameMinXMaxX = function()
|
|
7
|
+
local w = getLocalClientWidth()
|
|
8
|
+
local h = getLocalClientHeight()
|
|
9
|
+
local width4by3 = (w - h / 600 * 800) / 2
|
|
10
|
+
local pxtodpi = 0.6 / h
|
|
11
|
+
local minX = -width4by3 * pxtodpi
|
|
12
|
+
local maxX = minX + w * pxtodpi
|
|
13
|
+
return minX, maxX
|
|
14
|
+
end
|
|
15
|
+
---
|
|
16
|
+
-- @internal For use by internal systems only.
|
|
17
|
+
____exports.FRAME_MIN_Y = 0
|
|
18
|
+
---
|
|
19
|
+
-- @internal For use by internal systems only.
|
|
20
|
+
____exports.FRAME_MAX_Y = 0.6
|
|
21
|
+
return ____exports
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local getLocationZ = GetLocationZ
|
|
3
|
+
local moveLocation = MoveLocation
|
|
4
|
+
local location = Location(0, 0)
|
|
5
|
+
---
|
|
6
|
+
-- @internal For use by internal systems only.
|
|
7
|
+
____exports.getTerrainZ = function(x, y)
|
|
8
|
+
moveLocation(location, x, y)
|
|
9
|
+
return getLocationZ(location)
|
|
10
|
+
end
|
|
11
|
+
return ____exports
|
|
@@ -150,3 +150,38 @@ declare module "../unit" {
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
declare module "../unit" {
|
|
154
|
+
namespace Unit {
|
|
155
|
+
const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
declare module "../unit" {
|
|
159
|
+
namespace Unit {
|
|
160
|
+
const abilityWidgetTargetImpactEvent: DispatchingEvent<[Unit, Ability, Widget]>;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
declare module "../unit" {
|
|
164
|
+
namespace Unit {
|
|
165
|
+
const abilityUnitTargetImpactEvent: DispatchingEvent<[Unit, Ability, Unit]>;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
declare module "../unit" {
|
|
169
|
+
namespace Unit {
|
|
170
|
+
const abilityItemTargetImpactEvent: DispatchingEvent<[Unit, Ability, Item]>;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
declare module "../unit" {
|
|
174
|
+
namespace Unit {
|
|
175
|
+
const abilityDestructibleTargetImpactEvent: DispatchingEvent<[Unit, Ability, Destructable]>;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
declare module "../unit" {
|
|
179
|
+
namespace Unit {
|
|
180
|
+
const abilityPointTargetImpactEvent: DispatchingEvent<[Unit, Ability, number, number]>;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
declare module "../unit" {
|
|
184
|
+
namespace Unit {
|
|
185
|
+
const abilityNoTargetImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -21,6 +21,13 @@ local ____preconditions = require("utility.preconditions")
|
|
|
21
21
|
local checkNotNull = ____preconditions.checkNotNull
|
|
22
22
|
local ____lazy = require("utility.lazy")
|
|
23
23
|
local lazyRecord = ____lazy.lazyRecord
|
|
24
|
+
local ____timer = require("core.types.timer")
|
|
25
|
+
local consumeZeroTimerCallback = ____timer.consumeZeroTimerCallback
|
|
26
|
+
local Timer = ____timer.Timer
|
|
27
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
28
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
29
|
+
local ____attributes = require("attributes")
|
|
30
|
+
local attribute = ____attributes.attribute
|
|
24
31
|
local eventInvoke = Event.invoke
|
|
25
32
|
local condition = Condition
|
|
26
33
|
local createTrigger = CreateTrigger
|
|
@@ -345,21 +352,17 @@ rawset(
|
|
|
345
352
|
extractAbilityTypeId
|
|
346
353
|
)
|
|
347
354
|
)
|
|
355
|
+
local internalAbilityChannelingFinishEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters)
|
|
348
356
|
rawset(
|
|
349
357
|
Unit,
|
|
350
358
|
"abilityChannelingFinishEvent",
|
|
351
|
-
createDispatchingEvent(
|
|
352
|
-
__TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters),
|
|
353
|
-
extractAbilityTypeId
|
|
354
|
-
)
|
|
359
|
+
createDispatchingEvent(internalAbilityChannelingFinishEvent, extractAbilityTypeId)
|
|
355
360
|
)
|
|
361
|
+
local internalAbilityStopEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters)
|
|
356
362
|
rawset(
|
|
357
363
|
Unit,
|
|
358
364
|
"abilityStopEvent",
|
|
359
|
-
createDispatchingEvent(
|
|
360
|
-
__TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters),
|
|
361
|
-
extractAbilityTypeId
|
|
362
|
-
)
|
|
365
|
+
createDispatchingEvent(internalAbilityStopEvent, extractAbilityTypeId)
|
|
363
366
|
)
|
|
364
367
|
rawset(
|
|
365
368
|
Unit,
|
|
@@ -376,7 +379,7 @@ rawset(
|
|
|
376
379
|
condition(function()
|
|
377
380
|
local unit = Unit:of(getTriggerUnit())
|
|
378
381
|
if unit ~= nil then
|
|
379
|
-
local ability = unit:
|
|
382
|
+
local ability = unit:getAbility(abilityTypeId)
|
|
380
383
|
if ability ~= nil then
|
|
381
384
|
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
382
385
|
end
|
|
@@ -388,4 +391,90 @@ rawset(
|
|
|
388
391
|
end)
|
|
389
392
|
end)
|
|
390
393
|
)
|
|
394
|
+
local internalAbilityImpactEvent = __TS__New(Event)
|
|
395
|
+
local impactCallbackIdAttribute = attribute()
|
|
396
|
+
local function invokeImpactEvent(unit, ability, ...)
|
|
397
|
+
ability[impactCallbackIdAttribute] = nil
|
|
398
|
+
eventInvoke(internalAbilityImpactEvent, unit, ability, ...)
|
|
399
|
+
end
|
|
400
|
+
internalAbilityChannelingStartEvent:addListener(
|
|
401
|
+
999999,
|
|
402
|
+
function(unit, ability, ...)
|
|
403
|
+
ability[impactCallbackIdAttribute] = Timer:run(invokeImpactEvent, unit, ability, ...)
|
|
404
|
+
end
|
|
405
|
+
)
|
|
406
|
+
local function consumeImpactCallback(_, ability)
|
|
407
|
+
local impactCallbackId = ability[impactCallbackIdAttribute]
|
|
408
|
+
if impactCallbackId ~= nil then
|
|
409
|
+
consumeZeroTimerCallback(impactCallbackId)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
internalAbilityChannelingFinishEvent:addListener(999999, consumeImpactCallback)
|
|
413
|
+
internalAbilityStopEvent:addListener(999999, consumeImpactCallback)
|
|
414
|
+
rawset(
|
|
415
|
+
Unit,
|
|
416
|
+
"abilityImpactEvent",
|
|
417
|
+
createDispatchingEvent(
|
|
418
|
+
createCommonEvent(internalAbilityImpactEvent),
|
|
419
|
+
extractAbilityTypeId
|
|
420
|
+
)
|
|
421
|
+
)
|
|
422
|
+
rawset(
|
|
423
|
+
Unit,
|
|
424
|
+
"abilityWidgetTargetImpactEvent",
|
|
425
|
+
createDispatchingEvent(
|
|
426
|
+
createWidgetTargetEvent(internalAbilityImpactEvent),
|
|
427
|
+
extractAbilityTypeId
|
|
428
|
+
)
|
|
429
|
+
)
|
|
430
|
+
rawset(
|
|
431
|
+
Unit,
|
|
432
|
+
"abilityUnitTargetImpactEvent",
|
|
433
|
+
createDispatchingEvent(
|
|
434
|
+
createUnitTargetEvent(internalAbilityImpactEvent),
|
|
435
|
+
extractAbilityTypeId
|
|
436
|
+
)
|
|
437
|
+
)
|
|
438
|
+
rawset(
|
|
439
|
+
Unit,
|
|
440
|
+
"abilityItemTargetImpactEvent",
|
|
441
|
+
createDispatchingEvent(
|
|
442
|
+
createItemTargetEvent(internalAbilityImpactEvent),
|
|
443
|
+
extractAbilityTypeId
|
|
444
|
+
)
|
|
445
|
+
)
|
|
446
|
+
rawset(
|
|
447
|
+
Unit,
|
|
448
|
+
"abilityDestructibleTargetImpactEvent",
|
|
449
|
+
createDispatchingEvent(
|
|
450
|
+
createDestructibleTargetEvent(internalAbilityImpactEvent),
|
|
451
|
+
extractAbilityTypeId
|
|
452
|
+
)
|
|
453
|
+
)
|
|
454
|
+
rawset(
|
|
455
|
+
Unit,
|
|
456
|
+
"abilityPointTargetImpactEvent",
|
|
457
|
+
createDispatchingEvent(
|
|
458
|
+
createPointTargetEvent(internalAbilityImpactEvent),
|
|
459
|
+
extractAbilityTypeId
|
|
460
|
+
)
|
|
461
|
+
)
|
|
462
|
+
rawset(
|
|
463
|
+
Unit,
|
|
464
|
+
"abilityNoTargetImpactEvent",
|
|
465
|
+
createDispatchingEvent(
|
|
466
|
+
createNoTargetEvent(internalAbilityImpactEvent),
|
|
467
|
+
extractAbilityTypeId
|
|
468
|
+
)
|
|
469
|
+
)
|
|
470
|
+
local spellEffectOnlyAbilityTypeIds = luaSetOf(fourCC("AAns"))
|
|
471
|
+
internalAbilityChannelingStartEvent:addListener(
|
|
472
|
+
-999999,
|
|
473
|
+
function(unit, ability)
|
|
474
|
+
if spellEffectOnlyAbilityTypeIds[ability.parentTypeId] ~= nil then
|
|
475
|
+
eventInvoke(internalAbilityChannelingFinishEvent, unit, ability)
|
|
476
|
+
eventInvoke(internalAbilityStopEvent, unit, ability)
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
)
|
|
391
480
|
return ____exports
|