warscript 0.0.1-dev.c16baee → 0.0.1-dev.c1eba7d
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/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 -0
- package/core/types/frame.lua +93 -1
- package/core/types/handle.lua +2 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +12 -0
- package/engine/behavior.d.ts +2 -2
- 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/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 +14 -3
- package/engine/behaviour/ability.lua +79 -33
- package/engine/behaviour/unit.d.ts +5 -0
- package/engine/behaviour/unit.lua +20 -0
- package/engine/buff.d.ts +66 -19
- package/engine/buff.lua +268 -80
- 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 +82 -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/bonus.d.ts +4 -2
- 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 +79 -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 +25 -10
- package/engine/internal/unit.lua +164 -89
- 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/sound-preset-name.d.ts +5 -1
- package/engine/object-data/entry/ability-type.lua +8 -12
- package/engine/object-data/entry/item-type.d.ts +14 -0
- package/engine/object-data/entry/item-type.lua +91 -0
- 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 -2
- package/engine/object-field.lua +4 -0
- package/engine/standard/fields/ability.d.ts +2 -0
- package/engine/standard/fields/ability.lua +2 -0
- package/engine/unit.d.ts +2 -0
- package/engine/unit.lua +2 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +7 -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/buff.lua +1 -1
- package/package.json +2 -2
- 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/utility/arrays.d.ts +8 -1
- package/utility/arrays.lua +34 -3
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +11 -2
- package/utility/linked-set.lua +5 -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
|
@@ -51,6 +51,8 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
54
56
|
local match = string.match
|
|
55
57
|
local ____tostring = _G.tostring
|
|
56
58
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -290,7 +292,6 @@ local function dispatch(event, idGetter, argsGetter)
|
|
|
290
292
|
return event[id]
|
|
291
293
|
end
|
|
292
294
|
if not initialized then
|
|
293
|
-
local invoke = Event.invoke
|
|
294
295
|
event:addListener(function(...)
|
|
295
296
|
local id = idGetter(...)
|
|
296
297
|
local dispatched = rawget(self, id)
|
|
@@ -328,7 +329,6 @@ local function dispatchAbility(event)
|
|
|
328
329
|
return event[id]
|
|
329
330
|
end
|
|
330
331
|
if not initialized then
|
|
331
|
-
local invoke = Event.invoke
|
|
332
332
|
event:addListener(function(unit, ability, ...)
|
|
333
333
|
local dispatched = rawget(self, ability.typeId)
|
|
334
334
|
if dispatched ~= nil then
|
|
@@ -564,17 +564,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
564
564
|
____exports.Unit:of(unit)
|
|
565
565
|
)
|
|
566
566
|
end
|
|
567
|
-
if not unitAddAbility(unit, abilityId) then
|
|
568
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
569
|
-
return UnitAbility:of(
|
|
570
|
-
ability,
|
|
571
|
-
abilityId,
|
|
572
|
-
____exports.Unit:of(unit)
|
|
573
|
-
)
|
|
574
|
-
end
|
|
575
|
-
else
|
|
576
|
-
unitRemoveAbility(unit, abilityId)
|
|
577
|
-
end
|
|
578
567
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
579
568
|
local item = unitItemInSlot(unit, i)
|
|
580
569
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -632,15 +621,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
632
621
|
dummies[player] = dummy
|
|
633
622
|
end
|
|
634
623
|
local function delayHealthChecksCallback(unit)
|
|
635
|
-
local counter = (unit[
|
|
624
|
+
local counter = (unit[103] or 0) - 1
|
|
636
625
|
if counter ~= 0 then
|
|
637
|
-
unit[
|
|
626
|
+
unit[103] = counter
|
|
638
627
|
return
|
|
639
628
|
end
|
|
640
|
-
unit[
|
|
641
|
-
local healthBonus = unit[
|
|
629
|
+
unit[103] = nil
|
|
630
|
+
local healthBonus = unit[104]
|
|
642
631
|
if healthBonus ~= nil then
|
|
643
|
-
unit[
|
|
632
|
+
unit[104] = nil
|
|
644
633
|
local handle = unit.handle
|
|
645
634
|
BlzSetUnitMaxHP(
|
|
646
635
|
handle,
|
|
@@ -648,12 +637,17 @@ local function delayHealthChecksCallback(unit)
|
|
|
648
637
|
)
|
|
649
638
|
end
|
|
650
639
|
end
|
|
640
|
+
local nextSyncId = 1
|
|
641
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
651
642
|
____exports.Unit = __TS__Class()
|
|
652
643
|
local Unit = ____exports.Unit
|
|
653
644
|
Unit.name = "Unit"
|
|
654
645
|
__TS__ClassExtends(Unit, Handle)
|
|
655
646
|
function Unit.prototype.____constructor(self, handle)
|
|
656
647
|
Handle.prototype.____constructor(self, handle)
|
|
648
|
+
local ____nextSyncId_0 = nextSyncId
|
|
649
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
650
|
+
self.syncId = ____nextSyncId_0
|
|
657
651
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
658
652
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
659
653
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -666,6 +660,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
666
660
|
fourCC("Amrf")
|
|
667
661
|
))
|
|
668
662
|
end
|
|
663
|
+
unitBySyncId[self.syncId] = self
|
|
669
664
|
local ____ = self.abilities
|
|
670
665
|
end
|
|
671
666
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -706,6 +701,10 @@ function Unit.prototype.onDestroy(self)
|
|
|
706
701
|
if eventsToDestroy ~= nil then
|
|
707
702
|
forEach(eventsToDestroy, "destroy")
|
|
708
703
|
end
|
|
704
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) > 0 then
|
|
705
|
+
unitRemoveAbility(handle, leaveDetectAbilityId)
|
|
706
|
+
removeUnit(handle)
|
|
707
|
+
end
|
|
709
708
|
return Handle.prototype.onDestroy(self)
|
|
710
709
|
end
|
|
711
710
|
function Unit.prototype.addAttackHandler(self, condition, action)
|
|
@@ -747,8 +746,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
747
746
|
end}
|
|
748
747
|
end
|
|
749
748
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
750
|
-
local
|
|
751
|
-
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
|
|
752
751
|
end
|
|
753
752
|
function Unit.prototype.addClassification(self, classification)
|
|
754
753
|
return unitAddType(self.handle, classification)
|
|
@@ -766,13 +765,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
766
765
|
return isUnitInvisible(self.handle, player.handle)
|
|
767
766
|
end
|
|
768
767
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
769
|
-
local
|
|
768
|
+
local ____temp_2
|
|
770
769
|
if type(x) == "number" then
|
|
771
|
-
|
|
770
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
772
771
|
else
|
|
773
|
-
|
|
772
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
774
773
|
end
|
|
775
|
-
return
|
|
774
|
+
return ____temp_2
|
|
776
775
|
end
|
|
777
776
|
function Unit.prototype.isAllyOf(self, unit)
|
|
778
777
|
return isUnitAlly(
|
|
@@ -799,7 +798,7 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
799
798
|
queueUnitAnimation(self.handle, animation)
|
|
800
799
|
end
|
|
801
800
|
function Unit.prototype.delayHealthChecks(self)
|
|
802
|
-
self[
|
|
801
|
+
self[103] = (self[103] or 0) + 1
|
|
803
802
|
Timer:run(delayHealthChecksCallback, self)
|
|
804
803
|
end
|
|
805
804
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -816,14 +815,14 @@ function Unit.prototype.kill(self)
|
|
|
816
815
|
killUnit(self.handle)
|
|
817
816
|
end
|
|
818
817
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
819
|
-
local
|
|
820
|
-
local
|
|
821
|
-
local
|
|
822
|
-
if
|
|
823
|
-
|
|
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
|
|
824
823
|
end
|
|
825
|
-
__TS__SparseArrayPush(
|
|
826
|
-
|
|
824
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
825
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
827
826
|
end
|
|
828
827
|
function Unit.prototype.healTarget(self, target, amount)
|
|
829
828
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -863,7 +862,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
863
862
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
864
863
|
end
|
|
865
864
|
function Unit.prototype.itemInSlot(self, slot)
|
|
866
|
-
return Item:of(
|
|
865
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
867
866
|
end
|
|
868
867
|
function Unit.prototype.addAbility(self, abilityId)
|
|
869
868
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -932,8 +931,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
932
931
|
unitInterruptAttack(self.handle)
|
|
933
932
|
end
|
|
934
933
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
935
|
-
|
|
936
|
-
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
|
+
)
|
|
937
943
|
end
|
|
938
944
|
function Unit.prototype.getDistanceTo(self, target)
|
|
939
945
|
local handle = self.handle
|
|
@@ -993,18 +999,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
993
999
|
self:decrementStunCounter()
|
|
994
1000
|
end
|
|
995
1001
|
function Unit.prototype.incrementStunCounter(self)
|
|
996
|
-
local stunCounter = self[
|
|
997
|
-
if not self[
|
|
1002
|
+
local stunCounter = self[102] or 0
|
|
1003
|
+
if not self[101] or stunCounter >= 0 then
|
|
998
1004
|
BlzPauseUnitEx(self.handle, true)
|
|
999
1005
|
end
|
|
1000
|
-
self[
|
|
1006
|
+
self[102] = stunCounter + 1
|
|
1001
1007
|
end
|
|
1002
1008
|
function Unit.prototype.decrementStunCounter(self)
|
|
1003
|
-
local stunCounter = self[
|
|
1004
|
-
if not self[
|
|
1009
|
+
local stunCounter = self[102] or 0
|
|
1010
|
+
if not self[101] or stunCounter >= 1 then
|
|
1005
1011
|
BlzPauseUnitEx(self.handle, false)
|
|
1006
1012
|
end
|
|
1007
|
-
self[
|
|
1013
|
+
self[102] = stunCounter - 1
|
|
1008
1014
|
end
|
|
1009
1015
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1010
1016
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1106,8 +1112,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1106
1112
|
)
|
|
1107
1113
|
return targetCollection
|
|
1108
1114
|
end
|
|
1109
|
-
function Unit.getSelectionOf(self, player)
|
|
1110
|
-
|
|
1115
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1116
|
+
if target == nil then
|
|
1117
|
+
target = {}
|
|
1118
|
+
end
|
|
1119
|
+
targetCollection = target
|
|
1111
1120
|
targetCollectionNextIndex = 1
|
|
1112
1121
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1113
1122
|
return targetCollection
|
|
@@ -1129,6 +1138,9 @@ end
|
|
|
1129
1138
|
function Unit.prototype.__tostring(self)
|
|
1130
1139
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1131
1140
|
end
|
|
1141
|
+
function Unit.getBySyncId(self, syncId)
|
|
1142
|
+
return unitBySyncId[syncId]
|
|
1143
|
+
end
|
|
1132
1144
|
__TS__SetDescriptor(
|
|
1133
1145
|
Unit.prototype,
|
|
1134
1146
|
"_deltas",
|
|
@@ -1386,17 +1398,17 @@ __TS__SetDescriptor(
|
|
|
1386
1398
|
"isTeamGlowVisible",
|
|
1387
1399
|
{
|
|
1388
1400
|
get = function(self)
|
|
1389
|
-
return not self[
|
|
1401
|
+
return not self[106]
|
|
1390
1402
|
end,
|
|
1391
1403
|
set = function(self, isTeamGlowVisible)
|
|
1392
1404
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1393
|
-
local
|
|
1405
|
+
local ____temp_6
|
|
1394
1406
|
if not isTeamGlowVisible then
|
|
1395
|
-
|
|
1407
|
+
____temp_6 = true
|
|
1396
1408
|
else
|
|
1397
|
-
|
|
1409
|
+
____temp_6 = nil
|
|
1398
1410
|
end
|
|
1399
|
-
self[
|
|
1411
|
+
self[106] = ____temp_6
|
|
1400
1412
|
end
|
|
1401
1413
|
},
|
|
1402
1414
|
true
|
|
@@ -1406,7 +1418,7 @@ __TS__SetDescriptor(
|
|
|
1406
1418
|
"color",
|
|
1407
1419
|
{set = function(self, color)
|
|
1408
1420
|
setUnitColor(self.handle, color.handle)
|
|
1409
|
-
if self[
|
|
1421
|
+
if self[106] then
|
|
1410
1422
|
showUnitTeamGlow(self.handle, false)
|
|
1411
1423
|
end
|
|
1412
1424
|
end},
|
|
@@ -1430,14 +1442,14 @@ __TS__SetDescriptor(
|
|
|
1430
1442
|
"maxHealth",
|
|
1431
1443
|
{
|
|
1432
1444
|
get = function(self)
|
|
1433
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1445
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1434
1446
|
end,
|
|
1435
1447
|
set = function(self, maxHealth)
|
|
1436
|
-
if maxHealth < 1 and self[
|
|
1437
|
-
self[
|
|
1448
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1449
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1438
1450
|
maxHealth = 1
|
|
1439
1451
|
end
|
|
1440
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1452
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1441
1453
|
end
|
|
1442
1454
|
},
|
|
1443
1455
|
true
|
|
@@ -1479,10 +1491,10 @@ __TS__SetDescriptor(
|
|
|
1479
1491
|
"health",
|
|
1480
1492
|
{
|
|
1481
1493
|
get = function(self)
|
|
1482
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1494
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1483
1495
|
end,
|
|
1484
1496
|
set = function(self, health)
|
|
1485
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1497
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1486
1498
|
end
|
|
1487
1499
|
},
|
|
1488
1500
|
true
|
|
@@ -1693,17 +1705,17 @@ __TS__SetDescriptor(
|
|
|
1693
1705
|
set = function(self, isPaused)
|
|
1694
1706
|
local handle = self.handle
|
|
1695
1707
|
if isPaused and not IsUnitPaused(handle) then
|
|
1696
|
-
self[
|
|
1697
|
-
for _ = self[
|
|
1708
|
+
self[101] = true
|
|
1709
|
+
for _ = self[102] or 0, -1 do
|
|
1698
1710
|
BlzPauseUnitEx(handle, true)
|
|
1699
1711
|
end
|
|
1700
1712
|
PauseUnit(handle, true)
|
|
1701
1713
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1702
1714
|
PauseUnit(handle, false)
|
|
1703
|
-
for _ = self[
|
|
1715
|
+
for _ = self[102] or 0, -1 do
|
|
1704
1716
|
BlzPauseUnitEx(handle, false)
|
|
1705
1717
|
end
|
|
1706
|
-
self[
|
|
1718
|
+
self[101] = nil
|
|
1707
1719
|
end
|
|
1708
1720
|
end
|
|
1709
1721
|
},
|
|
@@ -2060,7 +2072,6 @@ Unit.onDecay = __TS__New(
|
|
|
2060
2072
|
Unit.onResurrect = __TS__New(
|
|
2061
2073
|
InitializingEvent,
|
|
2062
2074
|
function(event)
|
|
2063
|
-
local invoke = Event.invoke
|
|
2064
2075
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2065
2076
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2066
2077
|
dead[unit] = true
|
|
@@ -2076,10 +2087,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2076
2087
|
Unit.morphEvent = __TS__New(
|
|
2077
2088
|
InitializingEvent,
|
|
2078
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
|
|
2079
2096
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2080
2097
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2081
|
-
|
|
2082
|
-
Timer:run(Event.invoke, event, unit)
|
|
2098
|
+
Timer:run(ifNotLeft, unit)
|
|
2083
2099
|
end
|
|
2084
2100
|
end)
|
|
2085
2101
|
end
|
|
@@ -2117,27 +2133,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2117
2133
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2118
2134
|
InitializingEvent,
|
|
2119
2135
|
function(event)
|
|
2120
|
-
local invoke = Event.invoke
|
|
2121
2136
|
local function listener(unit, id)
|
|
2122
|
-
local
|
|
2137
|
+
local ____GetSpellTargetUnit_result_9
|
|
2123
2138
|
if GetSpellTargetUnit() then
|
|
2124
|
-
|
|
2139
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2125
2140
|
else
|
|
2126
|
-
local
|
|
2141
|
+
local ____GetSpellTargetItem_result_8
|
|
2127
2142
|
if GetSpellTargetItem() then
|
|
2128
|
-
|
|
2143
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2129
2144
|
else
|
|
2130
|
-
local
|
|
2145
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2131
2146
|
if GetSpellTargetDestructable() then
|
|
2132
|
-
|
|
2147
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2133
2148
|
else
|
|
2134
|
-
|
|
2149
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2135
2150
|
end
|
|
2136
|
-
|
|
2151
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2137
2152
|
end
|
|
2138
|
-
|
|
2153
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2139
2154
|
end
|
|
2140
|
-
local target =
|
|
2155
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2141
2156
|
if target then
|
|
2142
2157
|
invoke(event, unit, id, target)
|
|
2143
2158
|
end
|
|
@@ -2309,10 +2324,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2309
2324
|
____exports.UnitTriggerEvent,
|
|
2310
2325
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2311
2326
|
function()
|
|
2312
|
-
local
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
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
|
|
2316
2333
|
end
|
|
2317
2334
|
return IgnoreEvent
|
|
2318
2335
|
end
|
|
@@ -2334,7 +2351,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2334
2351
|
)
|
|
2335
2352
|
Unit.onDamaging = (function()
|
|
2336
2353
|
local event = __TS__New(Event)
|
|
2337
|
-
local invoke = Event.invoke
|
|
2338
2354
|
local trigger = CreateTrigger()
|
|
2339
2355
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2340
2356
|
TriggerAddCondition(
|
|
@@ -2433,7 +2449,6 @@ end)()
|
|
|
2433
2449
|
Unit.onDamage = __TS__New(
|
|
2434
2450
|
InitializingEvent,
|
|
2435
2451
|
function(event)
|
|
2436
|
-
local invoke = Event.invoke
|
|
2437
2452
|
local trigger = CreateTrigger()
|
|
2438
2453
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2439
2454
|
TriggerAddCondition(
|
|
@@ -2449,6 +2464,7 @@ Unit.onDamage = __TS__New(
|
|
|
2449
2464
|
damageType = BlzGetEventDamageType(),
|
|
2450
2465
|
weaponType = BlzGetEventWeaponType(),
|
|
2451
2466
|
isAttack = BlzGetEventIsAttack(),
|
|
2467
|
+
originalAmount = GetEventDamage(),
|
|
2452
2468
|
preventDeath = damageEventPreventDeath
|
|
2453
2469
|
}
|
|
2454
2470
|
local evData = setmetatable(
|
|
@@ -2465,7 +2481,7 @@ Unit.onDamage = __TS__New(
|
|
|
2465
2481
|
invoke(event, source, target, evData)
|
|
2466
2482
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2467
2483
|
local bonusHealth = math.ceil(evData.amount)
|
|
2468
|
-
target[
|
|
2484
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2469
2485
|
BlzSetUnitMaxHP(
|
|
2470
2486
|
target.handle,
|
|
2471
2487
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2479,7 +2495,7 @@ Unit.onDamage = __TS__New(
|
|
|
2479
2495
|
evData[0],
|
|
2480
2496
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2481
2497
|
)
|
|
2482
|
-
target[
|
|
2498
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2483
2499
|
SetWidgetLife(
|
|
2484
2500
|
target.handle,
|
|
2485
2501
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2499,32 +2515,91 @@ Unit.onDamage = __TS__New(
|
|
|
2499
2515
|
DestroyTrigger(trigger)
|
|
2500
2516
|
end
|
|
2501
2517
|
)
|
|
2502
|
-
Unit.
|
|
2518
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2503
2519
|
____exports.UnitTriggerEvent,
|
|
2504
2520
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2505
2521
|
function()
|
|
2506
2522
|
local unit = getTriggerUnit()
|
|
2507
|
-
|
|
2508
|
-
|
|
2523
|
+
local item = getManipulatedItem()
|
|
2524
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2525
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2509
2526
|
end
|
|
2510
2527
|
return IgnoreEvent
|
|
2511
2528
|
end
|
|
2512
2529
|
)
|
|
2513
|
-
Unit.
|
|
2530
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2514
2531
|
____exports.UnitTriggerEvent,
|
|
2515
2532
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2516
2533
|
function()
|
|
2517
2534
|
local unit = getTriggerUnit()
|
|
2518
|
-
|
|
2519
|
-
|
|
2535
|
+
local item = getManipulatedItem()
|
|
2536
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2537
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2520
2538
|
end
|
|
2521
2539
|
return IgnoreEvent
|
|
2522
2540
|
end
|
|
2523
2541
|
)
|
|
2524
|
-
Unit.
|
|
2542
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2525
2543
|
____exports.UnitTriggerEvent,
|
|
2526
2544
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2527
|
-
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}
|
|
2528
2603
|
)
|
|
2529
2604
|
__TS__ObjectDefineProperty(
|
|
2530
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
|
}
|