warscript 0.0.1-dev.26f0c5f → 0.0.1-dev.277cbcb
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.
|
@@ -20,7 +20,6 @@ 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
|
|
24
23
|
local getItemX = GetItemX
|
|
25
24
|
local getItemY = GetItemY
|
|
26
25
|
local setAbilityRealLevelField = BlzSetAbilityRealLevelField
|
|
@@ -32,8 +31,6 @@ local unitAddItem = UnitAddItem
|
|
|
32
31
|
local unitRemoveItem = UnitRemoveItem
|
|
33
32
|
local unitUseItem = UnitUseItem
|
|
34
33
|
local unitResetCooldown = UnitResetCooldown
|
|
35
|
-
local unitInventorySize = UnitInventorySize
|
|
36
|
-
local unitItemInSlot = UnitItemInSlot
|
|
37
34
|
local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
|
|
38
35
|
if not currentMap then
|
|
39
36
|
return 0
|
|
@@ -68,7 +65,7 @@ ____exports.itemAbilityDummy = assert(CreateUnit(
|
|
|
68
65
|
270
|
|
69
66
|
))
|
|
70
67
|
local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
71
|
-
local cooldownStarterAbility =
|
|
68
|
+
local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
72
69
|
ShowUnit(____exports.itemAbilityDummy, false)
|
|
73
70
|
local function startItemCooldownInternal(handle, cooldown)
|
|
74
71
|
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
@@ -156,50 +153,4 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
|
156
153
|
end
|
|
157
154
|
return result
|
|
158
155
|
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
|
-
end
|
|
179
|
-
end
|
|
180
|
-
local result = action(...)
|
|
181
|
-
for slot = 0, unitInventorySize(unit) - 1 do
|
|
182
|
-
local item = itemBySlot[offset + slot]
|
|
183
|
-
if item ~= nil then
|
|
184
|
-
local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
|
|
185
|
-
if not isAlreadyIgnoredInEvents then
|
|
186
|
-
ignoreEventsItems[item] = true
|
|
187
|
-
end
|
|
188
|
-
local isPowerup = isItemPowerup(item)
|
|
189
|
-
if isPowerup then
|
|
190
|
-
setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
191
|
-
end
|
|
192
|
-
unitAddItemToSlot(unit, item, slot)
|
|
193
|
-
if isPowerup then
|
|
194
|
-
setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
195
|
-
end
|
|
196
|
-
if not isAlreadyIgnoredInEvents then
|
|
197
|
-
ignoreEventsItems[item] = nil
|
|
198
|
-
end
|
|
199
|
-
itemBySlot[offset + slot] = nil
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
depth = depth - 1
|
|
203
|
-
return result
|
|
204
|
-
end
|
|
205
156
|
return ____exports
|
|
@@ -267,7 +267,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
267
267
|
dropItemTarget(item: Item, target: Widget): boolean;
|
|
268
268
|
dropItemSlot(item: Item, slot: number): boolean;
|
|
269
269
|
itemInSlot(slot: number): Item | null;
|
|
270
|
-
addAbility(abilityId: number): UnitAbility |
|
|
270
|
+
addAbility(abilityId: number): UnitAbility | null;
|
|
271
271
|
makeAbilityPermanent(abilityId: number, permanent: true): boolean;
|
|
272
272
|
setAbilityLevel(abilityId: number, level: number): number;
|
|
273
273
|
getAbilityLevel(abilityId: number): number;
|
package/engine/internal/unit.lua
CHANGED
|
@@ -60,8 +60,6 @@ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage
|
|
|
60
60
|
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
61
|
local ____attributes = require("attributes")
|
|
62
62
|
local isAttribute = ____attributes.isAttribute
|
|
63
|
-
local ____ability = require("engine.internal.item.ability")
|
|
64
|
-
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
65
63
|
local match = string.match
|
|
66
64
|
local ____tostring = _G.tostring
|
|
67
65
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -667,41 +665,6 @@ end
|
|
|
667
665
|
local nextSyncId = 1
|
|
668
666
|
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
669
667
|
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
670
|
-
local function addAbility(unit, abilityTypeId)
|
|
671
|
-
local handle = unit.handle
|
|
672
|
-
if unitAddAbility(handle, abilityTypeId) then
|
|
673
|
-
local ability = UnitAbility:of(
|
|
674
|
-
checkNotNull(getUnitAbility(handle, abilityTypeId)),
|
|
675
|
-
abilityTypeId,
|
|
676
|
-
unit
|
|
677
|
-
)
|
|
678
|
-
local abilities = unit.abilities
|
|
679
|
-
abilities[#abilities + 1] = ability
|
|
680
|
-
return ability
|
|
681
|
-
end
|
|
682
|
-
return nil
|
|
683
|
-
end
|
|
684
|
-
local function getAbility(unit, abilityTypeId)
|
|
685
|
-
return UnitAbility:of(
|
|
686
|
-
getUnitAbility(unit.handle, abilityTypeId),
|
|
687
|
-
abilityTypeId,
|
|
688
|
-
unit
|
|
689
|
-
)
|
|
690
|
-
end
|
|
691
|
-
local function removeAbility(unit, abilityTypeId)
|
|
692
|
-
if unitRemoveAbility(unit.handle, abilityTypeId) then
|
|
693
|
-
local abilities = unit.abilities
|
|
694
|
-
for i = 1, #abilities do
|
|
695
|
-
if abilities[i].typeId == abilityTypeId then
|
|
696
|
-
abilities[i]:destroy()
|
|
697
|
-
tremove(abilities, i)
|
|
698
|
-
return true
|
|
699
|
-
end
|
|
700
|
-
end
|
|
701
|
-
return true
|
|
702
|
-
end
|
|
703
|
-
return false
|
|
704
|
-
end
|
|
705
668
|
____exports.Unit = __TS__Class()
|
|
706
669
|
local Unit = ____exports.Unit
|
|
707
670
|
Unit.name = "Unit"
|
|
@@ -942,13 +905,17 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
942
905
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
943
906
|
end
|
|
944
907
|
function Unit.prototype.addAbility(self, abilityId)
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
908
|
+
if unitAddAbility(self.handle, abilityId) then
|
|
909
|
+
local ability = UnitAbility:of(
|
|
910
|
+
checkNotNull(getUnitAbility(self.handle, abilityId)),
|
|
911
|
+
abilityId,
|
|
912
|
+
self
|
|
913
|
+
)
|
|
914
|
+
local abilities = self.abilities
|
|
915
|
+
abilities[#abilities + 1] = ability
|
|
916
|
+
return ability
|
|
917
|
+
end
|
|
918
|
+
return nil
|
|
952
919
|
end
|
|
953
920
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
954
921
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -963,22 +930,30 @@ function Unit.prototype.hasAbility(self, abilityId)
|
|
|
963
930
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
964
931
|
end
|
|
965
932
|
function Unit.prototype.getAbilityById(self, abilityId)
|
|
966
|
-
|
|
967
|
-
|
|
933
|
+
local handle = self.handle
|
|
934
|
+
if unitAddAbility(handle, abilityId) then
|
|
935
|
+
assert(unitRemoveAbility(handle, abilityId))
|
|
936
|
+
return nil
|
|
937
|
+
end
|
|
938
|
+
return UnitAbility:of(
|
|
939
|
+
getUnitAbility(self.handle, abilityId),
|
|
968
940
|
abilityId,
|
|
969
|
-
|
|
970
|
-
self,
|
|
971
|
-
abilityId
|
|
941
|
+
self
|
|
972
942
|
)
|
|
973
943
|
end
|
|
974
944
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
975
|
-
|
|
976
|
-
self.
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
945
|
+
if unitRemoveAbility(self.handle, abilityId) then
|
|
946
|
+
local abilities = self.abilities
|
|
947
|
+
for i = 1, #abilities do
|
|
948
|
+
if abilities[i].typeId == abilityId then
|
|
949
|
+
abilities[i]:destroy()
|
|
950
|
+
tremove(abilities, i)
|
|
951
|
+
return true
|
|
952
|
+
end
|
|
953
|
+
end
|
|
954
|
+
return true
|
|
955
|
+
end
|
|
956
|
+
return false
|
|
982
957
|
end
|
|
983
958
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
984
959
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
package/package.json
CHANGED