warscript 0.0.1-dev.1427c55 → 0.0.1-dev.147f4d7
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.d.ts +4 -1
- package/core/types/effect.lua +29 -4
- 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.d.ts +6 -2
- 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-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/package.json +1 -1
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
package/core/types/effect.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export type EffectParameters = {
|
|
|
12
12
|
readonly color?: PlayerColor;
|
|
13
13
|
readonly pitch?: number;
|
|
14
14
|
readonly roll?: number;
|
|
15
|
+
readonly detached?: boolean;
|
|
16
|
+
readonly zOffset?: number;
|
|
17
|
+
readonly scaleZOffset?: boolean;
|
|
15
18
|
};
|
|
16
19
|
export declare class Effect extends Handle<jeffect> {
|
|
17
20
|
private [EffectPropertyKey.COLOR]?;
|
|
@@ -29,7 +32,7 @@ export declare class Effect extends Handle<jeffect> {
|
|
|
29
32
|
static create<T extends Effect>(this: typeof Effect & (new (handle: jeffect) => T), model: string, pos: Vec2): T;
|
|
30
33
|
static createTarget<T extends Effect>(this: typeof Effect & (new (handle: jeffect) => T), model: string, target: Widget, attachPoint: string): T;
|
|
31
34
|
static flash(modelPath: string, ...args: [
|
|
32
|
-
...pointOrWidget: [x: number, y: number] | [widget: Widget, attachmentPoint
|
|
35
|
+
...pointOrWidget: [x: number, y: number] | [widget: Widget, attachmentPoint?: string],
|
|
33
36
|
...parametersOrDuration: [parametersOrDuration?: EffectParameters | number] | [duration?: number, parameters?: EffectParameters]
|
|
34
37
|
]): void;
|
|
35
38
|
static flashTarget(model: string, target: Widget, attachPoint: string, duration?: number): void;
|
package/core/types/effect.lua
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
5
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local dummyPlayer
|
|
@@ -12,6 +13,8 @@ local ____player = require("core.types.player")
|
|
|
12
13
|
local Player = ____player.Player
|
|
13
14
|
local ____timer = require("core.types.timer")
|
|
14
15
|
local Timer = ____timer.Timer
|
|
16
|
+
local ____unit = require("engine.internal.unit")
|
|
17
|
+
local Unit = ____unit.Unit
|
|
15
18
|
local ____pairs = _G.pairs
|
|
16
19
|
local select = _G.select
|
|
17
20
|
local mathRad = math.rad
|
|
@@ -27,16 +30,21 @@ local setSpecialEffectColorByPlayer = BlzSetSpecialEffectColorByPlayer
|
|
|
27
30
|
local specialEffectAddSubAnimation = BlzSpecialEffectAddSubAnimation
|
|
28
31
|
local specialEffectClearSubAnimations = BlzSpecialEffectClearSubAnimations
|
|
29
32
|
local specialEffectRemoveSubAnimation = BlzSpecialEffectRemoveSubAnimation
|
|
33
|
+
local setSpecialEffectZ = BlzSetSpecialEffectZ
|
|
34
|
+
local getLocationZ = GetLocationZ
|
|
35
|
+
local getUnitZ = BlzGetUnitZ
|
|
36
|
+
local moveLocation = MoveLocation
|
|
37
|
+
local location = Location(0, 0)
|
|
30
38
|
local function setSpecialEffectPitchDegrees(effect, pitch)
|
|
31
39
|
setSpecialEffectPitch(
|
|
32
40
|
effect,
|
|
33
41
|
-mathRad(pitch)
|
|
34
42
|
)
|
|
35
43
|
end
|
|
36
|
-
local function setSpecialEffectRollDegrees(effect,
|
|
44
|
+
local function setSpecialEffectRollDegrees(effect, roll)
|
|
37
45
|
setSpecialEffectRoll(
|
|
38
46
|
effect,
|
|
39
|
-
-mathRad(
|
|
47
|
+
-mathRad(roll)
|
|
40
48
|
)
|
|
41
49
|
end
|
|
42
50
|
local animTypeByAnimationName = {
|
|
@@ -149,10 +157,27 @@ function Effect.flash(self, modelPath, xOrWidget, yOrOrAttachmentPoint, paramete
|
|
|
149
157
|
parameters = parametersOrDuration
|
|
150
158
|
parametersOrDuration = nil
|
|
151
159
|
end
|
|
152
|
-
local
|
|
160
|
+
local coordinatesProvided = type(xOrWidget) == "number"
|
|
161
|
+
local isPositional = coordinatesProvided or (parameters and parameters.detached) == true
|
|
162
|
+
local x = not isPositional and 0 or (coordinatesProvided and xOrWidget or xOrWidget.x)
|
|
163
|
+
local y = not isPositional and 0 or (coordinatesProvided and yOrOrAttachmentPoint or xOrWidget.y)
|
|
164
|
+
local effect = isPositional and addSpecialEffect(modelPath, x, y) or addSpecialEffectTarget(modelPath, xOrWidget.handle, yOrOrAttachmentPoint or "origin")
|
|
165
|
+
if isPositional and not coordinatesProvided and (parameters and parameters.scale) == nil and __TS__InstanceOf(xOrWidget, Unit) then
|
|
166
|
+
setSpecialEffectScale(effect, xOrWidget.scale)
|
|
167
|
+
end
|
|
153
168
|
if parameters ~= nil then
|
|
154
169
|
for key, value in ____pairs(parameters) do
|
|
155
|
-
|
|
170
|
+
if key ~= "zOffset" and key ~= "detached" and key ~= "scaleZOffset" then
|
|
171
|
+
setters[key](effect, value)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
if isPositional and parameters.zOffset ~= nil then
|
|
175
|
+
moveLocation(location, x, y)
|
|
176
|
+
local z = __TS__InstanceOf(xOrWidget, Unit) and getLocationZ(location) + xOrWidget.flyHeight or getLocationZ(location)
|
|
177
|
+
BlzSetSpecialEffectZ(
|
|
178
|
+
effect,
|
|
179
|
+
z + parameters.zOffset * (parameters.scaleZOffset and getSpecialEffectScale(effect) or 1)
|
|
180
|
+
)
|
|
156
181
|
end
|
|
157
182
|
end
|
|
158
183
|
if parametersOrDuration ~= nil and parametersOrDuration > 0 then
|
|
@@ -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
|
|
@@ -9,11 +9,15 @@ 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
22
|
protected resolveCurrentAbilityDependentValue<T extends boolean | number | string>(value: AbilityDependentValue<T>): T;
|
|
19
23
|
protected flashAreaEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
|
|
@@ -21,10 +25,10 @@ export declare abstract class AbilityBehavior<Parameters extends {
|
|
|
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
|
|
@@ -4,5 +4,9 @@ export declare const enum SoundPresetName {
|
|
|
4
4
|
ABOMINATION_PISSED = "AbominationPissed",
|
|
5
5
|
ABOMINATION_READY = "AbominationReady",
|
|
6
6
|
ABOMINATION_WAR_CRY = "AbominationWarcry",
|
|
7
|
-
AXE_MEDIUM_CHOP_WOOD = "AxeMediumChopWood"
|
|
7
|
+
AXE_MEDIUM_CHOP_WOOD = "AxeMediumChopWood",
|
|
8
|
+
IMPALE = "Impale",
|
|
9
|
+
IMPALE_HIT = "ImpaleHit",
|
|
10
|
+
IMPALE_LAND = "ImpaleLand",
|
|
11
|
+
IMPALE_CAST = "ImpaleCast"
|
|
8
12
|
}
|
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
|