warscript 0.0.1-dev.3b2adda → 0.0.1-dev.3c953c8
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 +1 -0
- package/attributes.lua +9 -0
- 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/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 +6 -4
- 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/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +11 -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 +9 -3
- package/engine/behaviour/unit/stun-immunity.lua +53 -28
- package/engine/behaviour/unit.d.ts +26 -4
- package/engine/behaviour/unit.lua +114 -13
- package/engine/buff.d.ts +12 -5
- package/engine/buff.lua +125 -87
- package/engine/internal/ability.d.ts +5 -1
- package/engine/internal/ability.lua +44 -11
- package/engine/internal/item/ability.lua +51 -1
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +15 -16
- package/engine/internal/item.lua +113 -70
- 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/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-missile-launch.lua +45 -14
- package/engine/internal/unit.d.ts +20 -16
- package/engine/internal/unit.lua +185 -136
- 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/entry/ability-type.lua +5 -4
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +24 -1
- package/engine/object-field/unit.lua +91 -0
- package/engine/object-field.d.ts +15 -6
- package/engine/object-field.lua +225 -124
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -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 +1 -1
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
- package/utility/lua-maps.d.ts +12 -2
- package/utility/lua-maps.lua +37 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
- package/utility/types.d.ts +3 -0
- package/core/types/order.d.ts +0 -26
- package/core/types/order.lua +0 -65
|
@@ -7,14 +7,11 @@ import { ItemAbility } from "./ability";
|
|
|
7
7
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
8
8
|
import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
9
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
10
|
-
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
11
10
|
declare const enum ItemPropertyKey {
|
|
12
|
-
ABILITIES = 100
|
|
13
|
-
LUA_INDEX_BY_ABILITY_TYPE_ID = 101
|
|
11
|
+
ABILITIES = 100
|
|
14
12
|
}
|
|
15
13
|
export declare class Item extends Handle<jitem> {
|
|
16
14
|
private readonly [ItemPropertyKey.ABILITIES];
|
|
17
|
-
private readonly [ItemPropertyKey.LUA_INDEX_BY_ABILITY_TYPE_ID];
|
|
18
15
|
constructor(handle: jitem);
|
|
19
16
|
protected onDestroy(): HandleDestructor;
|
|
20
17
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
|
@@ -31,22 +28,22 @@ export declare class Item extends Handle<jitem> {
|
|
|
31
28
|
get extendedTooltip(): string;
|
|
32
29
|
set iconPath(v: string);
|
|
33
30
|
get iconPath(): string;
|
|
34
|
-
set
|
|
35
|
-
get
|
|
36
|
-
set
|
|
37
|
-
get
|
|
38
|
-
set
|
|
39
|
-
get
|
|
40
|
-
set
|
|
41
|
-
get
|
|
42
|
-
set
|
|
43
|
-
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;
|
|
44
41
|
get isAlive(): boolean;
|
|
45
42
|
get isDead(): boolean;
|
|
46
43
|
set isInvulnerable(isInvulnerable: boolean);
|
|
47
44
|
get isInvulnerable(): boolean;
|
|
48
|
-
set
|
|
49
|
-
get
|
|
45
|
+
set isActivelyUsed(isActivelyUsed: boolean);
|
|
46
|
+
get isActivelyUsed(): boolean;
|
|
50
47
|
set visible(v: boolean);
|
|
51
48
|
get visible(): boolean;
|
|
52
49
|
set level(v: number);
|
|
@@ -75,6 +72,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
75
72
|
set charges(v: number);
|
|
76
73
|
get charges(): number;
|
|
77
74
|
consumeCharge(): boolean;
|
|
75
|
+
consumeCharges(count: number): boolean;
|
|
78
76
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
79
77
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
80
78
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
@@ -84,5 +82,6 @@ export declare class Item extends Handle<jitem> {
|
|
|
84
82
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
85
83
|
static get onCreate(): Event<[Item]>;
|
|
86
84
|
static get destroyEvent(): Event<[Item]>;
|
|
85
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
87
86
|
}
|
|
88
87
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
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")
|
|
@@ -23,6 +27,7 @@ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slo
|
|
|
23
27
|
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
24
28
|
local ____vec2 = require("math.vec2")
|
|
25
29
|
local distance = ____vec2.distance
|
|
30
|
+
local itemChargesChangeEvent = __TS__New(Event)
|
|
26
31
|
local itemAddAbility = BlzItemAddAbility
|
|
27
32
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
28
33
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -40,10 +45,30 @@ local getItemX = GetItemX
|
|
|
40
45
|
local getItemY = GetItemY
|
|
41
46
|
local getItemCharges = GetItemCharges
|
|
42
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
|
|
43
57
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
44
58
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
45
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
|
|
46
69
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
70
|
+
---
|
|
71
|
+
-- @internal For use by internal systems only.
|
|
47
72
|
____exports.addAndGetAbility = function(handle, abilityTypeId)
|
|
48
73
|
if itemAddAbility(handle, abilityTypeId) then
|
|
49
74
|
return getItemAbility(handle, abilityTypeId)
|
|
@@ -69,6 +94,23 @@ local function getItemAbilities(handle, item)
|
|
|
69
94
|
end
|
|
70
95
|
return abilities
|
|
71
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
|
|
72
114
|
local targetCollection
|
|
73
115
|
local targetCollectionNextIndex
|
|
74
116
|
local centerX
|
|
@@ -101,15 +143,13 @@ Item.name = "Item"
|
|
|
101
143
|
__TS__ClassExtends(Item, Handle)
|
|
102
144
|
function Item.prototype.____constructor(self, handle)
|
|
103
145
|
Handle.prototype.____constructor(self, handle)
|
|
104
|
-
|
|
105
|
-
self[100] = abilities
|
|
106
|
-
local luaIndexByAbilityTypeId = {}
|
|
107
|
-
for i = 1, #abilities do
|
|
108
|
-
luaIndexByAbilityTypeId[abilities[i].typeId] = i
|
|
109
|
-
end
|
|
110
|
-
self[101] = luaIndexByAbilityTypeId
|
|
146
|
+
self[100] = doAbilityAction(handle, getItemAbilities, self)
|
|
111
147
|
end
|
|
112
148
|
function Item.prototype.onDestroy(self)
|
|
149
|
+
local owner = self.owner
|
|
150
|
+
if owner ~= nil then
|
|
151
|
+
unitRemoveItem(owner.handle, self.handle)
|
|
152
|
+
end
|
|
113
153
|
local abilities = self[100]
|
|
114
154
|
for i = 1, #abilities do
|
|
115
155
|
abilities[i]:destroy()
|
|
@@ -121,40 +161,31 @@ function Item.create(self, id, x, y, skinId)
|
|
|
121
161
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
122
162
|
end
|
|
123
163
|
function Item.prototype.consumeCharge(self)
|
|
164
|
+
return self:consumeCharges(1)
|
|
165
|
+
end
|
|
166
|
+
function Item.prototype.consumeCharges(self, count)
|
|
124
167
|
local handle = self.handle
|
|
125
168
|
local charges = getItemCharges(handle)
|
|
126
|
-
if charges
|
|
127
|
-
setItemCharges(handle, charges -
|
|
169
|
+
if charges > count then
|
|
170
|
+
setItemCharges(handle, charges - count)
|
|
171
|
+
invoke(itemChargesChangeEvent, self)
|
|
128
172
|
return true
|
|
129
173
|
end
|
|
130
|
-
if charges ==
|
|
174
|
+
if charges == count then
|
|
131
175
|
if getItemBooleanField(handle, ITEM_BF_PERISHABLE) then
|
|
132
176
|
self:destroy()
|
|
133
177
|
return true
|
|
134
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)
|
|
135
185
|
local ____doAbilityActionForceDummy_2 = doAbilityActionForceDummy
|
|
136
186
|
local ____opt_0 = self.owner
|
|
137
|
-
____doAbilityActionForceDummy_2(
|
|
138
|
-
|
|
139
|
-
____opt_0 and ____opt_0.handle,
|
|
140
|
-
function()
|
|
141
|
-
do
|
|
142
|
-
local i = 0
|
|
143
|
-
local ability = getItemAbilityByIndex(handle, i)
|
|
144
|
-
while ability ~= nil do
|
|
145
|
-
UnitRemoveAbility(
|
|
146
|
-
itemAbilityDummy,
|
|
147
|
-
getAbilityId(ability)
|
|
148
|
-
)
|
|
149
|
-
do
|
|
150
|
-
i = i + 1
|
|
151
|
-
ability = getItemAbilityByIndex(handle, i)
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
UnitUseItem(itemAbilityDummy, handle)
|
|
156
|
-
end
|
|
157
|
-
)
|
|
187
|
+
____doAbilityActionForceDummy_2(handle, ____opt_0 and ____opt_0.handle, consumeCharge)
|
|
188
|
+
invoke(itemChargesChangeEvent, self)
|
|
158
189
|
return true
|
|
159
190
|
end
|
|
160
191
|
return false
|
|
@@ -164,33 +195,32 @@ function Item.prototype.addAbility(self, abilityTypeId)
|
|
|
164
195
|
if nativeAbility ~= nil then
|
|
165
196
|
local ability = ItemAbility:of(nativeAbility, abilityTypeId, self)
|
|
166
197
|
local abilities = self[100]
|
|
167
|
-
|
|
168
|
-
abilities[luaIndex] = ability
|
|
169
|
-
self[101][abilityTypeId] = luaIndex
|
|
198
|
+
abilities[#abilities + 1] = ability
|
|
170
199
|
return ability
|
|
171
200
|
end
|
|
172
201
|
return nil
|
|
173
202
|
end
|
|
174
203
|
function Item.prototype.removeAbility(self, abilityTypeId)
|
|
175
|
-
local
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
for j = luaIndex, abilityTypeIdsLength do
|
|
183
|
-
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
|
|
184
211
|
end
|
|
185
212
|
end
|
|
186
|
-
return
|
|
213
|
+
return doAbilityAction(self.handle, itemRemoveAbility, abilityTypeId)
|
|
187
214
|
end
|
|
188
215
|
function Item.prototype.hasAbility(self, abilityTypeId)
|
|
189
|
-
return self
|
|
216
|
+
return doAbilityAction(self.handle, getItemAbility, abilityTypeId) ~= nil
|
|
190
217
|
end
|
|
191
218
|
function Item.prototype.getAbility(self, abilityTypeId)
|
|
192
|
-
|
|
193
|
-
|
|
219
|
+
return ItemAbility:of(
|
|
220
|
+
doAbilityAction(self.handle, getItemAbility, abilityTypeId),
|
|
221
|
+
abilityTypeId,
|
|
222
|
+
self
|
|
223
|
+
)
|
|
194
224
|
end
|
|
195
225
|
function Item.getInRange(self, x, y, range)
|
|
196
226
|
targetCollection = {}
|
|
@@ -302,65 +332,68 @@ __TS__SetDescriptor(
|
|
|
302
332
|
)
|
|
303
333
|
__TS__SetDescriptor(
|
|
304
334
|
Item.prototype,
|
|
305
|
-
"
|
|
335
|
+
"dropsOnDeath",
|
|
306
336
|
{
|
|
307
337
|
get = function(self)
|
|
308
|
-
return
|
|
338
|
+
return getItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
309
339
|
end,
|
|
310
|
-
set = function(self,
|
|
311
|
-
|
|
340
|
+
set = function(self, dropsOnDeath)
|
|
341
|
+
setItemDropOnDeath(self.handle, dropsOnDeath)
|
|
312
342
|
end
|
|
313
343
|
},
|
|
314
344
|
true
|
|
315
345
|
)
|
|
316
346
|
__TS__SetDescriptor(
|
|
317
347
|
Item.prototype,
|
|
318
|
-
"
|
|
348
|
+
"canBeDropped",
|
|
319
349
|
{
|
|
320
350
|
get = function(self)
|
|
321
|
-
return
|
|
351
|
+
return getItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
|
|
322
352
|
end,
|
|
323
|
-
set = function(self,
|
|
324
|
-
|
|
353
|
+
set = function(self, canBeDropped)
|
|
354
|
+
setItemDroppable(self.handle, canBeDropped)
|
|
325
355
|
end
|
|
326
356
|
},
|
|
327
357
|
true
|
|
328
358
|
)
|
|
329
359
|
__TS__SetDescriptor(
|
|
330
360
|
Item.prototype,
|
|
331
|
-
"
|
|
361
|
+
"canBeSold",
|
|
332
362
|
{
|
|
333
363
|
get = function(self)
|
|
334
|
-
return
|
|
364
|
+
return isItemPawnable(self.handle)
|
|
335
365
|
end,
|
|
336
|
-
set = function(self,
|
|
337
|
-
|
|
366
|
+
set = function(self, canBeSold)
|
|
367
|
+
setItemPawnable(self.handle, canBeSold)
|
|
338
368
|
end
|
|
339
369
|
},
|
|
340
370
|
true
|
|
341
371
|
)
|
|
342
372
|
__TS__SetDescriptor(
|
|
343
373
|
Item.prototype,
|
|
344
|
-
"
|
|
374
|
+
"perishes",
|
|
345
375
|
{
|
|
346
376
|
get = function(self)
|
|
347
377
|
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
348
378
|
end,
|
|
349
|
-
set = function(self,
|
|
350
|
-
|
|
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)
|
|
351
384
|
end
|
|
352
385
|
},
|
|
353
386
|
true
|
|
354
387
|
)
|
|
355
388
|
__TS__SetDescriptor(
|
|
356
389
|
Item.prototype,
|
|
357
|
-
"
|
|
390
|
+
"isPowerUp",
|
|
358
391
|
{
|
|
359
392
|
get = function(self)
|
|
360
393
|
return isItemPowerup(self.handle)
|
|
361
394
|
end,
|
|
362
|
-
set = function(self,
|
|
363
|
-
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)
|
|
364
397
|
end
|
|
365
398
|
},
|
|
366
399
|
true
|
|
@@ -396,16 +429,24 @@ __TS__SetDescriptor(
|
|
|
396
429
|
)
|
|
397
430
|
__TS__SetDescriptor(
|
|
398
431
|
Item.prototype,
|
|
399
|
-
"
|
|
432
|
+
"isActivelyUsed",
|
|
400
433
|
{
|
|
401
434
|
get = function(self)
|
|
402
435
|
return getItemBooleanField(self.handle, ITEM_BF_ACTIVELY_USED)
|
|
403
436
|
end,
|
|
404
|
-
set = function(self,
|
|
437
|
+
set = function(self, isActivelyUsed)
|
|
405
438
|
local handle = self.handle
|
|
406
|
-
local
|
|
407
|
-
|
|
408
|
-
|
|
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)
|
|
409
450
|
end
|
|
410
451
|
},
|
|
411
452
|
true
|
|
@@ -604,6 +645,7 @@ __TS__SetDescriptor(
|
|
|
604
645
|
end,
|
|
605
646
|
set = function(self, v)
|
|
606
647
|
setItemCharges(self.handle, v)
|
|
648
|
+
invoke(itemChargesChangeEvent, self)
|
|
607
649
|
end
|
|
608
650
|
},
|
|
609
651
|
true
|
|
@@ -630,6 +672,7 @@ __TS__ObjectDefineProperty(
|
|
|
630
672
|
return self.onDestroyEvent
|
|
631
673
|
end}
|
|
632
674
|
)
|
|
675
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
633
676
|
local getManipulatedItem = GetManipulatedItem
|
|
634
677
|
local trigger = CreateTrigger()
|
|
635
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
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____unit = require("engine.internal.unit")
|
|
5
|
+
local Unit = ____unit.Unit
|
|
6
|
+
local ____unit = require("engine.standard.fields.unit")
|
|
7
|
+
local FLY_HEIGHT_UNIT_FLOAT_FIELD = ____unit.FLY_HEIGHT_UNIT_FLOAT_FIELD
|
|
8
|
+
__TS__ObjectDefineProperty(
|
|
9
|
+
Unit.prototype,
|
|
10
|
+
"flyHeight",
|
|
11
|
+
{
|
|
12
|
+
get = function(self)
|
|
13
|
+
return FLY_HEIGHT_UNIT_FLOAT_FIELD:getValue(self)
|
|
14
|
+
end,
|
|
15
|
+
set = function(self, value)
|
|
16
|
+
FLY_HEIGHT_UNIT_FLOAT_FIELD:setValue(self, value)
|
|
17
|
+
end
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
return ____exports
|