warscript 0.0.1-dev.a58cc52 → 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 +6 -0
- package/attributes.lua +17 -1
- package/core/types/frame.lua +71 -22
- package/core/types/item.d.ts +1 -0
- package/core/types/item.lua +1 -0
- 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.lua +1 -1
- 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/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +14 -1
- package/engine/behavior.lua +230 -70
- package/engine/behaviour/ability/apply-buff.lua +5 -5
- package/engine/behaviour/ability/damage.d.ts +7 -2
- package/engine/behaviour/ability/damage.lua +31 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +16 -7
- 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.d.ts +11 -6
- package/engine/behaviour/ability.lua +38 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +39 -3
- package/engine/behaviour/unit.lua +269 -6
- package/engine/buff.d.ts +67 -22
- package/engine/buff.lua +371 -182
- package/engine/internal/ability.d.ts +7 -1
- package/engine/internal/ability.lua +64 -24
- package/engine/internal/item/ability.lua +63 -11
- 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 +12 -16
- package/engine/internal/item.lua +118 -69
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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/health-bonus.d.ts +2 -0
- package/engine/internal/object-data/health-bonus.lua +16 -0
- package/engine/internal/object-data/mana-bonus.d.ts +2 -0
- package/engine/internal/object-data/mana-bonus.lua +16 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +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/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +6 -0
- package/engine/internal/unit/bonus.lua +33 -3
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -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/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit+bonus.lua +3 -3
- package/engine/internal/unit+damage.d.ts +1 -1
- package/engine/internal/unit+damage.lua +6 -1
- package/engine/internal/unit-missile-launch.lua +52 -14
- package/engine/internal/unit.d.ts +32 -26
- package/engine/internal/unit.lua +351 -269
- package/engine/local-client.d.ts +7 -0
- package/engine/local-client.lua +86 -1
- 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/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +1 -1
- 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/health-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/reincarnation.d.ts +8 -0
- package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
- package/engine/object-data/entry/ability-type.d.ts +2 -0
- package/engine/object-data/entry/ability-type.lua +89 -8
- package/engine/object-data/entry/buff-type/applicable.lua +113 -109
- package/engine/object-data/entry/destructible-type.d.ts +27 -1
- package/engine/object-data/entry/destructible-type.lua +155 -0
- package/engine/object-data/entry/unit-type.d.ts +15 -2
- package/engine/object-data/entry/unit-type.lua +135 -33
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +9 -8
- package/engine/object-field/item.d.ts +22 -0
- package/engine/object-field/item.lua +118 -0
- package/engine/object-field/unit.d.ts +31 -5
- package/engine/object-field/unit.lua +95 -0
- package/engine/object-field.d.ts +18 -7
- package/engine/object-field.lua +294 -135
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +21 -0
- package/engine/standard/fields/ability.d.ts +2 -2
- package/engine/standard/fields/ability.lua +2 -2
- package/engine/standard/fields/item.d.ts +4 -0
- package/engine/standard/fields/item.lua +6 -0
- package/engine/standard/fields/unit.d.ts +12 -0
- package/engine/standard/fields/unit.lua +20 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +250 -10
- package/engine/unit.d.ts +6 -0
- package/engine/unit.lua +6 -0
- package/lualib_bundle.lua +1 -1
- package/math.d.ts +2 -0
- package/math.lua +14 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +10 -8
- package/objutil/object.lua +1 -1
- package/operation.lua +1 -4
- package/package.json +5 -5
- package/patch-lua.lua +15 -0
- 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-map.d.ts +35 -0
- package/utility/linked-map.lua +107 -0
- package/utility/linked-set.d.ts +4 -1
- package/utility/linked-set.lua +46 -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/records.lua +20 -1
- package/utility/types.d.ts +3 -0
- package/utility/unordered-map.d.ts +27 -0
- package/utility/unordered-map.lua +99 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
- /package/engine/internal/{object-data/armor-increase.d.ts → misc/damage-metadata-by-target.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
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,55 @@ __TS__SetDescriptor(
|
|
|
259
332
|
)
|
|
260
333
|
__TS__SetDescriptor(
|
|
261
334
|
Item.prototype,
|
|
262
|
-
"
|
|
263
|
-
{
|
|
264
|
-
get = function(self)
|
|
265
|
-
return BlzGetItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
266
|
-
end,
|
|
267
|
-
set = function(self, v)
|
|
268
|
-
SetItemDropOnDeath(self.handle, v)
|
|
269
|
-
end
|
|
270
|
-
},
|
|
271
|
-
true
|
|
272
|
-
)
|
|
273
|
-
__TS__SetDescriptor(
|
|
274
|
-
Item.prototype,
|
|
275
|
-
"droppable",
|
|
335
|
+
"dropsOnDeath",
|
|
276
336
|
{
|
|
277
337
|
get = function(self)
|
|
278
|
-
return
|
|
338
|
+
return getItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
279
339
|
end,
|
|
280
|
-
set = function(self,
|
|
281
|
-
|
|
340
|
+
set = function(self, dropsOnDeath)
|
|
341
|
+
setItemDropOnDeath(self.handle, dropsOnDeath)
|
|
282
342
|
end
|
|
283
343
|
},
|
|
284
344
|
true
|
|
285
345
|
)
|
|
286
346
|
__TS__SetDescriptor(
|
|
287
347
|
Item.prototype,
|
|
288
|
-
"
|
|
348
|
+
"canBeDropped",
|
|
289
349
|
{
|
|
290
350
|
get = function(self)
|
|
291
|
-
return
|
|
351
|
+
return getItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
|
|
292
352
|
end,
|
|
293
|
-
set = function(self,
|
|
294
|
-
|
|
353
|
+
set = function(self, canBeDropped)
|
|
354
|
+
setItemDroppable(self.handle, canBeDropped)
|
|
295
355
|
end
|
|
296
356
|
},
|
|
297
357
|
true
|
|
298
358
|
)
|
|
299
359
|
__TS__SetDescriptor(
|
|
300
360
|
Item.prototype,
|
|
301
|
-
"
|
|
361
|
+
"perishes",
|
|
302
362
|
{
|
|
303
363
|
get = function(self)
|
|
304
|
-
return
|
|
364
|
+
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
305
365
|
end,
|
|
306
|
-
set = function(self,
|
|
307
|
-
|
|
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)
|
|
308
371
|
end
|
|
309
372
|
},
|
|
310
373
|
true
|
|
311
374
|
)
|
|
312
375
|
__TS__SetDescriptor(
|
|
313
376
|
Item.prototype,
|
|
314
|
-
"
|
|
377
|
+
"isPowerUp",
|
|
315
378
|
{
|
|
316
379
|
get = function(self)
|
|
317
380
|
return isItemPowerup(self.handle)
|
|
318
381
|
end,
|
|
319
|
-
set = function(self,
|
|
320
|
-
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)
|
|
321
384
|
end
|
|
322
385
|
},
|
|
323
386
|
true
|
|
@@ -351,22 +414,6 @@ __TS__SetDescriptor(
|
|
|
351
414
|
},
|
|
352
415
|
true
|
|
353
416
|
)
|
|
354
|
-
__TS__SetDescriptor(
|
|
355
|
-
Item.prototype,
|
|
356
|
-
"usable",
|
|
357
|
-
{
|
|
358
|
-
get = function(self)
|
|
359
|
-
return getItemBooleanField(self.handle, ITEM_BF_ACTIVELY_USED)
|
|
360
|
-
end,
|
|
361
|
-
set = function(self, v)
|
|
362
|
-
local handle = self.handle
|
|
363
|
-
local powerup = isItemPowerup(handle)
|
|
364
|
-
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, v)
|
|
365
|
-
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerup)
|
|
366
|
-
end
|
|
367
|
-
},
|
|
368
|
-
true
|
|
369
|
-
)
|
|
370
417
|
__TS__SetDescriptor(
|
|
371
418
|
Item.prototype,
|
|
372
419
|
"visible",
|
|
@@ -557,10 +604,11 @@ __TS__SetDescriptor(
|
|
|
557
604
|
"charges",
|
|
558
605
|
{
|
|
559
606
|
get = function(self)
|
|
560
|
-
return
|
|
607
|
+
return getItemCharges(self.handle)
|
|
561
608
|
end,
|
|
562
609
|
set = function(self, v)
|
|
563
|
-
|
|
610
|
+
setItemCharges(self.handle, v)
|
|
611
|
+
invoke(itemChargesChangeEvent, self)
|
|
564
612
|
end
|
|
565
613
|
},
|
|
566
614
|
true
|
|
@@ -587,6 +635,7 @@ __TS__ObjectDefineProperty(
|
|
|
587
635
|
return self.onDestroyEvent
|
|
588
636
|
end}
|
|
589
637
|
)
|
|
638
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
590
639
|
local getManipulatedItem = GetManipulatedItem
|
|
591
640
|
local trigger = CreateTrigger()
|
|
592
641
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_PICKUP_ITEM)
|
|
@@ -74,9 +74,12 @@ ____exports.castAbility = function(nativeUnit, abilityTypeId, prepareAbility, ..
|
|
|
74
74
|
unitRemoveAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
|
|
75
75
|
if latestInventoryAbilityTypeId ~= 0 then
|
|
76
76
|
unitAddAbility(nativeUnit, latestInventoryAbilityTypeId)
|
|
77
|
-
for slot,
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
80
83
|
end
|
|
81
84
|
end
|
|
82
85
|
end
|
|
@@ -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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
-
local
|
|
3
|
-
local AttributeBonusAbilityType =
|
|
2
|
+
local ____attribute_2Dbonus = require("engine.object-data.entry.ability-type.attribute-bonus")
|
|
3
|
+
local AttributeBonusAbilityType = ____attribute_2Dbonus.AttributeBonusAbilityType
|
|
4
4
|
---
|
|
5
5
|
-- @internal For use by internal systems.
|
|
6
6
|
____exports.ATTRIBUTE_BONUS_DUMMY_ABILITY_TYPE_ID = compiletime(function()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____health_2Dbonus = require("engine.object-data.entry.ability-type.health-bonus")
|
|
3
|
+
local HealthBonusAbilityType = ____health_2Dbonus.HealthBonusAbilityType
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems only.
|
|
6
|
+
____exports.HEALTH_BONUS_DUMMY_ABILITY_TYPE_ID = compiletime(function()
|
|
7
|
+
local abilityType = HealthBonusAbilityType:create()
|
|
8
|
+
abilityType.isInternal = true
|
|
9
|
+
abilityType.isButtonVisible = false
|
|
10
|
+
abilityType.healthBonus = 0
|
|
11
|
+
return abilityType.id
|
|
12
|
+
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems only.
|
|
15
|
+
____exports.HEALTH_BONUS_DUMMY_ABILITY_FIELD = ABILITY_ILF_MAX_LIFE_GAINED
|
|
16
|
+
return ____exports
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____mana_2Dbonus = require("engine.object-data.entry.ability-type.mana-bonus")
|
|
3
|
+
local ManaBonusAbilityType = ____mana_2Dbonus.ManaBonusAbilityType
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems only.
|
|
6
|
+
____exports.MANA_BONUS_DUMMY_ABILITY_TYPE_ID = compiletime(function()
|
|
7
|
+
local abilityType = ManaBonusAbilityType:create()
|
|
8
|
+
abilityType.isInternal = true
|
|
9
|
+
abilityType.isButtonVisible = false
|
|
10
|
+
abilityType.manaBonus = 0
|
|
11
|
+
return abilityType.id
|
|
12
|
+
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems only.
|
|
15
|
+
____exports.MANA_BONUS_DUMMY_ABILITY_FIELD = ABILITY_ILF_MAX_MANA_GAINED
|
|
16
|
+
return ____exports
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____mana_2Dregeneration = require("engine.object-data.entry.ability-type.mana-regeneration")
|
|
3
|
+
local ManaRegenerationAbilityType = ____mana_2Dregeneration.ManaRegenerationAbilityType
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems.
|
|
6
|
+
____exports.MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = compiletime(function()
|
|
7
|
+
local abilityType = ManaRegenerationAbilityType:create()
|
|
8
|
+
abilityType.isInternal = true
|
|
9
|
+
abilityType.isButtonVisible = false
|
|
10
|
+
abilityType.manaRegenerationRateIncreaseFactor = 4
|
|
11
|
+
return abilityType.id
|
|
12
|
+
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems.
|
|
15
|
+
____exports.MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD = ABILITY_RLF_MANA_REGENERATION_BONUS_AS_FRACTION_OF_NORMAL
|
|
16
|
+
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
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { CombatClassifications } from "../../object-data/auxiliary/combat-classification";
|
|
3
3
|
declare module "../unit" {
|
|
4
4
|
interface Unit {
|
|
5
|
-
isAllowedTarget(this: Unit, source: Unit, allowedTargetCombatClassifications
|
|
5
|
+
isAllowedTarget(this: Unit, source: Unit, allowedTargetCombatClassifications?: CombatClassifications): boolean;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
declare module "../unit" {
|