warscript 0.0.1-dev.3bc4ba4 → 0.0.1-dev.3dad3ec
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/frame.lua +25 -12
- package/core/types/player.lua +4 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +76 -2
- package/core/types/timer.d.ts +2 -1
- package/core/types/timer.lua +7 -2
- package/decl/native.d.ts +4 -2
- package/engine/behavior.d.ts +2 -0
- package/engine/behavior.lua +53 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +2 -1
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.lua +7 -16
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +12 -1
- package/engine/behaviour/unit.lua +56 -7
- package/engine/buff.d.ts +2 -1
- package/engine/buff.lua +9 -3
- package/engine/internal/ability.lua +8 -2
- package/engine/internal/item/ability.lua +51 -1
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/unit/ability.d.ts +30 -0
- package/engine/internal/unit/ability.lua +48 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit-missile-launch.lua +8 -1
- package/engine/internal/unit.d.ts +3 -3
- package/engine/internal/unit.lua +70 -57
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/entry/ability-type.lua +1 -3
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +26 -3
- package/engine/text-tag.lua +215 -11
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +2 -2
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
- package/core/types/order.d.ts +0 -26
- package/core/types/order.lua +0 -65
package/core/types/frame.lua
CHANGED
|
@@ -20,6 +20,8 @@ local frameGetEnable = BlzFrameGetEnable
|
|
|
20
20
|
local frameIsVisible = BlzFrameIsVisible
|
|
21
21
|
local frameSetEnable = BlzFrameSetEnable
|
|
22
22
|
local frameSetScale = BlzFrameSetScale
|
|
23
|
+
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
24
|
+
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
23
25
|
local getCameraTargetPositionX = GetCameraTargetPositionX
|
|
24
26
|
local getCameraTargetPositionY = GetCameraTargetPositionY
|
|
25
27
|
local ____rawget = _G.rawget
|
|
@@ -123,6 +125,23 @@ do
|
|
|
123
125
|
FramePoint.BOTTOM_RIGHT = FRAMEPOINT_BOTTOMRIGHT
|
|
124
126
|
end
|
|
125
127
|
local tooltipByFrame = setmetatable({}, {__mode = "k"})
|
|
128
|
+
---
|
|
129
|
+
-- @internal For use by internal systems only.
|
|
130
|
+
____exports.getFrameMinXMaxX = function()
|
|
131
|
+
local w = getLocalClientWidth()
|
|
132
|
+
local h = getLocalClientHeight()
|
|
133
|
+
local width4by3 = (w - h / 600 * 800) / 2
|
|
134
|
+
local pxtodpi = 0.6 / h
|
|
135
|
+
local minX = -width4by3 * pxtodpi
|
|
136
|
+
local maxX = minX + w * pxtodpi
|
|
137
|
+
return minX, maxX
|
|
138
|
+
end
|
|
139
|
+
---
|
|
140
|
+
-- @internal For use by internal systems only.
|
|
141
|
+
____exports.FRAME_MIN_Y = 0
|
|
142
|
+
---
|
|
143
|
+
-- @internal For use by internal systems only.
|
|
144
|
+
____exports.FRAME_MAX_Y = 0.6
|
|
126
145
|
____exports.Frame = __TS__Class()
|
|
127
146
|
local Frame = ____exports.Frame
|
|
128
147
|
Frame.name = "Frame"
|
|
@@ -344,27 +363,21 @@ __TS__ObjectDefineProperty(
|
|
|
344
363
|
Frame,
|
|
345
364
|
"minX",
|
|
346
365
|
{get = function(self)
|
|
347
|
-
local
|
|
348
|
-
|
|
349
|
-
local width4by3 = (w - h / 600 * 800) / 2
|
|
350
|
-
local pxtodpi = 0.6 / h
|
|
351
|
-
return -width4by3 * pxtodpi
|
|
366
|
+
local minX = ____exports.getFrameMinXMaxX()
|
|
367
|
+
return minX
|
|
352
368
|
end}
|
|
353
369
|
)
|
|
354
370
|
__TS__ObjectDefineProperty(
|
|
355
371
|
Frame,
|
|
356
372
|
"maxX",
|
|
357
373
|
{get = function(self)
|
|
358
|
-
local
|
|
359
|
-
|
|
360
|
-
local width4by3 = (w - h / 600 * 800) / 2
|
|
361
|
-
local pxtodpi = 0.6 / h
|
|
362
|
-
return (-width4by3 + w) * pxtodpi
|
|
374
|
+
local ____, maxX = ____exports.getFrameMinXMaxX()
|
|
375
|
+
return maxX
|
|
363
376
|
end}
|
|
364
377
|
)
|
|
365
378
|
Frame.centerX = 0.4
|
|
366
|
-
Frame.minY =
|
|
367
|
-
Frame.maxY =
|
|
379
|
+
Frame.minY = ____exports.FRAME_MIN_Y
|
|
380
|
+
Frame.maxY = ____exports.FRAME_MAX_Y
|
|
368
381
|
Frame.centerY = 0.3
|
|
369
382
|
__TS__SetDescriptor(
|
|
370
383
|
Frame.prototype,
|
package/core/types/player.lua
CHANGED
|
@@ -29,6 +29,9 @@ local setPlayerTechMaxAllowed = SetPlayerTechMaxAllowed
|
|
|
29
29
|
local setPlayerTechResearched = SetPlayerTechResearched
|
|
30
30
|
local setPlayerAbilityAvailable = SetPlayerAbilityAvailable
|
|
31
31
|
local playerNative = _G.Player
|
|
32
|
+
---
|
|
33
|
+
-- @internal For use by internal systems only.
|
|
34
|
+
____exports.PLAYER_LOCAL_HANDLE = GetLocalPlayer()
|
|
32
35
|
____exports.Player = __TS__Class()
|
|
33
36
|
local Player = ____exports.Player
|
|
34
37
|
Player.name = "Player"
|
|
@@ -249,7 +252,7 @@ Player.all = (function()
|
|
|
249
252
|
end
|
|
250
253
|
return all
|
|
251
254
|
end)()
|
|
252
|
-
Player["local"] = ____exports.Player:of(
|
|
255
|
+
Player["local"] = ____exports.Player:of(____exports.PLAYER_LOCAL_HANDLE)
|
|
253
256
|
Player.neutralPassive = ____exports.Player.all[PLAYER_NEUTRAL_PASSIVE + 1]
|
|
254
257
|
Player.neutralAggressive = ____exports.Player.all[PLAYER_NEUTRAL_AGGRESSIVE + 1]
|
|
255
258
|
Player.neutralVictim = ____exports.Player.all[bj_PLAYER_NEUTRAL_VICTIM + 1]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
+
import type { Unit } from "../../engine/internal/unit";
|
|
2
3
|
export declare class PlayerCamera {
|
|
3
4
|
private readonly player;
|
|
4
5
|
private readonly isLocal;
|
|
@@ -28,5 +29,6 @@ export declare class PlayerCamera {
|
|
|
28
29
|
get roll(): number;
|
|
29
30
|
set roll(v: number);
|
|
30
31
|
reset(): void;
|
|
32
|
+
static isUnitInView(unit: Unit): boolean;
|
|
31
33
|
static of(player: jplayer): PlayerCamera;
|
|
32
34
|
}
|
|
@@ -3,15 +3,27 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
5
|
local ____exports = {}
|
|
6
|
+
local ____player = require("core.types.player")
|
|
7
|
+
local PLAYER_LOCAL_HANDLE = ____player.PLAYER_LOCAL_HANDLE
|
|
8
|
+
local ____timer = require("core.types.timer")
|
|
9
|
+
local Timer = ____timer.Timer
|
|
10
|
+
local ____frame = require("core.types.frame")
|
|
11
|
+
local FRAME_MAX_Y = ____frame.FRAME_MAX_Y
|
|
12
|
+
local FRAME_MIN_Y = ____frame.FRAME_MIN_Y
|
|
13
|
+
local getFrameMinXMaxX = ____frame.getFrameMinXMaxX
|
|
6
14
|
local getHandleId = GetHandleId
|
|
7
15
|
local setCameraField = SetCameraField
|
|
8
16
|
local getCameraField = GetCameraField
|
|
9
17
|
local setCameraPosition = SetCameraPosition
|
|
18
|
+
local getCameraEyePositionX = GetCameraEyePositionX
|
|
19
|
+
local getCameraEyePositionY = GetCameraEyePositionY
|
|
20
|
+
local getCameraEyePositionZ = GetCameraEyePositionZ
|
|
10
21
|
local getCameraTargetPositionX = GetCameraTargetPositionX
|
|
11
22
|
local getCameraTargetPositionY = GetCameraTargetPositionY
|
|
12
23
|
local resetToGameCamera = ResetToGameCamera
|
|
24
|
+
local cos = math.cos
|
|
13
25
|
local deg = math.deg
|
|
14
|
-
local
|
|
26
|
+
local sin = math.sin
|
|
15
27
|
local memoized = {}
|
|
16
28
|
____exports.PlayerCamera = __TS__Class()
|
|
17
29
|
local PlayerCamera = ____exports.PlayerCamera
|
|
@@ -23,13 +35,17 @@ function PlayerCamera.prototype.____constructor(self, player)
|
|
|
23
35
|
end
|
|
24
36
|
memoized[id] = self
|
|
25
37
|
self.player = player
|
|
26
|
-
self.isLocal = player ==
|
|
38
|
+
self.isLocal = player == PLAYER_LOCAL_HANDLE
|
|
27
39
|
end
|
|
28
40
|
function PlayerCamera.prototype.reset(self)
|
|
29
41
|
if self.isLocal then
|
|
30
42
|
resetToGameCamera(0)
|
|
31
43
|
end
|
|
32
44
|
end
|
|
45
|
+
function PlayerCamera.isUnitInView(self, unit)
|
|
46
|
+
local ____, ____, isInView = ____exports.worldCoordinatesToFrame(unit.x, unit.y, unit.z)
|
|
47
|
+
return isInView
|
|
48
|
+
end
|
|
33
49
|
function PlayerCamera.of(self, player)
|
|
34
50
|
return memoized[getHandleId(player)] or __TS__New(____exports.PlayerCamera, player)
|
|
35
51
|
end
|
|
@@ -159,4 +175,62 @@ __TS__SetDescriptor(
|
|
|
159
175
|
},
|
|
160
176
|
true
|
|
161
177
|
)
|
|
178
|
+
local cameraEyeX = 0
|
|
179
|
+
local cameraEyeY = 0
|
|
180
|
+
local cameraEyeZ = 0
|
|
181
|
+
local cameraAngleOfAttack = 0
|
|
182
|
+
local cameraAngleOfAttackCos = 0
|
|
183
|
+
local cameraAngleOfAttackSin = 0
|
|
184
|
+
local cameraRotation = 0
|
|
185
|
+
local cameraRotationCos = 0
|
|
186
|
+
local cameraRotationSin = 0
|
|
187
|
+
local cameraAngleOfAttackCosRotationCos = 0
|
|
188
|
+
local cameraAngleOfAttackCosRotationSin = 0
|
|
189
|
+
local cameraAngleOfAttackSinRotationCos = 0
|
|
190
|
+
local cameraAngleOfAttackSinRotationSin = 0
|
|
191
|
+
local yCenterScreenShift = 0
|
|
192
|
+
local scaleFactor = 0
|
|
193
|
+
local frameMinX = 0
|
|
194
|
+
local frameMaxX = 0
|
|
195
|
+
local isCameraViewPrecalculated = false
|
|
196
|
+
local function precalculateCameraView()
|
|
197
|
+
cameraEyeX = getCameraEyePositionX()
|
|
198
|
+
cameraEyeY = getCameraEyePositionY()
|
|
199
|
+
cameraEyeZ = getCameraEyePositionZ()
|
|
200
|
+
cameraAngleOfAttack = getCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK)
|
|
201
|
+
cameraAngleOfAttackCos = cos(cameraAngleOfAttack)
|
|
202
|
+
cameraAngleOfAttackSin = sin(cameraAngleOfAttack)
|
|
203
|
+
cameraRotation = getCameraField(CAMERA_FIELD_ROTATION)
|
|
204
|
+
cameraRotationCos = cos(cameraRotation)
|
|
205
|
+
cameraRotationSin = sin(cameraRotation)
|
|
206
|
+
cameraAngleOfAttackCosRotationCos = cameraAngleOfAttackCos * cameraRotationCos
|
|
207
|
+
cameraAngleOfAttackCosRotationSin = cameraAngleOfAttackCos * cameraRotationSin
|
|
208
|
+
cameraAngleOfAttackSinRotationCos = cameraAngleOfAttackSin * cameraRotationCos
|
|
209
|
+
cameraAngleOfAttackSinRotationSin = cameraAngleOfAttackSin * cameraRotationSin
|
|
210
|
+
yCenterScreenShift = 0.1284 * cameraAngleOfAttackCos
|
|
211
|
+
local cameraFieldOfView = getCameraField(CAMERA_FIELD_FIELD_OF_VIEW)
|
|
212
|
+
scaleFactor = 0.0524 * cameraFieldOfView ^ 3 - 0.0283 * cameraFieldOfView ^ 2 + 1.061 * cameraFieldOfView
|
|
213
|
+
frameMinX, frameMaxX = getFrameMinXMaxX()
|
|
214
|
+
isCameraViewPrecalculated = true
|
|
215
|
+
end
|
|
216
|
+
Timer.onPeriod[1 / 64]:addListener(
|
|
217
|
+
4,
|
|
218
|
+
function()
|
|
219
|
+
isCameraViewPrecalculated = false
|
|
220
|
+
end
|
|
221
|
+
)
|
|
222
|
+
---
|
|
223
|
+
-- @internal For use by internal systems only.
|
|
224
|
+
____exports.worldCoordinatesToFrame = function(x, y, z)
|
|
225
|
+
if not isCameraViewPrecalculated then
|
|
226
|
+
precalculateCameraView()
|
|
227
|
+
end
|
|
228
|
+
local dx = x - cameraEyeX
|
|
229
|
+
local dy = y - cameraEyeY
|
|
230
|
+
local dz = z - cameraEyeZ
|
|
231
|
+
local xPrime = scaleFactor * (-cameraAngleOfAttackCosRotationCos * dx - cameraAngleOfAttackCosRotationSin * dy - cameraAngleOfAttackSin * dz)
|
|
232
|
+
local frameX = 0.4 + (cameraRotationCos * dy - cameraRotationSin * dx) / xPrime
|
|
233
|
+
local frameY = 0.42625 - yCenterScreenShift + (cameraAngleOfAttackSinRotationCos * dx + cameraAngleOfAttackSinRotationSin * dy - cameraAngleOfAttackCos * dz) / xPrime
|
|
234
|
+
return frameX, frameY, xPrime < 0 and frameX >= frameMinX and frameX <= frameMaxX and frameY >= FRAME_MIN_Y and frameY <= FRAME_MAX_Y
|
|
235
|
+
end
|
|
162
236
|
return ____exports
|
package/core/types/timer.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ export declare class Timer extends AbstractDestroyable {
|
|
|
22
22
|
pause(): void;
|
|
23
23
|
resume(): void;
|
|
24
24
|
static create(): Timer;
|
|
25
|
-
static run<
|
|
25
|
+
static run<T, K extends KeysOfType<T, (this: T, ...args: any) => any>>(object: T, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): void;
|
|
26
|
+
static run<Args extends any[]>(callback: (this: void, ...args: Args) => void, ...args: Args): void;
|
|
26
27
|
static simple<Args extends any[]>(timeout: number, callback: (...args: Args) => void, ...args: Args): Timer;
|
|
27
28
|
static periodic<Args extends any[]>(period: number, callback: (this: void, timer: Timer, ...args: Args) => void, ...args: Args): Timer;
|
|
28
29
|
static counted(period: number, count: number, callback: (this: void, timer: Timer) => void): Timer;
|
package/core/types/timer.lua
CHANGED
|
@@ -24,6 +24,7 @@ local getHandleId = GetHandleId
|
|
|
24
24
|
local ____pcall = _G.pcall
|
|
25
25
|
local ____print = _G.print
|
|
26
26
|
local select = _G.select
|
|
27
|
+
local ____type = _G.type
|
|
27
28
|
local safeCall = warpack.safeCall
|
|
28
29
|
local corunning = coroutine.running
|
|
29
30
|
local coresume = coroutine.resume
|
|
@@ -81,8 +82,12 @@ end
|
|
|
81
82
|
function Timer.create(self)
|
|
82
83
|
return __TS__New(____exports.Timer)
|
|
83
84
|
end
|
|
84
|
-
function Timer.run(self,
|
|
85
|
-
|
|
85
|
+
function Timer.run(self, objectOrCallback, keyOrFirstArg, ...)
|
|
86
|
+
if ____type(objectOrCallback) == "function" then
|
|
87
|
+
____exports.Timer:simple(0, objectOrCallback, keyOrFirstArg, ...)
|
|
88
|
+
else
|
|
89
|
+
____exports.Timer:simple(0, objectOrCallback[keyOrFirstArg], objectOrCallback, ...)
|
|
90
|
+
end
|
|
86
91
|
end
|
|
87
92
|
function Timer.simple(self, timeout, callback, ...)
|
|
88
93
|
local timer = __TS__New(____exports.Timer)
|
package/decl/native.d.ts
CHANGED
|
@@ -388,13 +388,15 @@ declare interface jmovetype extends jhandle {
|
|
|
388
388
|
declare interface jtargetflag extends jhandle {
|
|
389
389
|
__jtargetflag: never
|
|
390
390
|
}
|
|
391
|
-
declare
|
|
391
|
+
declare type jarmortype = symbol &
|
|
392
|
+
jhandle & {
|
|
392
393
|
__jarmortype: never
|
|
393
394
|
}
|
|
394
395
|
declare interface jheroattribute extends jhandle {
|
|
395
396
|
__jheroattribute: never
|
|
396
397
|
}
|
|
397
|
-
declare
|
|
398
|
+
declare type jdefensetype = symbol &
|
|
399
|
+
jhandle & {
|
|
398
400
|
__jdefensetype: never
|
|
399
401
|
}
|
|
400
402
|
declare interface jregentype extends jhandle {
|
package/engine/behavior.d.ts
CHANGED
|
@@ -24,5 +24,7 @@ export declare abstract class Behavior<T extends AnyNotNil, PeriodicActionParame
|
|
|
24
24
|
static forFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], K extends KeysOfType<T, (this: T, ...args: any) => any>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, count: number, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): number;
|
|
25
25
|
static forAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => unknown, ...parameters: ConsumerParameters): number;
|
|
26
26
|
static forAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], K extends KeysOfType<T, (this: T, ...args: any) => any>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): number;
|
|
27
|
+
static reduce<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[], Accumulator, R>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, operation: (this: void, accumulator: Accumulator, value: R) => Accumulator, initial: Accumulator, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => R, ...parameters: ConsumerParameters): Accumulator;
|
|
28
|
+
static reduce<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], Accumulator, R, K extends KeysOfType<T, (this: T, ...args: any) => R>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, operation: (this: void, accumulator: Accumulator, value: R) => Accumulator, initial: Accumulator, key: K, ...parameters: T[K] extends (this: T, ...args: any) => R ? Parameters<T[K]> : never): Accumulator;
|
|
27
29
|
}
|
|
28
30
|
export {};
|
package/engine/behavior.lua
CHANGED
|
@@ -1,18 +1,52 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
-
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
5
|
local ____exports = {}
|
|
6
6
|
local ____destroyable = require("destroyable")
|
|
7
7
|
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
8
8
|
local ____timer = require("core.types.timer")
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
|
+
local ____functions = require("utility.functions")
|
|
11
|
+
local increment = ____functions.increment
|
|
10
12
|
local safeCall = warpack.safeCall
|
|
11
13
|
local firstBehaviorByObject = {}
|
|
12
14
|
local lastBehaviorByObject = {}
|
|
13
15
|
local function invokeBehaviorOnPeriod(behavior, ...)
|
|
14
16
|
behavior.onPeriod(behavior, ...)
|
|
15
17
|
end
|
|
18
|
+
local function reduceBehaviors(behaviorConstructor, object, operation, initial, consumerOrKey, ...)
|
|
19
|
+
local accumulator = initial
|
|
20
|
+
local behavior = firstBehaviorByObject[object]
|
|
21
|
+
if behavior ~= nil then
|
|
22
|
+
if type(consumerOrKey) == "function" then
|
|
23
|
+
repeat
|
|
24
|
+
do
|
|
25
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
26
|
+
local isSuccessful, result = safeCall(consumerOrKey, behavior, ...)
|
|
27
|
+
if isSuccessful then
|
|
28
|
+
accumulator = operation(accumulator, result)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
behavior = behavior[1]
|
|
32
|
+
end
|
|
33
|
+
until not (behavior ~= nil)
|
|
34
|
+
else
|
|
35
|
+
repeat
|
|
36
|
+
do
|
|
37
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
38
|
+
local isSuccessful, result = safeCall(behavior[consumerOrKey], behavior, ...)
|
|
39
|
+
if isSuccessful then
|
|
40
|
+
accumulator = operation(accumulator, result)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
behavior = behavior[1]
|
|
44
|
+
end
|
|
45
|
+
until not (behavior ~= nil)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
return accumulator
|
|
49
|
+
end
|
|
16
50
|
____exports.Behavior = __TS__Class()
|
|
17
51
|
local Behavior = ____exports.Behavior
|
|
18
52
|
Behavior.name = "Behavior"
|
|
@@ -151,31 +185,23 @@ function Behavior.forFirst(self, object, count, consumerOrKey, ...)
|
|
|
151
185
|
return behaviorsCount
|
|
152
186
|
end
|
|
153
187
|
function Behavior.forAll(self, object, consumerOrKey, ...)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
behaviorsCount = behaviorsCount + 1
|
|
173
|
-
end
|
|
174
|
-
behavior = behavior[1]
|
|
175
|
-
end
|
|
176
|
-
until not (behavior ~= nil)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
return behaviorsCount
|
|
188
|
+
return reduceBehaviors(
|
|
189
|
+
self,
|
|
190
|
+
object,
|
|
191
|
+
increment,
|
|
192
|
+
0,
|
|
193
|
+
consumerOrKey,
|
|
194
|
+
...
|
|
195
|
+
)
|
|
196
|
+
end
|
|
197
|
+
function Behavior.reduce(self, object, operation, initial, consumerOrKey, ...)
|
|
198
|
+
return reduceBehaviors(
|
|
199
|
+
self,
|
|
200
|
+
object,
|
|
201
|
+
operation,
|
|
202
|
+
initial,
|
|
203
|
+
consumerOrKey,
|
|
204
|
+
...
|
|
205
|
+
)
|
|
180
206
|
end
|
|
181
207
|
return ____exports
|
|
@@ -148,7 +148,7 @@ function ApplyBuffChannelingTargetAbilityBehavior.prototype.onStop(self)
|
|
|
148
148
|
self.buff = nil
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
|
-
Buff.
|
|
151
|
+
Buff.beingDestroyedEvent:addListener(function(buff)
|
|
152
152
|
local behavior = behaviorByBuff[buff]
|
|
153
153
|
if behavior ~= nil then
|
|
154
154
|
behaviorByBuff[buff] = nil
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { AbilityBehavior } from "../ability";
|
|
3
3
|
import { Unit } from "../../internal/unit";
|
|
4
4
|
export declare abstract class EmulateImpactAbilityBehavior extends AbilityBehavior {
|
|
5
|
-
protected emulateImpact(caster: Unit):
|
|
5
|
+
protected emulateImpact(caster: Unit): boolean;
|
|
6
6
|
}
|
|
@@ -28,7 +28,7 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
|
28
28
|
local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
|
|
29
29
|
local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
|
|
30
30
|
if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost or __TS__InstanceOf(self.ability, UnitAbility) and self.ability.isDisabled then
|
|
31
|
-
return
|
|
31
|
+
return false
|
|
32
32
|
end
|
|
33
33
|
caster.mana = caster.mana - manaCost
|
|
34
34
|
self.ability.cooldownRemaining = max(cooldown, MINIMUM_POSITIVE_NORMALIZED_FLOAT)
|
|
@@ -38,5 +38,6 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
|
38
38
|
Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
|
|
39
39
|
end
|
|
40
40
|
Event.invoke(Unit.abilityImpactEvent, caster, self.ability)
|
|
41
|
+
return true
|
|
41
42
|
end
|
|
42
43
|
return ____exports
|
|
@@ -8,7 +8,7 @@ export declare class RestoreManaSelfAbilityBehavior extends AbilityBehavior {
|
|
|
8
8
|
constructor(ability: Ability, mana: AbilityDependentValue<number>);
|
|
9
9
|
onImpact(caster: Unit): void;
|
|
10
10
|
}
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class RestoreManaTargetAbilityBehavior extends AbilityBehavior {
|
|
12
12
|
private readonly mana;
|
|
13
13
|
constructor(ability: Ability, mana: AbilityDependentValue<number>);
|
|
14
14
|
onUnitTargetImpact(caster: Unit, target: Unit): void;
|
|
@@ -15,15 +15,15 @@ end
|
|
|
15
15
|
function RestoreManaSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
16
16
|
caster.mana = caster.mana + self:resolveCurrentAbilityDependentValue(self.mana)
|
|
17
17
|
end
|
|
18
|
-
____exports.
|
|
19
|
-
local
|
|
20
|
-
|
|
21
|
-
__TS__ClassExtends(
|
|
22
|
-
function
|
|
18
|
+
____exports.RestoreManaTargetAbilityBehavior = __TS__Class()
|
|
19
|
+
local RestoreManaTargetAbilityBehavior = ____exports.RestoreManaTargetAbilityBehavior
|
|
20
|
+
RestoreManaTargetAbilityBehavior.name = "RestoreManaTargetAbilityBehavior"
|
|
21
|
+
__TS__ClassExtends(RestoreManaTargetAbilityBehavior, AbilityBehavior)
|
|
22
|
+
function RestoreManaTargetAbilityBehavior.prototype.____constructor(self, ability, mana)
|
|
23
23
|
AbilityBehavior.prototype.____constructor(self, ability)
|
|
24
24
|
self.mana = mana
|
|
25
25
|
end
|
|
26
|
-
function
|
|
26
|
+
function RestoreManaTargetAbilityBehavior.prototype.onUnitTargetImpact(self, caster, target)
|
|
27
27
|
target.mana = target.mana + self:resolveCurrentAbilityDependentValue(self.mana)
|
|
28
28
|
end
|
|
29
29
|
return ____exports
|
|
@@ -5,7 +5,6 @@ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
|
5
5
|
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
7
7
|
local ____exports = {}
|
|
8
|
-
local createUnitEventListener
|
|
9
8
|
local ____behavior = require("engine.behavior")
|
|
10
9
|
local Behavior = ____behavior.Behavior
|
|
11
10
|
local ____unit = require("engine.unit")
|
|
@@ -30,17 +29,9 @@ local ____ability = require("engine.object-field.ability")
|
|
|
30
29
|
local AbilityField = ____ability.AbilityField
|
|
31
30
|
local AbilityLevelField = ____ability.AbilityLevelField
|
|
32
31
|
local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
|
|
33
|
-
local ____timer = require("core.types.timer")
|
|
34
|
-
local Timer = ____timer.Timer
|
|
35
32
|
local createBehaviorFunctionsByAbilityTypeId = {}
|
|
36
33
|
local exclusiveOnImpactHandlerAbilityBehaviorByAbility = setmetatable({}, {__mode = "k"})
|
|
37
|
-
local function
|
|
38
|
-
local unitEventListener = createUnitEventListener(key)
|
|
39
|
-
return function(unit, ability, ...)
|
|
40
|
-
Timer:run(unitEventListener, unit, ability, ...)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
createUnitEventListener = function(key)
|
|
34
|
+
local function createUnitEventListener(key)
|
|
44
35
|
return function(unit, ability, ...)
|
|
45
36
|
____exports.AbilityBehavior:forAll(ability, key, unit, ...)
|
|
46
37
|
end
|
|
@@ -275,12 +266,12 @@ __TS__SetDescriptor(
|
|
|
275
266
|
Unit.abilityPointTargetChannelingStartEvent:addListener(createUnitEventListener("onPointTargetChannelingStart"))
|
|
276
267
|
Unit.abilityNoTargetChannelingStartEvent:addListener(createUnitEventListener("onNoTargetChannelingStart"))
|
|
277
268
|
Unit.abilityImpactEvent:addListener(createUnitEventListener("onImpact"))
|
|
278
|
-
Unit.
|
|
279
|
-
Unit.
|
|
280
|
-
Unit.
|
|
281
|
-
Unit.
|
|
282
|
-
Unit.
|
|
283
|
-
Unit.
|
|
269
|
+
Unit.abilityWidgetTargetImpactEvent:addListener(createUnitEventListener("onWidgetTargetImpact"))
|
|
270
|
+
Unit.abilityUnitTargetImpactEvent:addListener(createUnitEventListener("onUnitTargetImpact"))
|
|
271
|
+
Unit.abilityItemTargetImpactEvent:addListener(createUnitEventListener("onItemTargetImpact"))
|
|
272
|
+
Unit.abilityDestructibleTargetImpactEvent:addListener(createUnitEventListener("onDestructibleTargetImpact"))
|
|
273
|
+
Unit.abilityPointTargetImpactEvent:addListener(createUnitEventListener("onPointTargetImpact"))
|
|
274
|
+
Unit.abilityNoTargetImpactEvent:addListener(createUnitEventListener("onNoTargetImpact"))
|
|
284
275
|
Unit.abilityChannelingFinishEvent:addListener(createUnitEventListener("onChannelingFinish"))
|
|
285
276
|
Unit.abilityStopEvent:addListener(createUnitEventListener("onStop"))
|
|
286
277
|
end)(AbilityBehavior)
|
|
@@ -10,9 +10,11 @@ export type StunImmunityUnitBehaviourParameters = {
|
|
|
10
10
|
textTagText?: string;
|
|
11
11
|
};
|
|
12
12
|
export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
13
|
-
|
|
13
|
+
readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
|
|
14
14
|
static defaultParameters: StunImmunityUnitBehaviourParameters;
|
|
15
|
-
constructor(unit: Unit, parameters?: StunImmunityUnitBehaviourParameters);
|
|
15
|
+
constructor(unit: Unit, parameters?: Readonly<StunImmunityUnitBehaviourParameters>);
|
|
16
16
|
protected onDestroy(): Destructor;
|
|
17
|
-
|
|
17
|
+
onDamageReceived(): void;
|
|
18
|
+
onTargetingAbilityChannelingStart(): void;
|
|
19
|
+
onTargetingAbilityImpact(): void;
|
|
18
20
|
}
|
|
@@ -12,31 +12,46 @@ local flatMapToLuaSet = ____arrays.flatMapToLuaSet
|
|
|
12
12
|
local map = ____arrays.map
|
|
13
13
|
local ____text_2Dtag = require("engine.text-tag")
|
|
14
14
|
local TextTag = ____text_2Dtag.TextTag
|
|
15
|
+
local ____timer = require("core.types.timer")
|
|
16
|
+
local Timer = ____timer.Timer
|
|
15
17
|
local DEFAULT_BUFF_TYPE_IDS = postcompile(function()
|
|
16
18
|
return flatMapToLuaSet(
|
|
17
19
|
AbilityType:getAllByBaseIds(map({
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
20
|
+
"AHtb",
|
|
21
|
+
"AHbh",
|
|
22
|
+
"AOws",
|
|
23
|
+
"AOw2",
|
|
24
|
+
"AUim",
|
|
25
|
+
"Acyc",
|
|
26
|
+
"ANfb",
|
|
27
|
+
"ANsb",
|
|
28
|
+
"ANcs",
|
|
29
|
+
"ANc1",
|
|
30
|
+
"ANc2",
|
|
31
|
+
"ANc3",
|
|
32
|
+
"ACbh",
|
|
33
|
+
"ANbh",
|
|
34
|
+
"SCc1",
|
|
35
|
+
"ACcy",
|
|
36
|
+
"ANb2",
|
|
37
|
+
"Awrs",
|
|
38
|
+
"Awrh",
|
|
39
|
+
"Awrg",
|
|
40
|
+
"ACtb",
|
|
41
|
+
"ACcb"
|
|
36
42
|
}, fourCC)),
|
|
37
43
|
function(abilityType) return __TS__ArrayFlat(abilityType.buffTypeIds) end
|
|
38
44
|
)
|
|
39
45
|
end)
|
|
46
|
+
local function process(behavior)
|
|
47
|
+
local hasRemovedBuffs = false
|
|
48
|
+
for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
|
|
49
|
+
hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
|
|
50
|
+
end
|
|
51
|
+
if hasRemovedBuffs and behavior.parameters.textTagText ~= nil then
|
|
52
|
+
TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
40
55
|
____exports.StunImmunityUnitBehavior = __TS__Class()
|
|
41
56
|
local StunImmunityUnitBehavior = ____exports.StunImmunityUnitBehavior
|
|
42
57
|
StunImmunityUnitBehavior.name = "StunImmunityUnitBehavior"
|
|
@@ -48,20 +63,21 @@ function StunImmunityUnitBehavior.prototype.____constructor(self, unit, paramete
|
|
|
48
63
|
UnitBehavior.prototype.____constructor(self, unit)
|
|
49
64
|
self.parameters = parameters
|
|
50
65
|
unit:decrementStunCounter()
|
|
51
|
-
self
|
|
66
|
+
process(self)
|
|
52
67
|
end
|
|
53
68
|
function StunImmunityUnitBehavior.prototype.onDestroy(self)
|
|
54
69
|
self.unit:incrementStunCounter()
|
|
55
70
|
return UnitBehavior.prototype.onDestroy(self)
|
|
56
71
|
end
|
|
57
|
-
function StunImmunityUnitBehavior.prototype.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
function StunImmunityUnitBehavior.prototype.onDamageReceived(self)
|
|
73
|
+
process(self)
|
|
74
|
+
Timer:run(process, self)
|
|
75
|
+
end
|
|
76
|
+
function StunImmunityUnitBehavior.prototype.onTargetingAbilityChannelingStart(self)
|
|
77
|
+
process(self)
|
|
78
|
+
end
|
|
79
|
+
function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
|
|
80
|
+
process(self)
|
|
65
81
|
end
|
|
66
82
|
StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
|
|
67
83
|
return ____exports
|
|
@@ -9,13 +9,15 @@ import type { AbilityBehavior } from "./ability";
|
|
|
9
9
|
import { Event } from "../../event";
|
|
10
10
|
import { Destructor } from "../../destroyable";
|
|
11
11
|
import type { Widget } from "../../core/types/widget";
|
|
12
|
+
import { Destructable } from "../../core/types/destructable";
|
|
13
|
+
import type { Buff } from "../buff";
|
|
12
14
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
13
15
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
14
16
|
constructor(unit: Unit);
|
|
15
17
|
protected onDestroy(): Destructor;
|
|
16
18
|
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
17
19
|
get unit(): Unit;
|
|
18
|
-
registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this,
|
|
20
|
+
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;
|
|
19
21
|
onImmediateOrder(orderId: number): void;
|
|
20
22
|
onTargetOrder(orderId: number, target: Widget): void;
|
|
21
23
|
onPointOrder(orderId: number, x: number, y: number): void;
|
|
@@ -31,8 +33,17 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
31
33
|
onAbilityLost(ability: Ability): void;
|
|
32
34
|
onAbilityChannelingStart(ability: Ability): void;
|
|
33
35
|
onAbilityImpact(ability: Ability): void;
|
|
36
|
+
onAbilityWidgetTargetImpact(ability: Ability, target: Widget): void;
|
|
37
|
+
onAbilityUnitTargetImpact(ability: Ability, target: Unit): void;
|
|
38
|
+
onAbilityItemTargetImpact(ability: Ability, target: Item): void;
|
|
39
|
+
onAbilityDestructibleTargetImpact(ability: Ability, target: Destructable): void;
|
|
40
|
+
onAbilityPointTargetImpact(ability: Ability, x: number, y: number): void;
|
|
41
|
+
onAbilityNoTargetImpact(ability: Ability): void;
|
|
34
42
|
onAbilityChannelingFinish(ability: Ability): void;
|
|
35
43
|
onAbilityStop(ability: Ability): void;
|
|
44
|
+
onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
|
|
45
|
+
onTargetingAbilityImpact(ability: Ability, source: Unit): void;
|
|
46
|
+
onBuffGained(buff: Buff): void;
|
|
36
47
|
onItemDropped(item: Item): void;
|
|
37
48
|
onItemPickedUp(item: Item): void;
|
|
38
49
|
onItemUsed(item: Item): void;
|