warscript 0.0.1-dev.cdcfbc9 → 0.0.1-dev.ce2be36
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/buff.d.ts +10 -1
- package/engine/buff.lua +60 -7
- package/engine/internal/unit/ability.lua +3 -3
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit-missile-launch.lua +41 -23
- package/engine/internal/unit.d.ts +13 -6
- package/engine/internal/unit.lua +83 -37
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -0
- package/engine/object-field.d.ts +7 -1
- package/engine/object-field.lua +177 -88
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.lua +2 -1
- 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
|
package/engine/buff.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
79
79
|
healingOnExpiration?: NumberParameterValueType;
|
|
80
80
|
killsOnExpiration?: BooleanParameterValueType;
|
|
81
81
|
explodesOnExpiration?: BooleanParameterValueType;
|
|
82
|
+
abilityCooldownFactor?: NumberParameterValueType;
|
|
82
83
|
uniqueGroup?: BuffUniqueGroup;
|
|
83
84
|
} : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
|
|
84
85
|
declare const enum BuffPropertyKey {
|
|
@@ -124,7 +125,9 @@ declare const enum BuffPropertyKey {
|
|
|
124
125
|
PROVIDES_INVULNERABILITY = 139,
|
|
125
126
|
KILLS_ON_EXPIRATION = 140,
|
|
126
127
|
EXPLODES_ON_EXPIRATION = 141,
|
|
127
|
-
MISS_PROBABILITY = 142
|
|
128
|
+
MISS_PROBABILITY = 142,
|
|
129
|
+
ABILITY_COOLDOWN_FACTOR = 143,
|
|
130
|
+
ABILITY_COOLDOWN_MODIFIER = 144
|
|
128
131
|
}
|
|
129
132
|
export declare const enum BuffTypeIdSelectionPolicy {
|
|
130
133
|
LEAST_DURATION = 0
|
|
@@ -187,6 +190,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
187
190
|
private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
|
|
188
191
|
private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
|
|
189
192
|
private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
|
|
193
|
+
private [BuffPropertyKey.ABILITY_COOLDOWN_FACTOR]?;
|
|
194
|
+
private [BuffPropertyKey.ABILITY_COOLDOWN_MODIFIER]?;
|
|
190
195
|
protected static readonly defaultParameters: BuffParameters;
|
|
191
196
|
get source(): Unit;
|
|
192
197
|
readonly typeId: ApplicableBuffTypeId;
|
|
@@ -262,6 +267,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
262
267
|
get duration(): number;
|
|
263
268
|
get remainingDuration(): number;
|
|
264
269
|
set remainingDuration(remainingDuration: number);
|
|
270
|
+
get abilityCooldownFactor(): number;
|
|
271
|
+
set abilityCooldownFactor(abilityCooldownFactor: number);
|
|
272
|
+
onAbilityGained(ability: Ability): void;
|
|
273
|
+
onAbilityLost(ability: Ability): void;
|
|
265
274
|
flashEffect(...parameters: [
|
|
266
275
|
...widgetOrXY: [] | [Widget] | [x: number, x: number],
|
|
267
276
|
...parametersOrDuration: [] | [EffectParameters] | [number]
|
package/engine/buff.lua
CHANGED
|
@@ -16,6 +16,7 @@ local internalApplyBuff = ____applicable.internalApplyBuff
|
|
|
16
16
|
local removeBuff = ____applicable.removeBuff
|
|
17
17
|
local ____ability = require("engine.internal.ability")
|
|
18
18
|
local Ability = ____ability.Ability
|
|
19
|
+
local UnitAbility = ____ability.UnitAbility
|
|
19
20
|
local ____ability = require("engine.object-field.ability")
|
|
20
21
|
local AbilityBooleanField = ____ability.AbilityBooleanField
|
|
21
22
|
local AbilityNumberField = ____ability.AbilityNumberField
|
|
@@ -50,6 +51,8 @@ local ____item = require("engine.internal.item")
|
|
|
50
51
|
local Item = ____item.Item
|
|
51
52
|
local ____destructable = require("core.types.destructable")
|
|
52
53
|
local Destructable = ____destructable.Destructable
|
|
54
|
+
local ____ability = require("engine.standard.fields.ability")
|
|
55
|
+
local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
|
|
53
56
|
local getUnitAbility = BlzGetUnitAbility
|
|
54
57
|
local stringValueByBuffTypeIdByFieldId = postcompile(function()
|
|
55
58
|
local stringValueByBuffTypeIdByFieldId = {}
|
|
@@ -121,7 +124,8 @@ local buffParametersKeys = {
|
|
|
121
124
|
damageOnExpiration = true,
|
|
122
125
|
healingOnExpiration = true,
|
|
123
126
|
killsOnExpiration = true,
|
|
124
|
-
explodesOnExpiration = true
|
|
127
|
+
explodesOnExpiration = true,
|
|
128
|
+
abilityCooldownFactor = true
|
|
125
129
|
}
|
|
126
130
|
local function resolveEnumValue(ability, level, value)
|
|
127
131
|
if value == nil or type(value) == "number" then
|
|
@@ -198,7 +202,8 @@ local buffNumberParameters = {
|
|
|
198
202
|
"healingPerInterval",
|
|
199
203
|
"healingOverDuration",
|
|
200
204
|
"damageOnExpiration",
|
|
201
|
-
"healingOnExpiration"
|
|
205
|
+
"healingOnExpiration",
|
|
206
|
+
"abilityCooldownFactor"
|
|
202
207
|
}
|
|
203
208
|
local unsuccessfulApplicationMarker = {}
|
|
204
209
|
local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
|
|
@@ -506,6 +511,22 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
506
511
|
self[100] = 1
|
|
507
512
|
Event.invoke(buffCreatedEvent, self)
|
|
508
513
|
end
|
|
514
|
+
function Buff.prototype.onAbilityGained(self, ability)
|
|
515
|
+
if __TS__InstanceOf(ability, UnitAbility) then
|
|
516
|
+
local abilityCooldownModifier = self[144]
|
|
517
|
+
if abilityCooldownModifier then
|
|
518
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
function Buff.prototype.onAbilityLost(self, ability)
|
|
523
|
+
if __TS__InstanceOf(ability, UnitAbility) then
|
|
524
|
+
local abilityCooldownModifier = self[144]
|
|
525
|
+
if abilityCooldownModifier then
|
|
526
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
end
|
|
509
530
|
function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
510
531
|
if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
|
|
511
532
|
Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
@@ -580,6 +601,12 @@ function Buff.prototype.onDestroy(self)
|
|
|
580
601
|
behavior:destroy()
|
|
581
602
|
end
|
|
582
603
|
end
|
|
604
|
+
local previousAbilityCooldownModifier = self[144]
|
|
605
|
+
if previousAbilityCooldownModifier then
|
|
606
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
607
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
|
|
608
|
+
end
|
|
609
|
+
end
|
|
583
610
|
if self[139] then
|
|
584
611
|
unit:decrementInvulnerabilityCounter()
|
|
585
612
|
end
|
|
@@ -588,7 +615,7 @@ function Buff.prototype.onDestroy(self)
|
|
|
588
615
|
end
|
|
589
616
|
if self[136] then
|
|
590
617
|
if self[137] then
|
|
591
|
-
unit:
|
|
618
|
+
unit:decrementForceStunCounter()
|
|
592
619
|
end
|
|
593
620
|
unit:decrementStunCounter()
|
|
594
621
|
end
|
|
@@ -987,13 +1014,13 @@ __TS__SetDescriptor(
|
|
|
987
1014
|
set = function(self, stuns)
|
|
988
1015
|
if not stuns and self[136] then
|
|
989
1016
|
if self[137] then
|
|
990
|
-
self.object:
|
|
1017
|
+
self.object:decrementForceStunCounter()
|
|
991
1018
|
end
|
|
992
1019
|
self.object:decrementStunCounter()
|
|
993
1020
|
self[136] = nil
|
|
994
1021
|
elseif stuns and not self[136] then
|
|
995
1022
|
if self[137] then
|
|
996
|
-
self.object:
|
|
1023
|
+
self.object:incrementForceStunCounter()
|
|
997
1024
|
end
|
|
998
1025
|
self.object:incrementStunCounter()
|
|
999
1026
|
self[136] = true
|
|
@@ -1016,12 +1043,12 @@ __TS__SetDescriptor(
|
|
|
1016
1043
|
set = function(self, ignoresStunImmunity)
|
|
1017
1044
|
if not ignoresStunImmunity and self[137] then
|
|
1018
1045
|
if self[136] then
|
|
1019
|
-
self.object:
|
|
1046
|
+
self.object:decrementForceStunCounter()
|
|
1020
1047
|
end
|
|
1021
1048
|
self[137] = nil
|
|
1022
1049
|
elseif ignoresStunImmunity and not self[137] then
|
|
1023
1050
|
if self[136] then
|
|
1024
|
-
self.object:
|
|
1051
|
+
self.object:incrementForceStunCounter()
|
|
1025
1052
|
end
|
|
1026
1053
|
self[137] = true
|
|
1027
1054
|
end
|
|
@@ -1269,6 +1296,32 @@ __TS__SetDescriptor(
|
|
|
1269
1296
|
},
|
|
1270
1297
|
true
|
|
1271
1298
|
)
|
|
1299
|
+
__TS__SetDescriptor(
|
|
1300
|
+
Buff.prototype,
|
|
1301
|
+
"abilityCooldownFactor",
|
|
1302
|
+
{
|
|
1303
|
+
get = function(self)
|
|
1304
|
+
return self[143] or 1
|
|
1305
|
+
end,
|
|
1306
|
+
set = function(self, abilityCooldownFactor)
|
|
1307
|
+
local previousAbilityCooldownModifier = self[144]
|
|
1308
|
+
if previousAbilityCooldownModifier then
|
|
1309
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
1310
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
|
|
1311
|
+
end
|
|
1312
|
+
end
|
|
1313
|
+
local function modifier(ability, level, cooldown)
|
|
1314
|
+
return cooldown * abilityCooldownFactor
|
|
1315
|
+
end
|
|
1316
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
1317
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
|
|
1318
|
+
end
|
|
1319
|
+
self[144] = modifier
|
|
1320
|
+
self[143] = abilityCooldownFactor
|
|
1321
|
+
end
|
|
1322
|
+
},
|
|
1323
|
+
true
|
|
1324
|
+
)
|
|
1272
1325
|
Buff.createdEvent = buffCreatedEvent
|
|
1273
1326
|
Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
|
|
1274
1327
|
(function(self)
|
|
@@ -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",
|
|
@@ -9,11 +9,18 @@ local ____timer = require("core.types.timer")
|
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
10
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
11
|
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
12
|
+
local ____attributes = require("attributes")
|
|
13
|
+
local attribute = ____attributes.attribute
|
|
14
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
15
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
12
16
|
local ____math = require("math")
|
|
13
|
-
local
|
|
17
|
+
local ceil = ____math.ceil
|
|
14
18
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
15
19
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
16
|
-
local
|
|
20
|
+
local units = __TS__New(LinkedSet)
|
|
21
|
+
local targetAttribute = attribute()
|
|
22
|
+
local impactDelayAttribute = attribute()
|
|
23
|
+
local passedTimeAttribute = attribute()
|
|
17
24
|
local instantOrderIds = luaSetOf(
|
|
18
25
|
orderId("avatar"),
|
|
19
26
|
orderId("berserk"),
|
|
@@ -30,35 +37,46 @@ local instantOrderIds = luaSetOf(
|
|
|
30
37
|
orderId("unimmolation")
|
|
31
38
|
)
|
|
32
39
|
local function reset(source, orderId)
|
|
33
|
-
if not (instantOrderIds[orderId] ~= nil) then
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
eventTimerByUnit[source] = nil
|
|
38
|
-
end
|
|
40
|
+
if not (instantOrderIds[orderId] ~= nil) and units:remove(source) then
|
|
41
|
+
source[targetAttribute] = nil
|
|
42
|
+
source[impactDelayAttribute] = nil
|
|
43
|
+
source[passedTimeAttribute] = nil
|
|
39
44
|
end
|
|
40
45
|
end
|
|
41
46
|
Unit.onImmediateOrder:addListener(reset)
|
|
42
47
|
Unit.onPointOrder:addListener(reset)
|
|
43
48
|
Unit.onTargetOrder:addListener(reset)
|
|
44
|
-
local
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
local timerPeriod = 1 / 64
|
|
50
|
+
local function invokeEvent(unit)
|
|
51
|
+
units:remove(unit)
|
|
52
|
+
local target = unit[targetAttribute]
|
|
53
|
+
unit[targetAttribute] = nil
|
|
54
|
+
unit[impactDelayAttribute] = nil
|
|
55
|
+
unit[passedTimeAttribute] = nil
|
|
56
|
+
Event.invoke(autoAttackFinishEvent, unit, target)
|
|
57
|
+
end
|
|
58
|
+
local function checkUnit(unit)
|
|
59
|
+
local passedTime = unit[passedTimeAttribute] + timerPeriod
|
|
60
|
+
local impactDelay = unit[impactDelayAttribute]
|
|
61
|
+
if passedTime >= impactDelay and ceil(passedTime / 0.02) >= ceil(impactDelay / 0.02) then
|
|
62
|
+
invokeEvent(unit)
|
|
63
|
+
else
|
|
64
|
+
unit[passedTimeAttribute] = passedTime
|
|
65
|
+
end
|
|
47
66
|
end
|
|
67
|
+
Timer.onPeriod[timerPeriod]:addListener(function()
|
|
68
|
+
units:forEach(checkUnit)
|
|
69
|
+
end)
|
|
48
70
|
Unit.autoAttackStartEvent:addListener(
|
|
49
|
-
|
|
71
|
+
999999,
|
|
50
72
|
function(source, target)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
source,
|
|
59
|
-
target
|
|
60
|
-
)
|
|
61
|
-
eventTimerByUnit[source] = timer
|
|
73
|
+
if source[targetAttribute] ~= nil then
|
|
74
|
+
invokeEvent(source)
|
|
75
|
+
end
|
|
76
|
+
source[targetAttribute] = target
|
|
77
|
+
source[impactDelayAttribute] = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
78
|
+
source[passedTimeAttribute] = -timerPeriod
|
|
79
|
+
units:add(source)
|
|
62
80
|
end
|
|
63
81
|
)
|
|
64
82
|
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];
|
|
@@ -107,12 +109,13 @@ declare const enum UnitPropertyKey {
|
|
|
107
109
|
SYNC_ID = 100,
|
|
108
110
|
IS_PAUSED = 101,
|
|
109
111
|
STUN_COUNTER = 102,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
FORCE_STUN_COUNTER = 103,
|
|
113
|
+
DELAY_HEALTH_CHECKS_COUNTER = 104,
|
|
114
|
+
DELAY_HEALTH_CHECKS_HEALTH_BONUS = 105,
|
|
115
|
+
PREVENT_DEATH_HEALTH_BONUS = 106,
|
|
116
|
+
IS_TEAM_GLOW_HIDDEN = 107,
|
|
117
|
+
LAST_X = 108,
|
|
118
|
+
LAST_Y = 109
|
|
116
119
|
}
|
|
117
120
|
export type UnitSyncId = number & {
|
|
118
121
|
readonly __unitSyncId: unique symbol;
|
|
@@ -121,6 +124,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
121
124
|
readonly syncId: UnitSyncId;
|
|
122
125
|
private [UnitPropertyKey.IS_PAUSED]?;
|
|
123
126
|
private [UnitPropertyKey.STUN_COUNTER]?;
|
|
127
|
+
private [UnitPropertyKey.FORCE_STUN_COUNTER]?;
|
|
124
128
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
|
|
125
129
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
|
|
126
130
|
private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
|
|
@@ -292,6 +296,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
292
296
|
unpauseEx(): void;
|
|
293
297
|
incrementStunCounter(): void;
|
|
294
298
|
decrementStunCounter(): void;
|
|
299
|
+
incrementForceStunCounter(): void;
|
|
300
|
+
decrementForceStunCounter(): void;
|
|
295
301
|
set waygateActive(v: boolean);
|
|
296
302
|
get waygateActive(): boolean;
|
|
297
303
|
set waygateDestination(v: Vec2);
|
|
@@ -373,5 +379,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
373
379
|
setField(field: junitstringfield, value: string): boolean;
|
|
374
380
|
toString(): string;
|
|
375
381
|
static getBySyncId(syncId: UnitSyncId): Unit | undefined;
|
|
382
|
+
static synchronize: (player: Player, object: Unit | undefined) => Promise<Unit | undefined>;
|
|
376
383
|
}
|
|
377
384
|
export {};
|