warscript 0.0.1-dev.987b772 → 0.0.1-dev.9b0216a
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 +13 -3
- package/core/types/effect.lua +116 -17
- package/core/types/frame.d.ts +3 -0
- package/core/types/frame.lua +59 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +6 -0
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +29 -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 +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.d.ts +9 -2
- package/engine/behaviour/ability.lua +47 -33
- package/engine/buff.d.ts +6 -1
- package/engine/buff.lua +29 -18
- package/engine/internal/ability.d.ts +15 -2
- package/engine/internal/ability.lua +83 -4
- package/engine/internal/item/ability.lua +81 -0
- 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/item.d.ts +1 -0
- package/engine/internal/unit/item.lua +5 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +51 -0
- package/engine/internal/unit.d.ts +19 -6
- package/engine/internal/unit.lua +107 -64
- package/engine/internal/utility.lua +12 -0
- package/engine/local-client.lua +9 -8
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/entry/ability-type.lua +8 -12
- package/engine/object-data/entry/item-type.d.ts +2 -0
- package/engine/object-data/entry/item-type.lua +13 -0
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +4 -1
- package/engine/standard/fields/ability.d.ts +2 -0
- package/engine/standard/fields/ability.lua +2 -0
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +1 -1
- 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
|
@@ -15,8 +15,15 @@ local UnitTriggerEvent = ____unit.UnitTriggerEvent
|
|
|
15
15
|
local ____event = require("event")
|
|
16
16
|
local createDispatchingEvent = ____event.createDispatchingEvent
|
|
17
17
|
local DependentInitializingEvent = ____event.DependentInitializingEvent
|
|
18
|
+
local Event = ____event.Event
|
|
19
|
+
local InitializingEvent = ____event.InitializingEvent
|
|
18
20
|
local ____preconditions = require("utility.preconditions")
|
|
19
21
|
local checkNotNull = ____preconditions.checkNotNull
|
|
22
|
+
local ____lazy = require("utility.lazy")
|
|
23
|
+
local lazyRecord = ____lazy.lazyRecord
|
|
24
|
+
local eventInvoke = Event.invoke
|
|
25
|
+
local condition = Condition
|
|
26
|
+
local createTrigger = CreateTrigger
|
|
20
27
|
local getItemAbility = BlzGetItemAbility
|
|
21
28
|
local getSpellAbility = GetSpellAbility
|
|
22
29
|
local getSpellAbilityId = GetSpellAbilityId
|
|
@@ -26,11 +33,10 @@ local getSpellTargetUnit = GetSpellTargetUnit
|
|
|
26
33
|
local getSpellTargetX = GetSpellTargetX
|
|
27
34
|
local getSpellTargetY = GetSpellTargetY
|
|
28
35
|
local getTriggerUnit = GetTriggerUnit
|
|
29
|
-
local
|
|
30
|
-
local
|
|
36
|
+
local triggerAddCondition = TriggerAddCondition
|
|
37
|
+
local triggerRegisterCommandEvent = TriggerRegisterCommandEvent
|
|
31
38
|
local unitInventorySize = UnitInventorySize
|
|
32
39
|
local unitItemInSlot = UnitItemInSlot
|
|
33
|
-
local unitRemoveAbility = UnitRemoveAbility
|
|
34
40
|
local function retrieveAbility(unit, ability, abilityId)
|
|
35
41
|
if ability == nil then
|
|
36
42
|
return __TS__New(
|
|
@@ -39,17 +45,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
39
45
|
Unit:of(unit)
|
|
40
46
|
)
|
|
41
47
|
end
|
|
42
|
-
if not unitAddAbility(unit, abilityId) then
|
|
43
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
44
|
-
return UnitAbility:of(
|
|
45
|
-
ability,
|
|
46
|
-
abilityId,
|
|
47
|
-
Unit:of(unit)
|
|
48
|
-
)
|
|
49
|
-
end
|
|
50
|
-
else
|
|
51
|
-
unitRemoveAbility(unit, abilityId)
|
|
52
|
-
end
|
|
53
48
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
54
49
|
local item = unitItemInSlot(unit, i)
|
|
55
50
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -366,4 +361,31 @@ rawset(
|
|
|
366
361
|
extractAbilityTypeId
|
|
367
362
|
)
|
|
368
363
|
)
|
|
364
|
+
rawset(
|
|
365
|
+
Unit,
|
|
366
|
+
"abilityCommandEvent",
|
|
367
|
+
lazyRecord(function(abilityTypeId)
|
|
368
|
+
return lazyRecord(function(orderTypeStringId)
|
|
369
|
+
return __TS__New(
|
|
370
|
+
InitializingEvent,
|
|
371
|
+
function(event)
|
|
372
|
+
local trigger = createTrigger()
|
|
373
|
+
triggerRegisterCommandEvent(trigger, abilityTypeId, orderTypeStringId)
|
|
374
|
+
triggerAddCondition(
|
|
375
|
+
trigger,
|
|
376
|
+
condition(function()
|
|
377
|
+
local unit = Unit:of(getTriggerUnit())
|
|
378
|
+
if unit ~= nil then
|
|
379
|
+
local ability = unit:getAbilityById(abilityTypeId)
|
|
380
|
+
if ability ~= nil then
|
|
381
|
+
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
end)
|
|
385
|
+
)
|
|
386
|
+
end
|
|
387
|
+
)
|
|
388
|
+
end)
|
|
389
|
+
end)
|
|
390
|
+
)
|
|
369
391
|
return ____exports
|
|
@@ -11,6 +11,7 @@ export interface UnitItems extends ReadonlyArray<Item | undefined> {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class UnitItems {
|
|
13
13
|
constructor(handle: junit);
|
|
14
|
+
findSlot(item: Item): 0 | 1 | 2 | 3 | 4 | 5 | undefined;
|
|
14
15
|
protected __newindex(slot: number, item: Item | undefined): void;
|
|
15
16
|
protected __index(key: string | number): unknown;
|
|
16
17
|
protected __len(): number;
|
|
@@ -7,6 +7,8 @@ local ____item = require("engine.internal.item")
|
|
|
7
7
|
local Item = ____item.Item
|
|
8
8
|
local ____unit = require("engine.internal.unit")
|
|
9
9
|
local Unit = ____unit.Unit
|
|
10
|
+
local ____utility = require("engine.internal.utility")
|
|
11
|
+
local findUnitItemSlot = ____utility.findUnitItemSlot
|
|
10
12
|
local rawset = _G.rawset
|
|
11
13
|
local ____type = _G.type
|
|
12
14
|
local isItemPowerup = IsItemPowerup
|
|
@@ -30,6 +32,9 @@ UnitItems.name = "UnitItems"
|
|
|
30
32
|
function UnitItems.prototype.____constructor(self, handle)
|
|
31
33
|
handleByUnitItems[self] = handle
|
|
32
34
|
end
|
|
35
|
+
function UnitItems.prototype.findSlot(self, item)
|
|
36
|
+
return findUnitItemSlot(handleByUnitItems[self], item.handle)
|
|
37
|
+
end
|
|
33
38
|
function UnitItems.prototype.__newindex(self, slot, item)
|
|
34
39
|
local handle = handleByUnitItems[self]
|
|
35
40
|
if slot < 1 or slot > unitInventorySize(handle) then
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Player } from "../../../core/types/player";
|
|
3
|
+
import { Event } from "../../../event";
|
|
4
|
+
declare module "../unit" {
|
|
5
|
+
namespace Unit {
|
|
6
|
+
const mainSelectedUnitChangeEvent: Event<[Player]>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare module "../unit" {
|
|
10
|
+
namespace Unit {
|
|
11
|
+
const getMainSelectedOf: (player: Player) => Unit | undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____player = require("core.types.player")
|
|
5
|
+
local Player = ____player.Player
|
|
6
|
+
local ____math = require("math")
|
|
7
|
+
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
8
|
+
local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
|
|
9
|
+
local ____local_2Dclient = require("engine.local-client")
|
|
10
|
+
local LocalClient = ____local_2Dclient.LocalClient
|
|
11
|
+
local ____unit = require("engine.internal.unit")
|
|
12
|
+
local Unit = ____unit.Unit
|
|
13
|
+
local ____event = require("event")
|
|
14
|
+
local Event = ____event.Event
|
|
15
|
+
local mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
16
|
+
rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
|
|
17
|
+
local mainSelectedUnitByPlayer = {}
|
|
18
|
+
local syncSlider = BlzCreateFrameByType(
|
|
19
|
+
"SLIDER",
|
|
20
|
+
"UnitSyncId",
|
|
21
|
+
BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
|
|
22
|
+
"",
|
|
23
|
+
0
|
|
24
|
+
)
|
|
25
|
+
BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
|
|
26
|
+
LocalClient.mainSelectedUnitChangeEvent:addListener(function()
|
|
27
|
+
local ____opt_0 = LocalClient.mainSelectedUnit
|
|
28
|
+
local syncId = ____opt_0 and ____opt_0.syncId
|
|
29
|
+
BlzFrameSetValue(syncSlider, syncId or 0)
|
|
30
|
+
end)
|
|
31
|
+
local trg = CreateTrigger()
|
|
32
|
+
BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
|
|
33
|
+
TriggerAddAction(
|
|
34
|
+
trg,
|
|
35
|
+
function()
|
|
36
|
+
local player = Player:of(GetTriggerPlayer())
|
|
37
|
+
local mainSelectedUnit = Unit:getBySyncId(BlzGetTriggerFrameValue())
|
|
38
|
+
if mainSelectedUnit ~= mainSelectedUnitByPlayer[player] then
|
|
39
|
+
mainSelectedUnitByPlayer[player] = mainSelectedUnit
|
|
40
|
+
Event.invoke(mainSelectedUnitChangeEvent, player)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
)
|
|
44
|
+
rawset(
|
|
45
|
+
Unit,
|
|
46
|
+
"getMainSelectedOf",
|
|
47
|
+
function(player)
|
|
48
|
+
return mainSelectedUnitByPlayer[player]
|
|
49
|
+
end
|
|
50
|
+
)
|
|
51
|
+
return ____exports
|
|
@@ -94,14 +94,19 @@ export declare class UnitWeapon {
|
|
|
94
94
|
set missileSpeed(missileSpeed: number);
|
|
95
95
|
}
|
|
96
96
|
declare const enum UnitPropertyKey {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
|
103
104
|
}
|
|
105
|
+
export type UnitSyncId = number & {
|
|
106
|
+
readonly __unitSyncId: unique symbol;
|
|
107
|
+
};
|
|
104
108
|
export declare class Unit extends Handle<junit> {
|
|
109
|
+
readonly syncId: UnitSyncId;
|
|
105
110
|
private [UnitPropertyKey.IS_PAUSED]?;
|
|
106
111
|
private [UnitPropertyKey.STUN_COUNTER]?;
|
|
107
112
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
|
|
@@ -327,6 +332,13 @@ export declare class Unit extends Handle<junit> {
|
|
|
327
332
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
328
333
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
329
334
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
335
|
+
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
336
|
+
static get itemMoveOrderEvent(): Event<[
|
|
337
|
+
unit: Unit,
|
|
338
|
+
item: Item,
|
|
339
|
+
slotFrom: 0 | 1 | 2 | 3 | 4 | 5,
|
|
340
|
+
slotTo: 0 | 1 | 2 | 3 | 4 | 5
|
|
341
|
+
]>;
|
|
330
342
|
static get onCreate(): EventDispatcher<[Unit], [Unit]>;
|
|
331
343
|
static get destroyEvent(): EventDispatcher<[Unit], [Unit]>;
|
|
332
344
|
getField(field: junitintegerfield | junitrealfield): number;
|
|
@@ -337,5 +349,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
337
349
|
setField(field: junitbooleanfield, value: boolean): boolean;
|
|
338
350
|
setField(field: junitstringfield, value: string): boolean;
|
|
339
351
|
toString(): string;
|
|
352
|
+
static getBySyncId(syncId: UnitSyncId): Unit | undefined;
|
|
340
353
|
}
|
|
341
354
|
export {};
|
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
|
|
@@ -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(
|
|
@@ -1134,6 +1129,9 @@ end
|
|
|
1134
1129
|
function Unit.prototype.__tostring(self)
|
|
1135
1130
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1136
1131
|
end
|
|
1132
|
+
function Unit.getBySyncId(self, syncId)
|
|
1133
|
+
return unitBySyncId[syncId]
|
|
1134
|
+
end
|
|
1137
1135
|
__TS__SetDescriptor(
|
|
1138
1136
|
Unit.prototype,
|
|
1139
1137
|
"_deltas",
|
|
@@ -1391,17 +1389,17 @@ __TS__SetDescriptor(
|
|
|
1391
1389
|
"isTeamGlowVisible",
|
|
1392
1390
|
{
|
|
1393
1391
|
get = function(self)
|
|
1394
|
-
return not self[
|
|
1392
|
+
return not self[106]
|
|
1395
1393
|
end,
|
|
1396
1394
|
set = function(self, isTeamGlowVisible)
|
|
1397
1395
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1398
|
-
local
|
|
1396
|
+
local ____temp_6
|
|
1399
1397
|
if not isTeamGlowVisible then
|
|
1400
|
-
|
|
1398
|
+
____temp_6 = true
|
|
1401
1399
|
else
|
|
1402
|
-
|
|
1400
|
+
____temp_6 = nil
|
|
1403
1401
|
end
|
|
1404
|
-
self[
|
|
1402
|
+
self[106] = ____temp_6
|
|
1405
1403
|
end
|
|
1406
1404
|
},
|
|
1407
1405
|
true
|
|
@@ -1411,7 +1409,7 @@ __TS__SetDescriptor(
|
|
|
1411
1409
|
"color",
|
|
1412
1410
|
{set = function(self, color)
|
|
1413
1411
|
setUnitColor(self.handle, color.handle)
|
|
1414
|
-
if self[
|
|
1412
|
+
if self[106] then
|
|
1415
1413
|
showUnitTeamGlow(self.handle, false)
|
|
1416
1414
|
end
|
|
1417
1415
|
end},
|
|
@@ -1435,14 +1433,14 @@ __TS__SetDescriptor(
|
|
|
1435
1433
|
"maxHealth",
|
|
1436
1434
|
{
|
|
1437
1435
|
get = function(self)
|
|
1438
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1436
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1439
1437
|
end,
|
|
1440
1438
|
set = function(self, maxHealth)
|
|
1441
|
-
if maxHealth < 1 and self[
|
|
1442
|
-
self[
|
|
1439
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1440
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1443
1441
|
maxHealth = 1
|
|
1444
1442
|
end
|
|
1445
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1443
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1446
1444
|
end
|
|
1447
1445
|
},
|
|
1448
1446
|
true
|
|
@@ -1484,10 +1482,10 @@ __TS__SetDescriptor(
|
|
|
1484
1482
|
"health",
|
|
1485
1483
|
{
|
|
1486
1484
|
get = function(self)
|
|
1487
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1485
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1488
1486
|
end,
|
|
1489
1487
|
set = function(self, health)
|
|
1490
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1488
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1491
1489
|
end
|
|
1492
1490
|
},
|
|
1493
1491
|
true
|
|
@@ -1698,17 +1696,17 @@ __TS__SetDescriptor(
|
|
|
1698
1696
|
set = function(self, isPaused)
|
|
1699
1697
|
local handle = self.handle
|
|
1700
1698
|
if isPaused and not IsUnitPaused(handle) then
|
|
1701
|
-
self[
|
|
1702
|
-
for _ = self[
|
|
1699
|
+
self[101] = true
|
|
1700
|
+
for _ = self[102] or 0, -1 do
|
|
1703
1701
|
BlzPauseUnitEx(handle, true)
|
|
1704
1702
|
end
|
|
1705
1703
|
PauseUnit(handle, true)
|
|
1706
1704
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1707
1705
|
PauseUnit(handle, false)
|
|
1708
|
-
for _ = self[
|
|
1706
|
+
for _ = self[102] or 0, -1 do
|
|
1709
1707
|
BlzPauseUnitEx(handle, false)
|
|
1710
1708
|
end
|
|
1711
|
-
self[
|
|
1709
|
+
self[101] = nil
|
|
1712
1710
|
end
|
|
1713
1711
|
end
|
|
1714
1712
|
},
|
|
@@ -2127,25 +2125,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2127
2125
|
InitializingEvent,
|
|
2128
2126
|
function(event)
|
|
2129
2127
|
local function listener(unit, id)
|
|
2130
|
-
local
|
|
2128
|
+
local ____GetSpellTargetUnit_result_9
|
|
2131
2129
|
if GetSpellTargetUnit() then
|
|
2132
|
-
|
|
2130
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2133
2131
|
else
|
|
2134
|
-
local
|
|
2132
|
+
local ____GetSpellTargetItem_result_8
|
|
2135
2133
|
if GetSpellTargetItem() then
|
|
2136
|
-
|
|
2134
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2137
2135
|
else
|
|
2138
|
-
local
|
|
2136
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2139
2137
|
if GetSpellTargetDestructable() then
|
|
2140
|
-
|
|
2138
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2141
2139
|
else
|
|
2142
|
-
|
|
2140
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2143
2141
|
end
|
|
2144
|
-
|
|
2142
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2145
2143
|
end
|
|
2146
|
-
|
|
2144
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2147
2145
|
end
|
|
2148
|
-
local target =
|
|
2146
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2149
2147
|
if target then
|
|
2150
2148
|
invoke(event, unit, id, target)
|
|
2151
2149
|
end
|
|
@@ -2472,7 +2470,7 @@ Unit.onDamage = __TS__New(
|
|
|
2472
2470
|
invoke(event, source, target, evData)
|
|
2473
2471
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2474
2472
|
local bonusHealth = math.ceil(evData.amount)
|
|
2475
|
-
target[
|
|
2473
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2476
2474
|
BlzSetUnitMaxHP(
|
|
2477
2475
|
target.handle,
|
|
2478
2476
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2486,7 +2484,7 @@ Unit.onDamage = __TS__New(
|
|
|
2486
2484
|
evData[0],
|
|
2487
2485
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2488
2486
|
)
|
|
2489
|
-
target[
|
|
2487
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2490
2488
|
SetWidgetLife(
|
|
2491
2489
|
target.handle,
|
|
2492
2490
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2538,6 +2536,51 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2538
2536
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2539
2537
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2540
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}
|
|
2583
|
+
)
|
|
2541
2584
|
__TS__ObjectDefineProperty(
|
|
2542
2585
|
Unit,
|
|
2543
2586
|
"onCreate",
|
|
@@ -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.lua
CHANGED
|
@@ -34,13 +34,11 @@ compiletime(function()
|
|
|
34
34
|
currentMap:addFileString("_HD.w3mod\\" .. tocPath, fdfPath .. "\r\n")
|
|
35
35
|
end
|
|
36
36
|
end)
|
|
37
|
-
local selectionContainer
|
|
38
37
|
local selectionButtons
|
|
39
38
|
Timer:run(function()
|
|
40
|
-
selectionContainer = Frame:byName("SimpleInfoPanelUnitDetail").parent:getChild(5):getChild(0)
|
|
41
39
|
selectionButtons = __TS__ArrayMap(
|
|
42
|
-
|
|
43
|
-
function(____, frame) return frame:getChild(
|
|
40
|
+
Frame:byName("SimpleInfoPanelUnitDetail").parent:getChild(5):getChild(0).children,
|
|
41
|
+
function(____, frame) return frame:getChild(1) end
|
|
44
42
|
)
|
|
45
43
|
end)
|
|
46
44
|
local localSelectedUnits = {}
|
|
@@ -117,11 +115,13 @@ __TS__ObjectDefineProperty(
|
|
|
117
115
|
end
|
|
118
116
|
tableSort(localSelectedUnits, compareUnitsSelectionPriority)
|
|
119
117
|
local mainSelectedUnitIndex
|
|
120
|
-
if
|
|
118
|
+
if selectionButtons and #localSelectedUnits > 1 then
|
|
119
|
+
local maxButtonWidth = 0
|
|
121
120
|
for i = 0, #selectionButtons - 1 do
|
|
122
|
-
|
|
121
|
+
local width = selectionButtons[i + 1].width
|
|
122
|
+
if width > maxButtonWidth then
|
|
123
|
+
maxButtonWidth = width
|
|
123
124
|
mainSelectedUnitIndex = i
|
|
124
|
-
break
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
end
|
|
@@ -131,8 +131,9 @@ __TS__ObjectDefineProperty(
|
|
|
131
131
|
localSelectedUnits[i] = nil
|
|
132
132
|
end
|
|
133
133
|
if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
|
|
134
|
-
|
|
134
|
+
local previousPreviousMainSelectedUnit = previousMainSelectedUnit
|
|
135
135
|
previousMainSelectedUnit = mainSelectedUnit
|
|
136
|
+
Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
|
|
136
137
|
end
|
|
137
138
|
return mainSelectedUnit
|
|
138
139
|
end}
|
|
@@ -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
|
}
|