warscript 0.0.1-dev.35997e2 → 0.0.1-dev.363d29d
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 -19
- 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 +26 -12
- package/engine/internal/unit.lua +166 -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.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 +1 -0
- package/engine/standard/entries/unit-type.lua +1 -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
|
|
@@ -279,16 +284,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
279
284
|
end
|
|
280
285
|
local function dispatch(event, idGetter, argsGetter)
|
|
281
286
|
local initialized = false
|
|
282
|
-
local x = {}
|
|
283
287
|
return setmetatable(
|
|
284
|
-
|
|
288
|
+
{},
|
|
285
289
|
{
|
|
286
290
|
__index = function(self, id)
|
|
287
291
|
if type(id) ~= "number" then
|
|
288
292
|
return event[id]
|
|
289
293
|
end
|
|
290
294
|
if not initialized then
|
|
291
|
-
local invoke = Event.invoke
|
|
292
295
|
event:addListener(function(...)
|
|
293
296
|
local id = idGetter(...)
|
|
294
297
|
local dispatched = rawget(self, id)
|
|
@@ -326,7 +329,6 @@ local function dispatchAbility(event)
|
|
|
326
329
|
return event[id]
|
|
327
330
|
end
|
|
328
331
|
if not initialized then
|
|
329
|
-
local invoke = Event.invoke
|
|
330
332
|
event:addListener(function(unit, ability, ...)
|
|
331
333
|
local dispatched = rawget(self, ability.typeId)
|
|
332
334
|
if dispatched ~= nil then
|
|
@@ -562,17 +564,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
564
|
____exports.Unit:of(unit)
|
|
563
565
|
)
|
|
564
566
|
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
567
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
568
|
local item = unitItemInSlot(unit, i)
|
|
578
569
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -630,15 +621,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
621
|
dummies[player] = dummy
|
|
631
622
|
end
|
|
632
623
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
624
|
+
local counter = (unit[103] or 0) - 1
|
|
634
625
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
626
|
+
unit[103] = counter
|
|
636
627
|
return
|
|
637
628
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
629
|
+
unit[103] = nil
|
|
630
|
+
local healthBonus = unit[104]
|
|
640
631
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
632
|
+
unit[104] = nil
|
|
642
633
|
local handle = unit.handle
|
|
643
634
|
BlzSetUnitMaxHP(
|
|
644
635
|
handle,
|
|
@@ -646,12 +637,17 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
637
|
)
|
|
647
638
|
end
|
|
648
639
|
end
|
|
640
|
+
local nextSyncId = 1
|
|
641
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
649
642
|
____exports.Unit = __TS__Class()
|
|
650
643
|
local Unit = ____exports.Unit
|
|
651
644
|
Unit.name = "Unit"
|
|
652
645
|
__TS__ClassExtends(Unit, Handle)
|
|
653
646
|
function Unit.prototype.____constructor(self, handle)
|
|
654
647
|
Handle.prototype.____constructor(self, handle)
|
|
648
|
+
local ____nextSyncId_0 = nextSyncId
|
|
649
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
650
|
+
self.syncId = ____nextSyncId_0
|
|
655
651
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
652
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
653
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +660,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
660
|
fourCC("Amrf")
|
|
665
661
|
))
|
|
666
662
|
end
|
|
663
|
+
unitBySyncId[self.syncId] = self
|
|
667
664
|
local ____ = self.abilities
|
|
668
665
|
end
|
|
669
666
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -749,8 +746,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
746
|
end}
|
|
750
747
|
end
|
|
751
748
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
749
|
+
local ____combatClassification_1 = combatClassification
|
|
750
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
754
751
|
end
|
|
755
752
|
function Unit.prototype.addClassification(self, classification)
|
|
756
753
|
return unitAddType(self.handle, classification)
|
|
@@ -768,13 +765,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
765
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
766
|
end
|
|
770
767
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
768
|
+
local ____temp_2
|
|
772
769
|
if type(x) == "number" then
|
|
773
|
-
|
|
770
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
771
|
else
|
|
775
|
-
|
|
772
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
776
773
|
end
|
|
777
|
-
return
|
|
774
|
+
return ____temp_2
|
|
778
775
|
end
|
|
779
776
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
777
|
return isUnitAlly(
|
|
@@ -801,7 +798,7 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
801
798
|
queueUnitAnimation(self.handle, animation)
|
|
802
799
|
end
|
|
803
800
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
801
|
+
self[103] = (self[103] or 0) + 1
|
|
805
802
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
803
|
end
|
|
807
804
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -817,8 +814,15 @@ end
|
|
|
817
814
|
function Unit.prototype.kill(self)
|
|
818
815
|
killUnit(self.handle)
|
|
819
816
|
end
|
|
820
|
-
function Unit.prototype.revive(self,
|
|
821
|
-
|
|
817
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
818
|
+
local ____ReviveHero_5 = ReviveHero
|
|
819
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
820
|
+
local ____doEffect_3 = doEffect
|
|
821
|
+
if ____doEffect_3 == nil then
|
|
822
|
+
____doEffect_3 = false
|
|
823
|
+
end
|
|
824
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
825
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
822
826
|
end
|
|
823
827
|
function Unit.prototype.healTarget(self, target, amount)
|
|
824
828
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -858,7 +862,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
858
862
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
859
863
|
end
|
|
860
864
|
function Unit.prototype.itemInSlot(self, slot)
|
|
861
|
-
return Item:of(
|
|
865
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
862
866
|
end
|
|
863
867
|
function Unit.prototype.addAbility(self, abilityId)
|
|
864
868
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -927,8 +931,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
927
931
|
unitInterruptAttack(self.handle)
|
|
928
932
|
end
|
|
929
933
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
930
|
-
|
|
931
|
-
unitDisableAbility(
|
|
934
|
+
local handle = self.handle
|
|
935
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
936
|
+
Timer:run(
|
|
937
|
+
unitDisableAbility,
|
|
938
|
+
handle,
|
|
939
|
+
abilityId,
|
|
940
|
+
false,
|
|
941
|
+
false
|
|
942
|
+
)
|
|
932
943
|
end
|
|
933
944
|
function Unit.prototype.getDistanceTo(self, target)
|
|
934
945
|
local handle = self.handle
|
|
@@ -988,18 +999,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
988
999
|
self:decrementStunCounter()
|
|
989
1000
|
end
|
|
990
1001
|
function Unit.prototype.incrementStunCounter(self)
|
|
991
|
-
local stunCounter = self[
|
|
992
|
-
if not self[
|
|
1002
|
+
local stunCounter = self[102] or 0
|
|
1003
|
+
if not self[101] or stunCounter >= 0 then
|
|
993
1004
|
BlzPauseUnitEx(self.handle, true)
|
|
994
1005
|
end
|
|
995
|
-
self[
|
|
1006
|
+
self[102] = stunCounter + 1
|
|
996
1007
|
end
|
|
997
1008
|
function Unit.prototype.decrementStunCounter(self)
|
|
998
|
-
local stunCounter = self[
|
|
999
|
-
if not self[
|
|
1009
|
+
local stunCounter = self[102] or 0
|
|
1010
|
+
if not self[101] or stunCounter >= 1 then
|
|
1000
1011
|
BlzPauseUnitEx(self.handle, false)
|
|
1001
1012
|
end
|
|
1002
|
-
self[
|
|
1013
|
+
self[102] = stunCounter - 1
|
|
1003
1014
|
end
|
|
1004
1015
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1005
1016
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1101,8 +1112,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1101
1112
|
)
|
|
1102
1113
|
return targetCollection
|
|
1103
1114
|
end
|
|
1104
|
-
function Unit.getSelectionOf(self, player)
|
|
1105
|
-
|
|
1115
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1116
|
+
if target == nil then
|
|
1117
|
+
target = {}
|
|
1118
|
+
end
|
|
1119
|
+
targetCollection = target
|
|
1106
1120
|
targetCollectionNextIndex = 1
|
|
1107
1121
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1108
1122
|
return targetCollection
|
|
@@ -1124,6 +1138,9 @@ end
|
|
|
1124
1138
|
function Unit.prototype.__tostring(self)
|
|
1125
1139
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1126
1140
|
end
|
|
1141
|
+
function Unit.getBySyncId(self, syncId)
|
|
1142
|
+
return unitBySyncId[syncId]
|
|
1143
|
+
end
|
|
1127
1144
|
__TS__SetDescriptor(
|
|
1128
1145
|
Unit.prototype,
|
|
1129
1146
|
"_deltas",
|
|
@@ -1381,17 +1398,17 @@ __TS__SetDescriptor(
|
|
|
1381
1398
|
"isTeamGlowVisible",
|
|
1382
1399
|
{
|
|
1383
1400
|
get = function(self)
|
|
1384
|
-
return not self[
|
|
1401
|
+
return not self[106]
|
|
1385
1402
|
end,
|
|
1386
1403
|
set = function(self, isTeamGlowVisible)
|
|
1387
1404
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1388
|
-
local
|
|
1405
|
+
local ____temp_6
|
|
1389
1406
|
if not isTeamGlowVisible then
|
|
1390
|
-
|
|
1407
|
+
____temp_6 = true
|
|
1391
1408
|
else
|
|
1392
|
-
|
|
1409
|
+
____temp_6 = nil
|
|
1393
1410
|
end
|
|
1394
|
-
self[
|
|
1411
|
+
self[106] = ____temp_6
|
|
1395
1412
|
end
|
|
1396
1413
|
},
|
|
1397
1414
|
true
|
|
@@ -1401,7 +1418,7 @@ __TS__SetDescriptor(
|
|
|
1401
1418
|
"color",
|
|
1402
1419
|
{set = function(self, color)
|
|
1403
1420
|
setUnitColor(self.handle, color.handle)
|
|
1404
|
-
if self[
|
|
1421
|
+
if self[106] then
|
|
1405
1422
|
showUnitTeamGlow(self.handle, false)
|
|
1406
1423
|
end
|
|
1407
1424
|
end},
|
|
@@ -1425,14 +1442,14 @@ __TS__SetDescriptor(
|
|
|
1425
1442
|
"maxHealth",
|
|
1426
1443
|
{
|
|
1427
1444
|
get = function(self)
|
|
1428
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1445
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1429
1446
|
end,
|
|
1430
1447
|
set = function(self, maxHealth)
|
|
1431
|
-
if maxHealth < 1 and self[
|
|
1432
|
-
self[
|
|
1448
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1449
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1433
1450
|
maxHealth = 1
|
|
1434
1451
|
end
|
|
1435
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1452
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1436
1453
|
end
|
|
1437
1454
|
},
|
|
1438
1455
|
true
|
|
@@ -1474,10 +1491,10 @@ __TS__SetDescriptor(
|
|
|
1474
1491
|
"health",
|
|
1475
1492
|
{
|
|
1476
1493
|
get = function(self)
|
|
1477
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1494
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1478
1495
|
end,
|
|
1479
1496
|
set = function(self, health)
|
|
1480
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1497
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1481
1498
|
end
|
|
1482
1499
|
},
|
|
1483
1500
|
true
|
|
@@ -1688,17 +1705,17 @@ __TS__SetDescriptor(
|
|
|
1688
1705
|
set = function(self, isPaused)
|
|
1689
1706
|
local handle = self.handle
|
|
1690
1707
|
if isPaused and not IsUnitPaused(handle) then
|
|
1691
|
-
self[
|
|
1692
|
-
for _ = self[
|
|
1708
|
+
self[101] = true
|
|
1709
|
+
for _ = self[102] or 0, -1 do
|
|
1693
1710
|
BlzPauseUnitEx(handle, true)
|
|
1694
1711
|
end
|
|
1695
1712
|
PauseUnit(handle, true)
|
|
1696
1713
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1697
1714
|
PauseUnit(handle, false)
|
|
1698
|
-
for _ = self[
|
|
1715
|
+
for _ = self[102] or 0, -1 do
|
|
1699
1716
|
BlzPauseUnitEx(handle, false)
|
|
1700
1717
|
end
|
|
1701
|
-
self[
|
|
1718
|
+
self[101] = nil
|
|
1702
1719
|
end
|
|
1703
1720
|
end
|
|
1704
1721
|
},
|
|
@@ -2055,7 +2072,6 @@ Unit.onDecay = __TS__New(
|
|
|
2055
2072
|
Unit.onResurrect = __TS__New(
|
|
2056
2073
|
InitializingEvent,
|
|
2057
2074
|
function(event)
|
|
2058
|
-
local invoke = Event.invoke
|
|
2059
2075
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2060
2076
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2061
2077
|
dead[unit] = true
|
|
@@ -2071,10 +2087,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2071
2087
|
Unit.morphEvent = __TS__New(
|
|
2072
2088
|
InitializingEvent,
|
|
2073
2089
|
function(event)
|
|
2090
|
+
local function ifNotLeft(unit)
|
|
2091
|
+
local handle = unit.handle
|
|
2092
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2093
|
+
invoke(event, unit)
|
|
2094
|
+
end
|
|
2095
|
+
end
|
|
2074
2096
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2075
2097
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2076
|
-
|
|
2077
|
-
Timer:run(Event.invoke, event, unit)
|
|
2098
|
+
Timer:run(ifNotLeft, unit)
|
|
2078
2099
|
end
|
|
2079
2100
|
end)
|
|
2080
2101
|
end
|
|
@@ -2112,27 +2133,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2112
2133
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2113
2134
|
InitializingEvent,
|
|
2114
2135
|
function(event)
|
|
2115
|
-
local invoke = Event.invoke
|
|
2116
2136
|
local function listener(unit, id)
|
|
2117
|
-
local
|
|
2137
|
+
local ____GetSpellTargetUnit_result_9
|
|
2118
2138
|
if GetSpellTargetUnit() then
|
|
2119
|
-
|
|
2139
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2120
2140
|
else
|
|
2121
|
-
local
|
|
2141
|
+
local ____GetSpellTargetItem_result_8
|
|
2122
2142
|
if GetSpellTargetItem() then
|
|
2123
|
-
|
|
2143
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2124
2144
|
else
|
|
2125
|
-
local
|
|
2145
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2126
2146
|
if GetSpellTargetDestructable() then
|
|
2127
|
-
|
|
2147
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2128
2148
|
else
|
|
2129
|
-
|
|
2149
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2130
2150
|
end
|
|
2131
|
-
|
|
2151
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2132
2152
|
end
|
|
2133
|
-
|
|
2153
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2134
2154
|
end
|
|
2135
|
-
local target =
|
|
2155
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2136
2156
|
if target then
|
|
2137
2157
|
invoke(event, unit, id, target)
|
|
2138
2158
|
end
|
|
@@ -2304,10 +2324,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2304
2324
|
____exports.UnitTriggerEvent,
|
|
2305
2325
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2306
2326
|
function()
|
|
2307
|
-
local
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2327
|
+
local handle = getOrderedUnit()
|
|
2328
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2329
|
+
local unit = ____exports.Unit:of(handle)
|
|
2330
|
+
if unit.state == 1 then
|
|
2331
|
+
return unit, getIssuedOrderId()
|
|
2332
|
+
end
|
|
2311
2333
|
end
|
|
2312
2334
|
return IgnoreEvent
|
|
2313
2335
|
end
|
|
@@ -2329,7 +2351,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2329
2351
|
)
|
|
2330
2352
|
Unit.onDamaging = (function()
|
|
2331
2353
|
local event = __TS__New(Event)
|
|
2332
|
-
local invoke = Event.invoke
|
|
2333
2354
|
local trigger = CreateTrigger()
|
|
2334
2355
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2335
2356
|
TriggerAddCondition(
|
|
@@ -2428,7 +2449,6 @@ end)()
|
|
|
2428
2449
|
Unit.onDamage = __TS__New(
|
|
2429
2450
|
InitializingEvent,
|
|
2430
2451
|
function(event)
|
|
2431
|
-
local invoke = Event.invoke
|
|
2432
2452
|
local trigger = CreateTrigger()
|
|
2433
2453
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2434
2454
|
TriggerAddCondition(
|
|
@@ -2444,6 +2464,7 @@ Unit.onDamage = __TS__New(
|
|
|
2444
2464
|
damageType = BlzGetEventDamageType(),
|
|
2445
2465
|
weaponType = BlzGetEventWeaponType(),
|
|
2446
2466
|
isAttack = BlzGetEventIsAttack(),
|
|
2467
|
+
originalAmount = GetEventDamage(),
|
|
2447
2468
|
preventDeath = damageEventPreventDeath
|
|
2448
2469
|
}
|
|
2449
2470
|
local evData = setmetatable(
|
|
@@ -2460,7 +2481,7 @@ Unit.onDamage = __TS__New(
|
|
|
2460
2481
|
invoke(event, source, target, evData)
|
|
2461
2482
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2462
2483
|
local bonusHealth = math.ceil(evData.amount)
|
|
2463
|
-
target[
|
|
2484
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2464
2485
|
BlzSetUnitMaxHP(
|
|
2465
2486
|
target.handle,
|
|
2466
2487
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2474,7 +2495,7 @@ Unit.onDamage = __TS__New(
|
|
|
2474
2495
|
evData[0],
|
|
2475
2496
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2476
2497
|
)
|
|
2477
|
-
target[
|
|
2498
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2478
2499
|
SetWidgetLife(
|
|
2479
2500
|
target.handle,
|
|
2480
2501
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2494,32 +2515,91 @@ Unit.onDamage = __TS__New(
|
|
|
2494
2515
|
DestroyTrigger(trigger)
|
|
2495
2516
|
end
|
|
2496
2517
|
)
|
|
2497
|
-
Unit.
|
|
2518
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2498
2519
|
____exports.UnitTriggerEvent,
|
|
2499
2520
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2500
2521
|
function()
|
|
2501
2522
|
local unit = getTriggerUnit()
|
|
2502
|
-
|
|
2503
|
-
|
|
2523
|
+
local item = getManipulatedItem()
|
|
2524
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2525
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2504
2526
|
end
|
|
2505
2527
|
return IgnoreEvent
|
|
2506
2528
|
end
|
|
2507
2529
|
)
|
|
2508
|
-
Unit.
|
|
2530
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2509
2531
|
____exports.UnitTriggerEvent,
|
|
2510
2532
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2511
2533
|
function()
|
|
2512
2534
|
local unit = getTriggerUnit()
|
|
2513
|
-
|
|
2514
|
-
|
|
2535
|
+
local item = getManipulatedItem()
|
|
2536
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2537
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2515
2538
|
end
|
|
2516
2539
|
return IgnoreEvent
|
|
2517
2540
|
end
|
|
2518
2541
|
)
|
|
2519
|
-
Unit.
|
|
2542
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2520
2543
|
____exports.UnitTriggerEvent,
|
|
2521
2544
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2522
|
-
function()
|
|
2545
|
+
function()
|
|
2546
|
+
local unit = getTriggerUnit()
|
|
2547
|
+
local item = getManipulatedItem()
|
|
2548
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2549
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2550
|
+
end
|
|
2551
|
+
return IgnoreEvent
|
|
2552
|
+
end
|
|
2553
|
+
)
|
|
2554
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2555
|
+
____exports.UnitTriggerEvent,
|
|
2556
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2557
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2558
|
+
)
|
|
2559
|
+
__TS__ObjectDefineProperty(
|
|
2560
|
+
Unit,
|
|
2561
|
+
"itemUseOrderEvent",
|
|
2562
|
+
{get = function(self)
|
|
2563
|
+
local event = __TS__New(Event)
|
|
2564
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2565
|
+
local slot = order - orderId("useslot0")
|
|
2566
|
+
local function listener(unit)
|
|
2567
|
+
local item = unit.items[slot + 1]
|
|
2568
|
+
if item ~= nil then
|
|
2569
|
+
invoke(event, unit, item)
|
|
2570
|
+
end
|
|
2571
|
+
end
|
|
2572
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2573
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2574
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2575
|
+
end
|
|
2576
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2577
|
+
return event
|
|
2578
|
+
end}
|
|
2579
|
+
)
|
|
2580
|
+
__TS__ObjectDefineProperty(
|
|
2581
|
+
Unit,
|
|
2582
|
+
"itemMoveOrderEvent",
|
|
2583
|
+
{get = function(self)
|
|
2584
|
+
local event = __TS__New(Event)
|
|
2585
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2586
|
+
local slotTo = order - orderId("moveslot0")
|
|
2587
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2588
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2589
|
+
if slotFrom ~= nil then
|
|
2590
|
+
invoke(
|
|
2591
|
+
event,
|
|
2592
|
+
unit,
|
|
2593
|
+
item,
|
|
2594
|
+
slotFrom,
|
|
2595
|
+
slotTo
|
|
2596
|
+
)
|
|
2597
|
+
end
|
|
2598
|
+
end)
|
|
2599
|
+
end
|
|
2600
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2601
|
+
return event
|
|
2602
|
+
end}
|
|
2523
2603
|
)
|
|
2524
2604
|
__TS__ObjectDefineProperty(
|
|
2525
2605
|
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
|
}
|