warscript 0.0.1-dev.63f1d69 → 0.0.1-dev.64cec8d
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/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 +29 -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 +9 -2
- package/engine/behaviour/ability.lua +47 -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 +79 -76
- package/engine/internal/item/ability.lua +68 -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/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 +139 -87
- 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-effects.d.ts +2 -0
- package/engine/object-data/entry/ability-type-effects.lua +89 -0
- package/engine/object-data/entry/ability-type.d.ts +0 -1
- package/engine/object-data/entry/ability-type.lua +15 -86
- package/engine/object-data/entry/item-type.d.ts +14 -0
- package/engine/object-data/entry/item-type.lua +91 -0
- package/engine/object-field/ability.d.ts +21 -1
- package/engine/object-field/ability.lua +51 -1
- 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
|
@@ -290,7 +290,6 @@ local function dispatch(event, idGetter, argsGetter)
|
|
|
290
290
|
return event[id]
|
|
291
291
|
end
|
|
292
292
|
if not initialized then
|
|
293
|
-
local invoke = Event.invoke
|
|
294
293
|
event:addListener(function(...)
|
|
295
294
|
local id = idGetter(...)
|
|
296
295
|
local dispatched = rawget(self, id)
|
|
@@ -328,7 +327,6 @@ local function dispatchAbility(event)
|
|
|
328
327
|
return event[id]
|
|
329
328
|
end
|
|
330
329
|
if not initialized then
|
|
331
|
-
local invoke = Event.invoke
|
|
332
330
|
event:addListener(function(unit, ability, ...)
|
|
333
331
|
local dispatched = rawget(self, ability.typeId)
|
|
334
332
|
if dispatched ~= nil then
|
|
@@ -564,17 +562,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
564
562
|
____exports.Unit:of(unit)
|
|
565
563
|
)
|
|
566
564
|
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
565
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
579
566
|
local item = unitItemInSlot(unit, i)
|
|
580
567
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -632,15 +619,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
632
619
|
dummies[player] = dummy
|
|
633
620
|
end
|
|
634
621
|
local function delayHealthChecksCallback(unit)
|
|
635
|
-
local counter = (unit[
|
|
622
|
+
local counter = (unit[103] or 0) - 1
|
|
636
623
|
if counter ~= 0 then
|
|
637
|
-
unit[
|
|
624
|
+
unit[103] = counter
|
|
638
625
|
return
|
|
639
626
|
end
|
|
640
|
-
unit[
|
|
641
|
-
local healthBonus = unit[
|
|
627
|
+
unit[103] = nil
|
|
628
|
+
local healthBonus = unit[104]
|
|
642
629
|
if healthBonus ~= nil then
|
|
643
|
-
unit[
|
|
630
|
+
unit[104] = nil
|
|
644
631
|
local handle = unit.handle
|
|
645
632
|
BlzSetUnitMaxHP(
|
|
646
633
|
handle,
|
|
@@ -648,12 +635,17 @@ local function delayHealthChecksCallback(unit)
|
|
|
648
635
|
)
|
|
649
636
|
end
|
|
650
637
|
end
|
|
638
|
+
local nextSyncId = 1
|
|
639
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
651
640
|
____exports.Unit = __TS__Class()
|
|
652
641
|
local Unit = ____exports.Unit
|
|
653
642
|
Unit.name = "Unit"
|
|
654
643
|
__TS__ClassExtends(Unit, Handle)
|
|
655
644
|
function Unit.prototype.____constructor(self, handle)
|
|
656
645
|
Handle.prototype.____constructor(self, handle)
|
|
646
|
+
local ____nextSyncId_0 = nextSyncId
|
|
647
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
648
|
+
self.syncId = ____nextSyncId_0
|
|
657
649
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
658
650
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
659
651
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -666,6 +658,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
666
658
|
fourCC("Amrf")
|
|
667
659
|
))
|
|
668
660
|
end
|
|
661
|
+
unitBySyncId[self.syncId] = self
|
|
669
662
|
local ____ = self.abilities
|
|
670
663
|
end
|
|
671
664
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -706,7 +699,10 @@ function Unit.prototype.onDestroy(self)
|
|
|
706
699
|
if eventsToDestroy ~= nil then
|
|
707
700
|
forEach(eventsToDestroy, "destroy")
|
|
708
701
|
end
|
|
709
|
-
|
|
702
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) > 0 then
|
|
703
|
+
unitRemoveAbility(handle, leaveDetectAbilityId)
|
|
704
|
+
removeUnit(handle)
|
|
705
|
+
end
|
|
710
706
|
return Handle.prototype.onDestroy(self)
|
|
711
707
|
end
|
|
712
708
|
function Unit.prototype.addAttackHandler(self, condition, action)
|
|
@@ -748,8 +744,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
748
744
|
end}
|
|
749
745
|
end
|
|
750
746
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
751
|
-
local
|
|
752
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
747
|
+
local ____combatClassification_1 = combatClassification
|
|
748
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
753
749
|
end
|
|
754
750
|
function Unit.prototype.addClassification(self, classification)
|
|
755
751
|
return unitAddType(self.handle, classification)
|
|
@@ -767,13 +763,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
767
763
|
return isUnitInvisible(self.handle, player.handle)
|
|
768
764
|
end
|
|
769
765
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
770
|
-
local
|
|
766
|
+
local ____temp_2
|
|
771
767
|
if type(x) == "number" then
|
|
772
|
-
|
|
768
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
773
769
|
else
|
|
774
|
-
|
|
770
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
775
771
|
end
|
|
776
|
-
return
|
|
772
|
+
return ____temp_2
|
|
777
773
|
end
|
|
778
774
|
function Unit.prototype.isAllyOf(self, unit)
|
|
779
775
|
return isUnitAlly(
|
|
@@ -800,7 +796,7 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
800
796
|
queueUnitAnimation(self.handle, animation)
|
|
801
797
|
end
|
|
802
798
|
function Unit.prototype.delayHealthChecks(self)
|
|
803
|
-
self[
|
|
799
|
+
self[103] = (self[103] or 0) + 1
|
|
804
800
|
Timer:run(delayHealthChecksCallback, self)
|
|
805
801
|
end
|
|
806
802
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -817,14 +813,14 @@ function Unit.prototype.kill(self)
|
|
|
817
813
|
killUnit(self.handle)
|
|
818
814
|
end
|
|
819
815
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
820
|
-
local
|
|
821
|
-
local
|
|
822
|
-
local
|
|
823
|
-
if
|
|
824
|
-
|
|
816
|
+
local ____ReviveHero_5 = ReviveHero
|
|
817
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
818
|
+
local ____doEffect_3 = doEffect
|
|
819
|
+
if ____doEffect_3 == nil then
|
|
820
|
+
____doEffect_3 = false
|
|
825
821
|
end
|
|
826
|
-
__TS__SparseArrayPush(
|
|
827
|
-
|
|
822
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
823
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
828
824
|
end
|
|
829
825
|
function Unit.prototype.healTarget(self, target, amount)
|
|
830
826
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -864,7 +860,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
864
860
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
865
861
|
end
|
|
866
862
|
function Unit.prototype.itemInSlot(self, slot)
|
|
867
|
-
return Item:of(
|
|
863
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
868
864
|
end
|
|
869
865
|
function Unit.prototype.addAbility(self, abilityId)
|
|
870
866
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -994,18 +990,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
994
990
|
self:decrementStunCounter()
|
|
995
991
|
end
|
|
996
992
|
function Unit.prototype.incrementStunCounter(self)
|
|
997
|
-
local stunCounter = self[
|
|
998
|
-
if not self[
|
|
993
|
+
local stunCounter = self[102] or 0
|
|
994
|
+
if not self[101] or stunCounter >= 0 then
|
|
999
995
|
BlzPauseUnitEx(self.handle, true)
|
|
1000
996
|
end
|
|
1001
|
-
self[
|
|
997
|
+
self[102] = stunCounter + 1
|
|
1002
998
|
end
|
|
1003
999
|
function Unit.prototype.decrementStunCounter(self)
|
|
1004
|
-
local stunCounter = self[
|
|
1005
|
-
if not self[
|
|
1000
|
+
local stunCounter = self[102] or 0
|
|
1001
|
+
if not self[101] or stunCounter >= 1 then
|
|
1006
1002
|
BlzPauseUnitEx(self.handle, false)
|
|
1007
1003
|
end
|
|
1008
|
-
self[
|
|
1004
|
+
self[102] = stunCounter - 1
|
|
1009
1005
|
end
|
|
1010
1006
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1011
1007
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1107,8 +1103,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1107
1103
|
)
|
|
1108
1104
|
return targetCollection
|
|
1109
1105
|
end
|
|
1110
|
-
function Unit.getSelectionOf(self, player)
|
|
1111
|
-
|
|
1106
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1107
|
+
if target == nil then
|
|
1108
|
+
target = {}
|
|
1109
|
+
end
|
|
1110
|
+
targetCollection = target
|
|
1112
1111
|
targetCollectionNextIndex = 1
|
|
1113
1112
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1114
1113
|
return targetCollection
|
|
@@ -1130,6 +1129,9 @@ end
|
|
|
1130
1129
|
function Unit.prototype.__tostring(self)
|
|
1131
1130
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1132
1131
|
end
|
|
1132
|
+
function Unit.getBySyncId(self, syncId)
|
|
1133
|
+
return unitBySyncId[syncId]
|
|
1134
|
+
end
|
|
1133
1135
|
__TS__SetDescriptor(
|
|
1134
1136
|
Unit.prototype,
|
|
1135
1137
|
"_deltas",
|
|
@@ -1387,17 +1389,17 @@ __TS__SetDescriptor(
|
|
|
1387
1389
|
"isTeamGlowVisible",
|
|
1388
1390
|
{
|
|
1389
1391
|
get = function(self)
|
|
1390
|
-
return not self[
|
|
1392
|
+
return not self[106]
|
|
1391
1393
|
end,
|
|
1392
1394
|
set = function(self, isTeamGlowVisible)
|
|
1393
1395
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1394
|
-
local
|
|
1396
|
+
local ____temp_6
|
|
1395
1397
|
if not isTeamGlowVisible then
|
|
1396
|
-
|
|
1398
|
+
____temp_6 = true
|
|
1397
1399
|
else
|
|
1398
|
-
|
|
1400
|
+
____temp_6 = nil
|
|
1399
1401
|
end
|
|
1400
|
-
self[
|
|
1402
|
+
self[106] = ____temp_6
|
|
1401
1403
|
end
|
|
1402
1404
|
},
|
|
1403
1405
|
true
|
|
@@ -1407,7 +1409,7 @@ __TS__SetDescriptor(
|
|
|
1407
1409
|
"color",
|
|
1408
1410
|
{set = function(self, color)
|
|
1409
1411
|
setUnitColor(self.handle, color.handle)
|
|
1410
|
-
if self[
|
|
1412
|
+
if self[106] then
|
|
1411
1413
|
showUnitTeamGlow(self.handle, false)
|
|
1412
1414
|
end
|
|
1413
1415
|
end},
|
|
@@ -1431,14 +1433,14 @@ __TS__SetDescriptor(
|
|
|
1431
1433
|
"maxHealth",
|
|
1432
1434
|
{
|
|
1433
1435
|
get = function(self)
|
|
1434
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1436
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1435
1437
|
end,
|
|
1436
1438
|
set = function(self, maxHealth)
|
|
1437
|
-
if maxHealth < 1 and self[
|
|
1438
|
-
self[
|
|
1439
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1440
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1439
1441
|
maxHealth = 1
|
|
1440
1442
|
end
|
|
1441
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1443
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1442
1444
|
end
|
|
1443
1445
|
},
|
|
1444
1446
|
true
|
|
@@ -1480,10 +1482,10 @@ __TS__SetDescriptor(
|
|
|
1480
1482
|
"health",
|
|
1481
1483
|
{
|
|
1482
1484
|
get = function(self)
|
|
1483
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1485
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1484
1486
|
end,
|
|
1485
1487
|
set = function(self, health)
|
|
1486
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1488
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1487
1489
|
end
|
|
1488
1490
|
},
|
|
1489
1491
|
true
|
|
@@ -1694,17 +1696,17 @@ __TS__SetDescriptor(
|
|
|
1694
1696
|
set = function(self, isPaused)
|
|
1695
1697
|
local handle = self.handle
|
|
1696
1698
|
if isPaused and not IsUnitPaused(handle) then
|
|
1697
|
-
self[
|
|
1698
|
-
for _ = self[
|
|
1699
|
+
self[101] = true
|
|
1700
|
+
for _ = self[102] or 0, -1 do
|
|
1699
1701
|
BlzPauseUnitEx(handle, true)
|
|
1700
1702
|
end
|
|
1701
1703
|
PauseUnit(handle, true)
|
|
1702
1704
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1703
1705
|
PauseUnit(handle, false)
|
|
1704
|
-
for _ = self[
|
|
1706
|
+
for _ = self[102] or 0, -1 do
|
|
1705
1707
|
BlzPauseUnitEx(handle, false)
|
|
1706
1708
|
end
|
|
1707
|
-
self[
|
|
1709
|
+
self[101] = nil
|
|
1708
1710
|
end
|
|
1709
1711
|
end
|
|
1710
1712
|
},
|
|
@@ -2061,7 +2063,6 @@ Unit.onDecay = __TS__New(
|
|
|
2061
2063
|
Unit.onResurrect = __TS__New(
|
|
2062
2064
|
InitializingEvent,
|
|
2063
2065
|
function(event)
|
|
2064
|
-
local invoke = Event.invoke
|
|
2065
2066
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2066
2067
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2067
2068
|
dead[unit] = true
|
|
@@ -2077,10 +2078,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2077
2078
|
Unit.morphEvent = __TS__New(
|
|
2078
2079
|
InitializingEvent,
|
|
2079
2080
|
function(event)
|
|
2081
|
+
local function ifNotLeft(unit)
|
|
2082
|
+
local handle = unit.handle
|
|
2083
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2084
|
+
invoke(event, unit)
|
|
2085
|
+
end
|
|
2086
|
+
end
|
|
2080
2087
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2081
2088
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2082
|
-
|
|
2083
|
-
Timer:run(Event.invoke, event, unit)
|
|
2089
|
+
Timer:run(ifNotLeft, unit)
|
|
2084
2090
|
end
|
|
2085
2091
|
end)
|
|
2086
2092
|
end
|
|
@@ -2118,27 +2124,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2118
2124
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2119
2125
|
InitializingEvent,
|
|
2120
2126
|
function(event)
|
|
2121
|
-
local invoke = Event.invoke
|
|
2122
2127
|
local function listener(unit, id)
|
|
2123
|
-
local
|
|
2128
|
+
local ____GetSpellTargetUnit_result_9
|
|
2124
2129
|
if GetSpellTargetUnit() then
|
|
2125
|
-
|
|
2130
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2126
2131
|
else
|
|
2127
|
-
local
|
|
2132
|
+
local ____GetSpellTargetItem_result_8
|
|
2128
2133
|
if GetSpellTargetItem() then
|
|
2129
|
-
|
|
2134
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2130
2135
|
else
|
|
2131
|
-
local
|
|
2136
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2132
2137
|
if GetSpellTargetDestructable() then
|
|
2133
|
-
|
|
2138
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2134
2139
|
else
|
|
2135
|
-
|
|
2140
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2136
2141
|
end
|
|
2137
|
-
|
|
2142
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2138
2143
|
end
|
|
2139
|
-
|
|
2144
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2140
2145
|
end
|
|
2141
|
-
local target =
|
|
2146
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2142
2147
|
if target then
|
|
2143
2148
|
invoke(event, unit, id, target)
|
|
2144
2149
|
end
|
|
@@ -2335,7 +2340,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2335
2340
|
)
|
|
2336
2341
|
Unit.onDamaging = (function()
|
|
2337
2342
|
local event = __TS__New(Event)
|
|
2338
|
-
local invoke = Event.invoke
|
|
2339
2343
|
local trigger = CreateTrigger()
|
|
2340
2344
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2341
2345
|
TriggerAddCondition(
|
|
@@ -2434,7 +2438,6 @@ end)()
|
|
|
2434
2438
|
Unit.onDamage = __TS__New(
|
|
2435
2439
|
InitializingEvent,
|
|
2436
2440
|
function(event)
|
|
2437
|
-
local invoke = Event.invoke
|
|
2438
2441
|
local trigger = CreateTrigger()
|
|
2439
2442
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2440
2443
|
TriggerAddCondition(
|
|
@@ -2450,6 +2453,7 @@ Unit.onDamage = __TS__New(
|
|
|
2450
2453
|
damageType = BlzGetEventDamageType(),
|
|
2451
2454
|
weaponType = BlzGetEventWeaponType(),
|
|
2452
2455
|
isAttack = BlzGetEventIsAttack(),
|
|
2456
|
+
originalAmount = GetEventDamage(),
|
|
2453
2457
|
preventDeath = damageEventPreventDeath
|
|
2454
2458
|
}
|
|
2455
2459
|
local evData = setmetatable(
|
|
@@ -2466,7 +2470,7 @@ Unit.onDamage = __TS__New(
|
|
|
2466
2470
|
invoke(event, source, target, evData)
|
|
2467
2471
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2468
2472
|
local bonusHealth = math.ceil(evData.amount)
|
|
2469
|
-
target[
|
|
2473
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2470
2474
|
BlzSetUnitMaxHP(
|
|
2471
2475
|
target.handle,
|
|
2472
2476
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2480,7 +2484,7 @@ Unit.onDamage = __TS__New(
|
|
|
2480
2484
|
evData[0],
|
|
2481
2485
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2482
2486
|
)
|
|
2483
|
-
target[
|
|
2487
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2484
2488
|
SetWidgetLife(
|
|
2485
2489
|
target.handle,
|
|
2486
2490
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2500,7 +2504,7 @@ Unit.onDamage = __TS__New(
|
|
|
2500
2504
|
DestroyTrigger(trigger)
|
|
2501
2505
|
end
|
|
2502
2506
|
)
|
|
2503
|
-
Unit.
|
|
2507
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2504
2508
|
____exports.UnitTriggerEvent,
|
|
2505
2509
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2506
2510
|
function()
|
|
@@ -2511,7 +2515,7 @@ Unit.onItemDrop = __TS__New(
|
|
|
2511
2515
|
return IgnoreEvent
|
|
2512
2516
|
end
|
|
2513
2517
|
)
|
|
2514
|
-
Unit.
|
|
2518
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2515
2519
|
____exports.UnitTriggerEvent,
|
|
2516
2520
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2517
2521
|
function()
|
|
@@ -2522,10 +2526,60 @@ Unit.onItemPickup = __TS__New(
|
|
|
2522
2526
|
return IgnoreEvent
|
|
2523
2527
|
end
|
|
2524
2528
|
)
|
|
2525
|
-
Unit.
|
|
2529
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2526
2530
|
____exports.UnitTriggerEvent,
|
|
2527
2531
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2528
|
-
function() return ____exports.Unit:of(
|
|
2532
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2533
|
+
)
|
|
2534
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2535
|
+
____exports.UnitTriggerEvent,
|
|
2536
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2537
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2538
|
+
)
|
|
2539
|
+
__TS__ObjectDefineProperty(
|
|
2540
|
+
Unit,
|
|
2541
|
+
"itemUseOrderEvent",
|
|
2542
|
+
{get = function(self)
|
|
2543
|
+
local event = __TS__New(Event)
|
|
2544
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2545
|
+
local slot = order - orderId("useslot0")
|
|
2546
|
+
local function listener(unit)
|
|
2547
|
+
local item = unit.items[slot + 1]
|
|
2548
|
+
if item ~= nil then
|
|
2549
|
+
invoke(event, unit, item)
|
|
2550
|
+
end
|
|
2551
|
+
end
|
|
2552
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2553
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2554
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2555
|
+
end
|
|
2556
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2557
|
+
return event
|
|
2558
|
+
end}
|
|
2559
|
+
)
|
|
2560
|
+
__TS__ObjectDefineProperty(
|
|
2561
|
+
Unit,
|
|
2562
|
+
"itemMoveOrderEvent",
|
|
2563
|
+
{get = function(self)
|
|
2564
|
+
local event = __TS__New(Event)
|
|
2565
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2566
|
+
local slotTo = order - orderId("moveslot0")
|
|
2567
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2568
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2569
|
+
if slotFrom ~= nil then
|
|
2570
|
+
invoke(
|
|
2571
|
+
event,
|
|
2572
|
+
unit,
|
|
2573
|
+
item,
|
|
2574
|
+
slotFrom,
|
|
2575
|
+
slotTo
|
|
2576
|
+
)
|
|
2577
|
+
end
|
|
2578
|
+
end)
|
|
2579
|
+
end
|
|
2580
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2581
|
+
return event
|
|
2582
|
+
end}
|
|
2529
2583
|
)
|
|
2530
2584
|
__TS__ObjectDefineProperty(
|
|
2531
2585
|
Unit,
|
|
@@ -2575,15 +2629,13 @@ __TS__ObjectDefineProperty(
|
|
|
2575
2629
|
orderId("unimmolation")
|
|
2576
2630
|
}) do
|
|
2577
2631
|
____exports.Unit.onImmediateOrder[leaveOrderId]:addListener(function(unit)
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
return
|
|
2583
|
-
end
|
|
2632
|
+
local handle = unit.handle
|
|
2633
|
+
for i = 1, #leaveAbilityIds do
|
|
2634
|
+
if getUnitAbilityLevel(handle, leaveAbilityIds[i]) ~= 0 then
|
|
2635
|
+
return
|
|
2584
2636
|
end
|
|
2585
|
-
unit:destroy()
|
|
2586
2637
|
end
|
|
2638
|
+
unit:destroy()
|
|
2587
2639
|
end)
|
|
2588
2640
|
end
|
|
2589
2641
|
end)(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
|
}
|
package/engine/local-client.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
4
5
|
local __TS__New = ____lualib.__TS__New
|
|
@@ -6,13 +7,25 @@ local ____exports = {}
|
|
|
6
7
|
local ____unit = require("core.types.unit")
|
|
7
8
|
local Unit = ____unit.Unit
|
|
8
9
|
local ____event = require("event")
|
|
10
|
+
local Event = ____event.Event
|
|
9
11
|
local TriggerEvent = ____event.TriggerEvent
|
|
12
|
+
local ____frame = require("core.types.frame")
|
|
13
|
+
local Frame = ____frame.Frame
|
|
14
|
+
local ____player = require("core.types.player")
|
|
15
|
+
local Player = ____player.Player
|
|
16
|
+
local ____timer = require("core.types.timer")
|
|
17
|
+
local Timer = ____timer.Timer
|
|
10
18
|
local loadTOCFile = BlzLoadTOCFile
|
|
11
19
|
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
12
20
|
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
13
21
|
local isLocalClientActive = BlzIsLocalClientActive
|
|
22
|
+
local isHeroUnitId = IsHeroUnitId
|
|
23
|
+
local getHandleId = GetHandleId
|
|
14
24
|
local getMouseFocusUnit = BlzGetMouseFocusUnit
|
|
25
|
+
local getUnitRealField = BlzGetUnitRealField
|
|
26
|
+
local getUnitTypeId = GetUnitTypeId
|
|
15
27
|
local getLocale = BlzGetLocale
|
|
28
|
+
local tableSort = table.sort
|
|
16
29
|
local tocPath = "_warscript\\IsHD.toc"
|
|
17
30
|
compiletime(function()
|
|
18
31
|
if currentMap then
|
|
@@ -21,6 +34,29 @@ compiletime(function()
|
|
|
21
34
|
currentMap:addFileString("_HD.w3mod\\" .. tocPath, fdfPath .. "\r\n")
|
|
22
35
|
end
|
|
23
36
|
end)
|
|
37
|
+
local selectionButtons
|
|
38
|
+
Timer:run(function()
|
|
39
|
+
selectionButtons = __TS__ArrayMap(
|
|
40
|
+
Frame:byName("SimpleInfoPanelUnitDetail").parent:getChild(5):getChild(0).children,
|
|
41
|
+
function(____, frame) return frame:getChild(1) end
|
|
42
|
+
)
|
|
43
|
+
end)
|
|
44
|
+
local localSelectedUnits = {}
|
|
45
|
+
local indexByLocalSelectedUnit = {}
|
|
46
|
+
local function compareUnitsSelectionPriority(a, b)
|
|
47
|
+
local aHandle = a.handle
|
|
48
|
+
local bHandle = b.handle
|
|
49
|
+
local priorityDelta = getUnitRealField(bHandle, UNIT_RF_PRIORITY) - getUnitRealField(aHandle, UNIT_RF_PRIORITY)
|
|
50
|
+
if priorityDelta ~= 0 then
|
|
51
|
+
return priorityDelta < 0
|
|
52
|
+
end
|
|
53
|
+
local aTypeId = getUnitTypeId(aHandle)
|
|
54
|
+
local bTypeId = getUnitTypeId(bHandle)
|
|
55
|
+
local orderDelta = (isHeroUnitId(aTypeId) and getHandleId(aHandle) or aTypeId) - (isHeroUnitId(bTypeId) and getHandleId(bHandle) or bTypeId)
|
|
56
|
+
return (orderDelta ~= 0 and orderDelta or indexByLocalSelectedUnit[a] - indexByLocalSelectedUnit[b]) < 0
|
|
57
|
+
end
|
|
58
|
+
local mainSelectedUnitChangeEvent
|
|
59
|
+
local previousMainSelectedUnit
|
|
24
60
|
____exports.LocalClient = __TS__Class()
|
|
25
61
|
local LocalClient = ____exports.LocalClient
|
|
26
62
|
LocalClient.name = "LocalClient"
|
|
@@ -69,6 +105,52 @@ __TS__ObjectDefineProperty(
|
|
|
69
105
|
return Unit:of(getMouseFocusUnit())
|
|
70
106
|
end}
|
|
71
107
|
)
|
|
108
|
+
__TS__ObjectDefineProperty(
|
|
109
|
+
LocalClient,
|
|
110
|
+
"mainSelectedUnit",
|
|
111
|
+
{get = function(self)
|
|
112
|
+
Unit:getSelectionOf(Player["local"], localSelectedUnits)
|
|
113
|
+
for i = 1, #localSelectedUnits do
|
|
114
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = i
|
|
115
|
+
end
|
|
116
|
+
tableSort(localSelectedUnits, compareUnitsSelectionPriority)
|
|
117
|
+
local mainSelectedUnitIndex
|
|
118
|
+
if selectionButtons and #localSelectedUnits > 1 then
|
|
119
|
+
local maxButtonWidth = 0
|
|
120
|
+
for i = 0, #selectionButtons - 1 do
|
|
121
|
+
local width = selectionButtons[i + 1].width
|
|
122
|
+
if width > maxButtonWidth then
|
|
123
|
+
maxButtonWidth = width
|
|
124
|
+
mainSelectedUnitIndex = i
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
local mainSelectedUnit = localSelectedUnits[(mainSelectedUnitIndex or 0) + 1]
|
|
129
|
+
for i = 1, #localSelectedUnits do
|
|
130
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
|
|
131
|
+
localSelectedUnits[i] = nil
|
|
132
|
+
end
|
|
133
|
+
if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
|
|
134
|
+
local previousPreviousMainSelectedUnit = previousMainSelectedUnit
|
|
135
|
+
previousMainSelectedUnit = mainSelectedUnit
|
|
136
|
+
Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
|
|
137
|
+
end
|
|
138
|
+
return mainSelectedUnit
|
|
139
|
+
end}
|
|
140
|
+
)
|
|
141
|
+
__TS__ObjectDefineProperty(
|
|
142
|
+
LocalClient,
|
|
143
|
+
"mainSelectedUnitChangeEvent",
|
|
144
|
+
{get = function(self)
|
|
145
|
+
if mainSelectedUnitChangeEvent == nil then
|
|
146
|
+
mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
147
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
148
|
+
local _ = ____exports.LocalClient.mainSelectedUnit
|
|
149
|
+
end)
|
|
150
|
+
end
|
|
151
|
+
return mainSelectedUnitChangeEvent
|
|
152
|
+
end}
|
|
153
|
+
)
|
|
72
154
|
LocalClient.onDisconnect = __TS__New(
|
|
73
155
|
TriggerEvent,
|
|
74
156
|
function(trigger)
|
|
@@ -4,5 +4,9 @@ export declare const enum SoundPresetName {
|
|
|
4
4
|
ABOMINATION_PISSED = "AbominationPissed",
|
|
5
5
|
ABOMINATION_READY = "AbominationReady",
|
|
6
6
|
ABOMINATION_WAR_CRY = "AbominationWarcry",
|
|
7
|
-
AXE_MEDIUM_CHOP_WOOD = "AxeMediumChopWood"
|
|
7
|
+
AXE_MEDIUM_CHOP_WOOD = "AxeMediumChopWood",
|
|
8
|
+
IMPALE = "Impale",
|
|
9
|
+
IMPALE_HIT = "ImpaleHit",
|
|
10
|
+
IMPALE_LAND = "ImpaleLand",
|
|
11
|
+
IMPALE_CAST = "ImpaleCast"
|
|
8
12
|
}
|