warscript 0.0.1-dev.d5f6f38 → 0.0.1-dev.e1acea3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/types/effect.lua +2 -2
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +29 -0
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -19
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +18 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +13 -0
- package/engine/behaviour/ability/remove-buffs.lua +22 -0
- package/engine/behaviour/ability.d.ts +7 -3
- package/engine/behaviour/ability.lua +35 -34
- package/engine/buff.lua +1 -1
- package/engine/internal/ability.d.ts +2 -1
- package/engine/internal/ability.lua +10 -2
- package/engine/internal/unit/ability.d.ts +10 -1
- package/engine/internal/unit/ability.lua +36 -0
- package/engine/object-field/ability.d.ts +2 -2
- package/package.json +1 -1
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
package/core/types/effect.lua
CHANGED
|
@@ -41,10 +41,10 @@ local function setSpecialEffectPitchDegrees(effect, pitch)
|
|
|
41
41
|
-mathRad(pitch)
|
|
42
42
|
)
|
|
43
43
|
end
|
|
44
|
-
local function setSpecialEffectRollDegrees(effect,
|
|
44
|
+
local function setSpecialEffectRollDegrees(effect, roll)
|
|
45
45
|
setSpecialEffectRoll(
|
|
46
46
|
effect,
|
|
47
|
-
-mathRad(
|
|
47
|
+
-mathRad(roll)
|
|
48
48
|
)
|
|
49
49
|
end
|
|
50
50
|
local animTypeByAnimationName = {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____ability = require("engine.behaviour.ability")
|
|
6
|
+
local AbilityBehavior = ____ability.AbilityBehavior
|
|
7
|
+
local ____ability = require("engine.standard.fields.ability")
|
|
8
|
+
local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
|
|
9
|
+
local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTEGER_LEVEL_FIELD
|
|
10
|
+
____exports.EmulateImpactAbilityBehavior = __TS__Class()
|
|
11
|
+
local EmulateImpactAbilityBehavior = ____exports.EmulateImpactAbilityBehavior
|
|
12
|
+
EmulateImpactAbilityBehavior.name = "EmulateImpactAbilityBehavior"
|
|
13
|
+
__TS__ClassExtends(EmulateImpactAbilityBehavior, AbilityBehavior)
|
|
14
|
+
function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
15
|
+
local abilityTypeId = self.ability.typeId
|
|
16
|
+
local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
|
|
17
|
+
local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
|
|
18
|
+
if caster:getAbilityRemainingCooldown(abilityTypeId) ~= 0 or caster.mana < manaCost then
|
|
19
|
+
return
|
|
20
|
+
end
|
|
21
|
+
caster.mana = caster.mana - manaCost
|
|
22
|
+
if cooldown == 0 then
|
|
23
|
+
caster:interruptCast(self.ability.typeId)
|
|
24
|
+
else
|
|
25
|
+
caster:startAbilityCooldown(self.ability.typeId, cooldown)
|
|
26
|
+
end
|
|
27
|
+
AbilityBehavior:forAll(self.ability, "onImpact", caster)
|
|
28
|
+
end
|
|
29
|
+
return ____exports
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import { AbilityBehavior } from "../ability";
|
|
3
2
|
import { Unit } from "../../internal/unit";
|
|
4
|
-
|
|
3
|
+
import { EmulateImpactAbilityBehavior } from "./emulate-impact";
|
|
4
|
+
export declare class InstantImpactAbilityBehavior extends EmulateImpactAbilityBehavior {
|
|
5
5
|
onCastingStart(caster: Unit): void;
|
|
6
6
|
}
|
|
@@ -2,28 +2,13 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
4
|
local ____exports = {}
|
|
5
|
-
local
|
|
6
|
-
local
|
|
7
|
-
local ____ability = require("engine.standard.fields.ability")
|
|
8
|
-
local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
|
|
9
|
-
local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTEGER_LEVEL_FIELD
|
|
5
|
+
local ____emulate_2Dimpact = require("engine.behaviour.ability.emulate-impact")
|
|
6
|
+
local EmulateImpactAbilityBehavior = ____emulate_2Dimpact.EmulateImpactAbilityBehavior
|
|
10
7
|
____exports.InstantImpactAbilityBehavior = __TS__Class()
|
|
11
8
|
local InstantImpactAbilityBehavior = ____exports.InstantImpactAbilityBehavior
|
|
12
9
|
InstantImpactAbilityBehavior.name = "InstantImpactAbilityBehavior"
|
|
13
|
-
__TS__ClassExtends(InstantImpactAbilityBehavior,
|
|
10
|
+
__TS__ClassExtends(InstantImpactAbilityBehavior, EmulateImpactAbilityBehavior)
|
|
14
11
|
function InstantImpactAbilityBehavior.prototype.onCastingStart(self, caster)
|
|
15
|
-
|
|
16
|
-
local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
|
|
17
|
-
local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
|
|
18
|
-
if caster:getAbilityRemainingCooldown(abilityTypeId) ~= 0 or caster.mana < manaCost then
|
|
19
|
-
return
|
|
20
|
-
end
|
|
21
|
-
caster.mana = caster.mana - manaCost
|
|
22
|
-
if cooldown == 0 then
|
|
23
|
-
caster:interruptCast(self.ability.typeId)
|
|
24
|
-
else
|
|
25
|
-
caster:startAbilityCooldown(self.ability.typeId, cooldown)
|
|
26
|
-
end
|
|
27
|
-
AbilityBehavior:forAll(self.ability, "onImpact", caster)
|
|
12
|
+
self:emulateImpact(caster)
|
|
28
13
|
end
|
|
29
14
|
return ____exports
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Unit } from "../../internal/unit";
|
|
3
|
+
import { EmulateImpactAbilityBehavior } from "./emulate-impact";
|
|
4
|
+
import { Ability } from "../../internal/ability";
|
|
5
|
+
export declare class OnCommandImpactAbilityBehavior extends EmulateImpactAbilityBehavior {
|
|
6
|
+
constructor(ability: Ability);
|
|
7
|
+
onCommand(caster: Unit): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____emulate_2Dimpact = require("engine.behaviour.ability.emulate-impact")
|
|
6
|
+
local EmulateImpactAbilityBehavior = ____emulate_2Dimpact.EmulateImpactAbilityBehavior
|
|
7
|
+
____exports.OnCommandImpactAbilityBehavior = __TS__Class()
|
|
8
|
+
local OnCommandImpactAbilityBehavior = ____exports.OnCommandImpactAbilityBehavior
|
|
9
|
+
OnCommandImpactAbilityBehavior.name = "OnCommandImpactAbilityBehavior"
|
|
10
|
+
__TS__ClassExtends(OnCommandImpactAbilityBehavior, EmulateImpactAbilityBehavior)
|
|
11
|
+
function OnCommandImpactAbilityBehavior.prototype.____constructor(self, ability)
|
|
12
|
+
EmulateImpactAbilityBehavior.prototype.____constructor(self, ability)
|
|
13
|
+
self:registerCommandEvent()
|
|
14
|
+
end
|
|
15
|
+
function OnCommandImpactAbilityBehavior.prototype.onCommand(self, caster)
|
|
16
|
+
self:emulateImpact(caster)
|
|
17
|
+
end
|
|
18
|
+
return ____exports
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { AbilityBehavior } from "../ability";
|
|
3
|
+
import { Unit } from "../../internal/unit";
|
|
4
|
+
import { Ability } from "../../internal/ability";
|
|
5
|
+
import { AbilityDependentValue } from "../../object-field/ability";
|
|
6
|
+
import { BuffPolarity } from "../../object-data/auxiliary/buff-polarity";
|
|
7
|
+
import { BuffResistanceType } from "../../object-data/auxiliary/buff-resistance-type";
|
|
8
|
+
export declare class RemoveBuffsSelfAbilityBehavior extends AbilityBehavior {
|
|
9
|
+
private readonly polarity?;
|
|
10
|
+
private readonly resistanceType?;
|
|
11
|
+
constructor(ability: Ability, polarity?: AbilityDependentValue<BuffPolarity> | undefined, resistanceType?: AbilityDependentValue<BuffResistanceType> | undefined);
|
|
12
|
+
onImpact(caster: Unit): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____ability = require("engine.behaviour.ability")
|
|
6
|
+
local AbilityBehavior = ____ability.AbilityBehavior
|
|
7
|
+
____exports.RemoveBuffsSelfAbilityBehavior = __TS__Class()
|
|
8
|
+
local RemoveBuffsSelfAbilityBehavior = ____exports.RemoveBuffsSelfAbilityBehavior
|
|
9
|
+
RemoveBuffsSelfAbilityBehavior.name = "RemoveBuffsSelfAbilityBehavior"
|
|
10
|
+
__TS__ClassExtends(RemoveBuffsSelfAbilityBehavior, AbilityBehavior)
|
|
11
|
+
function RemoveBuffsSelfAbilityBehavior.prototype.____constructor(self, ability, polarity, resistanceType)
|
|
12
|
+
AbilityBehavior.prototype.____constructor(self, ability)
|
|
13
|
+
self.polarity = polarity
|
|
14
|
+
self.resistanceType = resistanceType
|
|
15
|
+
end
|
|
16
|
+
function RemoveBuffsSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
17
|
+
caster:removeBuffs(
|
|
18
|
+
self:resolveCurrentAbilityDependentValue(self.polarity),
|
|
19
|
+
self:resolveCurrentAbilityDependentValue(self.resistanceType)
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
return ____exports
|
|
@@ -9,22 +9,26 @@ import { Destructable } from "../../core/types/destructable";
|
|
|
9
9
|
import { EffectParameters } from "../../core/types/effect";
|
|
10
10
|
import { AbilityDependentValue } from "../object-field/ability";
|
|
11
11
|
export type AbilityBehaviorConstructor<Args extends any[]> = new (ability: Ability, ...args: Args) => AbilityBehavior;
|
|
12
|
+
export type AbilityBehaviorParameters = {
|
|
13
|
+
isExclusiveOnImpactHandler?: boolean;
|
|
14
|
+
};
|
|
12
15
|
export declare abstract class AbilityBehavior<Parameters extends {
|
|
13
16
|
periodicActionParameters?: any[];
|
|
14
17
|
missileParameters?: any[];
|
|
15
18
|
} = {}> extends Behavior<Ability, NonNullable<Parameters["periodicActionParameters"]>> {
|
|
16
|
-
constructor(ability: Ability);
|
|
19
|
+
constructor(ability: Ability, parameters?: AbilityBehaviorParameters);
|
|
20
|
+
protected registerCommandEvent(orderTypeStringId?: string): void;
|
|
17
21
|
get ability(): Ability;
|
|
18
|
-
protected resolveCurrentAbilityDependentValue<T extends boolean | number | string>(value: AbilityDependentValue<T>): T;
|
|
22
|
+
protected resolveCurrentAbilityDependentValue<T extends boolean | number | string | undefined>(value: AbilityDependentValue<T>): T;
|
|
19
23
|
protected flashAreaEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
|
|
20
24
|
protected flashEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
|
|
21
25
|
protected flashSpecialEffect(...args: [...pointOrWidget: [x: number, y: number] | [widget: Widget], duration?: number]): void;
|
|
22
26
|
private static MissileLaunchConfig;
|
|
23
27
|
private get missileLaunchConfig();
|
|
24
|
-
protected launchMissile(source: Unit, target: Unit, ...parameters: NonNullable<Parameters["missileParameters"]>): void;
|
|
25
28
|
onMissileArrival(...parameters: NonNullable<Parameters["missileParameters"]>): void;
|
|
26
29
|
onUnitGainAbility(_unit: Unit): void;
|
|
27
30
|
onUnitLoseAbility(_unit: Unit): void;
|
|
31
|
+
onCommand(caster: Unit, orderTypeStringId: string): void;
|
|
28
32
|
onCastingStart(caster: Unit): void;
|
|
29
33
|
onCastingFinish(caster: Unit): void;
|
|
30
34
|
onChannelingStart(caster: Unit): void;
|
|
@@ -4,6 +4,7 @@ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
6
6
|
local ____exports = {}
|
|
7
|
+
local createUnitEventListener
|
|
7
8
|
local ____behavior = require("engine.behavior")
|
|
8
9
|
local Behavior = ____behavior.Behavior
|
|
9
10
|
local ____unit = require("engine.unit")
|
|
@@ -24,21 +25,27 @@ local ____ability = require("engine.object-field.ability")
|
|
|
24
25
|
local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
|
|
25
26
|
local ____timer = require("core.types.timer")
|
|
26
27
|
local Timer = ____timer.Timer
|
|
27
|
-
local ____missile = require("core.types.missile")
|
|
28
|
-
local Missile = ____missile.Missile
|
|
29
28
|
local createBehaviorFunctionsByAbilityTypeId = {}
|
|
30
|
-
local
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
local exclusiveOnImpactHandlerAbilityBehaviorByAbility = setmetatable({}, {__mode = "k"})
|
|
30
|
+
local function createZeroTimerUnitEventListener(key)
|
|
31
|
+
local unitEventListener = createUnitEventListener(key)
|
|
32
|
+
return function(unit, ability, ...)
|
|
33
|
+
Timer:run(unitEventListener, unit, ability, ...)
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
createUnitEventListener = function(key)
|
|
37
|
+
return function(unit, ability, ...)
|
|
38
|
+
____exports.AbilityBehavior:forAll(ability, key, unit, ...)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
local registeredCommandEventIds = {}
|
|
42
|
+
local ____class_2 = __TS__Class()
|
|
43
|
+
____class_2.name = ""
|
|
44
|
+
function ____class_2.prototype.____constructor(self, abilityBehavior)
|
|
38
45
|
self.abilityBehavior = abilityBehavior
|
|
39
46
|
end
|
|
40
47
|
__TS__SetDescriptor(
|
|
41
|
-
|
|
48
|
+
____class_2.prototype,
|
|
42
49
|
"art",
|
|
43
50
|
{get = function(self)
|
|
44
51
|
return MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.abilityBehavior.ability, 0)
|
|
@@ -46,7 +53,7 @@ __TS__SetDescriptor(
|
|
|
46
53
|
true
|
|
47
54
|
)
|
|
48
55
|
__TS__SetDescriptor(
|
|
49
|
-
|
|
56
|
+
____class_2.prototype,
|
|
50
57
|
"arc",
|
|
51
58
|
{get = function(self)
|
|
52
59
|
return MISSILE_ARC_ABILITY_FLOAT_FIELD:getValue(self.abilityBehavior.ability)
|
|
@@ -54,7 +61,7 @@ __TS__SetDescriptor(
|
|
|
54
61
|
true
|
|
55
62
|
)
|
|
56
63
|
__TS__SetDescriptor(
|
|
57
|
-
|
|
64
|
+
____class_2.prototype,
|
|
58
65
|
"speed",
|
|
59
66
|
{get = function(self)
|
|
60
67
|
return MISSILE_SPEED_ABILITY_INTEGER_FIELD:getValue(self.abilityBehavior.ability)
|
|
@@ -65,8 +72,21 @@ ____exports.AbilityBehavior = __TS__Class()
|
|
|
65
72
|
local AbilityBehavior = ____exports.AbilityBehavior
|
|
66
73
|
AbilityBehavior.name = "AbilityBehavior"
|
|
67
74
|
__TS__ClassExtends(AbilityBehavior, Behavior)
|
|
68
|
-
function AbilityBehavior.prototype.____constructor(self, ability)
|
|
75
|
+
function AbilityBehavior.prototype.____constructor(self, ability, parameters)
|
|
69
76
|
Behavior.prototype.____constructor(self, ability)
|
|
77
|
+
if parameters and parameters.isExclusiveOnImpactHandler then
|
|
78
|
+
exclusiveOnImpactHandlerAbilityBehaviorByAbility[ability] = self
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
function AbilityBehavior.prototype.registerCommandEvent(self, orderTypeStringId)
|
|
82
|
+
if orderTypeStringId == nil then
|
|
83
|
+
orderTypeStringId = self.ability.orderTypeStringId
|
|
84
|
+
end
|
|
85
|
+
local commandEventId = (tostring(self.ability.typeId) .. "#") .. orderTypeStringId
|
|
86
|
+
if not (registeredCommandEventIds[commandEventId] ~= nil) then
|
|
87
|
+
registeredCommandEventIds[commandEventId] = true
|
|
88
|
+
Unit.abilityCommandEvent[self.ability.typeId][orderTypeStringId]:addListener(createUnitEventListener("onCommand"))
|
|
89
|
+
end
|
|
70
90
|
end
|
|
71
91
|
function AbilityBehavior.prototype.resolveCurrentAbilityDependentValue(self, value)
|
|
72
92
|
return resolveCurrentAbilityDependentValue(self.ability, value)
|
|
@@ -104,22 +124,14 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrDurati
|
|
|
104
124
|
)
|
|
105
125
|
end
|
|
106
126
|
end
|
|
107
|
-
function AbilityBehavior.prototype.launchMissile(self, source, target, ...)
|
|
108
|
-
Missile:launch(
|
|
109
|
-
self.missileLaunchConfig,
|
|
110
|
-
source,
|
|
111
|
-
target,
|
|
112
|
-
invokeOnMissileArrival,
|
|
113
|
-
self,
|
|
114
|
-
...
|
|
115
|
-
)
|
|
116
|
-
end
|
|
117
127
|
function AbilityBehavior.prototype.onMissileArrival(self, ...)
|
|
118
128
|
end
|
|
119
129
|
function AbilityBehavior.prototype.onUnitGainAbility(self, _unit)
|
|
120
130
|
end
|
|
121
131
|
function AbilityBehavior.prototype.onUnitLoseAbility(self, _unit)
|
|
122
132
|
end
|
|
133
|
+
function AbilityBehavior.prototype.onCommand(self, caster, orderTypeStringId)
|
|
134
|
+
end
|
|
123
135
|
function AbilityBehavior.prototype.onCastingStart(self, caster)
|
|
124
136
|
end
|
|
125
137
|
function AbilityBehavior.prototype.onCastingFinish(self, caster)
|
|
@@ -179,7 +191,7 @@ __TS__SetDescriptor(
|
|
|
179
191
|
end},
|
|
180
192
|
true
|
|
181
193
|
)
|
|
182
|
-
AbilityBehavior.MissileLaunchConfig =
|
|
194
|
+
AbilityBehavior.MissileLaunchConfig = ____class_2
|
|
183
195
|
__TS__SetDescriptor(
|
|
184
196
|
AbilityBehavior.prototype,
|
|
185
197
|
"missileLaunchConfig",
|
|
@@ -191,17 +203,6 @@ __TS__SetDescriptor(
|
|
|
191
203
|
true
|
|
192
204
|
);
|
|
193
205
|
(function(self)
|
|
194
|
-
local function createUnitEventListener(key)
|
|
195
|
-
return function(unit, ability, ...)
|
|
196
|
-
____exports.AbilityBehavior:forAll(ability, key, unit, ...)
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
local function createZeroTimerUnitEventListener(key)
|
|
200
|
-
local unitEventListener = createUnitEventListener(key)
|
|
201
|
-
return function(unit, ability, ...)
|
|
202
|
-
Timer:run(unitEventListener, unit, ability, ...)
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
206
|
Unit.abilityGainedEvent:addListener(createUnitEventListener("onUnitGainAbility"))
|
|
206
207
|
Unit.abilityLostEvent:addListener(createUnitEventListener("onUnitLoseAbility"))
|
|
207
208
|
Unit.abilityCastingStartEvent:addListener(createUnitEventListener("onCastingStart"))
|
package/engine/buff.lua
CHANGED
|
@@ -515,7 +515,7 @@ function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrPa
|
|
|
515
515
|
)
|
|
516
516
|
local ____isWidgetProvided_38
|
|
517
517
|
if isWidgetProvided then
|
|
518
|
-
____isWidgetProvided_38 =
|
|
518
|
+
____isWidgetProvided_38 = yOrParametersOrDuration
|
|
519
519
|
else
|
|
520
520
|
____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
|
|
521
521
|
end
|
|
@@ -12,7 +12,8 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
12
12
|
protected constructor(handle: jability, typeId: number);
|
|
13
13
|
toString(): string;
|
|
14
14
|
get parentTypeId(): number;
|
|
15
|
-
get
|
|
15
|
+
get orderTypeStringId(): string;
|
|
16
|
+
get orderTypeId(): number;
|
|
16
17
|
abstract readonly owner: Unit | Item;
|
|
17
18
|
getSnapshot(): AbilitySnapshot;
|
|
18
19
|
hasField(field: jabilityfield | number): boolean;
|
|
@@ -296,10 +296,18 @@ __TS__SetDescriptor(
|
|
|
296
296
|
)
|
|
297
297
|
__TS__SetDescriptor(
|
|
298
298
|
Ability.prototype,
|
|
299
|
-
"
|
|
299
|
+
"orderTypeStringId",
|
|
300
300
|
{get = function(self)
|
|
301
301
|
local field = orderIdFieldByParentTypeId[self.parentTypeId]
|
|
302
|
-
return
|
|
302
|
+
return field ~= nil and getAbilityStringLevelField(self.handle, field, self.level) or (orders[self.parentTypeId] or "")
|
|
303
|
+
end},
|
|
304
|
+
true
|
|
305
|
+
)
|
|
306
|
+
__TS__SetDescriptor(
|
|
307
|
+
Ability.prototype,
|
|
308
|
+
"orderTypeId",
|
|
309
|
+
{get = function(self)
|
|
310
|
+
return order2orderId(self.orderTypeStringId)
|
|
303
311
|
end},
|
|
304
312
|
true
|
|
305
313
|
)
|
|
@@ -3,7 +3,7 @@ import { Ability } from "../ability";
|
|
|
3
3
|
import { Destructable } from "../../../core/types/destructable";
|
|
4
4
|
import { Item } from "../item";
|
|
5
5
|
import { Widget } from "../../../core/types/widget";
|
|
6
|
-
import { DispatchingEvent } from "../../../event";
|
|
6
|
+
import { DispatchingEvent, Event } from "../../../event";
|
|
7
7
|
declare module "../unit" {
|
|
8
8
|
namespace Unit {
|
|
9
9
|
const abilityCastingStartEvent: DispatchingEvent<[Unit, Ability]>;
|
|
@@ -141,3 +141,12 @@ declare module "../unit" {
|
|
|
141
141
|
const abilityStopEvent: DispatchingEvent<[Unit, Ability]>;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
+
declare module "../unit" {
|
|
145
|
+
namespace Unit {
|
|
146
|
+
const abilityCommandEvent: {
|
|
147
|
+
readonly [abilityTypeId: number]: {
|
|
148
|
+
readonly [orderTypeStringId: string]: Event<[Unit, Ability, string]>;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -15,8 +15,15 @@ local UnitTriggerEvent = ____unit.UnitTriggerEvent
|
|
|
15
15
|
local ____event = require("event")
|
|
16
16
|
local createDispatchingEvent = ____event.createDispatchingEvent
|
|
17
17
|
local DependentInitializingEvent = ____event.DependentInitializingEvent
|
|
18
|
+
local Event = ____event.Event
|
|
19
|
+
local InitializingEvent = ____event.InitializingEvent
|
|
18
20
|
local ____preconditions = require("utility.preconditions")
|
|
19
21
|
local checkNotNull = ____preconditions.checkNotNull
|
|
22
|
+
local ____lazy = require("utility.lazy")
|
|
23
|
+
local lazyRecord = ____lazy.lazyRecord
|
|
24
|
+
local eventInvoke = Event.invoke
|
|
25
|
+
local condition = Condition
|
|
26
|
+
local createTrigger = CreateTrigger
|
|
20
27
|
local getItemAbility = BlzGetItemAbility
|
|
21
28
|
local getSpellAbility = GetSpellAbility
|
|
22
29
|
local getSpellAbilityId = GetSpellAbilityId
|
|
@@ -26,6 +33,8 @@ local getSpellTargetUnit = GetSpellTargetUnit
|
|
|
26
33
|
local getSpellTargetX = GetSpellTargetX
|
|
27
34
|
local getSpellTargetY = GetSpellTargetY
|
|
28
35
|
local getTriggerUnit = GetTriggerUnit
|
|
36
|
+
local triggerAddCondition = TriggerAddCondition
|
|
37
|
+
local triggerRegisterCommandEvent = TriggerRegisterCommandEvent
|
|
29
38
|
local unitInventorySize = UnitInventorySize
|
|
30
39
|
local unitItemInSlot = UnitItemInSlot
|
|
31
40
|
local function retrieveAbility(unit, ability, abilityId)
|
|
@@ -352,4 +361,31 @@ rawset(
|
|
|
352
361
|
extractAbilityTypeId
|
|
353
362
|
)
|
|
354
363
|
)
|
|
364
|
+
rawset(
|
|
365
|
+
Unit,
|
|
366
|
+
"abilityCommandEvent",
|
|
367
|
+
lazyRecord(function(abilityTypeId)
|
|
368
|
+
return lazyRecord(function(orderTypeStringId)
|
|
369
|
+
return __TS__New(
|
|
370
|
+
InitializingEvent,
|
|
371
|
+
function(event)
|
|
372
|
+
local trigger = createTrigger()
|
|
373
|
+
triggerRegisterCommandEvent(trigger, abilityTypeId, orderTypeStringId)
|
|
374
|
+
triggerAddCondition(
|
|
375
|
+
trigger,
|
|
376
|
+
condition(function()
|
|
377
|
+
local unit = Unit:of(getTriggerUnit())
|
|
378
|
+
if unit ~= nil then
|
|
379
|
+
local ability = unit:getAbilityById(abilityTypeId)
|
|
380
|
+
if ability ~= nil then
|
|
381
|
+
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
end)
|
|
385
|
+
)
|
|
386
|
+
end
|
|
387
|
+
)
|
|
388
|
+
end)
|
|
389
|
+
end)
|
|
390
|
+
)
|
|
355
391
|
return ____exports
|
|
@@ -130,5 +130,5 @@ export declare class AbilityCombatClassificationsLevelField extends AbilityLevel
|
|
|
130
130
|
protected getNativeFieldValue(instance: Ability, level: number): CombatClassifications;
|
|
131
131
|
protected setNativeFieldValue(instance: Ability, level: number, value: CombatClassifications): boolean;
|
|
132
132
|
}
|
|
133
|
-
export type AbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType
|
|
134
|
-
export declare const resolveCurrentAbilityDependentValue: <ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>) => ValueType;
|
|
133
|
+
export type AbilityDependentValue<ValueType extends boolean | number | string | undefined> = ValueType | AbilityField<NonNullable<ValueType>> | AbilityLevelField<NonNullable<ValueType>> | ((ability: Ability) => ValueType);
|
|
134
|
+
export declare const resolveCurrentAbilityDependentValue: <ValueType extends boolean | number | string | undefined>(ability: Ability, value: AbilityDependentValue<ValueType>) => ValueType;
|
package/package.json
CHANGED
package/utility/lazy.lua
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local rawset = _G.rawset
|
|
3
|
+
local setmetatable = _G.setmetatable
|
|
4
|
+
____exports.lazyRecord = function(initializer)
|
|
5
|
+
return setmetatable(
|
|
6
|
+
{},
|
|
7
|
+
{__index = function(self, key)
|
|
8
|
+
local value = initializer(key)
|
|
9
|
+
rawset(self, key, value)
|
|
10
|
+
return value
|
|
11
|
+
end}
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
return ____exports
|