warscript 0.0.1-dev.a319619 → 0.0.1-dev.a3deff8
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/frame.lua +14 -9
- package/core/types/player.d.ts +15 -0
- package/core/types/player.lua +53 -13
- package/core/types/playerCamera.lua +44 -0
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +3 -2
- package/core/types/timer.lua +22 -2
- package/decl/native.d.ts +2 -2
- package/engine/behavior.d.ts +3 -0
- package/engine/behavior.lua +53 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/unit/stun-immunity.d.ts +2 -0
- package/engine/behaviour/unit/stun-immunity.lua +11 -2
- package/engine/behaviour/unit.d.ts +8 -2
- package/engine/behaviour/unit.lua +29 -2
- package/engine/buff.d.ts +9 -4
- package/engine/buff.lua +112 -82
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +26 -9
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +63 -49
- package/engine/internal/unit/ability.d.ts +14 -14
- package/engine/internal/unit/ability.lua +72 -45
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit+ability.lua +9 -8
- package/engine/internal/unit-missile-launch.lua +44 -20
- package/engine/internal/unit.d.ts +16 -9
- package/engine/internal/unit.lua +102 -54
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -0
- package/engine/object-data/entry/ability-type.lua +4 -1
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field.d.ts +9 -3
- package/engine/object-field.lua +184 -93
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.lua +3 -2
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +1 -1
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/types.d.ts +3 -0
|
@@ -8,6 +8,7 @@ export type StunImmunityUnitBehaviourParameters = {
|
|
|
8
8
|
buffTypeIds?: LuaSet<BuffTypeId>;
|
|
9
9
|
textTagPreset?: TextTagPreset;
|
|
10
10
|
textTagText?: string;
|
|
11
|
+
additionalAction?: (this: void, unit: Unit) => void;
|
|
11
12
|
};
|
|
12
13
|
export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
13
14
|
readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
|
|
@@ -17,4 +18,5 @@ export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
|
17
18
|
onDamageReceived(): void;
|
|
18
19
|
onTargetingAbilityChannelingStart(): void;
|
|
19
20
|
onTargetingAbilityImpact(): void;
|
|
21
|
+
protected onEffect(): void;
|
|
20
22
|
}
|
|
@@ -48,8 +48,15 @@ local function process(behavior)
|
|
|
48
48
|
for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
|
|
49
49
|
hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
|
|
50
50
|
end
|
|
51
|
-
if hasRemovedBuffs
|
|
52
|
-
|
|
51
|
+
if hasRemovedBuffs then
|
|
52
|
+
behavior.onEffect(behavior)
|
|
53
|
+
if behavior.parameters.textTagText ~= nil then
|
|
54
|
+
TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
|
|
55
|
+
end
|
|
56
|
+
local ____opt_0 = behavior.parameters.additionalAction
|
|
57
|
+
if ____opt_0 ~= nil then
|
|
58
|
+
____opt_0(behavior.unit)
|
|
59
|
+
end
|
|
53
60
|
end
|
|
54
61
|
end
|
|
55
62
|
____exports.StunImmunityUnitBehavior = __TS__Class()
|
|
@@ -79,5 +86,7 @@ end
|
|
|
79
86
|
function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
|
|
80
87
|
process(self)
|
|
81
88
|
end
|
|
89
|
+
function StunImmunityUnitBehavior.prototype.onEffect(self)
|
|
90
|
+
end
|
|
82
91
|
StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
|
|
83
92
|
return ____exports
|
|
@@ -11,13 +11,18 @@ import { Destructor } from "../../destroyable";
|
|
|
11
11
|
import type { Widget } from "../../core/types/widget";
|
|
12
12
|
import { Destructable } from "../../core/types/destructable";
|
|
13
13
|
import type { Buff } from "../buff";
|
|
14
|
+
import { UnitBonusType } from "../internal/unit/bonus";
|
|
15
|
+
import { Player } from "../../core/types/player";
|
|
14
16
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
15
17
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
18
|
+
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
19
|
+
private _bonusIdByBonusType?;
|
|
16
20
|
constructor(unit: Unit);
|
|
17
21
|
protected onDestroy(): Destructor;
|
|
18
|
-
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
19
22
|
get unit(): Unit;
|
|
20
|
-
|
|
23
|
+
protected getUnitBonus(bonusType: UnitBonusType): number;
|
|
24
|
+
protected addOrUpdateOrRemoveUnitBonus(bonusType: UnitBonusType, value: number): void;
|
|
25
|
+
protected registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractUnit: (...args: Args) => Unit | undefined, range: number, listener: T): void;
|
|
21
26
|
onImmediateOrder(orderId: number): void;
|
|
22
27
|
onTargetOrder(orderId: number, target: Widget): void;
|
|
23
28
|
onPointOrder(orderId: number, x: number, y: number): void;
|
|
@@ -51,4 +56,5 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
51
56
|
onItemChargesChanged(item: Item): void;
|
|
52
57
|
onKill(target: Unit): void;
|
|
53
58
|
onDeath(source: Unit | undefined): void;
|
|
59
|
+
onOwnerChange(previousOwner: Player): void;
|
|
54
60
|
}
|
|
@@ -17,6 +17,11 @@ local getOrPut = ____lua_2Dmaps.getOrPut
|
|
|
17
17
|
local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
|
|
18
18
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
19
19
|
local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
|
|
20
|
+
local ____bonus = require("engine.internal.unit.bonus")
|
|
21
|
+
local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
|
|
22
|
+
local getUnitBonus = ____bonus.getUnitBonus
|
|
23
|
+
local removeUnitBonus = ____bonus.removeUnitBonus
|
|
24
|
+
local safeCall = warpack.safeCall
|
|
20
25
|
local behaviorsByEvent = {}
|
|
21
26
|
local rangeByBehaviorByEvent = {}
|
|
22
27
|
local listenerByBehaviorByEvent = {}
|
|
@@ -47,8 +52,26 @@ function UnitBehavior.prototype.onDestroy(self)
|
|
|
47
52
|
end
|
|
48
53
|
eventsByBehavior[self] = nil
|
|
49
54
|
end
|
|
55
|
+
if self._bonusIdByBonusType ~= nil then
|
|
56
|
+
for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
|
|
57
|
+
removeUnitBonus(self.object, bonusType, bonusId)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
50
60
|
return Behavior.prototype.onDestroy(self)
|
|
51
61
|
end
|
|
62
|
+
function UnitBehavior.prototype.getUnitBonus(self, bonusType)
|
|
63
|
+
local ____opt_6 = self._bonusIdByBonusType
|
|
64
|
+
local bonusId = ____opt_6 and ____opt_6[bonusType]
|
|
65
|
+
return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
|
|
66
|
+
end
|
|
67
|
+
function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
|
|
68
|
+
local bonusIdByBonusType = self._bonusIdByBonusType
|
|
69
|
+
if bonusIdByBonusType == nil then
|
|
70
|
+
bonusIdByBonusType = {}
|
|
71
|
+
self._bonusIdByBonusType = bonusIdByBonusType
|
|
72
|
+
end
|
|
73
|
+
bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self.object, bonusType, bonusIdByBonusType[bonusType], value)
|
|
74
|
+
end
|
|
52
75
|
function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
|
|
53
76
|
local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
|
|
54
77
|
rangeByBehavior[self] = range
|
|
@@ -65,8 +88,7 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUni
|
|
|
65
88
|
for behavior in pairs(behaviors) do
|
|
66
89
|
local range = rangeByBehavior[behavior]
|
|
67
90
|
if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
|
|
68
|
-
|
|
69
|
-
____self_6[listenerByBehavior[behavior]](____self_6, ...)
|
|
91
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
70
92
|
end
|
|
71
93
|
end
|
|
72
94
|
end
|
|
@@ -143,6 +165,8 @@ function UnitBehavior.prototype.onKill(self, target)
|
|
|
143
165
|
end
|
|
144
166
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
145
167
|
end
|
|
168
|
+
function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
|
|
169
|
+
end
|
|
146
170
|
__TS__SetDescriptor(
|
|
147
171
|
UnitBehavior.prototype,
|
|
148
172
|
"unit",
|
|
@@ -254,6 +278,9 @@ __TS__SetDescriptor(
|
|
|
254
278
|
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
255
279
|
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
256
280
|
end)
|
|
281
|
+
Unit.onOwnerChange:addListener(function(unit, previousOwner)
|
|
282
|
+
____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
|
|
283
|
+
end)
|
|
257
284
|
end)(UnitBehavior)
|
|
258
285
|
Unit.destroyEvent:addListener(function(unit)
|
|
259
286
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
package/engine/buff.d.ts
CHANGED
|
@@ -124,7 +124,9 @@ declare const enum BuffPropertyKey {
|
|
|
124
124
|
PROVIDES_INVULNERABILITY = 139,
|
|
125
125
|
KILLS_ON_EXPIRATION = 140,
|
|
126
126
|
EXPLODES_ON_EXPIRATION = 141,
|
|
127
|
-
MISS_PROBABILITY = 142
|
|
127
|
+
MISS_PROBABILITY = 142,
|
|
128
|
+
ABILITY_COOLDOWN_FACTOR = 143,
|
|
129
|
+
ABILITY_COOLDOWN_MODIFIER = 144
|
|
128
130
|
}
|
|
129
131
|
export declare const enum BuffTypeIdSelectionPolicy {
|
|
130
132
|
LEAST_DURATION = 0
|
|
@@ -187,6 +189,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
187
189
|
private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
|
|
188
190
|
private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
|
|
189
191
|
private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
|
|
192
|
+
private [BuffPropertyKey.ABILITY_COOLDOWN_FACTOR]?;
|
|
193
|
+
private [BuffPropertyKey.ABILITY_COOLDOWN_MODIFIER]?;
|
|
190
194
|
protected static readonly defaultParameters: BuffParameters;
|
|
191
195
|
get source(): Unit;
|
|
192
196
|
readonly typeId: ApplicableBuffTypeId;
|
|
@@ -201,11 +205,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
201
205
|
private readonly _spellStealPriority?;
|
|
202
206
|
private readonly _learnLevelMinimum?;
|
|
203
207
|
private readonly [BuffPropertyKey.MISS_PROBABILITY]?;
|
|
204
|
-
private _bonusIdByBonusType?;
|
|
205
208
|
private readonly _abilityTypeIds?;
|
|
206
209
|
private _behaviors?;
|
|
207
|
-
private getUnitBonus;
|
|
208
|
-
private addOrUpdateOrRemoveUnitBonus;
|
|
209
210
|
constructor(target: Unit, ...parameters: BuffConstructorParameters<AdditionalParameters>);
|
|
210
211
|
get level(): number;
|
|
211
212
|
get remainingDamageOverDuration(): number;
|
|
@@ -265,6 +266,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
265
266
|
get duration(): number;
|
|
266
267
|
get remainingDuration(): number;
|
|
267
268
|
set remainingDuration(remainingDuration: number);
|
|
269
|
+
get abilityCooldownFactor(): number;
|
|
270
|
+
set abilityCooldownFactor(abilityCooldownFactor: number);
|
|
271
|
+
onAbilityGained(ability: Ability): void;
|
|
272
|
+
onAbilityLost(ability: Ability): void;
|
|
268
273
|
flashEffect(...parameters: [
|
|
269
274
|
...widgetOrXY: [] | [Widget] | [x: number, x: number],
|
|
270
275
|
...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
|
|
@@ -28,9 +29,6 @@ local ____math = require("math")
|
|
|
28
29
|
local max = ____math.max
|
|
29
30
|
local min = ____math.min
|
|
30
31
|
local ____bonus = require("engine.internal.unit.bonus")
|
|
31
|
-
local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
|
|
32
|
-
local getUnitBonus = ____bonus.getUnitBonus
|
|
33
|
-
local removeUnitBonus = ____bonus.removeUnitBonus
|
|
34
32
|
local UnitBonusType = ____bonus.UnitBonusType
|
|
35
33
|
local ____area_2Ddamage = require("engine.internal.mechanics.area-damage")
|
|
36
34
|
local damageArea = ____area_2Ddamage.damageArea
|
|
@@ -53,6 +51,8 @@ local ____item = require("engine.internal.item")
|
|
|
53
51
|
local Item = ____item.Item
|
|
54
52
|
local ____destructable = require("core.types.destructable")
|
|
55
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
|
|
56
56
|
local getUnitAbility = BlzGetUnitAbility
|
|
57
57
|
local stringValueByBuffTypeIdByFieldId = postcompile(function()
|
|
58
58
|
local stringValueByBuffTypeIdByFieldId = {}
|
|
@@ -509,63 +509,66 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
509
509
|
self[100] = 1
|
|
510
510
|
Event.invoke(buffCreatedEvent, self)
|
|
511
511
|
end
|
|
512
|
-
function Buff.prototype.
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
512
|
+
function Buff.prototype.onAbilityGained(self, ability)
|
|
513
|
+
if __TS__InstanceOf(ability, UnitAbility) then
|
|
514
|
+
local abilityCooldownModifier = self[144]
|
|
515
|
+
if abilityCooldownModifier then
|
|
516
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
|
|
517
|
+
end
|
|
518
|
+
end
|
|
516
519
|
end
|
|
517
|
-
function Buff.prototype.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
520
|
+
function Buff.prototype.onAbilityLost(self, ability)
|
|
521
|
+
if __TS__InstanceOf(ability, UnitAbility) then
|
|
522
|
+
local abilityCooldownModifier = self[144]
|
|
523
|
+
if abilityCooldownModifier then
|
|
524
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
|
|
525
|
+
end
|
|
522
526
|
end
|
|
523
|
-
bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
|
|
524
527
|
end
|
|
525
528
|
function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
526
529
|
if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
|
|
527
530
|
Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
528
531
|
else
|
|
529
532
|
local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
|
|
530
|
-
local
|
|
531
|
-
local
|
|
532
|
-
local
|
|
533
|
+
local ____Effect_40 = Effect
|
|
534
|
+
local ____Effect_flash_41 = Effect.flash
|
|
535
|
+
local ____array_39 = __TS__SparseArrayNew(
|
|
533
536
|
self[105],
|
|
534
537
|
isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
|
|
535
538
|
stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
|
|
536
539
|
)
|
|
537
|
-
local
|
|
540
|
+
local ____isWidgetProvided_38
|
|
538
541
|
if isWidgetProvided then
|
|
539
|
-
|
|
542
|
+
____isWidgetProvided_38 = yOrParametersOrDuration
|
|
540
543
|
else
|
|
541
|
-
|
|
544
|
+
____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
|
|
542
545
|
end
|
|
543
|
-
__TS__SparseArrayPush(
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
__TS__SparseArraySpread(
|
|
546
|
+
__TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
|
|
547
|
+
____Effect_flash_41(
|
|
548
|
+
____Effect_40,
|
|
549
|
+
__TS__SparseArraySpread(____array_39)
|
|
547
550
|
)
|
|
548
551
|
end
|
|
549
552
|
end
|
|
550
553
|
function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
|
|
551
554
|
local isWidgetProvided = type(widgetOrDuration) == "table"
|
|
552
|
-
local
|
|
553
|
-
local
|
|
554
|
-
local
|
|
555
|
+
local ____Effect_44 = Effect
|
|
556
|
+
local ____Effect_flash_45 = Effect.flash
|
|
557
|
+
local ____array_43 = __TS__SparseArrayNew(
|
|
555
558
|
self[106],
|
|
556
559
|
isWidgetProvided and widgetOrDuration or self._unit,
|
|
557
560
|
stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
|
|
558
561
|
)
|
|
559
|
-
local
|
|
562
|
+
local ____isWidgetProvided_42
|
|
560
563
|
if isWidgetProvided then
|
|
561
|
-
|
|
564
|
+
____isWidgetProvided_42 = duration
|
|
562
565
|
else
|
|
563
|
-
|
|
566
|
+
____isWidgetProvided_42 = widgetOrDuration
|
|
564
567
|
end
|
|
565
|
-
__TS__SparseArrayPush(
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
__TS__SparseArraySpread(
|
|
568
|
+
__TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
|
|
569
|
+
____Effect_flash_45(
|
|
570
|
+
____Effect_44,
|
|
571
|
+
__TS__SparseArraySpread(____array_43)
|
|
569
572
|
)
|
|
570
573
|
end
|
|
571
574
|
function Buff.prototype.onCreate(self)
|
|
@@ -596,6 +599,12 @@ function Buff.prototype.onDestroy(self)
|
|
|
596
599
|
behavior:destroy()
|
|
597
600
|
end
|
|
598
601
|
end
|
|
602
|
+
local previousAbilityCooldownModifier = self[144]
|
|
603
|
+
if previousAbilityCooldownModifier then
|
|
604
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
605
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
|
|
606
|
+
end
|
|
607
|
+
end
|
|
599
608
|
if self[139] then
|
|
600
609
|
unit:decrementInvulnerabilityCounter()
|
|
601
610
|
end
|
|
@@ -604,7 +613,7 @@ function Buff.prototype.onDestroy(self)
|
|
|
604
613
|
end
|
|
605
614
|
if self[136] then
|
|
606
615
|
if self[137] then
|
|
607
|
-
unit:
|
|
616
|
+
unit:decrementForceStunCounter()
|
|
608
617
|
end
|
|
609
618
|
unit:decrementStunCounter()
|
|
610
619
|
end
|
|
@@ -616,11 +625,6 @@ function Buff.prototype.onDestroy(self)
|
|
|
616
625
|
unit:removeAbility(abilityTypeId)
|
|
617
626
|
end
|
|
618
627
|
end
|
|
619
|
-
if self._bonusIdByBonusType ~= nil then
|
|
620
|
-
for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
|
|
621
|
-
removeUnitBonus(unit, bonusType, bonusId)
|
|
622
|
-
end
|
|
623
|
-
end
|
|
624
628
|
Event.invoke(buffBeingDestroyedEvent, self)
|
|
625
629
|
self[100] = 3
|
|
626
630
|
return UnitBehavior.prototype.onDestroy(self)
|
|
@@ -650,8 +654,8 @@ function Buff.apply(self, ...)
|
|
|
650
654
|
end
|
|
651
655
|
end
|
|
652
656
|
function Buff.getByTypeId(self, unit, typeId)
|
|
653
|
-
local
|
|
654
|
-
local buff =
|
|
657
|
+
local ____opt_46 = buffByTypeIdByUnit[unit]
|
|
658
|
+
local buff = ____opt_46 and ____opt_46[typeId]
|
|
655
659
|
if __TS__InstanceOf(buff, self) then
|
|
656
660
|
return buff
|
|
657
661
|
end
|
|
@@ -809,8 +813,8 @@ __TS__SetDescriptor(
|
|
|
809
813
|
return
|
|
810
814
|
end
|
|
811
815
|
self[112] = damageInterval
|
|
812
|
-
local
|
|
813
|
-
local elapsed =
|
|
816
|
+
local ____opt_48 = self._timer
|
|
817
|
+
local elapsed = ____opt_48 and ____opt_48.elapsed or 0
|
|
814
818
|
local timer = self[114]
|
|
815
819
|
if timer == nil then
|
|
816
820
|
timer = Timer:create()
|
|
@@ -889,8 +893,8 @@ __TS__SetDescriptor(
|
|
|
889
893
|
return
|
|
890
894
|
end
|
|
891
895
|
self[117] = healingInterval
|
|
892
|
-
local
|
|
893
|
-
local elapsed =
|
|
896
|
+
local ____opt_50 = self._timer
|
|
897
|
+
local elapsed = ____opt_50 and ____opt_50.elapsed or 0
|
|
894
898
|
local timer = self[119]
|
|
895
899
|
if timer == nil then
|
|
896
900
|
timer = Timer:create()
|
|
@@ -976,11 +980,11 @@ __TS__SetDescriptor(
|
|
|
976
980
|
"turnsIntoGhost",
|
|
977
981
|
{
|
|
978
982
|
get = function(self)
|
|
979
|
-
local
|
|
980
|
-
if
|
|
981
|
-
|
|
983
|
+
local ____self__135_52 = self[135]
|
|
984
|
+
if ____self__135_52 == nil then
|
|
985
|
+
____self__135_52 = false
|
|
982
986
|
end
|
|
983
|
-
return
|
|
987
|
+
return ____self__135_52
|
|
984
988
|
end,
|
|
985
989
|
set = function(self, turnsIntoGhost)
|
|
986
990
|
if not turnsIntoGhost and self[135] then
|
|
@@ -999,22 +1003,22 @@ __TS__SetDescriptor(
|
|
|
999
1003
|
"stuns",
|
|
1000
1004
|
{
|
|
1001
1005
|
get = function(self)
|
|
1002
|
-
local
|
|
1003
|
-
if
|
|
1004
|
-
|
|
1006
|
+
local ____self__136_53 = self[136]
|
|
1007
|
+
if ____self__136_53 == nil then
|
|
1008
|
+
____self__136_53 = false
|
|
1005
1009
|
end
|
|
1006
|
-
return
|
|
1010
|
+
return ____self__136_53
|
|
1007
1011
|
end,
|
|
1008
1012
|
set = function(self, stuns)
|
|
1009
1013
|
if not stuns and self[136] then
|
|
1010
1014
|
if self[137] then
|
|
1011
|
-
self.object:
|
|
1015
|
+
self.object:decrementForceStunCounter()
|
|
1012
1016
|
end
|
|
1013
1017
|
self.object:decrementStunCounter()
|
|
1014
1018
|
self[136] = nil
|
|
1015
1019
|
elseif stuns and not self[136] then
|
|
1016
1020
|
if self[137] then
|
|
1017
|
-
self.object:
|
|
1021
|
+
self.object:incrementForceStunCounter()
|
|
1018
1022
|
end
|
|
1019
1023
|
self.object:incrementStunCounter()
|
|
1020
1024
|
self[136] = true
|
|
@@ -1028,21 +1032,21 @@ __TS__SetDescriptor(
|
|
|
1028
1032
|
"ignoresStunImmunity",
|
|
1029
1033
|
{
|
|
1030
1034
|
get = function(self)
|
|
1031
|
-
local
|
|
1032
|
-
if
|
|
1033
|
-
|
|
1035
|
+
local ____self__137_54 = self[137]
|
|
1036
|
+
if ____self__137_54 == nil then
|
|
1037
|
+
____self__137_54 = false
|
|
1034
1038
|
end
|
|
1035
|
-
return
|
|
1039
|
+
return ____self__137_54
|
|
1036
1040
|
end,
|
|
1037
1041
|
set = function(self, ignoresStunImmunity)
|
|
1038
1042
|
if not ignoresStunImmunity and self[137] then
|
|
1039
1043
|
if self[136] then
|
|
1040
|
-
self.object:
|
|
1044
|
+
self.object:decrementForceStunCounter()
|
|
1041
1045
|
end
|
|
1042
1046
|
self[137] = nil
|
|
1043
1047
|
elseif ignoresStunImmunity and not self[137] then
|
|
1044
1048
|
if self[136] then
|
|
1045
|
-
self.object:
|
|
1049
|
+
self.object:incrementForceStunCounter()
|
|
1046
1050
|
end
|
|
1047
1051
|
self[137] = true
|
|
1048
1052
|
end
|
|
@@ -1055,11 +1059,11 @@ __TS__SetDescriptor(
|
|
|
1055
1059
|
"disablesAutoAttack",
|
|
1056
1060
|
{
|
|
1057
1061
|
get = function(self)
|
|
1058
|
-
local
|
|
1059
|
-
if
|
|
1060
|
-
|
|
1062
|
+
local ____self__138_55 = self[138]
|
|
1063
|
+
if ____self__138_55 == nil then
|
|
1064
|
+
____self__138_55 = false
|
|
1061
1065
|
end
|
|
1062
|
-
return
|
|
1066
|
+
return ____self__138_55
|
|
1063
1067
|
end,
|
|
1064
1068
|
set = function(self, disablesAutoAttack)
|
|
1065
1069
|
if not disablesAutoAttack and self[138] then
|
|
@@ -1078,11 +1082,11 @@ __TS__SetDescriptor(
|
|
|
1078
1082
|
"providesInvulnerability",
|
|
1079
1083
|
{
|
|
1080
1084
|
get = function(self)
|
|
1081
|
-
local
|
|
1082
|
-
if
|
|
1083
|
-
|
|
1085
|
+
local ____self__139_56 = self[139]
|
|
1086
|
+
if ____self__139_56 == nil then
|
|
1087
|
+
____self__139_56 = false
|
|
1084
1088
|
end
|
|
1085
|
-
return
|
|
1089
|
+
return ____self__139_56
|
|
1086
1090
|
end,
|
|
1087
1091
|
set = function(self, providesInvulnerability)
|
|
1088
1092
|
if not providesInvulnerability and self[139] then
|
|
@@ -1101,11 +1105,11 @@ __TS__SetDescriptor(
|
|
|
1101
1105
|
"killsOnExpiration",
|
|
1102
1106
|
{
|
|
1103
1107
|
get = function(self)
|
|
1104
|
-
local
|
|
1105
|
-
if
|
|
1106
|
-
|
|
1108
|
+
local ____self__140_57 = self[140]
|
|
1109
|
+
if ____self__140_57 == nil then
|
|
1110
|
+
____self__140_57 = false
|
|
1107
1111
|
end
|
|
1108
|
-
return
|
|
1112
|
+
return ____self__140_57
|
|
1109
1113
|
end,
|
|
1110
1114
|
set = function(self, killsOnExpiration)
|
|
1111
1115
|
if not killsOnExpiration and self[140] then
|
|
@@ -1122,11 +1126,11 @@ __TS__SetDescriptor(
|
|
|
1122
1126
|
"explodesOnExpiration",
|
|
1123
1127
|
{
|
|
1124
1128
|
get = function(self)
|
|
1125
|
-
local
|
|
1126
|
-
if
|
|
1127
|
-
|
|
1129
|
+
local ____self__141_58 = self[141]
|
|
1130
|
+
if ____self__141_58 == nil then
|
|
1131
|
+
____self__141_58 = false
|
|
1128
1132
|
end
|
|
1129
|
-
return
|
|
1133
|
+
return ____self__141_58
|
|
1130
1134
|
end,
|
|
1131
1135
|
set = function(self, killsOnExpiration)
|
|
1132
1136
|
if not killsOnExpiration and self[141] then
|
|
@@ -1254,13 +1258,13 @@ __TS__SetDescriptor(
|
|
|
1254
1258
|
"remainingDuration",
|
|
1255
1259
|
{
|
|
1256
1260
|
get = function(self)
|
|
1257
|
-
local
|
|
1258
|
-
return
|
|
1261
|
+
local ____opt_59 = self._timer
|
|
1262
|
+
return ____opt_59 and ____opt_59.remaining or 0
|
|
1259
1263
|
end,
|
|
1260
1264
|
set = function(self, remainingDuration)
|
|
1261
|
-
local
|
|
1262
|
-
local
|
|
1263
|
-
local remainingDurationDelta =
|
|
1265
|
+
local ____remainingDuration_63 = remainingDuration
|
|
1266
|
+
local ____opt_61 = self._timer
|
|
1267
|
+
local remainingDurationDelta = ____remainingDuration_63 - (____opt_61 and ____opt_61.remaining or 0)
|
|
1264
1268
|
if remainingDurationDelta ~= 0 then
|
|
1265
1269
|
self[103] = self[103] + remainingDurationDelta
|
|
1266
1270
|
if remainingDuration <= 0 then
|
|
@@ -1290,6 +1294,32 @@ __TS__SetDescriptor(
|
|
|
1290
1294
|
},
|
|
1291
1295
|
true
|
|
1292
1296
|
)
|
|
1297
|
+
__TS__SetDescriptor(
|
|
1298
|
+
Buff.prototype,
|
|
1299
|
+
"abilityCooldownFactor",
|
|
1300
|
+
{
|
|
1301
|
+
get = function(self)
|
|
1302
|
+
return self[143] or 1
|
|
1303
|
+
end,
|
|
1304
|
+
set = function(self, abilityCooldownFactor)
|
|
1305
|
+
local previousAbilityCooldownModifier = self[144]
|
|
1306
|
+
if previousAbilityCooldownModifier then
|
|
1307
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
1308
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
|
|
1309
|
+
end
|
|
1310
|
+
end
|
|
1311
|
+
local function modifier(ability, level, cooldown)
|
|
1312
|
+
return cooldown * abilityCooldownFactor
|
|
1313
|
+
end
|
|
1314
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
1315
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
|
|
1316
|
+
end
|
|
1317
|
+
self[144] = modifier
|
|
1318
|
+
self[143] = abilityCooldownFactor
|
|
1319
|
+
end
|
|
1320
|
+
},
|
|
1321
|
+
true
|
|
1322
|
+
)
|
|
1293
1323
|
Buff.createdEvent = buffCreatedEvent
|
|
1294
1324
|
Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
|
|
1295
1325
|
(function(self)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import { Handle } from "../../core/types/handle";
|
|
2
|
+
import { Handle, HandleDestructor } from "../../core/types/handle";
|
|
3
3
|
import { Event } from "../../event";
|
|
4
4
|
import type { Item } from "../../core/types/item";
|
|
5
5
|
import type { Unit } from "./unit";
|
|
@@ -67,6 +67,7 @@ export declare class UnitAbility extends Ability {
|
|
|
67
67
|
get cooldownRemaining(): number;
|
|
68
68
|
set cooldownRemaining(cooldownRemaining: number);
|
|
69
69
|
interruptCast(): void;
|
|
70
|
+
protected onDestroy(): HandleDestructor;
|
|
70
71
|
static get onCreate(): Event<[UnitAbility]>;
|
|
71
72
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
72
73
|
}
|
|
@@ -93,6 +94,7 @@ export declare class ItemAbility extends Ability {
|
|
|
93
94
|
get cooldownRemaining(): number;
|
|
94
95
|
set cooldownRemaining(cooldownRemaining: number);
|
|
95
96
|
interruptCast(): void;
|
|
97
|
+
protected onDestroy(): HandleDestructor;
|
|
96
98
|
static get onCreate(): Event<[ItemAbility]>;
|
|
97
99
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
98
100
|
}
|
|
@@ -232,6 +232,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
|
|
|
232
232
|
local parentTypeId = availableFields[abilityTypeId]
|
|
233
233
|
return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
|
|
234
234
|
end
|
|
235
|
+
---
|
|
236
|
+
-- @internal For use by internal systems only.
|
|
237
|
+
____exports.abilityTypeHasField = function(abilityTypeId, field)
|
|
238
|
+
field = ____type(field) == "number" and field or getHandleId(field)
|
|
239
|
+
if commonFields[field] then
|
|
240
|
+
return true
|
|
241
|
+
end
|
|
242
|
+
local id = availableFields[abilityTypeId]
|
|
243
|
+
if ____type(id) == "number" then
|
|
244
|
+
id = availableFields[id]
|
|
245
|
+
end
|
|
246
|
+
return not not (id and id[field])
|
|
247
|
+
end
|
|
235
248
|
____exports.Ability = __TS__Class()
|
|
236
249
|
local Ability = ____exports.Ability
|
|
237
250
|
Ability.name = "Ability"
|
|
@@ -247,15 +260,7 @@ function Ability.prototype.getSnapshot(self)
|
|
|
247
260
|
return nil
|
|
248
261
|
end
|
|
249
262
|
function Ability.prototype.hasField(self, field)
|
|
250
|
-
|
|
251
|
-
if commonFields[field] then
|
|
252
|
-
return true
|
|
253
|
-
end
|
|
254
|
-
local id = availableFields[self.typeId]
|
|
255
|
-
if ____type(id) == "number" then
|
|
256
|
-
id = availableFields[id]
|
|
257
|
-
end
|
|
258
|
-
return not not (id and id[field])
|
|
263
|
+
return ____exports.abilityTypeHasField(self.typeId, field)
|
|
259
264
|
end
|
|
260
265
|
function Ability.prototype.getField(self, field, level)
|
|
261
266
|
local fieldType = match(
|
|
@@ -420,6 +425,12 @@ end
|
|
|
420
425
|
function UnitAbility.prototype.interruptCast(self)
|
|
421
426
|
self.owner:interruptCast(self.typeId)
|
|
422
427
|
end
|
|
428
|
+
function UnitAbility.prototype.onDestroy(self)
|
|
429
|
+
if self.owner.state ~= 2 then
|
|
430
|
+
self.owner:removeAbility(self.typeId)
|
|
431
|
+
end
|
|
432
|
+
return UnitAbility.____super.prototype.onDestroy(self)
|
|
433
|
+
end
|
|
423
434
|
__TS__SetDescriptor(
|
|
424
435
|
UnitAbility.prototype,
|
|
425
436
|
"isDisabled",
|
|
@@ -512,6 +523,12 @@ function ItemAbility.prototype.interruptCast(self)
|
|
|
512
523
|
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
513
524
|
end
|
|
514
525
|
end
|
|
526
|
+
function ItemAbility.prototype.onDestroy(self)
|
|
527
|
+
if self.owner.state ~= 2 then
|
|
528
|
+
self.owner:removeAbility(self.typeId)
|
|
529
|
+
end
|
|
530
|
+
return ItemAbility.____super.prototype.onDestroy(self)
|
|
531
|
+
end
|
|
515
532
|
__TS__SetDescriptor(
|
|
516
533
|
ItemAbility.prototype,
|
|
517
534
|
"level",
|
|
@@ -6,12 +6,18 @@ local Item = ____item.Item
|
|
|
6
6
|
local ____unit = require("engine.internal.unit")
|
|
7
7
|
local Unit = ____unit.Unit
|
|
8
8
|
local ownerByItem = setmetatable({}, {__mode = "kv"})
|
|
9
|
-
Unit.itemPickedUpEvent:addListener(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
Unit.itemPickedUpEvent:addListener(
|
|
10
|
+
4,
|
|
11
|
+
function(unit, item)
|
|
12
|
+
ownerByItem[item] = unit
|
|
13
|
+
end
|
|
14
|
+
)
|
|
15
|
+
Unit.itemDroppedEvent:addListener(
|
|
16
|
+
4,
|
|
17
|
+
function(unit, item)
|
|
18
|
+
ownerByItem[item] = nil
|
|
19
|
+
end
|
|
20
|
+
)
|
|
15
21
|
__TS__ObjectDefineProperty(
|
|
16
22
|
Item.prototype,
|
|
17
23
|
"owner",
|