warscript 0.0.1-dev.c37d12c → 0.0.1-dev.c59dd14
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 +13 -0
- package/attributes.lua +16 -0
- package/core/types/handle.d.ts +2 -1
- package/core/types/handle.lua +5 -0
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +8 -4
- package/engine/behaviour/ability/apply-unit-behavior.lua +31 -9
- package/engine/behaviour/ability/instant-impact.lua +4 -0
- package/engine/behaviour/ability.d.ts +8 -1
- package/engine/behaviour/ability.lua +62 -0
- package/engine/internal/ability.d.ts +1 -1
- package/engine/internal/mechanics/ability-duration.d.ts +1 -3
- package/engine/internal/mechanics/ability-duration.lua +2 -0
- package/engine/internal/mechanics/cast-ability.d.ts +2 -0
- package/engine/internal/mechanics/cast-ability.lua +86 -0
- package/engine/internal/unit/detach-missiles.d.ts +7 -0
- package/engine/internal/unit/detach-missiles.lua +30 -0
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +36 -8
- package/engine/internal/unit.lua +215 -63
- package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
- package/engine/object-data/entry/ability-type/blink.lua +39 -0
- package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -0
- package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- package/engine/object-data/entry/ability-type.d.ts +1 -0
- package/engine/object-data/entry/ability-type.lua +1 -0
- package/engine/object-data/entry/buff-type/applicable.lua +27 -71
- package/engine/object-data/entry/unit-type.d.ts +42 -1
- package/engine/object-data/entry/unit-type.lua +378 -50
- package/engine/object-field/ability.d.ts +7 -5
- package/engine/object-field/ability.lua +6 -0
- package/engine/object-field/unit.d.ts +1 -0
- package/engine/object-field/unit.lua +3 -0
- package/engine/object-field.d.ts +6 -5
- package/engine/object-field.lua +37 -18
- package/engine/random.d.ts +5 -0
- package/engine/random.lua +9 -0
- package/engine/standard/entries/unit-type.d.ts +42 -1
- package/engine/standard/entries/unit-type.lua +42 -1
- package/engine/standard/fields/ability.d.ts +1 -1
- package/engine/standard/fields/ability.lua +1 -1
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/global/vec2.lua +1 -0
- package/package.json +3 -4
- package/string.d.ts +14 -0
- package/string.lua +9 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +16 -0
- package/utility/types.d.ts +2 -2
package/attributes.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
2
|
+
/** @noSelfInFile */
|
|
3
|
+
export type Attribute<T> = {
|
|
4
|
+
readonly __attribute: unique symbol;
|
|
5
|
+
readonly __type: T;
|
|
6
|
+
} & symbol;
|
|
7
|
+
export declare namespace Attribute {
|
|
8
|
+
const create: <T>() => Attribute<T>;
|
|
9
|
+
}
|
|
10
|
+
export declare class AttributesHolder {
|
|
11
|
+
readonly get: (<T>(attribute: Attribute<T>) => T | undefined) & LuaExtension<"TableGetMethod">;
|
|
12
|
+
readonly set: (<T>(attribute: Attribute<T>, value: T | undefined) => void) & LuaExtension<"TableSetMethod">;
|
|
13
|
+
}
|
package/attributes.lua
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
____exports.Attribute = {}
|
|
5
|
+
local Attribute = ____exports.Attribute
|
|
6
|
+
do
|
|
7
|
+
Attribute.create = function()
|
|
8
|
+
return {}
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
____exports.AttributesHolder = __TS__Class()
|
|
12
|
+
local AttributesHolder = ____exports.AttributesHolder
|
|
13
|
+
AttributesHolder.name = "AttributesHolder"
|
|
14
|
+
function AttributesHolder.prototype.____constructor(self)
|
|
15
|
+
end
|
|
16
|
+
return ____exports
|
package/core/types/handle.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Event } from "../../event";
|
|
3
|
+
import { AttributesHolder } from "../../attributes";
|
|
3
4
|
export type HandleConstructor<H extends jhandle, T extends Handle<H>, Args extends any[]> = new (handle: H, ...args: Args) => T;
|
|
4
5
|
export type HandleDestructor = {
|
|
5
6
|
readonly __handleDestructor: unique symbol;
|
|
@@ -11,7 +12,7 @@ type NoOverride = {
|
|
|
11
12
|
declare const enum HandlePropertyKey {
|
|
12
13
|
STATE = 0
|
|
13
14
|
}
|
|
14
|
-
export declare class Handle<H extends jhandle, DestroyParameters extends any[] = []> implements Destroyable {
|
|
15
|
+
export declare class Handle<H extends jhandle, DestroyParameters extends any[] = []> extends AttributesHolder implements Destroyable {
|
|
15
16
|
readonly handle: H;
|
|
16
17
|
private [HandlePropertyKey.STATE]?;
|
|
17
18
|
private onDestroyEvent?;
|
package/core/types/handle.lua
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
3
4
|
local __TS__New = ____lualib.__TS__New
|
|
4
5
|
local __TS__Delete = ____lualib.__TS__Delete
|
|
5
6
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
@@ -12,13 +13,17 @@ local getClass = ____reflection.getClass
|
|
|
12
13
|
local getSuperclass = ____reflection.getSuperclass
|
|
13
14
|
local ____exception = require("exception")
|
|
14
15
|
local IllegalStateException = ____exception.IllegalStateException
|
|
16
|
+
local ____attributes = require("attributes")
|
|
17
|
+
local AttributesHolder = ____attributes.AttributesHolder
|
|
15
18
|
local getHandleId = GetHandleId
|
|
16
19
|
local onCreateEventByHandleConstructor = {}
|
|
17
20
|
local onDestroyEventByHandleConstructor = {}
|
|
18
21
|
____exports.Handle = __TS__Class()
|
|
19
22
|
local Handle = ____exports.Handle
|
|
20
23
|
Handle.name = "Handle"
|
|
24
|
+
__TS__ClassExtends(Handle, AttributesHolder)
|
|
21
25
|
function Handle.prototype.____constructor(self, handle)
|
|
26
|
+
AttributesHolder.prototype.____constructor(self)
|
|
22
27
|
self[0] = 0
|
|
23
28
|
local id = getHandleId(handle)
|
|
24
29
|
local clazz = self.constructor
|
package/core/types/missile.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class Missile implements Destroyable {
|
|
|
5
5
|
readonly retarget: (this: void, target: Unit | Vec2) => void;
|
|
6
6
|
private readonly update;
|
|
7
7
|
protected constructor(effect: jeffect, retarget: (this: void, target: Unit | Vec2) => void, update: (this: Missile) => boolean);
|
|
8
|
-
static launch(config: Readonly<{
|
|
8
|
+
static launch<T extends any[]>(config: Readonly<{
|
|
9
9
|
art: string;
|
|
10
10
|
scale?: number;
|
|
11
11
|
acceleration?: number;
|
|
@@ -15,7 +15,7 @@ export declare class Missile implements Destroyable {
|
|
|
15
15
|
maxSpeed?: number;
|
|
16
16
|
sourceOffset?: Vec2;
|
|
17
17
|
targetOffset?: Vec2;
|
|
18
|
-
}>, source: Unit | Vec2, target: Unit | Vec2, onArrival: (missile: Missile, success: boolean) => void): Missile;
|
|
18
|
+
}>, source: Unit | Vec2, target: Unit | Vec2, onArrival: (missile: Missile, success: boolean, ...parameters: T) => void, ...parameters: T): Missile;
|
|
19
19
|
destroy(): void;
|
|
20
20
|
}
|
|
21
21
|
export declare namespace Missile {
|
package/core/types/missile.lua
CHANGED
|
@@ -41,7 +41,8 @@ function Missile.prototype.____constructor(self, effect, retarget, update)
|
|
|
41
41
|
end
|
|
42
42
|
head = self
|
|
43
43
|
end
|
|
44
|
-
function Missile.launch(self, config, source, target, onArrival)
|
|
44
|
+
function Missile.launch(self, config, source, target, onArrival, ...)
|
|
45
|
+
local parameters = {...}
|
|
45
46
|
local ____opt_0 = config.sourceOffset
|
|
46
47
|
local offsetX = ____opt_0 and ____opt_0.x or 0
|
|
47
48
|
local ____opt_2 = config.sourceOffset
|
|
@@ -142,7 +143,12 @@ function Missile.launch(self, config, source, target, onArrival)
|
|
|
142
143
|
visualPositionArcY = currentVisualTargetY
|
|
143
144
|
visualPositionArcZ = currentVisualTargetZ
|
|
144
145
|
retarget = false
|
|
145
|
-
safeCall(
|
|
146
|
+
safeCall(
|
|
147
|
+
onArrival,
|
|
148
|
+
self,
|
|
149
|
+
true,
|
|
150
|
+
table.unpack(parameters)
|
|
151
|
+
)
|
|
146
152
|
return not retarget
|
|
147
153
|
end
|
|
148
154
|
if arcVSpeed ~= 0 and (currentTargetX ~= initialTargetX or currentTargetY ~= initialTargetY) then
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { AbilityBehavior } from "../ability";
|
|
3
3
|
import { Ability } from "../../internal/ability";
|
|
4
|
-
import {
|
|
4
|
+
import { UnitBehavior } from "../unit";
|
|
5
5
|
import { Unit } from "../../internal/unit";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { AbilityDependentValue } from "../../object-field/ability";
|
|
7
|
+
export declare class ApplyUnitBehaviorAbilityBehavior<T extends UnitBehavior> extends AbilityBehavior {
|
|
8
|
+
private readonly unitBehaviorConstructor;
|
|
9
|
+
private readonly parameters?;
|
|
10
|
+
private readonly keys?;
|
|
8
11
|
private unitBehavior?;
|
|
9
|
-
constructor(ability: Ability, unitBehaviorConstructor:
|
|
12
|
+
constructor(ability: Ability, unitBehaviorConstructor: new (unit: Unit) => T, parameters?: Partial<{ [K in keyof T & { [P in keyof T]-?: (<T_1>() => T_1 extends { [Q in P]: T[P]; } ? 1 : 2) extends <T_2>() => T_2 extends { -readonly [Q_1 in P]: T[P]; } ? 1 : 2 ? P : never; }[keyof T] & KeysOfType<T, string | number | boolean>]: T[K] extends string | number | boolean ? AbilityDependentValue<T[K]> : never; }> | undefined);
|
|
13
|
+
update(): void;
|
|
10
14
|
onUnitGainAbility(unit: Unit): void;
|
|
11
15
|
onUnitLoseAbility(): void;
|
|
12
16
|
}
|
|
@@ -1,23 +1,38 @@
|
|
|
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__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
5
|
+
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
4
6
|
local __TS__New = ____lualib.__TS__New
|
|
5
7
|
local ____exports = {}
|
|
6
8
|
local ____ability = require("engine.behaviour.ability")
|
|
7
9
|
local AbilityBehavior = ____ability.AbilityBehavior
|
|
10
|
+
local ____ability = require("engine.object-field.ability")
|
|
11
|
+
local AbilityField = ____ability.AbilityField
|
|
12
|
+
local AbilityLevelField = ____ability.AbilityLevelField
|
|
8
13
|
____exports.ApplyUnitBehaviorAbilityBehavior = __TS__Class()
|
|
9
14
|
local ApplyUnitBehaviorAbilityBehavior = ____exports.ApplyUnitBehaviorAbilityBehavior
|
|
10
15
|
ApplyUnitBehaviorAbilityBehavior.name = "ApplyUnitBehaviorAbilityBehavior"
|
|
11
16
|
__TS__ClassExtends(ApplyUnitBehaviorAbilityBehavior, AbilityBehavior)
|
|
12
|
-
function ApplyUnitBehaviorAbilityBehavior.prototype.____constructor(self, ability, unitBehaviorConstructor,
|
|
13
|
-
local args = {...}
|
|
17
|
+
function ApplyUnitBehaviorAbilityBehavior.prototype.____constructor(self, ability, unitBehaviorConstructor, parameters)
|
|
14
18
|
AbilityBehavior.prototype.____constructor(self, ability)
|
|
15
|
-
self.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
self.unitBehaviorConstructor = unitBehaviorConstructor
|
|
20
|
+
self.parameters = parameters
|
|
21
|
+
if parameters ~= nil then
|
|
22
|
+
self.keys = __TS__ArraySort(__TS__ObjectKeys(parameters))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
function ApplyUnitBehaviorAbilityBehavior.prototype.update(self)
|
|
26
|
+
local unitBehavior = self.unitBehavior
|
|
27
|
+
local parameters = self.parameters
|
|
28
|
+
local keys = self.keys
|
|
29
|
+
if unitBehavior ~= nil and parameters ~= nil and keys ~= nil then
|
|
30
|
+
for ____, key in ipairs(keys) do
|
|
31
|
+
local value = parameters[key]
|
|
32
|
+
if value ~= nil then
|
|
33
|
+
unitBehavior[key] = self:resolveCurrentAbilityDependentValue(value)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
21
36
|
end
|
|
22
37
|
end
|
|
23
38
|
function ApplyUnitBehaviorAbilityBehavior.prototype.onUnitGainAbility(self, unit)
|
|
@@ -25,7 +40,8 @@ function ApplyUnitBehaviorAbilityBehavior.prototype.onUnitGainAbility(self, unit
|
|
|
25
40
|
if ____opt_0 ~= nil then
|
|
26
41
|
____opt_0:destroy()
|
|
27
42
|
end
|
|
28
|
-
self.unitBehavior = self
|
|
43
|
+
self.unitBehavior = __TS__New(self.unitBehaviorConstructor, unit)
|
|
44
|
+
self:update()
|
|
29
45
|
end
|
|
30
46
|
function ApplyUnitBehaviorAbilityBehavior.prototype.onUnitLoseAbility(self)
|
|
31
47
|
local ____opt_2 = self.unitBehavior
|
|
@@ -33,4 +49,10 @@ function ApplyUnitBehaviorAbilityBehavior.prototype.onUnitLoseAbility(self)
|
|
|
33
49
|
____opt_2:destroy()
|
|
34
50
|
end
|
|
35
51
|
end
|
|
52
|
+
AbilityField.valueChangeEvent:addListener(function(ability)
|
|
53
|
+
____exports.ApplyUnitBehaviorAbilityBehavior:forAll(ability, "update")
|
|
54
|
+
end)
|
|
55
|
+
AbilityLevelField.valueChangeEvent:addListener(function(ability)
|
|
56
|
+
____exports.ApplyUnitBehaviorAbilityBehavior:forAll(ability, "update")
|
|
57
|
+
end)
|
|
36
58
|
return ____exports
|
|
@@ -12,8 +12,12 @@ local InstantImpactAbilityBehavior = ____exports.InstantImpactAbilityBehavior
|
|
|
12
12
|
InstantImpactAbilityBehavior.name = "InstantImpactAbilityBehavior"
|
|
13
13
|
__TS__ClassExtends(InstantImpactAbilityBehavior, AbilityBehavior)
|
|
14
14
|
function InstantImpactAbilityBehavior.prototype.onCastingStart(self, caster)
|
|
15
|
+
local abilityTypeId = self.ability.typeId
|
|
15
16
|
local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
|
|
16
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
|
|
17
21
|
caster.mana = caster.mana - manaCost
|
|
18
22
|
if cooldown == 0 then
|
|
19
23
|
caster:interruptCast(self.ability.typeId)
|
|
@@ -9,13 +9,20 @@ 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 declare abstract class AbilityBehavior<
|
|
12
|
+
export declare abstract class AbilityBehavior<Parameters extends {
|
|
13
|
+
periodicActionParameters?: any[];
|
|
14
|
+
missileParameters?: any[];
|
|
15
|
+
} = {}> extends Behavior<Ability, NonNullable<Parameters["periodicActionParameters"]>> {
|
|
13
16
|
constructor(ability: Ability);
|
|
14
17
|
get ability(): Ability;
|
|
15
18
|
protected resolveCurrentAbilityDependentValue<T extends boolean | number | string>(value: AbilityDependentValue<T>): T;
|
|
16
19
|
protected flashAreaEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
|
|
17
20
|
protected flashEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
|
|
18
21
|
protected flashSpecialEffect(...args: [...pointOrWidget: [x: number, y: number] | [widget: Widget], duration?: number]): void;
|
|
22
|
+
private static MissileLaunchConfig;
|
|
23
|
+
private get missileLaunchConfig();
|
|
24
|
+
protected launchMissile(source: Unit, target: Unit, ...parameters: NonNullable<Parameters["missileParameters"]>): void;
|
|
25
|
+
onMissileArrival(...parameters: NonNullable<Parameters["missileParameters"]>): void;
|
|
19
26
|
onUnitGainAbility(_unit: Unit): void;
|
|
20
27
|
onUnitLoseAbility(_unit: Unit): void;
|
|
21
28
|
onCastingStart(caster: Unit): void;
|
|
@@ -15,13 +15,52 @@ local Effect = ____effect.Effect
|
|
|
15
15
|
local ____ability = require("engine.standard.fields.ability")
|
|
16
16
|
local AREA_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.AREA_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
|
|
17
17
|
local EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
|
|
18
|
+
local MISSILE_ARC_ABILITY_FLOAT_FIELD = ____ability.MISSILE_ARC_ABILITY_FLOAT_FIELD
|
|
19
|
+
local MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
|
|
20
|
+
local MISSILE_SPEED_ABILITY_INTEGER_FIELD = ____ability.MISSILE_SPEED_ABILITY_INTEGER_FIELD
|
|
18
21
|
local SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD = ____ability.SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD
|
|
19
22
|
local SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
|
|
20
23
|
local ____ability = require("engine.object-field.ability")
|
|
21
24
|
local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
|
|
22
25
|
local ____timer = require("core.types.timer")
|
|
23
26
|
local Timer = ____timer.Timer
|
|
27
|
+
local ____missile = require("core.types.missile")
|
|
28
|
+
local Missile = ____missile.Missile
|
|
24
29
|
local createBehaviorFunctionsByAbilityTypeId = {}
|
|
30
|
+
local function invokeOnMissileArrival(_missile, success, abilityBehavior, ...)
|
|
31
|
+
if success then
|
|
32
|
+
abilityBehavior:onMissileArrival(...)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
local ____class_0 = __TS__Class()
|
|
36
|
+
____class_0.name = ""
|
|
37
|
+
function ____class_0.prototype.____constructor(self, abilityBehavior)
|
|
38
|
+
self.abilityBehavior = abilityBehavior
|
|
39
|
+
end
|
|
40
|
+
__TS__SetDescriptor(
|
|
41
|
+
____class_0.prototype,
|
|
42
|
+
"art",
|
|
43
|
+
{get = function(self)
|
|
44
|
+
return MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.abilityBehavior.ability, 0)
|
|
45
|
+
end},
|
|
46
|
+
true
|
|
47
|
+
)
|
|
48
|
+
__TS__SetDescriptor(
|
|
49
|
+
____class_0.prototype,
|
|
50
|
+
"arc",
|
|
51
|
+
{get = function(self)
|
|
52
|
+
return MISSILE_ARC_ABILITY_FLOAT_FIELD:getValue(self.abilityBehavior.ability)
|
|
53
|
+
end},
|
|
54
|
+
true
|
|
55
|
+
)
|
|
56
|
+
__TS__SetDescriptor(
|
|
57
|
+
____class_0.prototype,
|
|
58
|
+
"speed",
|
|
59
|
+
{get = function(self)
|
|
60
|
+
return MISSILE_SPEED_ABILITY_INTEGER_FIELD:getValue(self.abilityBehavior.ability)
|
|
61
|
+
end},
|
|
62
|
+
true
|
|
63
|
+
)
|
|
25
64
|
____exports.AbilityBehavior = __TS__Class()
|
|
26
65
|
local AbilityBehavior = ____exports.AbilityBehavior
|
|
27
66
|
AbilityBehavior.name = "AbilityBehavior"
|
|
@@ -65,6 +104,18 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrDurati
|
|
|
65
104
|
)
|
|
66
105
|
end
|
|
67
106
|
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
|
+
function AbilityBehavior.prototype.onMissileArrival(self, ...)
|
|
118
|
+
end
|
|
68
119
|
function AbilityBehavior.prototype.onUnitGainAbility(self, _unit)
|
|
69
120
|
end
|
|
70
121
|
function AbilityBehavior.prototype.onUnitLoseAbility(self, _unit)
|
|
@@ -127,6 +178,17 @@ __TS__SetDescriptor(
|
|
|
127
178
|
return self.object
|
|
128
179
|
end},
|
|
129
180
|
true
|
|
181
|
+
)
|
|
182
|
+
AbilityBehavior.MissileLaunchConfig = ____class_0
|
|
183
|
+
__TS__SetDescriptor(
|
|
184
|
+
AbilityBehavior.prototype,
|
|
185
|
+
"missileLaunchConfig",
|
|
186
|
+
{get = function(self)
|
|
187
|
+
local missileLaunchConfig = __TS__New(____exports.AbilityBehavior.MissileLaunchConfig, self)
|
|
188
|
+
rawset(self, "missileLaunchConfig", missileLaunchConfig)
|
|
189
|
+
return missileLaunchConfig
|
|
190
|
+
end},
|
|
191
|
+
true
|
|
130
192
|
);
|
|
131
193
|
(function(self)
|
|
132
194
|
local function createUnitEventListener(key)
|
|
@@ -12,7 +12,7 @@ interface Fields<K, V> {
|
|
|
12
12
|
interface AbilityLevel {
|
|
13
13
|
realFields: Fields<jabilityreallevelfield, number>;
|
|
14
14
|
}
|
|
15
|
-
type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
|
|
15
|
+
export type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
|
|
16
16
|
export declare class AbilitySnapshot {
|
|
17
17
|
}
|
|
18
18
|
export declare abstract class Ability extends Handle<jability> {
|
|
@@ -4,6 +4,8 @@ local UnitClassification = ____unit.UnitClassification
|
|
|
4
4
|
local ____ability = require("engine.standard.fields.ability")
|
|
5
5
|
local DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD
|
|
6
6
|
local DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD
|
|
7
|
+
---
|
|
8
|
+
-- @internal For use by internal systems only.
|
|
7
9
|
____exports.getAbilityDuration = function(ability, target)
|
|
8
10
|
local level = ability.level
|
|
9
11
|
return target ~= nil and target:hasClassification(UnitClassification.RESISTANT) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
|
|
3
|
+
local AbilityType = ____ability_2Dtype.AbilityType
|
|
4
|
+
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
5
|
+
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
6
|
+
local ____dummy_2Dunits = require("engine.internal.misc.dummy-units")
|
|
7
|
+
local INVENTORY_DUMMY_NATIVE_UNIT = ____dummy_2Dunits.INVENTORY_DUMMY_NATIVE_UNIT
|
|
8
|
+
local ____preconditions = require("utility.preconditions")
|
|
9
|
+
local checkNotNull = ____preconditions.checkNotNull
|
|
10
|
+
local ____dummy_2Dinventory = require("engine.internal.object-data.dummy-inventory")
|
|
11
|
+
local INVENTORY_ABILITY_TYPE_ID = ____dummy_2Dinventory.INVENTORY_ABILITY_TYPE_ID
|
|
12
|
+
local ____arrays = require("utility.arrays")
|
|
13
|
+
local map = ____arrays.map
|
|
14
|
+
local toLuaSet = ____arrays.toLuaSet
|
|
15
|
+
local createItem = CreateItem
|
|
16
|
+
local getAbilityId = BlzGetAbilityId
|
|
17
|
+
local getItemAbility = BlzGetItemAbility
|
|
18
|
+
local getUnitAbilityByIndex = BlzGetUnitAbilityByIndex
|
|
19
|
+
local itemAddAbility = BlzItemAddAbility
|
|
20
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
21
|
+
local removeItem = RemoveItem
|
|
22
|
+
local unitAddAbility = UnitAddAbility
|
|
23
|
+
local unitAddItem = UnitAddItem
|
|
24
|
+
local unitDropItemSlot = UnitDropItemSlot
|
|
25
|
+
local unitInventorySize = UnitInventorySize
|
|
26
|
+
local unitRemoveAbility = UnitRemoveAbility
|
|
27
|
+
local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
|
|
28
|
+
local INVENTORY_ABILITY_TYPE_IDS = postcompile(function()
|
|
29
|
+
return toLuaSet(AbilityType:getAllIdsByBaseIds(map({
|
|
30
|
+
"AInv",
|
|
31
|
+
"Aihn",
|
|
32
|
+
"Aien",
|
|
33
|
+
"Aion",
|
|
34
|
+
"Aiun"
|
|
35
|
+
}, fourCC)))
|
|
36
|
+
end)
|
|
37
|
+
---
|
|
38
|
+
-- @internal For use by internal systems only.
|
|
39
|
+
____exports.castAbility = function(nativeUnit, abilityTypeId, prepareAbility, ...)
|
|
40
|
+
local nativeItem = createItem(DUMMY_ITEM_ID, 0, 0)
|
|
41
|
+
unitAddItem(INVENTORY_DUMMY_NATIVE_UNIT, nativeItem)
|
|
42
|
+
itemAddAbility(nativeItem, abilityTypeId)
|
|
43
|
+
local nativeAbility = checkNotNull(getItemAbility(nativeItem, abilityTypeId))
|
|
44
|
+
if prepareAbility ~= nil then
|
|
45
|
+
prepareAbility(nativeAbility, ...)
|
|
46
|
+
end
|
|
47
|
+
setItemBooleanField(nativeItem, ITEM_BF_ACTIVELY_USED, true)
|
|
48
|
+
setItemBooleanField(nativeItem, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
49
|
+
local success
|
|
50
|
+
if unitAddItem(nativeUnit, nativeItem) then
|
|
51
|
+
success = true
|
|
52
|
+
else
|
|
53
|
+
local latestInventoryAbilityTypeId = 0
|
|
54
|
+
local nativeItemBySlot = {}
|
|
55
|
+
local inventorySize = unitInventorySize(nativeUnit)
|
|
56
|
+
if inventorySize ~= 0 then
|
|
57
|
+
for slot = 0, inventorySize - 1 do
|
|
58
|
+
nativeItemBySlot[slot] = unitRemoveItemFromSlot(nativeUnit, slot)
|
|
59
|
+
end
|
|
60
|
+
local unitNativeAbility = getUnitAbilityByIndex(nativeUnit, 0)
|
|
61
|
+
local i = 1
|
|
62
|
+
while unitNativeAbility ~= nil do
|
|
63
|
+
local abilityTypeId = getAbilityId(unitNativeAbility)
|
|
64
|
+
if INVENTORY_ABILITY_TYPE_IDS[abilityTypeId] ~= nil then
|
|
65
|
+
latestInventoryAbilityTypeId = abilityTypeId
|
|
66
|
+
end
|
|
67
|
+
unitNativeAbility = getUnitAbilityByIndex(nativeUnit, i)
|
|
68
|
+
i = i + 1
|
|
69
|
+
end
|
|
70
|
+
unitRemoveAbility(nativeUnit, latestInventoryAbilityTypeId)
|
|
71
|
+
end
|
|
72
|
+
unitAddAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
|
|
73
|
+
success = unitAddItem(nativeUnit, nativeItem)
|
|
74
|
+
unitRemoveAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
|
|
75
|
+
if latestInventoryAbilityTypeId ~= 0 then
|
|
76
|
+
unitAddAbility(nativeUnit, latestInventoryAbilityTypeId)
|
|
77
|
+
for slot, nativeItem in pairs(nativeItemBySlot) do
|
|
78
|
+
unitAddItem(nativeUnit, nativeItem)
|
|
79
|
+
unitDropItemSlot(nativeUnit, nativeItem, slot)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
removeItem(nativeItem)
|
|
84
|
+
return success
|
|
85
|
+
end
|
|
86
|
+
return ____exports
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____unit = require("engine.internal.unit")
|
|
3
|
+
local Unit = ____unit.Unit
|
|
4
|
+
local ____cast_2Dability = require("engine.internal.mechanics.cast-ability")
|
|
5
|
+
local castAbility = ____cast_2Dability.castAbility
|
|
6
|
+
local ____blink = require("engine.object-data.entry.ability-type.blink")
|
|
7
|
+
local BlinkAbilityType = ____blink.BlinkAbilityType
|
|
8
|
+
local ____math = require("math")
|
|
9
|
+
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
10
|
+
local getUnitX = GetUnitX
|
|
11
|
+
local getUnitY = GetUnitY
|
|
12
|
+
local setUnitX = SetUnitX
|
|
13
|
+
local setUnitY = SetUnitY
|
|
14
|
+
local BLINK_ABILITY_TYPE_ID = compiletime(function()
|
|
15
|
+
local abilityType = BlinkAbilityType:create()
|
|
16
|
+
abilityType.minimumRange = 0
|
|
17
|
+
abilityType.maximumRange = MAXIMUM_INTEGER
|
|
18
|
+
abilityType.manaCost = 0
|
|
19
|
+
abilityType.cooldown = 0
|
|
20
|
+
return abilityType.id
|
|
21
|
+
end)
|
|
22
|
+
Unit.prototype.detachMissiles = function(self)
|
|
23
|
+
local nativeUnit = self.handle
|
|
24
|
+
local x = getUnitX(nativeUnit)
|
|
25
|
+
local y = getUnitY(nativeUnit)
|
|
26
|
+
castAbility(nativeUnit, BLINK_ABILITY_TYPE_ID)
|
|
27
|
+
setUnitX(nativeUnit, x)
|
|
28
|
+
setUnitY(nativeUnit, y)
|
|
29
|
+
end
|
|
30
|
+
return ____exports
|
|
@@ -25,7 +25,7 @@ local function timerCallback(source, target)
|
|
|
25
25
|
Event.invoke(autoAttackFinishEvent, source, target)
|
|
26
26
|
end
|
|
27
27
|
Unit.autoAttackStartEvent:addListener(function(source, target)
|
|
28
|
-
local attackPoint = source.weapons[1].
|
|
28
|
+
local attackPoint = source.weapons[1].impactDelay
|
|
29
29
|
local timer = Timer:simple(attackPoint, timerCallback, source, target)
|
|
30
30
|
eventTimerByUnit[source] = timer
|
|
31
31
|
end)
|
|
@@ -68,23 +68,44 @@ declare const modifiers: {
|
|
|
68
68
|
speed: (unit: junit, value: number) => void;
|
|
69
69
|
armor: (unit: junit, value: number) => void;
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
export declare class UnitWeapon {
|
|
72
|
+
readonly unit: Unit;
|
|
72
73
|
readonly index: 0 | 1;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
constructor(unit: Unit, index: 0 | 1);
|
|
75
|
+
get cooldown(): number;
|
|
76
|
+
set cooldown(cooldown: number);
|
|
77
|
+
get damage(): [minimumDamage: number, maximumDamage: number];
|
|
78
|
+
set damage([minimumDamage, maximumDamage]: [number, number]);
|
|
79
|
+
get damageBase(): number;
|
|
80
|
+
set damageBase(damageBase: number);
|
|
81
|
+
get damageDiceCount(): number;
|
|
82
|
+
set damageDiceCount(damageDiceCount: number);
|
|
83
|
+
get damageDiceSideCount(): number;
|
|
84
|
+
set damageDiceSideCount(damageDiceSideCount: number);
|
|
85
|
+
get range(): number;
|
|
86
|
+
set range(range: number);
|
|
87
|
+
get impactDelay(): number;
|
|
88
|
+
set impactDelay(impactDelay: number);
|
|
89
|
+
get missileArc(): number;
|
|
90
|
+
set missileArc(missileArc: number);
|
|
91
|
+
get missileModelPath(): string;
|
|
92
|
+
set missileModelPath(missileModelPath: string);
|
|
93
|
+
get missileSpeed(): number;
|
|
94
|
+
set missileSpeed(missileSpeed: number);
|
|
78
95
|
}
|
|
79
96
|
declare const enum UnitPropertyKey {
|
|
80
97
|
IS_PAUSED = 100,
|
|
81
98
|
STUN_COUNTER = 101,
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
DELAY_HEALTH_CHECKS_COUNTER = 102,
|
|
100
|
+
DELAY_HEALTH_CHECKS_HEALTH_BONUS = 103,
|
|
101
|
+
PREVENT_DEATH_HEALTH_BONUS = 104,
|
|
102
|
+
IS_TEAM_GLOW_HIDDEN = 105
|
|
84
103
|
}
|
|
85
104
|
export declare class Unit extends Handle<junit> {
|
|
86
105
|
private [UnitPropertyKey.IS_PAUSED]?;
|
|
87
106
|
private [UnitPropertyKey.STUN_COUNTER]?;
|
|
107
|
+
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
|
|
108
|
+
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
|
|
88
109
|
private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
|
|
89
110
|
private [UnitPropertyKey.IS_TEAM_GLOW_HIDDEN]?;
|
|
90
111
|
private _owner?;
|
|
@@ -123,6 +144,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
123
144
|
playAnimation(animation: number): void;
|
|
124
145
|
queueAnimation(animation: string): void;
|
|
125
146
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
147
|
+
get firstWeapon(): UnitWeapon;
|
|
148
|
+
get secondWeapon(): UnitWeapon;
|
|
126
149
|
get level(): number;
|
|
127
150
|
set level(v: number);
|
|
128
151
|
get xp(): number;
|
|
@@ -148,6 +171,10 @@ export declare class Unit extends Handle<junit> {
|
|
|
148
171
|
set color(color: PlayerColor);
|
|
149
172
|
get acquisitionRange(): number;
|
|
150
173
|
set acquisitionRange(v: number);
|
|
174
|
+
/**
|
|
175
|
+
* Keeps this unit alive even if its health becomes negative until the current game thread yields.
|
|
176
|
+
*/
|
|
177
|
+
delayHealthChecks(): void;
|
|
151
178
|
get maxHealth(): number;
|
|
152
179
|
set maxHealth(maxHealth: number);
|
|
153
180
|
get healthRegenerationRate(): number;
|
|
@@ -222,6 +249,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
222
249
|
getAbilityById(abilityId: number): UnitAbility | undefined;
|
|
223
250
|
removeAbility(abilityId: number): boolean;
|
|
224
251
|
hideAbility(abilityId: number, flag: boolean): void;
|
|
252
|
+
getAbilityRemainingCooldown(abilityId: number): number;
|
|
225
253
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
226
254
|
endAbilityCooldown(abilityId: number): void;
|
|
227
255
|
interruptAttack(): void;
|