warscript 0.0.1-dev.9f30788 → 0.0.1-dev.a0cb707
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/attributes.d.ts +1 -0
- package/attributes.lua +9 -0
- package/core/types/player.d.ts +15 -0
- package/core/types/player.lua +53 -13
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/internal/unit/ability.lua +3 -3
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit-missile-launch.lua +31 -40
- package/engine/internal/unit.d.ts +2 -0
- package/engine/internal/unit.lua +20 -10
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/net/socket.lua +1 -1
- package/package.json +1 -1
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
package/attributes.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export declare namespace Attribute {
|
|
|
13
13
|
export declare class AttributesHolder {
|
|
14
14
|
readonly get: (<T>(attribute: Attribute<T>) => T | undefined) & LuaExtension<"TableGetMethod">;
|
|
15
15
|
readonly set: (<T>(attribute: Attribute<T>, value: T | undefined) => void) & LuaExtension<"TableSetMethod">;
|
|
16
|
+
getOrPut<T>(attribute: Attribute<T>, defaultValue: () => T): T;
|
|
16
17
|
}
|
|
17
18
|
export {};
|
package/attributes.lua
CHANGED
|
@@ -20,4 +20,13 @@ local AttributesHolder = ____exports.AttributesHolder
|
|
|
20
20
|
AttributesHolder.name = "AttributesHolder"
|
|
21
21
|
function AttributesHolder.prototype.____constructor(self)
|
|
22
22
|
end
|
|
23
|
+
function AttributesHolder.prototype.getOrPut(self, attribute, defaultValue)
|
|
24
|
+
local value = self[attribute]
|
|
25
|
+
if value ~= nil then
|
|
26
|
+
return value
|
|
27
|
+
end
|
|
28
|
+
value = defaultValue()
|
|
29
|
+
self[attribute] = value
|
|
30
|
+
return value
|
|
31
|
+
end
|
|
23
32
|
return ____exports
|
package/core/types/player.d.ts
CHANGED
|
@@ -7,6 +7,18 @@ import { UpgradeId } from "../../engine/object-data/entry/upgrade";
|
|
|
7
7
|
interface Unit {
|
|
8
8
|
handle: junit;
|
|
9
9
|
}
|
|
10
|
+
export declare const enum PlayerAllianceType {
|
|
11
|
+
PASSIVE = 0,
|
|
12
|
+
RESCUABLE = 1,
|
|
13
|
+
HELP_REQUEST = 2,
|
|
14
|
+
HELP_RESPONSE = 3,
|
|
15
|
+
SHARED_XP = 4,
|
|
16
|
+
SHARED_SPELLS = 5,
|
|
17
|
+
SHARED_VISION = 6,
|
|
18
|
+
SHARED_VISION_FORCED = 7,
|
|
19
|
+
SHARED_CONTROL = 8,
|
|
20
|
+
SHARED_ADVANCED_CONTROL = 9
|
|
21
|
+
}
|
|
10
22
|
export declare class Player extends Handle<jplayer> {
|
|
11
23
|
static readonly all: Player[];
|
|
12
24
|
static readonly local: Player;
|
|
@@ -42,6 +54,8 @@ export declare class Player extends Handle<jplayer> {
|
|
|
42
54
|
forceUICancel(): void;
|
|
43
55
|
isAllyOf(other: Player): boolean;
|
|
44
56
|
isEnemyOf(other: Player): boolean;
|
|
57
|
+
setAlliance(other: Player, type: PlayerAllianceType, value: boolean): void;
|
|
58
|
+
getAlliance(other: Player, type: PlayerAllianceType): boolean;
|
|
45
59
|
setAbilityAvailable(abilityId: number, available: boolean): void;
|
|
46
60
|
getMaximumUpgradeLevel(upgradeId: UpgradeId): number;
|
|
47
61
|
setMaximumUpgradeLevel(upgradeId: UpgradeId, maximumLevel: number): void;
|
|
@@ -50,6 +64,7 @@ export declare class Player extends Handle<jplayer> {
|
|
|
50
64
|
setUpgradeLevel(upgradeId: UpgradeId, level: number): void;
|
|
51
65
|
private static getEvent;
|
|
52
66
|
private static getMouseEvent;
|
|
67
|
+
static get allianceChangedEvent(): Readonly<Record<PlayerAllianceType, Event<[Player]>>>;
|
|
53
68
|
static get onLeave(): Event<[Player]>;
|
|
54
69
|
static get onMouseDown(): Event<[Player, jmousebuttontype]>;
|
|
55
70
|
static get onMouseUp(): Event<[Player, jmousebuttontype]>;
|
package/core/types/player.lua
CHANGED
|
@@ -23,14 +23,32 @@ local ____math = require("math")
|
|
|
23
23
|
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
24
24
|
local ____player_2Dlocal_2Dhandle = require("engine.internal.misc.player-local-handle")
|
|
25
25
|
local PLAYER_LOCAL_HANDLE = ____player_2Dlocal_2Dhandle.PLAYER_LOCAL_HANDLE
|
|
26
|
+
local ____lazy = require("utility.lazy")
|
|
27
|
+
local lazyRecord = ____lazy.lazyRecord
|
|
28
|
+
local getPlayerAlliance = GetPlayerAlliance
|
|
26
29
|
local getPlayerColor = GetPlayerColor
|
|
27
30
|
local getPlayerName = GetPlayerName
|
|
28
31
|
local getPlayerTechCount = GetPlayerTechCount
|
|
29
32
|
local getPlayerTechMaxAllowed = GetPlayerTechMaxAllowed
|
|
33
|
+
local getTriggerPlayer = GetTriggerPlayer
|
|
34
|
+
local setPlayerAlliance = SetPlayerAlliance
|
|
30
35
|
local setPlayerTechMaxAllowed = SetPlayerTechMaxAllowed
|
|
31
36
|
local setPlayerTechResearched = SetPlayerTechResearched
|
|
32
37
|
local setPlayerAbilityAvailable = SetPlayerAbilityAvailable
|
|
38
|
+
local triggerRegisterPlayerAllianceChange = TriggerRegisterPlayerAllianceChange
|
|
33
39
|
local playerNative = _G.Player
|
|
40
|
+
local nativeByPlayerAllianceType = {
|
|
41
|
+
[0] = ALLIANCE_PASSIVE,
|
|
42
|
+
[1] = ALLIANCE_RESCUABLE,
|
|
43
|
+
[2] = ALLIANCE_HELP_REQUEST,
|
|
44
|
+
[3] = ALLIANCE_HELP_RESPONSE,
|
|
45
|
+
[4] = ALLIANCE_SHARED_XP,
|
|
46
|
+
[5] = ALLIANCE_SHARED_SPELLS,
|
|
47
|
+
[6] = ALLIANCE_SHARED_VISION,
|
|
48
|
+
[7] = ALLIANCE_SHARED_VISION_FORCED,
|
|
49
|
+
[8] = ALLIANCE_SHARED_CONTROL,
|
|
50
|
+
[9] = ALLIANCE_SHARED_ADVANCED_CONTROL
|
|
51
|
+
}
|
|
34
52
|
____exports.Player = __TS__Class()
|
|
35
53
|
local Player = ____exports.Player
|
|
36
54
|
Player.name = "Player"
|
|
@@ -85,6 +103,12 @@ end
|
|
|
85
103
|
function Player.prototype.isEnemyOf(self, other)
|
|
86
104
|
return IsPlayerEnemy(self.handle, other.handle)
|
|
87
105
|
end
|
|
106
|
+
function Player.prototype.setAlliance(self, other, ____type, value)
|
|
107
|
+
setPlayerAlliance(self.handle, other.handle, nativeByPlayerAllianceType[____type], value)
|
|
108
|
+
end
|
|
109
|
+
function Player.prototype.getAlliance(self, other, ____type)
|
|
110
|
+
return getPlayerAlliance(self.handle, other.handle, nativeByPlayerAllianceType[____type])
|
|
111
|
+
end
|
|
88
112
|
function Player.prototype.setAbilityAvailable(self, abilityId, available)
|
|
89
113
|
setPlayerAbilityAvailable(self.handle, abilityId, available)
|
|
90
114
|
end
|
|
@@ -124,14 +148,11 @@ function Player.getMouseEvent(self, event, collector)
|
|
|
124
148
|
self.events[eventId] = __TS__New(
|
|
125
149
|
TriggerEvent,
|
|
126
150
|
function(trigger)
|
|
127
|
-
Timer:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
for ____, player in ipairs(____exports.Player.all) do
|
|
131
|
-
TriggerRegisterPlayerEvent(trigger, player.handle, event)
|
|
132
|
-
end
|
|
151
|
+
Timer:run(function()
|
|
152
|
+
for ____, player in ipairs(____exports.Player.all) do
|
|
153
|
+
TriggerRegisterPlayerEvent(trigger, player.handle, event)
|
|
133
154
|
end
|
|
134
|
-
)
|
|
155
|
+
end)
|
|
135
156
|
end,
|
|
136
157
|
collector or (function() return {} end)
|
|
137
158
|
)
|
|
@@ -180,7 +201,7 @@ function Player.getKeyEvent(self, isDown)
|
|
|
180
201
|
TriggerAddCondition(
|
|
181
202
|
trigger,
|
|
182
203
|
Condition(function()
|
|
183
|
-
local player = ____exports.Player:of(
|
|
204
|
+
local player = ____exports.Player:of(getTriggerPlayer())
|
|
184
205
|
local key = BlzGetTriggerPlayerKey()
|
|
185
206
|
local metaKey = BlzGetTriggerPlayerMetaKey()
|
|
186
207
|
Event.invoke(event, player, key, metaKey)
|
|
@@ -369,13 +390,32 @@ __TS__SetDescriptor(
|
|
|
369
390
|
end},
|
|
370
391
|
true
|
|
371
392
|
)
|
|
393
|
+
__TS__ObjectDefineProperty(
|
|
394
|
+
Player,
|
|
395
|
+
"allianceChangedEvent",
|
|
396
|
+
{get = function(self)
|
|
397
|
+
local event = lazyRecord(function(____type)
|
|
398
|
+
return __TS__New(
|
|
399
|
+
TriggerEvent,
|
|
400
|
+
function(trigger)
|
|
401
|
+
for ____, player in ipairs(____exports.Player.all) do
|
|
402
|
+
triggerRegisterPlayerAllianceChange(trigger, player.handle, nativeByPlayerAllianceType[____type])
|
|
403
|
+
end
|
|
404
|
+
end,
|
|
405
|
+
function() return ____exports.Player:of(getTriggerPlayer()) end
|
|
406
|
+
)
|
|
407
|
+
end)
|
|
408
|
+
rawset(self, "allianceChangedEvent", event)
|
|
409
|
+
return event
|
|
410
|
+
end}
|
|
411
|
+
)
|
|
372
412
|
__TS__ObjectDefineProperty(
|
|
373
413
|
Player,
|
|
374
414
|
"onLeave",
|
|
375
415
|
{get = function(self)
|
|
376
416
|
return ____exports.Player:getEvent(
|
|
377
417
|
EVENT_PLAYER_LEAVE,
|
|
378
|
-
function() return ____exports.Player:of(
|
|
418
|
+
function() return ____exports.Player:of(getTriggerPlayer()) end
|
|
379
419
|
)
|
|
380
420
|
end}
|
|
381
421
|
)
|
|
@@ -385,7 +425,7 @@ __TS__ObjectDefineProperty(
|
|
|
385
425
|
{get = function(self)
|
|
386
426
|
return ____exports.Player:getMouseEvent(
|
|
387
427
|
EVENT_PLAYER_MOUSE_DOWN,
|
|
388
|
-
function() return ____exports.Player:of(
|
|
428
|
+
function() return ____exports.Player:of(getTriggerPlayer()), BlzGetTriggerPlayerMouseButton() end
|
|
389
429
|
)
|
|
390
430
|
end}
|
|
391
431
|
)
|
|
@@ -395,7 +435,7 @@ __TS__ObjectDefineProperty(
|
|
|
395
435
|
{get = function(self)
|
|
396
436
|
return ____exports.Player:getMouseEvent(
|
|
397
437
|
EVENT_PLAYER_MOUSE_UP,
|
|
398
|
-
function() return ____exports.Player:of(
|
|
438
|
+
function() return ____exports.Player:of(getTriggerPlayer()), BlzGetTriggerPlayerMouseButton() end
|
|
399
439
|
)
|
|
400
440
|
end}
|
|
401
441
|
)
|
|
@@ -405,7 +445,7 @@ __TS__ObjectDefineProperty(
|
|
|
405
445
|
{get = function(self)
|
|
406
446
|
return ____exports.Player:getMouseEvent(
|
|
407
447
|
EVENT_PLAYER_MOUSE_MOVE,
|
|
408
|
-
function() return ____exports.Player:of(
|
|
448
|
+
function() return ____exports.Player:of(getTriggerPlayer()), vec2(
|
|
409
449
|
BlzGetTriggerPlayerMouseX(),
|
|
410
450
|
BlzGetTriggerPlayerMouseY()
|
|
411
451
|
) end
|
|
@@ -441,7 +481,7 @@ __TS__ObjectDefineProperty(
|
|
|
441
481
|
TriggerRegisterPlayerChatEvent(trigger, player.handle, "", false)
|
|
442
482
|
end
|
|
443
483
|
end,
|
|
444
|
-
function() return ____exports.Player:of(
|
|
484
|
+
function() return ____exports.Player:of(getTriggerPlayer()), GetEventPlayerChatString() end
|
|
445
485
|
)
|
|
446
486
|
rawset(self, "onChat", event)
|
|
447
487
|
return event
|
|
@@ -14,3 +14,12 @@ export declare class RemoveBuffsSelfAbilityBehavior extends AbilityBehavior {
|
|
|
14
14
|
constructor(ability: Ability, polarity?: AbilityDependentValue<BuffPolarity> | undefined, resistanceType?: AbilityDependentValue<BuffResistanceType> | undefined, includeExpirationTimers?: AbilityDependentValue<boolean> | undefined, includeAuras?: AbilityDependentValue<boolean> | undefined, autoDispel?: AbilityDependentValue<boolean> | undefined);
|
|
15
15
|
onImpact(caster: Unit): void;
|
|
16
16
|
}
|
|
17
|
+
export declare class RemoveBuffsTargetAbilityBehavior extends AbilityBehavior {
|
|
18
|
+
private readonly polarity?;
|
|
19
|
+
private readonly resistanceType?;
|
|
20
|
+
private readonly includeExpirationTimers?;
|
|
21
|
+
private readonly includeAuras?;
|
|
22
|
+
private readonly autoDispel?;
|
|
23
|
+
constructor(ability: Ability, polarity?: AbilityDependentValue<BuffPolarity> | undefined, resistanceType?: AbilityDependentValue<BuffResistanceType> | undefined, includeExpirationTimers?: AbilityDependentValue<boolean> | undefined, includeAuras?: AbilityDependentValue<boolean> | undefined, autoDispel?: AbilityDependentValue<boolean> | undefined);
|
|
24
|
+
onUnitTargetImpact(_: Unit, target: Unit): void;
|
|
25
|
+
}
|
|
@@ -25,4 +25,25 @@ function RemoveBuffsSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
|
25
25
|
self:resolveCurrentAbilityDependentValue(self.autoDispel)
|
|
26
26
|
)
|
|
27
27
|
end
|
|
28
|
+
____exports.RemoveBuffsTargetAbilityBehavior = __TS__Class()
|
|
29
|
+
local RemoveBuffsTargetAbilityBehavior = ____exports.RemoveBuffsTargetAbilityBehavior
|
|
30
|
+
RemoveBuffsTargetAbilityBehavior.name = "RemoveBuffsTargetAbilityBehavior"
|
|
31
|
+
__TS__ClassExtends(RemoveBuffsTargetAbilityBehavior, AbilityBehavior)
|
|
32
|
+
function RemoveBuffsTargetAbilityBehavior.prototype.____constructor(self, ability, polarity, resistanceType, includeExpirationTimers, includeAuras, autoDispel)
|
|
33
|
+
AbilityBehavior.prototype.____constructor(self, ability)
|
|
34
|
+
self.polarity = polarity
|
|
35
|
+
self.resistanceType = resistanceType
|
|
36
|
+
self.includeExpirationTimers = includeExpirationTimers
|
|
37
|
+
self.includeAuras = includeAuras
|
|
38
|
+
self.autoDispel = autoDispel
|
|
39
|
+
end
|
|
40
|
+
function RemoveBuffsTargetAbilityBehavior.prototype.onUnitTargetImpact(self, _, target)
|
|
41
|
+
target:removeBuffs(
|
|
42
|
+
self:resolveCurrentAbilityDependentValue(self.polarity),
|
|
43
|
+
self:resolveCurrentAbilityDependentValue(self.resistanceType),
|
|
44
|
+
self:resolveCurrentAbilityDependentValue(self.includeExpirationTimers),
|
|
45
|
+
self:resolveCurrentAbilityDependentValue(self.includeAuras),
|
|
46
|
+
self:resolveCurrentAbilityDependentValue(self.autoDispel)
|
|
47
|
+
)
|
|
48
|
+
end
|
|
28
49
|
return ____exports
|
|
@@ -398,7 +398,7 @@ local function invokeImpactEvent(unit, ability, ...)
|
|
|
398
398
|
eventInvoke(internalAbilityImpactEvent, unit, ability, ...)
|
|
399
399
|
end
|
|
400
400
|
internalAbilityChannelingStartEvent:addListener(
|
|
401
|
-
|
|
401
|
+
999999,
|
|
402
402
|
function(unit, ability, ...)
|
|
403
403
|
ability[impactCallbackIdAttribute] = Timer:run(invokeImpactEvent, unit, ability, ...)
|
|
404
404
|
end
|
|
@@ -409,8 +409,8 @@ local function consumeImpactCallback(_, ability)
|
|
|
409
409
|
consumeZeroTimerCallback(impactCallbackId)
|
|
410
410
|
end
|
|
411
411
|
end
|
|
412
|
-
internalAbilityChannelingFinishEvent:addListener(
|
|
413
|
-
internalAbilityStopEvent:addListener(
|
|
412
|
+
internalAbilityChannelingFinishEvent:addListener(999999, consumeImpactCallback)
|
|
413
|
+
internalAbilityStopEvent:addListener(999999, consumeImpactCallback)
|
|
414
414
|
rawset(
|
|
415
415
|
Unit,
|
|
416
416
|
"abilityImpactEvent",
|
|
@@ -1,46 +1,31 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__New = ____lualib.__TS__New
|
|
3
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
4
|
local ____local_2Dclient = require("engine.local-client")
|
|
10
5
|
local LocalClient = ____local_2Dclient.LocalClient
|
|
11
6
|
local ____unit = require("engine.internal.unit")
|
|
12
7
|
local Unit = ____unit.Unit
|
|
13
8
|
local ____event = require("event")
|
|
14
9
|
local Event = ____event.Event
|
|
10
|
+
local ____synchronization = require("engine.synchronization")
|
|
11
|
+
local ObjectBus = ____synchronization.ObjectBus
|
|
15
12
|
local mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
16
13
|
rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
|
|
17
14
|
local mainSelectedUnitByPlayer = {}
|
|
18
|
-
local
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"",
|
|
23
|
-
0
|
|
15
|
+
local unitBus = __TS__New(
|
|
16
|
+
ObjectBus,
|
|
17
|
+
function(unit) return unit.syncId end,
|
|
18
|
+
function(syncId) return Unit:getBySyncId(syncId) end
|
|
24
19
|
)
|
|
25
|
-
BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
|
|
26
20
|
LocalClient.mainSelectedUnitChangeEvent:addListener(function()
|
|
27
|
-
|
|
28
|
-
local syncId = ____opt_0 and ____opt_0.syncId
|
|
29
|
-
BlzFrameSetValue(syncSlider, syncId or 0)
|
|
21
|
+
unitBus:send(LocalClient.mainSelectedUnit)
|
|
30
22
|
end)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
23
|
+
unitBus.event:addListener(function(player, unit)
|
|
24
|
+
if unit ~= mainSelectedUnitByPlayer[player] then
|
|
25
|
+
mainSelectedUnitByPlayer[player] = unit
|
|
26
|
+
Event.invoke(mainSelectedUnitChangeEvent, player)
|
|
42
27
|
end
|
|
43
|
-
)
|
|
28
|
+
end)
|
|
44
29
|
rawset(
|
|
45
30
|
Unit,
|
|
46
31
|
"getMainSelectedOf",
|
|
@@ -11,9 +11,14 @@ local ____lua_2Dsets = require("utility.lua-sets")
|
|
|
11
11
|
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
12
12
|
local ____attributes = require("attributes")
|
|
13
13
|
local attribute = ____attributes.attribute
|
|
14
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
15
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
14
16
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
15
17
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
16
|
-
local
|
|
18
|
+
local units = __TS__New(LinkedSet)
|
|
19
|
+
local targetAttribute = attribute()
|
|
20
|
+
local impactDelayAttribute = attribute()
|
|
21
|
+
local passedTimeAttribute = attribute()
|
|
17
22
|
local instantOrderIds = luaSetOf(
|
|
18
23
|
orderId("avatar"),
|
|
19
24
|
orderId("berserk"),
|
|
@@ -30,59 +35,45 @@ local instantOrderIds = luaSetOf(
|
|
|
30
35
|
orderId("unimmolation")
|
|
31
36
|
)
|
|
32
37
|
local function reset(source, orderId)
|
|
33
|
-
if not (instantOrderIds[orderId] ~= nil) then
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
eventTimerByUnit[source] = nil
|
|
38
|
-
end
|
|
38
|
+
if not (instantOrderIds[orderId] ~= nil) and units:remove(source) then
|
|
39
|
+
source[targetAttribute] = nil
|
|
40
|
+
source[impactDelayAttribute] = nil
|
|
41
|
+
source[passedTimeAttribute] = nil
|
|
39
42
|
end
|
|
40
43
|
end
|
|
41
44
|
Unit.onImmediateOrder:addListener(reset)
|
|
42
45
|
Unit.onPointOrder:addListener(reset)
|
|
43
46
|
Unit.onTargetOrder:addListener(reset)
|
|
44
|
-
local targetAttribute = attribute()
|
|
45
|
-
local impactDelayAttribute = attribute()
|
|
46
|
-
local passedTimeAttribute = attribute()
|
|
47
|
-
local unitsSize = 0
|
|
48
|
-
local units = {}
|
|
49
47
|
local timerPeriod = 1 / 64
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
unit[passedTimeAttribute] = nil
|
|
65
|
-
Event.invoke(autoAttackFinishEvent, unit, target)
|
|
66
|
-
else
|
|
67
|
-
unit[passedTimeAttribute] = passedTime
|
|
68
|
-
end
|
|
69
|
-
i = i + 1
|
|
70
|
-
end
|
|
48
|
+
local function invokeEvent(unit)
|
|
49
|
+
units:remove(unit)
|
|
50
|
+
local target = unit[targetAttribute]
|
|
51
|
+
unit[targetAttribute] = nil
|
|
52
|
+
unit[impactDelayAttribute] = nil
|
|
53
|
+
unit[passedTimeAttribute] = nil
|
|
54
|
+
Event.invoke(autoAttackFinishEvent, unit, target)
|
|
55
|
+
end
|
|
56
|
+
local function checkUnit(unit)
|
|
57
|
+
local passedTime = unit[passedTimeAttribute] + timerPeriod
|
|
58
|
+
if passedTime >= unit[impactDelayAttribute] then
|
|
59
|
+
invokeEvent(unit)
|
|
60
|
+
else
|
|
61
|
+
unit[passedTimeAttribute] = passedTime
|
|
71
62
|
end
|
|
63
|
+
end
|
|
64
|
+
Timer.onPeriod[timerPeriod]:addListener(function()
|
|
65
|
+
units:forEach(checkUnit)
|
|
72
66
|
end)
|
|
73
67
|
Unit.autoAttackStartEvent:addListener(
|
|
74
|
-
|
|
68
|
+
999999,
|
|
75
69
|
function(source, target)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Event.invoke(autoAttackFinishEvent, source, target)
|
|
79
|
-
else
|
|
80
|
-
unitsSize = unitsSize + 1
|
|
81
|
-
units[unitsSize] = source
|
|
70
|
+
if source[targetAttribute] ~= nil then
|
|
71
|
+
invokeEvent(source)
|
|
82
72
|
end
|
|
83
73
|
source[targetAttribute] = target
|
|
84
74
|
source[impactDelayAttribute] = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
85
75
|
source[passedTimeAttribute] = -timerPeriod
|
|
76
|
+
units:add(source)
|
|
86
77
|
end
|
|
87
78
|
)
|
|
88
79
|
return ____exports
|
|
@@ -80,6 +80,8 @@ export declare class UnitWeapon {
|
|
|
80
80
|
readonly unit: Unit;
|
|
81
81
|
readonly index: 0 | 1;
|
|
82
82
|
constructor(unit: Unit, index: 0 | 1);
|
|
83
|
+
get isEnabled(): boolean;
|
|
84
|
+
set isEnabled(isEnabled: boolean);
|
|
83
85
|
get cooldown(): number;
|
|
84
86
|
set cooldown(cooldown: number);
|
|
85
87
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
package/engine/internal/unit.lua
CHANGED
|
@@ -410,6 +410,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
410
410
|
self.unit = unit
|
|
411
411
|
self.index = index
|
|
412
412
|
end
|
|
413
|
+
__TS__SetDescriptor(
|
|
414
|
+
UnitWeapon.prototype,
|
|
415
|
+
"isEnabled",
|
|
416
|
+
{
|
|
417
|
+
get = function(self)
|
|
418
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
419
|
+
end,
|
|
420
|
+
set = function(self, isEnabled)
|
|
421
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
422
|
+
end
|
|
423
|
+
},
|
|
424
|
+
true
|
|
425
|
+
)
|
|
413
426
|
__TS__SetDescriptor(
|
|
414
427
|
UnitWeapon.prototype,
|
|
415
428
|
"cooldown",
|
|
@@ -836,11 +849,13 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
836
849
|
QueueUnitAnimation(self.handle, animation)
|
|
837
850
|
end
|
|
838
851
|
function Unit.prototype.chooseWeapon(self, target)
|
|
839
|
-
|
|
840
|
-
|
|
852
|
+
local firstWeapon = self.firstWeapon
|
|
853
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
854
|
+
return firstWeapon
|
|
841
855
|
end
|
|
842
|
-
|
|
843
|
-
|
|
856
|
+
local secondWeapon = self.secondWeapon
|
|
857
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
858
|
+
return secondWeapon
|
|
844
859
|
end
|
|
845
860
|
return nil
|
|
846
861
|
end
|
|
@@ -2468,12 +2483,7 @@ Unit.onDamaging = (function()
|
|
|
2468
2483
|
preventRetaliation = damagingEventPreventRetaliation
|
|
2469
2484
|
}
|
|
2470
2485
|
if data.isAttack and source then
|
|
2471
|
-
|
|
2472
|
-
if weapon == -1 then
|
|
2473
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2474
|
-
weapon = 0
|
|
2475
|
-
end
|
|
2476
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2486
|
+
data.weapon = source:chooseWeapon(target)
|
|
2477
2487
|
end
|
|
2478
2488
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2479
2489
|
invoke(
|
package/engine/local-client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Unit } from "../core/types/unit";
|
|
|
3
3
|
import { Async } from "../core/types/async";
|
|
4
4
|
import { Event, TriggerEvent } from "../event";
|
|
5
5
|
import { GraphicsMode } from "./index";
|
|
6
|
+
import { Color } from "../core/types/color";
|
|
6
7
|
export declare class LocalClient {
|
|
7
8
|
private constructor();
|
|
8
9
|
static readonly locale: string;
|
|
@@ -11,6 +12,7 @@ export declare class LocalClient {
|
|
|
11
12
|
static get isHD(): boolean;
|
|
12
13
|
static get graphicsMode(): GraphicsMode;
|
|
13
14
|
static get isActive(): boolean;
|
|
15
|
+
static pingMinimap(x: number, y: number, duration: number, ...parameters: [] | [red: number, green: number, blue: number, extraEffects?: boolean] | [color: Color, extraEffects?: boolean]): void;
|
|
14
16
|
static get mouseFocusUnit(): Async<Unit> | undefined;
|
|
15
17
|
static get mainSelectedUnit(): Async<Unit> | undefined;
|
|
16
18
|
static get mainSelectedUnitChangeEvent(): Event<[
|
package/engine/local-client.lua
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
3
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
5
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
5
6
|
local __TS__New = ____lualib.__TS__New
|
|
6
7
|
local ____exports = {}
|
|
@@ -15,6 +16,8 @@ local ____player = require("core.types.player")
|
|
|
15
16
|
local Player = ____player.Player
|
|
16
17
|
local ____timer = require("core.types.timer")
|
|
17
18
|
local Timer = ____timer.Timer
|
|
19
|
+
local ____color = require("core.types.color")
|
|
20
|
+
local Color = ____color.Color
|
|
18
21
|
local loadTOCFile = BlzLoadTOCFile
|
|
19
22
|
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
20
23
|
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
@@ -25,6 +28,8 @@ local getMouseFocusUnit = BlzGetMouseFocusUnit
|
|
|
25
28
|
local getUnitRealField = BlzGetUnitRealField
|
|
26
29
|
local getUnitTypeId = GetUnitTypeId
|
|
27
30
|
local getLocale = BlzGetLocale
|
|
31
|
+
local pingMinimap = PingMinimap
|
|
32
|
+
local pingMinimapEx = PingMinimapEx
|
|
28
33
|
local tableSort = table.sort
|
|
29
34
|
local tocPath = "_warscript\\IsHD.toc"
|
|
30
35
|
compiletime(function()
|
|
@@ -62,6 +67,31 @@ local LocalClient = ____exports.LocalClient
|
|
|
62
67
|
LocalClient.name = "LocalClient"
|
|
63
68
|
function LocalClient.prototype.____constructor(self)
|
|
64
69
|
end
|
|
70
|
+
function LocalClient.pingMinimap(self, x, y, duration, redOrColor, greenOrExtraEffects, blue, extraEffects)
|
|
71
|
+
if redOrColor == nil then
|
|
72
|
+
pingMinimap(x, y, duration)
|
|
73
|
+
elseif __TS__InstanceOf(redOrColor, Color) then
|
|
74
|
+
pingMinimapEx(
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
duration,
|
|
78
|
+
redOrColor.r,
|
|
79
|
+
redOrColor.g,
|
|
80
|
+
redOrColor.b,
|
|
81
|
+
greenOrExtraEffects or false
|
|
82
|
+
)
|
|
83
|
+
else
|
|
84
|
+
pingMinimapEx(
|
|
85
|
+
x,
|
|
86
|
+
y,
|
|
87
|
+
duration,
|
|
88
|
+
redOrColor,
|
|
89
|
+
greenOrExtraEffects,
|
|
90
|
+
blue,
|
|
91
|
+
extraEffects or false
|
|
92
|
+
)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
65
95
|
LocalClient.locale = getLocale()
|
|
66
96
|
__TS__ObjectDefineProperty(
|
|
67
97
|
LocalClient,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Player } from "../core/types/player";
|
|
3
|
+
import { Event } from "../event";
|
|
4
|
+
export declare const synchronizer: <T, K extends number>(getSyncId: (object: T) => K, getObject: (syncId: K) => T | undefined) => ((player: Player, object: T | undefined) => Promise<T | undefined>);
|
|
5
|
+
export declare class ObjectBus<T, K extends number> {
|
|
6
|
+
private readonly getSyncId;
|
|
7
|
+
readonly event: Event<[Player, T | undefined]>;
|
|
8
|
+
private readonly syncSlider;
|
|
9
|
+
constructor(getSyncId: (object: T) => K, getObject: (syncId: K) => T | undefined);
|
|
10
|
+
send(object: T | undefined): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
3
|
+
local __TS__Promise = ____lualib.__TS__Promise
|
|
4
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____player = require("core.types.player")
|
|
7
|
+
local Player = ____player.Player
|
|
8
|
+
local ____math = require("math")
|
|
9
|
+
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
10
|
+
local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
|
|
11
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
12
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
13
|
+
local ____event = require("event")
|
|
14
|
+
local Event = ____event.Event
|
|
15
|
+
local eventInvoke = Event.invoke
|
|
16
|
+
local createFrameByType = BlzCreateFrameByType
|
|
17
|
+
local createTrigger = CreateTrigger
|
|
18
|
+
local getOriginFrame = BlzGetOriginFrame
|
|
19
|
+
local getTriggerFrameValue = BlzGetTriggerFrameValue
|
|
20
|
+
local getTriggerPlayer = GetTriggerPlayer
|
|
21
|
+
local frameSetMinMaxValue = BlzFrameSetMinMaxValue
|
|
22
|
+
local frameSetValue = BlzFrameSetValue
|
|
23
|
+
local triggerAddAction = TriggerAddAction
|
|
24
|
+
local triggerRegisterFrameEvent = BlzTriggerRegisterFrameEvent
|
|
25
|
+
____exports.synchronizer = function(getSyncId, getObject)
|
|
26
|
+
local queue = __TS__New(LinkedSet)
|
|
27
|
+
local socket = __TS__New(____exports.ObjectBus, getSyncId, getObject)
|
|
28
|
+
socket.event:addListener(function(_, object)
|
|
29
|
+
local ____opt_0 = queue:pop()
|
|
30
|
+
if ____opt_0 ~= nil then
|
|
31
|
+
____opt_0(object)
|
|
32
|
+
end
|
|
33
|
+
end)
|
|
34
|
+
local function executor(____, resolve)
|
|
35
|
+
queue:add(resolve)
|
|
36
|
+
end
|
|
37
|
+
return function(player, object)
|
|
38
|
+
if player.isLocal then
|
|
39
|
+
socket:send(object)
|
|
40
|
+
end
|
|
41
|
+
return __TS__New(__TS__Promise, executor)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
____exports.ObjectBus = __TS__Class()
|
|
45
|
+
local ObjectBus = ____exports.ObjectBus
|
|
46
|
+
ObjectBus.name = "ObjectBus"
|
|
47
|
+
function ObjectBus.prototype.____constructor(self, getSyncId, getObject)
|
|
48
|
+
self.getSyncId = getSyncId
|
|
49
|
+
local syncSlider = createFrameByType(
|
|
50
|
+
"SLIDER",
|
|
51
|
+
"Synchronizer",
|
|
52
|
+
getOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
|
|
53
|
+
"",
|
|
54
|
+
0
|
|
55
|
+
)
|
|
56
|
+
frameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
|
|
57
|
+
self.syncSlider = syncSlider
|
|
58
|
+
local event = __TS__New(Event)
|
|
59
|
+
local trigger = createTrigger()
|
|
60
|
+
triggerRegisterFrameEvent(trigger, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
|
|
61
|
+
triggerAddAction(
|
|
62
|
+
trigger,
|
|
63
|
+
function()
|
|
64
|
+
eventInvoke(
|
|
65
|
+
event,
|
|
66
|
+
Player:of(getTriggerPlayer()),
|
|
67
|
+
getObject(getTriggerFrameValue())
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
)
|
|
71
|
+
self.event = event
|
|
72
|
+
end
|
|
73
|
+
function ObjectBus.prototype.send(self, object)
|
|
74
|
+
local syncId = object ~= nil and self.getSyncId(object) or 0
|
|
75
|
+
frameSetValue(self.syncSlider, syncId)
|
|
76
|
+
end
|
|
77
|
+
return ____exports
|
package/net/socket.lua
CHANGED
|
@@ -28,13 +28,13 @@ function Socket.prototype.____constructor(self)
|
|
|
28
28
|
onReceive[self[0]]:addListener(function(sender, data)
|
|
29
29
|
local chunks = chunksByPlayer[sender]
|
|
30
30
|
if chunks ~= nil then
|
|
31
|
+
chunksByPlayer[sender] = nil
|
|
31
32
|
chunks[#chunks + 1] = data
|
|
32
33
|
Event.invoke(
|
|
33
34
|
self.onMessage,
|
|
34
35
|
sender,
|
|
35
36
|
tableConcat(chunks)
|
|
36
37
|
)
|
|
37
|
-
chunksByPlayer[sender] = nil
|
|
38
38
|
else
|
|
39
39
|
Event.invoke(self.onMessage, sender, data)
|
|
40
40
|
end
|
package/package.json
CHANGED
package/utility/linked-set.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
|
|
|
36
36
|
copyOf(): LinkedSet<T>;
|
|
37
37
|
first(): T | undefined;
|
|
38
38
|
last(): T | undefined;
|
|
39
|
+
pop(): T | undefined;
|
|
39
40
|
next(key: T): T | undefined;
|
|
40
41
|
previous(key: T): T | undefined;
|
|
41
42
|
add(key: T): boolean;
|
package/utility/linked-set.lua
CHANGED
|
@@ -42,6 +42,23 @@ end
|
|
|
42
42
|
function LinkedSet.prototype.last(self)
|
|
43
43
|
return self.l
|
|
44
44
|
end
|
|
45
|
+
function LinkedSet.prototype.pop(self)
|
|
46
|
+
local f = self.f
|
|
47
|
+
if f == nil then
|
|
48
|
+
return nil
|
|
49
|
+
end
|
|
50
|
+
local n = self.n
|
|
51
|
+
local next = n[f]
|
|
52
|
+
n[f] = nil
|
|
53
|
+
self.f = next
|
|
54
|
+
if next ~= nil then
|
|
55
|
+
self.p[next] = nil
|
|
56
|
+
else
|
|
57
|
+
self.l = nil
|
|
58
|
+
end
|
|
59
|
+
self.s = self.s - 1
|
|
60
|
+
return f
|
|
61
|
+
end
|
|
45
62
|
function LinkedSet.prototype.next(self, key)
|
|
46
63
|
return self.n[key]
|
|
47
64
|
end
|
|
@@ -107,8 +124,9 @@ function LinkedSet.prototype.forEach(self, action, ...)
|
|
|
107
124
|
local n = self.n
|
|
108
125
|
local c = self.f
|
|
109
126
|
while c ~= nil do
|
|
127
|
+
local next = n[c]
|
|
110
128
|
action(c, ...)
|
|
111
|
-
c =
|
|
129
|
+
c = next
|
|
112
130
|
end
|
|
113
131
|
end
|
|
114
132
|
function LinkedSet.prototype.toArray(self)
|