warscript 0.0.1-dev.2af030d → 0.0.1-dev.3094932
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 +0 -1
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/core/types/effect.d.ts +13 -3
- package/core/types/effect.lua +116 -17
- package/core/types/frame.d.ts +8 -1
- package/core/types/frame.lua +93 -1
- package/core/types/group.d.ts +0 -1
- package/core/types/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +12 -0
- package/decl/index.d.ts +1 -0
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +10 -10
- package/engine/behavior.lua +6 -6
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +3 -5
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
- package/engine/behaviour/ability/damage.d.ts +33 -11
- package/engine/behaviour/ability/damage.lua +89 -31
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +28 -0
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -15
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -0
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +21 -3
- package/engine/behaviour/ability.lua +120 -12
- package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
- package/engine/behaviour/unit.d.ts +8 -2
- package/engine/behaviour/unit.lua +27 -0
- package/engine/buff.d.ts +68 -21
- package/engine/buff.lua +276 -90
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +16 -13
- package/engine/internal/ability.lua +80 -76
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/unit/ability.d.ts +10 -1
- package/engine/internal/unit/ability.lua +36 -14
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +50 -0
- package/engine/internal/unit/bonus.d.ts +9 -8
- package/engine/internal/unit/bonus.lua +6 -1
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +51 -0
- package/engine/internal/unit+ability.lua +2 -2
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +24 -5
- package/engine/internal/unit.d.ts +28 -12
- package/engine/internal/unit.lua +178 -86
- package/engine/internal/utility.lua +12 -0
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
- package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
- package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -0
- package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- package/engine/object-data/entry/ability-type.d.ts +0 -1
- package/engine/object-data/entry/ability-type.lua +8 -12
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +0 -1
- package/engine/object-data/entry/destructible-type.d.ts +0 -1
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +14 -1
- package/engine/object-data/entry/item-type.lua +91 -0
- package/engine/object-data/entry/lightning-type.d.ts +0 -1
- package/engine/object-data/entry/unit-type.d.ts +0 -1
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +0 -1
- package/engine/object-data/entry.d.ts +2 -3
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +26 -3
- package/engine/object-field/ability.lua +54 -1
- package/engine/object-field.d.ts +2 -3
- package/engine/object-field.lua +4 -0
- package/engine/random.d.ts +1 -0
- package/engine/random.lua +9 -0
- package/engine/standard/entries/unit-type.d.ts +18 -0
- package/engine/standard/entries/unit-type.lua +18 -0
- package/engine/standard/fields/ability.d.ts +3 -1
- package/engine/standard/fields/ability.lua +3 -1
- package/engine/unit.d.ts +3 -0
- package/engine/unit.lua +12 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +1 -1
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/package.json +13 -13
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +16 -0
- package/string.lua +5 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +11 -5
- package/utility/arrays.lua +34 -3
- package/utility/bit-set.d.ts +0 -2
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +11 -3
- package/utility/linked-set.lua +5 -2
- package/utility/lua-maps.d.ts +1 -2
- package/utility/lua-sets.d.ts +1 -2
- package/utility/types.d.ts +1 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
package/engine/internal/unit.lua
CHANGED
|
@@ -7,6 +7,9 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
8
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
9
9
|
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
10
|
+
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
11
|
+
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
12
|
+
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
10
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
@@ -48,6 +51,8 @@ local ____arrays = require("utility.arrays")
|
|
|
48
51
|
local forEach = ____arrays.forEach
|
|
49
52
|
local ____math = require("math")
|
|
50
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
51
56
|
local match = string.match
|
|
52
57
|
local ____tostring = _G.tostring
|
|
53
58
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -72,6 +77,7 @@ local setUnitScale = SetUnitScale
|
|
|
72
77
|
local setUnitPosition = SetUnitPosition
|
|
73
78
|
local setUnitTimeScale = SetUnitTimeScale
|
|
74
79
|
local getHandleId = GetHandleId
|
|
80
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
75
81
|
local createUnit = CreateUnit
|
|
76
82
|
local killUnit = KillUnit
|
|
77
83
|
local setUnitExploded = SetUnitExploded
|
|
@@ -279,16 +285,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
279
285
|
end
|
|
280
286
|
local function dispatch(event, idGetter, argsGetter)
|
|
281
287
|
local initialized = false
|
|
282
|
-
local x = {}
|
|
283
288
|
return setmetatable(
|
|
284
|
-
|
|
289
|
+
{},
|
|
285
290
|
{
|
|
286
291
|
__index = function(self, id)
|
|
287
292
|
if type(id) ~= "number" then
|
|
288
293
|
return event[id]
|
|
289
294
|
end
|
|
290
295
|
if not initialized then
|
|
291
|
-
local invoke = Event.invoke
|
|
292
296
|
event:addListener(function(...)
|
|
293
297
|
local id = idGetter(...)
|
|
294
298
|
local dispatched = rawget(self, id)
|
|
@@ -326,7 +330,6 @@ local function dispatchAbility(event)
|
|
|
326
330
|
return event[id]
|
|
327
331
|
end
|
|
328
332
|
if not initialized then
|
|
329
|
-
local invoke = Event.invoke
|
|
330
333
|
event:addListener(function(unit, ability, ...)
|
|
331
334
|
local dispatched = rawget(self, ability.typeId)
|
|
332
335
|
if dispatched ~= nil then
|
|
@@ -562,17 +565,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
565
|
____exports.Unit:of(unit)
|
|
563
566
|
)
|
|
564
567
|
end
|
|
565
|
-
if not unitAddAbility(unit, abilityId) then
|
|
566
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
567
|
-
return UnitAbility:of(
|
|
568
|
-
ability,
|
|
569
|
-
abilityId,
|
|
570
|
-
____exports.Unit:of(unit)
|
|
571
|
-
)
|
|
572
|
-
end
|
|
573
|
-
else
|
|
574
|
-
unitRemoveAbility(unit, abilityId)
|
|
575
|
-
end
|
|
576
568
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
569
|
local item = unitItemInSlot(unit, i)
|
|
578
570
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -630,15 +622,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
622
|
dummies[player] = dummy
|
|
631
623
|
end
|
|
632
624
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
625
|
+
local counter = (unit[103] or 0) - 1
|
|
634
626
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
627
|
+
unit[103] = counter
|
|
636
628
|
return
|
|
637
629
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
630
|
+
unit[103] = nil
|
|
631
|
+
local healthBonus = unit[104]
|
|
640
632
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
633
|
+
unit[104] = nil
|
|
642
634
|
local handle = unit.handle
|
|
643
635
|
BlzSetUnitMaxHP(
|
|
644
636
|
handle,
|
|
@@ -646,12 +638,17 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
638
|
)
|
|
647
639
|
end
|
|
648
640
|
end
|
|
641
|
+
local nextSyncId = 1
|
|
642
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
649
643
|
____exports.Unit = __TS__Class()
|
|
650
644
|
local Unit = ____exports.Unit
|
|
651
645
|
Unit.name = "Unit"
|
|
652
646
|
__TS__ClassExtends(Unit, Handle)
|
|
653
647
|
function Unit.prototype.____constructor(self, handle)
|
|
654
648
|
Handle.prototype.____constructor(self, handle)
|
|
649
|
+
local ____nextSyncId_0 = nextSyncId
|
|
650
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
651
|
+
self.syncId = ____nextSyncId_0
|
|
655
652
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
653
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
654
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +661,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
661
|
fourCC("Amrf")
|
|
665
662
|
))
|
|
666
663
|
end
|
|
664
|
+
unitBySyncId[self.syncId] = self
|
|
667
665
|
local ____ = self.abilities
|
|
668
666
|
end
|
|
669
667
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -749,8 +747,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
747
|
end}
|
|
750
748
|
end
|
|
751
749
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
750
|
+
local ____combatClassification_1 = combatClassification
|
|
751
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
754
752
|
end
|
|
755
753
|
function Unit.prototype.addClassification(self, classification)
|
|
756
754
|
return unitAddType(self.handle, classification)
|
|
@@ -768,13 +766,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
766
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
767
|
end
|
|
770
768
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
769
|
+
local ____temp_2
|
|
772
770
|
if type(x) == "number" then
|
|
773
|
-
|
|
771
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
772
|
else
|
|
775
|
-
|
|
773
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
776
774
|
end
|
|
777
|
-
return
|
|
775
|
+
return ____temp_2
|
|
778
776
|
end
|
|
779
777
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
778
|
return isUnitAlly(
|
|
@@ -801,7 +799,7 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
801
799
|
queueUnitAnimation(self.handle, animation)
|
|
802
800
|
end
|
|
803
801
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
802
|
+
self[103] = (self[103] or 0) + 1
|
|
805
803
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
804
|
end
|
|
807
805
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -817,8 +815,15 @@ end
|
|
|
817
815
|
function Unit.prototype.kill(self)
|
|
818
816
|
killUnit(self.handle)
|
|
819
817
|
end
|
|
820
|
-
function Unit.prototype.revive(self,
|
|
821
|
-
|
|
818
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
819
|
+
local ____ReviveHero_5 = ReviveHero
|
|
820
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
821
|
+
local ____doEffect_3 = doEffect
|
|
822
|
+
if ____doEffect_3 == nil then
|
|
823
|
+
____doEffect_3 = false
|
|
824
|
+
end
|
|
825
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
826
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
822
827
|
end
|
|
823
828
|
function Unit.prototype.healTarget(self, target, amount)
|
|
824
829
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -858,7 +863,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
858
863
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
859
864
|
end
|
|
860
865
|
function Unit.prototype.itemInSlot(self, slot)
|
|
861
|
-
return Item:of(
|
|
866
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
862
867
|
end
|
|
863
868
|
function Unit.prototype.addAbility(self, abilityId)
|
|
864
869
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -914,6 +919,9 @@ end
|
|
|
914
919
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
915
920
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
916
921
|
end
|
|
922
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
923
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
924
|
+
end
|
|
917
925
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
918
926
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
919
927
|
end
|
|
@@ -924,8 +932,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
924
932
|
unitInterruptAttack(self.handle)
|
|
925
933
|
end
|
|
926
934
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
927
|
-
|
|
928
|
-
unitDisableAbility(
|
|
935
|
+
local handle = self.handle
|
|
936
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
937
|
+
Timer:run(
|
|
938
|
+
unitDisableAbility,
|
|
939
|
+
handle,
|
|
940
|
+
abilityId,
|
|
941
|
+
false,
|
|
942
|
+
false
|
|
943
|
+
)
|
|
929
944
|
end
|
|
930
945
|
function Unit.prototype.getDistanceTo(self, target)
|
|
931
946
|
local handle = self.handle
|
|
@@ -985,18 +1000,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
985
1000
|
self:decrementStunCounter()
|
|
986
1001
|
end
|
|
987
1002
|
function Unit.prototype.incrementStunCounter(self)
|
|
988
|
-
local stunCounter = self[
|
|
989
|
-
if not self[
|
|
1003
|
+
local stunCounter = self[102] or 0
|
|
1004
|
+
if not self[101] or stunCounter >= 0 then
|
|
990
1005
|
BlzPauseUnitEx(self.handle, true)
|
|
991
1006
|
end
|
|
992
|
-
self[
|
|
1007
|
+
self[102] = stunCounter + 1
|
|
993
1008
|
end
|
|
994
1009
|
function Unit.prototype.decrementStunCounter(self)
|
|
995
|
-
local stunCounter = self[
|
|
996
|
-
if not self[
|
|
1010
|
+
local stunCounter = self[102] or 0
|
|
1011
|
+
if not self[101] or stunCounter >= 1 then
|
|
997
1012
|
BlzPauseUnitEx(self.handle, false)
|
|
998
1013
|
end
|
|
999
|
-
self[
|
|
1014
|
+
self[102] = stunCounter - 1
|
|
1000
1015
|
end
|
|
1001
1016
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1002
1017
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1098,8 +1113,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1098
1113
|
)
|
|
1099
1114
|
return targetCollection
|
|
1100
1115
|
end
|
|
1101
|
-
function Unit.getSelectionOf(self, player)
|
|
1102
|
-
|
|
1116
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1117
|
+
if target == nil then
|
|
1118
|
+
target = {}
|
|
1119
|
+
end
|
|
1120
|
+
targetCollection = target
|
|
1103
1121
|
targetCollectionNextIndex = 1
|
|
1104
1122
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1105
1123
|
return targetCollection
|
|
@@ -1121,6 +1139,9 @@ end
|
|
|
1121
1139
|
function Unit.prototype.__tostring(self)
|
|
1122
1140
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1123
1141
|
end
|
|
1142
|
+
function Unit.getBySyncId(self, syncId)
|
|
1143
|
+
return unitBySyncId[syncId]
|
|
1144
|
+
end
|
|
1124
1145
|
__TS__SetDescriptor(
|
|
1125
1146
|
Unit.prototype,
|
|
1126
1147
|
"_deltas",
|
|
@@ -1184,6 +1205,14 @@ __TS__SetDescriptor(
|
|
|
1184
1205
|
end},
|
|
1185
1206
|
true
|
|
1186
1207
|
)
|
|
1208
|
+
__TS__SetDescriptor(
|
|
1209
|
+
Unit.prototype,
|
|
1210
|
+
"isStunned",
|
|
1211
|
+
{get = function(self)
|
|
1212
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1213
|
+
end},
|
|
1214
|
+
true
|
|
1215
|
+
)
|
|
1187
1216
|
__TS__SetDescriptor(
|
|
1188
1217
|
Unit.prototype,
|
|
1189
1218
|
"combatClassifications",
|
|
@@ -1378,17 +1407,17 @@ __TS__SetDescriptor(
|
|
|
1378
1407
|
"isTeamGlowVisible",
|
|
1379
1408
|
{
|
|
1380
1409
|
get = function(self)
|
|
1381
|
-
return not self[
|
|
1410
|
+
return not self[106]
|
|
1382
1411
|
end,
|
|
1383
1412
|
set = function(self, isTeamGlowVisible)
|
|
1384
1413
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1385
|
-
local
|
|
1414
|
+
local ____temp_6
|
|
1386
1415
|
if not isTeamGlowVisible then
|
|
1387
|
-
|
|
1416
|
+
____temp_6 = true
|
|
1388
1417
|
else
|
|
1389
|
-
|
|
1418
|
+
____temp_6 = nil
|
|
1390
1419
|
end
|
|
1391
|
-
self[
|
|
1420
|
+
self[106] = ____temp_6
|
|
1392
1421
|
end
|
|
1393
1422
|
},
|
|
1394
1423
|
true
|
|
@@ -1398,7 +1427,7 @@ __TS__SetDescriptor(
|
|
|
1398
1427
|
"color",
|
|
1399
1428
|
{set = function(self, color)
|
|
1400
1429
|
setUnitColor(self.handle, color.handle)
|
|
1401
|
-
if self[
|
|
1430
|
+
if self[106] then
|
|
1402
1431
|
showUnitTeamGlow(self.handle, false)
|
|
1403
1432
|
end
|
|
1404
1433
|
end},
|
|
@@ -1422,14 +1451,14 @@ __TS__SetDescriptor(
|
|
|
1422
1451
|
"maxHealth",
|
|
1423
1452
|
{
|
|
1424
1453
|
get = function(self)
|
|
1425
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1454
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1426
1455
|
end,
|
|
1427
1456
|
set = function(self, maxHealth)
|
|
1428
|
-
if maxHealth < 1 and self[
|
|
1429
|
-
self[
|
|
1457
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1458
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1430
1459
|
maxHealth = 1
|
|
1431
1460
|
end
|
|
1432
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1461
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1433
1462
|
end
|
|
1434
1463
|
},
|
|
1435
1464
|
true
|
|
@@ -1471,10 +1500,10 @@ __TS__SetDescriptor(
|
|
|
1471
1500
|
"health",
|
|
1472
1501
|
{
|
|
1473
1502
|
get = function(self)
|
|
1474
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1503
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1475
1504
|
end,
|
|
1476
1505
|
set = function(self, health)
|
|
1477
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1506
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1478
1507
|
end
|
|
1479
1508
|
},
|
|
1480
1509
|
true
|
|
@@ -1685,17 +1714,17 @@ __TS__SetDescriptor(
|
|
|
1685
1714
|
set = function(self, isPaused)
|
|
1686
1715
|
local handle = self.handle
|
|
1687
1716
|
if isPaused and not IsUnitPaused(handle) then
|
|
1688
|
-
self[
|
|
1689
|
-
for _ = self[
|
|
1717
|
+
self[101] = true
|
|
1718
|
+
for _ = self[102] or 0, -1 do
|
|
1690
1719
|
BlzPauseUnitEx(handle, true)
|
|
1691
1720
|
end
|
|
1692
1721
|
PauseUnit(handle, true)
|
|
1693
1722
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1694
1723
|
PauseUnit(handle, false)
|
|
1695
|
-
for _ = self[
|
|
1724
|
+
for _ = self[102] or 0, -1 do
|
|
1696
1725
|
BlzPauseUnitEx(handle, false)
|
|
1697
1726
|
end
|
|
1698
|
-
self[
|
|
1727
|
+
self[101] = nil
|
|
1699
1728
|
end
|
|
1700
1729
|
end
|
|
1701
1730
|
},
|
|
@@ -2052,7 +2081,6 @@ Unit.onDecay = __TS__New(
|
|
|
2052
2081
|
Unit.onResurrect = __TS__New(
|
|
2053
2082
|
InitializingEvent,
|
|
2054
2083
|
function(event)
|
|
2055
|
-
local invoke = Event.invoke
|
|
2056
2084
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2057
2085
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2058
2086
|
dead[unit] = true
|
|
@@ -2068,10 +2096,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2068
2096
|
Unit.morphEvent = __TS__New(
|
|
2069
2097
|
InitializingEvent,
|
|
2070
2098
|
function(event)
|
|
2099
|
+
local function ifNotLeft(unit)
|
|
2100
|
+
local handle = unit.handle
|
|
2101
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2102
|
+
invoke(event, unit)
|
|
2103
|
+
end
|
|
2104
|
+
end
|
|
2071
2105
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2072
2106
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2073
|
-
|
|
2074
|
-
Timer:run(Event.invoke, event, unit)
|
|
2107
|
+
Timer:run(ifNotLeft, unit)
|
|
2075
2108
|
end
|
|
2076
2109
|
end)
|
|
2077
2110
|
end
|
|
@@ -2109,27 +2142,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2109
2142
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2110
2143
|
InitializingEvent,
|
|
2111
2144
|
function(event)
|
|
2112
|
-
local invoke = Event.invoke
|
|
2113
2145
|
local function listener(unit, id)
|
|
2114
|
-
local
|
|
2146
|
+
local ____GetSpellTargetUnit_result_9
|
|
2115
2147
|
if GetSpellTargetUnit() then
|
|
2116
|
-
|
|
2148
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2117
2149
|
else
|
|
2118
|
-
local
|
|
2150
|
+
local ____GetSpellTargetItem_result_8
|
|
2119
2151
|
if GetSpellTargetItem() then
|
|
2120
|
-
|
|
2152
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2121
2153
|
else
|
|
2122
|
-
local
|
|
2154
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2123
2155
|
if GetSpellTargetDestructable() then
|
|
2124
|
-
|
|
2156
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2125
2157
|
else
|
|
2126
|
-
|
|
2158
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2127
2159
|
end
|
|
2128
|
-
|
|
2160
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2129
2161
|
end
|
|
2130
|
-
|
|
2162
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2131
2163
|
end
|
|
2132
|
-
local target =
|
|
2164
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2133
2165
|
if target then
|
|
2134
2166
|
invoke(event, unit, id, target)
|
|
2135
2167
|
end
|
|
@@ -2301,10 +2333,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2301
2333
|
____exports.UnitTriggerEvent,
|
|
2302
2334
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2303
2335
|
function()
|
|
2304
|
-
local
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2336
|
+
local handle = getOrderedUnit()
|
|
2337
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2338
|
+
local unit = ____exports.Unit:of(handle)
|
|
2339
|
+
if unit.state == 1 then
|
|
2340
|
+
return unit, getIssuedOrderId()
|
|
2341
|
+
end
|
|
2308
2342
|
end
|
|
2309
2343
|
return IgnoreEvent
|
|
2310
2344
|
end
|
|
@@ -2326,7 +2360,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2326
2360
|
)
|
|
2327
2361
|
Unit.onDamaging = (function()
|
|
2328
2362
|
local event = __TS__New(Event)
|
|
2329
|
-
local invoke = Event.invoke
|
|
2330
2363
|
local trigger = CreateTrigger()
|
|
2331
2364
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2332
2365
|
TriggerAddCondition(
|
|
@@ -2425,7 +2458,6 @@ end)()
|
|
|
2425
2458
|
Unit.onDamage = __TS__New(
|
|
2426
2459
|
InitializingEvent,
|
|
2427
2460
|
function(event)
|
|
2428
|
-
local invoke = Event.invoke
|
|
2429
2461
|
local trigger = CreateTrigger()
|
|
2430
2462
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2431
2463
|
TriggerAddCondition(
|
|
@@ -2441,6 +2473,7 @@ Unit.onDamage = __TS__New(
|
|
|
2441
2473
|
damageType = BlzGetEventDamageType(),
|
|
2442
2474
|
weaponType = BlzGetEventWeaponType(),
|
|
2443
2475
|
isAttack = BlzGetEventIsAttack(),
|
|
2476
|
+
originalAmount = GetEventDamage(),
|
|
2444
2477
|
preventDeath = damageEventPreventDeath
|
|
2445
2478
|
}
|
|
2446
2479
|
local evData = setmetatable(
|
|
@@ -2457,7 +2490,7 @@ Unit.onDamage = __TS__New(
|
|
|
2457
2490
|
invoke(event, source, target, evData)
|
|
2458
2491
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2459
2492
|
local bonusHealth = math.ceil(evData.amount)
|
|
2460
|
-
target[
|
|
2493
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2461
2494
|
BlzSetUnitMaxHP(
|
|
2462
2495
|
target.handle,
|
|
2463
2496
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2471,7 +2504,7 @@ Unit.onDamage = __TS__New(
|
|
|
2471
2504
|
evData[0],
|
|
2472
2505
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2473
2506
|
)
|
|
2474
|
-
target[
|
|
2507
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2475
2508
|
SetWidgetLife(
|
|
2476
2509
|
target.handle,
|
|
2477
2510
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2491,32 +2524,91 @@ Unit.onDamage = __TS__New(
|
|
|
2491
2524
|
DestroyTrigger(trigger)
|
|
2492
2525
|
end
|
|
2493
2526
|
)
|
|
2494
|
-
Unit.
|
|
2527
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2495
2528
|
____exports.UnitTriggerEvent,
|
|
2496
2529
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2497
2530
|
function()
|
|
2498
2531
|
local unit = getTriggerUnit()
|
|
2499
|
-
|
|
2500
|
-
|
|
2532
|
+
local item = getManipulatedItem()
|
|
2533
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2534
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2501
2535
|
end
|
|
2502
2536
|
return IgnoreEvent
|
|
2503
2537
|
end
|
|
2504
2538
|
)
|
|
2505
|
-
Unit.
|
|
2539
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2506
2540
|
____exports.UnitTriggerEvent,
|
|
2507
2541
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2508
2542
|
function()
|
|
2509
2543
|
local unit = getTriggerUnit()
|
|
2510
|
-
|
|
2511
|
-
|
|
2544
|
+
local item = getManipulatedItem()
|
|
2545
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2546
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2512
2547
|
end
|
|
2513
2548
|
return IgnoreEvent
|
|
2514
2549
|
end
|
|
2515
2550
|
)
|
|
2516
|
-
Unit.
|
|
2551
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2517
2552
|
____exports.UnitTriggerEvent,
|
|
2518
2553
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2519
|
-
function()
|
|
2554
|
+
function()
|
|
2555
|
+
local unit = getTriggerUnit()
|
|
2556
|
+
local item = getManipulatedItem()
|
|
2557
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2558
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2559
|
+
end
|
|
2560
|
+
return IgnoreEvent
|
|
2561
|
+
end
|
|
2562
|
+
)
|
|
2563
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2564
|
+
____exports.UnitTriggerEvent,
|
|
2565
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2566
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2567
|
+
)
|
|
2568
|
+
__TS__ObjectDefineProperty(
|
|
2569
|
+
Unit,
|
|
2570
|
+
"itemUseOrderEvent",
|
|
2571
|
+
{get = function(self)
|
|
2572
|
+
local event = __TS__New(Event)
|
|
2573
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2574
|
+
local slot = order - orderId("useslot0")
|
|
2575
|
+
local function listener(unit)
|
|
2576
|
+
local item = unit.items[slot + 1]
|
|
2577
|
+
if item ~= nil then
|
|
2578
|
+
invoke(event, unit, item)
|
|
2579
|
+
end
|
|
2580
|
+
end
|
|
2581
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2582
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2583
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2584
|
+
end
|
|
2585
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2586
|
+
return event
|
|
2587
|
+
end}
|
|
2588
|
+
)
|
|
2589
|
+
__TS__ObjectDefineProperty(
|
|
2590
|
+
Unit,
|
|
2591
|
+
"itemMoveOrderEvent",
|
|
2592
|
+
{get = function(self)
|
|
2593
|
+
local event = __TS__New(Event)
|
|
2594
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2595
|
+
local slotTo = order - orderId("moveslot0")
|
|
2596
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2597
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2598
|
+
if slotFrom ~= nil then
|
|
2599
|
+
invoke(
|
|
2600
|
+
event,
|
|
2601
|
+
unit,
|
|
2602
|
+
item,
|
|
2603
|
+
slotFrom,
|
|
2604
|
+
slotTo
|
|
2605
|
+
)
|
|
2606
|
+
end
|
|
2607
|
+
end)
|
|
2608
|
+
end
|
|
2609
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2610
|
+
return event
|
|
2611
|
+
end}
|
|
2520
2612
|
)
|
|
2521
2613
|
__TS__ObjectDefineProperty(
|
|
2522
2614
|
Unit,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local getUnitAbility = BlzGetUnitAbility
|
|
3
3
|
local unitAddAbility = UnitAddAbility
|
|
4
|
+
local unitInventorySize = UnitInventorySize
|
|
5
|
+
local unitItemInSlot = UnitItemInSlot
|
|
4
6
|
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
5
7
|
---
|
|
6
8
|
-- @internal For use by internal systems only.
|
|
@@ -10,4 +12,14 @@ ____exports.addInternalAbility = function(unit, abilityTypeId)
|
|
|
10
12
|
end
|
|
11
13
|
return getUnitAbility(unit, abilityTypeId)
|
|
12
14
|
end
|
|
15
|
+
---
|
|
16
|
+
-- @internal For use by internal systems only.
|
|
17
|
+
____exports.findUnitItemSlot = function(unit, item)
|
|
18
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
19
|
+
if item == unitItemInSlot(unit, slot) then
|
|
20
|
+
return slot
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
return nil
|
|
24
|
+
end
|
|
13
25
|
return ____exports
|
package/engine/local-client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Unit } from "../core/types/unit";
|
|
3
3
|
import { Async } from "../core/types/async";
|
|
4
|
-
import { TriggerEvent } from "../event";
|
|
4
|
+
import { Event, TriggerEvent } from "../event";
|
|
5
5
|
import { GraphicsMode } from "./index";
|
|
6
6
|
export declare class LocalClient {
|
|
7
7
|
private constructor();
|
|
@@ -11,6 +11,11 @@ export declare class LocalClient {
|
|
|
11
11
|
static get isHD(): boolean;
|
|
12
12
|
static get graphicsMode(): GraphicsMode;
|
|
13
13
|
static get isActive(): boolean;
|
|
14
|
-
static get mouseFocusUnit(): Async<Unit
|
|
14
|
+
static get mouseFocusUnit(): Async<Unit> | undefined;
|
|
15
|
+
static get mainSelectedUnit(): Async<Unit> | undefined;
|
|
16
|
+
static get mainSelectedUnitChangeEvent(): Event<[
|
|
17
|
+
previousMainSelectedUnit: Unit | undefined,
|
|
18
|
+
newMainSelectedUnit: Unit | undefined
|
|
19
|
+
]>;
|
|
15
20
|
static readonly onDisconnect: TriggerEvent<[]>;
|
|
16
21
|
}
|