warscript 0.0.1-dev.22f399b → 0.0.1-dev.240d8a6
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/frame.d.ts +6 -0
- package/core/types/frame.lua +91 -1
- package/core/util.d.ts +1 -1
- package/core/util.lua +6 -0
- package/engine/behavior.d.ts +2 -2
- package/engine/behavior.lua +6 -6
- package/engine/behaviour/ability/apply-buff.d.ts +3 -5
- package/engine/behaviour/unit.d.ts +5 -0
- package/engine/behaviour/unit.lua +20 -0
- package/engine/buff.d.ts +60 -18
- package/engine/buff.lua +239 -62
- package/engine/internal/ability.d.ts +3 -11
- package/engine/internal/ability.lua +9 -78
- package/engine/internal/item+owner.lua +2 -2
- 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 +84 -0
- package/engine/internal/unit/main-selected.d.ts +7 -0
- package/engine/internal/unit/main-selected.lua +40 -0
- package/engine/internal/unit+ability.lua +2 -2
- package/engine/internal/unit-missile-launch.lua +24 -5
- package/engine/internal/unit.d.ts +24 -10
- package/engine/internal/unit.lua +106 -60
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- package/engine/object-data/entry/item-type.d.ts +12 -0
- package/engine/object-data/entry/item-type.lua +78 -0
- package/engine/object-field/ability.d.ts +17 -0
- package/engine/object-field/ability.lua +51 -1
- 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/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/linked-set.d.ts +11 -2
- package/utility/linked-set.lua +5 -2
- package/utility/types.d.ts +1 -0
package/engine/internal/unit.lua
CHANGED
|
@@ -630,15 +630,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
630
|
dummies[player] = dummy
|
|
631
631
|
end
|
|
632
632
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
633
|
+
local counter = (unit[103] or 0) - 1
|
|
634
634
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
635
|
+
unit[103] = counter
|
|
636
636
|
return
|
|
637
637
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
638
|
+
unit[103] = nil
|
|
639
|
+
local healthBonus = unit[104]
|
|
640
640
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
641
|
+
unit[104] = nil
|
|
642
642
|
local handle = unit.handle
|
|
643
643
|
BlzSetUnitMaxHP(
|
|
644
644
|
handle,
|
|
@@ -646,12 +646,17 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
646
|
)
|
|
647
647
|
end
|
|
648
648
|
end
|
|
649
|
+
local nextSyncId = 1
|
|
650
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
649
651
|
____exports.Unit = __TS__Class()
|
|
650
652
|
local Unit = ____exports.Unit
|
|
651
653
|
Unit.name = "Unit"
|
|
652
654
|
__TS__ClassExtends(Unit, Handle)
|
|
653
655
|
function Unit.prototype.____constructor(self, handle)
|
|
654
656
|
Handle.prototype.____constructor(self, handle)
|
|
657
|
+
local ____nextSyncId_0 = nextSyncId
|
|
658
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
659
|
+
self.syncId = ____nextSyncId_0
|
|
655
660
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
661
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
662
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +669,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
669
|
fourCC("Amrf")
|
|
665
670
|
))
|
|
666
671
|
end
|
|
672
|
+
unitBySyncId[self.syncId] = self
|
|
667
673
|
local ____ = self.abilities
|
|
668
674
|
end
|
|
669
675
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -749,8 +755,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
755
|
end}
|
|
750
756
|
end
|
|
751
757
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
758
|
+
local ____combatClassification_1 = combatClassification
|
|
759
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
754
760
|
end
|
|
755
761
|
function Unit.prototype.addClassification(self, classification)
|
|
756
762
|
return unitAddType(self.handle, classification)
|
|
@@ -768,13 +774,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
774
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
775
|
end
|
|
770
776
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
777
|
+
local ____temp_2
|
|
772
778
|
if type(x) == "number" then
|
|
773
|
-
|
|
779
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
780
|
else
|
|
775
|
-
|
|
781
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
776
782
|
end
|
|
777
|
-
return
|
|
783
|
+
return ____temp_2
|
|
778
784
|
end
|
|
779
785
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
786
|
return isUnitAlly(
|
|
@@ -801,7 +807,7 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
801
807
|
queueUnitAnimation(self.handle, animation)
|
|
802
808
|
end
|
|
803
809
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
810
|
+
self[103] = (self[103] or 0) + 1
|
|
805
811
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
812
|
end
|
|
807
813
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -818,14 +824,14 @@ function Unit.prototype.kill(self)
|
|
|
818
824
|
killUnit(self.handle)
|
|
819
825
|
end
|
|
820
826
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
821
|
-
local
|
|
822
|
-
local
|
|
823
|
-
local
|
|
824
|
-
if
|
|
825
|
-
|
|
827
|
+
local ____ReviveHero_5 = ReviveHero
|
|
828
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
829
|
+
local ____doEffect_3 = doEffect
|
|
830
|
+
if ____doEffect_3 == nil then
|
|
831
|
+
____doEffect_3 = false
|
|
826
832
|
end
|
|
827
|
-
__TS__SparseArrayPush(
|
|
828
|
-
|
|
833
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
834
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
829
835
|
end
|
|
830
836
|
function Unit.prototype.healTarget(self, target, amount)
|
|
831
837
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -865,7 +871,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
865
871
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
866
872
|
end
|
|
867
873
|
function Unit.prototype.itemInSlot(self, slot)
|
|
868
|
-
return Item:of(
|
|
874
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
869
875
|
end
|
|
870
876
|
function Unit.prototype.addAbility(self, abilityId)
|
|
871
877
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -995,18 +1001,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
995
1001
|
self:decrementStunCounter()
|
|
996
1002
|
end
|
|
997
1003
|
function Unit.prototype.incrementStunCounter(self)
|
|
998
|
-
local stunCounter = self[
|
|
999
|
-
if not self[
|
|
1004
|
+
local stunCounter = self[102] or 0
|
|
1005
|
+
if not self[101] or stunCounter >= 0 then
|
|
1000
1006
|
BlzPauseUnitEx(self.handle, true)
|
|
1001
1007
|
end
|
|
1002
|
-
self[
|
|
1008
|
+
self[102] = stunCounter + 1
|
|
1003
1009
|
end
|
|
1004
1010
|
function Unit.prototype.decrementStunCounter(self)
|
|
1005
|
-
local stunCounter = self[
|
|
1006
|
-
if not self[
|
|
1011
|
+
local stunCounter = self[102] or 0
|
|
1012
|
+
if not self[101] or stunCounter >= 1 then
|
|
1007
1013
|
BlzPauseUnitEx(self.handle, false)
|
|
1008
1014
|
end
|
|
1009
|
-
self[
|
|
1015
|
+
self[102] = stunCounter - 1
|
|
1010
1016
|
end
|
|
1011
1017
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1012
1018
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1108,8 +1114,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1108
1114
|
)
|
|
1109
1115
|
return targetCollection
|
|
1110
1116
|
end
|
|
1111
|
-
function Unit.getSelectionOf(self, player)
|
|
1112
|
-
|
|
1117
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1118
|
+
if target == nil then
|
|
1119
|
+
target = {}
|
|
1120
|
+
end
|
|
1121
|
+
targetCollection = target
|
|
1113
1122
|
targetCollectionNextIndex = 1
|
|
1114
1123
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1115
1124
|
return targetCollection
|
|
@@ -1131,6 +1140,9 @@ end
|
|
|
1131
1140
|
function Unit.prototype.__tostring(self)
|
|
1132
1141
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1133
1142
|
end
|
|
1143
|
+
function Unit.getBySyncId(self, syncId)
|
|
1144
|
+
return unitBySyncId[syncId]
|
|
1145
|
+
end
|
|
1134
1146
|
__TS__SetDescriptor(
|
|
1135
1147
|
Unit.prototype,
|
|
1136
1148
|
"_deltas",
|
|
@@ -1388,17 +1400,17 @@ __TS__SetDescriptor(
|
|
|
1388
1400
|
"isTeamGlowVisible",
|
|
1389
1401
|
{
|
|
1390
1402
|
get = function(self)
|
|
1391
|
-
return not self[
|
|
1403
|
+
return not self[106]
|
|
1392
1404
|
end,
|
|
1393
1405
|
set = function(self, isTeamGlowVisible)
|
|
1394
1406
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1395
|
-
local
|
|
1407
|
+
local ____temp_6
|
|
1396
1408
|
if not isTeamGlowVisible then
|
|
1397
|
-
|
|
1409
|
+
____temp_6 = true
|
|
1398
1410
|
else
|
|
1399
|
-
|
|
1411
|
+
____temp_6 = nil
|
|
1400
1412
|
end
|
|
1401
|
-
self[
|
|
1413
|
+
self[106] = ____temp_6
|
|
1402
1414
|
end
|
|
1403
1415
|
},
|
|
1404
1416
|
true
|
|
@@ -1408,7 +1420,7 @@ __TS__SetDescriptor(
|
|
|
1408
1420
|
"color",
|
|
1409
1421
|
{set = function(self, color)
|
|
1410
1422
|
setUnitColor(self.handle, color.handle)
|
|
1411
|
-
if self[
|
|
1423
|
+
if self[106] then
|
|
1412
1424
|
showUnitTeamGlow(self.handle, false)
|
|
1413
1425
|
end
|
|
1414
1426
|
end},
|
|
@@ -1432,14 +1444,14 @@ __TS__SetDescriptor(
|
|
|
1432
1444
|
"maxHealth",
|
|
1433
1445
|
{
|
|
1434
1446
|
get = function(self)
|
|
1435
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1447
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1436
1448
|
end,
|
|
1437
1449
|
set = function(self, maxHealth)
|
|
1438
|
-
if maxHealth < 1 and self[
|
|
1439
|
-
self[
|
|
1450
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1451
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1440
1452
|
maxHealth = 1
|
|
1441
1453
|
end
|
|
1442
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1454
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1443
1455
|
end
|
|
1444
1456
|
},
|
|
1445
1457
|
true
|
|
@@ -1481,10 +1493,10 @@ __TS__SetDescriptor(
|
|
|
1481
1493
|
"health",
|
|
1482
1494
|
{
|
|
1483
1495
|
get = function(self)
|
|
1484
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1496
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1485
1497
|
end,
|
|
1486
1498
|
set = function(self, health)
|
|
1487
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1499
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1488
1500
|
end
|
|
1489
1501
|
},
|
|
1490
1502
|
true
|
|
@@ -1695,17 +1707,17 @@ __TS__SetDescriptor(
|
|
|
1695
1707
|
set = function(self, isPaused)
|
|
1696
1708
|
local handle = self.handle
|
|
1697
1709
|
if isPaused and not IsUnitPaused(handle) then
|
|
1698
|
-
self[
|
|
1699
|
-
for _ = self[
|
|
1710
|
+
self[101] = true
|
|
1711
|
+
for _ = self[102] or 0, -1 do
|
|
1700
1712
|
BlzPauseUnitEx(handle, true)
|
|
1701
1713
|
end
|
|
1702
1714
|
PauseUnit(handle, true)
|
|
1703
1715
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1704
1716
|
PauseUnit(handle, false)
|
|
1705
|
-
for _ = self[
|
|
1717
|
+
for _ = self[102] or 0, -1 do
|
|
1706
1718
|
BlzPauseUnitEx(handle, false)
|
|
1707
1719
|
end
|
|
1708
|
-
self[
|
|
1720
|
+
self[101] = nil
|
|
1709
1721
|
end
|
|
1710
1722
|
end
|
|
1711
1723
|
},
|
|
@@ -2124,25 +2136,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2124
2136
|
InitializingEvent,
|
|
2125
2137
|
function(event)
|
|
2126
2138
|
local function listener(unit, id)
|
|
2127
|
-
local
|
|
2139
|
+
local ____GetSpellTargetUnit_result_9
|
|
2128
2140
|
if GetSpellTargetUnit() then
|
|
2129
|
-
|
|
2141
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2130
2142
|
else
|
|
2131
|
-
local
|
|
2143
|
+
local ____GetSpellTargetItem_result_8
|
|
2132
2144
|
if GetSpellTargetItem() then
|
|
2133
|
-
|
|
2145
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2134
2146
|
else
|
|
2135
|
-
local
|
|
2147
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2136
2148
|
if GetSpellTargetDestructable() then
|
|
2137
|
-
|
|
2149
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2138
2150
|
else
|
|
2139
|
-
|
|
2151
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2140
2152
|
end
|
|
2141
|
-
|
|
2153
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2142
2154
|
end
|
|
2143
|
-
|
|
2155
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2144
2156
|
end
|
|
2145
|
-
local target =
|
|
2157
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2146
2158
|
if target then
|
|
2147
2159
|
invoke(event, unit, id, target)
|
|
2148
2160
|
end
|
|
@@ -2452,6 +2464,7 @@ Unit.onDamage = __TS__New(
|
|
|
2452
2464
|
damageType = BlzGetEventDamageType(),
|
|
2453
2465
|
weaponType = BlzGetEventWeaponType(),
|
|
2454
2466
|
isAttack = BlzGetEventIsAttack(),
|
|
2467
|
+
originalAmount = GetEventDamage(),
|
|
2455
2468
|
preventDeath = damageEventPreventDeath
|
|
2456
2469
|
}
|
|
2457
2470
|
local evData = setmetatable(
|
|
@@ -2468,7 +2481,7 @@ Unit.onDamage = __TS__New(
|
|
|
2468
2481
|
invoke(event, source, target, evData)
|
|
2469
2482
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2470
2483
|
local bonusHealth = math.ceil(evData.amount)
|
|
2471
|
-
target[
|
|
2484
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2472
2485
|
BlzSetUnitMaxHP(
|
|
2473
2486
|
target.handle,
|
|
2474
2487
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2482,7 +2495,7 @@ Unit.onDamage = __TS__New(
|
|
|
2482
2495
|
evData[0],
|
|
2483
2496
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2484
2497
|
)
|
|
2485
|
-
target[
|
|
2498
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2486
2499
|
SetWidgetLife(
|
|
2487
2500
|
target.handle,
|
|
2488
2501
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2502,7 +2515,7 @@ Unit.onDamage = __TS__New(
|
|
|
2502
2515
|
DestroyTrigger(trigger)
|
|
2503
2516
|
end
|
|
2504
2517
|
)
|
|
2505
|
-
Unit.
|
|
2518
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2506
2519
|
____exports.UnitTriggerEvent,
|
|
2507
2520
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2508
2521
|
function()
|
|
@@ -2513,7 +2526,7 @@ Unit.onItemDrop = __TS__New(
|
|
|
2513
2526
|
return IgnoreEvent
|
|
2514
2527
|
end
|
|
2515
2528
|
)
|
|
2516
|
-
Unit.
|
|
2529
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2517
2530
|
____exports.UnitTriggerEvent,
|
|
2518
2531
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2519
2532
|
function()
|
|
@@ -2524,10 +2537,43 @@ Unit.onItemPickup = __TS__New(
|
|
|
2524
2537
|
return IgnoreEvent
|
|
2525
2538
|
end
|
|
2526
2539
|
)
|
|
2527
|
-
Unit.
|
|
2540
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2528
2541
|
____exports.UnitTriggerEvent,
|
|
2529
2542
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2530
|
-
function() return ____exports.Unit:of(
|
|
2543
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2544
|
+
)
|
|
2545
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2546
|
+
____exports.UnitTriggerEvent,
|
|
2547
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2548
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2549
|
+
)
|
|
2550
|
+
__TS__ObjectDefineProperty(
|
|
2551
|
+
Unit,
|
|
2552
|
+
"itemMovedEvent",
|
|
2553
|
+
{get = function(self)
|
|
2554
|
+
local event = __TS__New(Event)
|
|
2555
|
+
do
|
|
2556
|
+
local order = orderId("moveslot1")
|
|
2557
|
+
while order <= orderId("moveslot5") do
|
|
2558
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2559
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2560
|
+
if slotFrom ~= nil then
|
|
2561
|
+
local slotTo = order - orderId("moveslot1")
|
|
2562
|
+
invoke(
|
|
2563
|
+
event,
|
|
2564
|
+
unit,
|
|
2565
|
+
item,
|
|
2566
|
+
slotFrom,
|
|
2567
|
+
slotTo
|
|
2568
|
+
)
|
|
2569
|
+
end
|
|
2570
|
+
end)
|
|
2571
|
+
order = order + 1
|
|
2572
|
+
end
|
|
2573
|
+
end
|
|
2574
|
+
rawset(self, "itemMovedEvent", event)
|
|
2575
|
+
return event
|
|
2576
|
+
end}
|
|
2531
2577
|
)
|
|
2532
2578
|
__TS__ObjectDefineProperty(
|
|
2533
2579
|
Unit,
|
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)
|
|
@@ -45,4 +45,16 @@ export declare class ItemType extends ObjectDataEntry<ItemTypeId> {
|
|
|
45
45
|
set tooltipText(tooltipText: string);
|
|
46
46
|
get tooltipExtendedText(): string;
|
|
47
47
|
set tooltipExtendedText(tooltipText: string);
|
|
48
|
+
get goldCost(): number;
|
|
49
|
+
set goldCost(goldCost: number);
|
|
50
|
+
get lumberCost(): number;
|
|
51
|
+
set lumberCost(lumberCost: number);
|
|
52
|
+
get activelyUsed(): boolean;
|
|
53
|
+
set activelyUsed(activelyUsed: boolean);
|
|
54
|
+
get perishable(): boolean;
|
|
55
|
+
set perishable(perishable: boolean);
|
|
56
|
+
get initialStackSize(): number;
|
|
57
|
+
set initialStackSize(initialStackSize: number);
|
|
58
|
+
get maximumStackSize(): number;
|
|
59
|
+
set maximumStackSize(maximumStackSize: number);
|
|
48
60
|
}
|
|
@@ -256,4 +256,82 @@ __TS__SetDescriptor(
|
|
|
256
256
|
},
|
|
257
257
|
true
|
|
258
258
|
)
|
|
259
|
+
__TS__SetDescriptor(
|
|
260
|
+
ItemType.prototype,
|
|
261
|
+
"goldCost",
|
|
262
|
+
{
|
|
263
|
+
get = function(self)
|
|
264
|
+
return self:getNumberField("igol")
|
|
265
|
+
end,
|
|
266
|
+
set = function(self, goldCost)
|
|
267
|
+
self:setNumberField("igol", goldCost)
|
|
268
|
+
end
|
|
269
|
+
},
|
|
270
|
+
true
|
|
271
|
+
)
|
|
272
|
+
__TS__SetDescriptor(
|
|
273
|
+
ItemType.prototype,
|
|
274
|
+
"lumberCost",
|
|
275
|
+
{
|
|
276
|
+
get = function(self)
|
|
277
|
+
return self:getNumberField("ilum")
|
|
278
|
+
end,
|
|
279
|
+
set = function(self, lumberCost)
|
|
280
|
+
self:setNumberField("ilum", lumberCost)
|
|
281
|
+
end
|
|
282
|
+
},
|
|
283
|
+
true
|
|
284
|
+
)
|
|
285
|
+
__TS__SetDescriptor(
|
|
286
|
+
ItemType.prototype,
|
|
287
|
+
"activelyUsed",
|
|
288
|
+
{
|
|
289
|
+
get = function(self)
|
|
290
|
+
return self:getBooleanField("iusa")
|
|
291
|
+
end,
|
|
292
|
+
set = function(self, activelyUsed)
|
|
293
|
+
self:setBooleanField("iusa", activelyUsed)
|
|
294
|
+
end
|
|
295
|
+
},
|
|
296
|
+
true
|
|
297
|
+
)
|
|
298
|
+
__TS__SetDescriptor(
|
|
299
|
+
ItemType.prototype,
|
|
300
|
+
"perishable",
|
|
301
|
+
{
|
|
302
|
+
get = function(self)
|
|
303
|
+
return self:getBooleanField("iper")
|
|
304
|
+
end,
|
|
305
|
+
set = function(self, perishable)
|
|
306
|
+
self:setBooleanField("iper", perishable)
|
|
307
|
+
end
|
|
308
|
+
},
|
|
309
|
+
true
|
|
310
|
+
)
|
|
311
|
+
__TS__SetDescriptor(
|
|
312
|
+
ItemType.prototype,
|
|
313
|
+
"initialStackSize",
|
|
314
|
+
{
|
|
315
|
+
get = function(self)
|
|
316
|
+
return self:getNumberField("iuse")
|
|
317
|
+
end,
|
|
318
|
+
set = function(self, initialStackSize)
|
|
319
|
+
self:setNumberField("iuse", initialStackSize)
|
|
320
|
+
end
|
|
321
|
+
},
|
|
322
|
+
true
|
|
323
|
+
)
|
|
324
|
+
__TS__SetDescriptor(
|
|
325
|
+
ItemType.prototype,
|
|
326
|
+
"maximumStackSize",
|
|
327
|
+
{
|
|
328
|
+
get = function(self)
|
|
329
|
+
return self:getNumberField("ista")
|
|
330
|
+
end,
|
|
331
|
+
set = function(self, maximumStackSize)
|
|
332
|
+
self:setNumberField("ista", maximumStackSize)
|
|
333
|
+
end
|
|
334
|
+
},
|
|
335
|
+
true
|
|
336
|
+
)
|
|
259
337
|
return ____exports
|
|
@@ -6,6 +6,9 @@ import { ObjectDataEntryId } from "../object-data/entry";
|
|
|
6
6
|
import { LightningTypeId } from "../object-data/entry/lightning-type";
|
|
7
7
|
import { CombatClassifications } from "../object-data/auxiliary/combat-classification";
|
|
8
8
|
import { UnitTypeId } from "../object-data/entry/unit-type";
|
|
9
|
+
import { BuffResistanceType } from "../object-data/auxiliary/buff-resistance-type";
|
|
10
|
+
import { BuffPolarity } from "../object-data/auxiliary/buff-polarity";
|
|
11
|
+
import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
|
|
9
12
|
export declare abstract class AbilityField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectField<AbilityType, Ability, ValueType, NativeFieldType> {
|
|
10
13
|
protected get instanceClass(): typeof Ability;
|
|
11
14
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
@@ -107,6 +110,20 @@ export declare class AbilityAbilityTypeIdLevelField extends AbilityObjectDataEnt
|
|
|
107
110
|
}
|
|
108
111
|
export declare class AbilityUnitTypeIdLevelField extends AbilityObjectDataEntryIdLevelField<UnitTypeId> {
|
|
109
112
|
}
|
|
113
|
+
export declare abstract class AbilityEnumLevelField<T extends number> extends AbilityLevelField<T, T, jabilityintegerlevelfield> {
|
|
114
|
+
protected abstract values: ReadonlyNonEmptyLinkedSet<T>;
|
|
115
|
+
protected get defaultValue(): T;
|
|
116
|
+
protected getNativeFieldById(id: number): jabilityintegerlevelfield;
|
|
117
|
+
protected getNativeFieldValue(instance: Ability, level: number): T;
|
|
118
|
+
protected setNativeFieldValue(instance: Ability, level: number, value: T): boolean;
|
|
119
|
+
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<AbilityBooleanLevelField>;
|
|
120
|
+
}
|
|
121
|
+
export declare class AbilityBuffPolarityLevelField extends AbilityEnumLevelField<BuffPolarity> {
|
|
122
|
+
protected values: ReadonlyNonEmptyLinkedSet<BuffPolarity>;
|
|
123
|
+
}
|
|
124
|
+
export declare class AbilityBuffResistanceTypeLevelField extends AbilityEnumLevelField<BuffResistanceType> {
|
|
125
|
+
protected values: ReadonlyNonEmptyLinkedSet<BuffResistanceType>;
|
|
126
|
+
}
|
|
110
127
|
export declare class AbilityCombatClassificationsLevelField extends AbilityLevelField<CombatClassifications, CombatClassifications, jabilityintegerlevelfield> {
|
|
111
128
|
protected get defaultValue(): CombatClassifications;
|
|
112
129
|
protected getNativeFieldById(id: number): jabilityintegerlevelfield;
|