warscript 0.0.1-dev.6fe4470 → 0.0.1-dev.724bf08
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/core/types/effect.d.ts +12 -3
- package/core/types/effect.lua +56 -7
- package/core/types/frame.d.ts +4 -0
- package/core/types/frame.lua +71 -0
- 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/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +30 -0
- 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 +18 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -0
- package/engine/behaviour/ability.d.ts +8 -2
- package/engine/behaviour/ability.lua +44 -34
- package/engine/behaviour/unit.d.ts +5 -0
- package/engine/behaviour/unit.lua +20 -0
- package/engine/buff.d.ts +9 -1
- package/engine/buff.lua +44 -18
- package/engine/internal/ability.d.ts +5 -12
- package/engine/internal/ability.lua +13 -74
- package/engine/internal/item+owner.lua +2 -2
- 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 +84 -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-missile-launch.lua +24 -5
- package/engine/internal/unit.d.ts +23 -10
- package/engine/internal/unit.lua +101 -71
- 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/item-type.d.ts +12 -0
- package/engine/object-data/entry/item-type.lua +78 -0
- package/engine/object-field/ability.d.ts +4 -1
- package/engine/object-field/ability.lua +1 -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/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 +1 -1
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -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/engine/internal/unit.lua
CHANGED
|
@@ -562,17 +562,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
562
|
____exports.Unit:of(unit)
|
|
563
563
|
)
|
|
564
564
|
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
565
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
566
|
local item = unitItemInSlot(unit, i)
|
|
578
567
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -630,15 +619,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
619
|
dummies[player] = dummy
|
|
631
620
|
end
|
|
632
621
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
622
|
+
local counter = (unit[103] or 0) - 1
|
|
634
623
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
624
|
+
unit[103] = counter
|
|
636
625
|
return
|
|
637
626
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
627
|
+
unit[103] = nil
|
|
628
|
+
local healthBonus = unit[104]
|
|
640
629
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
630
|
+
unit[104] = nil
|
|
642
631
|
local handle = unit.handle
|
|
643
632
|
BlzSetUnitMaxHP(
|
|
644
633
|
handle,
|
|
@@ -646,12 +635,17 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
635
|
)
|
|
647
636
|
end
|
|
648
637
|
end
|
|
638
|
+
local nextSyncId = 1
|
|
639
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
649
640
|
____exports.Unit = __TS__Class()
|
|
650
641
|
local Unit = ____exports.Unit
|
|
651
642
|
Unit.name = "Unit"
|
|
652
643
|
__TS__ClassExtends(Unit, Handle)
|
|
653
644
|
function Unit.prototype.____constructor(self, handle)
|
|
654
645
|
Handle.prototype.____constructor(self, handle)
|
|
646
|
+
local ____nextSyncId_0 = nextSyncId
|
|
647
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
648
|
+
self.syncId = ____nextSyncId_0
|
|
655
649
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
650
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
651
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +658,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
658
|
fourCC("Amrf")
|
|
665
659
|
))
|
|
666
660
|
end
|
|
661
|
+
unitBySyncId[self.syncId] = self
|
|
667
662
|
local ____ = self.abilities
|
|
668
663
|
end
|
|
669
664
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -749,8 +744,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
744
|
end}
|
|
750
745
|
end
|
|
751
746
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
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
|
|
754
749
|
end
|
|
755
750
|
function Unit.prototype.addClassification(self, classification)
|
|
756
751
|
return unitAddType(self.handle, classification)
|
|
@@ -768,13 +763,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
763
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
764
|
end
|
|
770
765
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
766
|
+
local ____temp_2
|
|
772
767
|
if type(x) == "number" then
|
|
773
|
-
|
|
768
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
769
|
else
|
|
775
|
-
|
|
770
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
776
771
|
end
|
|
777
|
-
return
|
|
772
|
+
return ____temp_2
|
|
778
773
|
end
|
|
779
774
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
775
|
return isUnitAlly(
|
|
@@ -801,7 +796,7 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
801
796
|
queueUnitAnimation(self.handle, animation)
|
|
802
797
|
end
|
|
803
798
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
799
|
+
self[103] = (self[103] or 0) + 1
|
|
805
800
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
801
|
end
|
|
807
802
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -818,14 +813,14 @@ function Unit.prototype.kill(self)
|
|
|
818
813
|
killUnit(self.handle)
|
|
819
814
|
end
|
|
820
815
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
821
|
-
local
|
|
822
|
-
local
|
|
823
|
-
local
|
|
824
|
-
if
|
|
825
|
-
|
|
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
|
|
826
821
|
end
|
|
827
|
-
__TS__SparseArrayPush(
|
|
828
|
-
|
|
822
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
823
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
829
824
|
end
|
|
830
825
|
function Unit.prototype.healTarget(self, target, amount)
|
|
831
826
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -865,7 +860,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
865
860
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
866
861
|
end
|
|
867
862
|
function Unit.prototype.itemInSlot(self, slot)
|
|
868
|
-
return Item:of(
|
|
863
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
869
864
|
end
|
|
870
865
|
function Unit.prototype.addAbility(self, abilityId)
|
|
871
866
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -995,18 +990,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
995
990
|
self:decrementStunCounter()
|
|
996
991
|
end
|
|
997
992
|
function Unit.prototype.incrementStunCounter(self)
|
|
998
|
-
local stunCounter = self[
|
|
999
|
-
if not self[
|
|
993
|
+
local stunCounter = self[102] or 0
|
|
994
|
+
if not self[101] or stunCounter >= 0 then
|
|
1000
995
|
BlzPauseUnitEx(self.handle, true)
|
|
1001
996
|
end
|
|
1002
|
-
self[
|
|
997
|
+
self[102] = stunCounter + 1
|
|
1003
998
|
end
|
|
1004
999
|
function Unit.prototype.decrementStunCounter(self)
|
|
1005
|
-
local stunCounter = self[
|
|
1006
|
-
if not self[
|
|
1000
|
+
local stunCounter = self[102] or 0
|
|
1001
|
+
if not self[101] or stunCounter >= 1 then
|
|
1007
1002
|
BlzPauseUnitEx(self.handle, false)
|
|
1008
1003
|
end
|
|
1009
|
-
self[
|
|
1004
|
+
self[102] = stunCounter - 1
|
|
1010
1005
|
end
|
|
1011
1006
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1012
1007
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1108,8 +1103,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1108
1103
|
)
|
|
1109
1104
|
return targetCollection
|
|
1110
1105
|
end
|
|
1111
|
-
function Unit.getSelectionOf(self, player)
|
|
1112
|
-
|
|
1106
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1107
|
+
if target == nil then
|
|
1108
|
+
target = {}
|
|
1109
|
+
end
|
|
1110
|
+
targetCollection = target
|
|
1113
1111
|
targetCollectionNextIndex = 1
|
|
1114
1112
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1115
1113
|
return targetCollection
|
|
@@ -1131,6 +1129,9 @@ end
|
|
|
1131
1129
|
function Unit.prototype.__tostring(self)
|
|
1132
1130
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1133
1131
|
end
|
|
1132
|
+
function Unit.getBySyncId(self, syncId)
|
|
1133
|
+
return unitBySyncId[syncId]
|
|
1134
|
+
end
|
|
1134
1135
|
__TS__SetDescriptor(
|
|
1135
1136
|
Unit.prototype,
|
|
1136
1137
|
"_deltas",
|
|
@@ -1388,17 +1389,17 @@ __TS__SetDescriptor(
|
|
|
1388
1389
|
"isTeamGlowVisible",
|
|
1389
1390
|
{
|
|
1390
1391
|
get = function(self)
|
|
1391
|
-
return not self[
|
|
1392
|
+
return not self[106]
|
|
1392
1393
|
end,
|
|
1393
1394
|
set = function(self, isTeamGlowVisible)
|
|
1394
1395
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1395
|
-
local
|
|
1396
|
+
local ____temp_6
|
|
1396
1397
|
if not isTeamGlowVisible then
|
|
1397
|
-
|
|
1398
|
+
____temp_6 = true
|
|
1398
1399
|
else
|
|
1399
|
-
|
|
1400
|
+
____temp_6 = nil
|
|
1400
1401
|
end
|
|
1401
|
-
self[
|
|
1402
|
+
self[106] = ____temp_6
|
|
1402
1403
|
end
|
|
1403
1404
|
},
|
|
1404
1405
|
true
|
|
@@ -1408,7 +1409,7 @@ __TS__SetDescriptor(
|
|
|
1408
1409
|
"color",
|
|
1409
1410
|
{set = function(self, color)
|
|
1410
1411
|
setUnitColor(self.handle, color.handle)
|
|
1411
|
-
if self[
|
|
1412
|
+
if self[106] then
|
|
1412
1413
|
showUnitTeamGlow(self.handle, false)
|
|
1413
1414
|
end
|
|
1414
1415
|
end},
|
|
@@ -1432,14 +1433,14 @@ __TS__SetDescriptor(
|
|
|
1432
1433
|
"maxHealth",
|
|
1433
1434
|
{
|
|
1434
1435
|
get = function(self)
|
|
1435
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1436
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1436
1437
|
end,
|
|
1437
1438
|
set = function(self, maxHealth)
|
|
1438
|
-
if maxHealth < 1 and self[
|
|
1439
|
-
self[
|
|
1439
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1440
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1440
1441
|
maxHealth = 1
|
|
1441
1442
|
end
|
|
1442
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1443
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1443
1444
|
end
|
|
1444
1445
|
},
|
|
1445
1446
|
true
|
|
@@ -1481,10 +1482,10 @@ __TS__SetDescriptor(
|
|
|
1481
1482
|
"health",
|
|
1482
1483
|
{
|
|
1483
1484
|
get = function(self)
|
|
1484
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1485
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1485
1486
|
end,
|
|
1486
1487
|
set = function(self, health)
|
|
1487
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1488
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1488
1489
|
end
|
|
1489
1490
|
},
|
|
1490
1491
|
true
|
|
@@ -1695,17 +1696,17 @@ __TS__SetDescriptor(
|
|
|
1695
1696
|
set = function(self, isPaused)
|
|
1696
1697
|
local handle = self.handle
|
|
1697
1698
|
if isPaused and not IsUnitPaused(handle) then
|
|
1698
|
-
self[
|
|
1699
|
-
for _ = self[
|
|
1699
|
+
self[101] = true
|
|
1700
|
+
for _ = self[102] or 0, -1 do
|
|
1700
1701
|
BlzPauseUnitEx(handle, true)
|
|
1701
1702
|
end
|
|
1702
1703
|
PauseUnit(handle, true)
|
|
1703
1704
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1704
1705
|
PauseUnit(handle, false)
|
|
1705
|
-
for _ = self[
|
|
1706
|
+
for _ = self[102] or 0, -1 do
|
|
1706
1707
|
BlzPauseUnitEx(handle, false)
|
|
1707
1708
|
end
|
|
1708
|
-
self[
|
|
1709
|
+
self[101] = nil
|
|
1709
1710
|
end
|
|
1710
1711
|
end
|
|
1711
1712
|
},
|
|
@@ -2124,25 +2125,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2124
2125
|
InitializingEvent,
|
|
2125
2126
|
function(event)
|
|
2126
2127
|
local function listener(unit, id)
|
|
2127
|
-
local
|
|
2128
|
+
local ____GetSpellTargetUnit_result_9
|
|
2128
2129
|
if GetSpellTargetUnit() then
|
|
2129
|
-
|
|
2130
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2130
2131
|
else
|
|
2131
|
-
local
|
|
2132
|
+
local ____GetSpellTargetItem_result_8
|
|
2132
2133
|
if GetSpellTargetItem() then
|
|
2133
|
-
|
|
2134
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2134
2135
|
else
|
|
2135
|
-
local
|
|
2136
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2136
2137
|
if GetSpellTargetDestructable() then
|
|
2137
|
-
|
|
2138
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2138
2139
|
else
|
|
2139
|
-
|
|
2140
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2140
2141
|
end
|
|
2141
|
-
|
|
2142
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2142
2143
|
end
|
|
2143
|
-
|
|
2144
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2144
2145
|
end
|
|
2145
|
-
local target =
|
|
2146
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2146
2147
|
if target then
|
|
2147
2148
|
invoke(event, unit, id, target)
|
|
2148
2149
|
end
|
|
@@ -2469,7 +2470,7 @@ Unit.onDamage = __TS__New(
|
|
|
2469
2470
|
invoke(event, source, target, evData)
|
|
2470
2471
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2471
2472
|
local bonusHealth = math.ceil(evData.amount)
|
|
2472
|
-
target[
|
|
2473
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2473
2474
|
BlzSetUnitMaxHP(
|
|
2474
2475
|
target.handle,
|
|
2475
2476
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2483,7 +2484,7 @@ Unit.onDamage = __TS__New(
|
|
|
2483
2484
|
evData[0],
|
|
2484
2485
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2485
2486
|
)
|
|
2486
|
-
target[
|
|
2487
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2487
2488
|
SetWidgetLife(
|
|
2488
2489
|
target.handle,
|
|
2489
2490
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2503,7 +2504,7 @@ Unit.onDamage = __TS__New(
|
|
|
2503
2504
|
DestroyTrigger(trigger)
|
|
2504
2505
|
end
|
|
2505
2506
|
)
|
|
2506
|
-
Unit.
|
|
2507
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2507
2508
|
____exports.UnitTriggerEvent,
|
|
2508
2509
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2509
2510
|
function()
|
|
@@ -2514,7 +2515,7 @@ Unit.onItemDrop = __TS__New(
|
|
|
2514
2515
|
return IgnoreEvent
|
|
2515
2516
|
end
|
|
2516
2517
|
)
|
|
2517
|
-
Unit.
|
|
2518
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2518
2519
|
____exports.UnitTriggerEvent,
|
|
2519
2520
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2520
2521
|
function()
|
|
@@ -2525,10 +2526,39 @@ Unit.onItemPickup = __TS__New(
|
|
|
2525
2526
|
return IgnoreEvent
|
|
2526
2527
|
end
|
|
2527
2528
|
)
|
|
2528
|
-
Unit.
|
|
2529
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2529
2530
|
____exports.UnitTriggerEvent,
|
|
2530
2531
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2531
|
-
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
|
+
"itemMovedEvent",
|
|
2542
|
+
{get = function(self)
|
|
2543
|
+
local event = __TS__New(Event)
|
|
2544
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2545
|
+
local slotTo = order - orderId("moveslot0")
|
|
2546
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2547
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2548
|
+
if slotFrom ~= nil then
|
|
2549
|
+
invoke(
|
|
2550
|
+
event,
|
|
2551
|
+
unit,
|
|
2552
|
+
item,
|
|
2553
|
+
slotFrom,
|
|
2554
|
+
slotTo
|
|
2555
|
+
)
|
|
2556
|
+
end
|
|
2557
|
+
end)
|
|
2558
|
+
end
|
|
2559
|
+
rawset(self, "itemMovedEvent", event)
|
|
2560
|
+
return event
|
|
2561
|
+
end}
|
|
2532
2562
|
)
|
|
2533
2563
|
__TS__ObjectDefineProperty(
|
|
2534
2564
|
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)
|
|
@@ -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
|
}
|
|
@@ -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
|
|
@@ -131,4 +131,7 @@ export declare class AbilityCombatClassificationsLevelField extends AbilityLevel
|
|
|
131
131
|
protected setNativeFieldValue(instance: Ability, level: number, value: CombatClassifications): boolean;
|
|
132
132
|
}
|
|
133
133
|
export type AbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType> | ((ability: Ability) => ValueType);
|
|
134
|
-
export declare const resolveCurrentAbilityDependentValue:
|
|
134
|
+
export declare const resolveCurrentAbilityDependentValue: {
|
|
135
|
+
<ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>): ValueType;
|
|
136
|
+
<ValueType extends boolean | number | string>(ability: Ability, value?: AbilityDependentValue<ValueType>): ValueType | undefined;
|
|
137
|
+
};
|
|
@@ -261,7 +261,7 @@ local AbilityLevelField = ____exports.AbilityLevelField
|
|
|
261
261
|
AbilityLevelField.name = "AbilityLevelField"
|
|
262
262
|
__TS__ClassExtends(AbilityLevelField, ObjectLevelField)
|
|
263
263
|
function AbilityLevelField.prototype.getLevelCount(self, entry)
|
|
264
|
-
return
|
|
264
|
+
return entry.levelCount
|
|
265
265
|
end
|
|
266
266
|
function AbilityLevelField.prototype.getObjectDataEntryId(self, instance)
|
|
267
267
|
return instance.typeId
|
|
@@ -687,6 +687,8 @@ export declare const DISABLE_OTHER_ABILITIES_ABILITY_BOOLEAN_LEVEL_FIELD: Abilit
|
|
|
687
687
|
export declare const ALLOW_BOUNTY_ABILITY_BOOLEAN_LEVEL_FIELD: AbilityBooleanLevelField & symbol;
|
|
688
688
|
export declare const ICON_NORMAL_ABILITY_STRING_LEVEL_FIELD: AbilityStringLevelField & symbol;
|
|
689
689
|
export declare const CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD: AbilityStringArrayField & symbol;
|
|
690
|
+
export declare const CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
|
|
691
|
+
export declare const CASTER_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
|
|
690
692
|
export declare const TARGET_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD: AbilityStringArrayField & symbol;
|
|
691
693
|
export declare const TARGET_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
|
|
692
694
|
export declare const TARGET_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
|
|
@@ -698,6 +698,8 @@ ____exports.DISABLE_OTHER_ABILITIES_ABILITY_BOOLEAN_LEVEL_FIELD = AbilityBoolean
|
|
|
698
698
|
____exports.ALLOW_BOUNTY_ABILITY_BOOLEAN_LEVEL_FIELD = AbilityBooleanLevelField:create(fourCC("Ntm4"))
|
|
699
699
|
____exports.ICON_NORMAL_ABILITY_STRING_LEVEL_FIELD = AbilityStringLevelField:create(fourCC("aart"))
|
|
700
700
|
____exports.CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = AbilityStringArrayField:create(fourCC("acat"))
|
|
701
|
+
____exports.CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("acap"))
|
|
702
|
+
____exports.CASTER_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("aca1"))
|
|
701
703
|
____exports.TARGET_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = AbilityStringArrayField:create(fourCC("atat"))
|
|
702
704
|
____exports.TARGET_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("ata0"))
|
|
703
705
|
____exports.TARGET_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("ata1"))
|