warscript 0.0.1-dev.b026cc2 → 0.0.1-dev.b34a02b
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/frame.d.ts +3 -0
- package/core/types/frame.lua +30 -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 +32 -11
- package/engine/buff.lua +142 -61
- package/engine/internal/ability.d.ts +1 -11
- package/engine/internal/ability.lua +2 -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 +23 -0
- package/engine/internal/unit/item.lua +74 -0
- package/engine/internal/unit+ability.lua +2 -2
- package/engine/internal/unit-missile-launch.lua +24 -5
- package/engine/internal/unit.d.ts +15 -10
- package/engine/internal/unit.lua +105 -60
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +81 -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 +1 -0
- package/engine/unit.lua +1 -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/linked-set.d.ts +11 -2
- package/utility/linked-set.lua +5 -2
- package/utility/types.d.ts +1 -0
|
@@ -7,14 +7,33 @@ local ____event = require("event")
|
|
|
7
7
|
local Event = ____event.Event
|
|
8
8
|
local ____timer = require("core.types.timer")
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
10
12
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
11
13
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
12
14
|
local eventTimerByUnit = {}
|
|
13
|
-
local
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
local instantOrderIds = luaSetOf(
|
|
16
|
+
orderId("avatar"),
|
|
17
|
+
orderId("berserk"),
|
|
18
|
+
orderId("divineshield"),
|
|
19
|
+
orderId("immolation"),
|
|
20
|
+
orderId("moveslot0"),
|
|
21
|
+
orderId("moveslot1"),
|
|
22
|
+
orderId("moveslot2"),
|
|
23
|
+
orderId("moveslot3"),
|
|
24
|
+
orderId("moveslot4"),
|
|
25
|
+
orderId("moveslot5"),
|
|
26
|
+
orderId("unavatar"),
|
|
27
|
+
orderId("undivineshield"),
|
|
28
|
+
orderId("unimmolation")
|
|
29
|
+
)
|
|
30
|
+
local function reset(source, orderId)
|
|
31
|
+
if not (instantOrderIds[orderId] ~= nil) then
|
|
32
|
+
local eventTimer = eventTimerByUnit[source]
|
|
33
|
+
if eventTimer then
|
|
34
|
+
eventTimer:destroy()
|
|
35
|
+
eventTimerByUnit[source] = nil
|
|
36
|
+
end
|
|
18
37
|
end
|
|
19
38
|
end
|
|
20
39
|
Unit.onImmediateOrder:addListener(reset)
|
|
@@ -42,6 +42,7 @@ export interface DamagingEvent {
|
|
|
42
42
|
damageType: jdamagetype;
|
|
43
43
|
weaponType: jweapontype;
|
|
44
44
|
readonly isAttack: boolean;
|
|
45
|
+
readonly originalAmount: number;
|
|
45
46
|
}
|
|
46
47
|
export type DamageEvent = DamagingEvent & {
|
|
47
48
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
@@ -93,14 +94,16 @@ export declare class UnitWeapon {
|
|
|
93
94
|
set missileSpeed(missileSpeed: number);
|
|
94
95
|
}
|
|
95
96
|
declare const enum UnitPropertyKey {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
SYNC_ID = 100,
|
|
98
|
+
IS_PAUSED = 101,
|
|
99
|
+
STUN_COUNTER = 102,
|
|
100
|
+
DELAY_HEALTH_CHECKS_COUNTER = 103,
|
|
101
|
+
DELAY_HEALTH_CHECKS_HEALTH_BONUS = 104,
|
|
102
|
+
PREVENT_DEATH_HEALTH_BONUS = 105,
|
|
103
|
+
IS_TEAM_GLOW_HIDDEN = 106
|
|
102
104
|
}
|
|
103
105
|
export declare class Unit extends Handle<junit> {
|
|
106
|
+
private [UnitPropertyKey.SYNC_ID];
|
|
104
107
|
private [UnitPropertyKey.IS_PAUSED]?;
|
|
105
108
|
private [UnitPropertyKey.STUN_COUNTER]?;
|
|
106
109
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
|
|
@@ -287,7 +290,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
287
290
|
static getInRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
|
|
288
291
|
static getInCollisionRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
|
|
289
292
|
static getInSector(pos: Vec2, range: number, offsetAngle: number, centralAngle: number): Unit[];
|
|
290
|
-
static getSelectionOf(player: Player): Unit[];
|
|
293
|
+
static getSelectionOf(player: Player, target?: Unit[]): Unit[];
|
|
291
294
|
static readonly deathEvent: UnitTriggerEvent<[Unit]>;
|
|
292
295
|
static readonly onDecay: UnitTriggerEvent<[]>;
|
|
293
296
|
static readonly onResurrect: InitializingEvent<[Unit], void>;
|
|
@@ -322,9 +325,10 @@ export declare class Unit extends Handle<junit> {
|
|
|
322
325
|
static readonly autoAttackStartEvent: UnitTriggerEvent<[Unit]>;
|
|
323
326
|
static readonly onDamaging: Event<[source: Unit | undefined, target: Unit, event: DamagingEvent]>;
|
|
324
327
|
static readonly onDamage: InitializingEvent<[source: Unit | undefined, target: Unit, event: DamageEvent], jtrigger>;
|
|
325
|
-
static
|
|
326
|
-
static
|
|
327
|
-
static
|
|
328
|
+
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
329
|
+
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
330
|
+
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
331
|
+
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
328
332
|
static get onCreate(): EventDispatcher<[Unit], [Unit]>;
|
|
329
333
|
static get destroyEvent(): EventDispatcher<[Unit], [Unit]>;
|
|
330
334
|
getField(field: junitintegerfield | junitrealfield): number;
|
|
@@ -335,5 +339,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
335
339
|
setField(field: junitbooleanfield, value: boolean): boolean;
|
|
336
340
|
setField(field: junitstringfield, value: string): boolean;
|
|
337
341
|
toString(): string;
|
|
342
|
+
static getMainSelectedOf(player: Player): Unit | undefined;
|
|
338
343
|
}
|
|
339
344
|
export {};
|
package/engine/internal/unit.lua
CHANGED
|
@@ -15,6 +15,7 @@ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
|
15
15
|
local Set = ____lualib.Set
|
|
16
16
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
17
17
|
local ____exports = {}
|
|
18
|
+
local mainSelectedUnitByPlayer
|
|
18
19
|
local ____handle = require("core.types.handle")
|
|
19
20
|
local Handle = ____handle.Handle
|
|
20
21
|
local ____player = require("core.types.player")
|
|
@@ -50,7 +51,11 @@ local MANA_REGENERATION_RATE_BONUS_PER_INTELLIGENCE_POINT = ____constants.MANA_R
|
|
|
50
51
|
local ____arrays = require("utility.arrays")
|
|
51
52
|
local forEach = ____arrays.forEach
|
|
52
53
|
local ____math = require("math")
|
|
54
|
+
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
53
55
|
local min = ____math.min
|
|
56
|
+
local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
|
|
57
|
+
local ____local_2Dclient = require("engine.local-client")
|
|
58
|
+
local LocalClient = ____local_2Dclient.LocalClient
|
|
54
59
|
local match = string.match
|
|
55
60
|
local ____tostring = _G.tostring
|
|
56
61
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -630,15 +635,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
635
|
dummies[player] = dummy
|
|
631
636
|
end
|
|
632
637
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
638
|
+
local counter = (unit[103] or 0) - 1
|
|
634
639
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
640
|
+
unit[103] = counter
|
|
636
641
|
return
|
|
637
642
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
643
|
+
unit[103] = nil
|
|
644
|
+
local healthBonus = unit[104]
|
|
640
645
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
646
|
+
unit[104] = nil
|
|
642
647
|
local handle = unit.handle
|
|
643
648
|
BlzSetUnitMaxHP(
|
|
644
649
|
handle,
|
|
@@ -646,12 +651,17 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
651
|
)
|
|
647
652
|
end
|
|
648
653
|
end
|
|
654
|
+
local nextSyncId = 1
|
|
655
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
649
656
|
____exports.Unit = __TS__Class()
|
|
650
657
|
local Unit = ____exports.Unit
|
|
651
658
|
Unit.name = "Unit"
|
|
652
659
|
__TS__ClassExtends(Unit, Handle)
|
|
653
660
|
function Unit.prototype.____constructor(self, handle)
|
|
654
661
|
Handle.prototype.____constructor(self, handle)
|
|
662
|
+
local ____nextSyncId_0 = nextSyncId
|
|
663
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
664
|
+
self[100] = ____nextSyncId_0
|
|
655
665
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
666
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
667
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +674,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
674
|
fourCC("Amrf")
|
|
665
675
|
))
|
|
666
676
|
end
|
|
677
|
+
unitBySyncId[self[100]] = self
|
|
667
678
|
local ____ = self.abilities
|
|
668
679
|
end
|
|
669
680
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -749,8 +760,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
760
|
end}
|
|
750
761
|
end
|
|
751
762
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
763
|
+
local ____combatClassification_1 = combatClassification
|
|
764
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
754
765
|
end
|
|
755
766
|
function Unit.prototype.addClassification(self, classification)
|
|
756
767
|
return unitAddType(self.handle, classification)
|
|
@@ -768,13 +779,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
779
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
780
|
end
|
|
770
781
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
782
|
+
local ____temp_2
|
|
772
783
|
if type(x) == "number" then
|
|
773
|
-
|
|
784
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
785
|
else
|
|
775
|
-
|
|
786
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
776
787
|
end
|
|
777
|
-
return
|
|
788
|
+
return ____temp_2
|
|
778
789
|
end
|
|
779
790
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
791
|
return isUnitAlly(
|
|
@@ -801,7 +812,7 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
801
812
|
queueUnitAnimation(self.handle, animation)
|
|
802
813
|
end
|
|
803
814
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
815
|
+
self[103] = (self[103] or 0) + 1
|
|
805
816
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
817
|
end
|
|
807
818
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -818,14 +829,14 @@ function Unit.prototype.kill(self)
|
|
|
818
829
|
killUnit(self.handle)
|
|
819
830
|
end
|
|
820
831
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
821
|
-
local
|
|
822
|
-
local
|
|
823
|
-
local
|
|
824
|
-
if
|
|
825
|
-
|
|
832
|
+
local ____ReviveHero_5 = ReviveHero
|
|
833
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
834
|
+
local ____doEffect_3 = doEffect
|
|
835
|
+
if ____doEffect_3 == nil then
|
|
836
|
+
____doEffect_3 = false
|
|
826
837
|
end
|
|
827
|
-
__TS__SparseArrayPush(
|
|
828
|
-
|
|
838
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
839
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
829
840
|
end
|
|
830
841
|
function Unit.prototype.healTarget(self, target, amount)
|
|
831
842
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -865,7 +876,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
865
876
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
866
877
|
end
|
|
867
878
|
function Unit.prototype.itemInSlot(self, slot)
|
|
868
|
-
return Item:of(
|
|
879
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
869
880
|
end
|
|
870
881
|
function Unit.prototype.addAbility(self, abilityId)
|
|
871
882
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -995,18 +1006,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
995
1006
|
self:decrementStunCounter()
|
|
996
1007
|
end
|
|
997
1008
|
function Unit.prototype.incrementStunCounter(self)
|
|
998
|
-
local stunCounter = self[
|
|
999
|
-
if not self[
|
|
1009
|
+
local stunCounter = self[102] or 0
|
|
1010
|
+
if not self[101] or stunCounter >= 0 then
|
|
1000
1011
|
BlzPauseUnitEx(self.handle, true)
|
|
1001
1012
|
end
|
|
1002
|
-
self[
|
|
1013
|
+
self[102] = stunCounter + 1
|
|
1003
1014
|
end
|
|
1004
1015
|
function Unit.prototype.decrementStunCounter(self)
|
|
1005
|
-
local stunCounter = self[
|
|
1006
|
-
if not self[
|
|
1016
|
+
local stunCounter = self[102] or 0
|
|
1017
|
+
if not self[101] or stunCounter >= 1 then
|
|
1007
1018
|
BlzPauseUnitEx(self.handle, false)
|
|
1008
1019
|
end
|
|
1009
|
-
self[
|
|
1020
|
+
self[102] = stunCounter - 1
|
|
1010
1021
|
end
|
|
1011
1022
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1012
1023
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1108,8 +1119,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1108
1119
|
)
|
|
1109
1120
|
return targetCollection
|
|
1110
1121
|
end
|
|
1111
|
-
function Unit.getSelectionOf(self, player)
|
|
1112
|
-
|
|
1122
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1123
|
+
if target == nil then
|
|
1124
|
+
target = {}
|
|
1125
|
+
end
|
|
1126
|
+
targetCollection = target
|
|
1113
1127
|
targetCollectionNextIndex = 1
|
|
1114
1128
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1115
1129
|
return targetCollection
|
|
@@ -1131,6 +1145,9 @@ end
|
|
|
1131
1145
|
function Unit.prototype.__tostring(self)
|
|
1132
1146
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1133
1147
|
end
|
|
1148
|
+
function Unit.getMainSelectedOf(self, player)
|
|
1149
|
+
return mainSelectedUnitByPlayer[player]
|
|
1150
|
+
end
|
|
1134
1151
|
__TS__SetDescriptor(
|
|
1135
1152
|
Unit.prototype,
|
|
1136
1153
|
"_deltas",
|
|
@@ -1388,17 +1405,17 @@ __TS__SetDescriptor(
|
|
|
1388
1405
|
"isTeamGlowVisible",
|
|
1389
1406
|
{
|
|
1390
1407
|
get = function(self)
|
|
1391
|
-
return not self[
|
|
1408
|
+
return not self[106]
|
|
1392
1409
|
end,
|
|
1393
1410
|
set = function(self, isTeamGlowVisible)
|
|
1394
1411
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1395
|
-
local
|
|
1412
|
+
local ____temp_6
|
|
1396
1413
|
if not isTeamGlowVisible then
|
|
1397
|
-
|
|
1414
|
+
____temp_6 = true
|
|
1398
1415
|
else
|
|
1399
|
-
|
|
1416
|
+
____temp_6 = nil
|
|
1400
1417
|
end
|
|
1401
|
-
self[
|
|
1418
|
+
self[106] = ____temp_6
|
|
1402
1419
|
end
|
|
1403
1420
|
},
|
|
1404
1421
|
true
|
|
@@ -1408,7 +1425,7 @@ __TS__SetDescriptor(
|
|
|
1408
1425
|
"color",
|
|
1409
1426
|
{set = function(self, color)
|
|
1410
1427
|
setUnitColor(self.handle, color.handle)
|
|
1411
|
-
if self[
|
|
1428
|
+
if self[106] then
|
|
1412
1429
|
showUnitTeamGlow(self.handle, false)
|
|
1413
1430
|
end
|
|
1414
1431
|
end},
|
|
@@ -1432,14 +1449,14 @@ __TS__SetDescriptor(
|
|
|
1432
1449
|
"maxHealth",
|
|
1433
1450
|
{
|
|
1434
1451
|
get = function(self)
|
|
1435
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1452
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1436
1453
|
end,
|
|
1437
1454
|
set = function(self, maxHealth)
|
|
1438
|
-
if maxHealth < 1 and self[
|
|
1439
|
-
self[
|
|
1455
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1456
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1440
1457
|
maxHealth = 1
|
|
1441
1458
|
end
|
|
1442
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1459
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1443
1460
|
end
|
|
1444
1461
|
},
|
|
1445
1462
|
true
|
|
@@ -1481,10 +1498,10 @@ __TS__SetDescriptor(
|
|
|
1481
1498
|
"health",
|
|
1482
1499
|
{
|
|
1483
1500
|
get = function(self)
|
|
1484
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1501
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1485
1502
|
end,
|
|
1486
1503
|
set = function(self, health)
|
|
1487
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1504
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1488
1505
|
end
|
|
1489
1506
|
},
|
|
1490
1507
|
true
|
|
@@ -1695,17 +1712,17 @@ __TS__SetDescriptor(
|
|
|
1695
1712
|
set = function(self, isPaused)
|
|
1696
1713
|
local handle = self.handle
|
|
1697
1714
|
if isPaused and not IsUnitPaused(handle) then
|
|
1698
|
-
self[
|
|
1699
|
-
for _ = self[
|
|
1715
|
+
self[101] = true
|
|
1716
|
+
for _ = self[102] or 0, -1 do
|
|
1700
1717
|
BlzPauseUnitEx(handle, true)
|
|
1701
1718
|
end
|
|
1702
1719
|
PauseUnit(handle, true)
|
|
1703
1720
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1704
1721
|
PauseUnit(handle, false)
|
|
1705
|
-
for _ = self[
|
|
1722
|
+
for _ = self[102] or 0, -1 do
|
|
1706
1723
|
BlzPauseUnitEx(handle, false)
|
|
1707
1724
|
end
|
|
1708
|
-
self[
|
|
1725
|
+
self[101] = nil
|
|
1709
1726
|
end
|
|
1710
1727
|
end
|
|
1711
1728
|
},
|
|
@@ -2124,25 +2141,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2124
2141
|
InitializingEvent,
|
|
2125
2142
|
function(event)
|
|
2126
2143
|
local function listener(unit, id)
|
|
2127
|
-
local
|
|
2144
|
+
local ____GetSpellTargetUnit_result_9
|
|
2128
2145
|
if GetSpellTargetUnit() then
|
|
2129
|
-
|
|
2146
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2130
2147
|
else
|
|
2131
|
-
local
|
|
2148
|
+
local ____GetSpellTargetItem_result_8
|
|
2132
2149
|
if GetSpellTargetItem() then
|
|
2133
|
-
|
|
2150
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2134
2151
|
else
|
|
2135
|
-
local
|
|
2152
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2136
2153
|
if GetSpellTargetDestructable() then
|
|
2137
|
-
|
|
2154
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2138
2155
|
else
|
|
2139
|
-
|
|
2156
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2140
2157
|
end
|
|
2141
|
-
|
|
2158
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2142
2159
|
end
|
|
2143
|
-
|
|
2160
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2144
2161
|
end
|
|
2145
|
-
local target =
|
|
2162
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2146
2163
|
if target then
|
|
2147
2164
|
invoke(event, unit, id, target)
|
|
2148
2165
|
end
|
|
@@ -2452,6 +2469,7 @@ Unit.onDamage = __TS__New(
|
|
|
2452
2469
|
damageType = BlzGetEventDamageType(),
|
|
2453
2470
|
weaponType = BlzGetEventWeaponType(),
|
|
2454
2471
|
isAttack = BlzGetEventIsAttack(),
|
|
2472
|
+
originalAmount = GetEventDamage(),
|
|
2455
2473
|
preventDeath = damageEventPreventDeath
|
|
2456
2474
|
}
|
|
2457
2475
|
local evData = setmetatable(
|
|
@@ -2468,7 +2486,7 @@ Unit.onDamage = __TS__New(
|
|
|
2468
2486
|
invoke(event, source, target, evData)
|
|
2469
2487
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2470
2488
|
local bonusHealth = math.ceil(evData.amount)
|
|
2471
|
-
target[
|
|
2489
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2472
2490
|
BlzSetUnitMaxHP(
|
|
2473
2491
|
target.handle,
|
|
2474
2492
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2482,7 +2500,7 @@ Unit.onDamage = __TS__New(
|
|
|
2482
2500
|
evData[0],
|
|
2483
2501
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2484
2502
|
)
|
|
2485
|
-
target[
|
|
2503
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2486
2504
|
SetWidgetLife(
|
|
2487
2505
|
target.handle,
|
|
2488
2506
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2502,7 +2520,7 @@ Unit.onDamage = __TS__New(
|
|
|
2502
2520
|
DestroyTrigger(trigger)
|
|
2503
2521
|
end
|
|
2504
2522
|
)
|
|
2505
|
-
Unit.
|
|
2523
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2506
2524
|
____exports.UnitTriggerEvent,
|
|
2507
2525
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2508
2526
|
function()
|
|
@@ -2513,7 +2531,7 @@ Unit.onItemDrop = __TS__New(
|
|
|
2513
2531
|
return IgnoreEvent
|
|
2514
2532
|
end
|
|
2515
2533
|
)
|
|
2516
|
-
Unit.
|
|
2534
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2517
2535
|
____exports.UnitTriggerEvent,
|
|
2518
2536
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2519
2537
|
function()
|
|
@@ -2524,10 +2542,15 @@ Unit.onItemPickup = __TS__New(
|
|
|
2524
2542
|
return IgnoreEvent
|
|
2525
2543
|
end
|
|
2526
2544
|
)
|
|
2527
|
-
Unit.
|
|
2545
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2528
2546
|
____exports.UnitTriggerEvent,
|
|
2529
2547
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2530
|
-
function() return ____exports.Unit:of(
|
|
2548
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2549
|
+
)
|
|
2550
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2551
|
+
____exports.UnitTriggerEvent,
|
|
2552
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2553
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2531
2554
|
)
|
|
2532
2555
|
__TS__ObjectDefineProperty(
|
|
2533
2556
|
Unit,
|
|
@@ -2587,4 +2610,26 @@ __TS__ObjectDefineProperty(
|
|
|
2587
2610
|
end)
|
|
2588
2611
|
end
|
|
2589
2612
|
end)(Unit)
|
|
2613
|
+
mainSelectedUnitByPlayer = {}
|
|
2614
|
+
local syncSlider = BlzCreateFrameByType(
|
|
2615
|
+
"SLIDER",
|
|
2616
|
+
"UnitSyncId",
|
|
2617
|
+
BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
|
|
2618
|
+
"",
|
|
2619
|
+
0
|
|
2620
|
+
)
|
|
2621
|
+
BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
|
|
2622
|
+
LocalClient.mainSelectedUnitChangeEvent:addListener(function()
|
|
2623
|
+
local ____opt_10 = LocalClient.mainSelectedUnit
|
|
2624
|
+
local syncId = ____opt_10 and ____opt_10[100]
|
|
2625
|
+
BlzFrameSetValue(syncSlider, syncId or 0)
|
|
2626
|
+
end)
|
|
2627
|
+
local trg = CreateTrigger()
|
|
2628
|
+
BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
|
|
2629
|
+
TriggerAddAction(
|
|
2630
|
+
trg,
|
|
2631
|
+
function()
|
|
2632
|
+
mainSelectedUnitByPlayer[Player:of(GetTriggerPlayer())] = unitBySyncId[BlzGetTriggerFrameValue()]
|
|
2633
|
+
end
|
|
2634
|
+
)
|
|
2590
2635
|
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,51 @@ __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
|
+
Event.invoke(mainSelectedUnitChangeEvent, previousMainSelectedUnit, mainSelectedUnit)
|
|
135
|
+
previousMainSelectedUnit = mainSelectedUnit
|
|
136
|
+
end
|
|
137
|
+
return mainSelectedUnit
|
|
138
|
+
end}
|
|
139
|
+
)
|
|
140
|
+
__TS__ObjectDefineProperty(
|
|
141
|
+
LocalClient,
|
|
142
|
+
"mainSelectedUnitChangeEvent",
|
|
143
|
+
{get = function(self)
|
|
144
|
+
if mainSelectedUnitChangeEvent == nil then
|
|
145
|
+
mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
146
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
147
|
+
local _ = ____exports.LocalClient.mainSelectedUnit
|
|
148
|
+
end)
|
|
149
|
+
end
|
|
150
|
+
return mainSelectedUnitChangeEvent
|
|
151
|
+
end}
|
|
152
|
+
)
|
|
72
153
|
LocalClient.onDisconnect = __TS__New(
|
|
73
154
|
TriggerEvent,
|
|
74
155
|
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
|
}
|