warscript 0.0.1-dev.87bdb89 → 0.0.1-dev.8895725
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 +71 -22
- package/core/types/handle.lua +6 -9
- package/core/types/item.d.ts +1 -0
- package/core/types/item.lua +1 -0
- package/core/types/player.d.ts +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 +3 -0
- package/engine/behaviour/ability/damage.lua +8 -2
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +7 -5
- 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 +37 -16
- 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 +26 -5
- package/engine/behaviour/unit.lua +180 -27
- package/engine/buff.d.ts +67 -22
- package/engine/buff.lua +371 -182
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +49 -26
- package/engine/internal/item/ability.lua +51 -1
- 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 +11 -14
- package/engine/internal/item.lua +81 -70
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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 -5
- package/engine/internal/unit/ability.lua +96 -21
- 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-missile-launch.lua +52 -14
- package/engine/internal/unit.d.ts +20 -24
- package/engine/internal/unit.lua +232 -240
- 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/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 +14 -4
- package/engine/object-field.lua +282 -134
- 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 +26 -3
- package/engine/text-tag.lua +217 -11
- 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 -26
- package/core/types/order.lua +0 -65
- /package/engine/internal/{object-data/armor-increase.d.ts → misc/frame-coordinates.d.ts} +0 -0
- /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import { Handle } from "../../core/types/handle";
|
|
2
|
+
import { Handle, HandleDestructor } from "../../core/types/handle";
|
|
3
3
|
import { Event } from "../../event";
|
|
4
4
|
import type { Item } from "../../core/types/item";
|
|
5
5
|
import type { Unit } from "./unit";
|
|
@@ -67,6 +67,7 @@ export declare class UnitAbility extends Ability {
|
|
|
67
67
|
get cooldownRemaining(): number;
|
|
68
68
|
set cooldownRemaining(cooldownRemaining: number);
|
|
69
69
|
interruptCast(): void;
|
|
70
|
+
protected onDestroy(): HandleDestructor;
|
|
70
71
|
static get onCreate(): Event<[UnitAbility]>;
|
|
71
72
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
72
73
|
}
|
|
@@ -93,6 +94,7 @@ export declare class ItemAbility extends Ability {
|
|
|
93
94
|
get cooldownRemaining(): number;
|
|
94
95
|
set cooldownRemaining(cooldownRemaining: number);
|
|
95
96
|
interruptCast(): void;
|
|
97
|
+
protected onDestroy(): HandleDestructor;
|
|
96
98
|
static get onCreate(): Event<[ItemAbility]>;
|
|
97
99
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
98
100
|
}
|
|
@@ -35,8 +35,6 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
|
|
|
35
35
|
local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
|
|
36
36
|
local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
|
|
37
37
|
local getHandleId = GetHandleId
|
|
38
|
-
local getItemBooleanField = BlzGetItemBooleanField
|
|
39
|
-
local setItemBooleanField = BlzSetItemBooleanField
|
|
40
38
|
local unitHideAbility = BlzUnitHideAbility
|
|
41
39
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
42
40
|
local match = string.match
|
|
@@ -232,6 +230,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
|
|
|
232
230
|
local parentTypeId = availableFields[abilityTypeId]
|
|
233
231
|
return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
|
|
234
232
|
end
|
|
233
|
+
---
|
|
234
|
+
-- @internal For use by internal systems only.
|
|
235
|
+
____exports.abilityTypeHasField = function(abilityTypeId, field)
|
|
236
|
+
field = ____type(field) == "number" and field or getHandleId(field)
|
|
237
|
+
if commonFields[field] then
|
|
238
|
+
return true
|
|
239
|
+
end
|
|
240
|
+
local id = availableFields[abilityTypeId]
|
|
241
|
+
if ____type(id) == "number" then
|
|
242
|
+
id = availableFields[id]
|
|
243
|
+
end
|
|
244
|
+
return not not (id and id[field])
|
|
245
|
+
end
|
|
235
246
|
____exports.Ability = __TS__Class()
|
|
236
247
|
local Ability = ____exports.Ability
|
|
237
248
|
Ability.name = "Ability"
|
|
@@ -247,15 +258,7 @@ function Ability.prototype.getSnapshot(self)
|
|
|
247
258
|
return nil
|
|
248
259
|
end
|
|
249
260
|
function Ability.prototype.hasField(self, field)
|
|
250
|
-
|
|
251
|
-
if commonFields[field] then
|
|
252
|
-
return true
|
|
253
|
-
end
|
|
254
|
-
local id = availableFields[self.typeId]
|
|
255
|
-
if ____type(id) == "number" then
|
|
256
|
-
id = availableFields[id]
|
|
257
|
-
end
|
|
258
|
-
return not not (id and id[field])
|
|
261
|
+
return ____exports.abilityTypeHasField(self.typeId, field)
|
|
259
262
|
end
|
|
260
263
|
function Ability.prototype.getField(self, field, level)
|
|
261
264
|
local fieldType = match(
|
|
@@ -404,16 +407,28 @@ function UnitAbility.prototype.decrementHideCounter(self)
|
|
|
404
407
|
unitHideAbility(self.u, self.typeId, false)
|
|
405
408
|
end
|
|
406
409
|
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
407
|
-
|
|
410
|
+
local unit = self.u
|
|
411
|
+
local typeId = self.typeId
|
|
412
|
+
unitHideAbility(unit, typeId, true)
|
|
413
|
+
unitDisableAbility(unit, typeId, true, false)
|
|
408
414
|
self.d = (self.d or 0) + 1
|
|
409
415
|
end
|
|
410
416
|
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
411
|
-
|
|
417
|
+
local unit = self.u
|
|
418
|
+
local typeId = self.typeId
|
|
419
|
+
unitDisableAbility(unit, typeId, false, false)
|
|
420
|
+
unitHideAbility(unit, typeId, true)
|
|
412
421
|
self.d = (self.d or 0) - 1
|
|
413
422
|
end
|
|
414
423
|
function UnitAbility.prototype.interruptCast(self)
|
|
415
424
|
self.owner:interruptCast(self.typeId)
|
|
416
425
|
end
|
|
426
|
+
function UnitAbility.prototype.onDestroy(self)
|
|
427
|
+
if self.owner.state ~= 2 then
|
|
428
|
+
self.owner:removeAbility(self.typeId)
|
|
429
|
+
end
|
|
430
|
+
return UnitAbility.____super.prototype.onDestroy(self)
|
|
431
|
+
end
|
|
417
432
|
__TS__SetDescriptor(
|
|
418
433
|
UnitAbility.prototype,
|
|
419
434
|
"isDisabled",
|
|
@@ -499,12 +514,20 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
|
|
|
499
514
|
)
|
|
500
515
|
end
|
|
501
516
|
function ItemAbility.prototype.interruptCast(self)
|
|
502
|
-
local
|
|
503
|
-
local
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
517
|
+
local item = self.owner
|
|
518
|
+
local itemHandle = item.handle
|
|
519
|
+
local ____opt_1 = item.owner
|
|
520
|
+
local itemOwnerHandle = ____opt_1 and ____opt_1.handle
|
|
521
|
+
local cooldownRemaining = doAbilityActionForceDummy(itemHandle, itemOwnerHandle, getAbilityCooldown, self.typeId)
|
|
522
|
+
if cooldownRemaining == 0 then
|
|
523
|
+
startItemCooldown(itemHandle, itemOwnerHandle, 0.015625)
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
function ItemAbility.prototype.onDestroy(self)
|
|
527
|
+
if self.owner.state ~= 2 then
|
|
528
|
+
self.owner:removeAbility(self.typeId)
|
|
507
529
|
end
|
|
530
|
+
return ItemAbility.____super.prototype.onDestroy(self)
|
|
508
531
|
end
|
|
509
532
|
__TS__SetDescriptor(
|
|
510
533
|
ItemAbility.prototype,
|
|
@@ -520,17 +543,17 @@ __TS__SetDescriptor(
|
|
|
520
543
|
{
|
|
521
544
|
get = function(self)
|
|
522
545
|
local item = self.owner
|
|
523
|
-
local
|
|
524
|
-
local
|
|
525
|
-
local
|
|
526
|
-
return
|
|
546
|
+
local ____doAbilityActionForceDummy_6 = doAbilityActionForceDummy
|
|
547
|
+
local ____item_handle_5 = item.handle
|
|
548
|
+
local ____opt_3 = item.owner
|
|
549
|
+
return ____doAbilityActionForceDummy_6(____item_handle_5, ____opt_3 and ____opt_3.handle, getAbilityCooldown, self.typeId)
|
|
527
550
|
end,
|
|
528
551
|
set = function(self, cooldownRemaining)
|
|
529
552
|
local item = self.owner
|
|
530
|
-
local
|
|
531
|
-
local
|
|
532
|
-
local
|
|
533
|
-
|
|
553
|
+
local ____startItemCooldown_10 = startItemCooldown
|
|
554
|
+
local ____item_handle_9 = item.handle
|
|
555
|
+
local ____opt_7 = item.owner
|
|
556
|
+
____startItemCooldown_10(____item_handle_9, ____opt_7 and ____opt_7.handle, cooldownRemaining)
|
|
534
557
|
end
|
|
535
558
|
},
|
|
536
559
|
true
|
|
@@ -20,6 +20,7 @@ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slo
|
|
|
20
20
|
local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
|
|
21
21
|
local isItemOwned = IsItemOwned
|
|
22
22
|
local isItemPowerup = IsItemPowerup
|
|
23
|
+
local getItemAbility = BlzGetItemAbility
|
|
23
24
|
local getItemX = GetItemX
|
|
24
25
|
local getItemY = GetItemY
|
|
25
26
|
local setAbilityRealLevelField = BlzSetAbilityRealLevelField
|
|
@@ -31,6 +32,8 @@ local unitAddItem = UnitAddItem
|
|
|
31
32
|
local unitRemoveItem = UnitRemoveItem
|
|
32
33
|
local unitUseItem = UnitUseItem
|
|
33
34
|
local unitResetCooldown = UnitResetCooldown
|
|
35
|
+
local unitInventorySize = UnitInventorySize
|
|
36
|
+
local unitItemInSlot = UnitItemInSlot
|
|
34
37
|
local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
|
|
35
38
|
if not currentMap then
|
|
36
39
|
return 0
|
|
@@ -65,7 +68,7 @@ ____exports.itemAbilityDummy = assert(CreateUnit(
|
|
|
65
68
|
270
|
|
66
69
|
))
|
|
67
70
|
local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
68
|
-
local cooldownStarterAbility =
|
|
71
|
+
local cooldownStarterAbility = getItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
69
72
|
ShowUnit(____exports.itemAbilityDummy, false)
|
|
70
73
|
local function startItemCooldownInternal(handle, cooldown)
|
|
71
74
|
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
@@ -153,4 +156,51 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
|
153
156
|
end
|
|
154
157
|
return result
|
|
155
158
|
end
|
|
159
|
+
local depth = 0
|
|
160
|
+
local itemBySlot = {}
|
|
161
|
+
---
|
|
162
|
+
-- @internal For use by internal systems only.
|
|
163
|
+
____exports.doUnitAbilityAction = function(unit, abilityTypeId, action, ...)
|
|
164
|
+
local ____depth_0 = depth
|
|
165
|
+
depth = ____depth_0 + 1
|
|
166
|
+
local offset = 6 * ____depth_0
|
|
167
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
168
|
+
local item = unitItemInSlot(unit, slot)
|
|
169
|
+
if getItemAbility(item, abilityTypeId) ~= nil then
|
|
170
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
|
|
171
|
+
if not isAlreadyIgnoredInEvents then
|
|
172
|
+
ignoreEventsItems[item] = true
|
|
173
|
+
end
|
|
174
|
+
unitRemoveItem(unit, item)
|
|
175
|
+
if not isAlreadyIgnoredInEvents then
|
|
176
|
+
ignoreEventsItems[item] = nil
|
|
177
|
+
end
|
|
178
|
+
itemBySlot[offset + slot] = item
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
local result = action(unit, ...)
|
|
182
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
183
|
+
local item = itemBySlot[offset + slot]
|
|
184
|
+
if item ~= nil then
|
|
185
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
|
|
186
|
+
if not isAlreadyIgnoredInEvents then
|
|
187
|
+
ignoreEventsItems[item] = true
|
|
188
|
+
end
|
|
189
|
+
local isPowerup = isItemPowerup(item)
|
|
190
|
+
if isPowerup then
|
|
191
|
+
setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
192
|
+
end
|
|
193
|
+
unitAddItemToSlot(unit, item, slot)
|
|
194
|
+
if isPowerup then
|
|
195
|
+
setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
196
|
+
end
|
|
197
|
+
if not isAlreadyIgnoredInEvents then
|
|
198
|
+
ignoreEventsItems[item] = nil
|
|
199
|
+
end
|
|
200
|
+
itemBySlot[offset + slot] = nil
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
depth = depth - 1
|
|
204
|
+
return result
|
|
205
|
+
end
|
|
156
206
|
return ____exports
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____item = require("engine.internal.item")
|
|
5
|
+
local Item = ____item.Item
|
|
6
|
+
local ____item = require("engine.standard.fields.item")
|
|
7
|
+
local CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD = ____item.CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD
|
|
8
|
+
local IS_ACTIVELY_USED_ITEM_FIELD = ____item.IS_ACTIVELY_USED_ITEM_FIELD
|
|
9
|
+
__TS__ObjectDefineProperty(
|
|
10
|
+
Item.prototype,
|
|
11
|
+
"canBeSold",
|
|
12
|
+
{
|
|
13
|
+
get = function(self)
|
|
14
|
+
return CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD:getValue(self)
|
|
15
|
+
end,
|
|
16
|
+
set = function(self, value)
|
|
17
|
+
CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD:setValue(self, value)
|
|
18
|
+
end
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
__TS__ObjectDefineProperty(
|
|
22
|
+
Item.prototype,
|
|
23
|
+
"isActivelyUsed",
|
|
24
|
+
{
|
|
25
|
+
get = function(self)
|
|
26
|
+
return IS_ACTIVELY_USED_ITEM_FIELD:getValue(self)
|
|
27
|
+
end,
|
|
28
|
+
set = function(self, value)
|
|
29
|
+
IS_ACTIVELY_USED_ITEM_FIELD:setValue(self, value)
|
|
30
|
+
end
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
return ____exports
|
|
@@ -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",
|
|
@@ -9,11 +9,11 @@ import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
|
9
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
10
10
|
declare const enum ItemPropertyKey {
|
|
11
11
|
ABILITIES = 100,
|
|
12
|
-
|
|
12
|
+
DEATH_TRIGGER = 101
|
|
13
13
|
}
|
|
14
14
|
export declare class Item extends Handle<jitem> {
|
|
15
15
|
private readonly [ItemPropertyKey.ABILITIES];
|
|
16
|
-
private readonly [ItemPropertyKey.
|
|
16
|
+
private readonly [ItemPropertyKey.DEATH_TRIGGER];
|
|
17
17
|
constructor(handle: jitem);
|
|
18
18
|
protected onDestroy(): HandleDestructor;
|
|
19
19
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
|
@@ -30,22 +30,18 @@ export declare class Item extends Handle<jitem> {
|
|
|
30
30
|
get extendedTooltip(): string;
|
|
31
31
|
set iconPath(v: string);
|
|
32
32
|
get iconPath(): string;
|
|
33
|
-
set
|
|
34
|
-
get
|
|
35
|
-
set
|
|
36
|
-
get
|
|
37
|
-
set
|
|
38
|
-
get
|
|
39
|
-
set
|
|
40
|
-
get
|
|
41
|
-
set powerup(v: boolean);
|
|
42
|
-
get powerup(): boolean;
|
|
33
|
+
set dropsOnDeath(dropsOnDeath: boolean);
|
|
34
|
+
get dropsOnDeath(): boolean;
|
|
35
|
+
set canBeDropped(canBeDropped: boolean);
|
|
36
|
+
get canBeDropped(): 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 usable(v: boolean);
|
|
48
|
-
get usable(): boolean;
|
|
49
45
|
set visible(v: boolean);
|
|
50
46
|
get visible(): boolean;
|
|
51
47
|
set level(v: number);
|
|
@@ -84,6 +80,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
84
80
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
85
81
|
static get onCreate(): Event<[Item]>;
|
|
86
82
|
static get destroyEvent(): Event<[Item]>;
|
|
83
|
+
static readonly deathEvent: Event<[Item]>;
|
|
87
84
|
static readonly chargesChangedEvent: Event<[Item]>;
|
|
88
85
|
}
|
|
89
86
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -27,7 +27,13 @@ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slo
|
|
|
27
27
|
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
28
28
|
local ____vec2 = require("math.vec2")
|
|
29
29
|
local distance = ____vec2.distance
|
|
30
|
-
local
|
|
30
|
+
local ____timer = require("core.types.timer")
|
|
31
|
+
local Timer = ____timer.Timer
|
|
32
|
+
local createTrigger = CreateTrigger
|
|
33
|
+
local triggerAddCondition = TriggerAddCondition
|
|
34
|
+
local triggerRegisterDeathEvent = TriggerRegisterDeathEvent
|
|
35
|
+
local condition = Condition
|
|
36
|
+
local destroyTrigger = DestroyTrigger
|
|
31
37
|
local itemAddAbility = BlzItemAddAbility
|
|
32
38
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
33
39
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -46,9 +52,21 @@ local getItemY = GetItemY
|
|
|
46
52
|
local getItemCharges = GetItemCharges
|
|
47
53
|
local setItemCharges = SetItemCharges
|
|
48
54
|
local unitRemoveAbility = UnitRemoveAbility
|
|
55
|
+
local unitRemoveItem = UnitRemoveItem
|
|
49
56
|
local unitUseItem = UnitUseItem
|
|
50
57
|
local unitUseItemPoint = UnitUseItemPoint
|
|
51
58
|
local unitUseItemTarget = UnitUseItemTarget
|
|
59
|
+
local setItemDropOnDeath = SetItemDropOnDeath
|
|
60
|
+
local setItemDroppable = SetItemDroppable
|
|
61
|
+
local getItemIntegerField = BlzGetItemIntegerField
|
|
62
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
63
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
64
|
+
local getTriggerWidget = GetTriggerWidget
|
|
65
|
+
local saveWidgetHandle = SaveWidgetHandle
|
|
66
|
+
local loadItemHandle = LoadItemHandle
|
|
67
|
+
local tableRemove = table.remove
|
|
68
|
+
local itemChargesChangeEvent = __TS__New(Event)
|
|
69
|
+
local itemDeathEvent = __TS__New(Event)
|
|
52
70
|
_G.SetItemCharges = function(whichItem, charges)
|
|
53
71
|
setItemCharges(whichItem, charges)
|
|
54
72
|
invoke(
|
|
@@ -56,9 +74,6 @@ _G.SetItemCharges = function(whichItem, charges)
|
|
|
56
74
|
____exports.Item:of(whichItem)
|
|
57
75
|
)
|
|
58
76
|
end
|
|
59
|
-
local getItemIntegerField = BlzGetItemIntegerField
|
|
60
|
-
local setItemBooleanField = BlzSetItemBooleanField
|
|
61
|
-
local getItemBooleanField = BlzGetItemBooleanField
|
|
62
77
|
invoke = Event.invoke
|
|
63
78
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
64
79
|
---
|
|
@@ -131,26 +146,48 @@ local function collectIntoTargetRange()
|
|
|
131
146
|
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
132
147
|
end
|
|
133
148
|
end
|
|
149
|
+
local hashtable = InitHashtable()
|
|
150
|
+
local deathTriggerCondition = condition(function()
|
|
151
|
+
saveWidgetHandle(
|
|
152
|
+
hashtable,
|
|
153
|
+
1,
|
|
154
|
+
1,
|
|
155
|
+
getTriggerWidget()
|
|
156
|
+
)
|
|
157
|
+
local item = ____exports.Item:of(loadItemHandle(hashtable, 1, 1))
|
|
158
|
+
if item ~= nil then
|
|
159
|
+
invoke(itemDeathEvent, item)
|
|
160
|
+
end
|
|
161
|
+
end)
|
|
162
|
+
itemDeathEvent:addListener(
|
|
163
|
+
999999,
|
|
164
|
+
function(item)
|
|
165
|
+
Timer:run(item, "destroy")
|
|
166
|
+
end
|
|
167
|
+
)
|
|
134
168
|
____exports.Item = __TS__Class()
|
|
135
169
|
local Item = ____exports.Item
|
|
136
170
|
Item.name = "Item"
|
|
137
171
|
__TS__ClassExtends(Item, Handle)
|
|
138
172
|
function Item.prototype.____constructor(self, handle)
|
|
139
173
|
Handle.prototype.____constructor(self, handle)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
end
|
|
146
|
-
self[101] = luaIndexByAbilityTypeId
|
|
174
|
+
self[100] = doAbilityAction(handle, getItemAbilities, self)
|
|
175
|
+
local deathTrigger = createTrigger()
|
|
176
|
+
triggerRegisterDeathEvent(deathTrigger, handle)
|
|
177
|
+
triggerAddCondition(deathTrigger, deathTriggerCondition)
|
|
178
|
+
self[101] = deathTrigger
|
|
147
179
|
end
|
|
148
180
|
function Item.prototype.onDestroy(self)
|
|
181
|
+
local owner = self.owner
|
|
182
|
+
if owner ~= nil then
|
|
183
|
+
unitRemoveItem(owner.handle, self.handle)
|
|
184
|
+
end
|
|
149
185
|
local abilities = self[100]
|
|
150
186
|
for i = 1, #abilities do
|
|
151
187
|
abilities[i]:destroy()
|
|
152
188
|
end
|
|
153
189
|
removeItem(self.handle)
|
|
190
|
+
destroyTrigger(self[101])
|
|
154
191
|
return Handle.prototype.onDestroy(self)
|
|
155
192
|
end
|
|
156
193
|
function Item.create(self, id, x, y, skinId)
|
|
@@ -191,33 +228,32 @@ function Item.prototype.addAbility(self, abilityTypeId)
|
|
|
191
228
|
if nativeAbility ~= nil then
|
|
192
229
|
local ability = ItemAbility:of(nativeAbility, abilityTypeId, self)
|
|
193
230
|
local abilities = self[100]
|
|
194
|
-
|
|
195
|
-
abilities[luaIndex] = ability
|
|
196
|
-
self[101][abilityTypeId] = luaIndex
|
|
231
|
+
abilities[#abilities + 1] = ability
|
|
197
232
|
return ability
|
|
198
233
|
end
|
|
199
234
|
return nil
|
|
200
235
|
end
|
|
201
236
|
function Item.prototype.removeAbility(self, abilityTypeId)
|
|
202
|
-
local
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
for j = luaIndex, abilityTypeIdsLength do
|
|
210
|
-
abilities[j] = abilities[j + 1]
|
|
237
|
+
local abilities = self[100]
|
|
238
|
+
for i = 1, #abilities do
|
|
239
|
+
if abilities[i].typeId == abilityTypeId then
|
|
240
|
+
local ability = abilities[i]
|
|
241
|
+
tableRemove(abilities, i)
|
|
242
|
+
ability:destroy()
|
|
243
|
+
return true
|
|
211
244
|
end
|
|
212
245
|
end
|
|
213
|
-
return
|
|
246
|
+
return doAbilityAction(self.handle, itemRemoveAbility, abilityTypeId)
|
|
214
247
|
end
|
|
215
248
|
function Item.prototype.hasAbility(self, abilityTypeId)
|
|
216
|
-
return self
|
|
249
|
+
return doAbilityAction(self.handle, getItemAbility, abilityTypeId) ~= nil
|
|
217
250
|
end
|
|
218
251
|
function Item.prototype.getAbility(self, abilityTypeId)
|
|
219
|
-
|
|
220
|
-
|
|
252
|
+
return ItemAbility:of(
|
|
253
|
+
doAbilityAction(self.handle, getItemAbility, abilityTypeId),
|
|
254
|
+
abilityTypeId,
|
|
255
|
+
self
|
|
256
|
+
)
|
|
221
257
|
end
|
|
222
258
|
function Item.getInRange(self, x, y, range)
|
|
223
259
|
targetCollection = {}
|
|
@@ -329,65 +365,55 @@ __TS__SetDescriptor(
|
|
|
329
365
|
)
|
|
330
366
|
__TS__SetDescriptor(
|
|
331
367
|
Item.prototype,
|
|
332
|
-
"
|
|
368
|
+
"dropsOnDeath",
|
|
333
369
|
{
|
|
334
370
|
get = function(self)
|
|
335
|
-
return
|
|
371
|
+
return getItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
336
372
|
end,
|
|
337
|
-
set = function(self,
|
|
338
|
-
|
|
373
|
+
set = function(self, dropsOnDeath)
|
|
374
|
+
setItemDropOnDeath(self.handle, dropsOnDeath)
|
|
339
375
|
end
|
|
340
376
|
},
|
|
341
377
|
true
|
|
342
378
|
)
|
|
343
379
|
__TS__SetDescriptor(
|
|
344
380
|
Item.prototype,
|
|
345
|
-
"
|
|
381
|
+
"canBeDropped",
|
|
346
382
|
{
|
|
347
383
|
get = function(self)
|
|
348
|
-
return
|
|
384
|
+
return getItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
|
|
349
385
|
end,
|
|
350
|
-
set = function(self,
|
|
351
|
-
|
|
386
|
+
set = function(self, canBeDropped)
|
|
387
|
+
setItemDroppable(self.handle, canBeDropped)
|
|
352
388
|
end
|
|
353
389
|
},
|
|
354
390
|
true
|
|
355
391
|
)
|
|
356
392
|
__TS__SetDescriptor(
|
|
357
393
|
Item.prototype,
|
|
358
|
-
"
|
|
359
|
-
{
|
|
360
|
-
get = function(self)
|
|
361
|
-
return IsItemPawnable(self.handle)
|
|
362
|
-
end,
|
|
363
|
-
set = function(self, v)
|
|
364
|
-
SetItemPawnable(self.handle, v)
|
|
365
|
-
end
|
|
366
|
-
},
|
|
367
|
-
true
|
|
368
|
-
)
|
|
369
|
-
__TS__SetDescriptor(
|
|
370
|
-
Item.prototype,
|
|
371
|
-
"perishable",
|
|
394
|
+
"perishes",
|
|
372
395
|
{
|
|
373
396
|
get = function(self)
|
|
374
397
|
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
375
398
|
end,
|
|
376
|
-
set = function(self,
|
|
377
|
-
|
|
399
|
+
set = function(self, perishes)
|
|
400
|
+
local handle = self.handle
|
|
401
|
+
local powerUp = isItemPowerup(handle)
|
|
402
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
403
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
378
404
|
end
|
|
379
405
|
},
|
|
380
406
|
true
|
|
381
407
|
)
|
|
382
408
|
__TS__SetDescriptor(
|
|
383
409
|
Item.prototype,
|
|
384
|
-
"
|
|
410
|
+
"isPowerUp",
|
|
385
411
|
{
|
|
386
412
|
get = function(self)
|
|
387
413
|
return isItemPowerup(self.handle)
|
|
388
414
|
end,
|
|
389
|
-
set = function(self,
|
|
390
|
-
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED,
|
|
415
|
+
set = function(self, isPowerUp)
|
|
416
|
+
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, isPowerUp)
|
|
391
417
|
end
|
|
392
418
|
},
|
|
393
419
|
true
|
|
@@ -421,22 +447,6 @@ __TS__SetDescriptor(
|
|
|
421
447
|
},
|
|
422
448
|
true
|
|
423
449
|
)
|
|
424
|
-
__TS__SetDescriptor(
|
|
425
|
-
Item.prototype,
|
|
426
|
-
"usable",
|
|
427
|
-
{
|
|
428
|
-
get = function(self)
|
|
429
|
-
return getItemBooleanField(self.handle, ITEM_BF_ACTIVELY_USED)
|
|
430
|
-
end,
|
|
431
|
-
set = function(self, v)
|
|
432
|
-
local handle = self.handle
|
|
433
|
-
local powerup = isItemPowerup(handle)
|
|
434
|
-
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, v)
|
|
435
|
-
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerup)
|
|
436
|
-
end
|
|
437
|
-
},
|
|
438
|
-
true
|
|
439
|
-
)
|
|
440
450
|
__TS__SetDescriptor(
|
|
441
451
|
Item.prototype,
|
|
442
452
|
"visible",
|
|
@@ -658,6 +668,7 @@ __TS__ObjectDefineProperty(
|
|
|
658
668
|
return self.onDestroyEvent
|
|
659
669
|
end}
|
|
660
670
|
)
|
|
671
|
+
Item.deathEvent = itemDeathEvent
|
|
661
672
|
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
662
673
|
local getManipulatedItem = GetManipulatedItem
|
|
663
674
|
local trigger = CreateTrigger()
|
|
@@ -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
|