warscript 0.0.1-dev.eda504c → 0.0.1-dev.ee6e396
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +57 -14
- package/core/types/tileCell.d.ts +2 -1
- package/core/types/tileCell.lua +5 -0
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +10 -2
- package/engine/behavior.lua +157 -76
- package/engine/behaviour/ability/apply-buff.lua +4 -4
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability.d.ts +6 -1
- package/engine/behaviour/ability.lua +31 -1
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -5
- package/engine/behaviour/unit/stun-immunity.lua +6 -5
- package/engine/behaviour/unit.d.ts +7 -3
- package/engine/behaviour/unit.lua +101 -24
- package/engine/buff.d.ts +19 -4
- package/engine/buff.lua +122 -41
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +10 -0
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit-missile-launch.lua +16 -6
- package/engine/internal/unit.d.ts +13 -19
- package/engine/internal/unit.lua +140 -173
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -0
- package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/destructible-type.d.ts +27 -1
- package/engine/object-data/entry/destructible-type.lua +155 -0
- package/engine/object-data/entry/unit-type.d.ts +4 -0
- package/engine/object-data/entry/unit-type.lua +76 -32
- package/engine/object-field/unit.d.ts +20 -5
- package/engine/object-field/unit.lua +61 -0
- package/engine/object-field.d.ts +9 -1
- package/engine/object-field.lua +265 -122
- package/engine/standard/fields/ability.d.ts +2 -2
- package/engine/standard/fields/ability.lua +2 -2
- package/engine/standard/fields/unit.d.ts +11 -3
- package/engine/standard/fields/unit.lua +15 -2
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.lua +2 -1
- package/engine/unit.d.ts +5 -0
- package/engine/unit.lua +5 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +9 -7
- package/package.json +2 -2
- package/patch-lua.lua +15 -0
- package/utility/linked-map.d.ts +34 -0
- package/utility/linked-map.lua +101 -0
- package/utility/linked-set.d.ts +3 -1
- package/utility/linked-set.lua +38 -0
- package/utility/records.lua +20 -1
|
@@ -27,7 +27,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
27
27
|
constructorOrTypeIdOrTypeIds,
|
|
28
28
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
29
29
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
30
|
-
|
|
30
|
+
self,
|
|
31
31
|
resistanceTypeOrPolarityOrParameters
|
|
32
32
|
)
|
|
33
33
|
end
|
|
@@ -39,7 +39,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
39
39
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
40
40
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
41
41
|
resistanceTypeOrPolarityOrParameters,
|
|
42
|
-
|
|
42
|
+
self,
|
|
43
43
|
parametersOrResistanceType
|
|
44
44
|
)
|
|
45
45
|
end
|
|
@@ -50,7 +50,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
50
50
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
51
51
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
52
52
|
resistanceTypeOrPolarityOrParameters,
|
|
53
|
-
|
|
53
|
+
self,
|
|
54
54
|
parametersOrResistanceType
|
|
55
55
|
)
|
|
56
56
|
end
|
|
@@ -62,7 +62,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
62
62
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
63
63
|
resistanceTypeOrPolarityOrParameters,
|
|
64
64
|
parametersOrResistanceType,
|
|
65
|
-
|
|
65
|
+
self,
|
|
66
66
|
parameters
|
|
67
67
|
)
|
|
68
68
|
end
|
|
@@ -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
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Behavior } from "../behavior";
|
|
3
|
-
import { Unit } from "../unit";
|
|
3
|
+
import { Unit } from "../internal/unit";
|
|
4
|
+
import "../internal/unit/ability";
|
|
4
5
|
import { Ability } from "../internal/ability";
|
|
5
6
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
6
7
|
import { Widget } from "../../core/types/widget";
|
|
@@ -35,6 +36,10 @@ export declare abstract class AbilityBehavior<Parameters extends {
|
|
|
35
36
|
]): void;
|
|
36
37
|
private static MissileLaunchConfig;
|
|
37
38
|
private get missileLaunchConfig();
|
|
39
|
+
protected launchMissile(source: Unit, ...args: [
|
|
40
|
+
...pointOrWidget: [x: number, y: number] | [widget: Unit /** TODO: support Widget */],
|
|
41
|
+
...parameters: NonNullable<Parameters["missileParameters"]>
|
|
42
|
+
]): void;
|
|
38
43
|
protected onCreate(): void;
|
|
39
44
|
onValueChange(_value: ReadonlySubscribableAbilityDependentValue<string | number | boolean>): void;
|
|
40
45
|
onMissileArrival(...parameters: NonNullable<Parameters["missileParameters"]>): void;
|
|
@@ -7,8 +7,9 @@ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
|
7
7
|
local ____exports = {}
|
|
8
8
|
local ____behavior = require("engine.behavior")
|
|
9
9
|
local Behavior = ____behavior.Behavior
|
|
10
|
-
local ____unit = require("engine.unit")
|
|
10
|
+
local ____unit = require("engine.internal.unit")
|
|
11
11
|
local Unit = ____unit.Unit
|
|
12
|
+
require("engine.internal.unit.ability")
|
|
12
13
|
local ____ability = require("engine.internal.ability")
|
|
13
14
|
local Ability = ____ability.Ability
|
|
14
15
|
local ____effect = require("core.types.effect")
|
|
@@ -29,7 +30,14 @@ local ____ability = require("engine.object-field.ability")
|
|
|
29
30
|
local AbilityField = ____ability.AbilityField
|
|
30
31
|
local AbilityLevelField = ____ability.AbilityLevelField
|
|
31
32
|
local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
|
|
33
|
+
local ____missile = require("core.types.missile")
|
|
34
|
+
local Missile = ____missile.Missile
|
|
32
35
|
local createBehaviorFunctionsByAbilityTypeId = {}
|
|
36
|
+
local function invokeOnMissileArrival(_missile, success, abilityBehavior, ...)
|
|
37
|
+
if success then
|
|
38
|
+
abilityBehavior:onMissileArrival(...)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
33
41
|
local exclusiveOnImpactHandlerAbilityBehaviorByAbility = setmetatable({}, {__mode = "k"})
|
|
34
42
|
local function createUnitEventListener(key)
|
|
35
43
|
return function(unit, ability, ...)
|
|
@@ -159,6 +167,28 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrParame
|
|
|
159
167
|
)
|
|
160
168
|
end
|
|
161
169
|
end
|
|
170
|
+
function AbilityBehavior.prototype.launchMissile(self, source, xOrWidget, yOrParameter, ...)
|
|
171
|
+
if type(xOrWidget) ~= "number" then
|
|
172
|
+
Missile:launch(
|
|
173
|
+
self.missileLaunchConfig,
|
|
174
|
+
source,
|
|
175
|
+
xOrWidget,
|
|
176
|
+
invokeOnMissileArrival,
|
|
177
|
+
self,
|
|
178
|
+
yOrParameter,
|
|
179
|
+
...
|
|
180
|
+
)
|
|
181
|
+
else
|
|
182
|
+
Missile:launch(
|
|
183
|
+
self.missileLaunchConfig,
|
|
184
|
+
source,
|
|
185
|
+
vec2(xOrWidget, yOrParameter),
|
|
186
|
+
invokeOnMissileArrival,
|
|
187
|
+
self,
|
|
188
|
+
...
|
|
189
|
+
)
|
|
190
|
+
end
|
|
191
|
+
end
|
|
162
192
|
function AbilityBehavior.prototype.onCreate(self)
|
|
163
193
|
end
|
|
164
194
|
function AbilityBehavior.prototype.onValueChange(self, _value)
|
|
@@ -4,16 +4,18 @@ import { Unit } from "../../unit";
|
|
|
4
4
|
import { BuffTypeId } from "../../object-data/entry/buff-type";
|
|
5
5
|
import { TextTagPreset } from "../../text-tag";
|
|
6
6
|
import { Destructor } from "../../../destroyable";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { BehaviorPriority } from "../../behavior";
|
|
8
|
+
export type StunImmunityUnitBehaviorParameters = {
|
|
9
|
+
readonly priority?: BehaviorPriority;
|
|
10
|
+
buffTypeIds?: readonly BuffTypeId[];
|
|
9
11
|
textTagPreset?: TextTagPreset;
|
|
10
12
|
textTagText?: string;
|
|
11
13
|
additionalAction?: (this: void, unit: Unit) => void;
|
|
12
14
|
};
|
|
13
15
|
export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
14
|
-
readonly parameters: Readonly<
|
|
15
|
-
static defaultParameters:
|
|
16
|
-
constructor(unit: Unit, parameters?: Readonly<
|
|
16
|
+
readonly parameters: Readonly<StunImmunityUnitBehaviorParameters>;
|
|
17
|
+
static defaultParameters: StunImmunityUnitBehaviorParameters;
|
|
18
|
+
constructor(unit: Unit, parameters?: Readonly<StunImmunityUnitBehaviorParameters>);
|
|
17
19
|
protected onDestroy(): Destructor;
|
|
18
20
|
onDamageReceived(): void;
|
|
19
21
|
onTargetingAbilityChannelingStart(): void;
|
|
@@ -8,14 +8,15 @@ local UnitBehavior = ____unit.UnitBehavior
|
|
|
8
8
|
local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
|
|
9
9
|
local AbilityType = ____ability_2Dtype.AbilityType
|
|
10
10
|
local ____arrays = require("utility.arrays")
|
|
11
|
-
local
|
|
11
|
+
local distinct = ____arrays.distinct
|
|
12
|
+
local flatMap = ____arrays.flatMap
|
|
12
13
|
local map = ____arrays.map
|
|
13
14
|
local ____text_2Dtag = require("engine.text-tag")
|
|
14
15
|
local TextTag = ____text_2Dtag.TextTag
|
|
15
16
|
local ____timer = require("core.types.timer")
|
|
16
17
|
local Timer = ____timer.Timer
|
|
17
18
|
local DEFAULT_BUFF_TYPE_IDS = postcompile(function()
|
|
18
|
-
return
|
|
19
|
+
return distinct(flatMap(
|
|
19
20
|
AbilityType:getAllByBaseIds(map({
|
|
20
21
|
"AHtb",
|
|
21
22
|
"AHbh",
|
|
@@ -41,11 +42,11 @@ local DEFAULT_BUFF_TYPE_IDS = postcompile(function()
|
|
|
41
42
|
"ACcb"
|
|
42
43
|
}, fourCC)),
|
|
43
44
|
function(abilityType) return __TS__ArrayFlat(abilityType.buffTypeIds) end
|
|
44
|
-
)
|
|
45
|
+
))
|
|
45
46
|
end)
|
|
46
47
|
local function process(behavior)
|
|
47
48
|
local hasRemovedBuffs = false
|
|
48
|
-
for buffTypeId in
|
|
49
|
+
for ____, buffTypeId in ipairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
|
|
49
50
|
hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
|
|
50
51
|
end
|
|
51
52
|
if hasRemovedBuffs then
|
|
@@ -67,7 +68,7 @@ function StunImmunityUnitBehavior.prototype.____constructor(self, unit, paramete
|
|
|
67
68
|
if parameters == nil then
|
|
68
69
|
parameters = ____exports.StunImmunityUnitBehavior.defaultParameters
|
|
69
70
|
end
|
|
70
|
-
UnitBehavior.prototype.____constructor(self, unit)
|
|
71
|
+
UnitBehavior.prototype.____constructor(self, unit, parameters.priority)
|
|
71
72
|
self.parameters = parameters
|
|
72
73
|
unit:decrementStunCounter()
|
|
73
74
|
process(self)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import { Behavior } from "../behavior";
|
|
2
|
+
import { Behavior, BehaviorPriority } from "../behavior";
|
|
3
3
|
import { Ability } from "../internal/ability";
|
|
4
4
|
import { DamageEvent, DamagingEvent, Unit } from "../internal/unit";
|
|
5
5
|
import "../internal/unit+ability";
|
|
6
6
|
import "../internal/unit-missile-launch";
|
|
7
7
|
import { Item } from "../internal/item";
|
|
8
|
-
import
|
|
8
|
+
import { AbilityBehavior } from "./ability";
|
|
9
9
|
import { Event } from "../../event";
|
|
10
10
|
import { Destructor } from "../../destroyable";
|
|
11
11
|
import type { Widget } from "../../core/types/widget";
|
|
@@ -13,15 +13,17 @@ import { Destructable } from "../../core/types/destructable";
|
|
|
13
13
|
import type { Buff } from "../buff";
|
|
14
14
|
import { UnitBonusType } from "../internal/unit/bonus";
|
|
15
15
|
import { Player } from "../../core/types/player";
|
|
16
|
+
import { UnitTypeId } from "../object-data/entry/unit-type";
|
|
16
17
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
17
18
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
18
19
|
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
19
20
|
private _bonusIdByBonusType?;
|
|
20
|
-
constructor(unit: Unit);
|
|
21
|
+
constructor(unit: Unit, priority?: BehaviorPriority);
|
|
21
22
|
protected onDestroy(): Destructor;
|
|
22
23
|
get unit(): Unit;
|
|
23
24
|
protected getUnitBonus(bonusType: UnitBonusType): number;
|
|
24
25
|
protected addOrUpdateOrRemoveUnitBonus(bonusType: UnitBonusType, value: number): void;
|
|
26
|
+
protected registerOwningPlayerEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractPlayer: (...args: Args) => Player | undefined, listener: T): void;
|
|
25
27
|
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;
|
|
26
28
|
onImmediateOrder(orderId: number): void;
|
|
27
29
|
onTargetOrder(orderId: number, target: Widget): void;
|
|
@@ -49,6 +51,7 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
49
51
|
onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
|
|
50
52
|
onTargetingAbilityImpact(ability: Ability, source: Unit): void;
|
|
51
53
|
onBuffGained(buff: Buff): void;
|
|
54
|
+
onBuffLost(buff: Buff): void;
|
|
52
55
|
onItemDropped(item: Item): void;
|
|
53
56
|
onItemPickedUp(item: Item): void;
|
|
54
57
|
onItemUsed(item: Item): void;
|
|
@@ -57,4 +60,5 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
57
60
|
onKill(target: Unit): void;
|
|
58
61
|
onDeath(source: Unit | undefined): void;
|
|
59
62
|
onOwnerChange(previousOwner: Player): void;
|
|
63
|
+
static bindUnitType<Args extends any[]>(this: UnitBehaviorConstructor<Args>, unitTypeId: UnitTypeId, ...args: Args): void;
|
|
60
64
|
}
|
|
@@ -21,36 +21,56 @@ local ____bonus = require("engine.internal.unit.bonus")
|
|
|
21
21
|
local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
|
|
22
22
|
local getUnitBonus = ____bonus.getUnitBonus
|
|
23
23
|
local removeUnitBonus = ____bonus.removeUnitBonus
|
|
24
|
+
local ____linked_2Dmap = require("utility.linked-map")
|
|
25
|
+
local LinkedMap = ____linked_2Dmap.LinkedMap
|
|
24
26
|
local safeCall = warpack.safeCall
|
|
25
|
-
local
|
|
26
|
-
local
|
|
27
|
-
local
|
|
28
|
-
local
|
|
27
|
+
local createBehaviorFunctionsByUnitTypeId = {}
|
|
28
|
+
local behaviorsByOwningPlayerEvent = {}
|
|
29
|
+
local listenerByBehaviorByOwningPlayerEvent = {}
|
|
30
|
+
local owningPlayerEventsByBehavior = {}
|
|
31
|
+
local behaviorsByInRangeUnitEvent = {}
|
|
32
|
+
local rangeByBehaviorByInRangeUnitEvent = {}
|
|
33
|
+
local listenerByBehaviorByInRangeUnitEvent = {}
|
|
34
|
+
local inRangeUnitEventsByBehavior = {}
|
|
29
35
|
____exports.UnitBehavior = __TS__Class()
|
|
30
36
|
local UnitBehavior = ____exports.UnitBehavior
|
|
31
37
|
UnitBehavior.name = "UnitBehavior"
|
|
32
38
|
__TS__ClassExtends(UnitBehavior, Behavior)
|
|
33
|
-
function UnitBehavior.prototype.____constructor(self, unit)
|
|
34
|
-
Behavior.prototype.____constructor(self, unit)
|
|
39
|
+
function UnitBehavior.prototype.____constructor(self, unit, priority)
|
|
40
|
+
Behavior.prototype.____constructor(self, unit, priority)
|
|
35
41
|
end
|
|
36
42
|
function UnitBehavior.prototype.onDestroy(self)
|
|
37
|
-
local
|
|
38
|
-
if
|
|
39
|
-
for event in pairs(
|
|
40
|
-
local ____opt_0 =
|
|
43
|
+
local owningPlayerEvents = owningPlayerEventsByBehavior[self]
|
|
44
|
+
if owningPlayerEvents ~= nil then
|
|
45
|
+
for event in pairs(owningPlayerEvents) do
|
|
46
|
+
local ____opt_0 = behaviorsByOwningPlayerEvent[event]
|
|
41
47
|
if ____opt_0 ~= nil then
|
|
42
48
|
____opt_0:remove(self)
|
|
43
49
|
end
|
|
44
|
-
local ____opt_2 =
|
|
50
|
+
local ____opt_2 = listenerByBehaviorByOwningPlayerEvent[event]
|
|
45
51
|
if ____opt_2 ~= nil then
|
|
46
52
|
____opt_2[self] = nil
|
|
47
53
|
end
|
|
48
|
-
|
|
54
|
+
end
|
|
55
|
+
owningPlayerEventsByBehavior[self] = nil
|
|
56
|
+
end
|
|
57
|
+
local inRangeUnitEvents = inRangeUnitEventsByBehavior[self]
|
|
58
|
+
if inRangeUnitEvents ~= nil then
|
|
59
|
+
for event in pairs(inRangeUnitEvents) do
|
|
60
|
+
local ____opt_4 = behaviorsByInRangeUnitEvent[event]
|
|
49
61
|
if ____opt_4 ~= nil then
|
|
50
|
-
____opt_4
|
|
62
|
+
____opt_4:remove(self)
|
|
63
|
+
end
|
|
64
|
+
local ____opt_6 = rangeByBehaviorByInRangeUnitEvent[event]
|
|
65
|
+
if ____opt_6 ~= nil then
|
|
66
|
+
____opt_6[self] = nil
|
|
67
|
+
end
|
|
68
|
+
local ____opt_8 = listenerByBehaviorByInRangeUnitEvent[event]
|
|
69
|
+
if ____opt_8 ~= nil then
|
|
70
|
+
____opt_8[self] = nil
|
|
51
71
|
end
|
|
52
72
|
end
|
|
53
|
-
|
|
73
|
+
inRangeUnitEventsByBehavior[self] = nil
|
|
54
74
|
end
|
|
55
75
|
if self._bonusIdByBonusType ~= nil then
|
|
56
76
|
for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
|
|
@@ -60,28 +80,60 @@ function UnitBehavior.prototype.onDestroy(self)
|
|
|
60
80
|
return Behavior.prototype.onDestroy(self)
|
|
61
81
|
end
|
|
62
82
|
function UnitBehavior.prototype.getUnitBonus(self, bonusType)
|
|
63
|
-
local
|
|
64
|
-
local bonusId =
|
|
83
|
+
local ____opt_10 = self._bonusIdByBonusType
|
|
84
|
+
local bonusId = ____opt_10 and ____opt_10:get(bonusType)
|
|
65
85
|
return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
|
|
66
86
|
end
|
|
67
87
|
function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
|
|
68
88
|
local bonusIdByBonusType = self._bonusIdByBonusType
|
|
69
89
|
if bonusIdByBonusType == nil then
|
|
70
|
-
bonusIdByBonusType =
|
|
90
|
+
bonusIdByBonusType = __TS__New(LinkedMap)
|
|
71
91
|
self._bonusIdByBonusType = bonusIdByBonusType
|
|
72
92
|
end
|
|
73
|
-
bonusIdByBonusType
|
|
93
|
+
bonusIdByBonusType:put(
|
|
94
|
+
bonusType,
|
|
95
|
+
addOrUpdateOrRemoveUnitBonus(
|
|
96
|
+
self.object,
|
|
97
|
+
bonusType,
|
|
98
|
+
bonusIdByBonusType:get(bonusType),
|
|
99
|
+
value
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
end
|
|
103
|
+
function UnitBehavior.prototype.registerOwningPlayerEvent(self, event, extractPlayer, listener)
|
|
104
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByOwningPlayerEvent, event, mutableLuaMap)
|
|
105
|
+
listenerByBehavior[self] = listener
|
|
106
|
+
getOrPut(inRangeUnitEventsByBehavior, self, mutableLuaSet)[event] = true
|
|
107
|
+
local behaviors = behaviorsByOwningPlayerEvent[event]
|
|
108
|
+
if behaviors == nil then
|
|
109
|
+
event:addListener(function(...)
|
|
110
|
+
local behaviors = behaviorsByOwningPlayerEvent[event]
|
|
111
|
+
if behaviors ~= nil then
|
|
112
|
+
local player = extractPlayer(...)
|
|
113
|
+
if player ~= nil then
|
|
114
|
+
for behavior in pairs(behaviors) do
|
|
115
|
+
if behavior.unit.owner == player then
|
|
116
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end)
|
|
122
|
+
behaviors = __TS__New(LinkedSet)
|
|
123
|
+
behaviorsByOwningPlayerEvent[event] = behaviors
|
|
124
|
+
end
|
|
125
|
+
behaviors:add(self)
|
|
74
126
|
end
|
|
75
127
|
function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
|
|
76
|
-
local rangeByBehavior = getOrPut(
|
|
128
|
+
local rangeByBehavior = getOrPut(rangeByBehaviorByInRangeUnitEvent, event, mutableLuaMap)
|
|
77
129
|
rangeByBehavior[self] = range
|
|
78
|
-
local listenerByBehavior = getOrPut(
|
|
130
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByInRangeUnitEvent, event, mutableLuaMap)
|
|
79
131
|
listenerByBehavior[self] = listener
|
|
80
|
-
getOrPut(
|
|
81
|
-
local behaviors =
|
|
132
|
+
getOrPut(inRangeUnitEventsByBehavior, self, mutableLuaSet)[event] = true
|
|
133
|
+
local behaviors = behaviorsByInRangeUnitEvent[event]
|
|
82
134
|
if behaviors == nil then
|
|
83
135
|
event:addListener(function(...)
|
|
84
|
-
local behaviors =
|
|
136
|
+
local behaviors = behaviorsByInRangeUnitEvent[event]
|
|
85
137
|
if behaviors ~= nil then
|
|
86
138
|
local unit = extractUnit(...)
|
|
87
139
|
if unit ~= nil then
|
|
@@ -95,7 +147,7 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUni
|
|
|
95
147
|
end
|
|
96
148
|
end)
|
|
97
149
|
behaviors = __TS__New(LinkedSet)
|
|
98
|
-
|
|
150
|
+
behaviorsByInRangeUnitEvent[event] = behaviors
|
|
99
151
|
end
|
|
100
152
|
behaviors:add(self)
|
|
101
153
|
end
|
|
@@ -151,6 +203,8 @@ function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
|
|
|
151
203
|
end
|
|
152
204
|
function UnitBehavior.prototype.onBuffGained(self, buff)
|
|
153
205
|
end
|
|
206
|
+
function UnitBehavior.prototype.onBuffLost(self, buff)
|
|
207
|
+
end
|
|
154
208
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
155
209
|
end
|
|
156
210
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
|
@@ -167,6 +221,21 @@ function UnitBehavior.prototype.onDeath(self, source)
|
|
|
167
221
|
end
|
|
168
222
|
function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
|
|
169
223
|
end
|
|
224
|
+
function UnitBehavior.bindUnitType(self, unitTypeId, ...)
|
|
225
|
+
local args = {...}
|
|
226
|
+
local createBehaviorFunctions = createBehaviorFunctionsByUnitTypeId[unitTypeId]
|
|
227
|
+
if createBehaviorFunctions == nil then
|
|
228
|
+
createBehaviorFunctions = {}
|
|
229
|
+
createBehaviorFunctionsByUnitTypeId[unitTypeId] = createBehaviorFunctions
|
|
230
|
+
end
|
|
231
|
+
createBehaviorFunctions[#createBehaviorFunctions + 1] = function(unit)
|
|
232
|
+
return __TS__New(
|
|
233
|
+
self,
|
|
234
|
+
unit,
|
|
235
|
+
table.unpack(args)
|
|
236
|
+
)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
170
239
|
__TS__SetDescriptor(
|
|
171
240
|
UnitBehavior.prototype,
|
|
172
241
|
"unit",
|
|
@@ -282,6 +351,14 @@ __TS__SetDescriptor(
|
|
|
282
351
|
____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
|
|
283
352
|
end)
|
|
284
353
|
end)(UnitBehavior)
|
|
354
|
+
Unit.onCreate:addListener(function(unit)
|
|
355
|
+
local createBehaviorFunctions = createBehaviorFunctionsByUnitTypeId[unit.typeId]
|
|
356
|
+
if createBehaviorFunctions ~= nil then
|
|
357
|
+
for ____, createBehavior in ipairs(createBehaviorFunctions) do
|
|
358
|
+
createBehavior(unit)
|
|
359
|
+
end
|
|
360
|
+
end
|
|
361
|
+
end)
|
|
285
362
|
Unit.destroyEvent:addListener(function(unit)
|
|
286
363
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
|
287
364
|
end)
|
package/engine/buff.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { UnitBehavior } from "./behaviour/unit";
|
|
|
13
13
|
import type { Widget } from "../core/types/widget";
|
|
14
14
|
import { Destructor } from "../destroyable";
|
|
15
15
|
import { Event } from "../event";
|
|
16
|
+
import { AbilityBehavior } from "./behaviour/ability";
|
|
16
17
|
export type BuffConstructor<T extends Buff<any> = Buff<any>, Args extends any[] = any> = OmitConstructor<typeof Buff<any>> & (new (...args: Args) => T);
|
|
17
18
|
type EnumParameterValueType<T extends number> = T | AbilityEnumLevelField<T>;
|
|
18
19
|
type NumberParameterValueType = number | AbilityNumberField | AbilityNumberLevelField;
|
|
@@ -30,8 +31,10 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
30
31
|
source?: Unit;
|
|
31
32
|
behaviorConstructors?: (new (unit: Unit) => UnitBehavior)[];
|
|
32
33
|
abilityTypeIds?: Record<AbilityTypeId, {
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
readonly fields?: [
|
|
35
|
+
AbilityNumberField | AbilityNumberLevelField,
|
|
36
|
+
NumberParameterValueType
|
|
37
|
+
][];
|
|
35
38
|
/** Default `true`. */
|
|
36
39
|
readonly isButtonVisible?: boolean;
|
|
37
40
|
/** Default is the level of the source ability or 0 if it is absent. */
|
|
@@ -56,6 +59,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
56
59
|
armorIncreaseFactor?: NumberParameterValueType;
|
|
57
60
|
attackSpeedIncreaseFactor?: NumberParameterValueType;
|
|
58
61
|
movementSpeedIncreaseFactor?: NumberParameterValueType;
|
|
62
|
+
manaRegenerationRateIncreaseFactor?: NumberParameterValueType;
|
|
59
63
|
evasionProbability?: NumberParameterValueType;
|
|
60
64
|
missProbability?: NumberParameterValueType;
|
|
61
65
|
damageFactor?: NumberParameterValueType;
|
|
@@ -79,6 +83,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
79
83
|
healingOnExpiration?: NumberParameterValueType;
|
|
80
84
|
killsOnExpiration?: BooleanParameterValueType;
|
|
81
85
|
explodesOnExpiration?: BooleanParameterValueType;
|
|
86
|
+
abilityCooldownFactor?: NumberParameterValueType;
|
|
82
87
|
uniqueGroup?: BuffUniqueGroup;
|
|
83
88
|
} : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
|
|
84
89
|
declare const enum BuffPropertyKey {
|
|
@@ -124,7 +129,9 @@ declare const enum BuffPropertyKey {
|
|
|
124
129
|
PROVIDES_INVULNERABILITY = 139,
|
|
125
130
|
KILLS_ON_EXPIRATION = 140,
|
|
126
131
|
EXPLODES_ON_EXPIRATION = 141,
|
|
127
|
-
MISS_PROBABILITY = 142
|
|
132
|
+
MISS_PROBABILITY = 142,
|
|
133
|
+
ABILITY_COOLDOWN_FACTOR = 143,
|
|
134
|
+
ABILITY_COOLDOWN_MODIFIER = 144
|
|
128
135
|
}
|
|
129
136
|
export declare const enum BuffTypeIdSelectionPolicy {
|
|
130
137
|
LEAST_DURATION = 0
|
|
@@ -138,7 +145,7 @@ export type BuffConstructorParameters<AdditionalParameters extends BuffAdditiona
|
|
|
138
145
|
polarity: BuffPolarityParameterType,
|
|
139
146
|
resistanceType: BuffResistanceTypeParameterType,
|
|
140
147
|
...abilityOrParameters: [
|
|
141
|
-
ability?: Ability,
|
|
148
|
+
ability?: Ability | AbilityBehavior,
|
|
142
149
|
parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
|
|
143
150
|
] | [parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>]
|
|
144
151
|
];
|
|
@@ -187,6 +194,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
187
194
|
private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
|
|
188
195
|
private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
|
|
189
196
|
private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
|
|
197
|
+
private [BuffPropertyKey.ABILITY_COOLDOWN_FACTOR]?;
|
|
198
|
+
private [BuffPropertyKey.ABILITY_COOLDOWN_MODIFIER]?;
|
|
190
199
|
protected static readonly defaultParameters: BuffParameters;
|
|
191
200
|
get source(): Unit;
|
|
192
201
|
readonly typeId: ApplicableBuffTypeId;
|
|
@@ -259,9 +268,15 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
259
268
|
set movementSpeedIncreaseFactor(movementSpeedIncreaseFactor: number);
|
|
260
269
|
get evasionProbability(): number;
|
|
261
270
|
set evasionProbability(evasionProbability: number);
|
|
271
|
+
get manaRegenerationRateIncreaseFactor(): number;
|
|
272
|
+
set manaRegenerationRateIncreaseFactor(manaRegenerationRateIncreaseFactor: number);
|
|
262
273
|
get duration(): number;
|
|
263
274
|
get remainingDuration(): number;
|
|
264
275
|
set remainingDuration(remainingDuration: number);
|
|
276
|
+
get abilityCooldownFactor(): number;
|
|
277
|
+
set abilityCooldownFactor(abilityCooldownFactor: number);
|
|
278
|
+
onAbilityGained(ability: Ability): void;
|
|
279
|
+
onAbilityLost(ability: Ability): void;
|
|
265
280
|
flashEffect(...parameters: [
|
|
266
281
|
...widgetOrXY: [] | [Widget] | [x: number, x: number],
|
|
267
282
|
...parametersOrDuration: [] | [EffectParameters] | [number]
|