warscript 0.0.1-dev.90f1d49 → 0.0.1-dev.91a4dce
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 +1 -2
- package/attributes.lua +9 -0
- package/core/types/frame.lua +24 -21
- package/core/types/player.d.ts +15 -0
- package/core/types/player.lua +40 -7
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +3 -1
- package/core/types/timer.lua +27 -2
- package/decl/native.d.ts +6 -4
- package/engine/behavior.d.ts +5 -0
- package/engine/behavior.lua +106 -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 +11 -3
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.lua +8 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
- package/engine/behaviour/unit/stun-immunity.lua +52 -27
- package/engine/behaviour/unit.d.ts +33 -1
- package/engine/behaviour/unit.lua +190 -4
- package/engine/buff.d.ts +2 -4
- package/engine/buff.lua +68 -83
- package/engine/internal/ability.d.ts +7 -1
- package/engine/internal/ability.lua +49 -9
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +16 -16
- package/engine/internal/item.lua +135 -49
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +98 -9
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit-missile-launch.lua +42 -14
- package/engine/internal/unit.d.ts +16 -7
- package/engine/internal/unit.lua +182 -86
- 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/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type.lua +5 -4
- 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/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +8 -5
- package/engine/object-field.lua +90 -76
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +249 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +1 -1
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
- package/utility/lua-maps.d.ts +12 -2
- package/utility/lua-maps.lua +37 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
- package/utility/types.d.ts +3 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local getLocationZ = GetLocationZ
|
|
3
|
+
local moveLocation = MoveLocation
|
|
4
|
+
local location = Location(0, 0)
|
|
5
|
+
---
|
|
6
|
+
-- @internal For use by internal systems only.
|
|
7
|
+
____exports.getTerrainZ = function(x, y)
|
|
8
|
+
moveLocation(location, x, y)
|
|
9
|
+
return getLocationZ(location)
|
|
10
|
+
end
|
|
11
|
+
return ____exports
|
|
@@ -150,3 +150,38 @@ declare module "../unit" {
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
declare module "../unit" {
|
|
154
|
+
namespace Unit {
|
|
155
|
+
const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
declare module "../unit" {
|
|
159
|
+
namespace Unit {
|
|
160
|
+
const abilityWidgetTargetImpactEvent: DispatchingEvent<[Unit, Ability, Widget]>;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
declare module "../unit" {
|
|
164
|
+
namespace Unit {
|
|
165
|
+
const abilityUnitTargetImpactEvent: DispatchingEvent<[Unit, Ability, Unit]>;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
declare module "../unit" {
|
|
169
|
+
namespace Unit {
|
|
170
|
+
const abilityItemTargetImpactEvent: DispatchingEvent<[Unit, Ability, Item]>;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
declare module "../unit" {
|
|
174
|
+
namespace Unit {
|
|
175
|
+
const abilityDestructibleTargetImpactEvent: DispatchingEvent<[Unit, Ability, Destructable]>;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
declare module "../unit" {
|
|
179
|
+
namespace Unit {
|
|
180
|
+
const abilityPointTargetImpactEvent: DispatchingEvent<[Unit, Ability, number, number]>;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
declare module "../unit" {
|
|
184
|
+
namespace Unit {
|
|
185
|
+
const abilityNoTargetImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -21,6 +21,13 @@ local ____preconditions = require("utility.preconditions")
|
|
|
21
21
|
local checkNotNull = ____preconditions.checkNotNull
|
|
22
22
|
local ____lazy = require("utility.lazy")
|
|
23
23
|
local lazyRecord = ____lazy.lazyRecord
|
|
24
|
+
local ____timer = require("core.types.timer")
|
|
25
|
+
local consumeZeroTimerCallback = ____timer.consumeZeroTimerCallback
|
|
26
|
+
local Timer = ____timer.Timer
|
|
27
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
28
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
29
|
+
local ____attributes = require("attributes")
|
|
30
|
+
local attribute = ____attributes.attribute
|
|
24
31
|
local eventInvoke = Event.invoke
|
|
25
32
|
local condition = Condition
|
|
26
33
|
local createTrigger = CreateTrigger
|
|
@@ -345,21 +352,17 @@ rawset(
|
|
|
345
352
|
extractAbilityTypeId
|
|
346
353
|
)
|
|
347
354
|
)
|
|
355
|
+
local internalAbilityChannelingFinishEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters)
|
|
348
356
|
rawset(
|
|
349
357
|
Unit,
|
|
350
358
|
"abilityChannelingFinishEvent",
|
|
351
|
-
createDispatchingEvent(
|
|
352
|
-
__TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters),
|
|
353
|
-
extractAbilityTypeId
|
|
354
|
-
)
|
|
359
|
+
createDispatchingEvent(internalAbilityChannelingFinishEvent, extractAbilityTypeId)
|
|
355
360
|
)
|
|
361
|
+
local internalAbilityStopEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters)
|
|
356
362
|
rawset(
|
|
357
363
|
Unit,
|
|
358
364
|
"abilityStopEvent",
|
|
359
|
-
createDispatchingEvent(
|
|
360
|
-
__TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters),
|
|
361
|
-
extractAbilityTypeId
|
|
362
|
-
)
|
|
365
|
+
createDispatchingEvent(internalAbilityStopEvent, extractAbilityTypeId)
|
|
363
366
|
)
|
|
364
367
|
rawset(
|
|
365
368
|
Unit,
|
|
@@ -376,7 +379,7 @@ rawset(
|
|
|
376
379
|
condition(function()
|
|
377
380
|
local unit = Unit:of(getTriggerUnit())
|
|
378
381
|
if unit ~= nil then
|
|
379
|
-
local ability = unit:
|
|
382
|
+
local ability = unit:getAbility(abilityTypeId)
|
|
380
383
|
if ability ~= nil then
|
|
381
384
|
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
382
385
|
end
|
|
@@ -388,4 +391,90 @@ rawset(
|
|
|
388
391
|
end)
|
|
389
392
|
end)
|
|
390
393
|
)
|
|
394
|
+
local internalAbilityImpactEvent = __TS__New(Event)
|
|
395
|
+
local impactCallbackIdAttribute = attribute()
|
|
396
|
+
local function invokeImpactEvent(unit, ability, ...)
|
|
397
|
+
ability[impactCallbackIdAttribute] = nil
|
|
398
|
+
eventInvoke(internalAbilityImpactEvent, unit, ability, ...)
|
|
399
|
+
end
|
|
400
|
+
internalAbilityChannelingStartEvent:addListener(
|
|
401
|
+
999999,
|
|
402
|
+
function(unit, ability, ...)
|
|
403
|
+
ability[impactCallbackIdAttribute] = Timer:run(invokeImpactEvent, unit, ability, ...)
|
|
404
|
+
end
|
|
405
|
+
)
|
|
406
|
+
local function consumeImpactCallback(_, ability)
|
|
407
|
+
local impactCallbackId = ability[impactCallbackIdAttribute]
|
|
408
|
+
if impactCallbackId ~= nil then
|
|
409
|
+
consumeZeroTimerCallback(impactCallbackId)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
internalAbilityChannelingFinishEvent:addListener(999999, consumeImpactCallback)
|
|
413
|
+
internalAbilityStopEvent:addListener(999999, consumeImpactCallback)
|
|
414
|
+
rawset(
|
|
415
|
+
Unit,
|
|
416
|
+
"abilityImpactEvent",
|
|
417
|
+
createDispatchingEvent(
|
|
418
|
+
createCommonEvent(internalAbilityImpactEvent),
|
|
419
|
+
extractAbilityTypeId
|
|
420
|
+
)
|
|
421
|
+
)
|
|
422
|
+
rawset(
|
|
423
|
+
Unit,
|
|
424
|
+
"abilityWidgetTargetImpactEvent",
|
|
425
|
+
createDispatchingEvent(
|
|
426
|
+
createWidgetTargetEvent(internalAbilityImpactEvent),
|
|
427
|
+
extractAbilityTypeId
|
|
428
|
+
)
|
|
429
|
+
)
|
|
430
|
+
rawset(
|
|
431
|
+
Unit,
|
|
432
|
+
"abilityUnitTargetImpactEvent",
|
|
433
|
+
createDispatchingEvent(
|
|
434
|
+
createUnitTargetEvent(internalAbilityImpactEvent),
|
|
435
|
+
extractAbilityTypeId
|
|
436
|
+
)
|
|
437
|
+
)
|
|
438
|
+
rawset(
|
|
439
|
+
Unit,
|
|
440
|
+
"abilityItemTargetImpactEvent",
|
|
441
|
+
createDispatchingEvent(
|
|
442
|
+
createItemTargetEvent(internalAbilityImpactEvent),
|
|
443
|
+
extractAbilityTypeId
|
|
444
|
+
)
|
|
445
|
+
)
|
|
446
|
+
rawset(
|
|
447
|
+
Unit,
|
|
448
|
+
"abilityDestructibleTargetImpactEvent",
|
|
449
|
+
createDispatchingEvent(
|
|
450
|
+
createDestructibleTargetEvent(internalAbilityImpactEvent),
|
|
451
|
+
extractAbilityTypeId
|
|
452
|
+
)
|
|
453
|
+
)
|
|
454
|
+
rawset(
|
|
455
|
+
Unit,
|
|
456
|
+
"abilityPointTargetImpactEvent",
|
|
457
|
+
createDispatchingEvent(
|
|
458
|
+
createPointTargetEvent(internalAbilityImpactEvent),
|
|
459
|
+
extractAbilityTypeId
|
|
460
|
+
)
|
|
461
|
+
)
|
|
462
|
+
rawset(
|
|
463
|
+
Unit,
|
|
464
|
+
"abilityNoTargetImpactEvent",
|
|
465
|
+
createDispatchingEvent(
|
|
466
|
+
createNoTargetEvent(internalAbilityImpactEvent),
|
|
467
|
+
extractAbilityTypeId
|
|
468
|
+
)
|
|
469
|
+
)
|
|
470
|
+
local spellEffectOnlyAbilityTypeIds = luaSetOf(fourCC("AAns"))
|
|
471
|
+
internalAbilityChannelingStartEvent:addListener(
|
|
472
|
+
-999999,
|
|
473
|
+
function(unit, ability)
|
|
474
|
+
if spellEffectOnlyAbilityTypeIds[ability.parentTypeId] ~= nil then
|
|
475
|
+
eventInvoke(internalAbilityChannelingFinishEvent, unit, ability)
|
|
476
|
+
eventInvoke(internalAbilityStopEvent, unit, ability)
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
)
|
|
391
480
|
return ____exports
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { CombatClassifications } from "../../object-data/auxiliary/combat-classification";
|
|
3
3
|
declare module "../unit" {
|
|
4
4
|
interface Unit {
|
|
5
|
-
isAllowedTarget(this: Unit, source: Unit, allowedTargetCombatClassifications
|
|
5
|
+
isAllowedTarget(this: Unit, source: Unit, allowedTargetCombatClassifications?: CombatClassifications): boolean;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
declare module "../unit" {
|
|
@@ -5,7 +5,15 @@ local initializeFilterTargetState = ____combat_2Dclassification.initializeFilter
|
|
|
5
5
|
local ____unit = require("engine.internal.unit")
|
|
6
6
|
local Unit = ____unit.Unit
|
|
7
7
|
Unit.prototype.isAllowedTarget = function(self, source, allowedTargetCombatClassifications)
|
|
8
|
-
|
|
8
|
+
if allowedTargetCombatClassifications ~= nil then
|
|
9
|
+
initializeFilterTargetState(source, allowedTargetCombatClassifications)
|
|
10
|
+
return filterTarget(self)
|
|
11
|
+
end
|
|
12
|
+
initializeFilterTargetState(source, source.firstWeapon.allowedTargetCombatClassifications)
|
|
13
|
+
if filterTarget(self) then
|
|
14
|
+
return true
|
|
15
|
+
end
|
|
16
|
+
initializeFilterTargetState(source, source.secondWeapon.allowedTargetCombatClassifications)
|
|
9
17
|
return filterTarget(self)
|
|
10
18
|
end
|
|
11
19
|
Unit.getAllowedTargetsInRange = function(source, allowedTargetCombatClassifications, x, y, range)
|
|
@@ -1,46 +1,31 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__New = ____lualib.__TS__New
|
|
3
3
|
local ____exports = {}
|
|
4
|
-
local ____player = require("core.types.player")
|
|
5
|
-
local Player = ____player.Player
|
|
6
|
-
local ____math = require("math")
|
|
7
|
-
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
8
|
-
local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
|
|
9
4
|
local ____local_2Dclient = require("engine.local-client")
|
|
10
5
|
local LocalClient = ____local_2Dclient.LocalClient
|
|
11
6
|
local ____unit = require("engine.internal.unit")
|
|
12
7
|
local Unit = ____unit.Unit
|
|
13
8
|
local ____event = require("event")
|
|
14
9
|
local Event = ____event.Event
|
|
10
|
+
local ____synchronization = require("engine.synchronization")
|
|
11
|
+
local ObjectBus = ____synchronization.ObjectBus
|
|
15
12
|
local mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
16
13
|
rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
|
|
17
14
|
local mainSelectedUnitByPlayer = {}
|
|
18
|
-
local
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"",
|
|
23
|
-
0
|
|
15
|
+
local unitBus = __TS__New(
|
|
16
|
+
ObjectBus,
|
|
17
|
+
function(unit) return unit.syncId end,
|
|
18
|
+
function(syncId) return Unit:getBySyncId(syncId) end
|
|
24
19
|
)
|
|
25
|
-
BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
|
|
26
20
|
LocalClient.mainSelectedUnitChangeEvent:addListener(function()
|
|
27
|
-
|
|
28
|
-
local syncId = ____opt_0 and ____opt_0.syncId
|
|
29
|
-
BlzFrameSetValue(syncSlider, syncId or 0)
|
|
21
|
+
unitBus:send(LocalClient.mainSelectedUnit)
|
|
30
22
|
end)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function()
|
|
36
|
-
local player = Player:of(GetTriggerPlayer())
|
|
37
|
-
local mainSelectedUnit = Unit:getBySyncId(BlzGetTriggerFrameValue())
|
|
38
|
-
if mainSelectedUnit ~= mainSelectedUnitByPlayer[player] then
|
|
39
|
-
mainSelectedUnitByPlayer[player] = mainSelectedUnit
|
|
40
|
-
Event.invoke(mainSelectedUnitChangeEvent, player)
|
|
41
|
-
end
|
|
23
|
+
unitBus.event:addListener(function(player, unit)
|
|
24
|
+
if unit ~= mainSelectedUnitByPlayer[player] then
|
|
25
|
+
mainSelectedUnitByPlayer[player] = unit
|
|
26
|
+
Event.invoke(mainSelectedUnitChangeEvent, player)
|
|
42
27
|
end
|
|
43
|
-
)
|
|
28
|
+
end)
|
|
44
29
|
rawset(
|
|
45
30
|
Unit,
|
|
46
31
|
"getMainSelectedOf",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Widget } from "../../../core/types/widget";
|
|
3
|
+
export declare const enum OrderType {
|
|
4
|
+
IMMEDIATE = 0,
|
|
5
|
+
POINT = 1,
|
|
6
|
+
TARGET = 2
|
|
7
|
+
}
|
|
8
|
+
declare module "../unit" {
|
|
9
|
+
interface Unit {
|
|
10
|
+
readonly currentOrderType: OrderType;
|
|
11
|
+
readonly currentOrderId: number;
|
|
12
|
+
readonly currentOrderStartTime: number;
|
|
13
|
+
readonly currentOrderStartX: number;
|
|
14
|
+
readonly currentOrderStartY: number;
|
|
15
|
+
readonly currentOrderTargetX: number;
|
|
16
|
+
readonly currentOrderTargetY: number;
|
|
17
|
+
readonly currentOrderTarget?: Widget;
|
|
18
|
+
issueOrder(...order: [orderType: OrderType.IMMEDIATE, orderId: number] | [orderType: OrderType.POINT, orderId: number, x: number, y: number] | [orderType: OrderType.TARGET, orderId: number, target: Widget]): boolean;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____attributes = require("attributes")
|
|
5
|
+
local attribute = ____attributes.attribute
|
|
6
|
+
local ____unit = require("engine.internal.unit")
|
|
7
|
+
local Unit = ____unit.Unit
|
|
8
|
+
local ____game = require("core.game")
|
|
9
|
+
local elapsedTime = ____game.elapsedTime
|
|
10
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
11
|
+
local issueImmediateOrderById = IssueImmediateOrderById
|
|
12
|
+
local issuePointOrderById = IssuePointOrderById
|
|
13
|
+
local issueTargetOrderById = IssueTargetOrderById
|
|
14
|
+
local unitLastOrderTypeAttribute = attribute()
|
|
15
|
+
local unitLastOrderIdAttribute = attribute()
|
|
16
|
+
local unitLastOrderStartTimeAttribute = attribute()
|
|
17
|
+
local unitLastOrderStartXAttribute = attribute()
|
|
18
|
+
local unitLastOrderStartYAttribute = attribute()
|
|
19
|
+
local unitLastOrderTargetXAttribute = attribute()
|
|
20
|
+
local unitLastOrderTargetYAttribute = attribute()
|
|
21
|
+
local unitLastOrderTargetAttribute = attribute()
|
|
22
|
+
Unit.onImmediateOrder:addListener(
|
|
23
|
+
4,
|
|
24
|
+
function(unit, orderId)
|
|
25
|
+
unit[unitLastOrderTypeAttribute] = 0
|
|
26
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
27
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
28
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
29
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
30
|
+
unit[unitLastOrderTargetXAttribute] = nil
|
|
31
|
+
unit[unitLastOrderTargetYAttribute] = nil
|
|
32
|
+
unit[unitLastOrderTargetAttribute] = nil
|
|
33
|
+
end
|
|
34
|
+
)
|
|
35
|
+
Unit.onPointOrder:addListener(
|
|
36
|
+
4,
|
|
37
|
+
function(unit, orderId, x, y)
|
|
38
|
+
unit[unitLastOrderTypeAttribute] = 1
|
|
39
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
40
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
41
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
42
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
43
|
+
unit[unitLastOrderTargetXAttribute] = x
|
|
44
|
+
unit[unitLastOrderTargetYAttribute] = y
|
|
45
|
+
unit[unitLastOrderTargetAttribute] = nil
|
|
46
|
+
end
|
|
47
|
+
)
|
|
48
|
+
Unit.onTargetOrder:addListener(
|
|
49
|
+
4,
|
|
50
|
+
function(unit, orderId, target)
|
|
51
|
+
unit[unitLastOrderTypeAttribute] = 2
|
|
52
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
53
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
54
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
55
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
56
|
+
unit[unitLastOrderTargetXAttribute] = target.x
|
|
57
|
+
unit[unitLastOrderTargetYAttribute] = target.y
|
|
58
|
+
unit[unitLastOrderTargetAttribute] = target
|
|
59
|
+
end
|
|
60
|
+
)
|
|
61
|
+
local function toUndefinedIfCurrentOrderDoesNotMatchLast(unit, value)
|
|
62
|
+
local currentOrderId = getUnitCurrentOrder(unit.handle)
|
|
63
|
+
local lastOrderId = unit[unitLastOrderIdAttribute]
|
|
64
|
+
local ____temp_0
|
|
65
|
+
if currentOrderId == lastOrderId or currentOrderId == orderId("patrolAI") and lastOrderId == orderId("patrol") then
|
|
66
|
+
____temp_0 = value
|
|
67
|
+
else
|
|
68
|
+
____temp_0 = nil
|
|
69
|
+
end
|
|
70
|
+
return ____temp_0
|
|
71
|
+
end
|
|
72
|
+
__TS__ObjectDefineProperty(
|
|
73
|
+
Unit.prototype,
|
|
74
|
+
"currentOrderType",
|
|
75
|
+
{get = function(self)
|
|
76
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTypeAttribute]) or 0
|
|
77
|
+
end}
|
|
78
|
+
)
|
|
79
|
+
__TS__ObjectDefineProperty(
|
|
80
|
+
Unit.prototype,
|
|
81
|
+
"currentOrderId",
|
|
82
|
+
{get = function(self)
|
|
83
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderIdAttribute]) or 0
|
|
84
|
+
end}
|
|
85
|
+
)
|
|
86
|
+
__TS__ObjectDefineProperty(
|
|
87
|
+
Unit.prototype,
|
|
88
|
+
"currentOrderStartTime",
|
|
89
|
+
{get = function(self)
|
|
90
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartTimeAttribute]) or 0
|
|
91
|
+
end}
|
|
92
|
+
)
|
|
93
|
+
__TS__ObjectDefineProperty(
|
|
94
|
+
Unit.prototype,
|
|
95
|
+
"currentOrderStartX",
|
|
96
|
+
{get = function(self)
|
|
97
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartXAttribute]) or 0
|
|
98
|
+
end}
|
|
99
|
+
)
|
|
100
|
+
__TS__ObjectDefineProperty(
|
|
101
|
+
Unit.prototype,
|
|
102
|
+
"currentOrderStartY",
|
|
103
|
+
{get = function(self)
|
|
104
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartYAttribute]) or 0
|
|
105
|
+
end}
|
|
106
|
+
)
|
|
107
|
+
__TS__ObjectDefineProperty(
|
|
108
|
+
Unit.prototype,
|
|
109
|
+
"currentOrderTargetX",
|
|
110
|
+
{get = function(self)
|
|
111
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetXAttribute]) or 0
|
|
112
|
+
end}
|
|
113
|
+
)
|
|
114
|
+
__TS__ObjectDefineProperty(
|
|
115
|
+
Unit.prototype,
|
|
116
|
+
"currentOrderTargetY",
|
|
117
|
+
{get = function(self)
|
|
118
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetYAttribute]) or 0
|
|
119
|
+
end}
|
|
120
|
+
)
|
|
121
|
+
__TS__ObjectDefineProperty(
|
|
122
|
+
Unit.prototype,
|
|
123
|
+
"currentOrderTarget",
|
|
124
|
+
{get = function(self)
|
|
125
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetAttribute])
|
|
126
|
+
end}
|
|
127
|
+
)
|
|
128
|
+
local issueOrderByType = {
|
|
129
|
+
[0] = issueImmediateOrderById,
|
|
130
|
+
[1] = issuePointOrderById,
|
|
131
|
+
[2] = function(unitHandle, orderId, widget) return issueTargetOrderById(unitHandle, orderId, widget.handle) end
|
|
132
|
+
}
|
|
133
|
+
Unit.prototype.issueOrder = function(self, orderType, orderId, xOrTarget, y)
|
|
134
|
+
return issueOrderByType[orderType](self.handle, orderId, xOrTarget, y)
|
|
135
|
+
end
|
|
136
|
+
return ____exports
|
|
@@ -7,8 +7,8 @@ local UnitAbility = ____ability.UnitAbility
|
|
|
7
7
|
local ____unit = require("engine.internal.unit")
|
|
8
8
|
local Unit = ____unit.Unit
|
|
9
9
|
local ____event = require("event")
|
|
10
|
-
local Event = ____event.Event
|
|
11
10
|
local createDispatchingEvent = ____event.createDispatchingEvent
|
|
11
|
+
local Event = ____event.Event
|
|
12
12
|
local abilityGainedEvent = createDispatchingEvent(
|
|
13
13
|
__TS__New(Event),
|
|
14
14
|
function(unit, ability) return ability.typeId end
|
|
@@ -40,6 +40,15 @@ ItemAbility.onCreate:addListener(
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
)
|
|
43
|
+
ItemAbility.destroyEvent:addListener(
|
|
44
|
+
4,
|
|
45
|
+
function(ability)
|
|
46
|
+
local unit = ability.owner.owner
|
|
47
|
+
if unit ~= nil then
|
|
48
|
+
Event.invoke(abilityLostEvent, unit, ability)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
)
|
|
43
52
|
Unit.itemPickedUpEvent:addListener(
|
|
44
53
|
0,
|
|
45
54
|
function(unit, item)
|
|
@@ -9,9 +9,16 @@ local ____timer = require("core.types.timer")
|
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
10
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
11
|
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
12
|
+
local ____attributes = require("attributes")
|
|
13
|
+
local attribute = ____attributes.attribute
|
|
14
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
15
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
12
16
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
13
17
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
14
|
-
local
|
|
18
|
+
local units = __TS__New(LinkedSet)
|
|
19
|
+
local targetAttribute = attribute()
|
|
20
|
+
local impactDelayAttribute = attribute()
|
|
21
|
+
local passedTimeAttribute = attribute()
|
|
15
22
|
local instantOrderIds = luaSetOf(
|
|
16
23
|
orderId("avatar"),
|
|
17
24
|
orderId("berserk"),
|
|
@@ -28,24 +35,45 @@ local instantOrderIds = luaSetOf(
|
|
|
28
35
|
orderId("unimmolation")
|
|
29
36
|
)
|
|
30
37
|
local function reset(source, orderId)
|
|
31
|
-
if not (instantOrderIds[orderId] ~= nil) then
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
eventTimerByUnit[source] = nil
|
|
36
|
-
end
|
|
38
|
+
if not (instantOrderIds[orderId] ~= nil) and units:remove(source) then
|
|
39
|
+
source[targetAttribute] = nil
|
|
40
|
+
source[impactDelayAttribute] = nil
|
|
41
|
+
source[passedTimeAttribute] = nil
|
|
37
42
|
end
|
|
38
43
|
end
|
|
39
44
|
Unit.onImmediateOrder:addListener(reset)
|
|
40
45
|
Unit.onPointOrder:addListener(reset)
|
|
41
46
|
Unit.onTargetOrder:addListener(reset)
|
|
42
|
-
local
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
local timerPeriod = 1 / 64
|
|
48
|
+
local function invokeEvent(unit)
|
|
49
|
+
units:remove(unit)
|
|
50
|
+
local target = unit[targetAttribute]
|
|
51
|
+
unit[targetAttribute] = nil
|
|
52
|
+
unit[impactDelayAttribute] = nil
|
|
53
|
+
unit[passedTimeAttribute] = nil
|
|
54
|
+
Event.invoke(autoAttackFinishEvent, unit, target)
|
|
55
|
+
end
|
|
56
|
+
local function checkUnit(unit)
|
|
57
|
+
local passedTime = unit[passedTimeAttribute] + timerPeriod
|
|
58
|
+
if passedTime >= unit[impactDelayAttribute] then
|
|
59
|
+
invokeEvent(unit)
|
|
60
|
+
else
|
|
61
|
+
unit[passedTimeAttribute] = passedTime
|
|
62
|
+
end
|
|
45
63
|
end
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
local timer = Timer:simple(attackPoint, timerCallback, source, target)
|
|
49
|
-
eventTimerByUnit[source] = timer
|
|
64
|
+
Timer.onPeriod[timerPeriod]:addListener(function()
|
|
65
|
+
units:forEach(checkUnit)
|
|
50
66
|
end)
|
|
67
|
+
Unit.autoAttackStartEvent:addListener(
|
|
68
|
+
999999,
|
|
69
|
+
function(source, target)
|
|
70
|
+
if source[targetAttribute] ~= nil then
|
|
71
|
+
invokeEvent(source)
|
|
72
|
+
end
|
|
73
|
+
source[targetAttribute] = target
|
|
74
|
+
source[impactDelayAttribute] = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
75
|
+
source[passedTimeAttribute] = -timerPeriod
|
|
76
|
+
units:add(source)
|
|
77
|
+
end
|
|
78
|
+
)
|
|
51
79
|
return ____exports
|
|
@@ -23,6 +23,7 @@ export declare namespace UnitClassification {
|
|
|
23
23
|
const GROUND: junittype;
|
|
24
24
|
const SUMMONED: junittype;
|
|
25
25
|
const MECHANICAL: junittype;
|
|
26
|
+
const WORKER: junittype;
|
|
26
27
|
const ANCIENT: junittype;
|
|
27
28
|
const SUICIDAL: junittype;
|
|
28
29
|
const TAUREN: junittype;
|
|
@@ -49,8 +50,9 @@ export interface DamagingEvent extends AttributesHolder {
|
|
|
49
50
|
readonly isAttack: boolean;
|
|
50
51
|
readonly originalAmount: number;
|
|
51
52
|
readonly originalMetadata: unknown;
|
|
53
|
+
preventRetaliation(this: DamagingEvent): void;
|
|
52
54
|
}
|
|
53
|
-
export type DamageEvent = DamagingEvent & {
|
|
55
|
+
export type DamageEvent = Omit<DamagingEvent, "preventRetaliation"> & {
|
|
54
56
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
55
57
|
};
|
|
56
58
|
export type AttackDamageEvent = DamagingEvent & {
|
|
@@ -78,10 +80,14 @@ export declare class UnitWeapon {
|
|
|
78
80
|
readonly unit: Unit;
|
|
79
81
|
readonly index: 0 | 1;
|
|
80
82
|
constructor(unit: Unit, index: 0 | 1);
|
|
83
|
+
get isEnabled(): boolean;
|
|
84
|
+
set isEnabled(isEnabled: boolean);
|
|
81
85
|
get cooldown(): number;
|
|
82
86
|
set cooldown(cooldown: number);
|
|
83
87
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
|
84
88
|
set damage([minimumDamage, maximumDamage]: [number, number]);
|
|
89
|
+
get allowedTargetCombatClassifications(): CombatClassifications;
|
|
90
|
+
set allowedTargetCombatClassifications(allowedTargetCombatClassifications: CombatClassifications);
|
|
85
91
|
get damageBase(): number;
|
|
86
92
|
set damageBase(damageBase: number);
|
|
87
93
|
get damageDiceCount(): number;
|
|
@@ -156,13 +162,13 @@ export declare class Unit extends Handle<junit> {
|
|
|
156
162
|
isInRangeOf(unit: Unit, range: number): boolean;
|
|
157
163
|
isAllyOf(unit: Unit): boolean;
|
|
158
164
|
isEnemyOf(unit: Unit): boolean;
|
|
159
|
-
playAnimation(animation: string, rarity?: jraritycontrol): void;
|
|
160
|
-
playAnimation(animation: number): void;
|
|
165
|
+
playAnimation(...parameters: [animation: number] | [animation: string, rarity?: jraritycontrol]): void;
|
|
161
166
|
resetAnimation(): void;
|
|
162
167
|
queueAnimation(animation: string): void;
|
|
163
168
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
164
169
|
get firstWeapon(): UnitWeapon;
|
|
165
170
|
get secondWeapon(): UnitWeapon;
|
|
171
|
+
chooseWeapon(target: Unit): UnitWeapon | undefined;
|
|
166
172
|
get level(): number;
|
|
167
173
|
set level(v: number);
|
|
168
174
|
get xp(): number;
|
|
@@ -262,17 +268,18 @@ export declare class Unit extends Handle<junit> {
|
|
|
262
268
|
dropItemTarget(item: Item, target: Widget): boolean;
|
|
263
269
|
dropItemSlot(item: Item, slot: number): boolean;
|
|
264
270
|
itemInSlot(slot: number): Item | null;
|
|
265
|
-
addAbility(abilityId: number): UnitAbility |
|
|
271
|
+
addAbility(abilityId: number): UnitAbility | undefined;
|
|
266
272
|
makeAbilityPermanent(abilityId: number, permanent: true): boolean;
|
|
267
273
|
setAbilityLevel(abilityId: number, level: number): number;
|
|
268
274
|
getAbilityLevel(abilityId: number): number;
|
|
269
275
|
hasAbility(abilityId: number): boolean;
|
|
270
|
-
|
|
271
|
-
removeAbility(
|
|
276
|
+
getAbility(abilityId: number): UnitAbility | undefined;
|
|
277
|
+
removeAbility(abilityTypeId: number): boolean;
|
|
272
278
|
hideAbility(abilityId: number, flag: boolean): void;
|
|
273
279
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
274
280
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
275
281
|
endAbilityCooldown(abilityId: number): void;
|
|
282
|
+
interruptMovement(): void;
|
|
276
283
|
interruptAttack(): void;
|
|
277
284
|
interruptCast(abilityId: number): void;
|
|
278
285
|
getDistanceTo(target: Unit | Vec2): number;
|
|
@@ -295,6 +302,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
295
302
|
get onUnitInRange(): Record<number, Event<[Unit]>>;
|
|
296
303
|
get onManaEqual(): Record<number, Event<[Unit, number]>>;
|
|
297
304
|
get manaEvent(): Record<Operator, Record<number, Event<[Unit]>>>;
|
|
305
|
+
get targetAcquiredEvent(): Event;
|
|
298
306
|
get onSelect(): Event;
|
|
299
307
|
get onDeselect(): Event;
|
|
300
308
|
get onImmediateOrder(): Event<[number]>;
|
|
@@ -347,7 +355,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
347
355
|
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
348
356
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
349
357
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
350
|
-
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
358
|
+
static itemStackedEvent: UnitTriggerEvent<[target: Item, source: Item]>;
|
|
359
|
+
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
351
360
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
352
361
|
static get itemMoveOrderEvent(): Event<[
|
|
353
362
|
unit: Unit,
|