warscript 0.0.1-dev.416ccba → 0.0.1-dev.4f7cd3b
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/engine/behaviour/ability/emulate-impact.lua +4 -5
- package/engine/behaviour/ability.d.ts +5 -1
- package/engine/behaviour/ability.lua +32 -0
- package/engine/internal/ability.lua +16 -13
- package/engine/internal/unit.lua +22 -7
- package/engine/object-field/ability.d.ts +3 -1
- package/package.json +1 -1
|
@@ -7,6 +7,9 @@ local AbilityBehavior = ____ability.AbilityBehavior
|
|
|
7
7
|
local ____ability = require("engine.standard.fields.ability")
|
|
8
8
|
local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
|
|
9
9
|
local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTEGER_LEVEL_FIELD
|
|
10
|
+
local ____math = require("math")
|
|
11
|
+
local max = ____math.max
|
|
12
|
+
local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
10
13
|
____exports.EmulateImpactAbilityBehavior = __TS__Class()
|
|
11
14
|
local EmulateImpactAbilityBehavior = ____exports.EmulateImpactAbilityBehavior
|
|
12
15
|
EmulateImpactAbilityBehavior.name = "EmulateImpactAbilityBehavior"
|
|
@@ -18,11 +21,7 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
|
18
21
|
return
|
|
19
22
|
end
|
|
20
23
|
caster.mana = caster.mana - manaCost
|
|
21
|
-
|
|
22
|
-
self.ability:interruptCast()
|
|
23
|
-
else
|
|
24
|
-
self.ability.cooldownRemaining = cooldown
|
|
25
|
-
end
|
|
24
|
+
self.ability.cooldownRemaining = max(cooldown, MINIMUM_POSITIVE_NORMALIZED_FLOAT)
|
|
26
25
|
self:flashCasterEffect(caster)
|
|
27
26
|
AbilityBehavior:forAll(self.ability, "onImpact", caster)
|
|
28
27
|
end
|
|
@@ -7,7 +7,8 @@ import { Widget } from "../../core/types/widget";
|
|
|
7
7
|
import { Item } from "../internal/item";
|
|
8
8
|
import { Destructable } from "../../core/types/destructable";
|
|
9
9
|
import { EffectParameters } from "../../core/types/effect";
|
|
10
|
-
import { AbilityDependentValue } from "../object-field/ability";
|
|
10
|
+
import { AbilityDependentValue, ReadonlySubscribableAbilityDependentValue, SubscribableAbilityDependentValue } from "../object-field/ability";
|
|
11
|
+
import { Destructor } from "../../destroyable";
|
|
11
12
|
export type AbilityBehaviorConstructor<Args extends any[]> = new (ability: Ability, ...args: Args) => AbilityBehavior;
|
|
12
13
|
export type AbilityBehaviorParameters = {
|
|
13
14
|
isExclusiveOnImpactHandler?: boolean;
|
|
@@ -17,6 +18,8 @@ export declare abstract class AbilityBehavior<Parameters extends {
|
|
|
17
18
|
missileParameters?: any[];
|
|
18
19
|
} = {}> extends Behavior<Ability, NonNullable<Parameters["periodicActionParameters"]>> {
|
|
19
20
|
constructor(ability: Ability, parameters?: AbilityBehaviorParameters);
|
|
21
|
+
protected onDestroy(): Destructor;
|
|
22
|
+
protected subscribe<T extends boolean | number | string>(value: SubscribableAbilityDependentValue<T>): void;
|
|
20
23
|
protected registerCommandEvent(orderTypeStringId?: string): void;
|
|
21
24
|
get ability(): Ability;
|
|
22
25
|
protected resolveCurrentAbilityDependentValue<T extends boolean | number | string>(value: AbilityDependentValue<T>): T;
|
|
@@ -28,6 +31,7 @@ export declare abstract class AbilityBehavior<Parameters extends {
|
|
|
28
31
|
private static MissileLaunchConfig;
|
|
29
32
|
private get missileLaunchConfig();
|
|
30
33
|
protected onCreate(): void;
|
|
34
|
+
onValueChange(_value: ReadonlySubscribableAbilityDependentValue<string | number | boolean>): void;
|
|
31
35
|
onMissileArrival(...parameters: NonNullable<Parameters["missileParameters"]>): void;
|
|
32
36
|
onUnitGainAbility(_unit: Unit): void;
|
|
33
37
|
onUnitLoseAbility(_unit: Unit): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
5
|
local __TS__New = ____lualib.__TS__New
|
|
5
6
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
6
7
|
local ____exports = {}
|
|
@@ -24,6 +25,8 @@ local MISSILE_SPEED_ABILITY_INTEGER_FIELD = ____ability.MISSILE_SPEED_ABILITY_IN
|
|
|
24
25
|
local SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD = ____ability.SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD
|
|
25
26
|
local SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
|
|
26
27
|
local ____ability = require("engine.object-field.ability")
|
|
28
|
+
local AbilityField = ____ability.AbilityField
|
|
29
|
+
local AbilityLevelField = ____ability.AbilityLevelField
|
|
27
30
|
local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
|
|
28
31
|
local ____timer = require("core.types.timer")
|
|
29
32
|
local Timer = ____timer.Timer
|
|
@@ -41,6 +44,7 @@ createUnitEventListener = function(key)
|
|
|
41
44
|
end
|
|
42
45
|
end
|
|
43
46
|
local registeredCommandEventIds = {}
|
|
47
|
+
local subscribedValuesByAbilityBehavior = {}
|
|
44
48
|
local ____class_2 = __TS__Class()
|
|
45
49
|
____class_2.name = ""
|
|
46
50
|
function ____class_2.prototype.____constructor(self, abilityBehavior)
|
|
@@ -81,6 +85,20 @@ function AbilityBehavior.prototype.____constructor(self, ability, parameters)
|
|
|
81
85
|
end
|
|
82
86
|
self:onCreate()
|
|
83
87
|
end
|
|
88
|
+
function AbilityBehavior.prototype.onDestroy(self)
|
|
89
|
+
subscribedValuesByAbilityBehavior[self] = nil
|
|
90
|
+
return Behavior.prototype.onDestroy(self)
|
|
91
|
+
end
|
|
92
|
+
function AbilityBehavior.prototype.subscribe(self, value)
|
|
93
|
+
if __TS__InstanceOf(value, AbilityField) or __TS__InstanceOf(value, AbilityLevelField) then
|
|
94
|
+
local subscribedValues = subscribedValuesByAbilityBehavior[self]
|
|
95
|
+
if subscribedValues == nil then
|
|
96
|
+
subscribedValues = {}
|
|
97
|
+
subscribedValuesByAbilityBehavior[self] = subscribedValues
|
|
98
|
+
end
|
|
99
|
+
subscribedValues[value] = true
|
|
100
|
+
end
|
|
101
|
+
end
|
|
84
102
|
function AbilityBehavior.prototype.registerCommandEvent(self, orderTypeStringId)
|
|
85
103
|
if orderTypeStringId == nil then
|
|
86
104
|
orderTypeStringId = self.ability.orderTypeStringId
|
|
@@ -137,6 +155,8 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrDurati
|
|
|
137
155
|
end
|
|
138
156
|
function AbilityBehavior.prototype.onCreate(self)
|
|
139
157
|
end
|
|
158
|
+
function AbilityBehavior.prototype.onValueChange(self, _value)
|
|
159
|
+
end
|
|
140
160
|
function AbilityBehavior.prototype.onMissileArrival(self, ...)
|
|
141
161
|
end
|
|
142
162
|
function AbilityBehavior.prototype.onUnitGainAbility(self, _unit)
|
|
@@ -237,6 +257,18 @@ __TS__SetDescriptor(
|
|
|
237
257
|
Unit.abilityChannelingFinishEvent:addListener(createUnitEventListener("onChannelingFinish"))
|
|
238
258
|
Unit.abilityStopEvent:addListener(createUnitEventListener("onStop"))
|
|
239
259
|
end)(AbilityBehavior)
|
|
260
|
+
local function checkBehaviorOnValueChange(behavior, field)
|
|
261
|
+
local subscribedValues = subscribedValuesByAbilityBehavior[behavior]
|
|
262
|
+
if subscribedValues ~= nil and subscribedValues[field] ~= nil then
|
|
263
|
+
behavior:onValueChange(field)
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
AbilityField.valueChangeEvent:addListener(function(ability, field)
|
|
267
|
+
____exports.AbilityBehavior:forAll(ability, checkBehaviorOnValueChange, field)
|
|
268
|
+
end)
|
|
269
|
+
AbilityLevelField.valueChangeEvent:addListener(function(ability, field)
|
|
270
|
+
____exports.AbilityBehavior:forAll(ability, checkBehaviorOnValueChange, field)
|
|
271
|
+
end)
|
|
240
272
|
Ability.onCreate:addListener(function(ability)
|
|
241
273
|
local createBehaviorFunctions = createBehaviorFunctionsByAbilityTypeId[ability.typeId]
|
|
242
274
|
if createBehaviorFunctions ~= nil then
|
|
@@ -35,6 +35,8 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
|
|
|
35
35
|
local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
|
|
36
36
|
local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
|
|
37
37
|
local getHandleId = GetHandleId
|
|
38
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
39
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
38
40
|
local unitHideAbility = BlzUnitHideAbility
|
|
39
41
|
local match = string.match
|
|
40
42
|
local ____type = _G.type
|
|
@@ -482,11 +484,12 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
|
|
|
482
484
|
)
|
|
483
485
|
end
|
|
484
486
|
function ItemAbility.prototype.interruptCast(self)
|
|
485
|
-
local
|
|
486
|
-
local
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
local handle = self.owner.handle
|
|
488
|
+
local activelyUsed = getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED)
|
|
489
|
+
if activelyUsed then
|
|
490
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, false)
|
|
491
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
492
|
+
end
|
|
490
493
|
end
|
|
491
494
|
__TS__SetDescriptor(
|
|
492
495
|
ItemAbility.prototype,
|
|
@@ -502,17 +505,17 @@ __TS__SetDescriptor(
|
|
|
502
505
|
{
|
|
503
506
|
get = function(self)
|
|
504
507
|
local item = self.owner
|
|
505
|
-
local
|
|
506
|
-
local
|
|
507
|
-
local
|
|
508
|
-
return
|
|
508
|
+
local ____doAbilityActionForceDummy_4 = doAbilityActionForceDummy
|
|
509
|
+
local ____item_handle_3 = item.handle
|
|
510
|
+
local ____opt_1 = item.owner
|
|
511
|
+
return ____doAbilityActionForceDummy_4(____item_handle_3, ____opt_1 and ____opt_1.handle, getAbilityCooldown, self.typeId)
|
|
509
512
|
end,
|
|
510
513
|
set = function(self, cooldownRemaining)
|
|
511
514
|
local item = self.owner
|
|
512
|
-
local
|
|
513
|
-
local
|
|
514
|
-
local
|
|
515
|
-
|
|
515
|
+
local ____startItemCooldown_8 = startItemCooldown
|
|
516
|
+
local ____item_handle_7 = item.handle
|
|
517
|
+
local ____opt_5 = item.owner
|
|
518
|
+
____startItemCooldown_8(____item_handle_7, ____opt_5 and ____opt_5.handle, cooldownRemaining)
|
|
516
519
|
end
|
|
517
520
|
},
|
|
518
521
|
true
|
package/engine/internal/unit.lua
CHANGED
|
@@ -929,8 +929,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
929
929
|
unitInterruptAttack(self.handle)
|
|
930
930
|
end
|
|
931
931
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
932
|
-
|
|
933
|
-
unitDisableAbility(
|
|
932
|
+
local handle = self.handle
|
|
933
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
934
|
+
Timer:run(
|
|
935
|
+
unitDisableAbility,
|
|
936
|
+
handle,
|
|
937
|
+
abilityId,
|
|
938
|
+
false,
|
|
939
|
+
false
|
|
940
|
+
)
|
|
934
941
|
end
|
|
935
942
|
function Unit.prototype.getDistanceTo(self, target)
|
|
936
943
|
local handle = self.handle
|
|
@@ -2315,10 +2322,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2315
2322
|
____exports.UnitTriggerEvent,
|
|
2316
2323
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2317
2324
|
function()
|
|
2318
|
-
local
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2325
|
+
local handle = getOrderedUnit()
|
|
2326
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2327
|
+
local unit = ____exports.Unit:of(handle)
|
|
2328
|
+
if unit.state == 1 then
|
|
2329
|
+
return unit, getIssuedOrderId()
|
|
2330
|
+
end
|
|
2322
2331
|
end
|
|
2323
2332
|
return IgnoreEvent
|
|
2324
2333
|
end
|
|
@@ -2529,7 +2538,13 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2529
2538
|
Unit.itemUsedEvent = __TS__New(
|
|
2530
2539
|
____exports.UnitTriggerEvent,
|
|
2531
2540
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
function()
|
|
2541
|
+
function()
|
|
2542
|
+
local unit = getTriggerUnit()
|
|
2543
|
+
if getUnitTypeId(unit) ~= dummyUnitId then
|
|
2544
|
+
return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
|
|
2545
|
+
end
|
|
2546
|
+
return IgnoreEvent
|
|
2547
|
+
end
|
|
2533
2548
|
)
|
|
2534
2549
|
Unit.itemStackedEvent = __TS__New(
|
|
2535
2550
|
____exports.UnitTriggerEvent,
|
|
@@ -130,7 +130,9 @@ export declare class AbilityCombatClassificationsLevelField extends AbilityLevel
|
|
|
130
130
|
protected getNativeFieldValue(instance: Ability, level: number): CombatClassifications;
|
|
131
131
|
protected setNativeFieldValue(instance: Ability, level: number, value: CombatClassifications): boolean;
|
|
132
132
|
}
|
|
133
|
-
export type
|
|
133
|
+
export type ReadonlySubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | ReadonlyObjectFieldType<AbilityField<ValueType>> | ReadonlyObjectLevelFieldType<AbilityLevelField<ValueType>>;
|
|
134
|
+
export type SubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType>;
|
|
135
|
+
export type AbilityDependentValue<ValueType extends boolean | number | string> = SubscribableAbilityDependentValue<ValueType> | ((ability: Ability) => ValueType);
|
|
134
136
|
export declare const resolveCurrentAbilityDependentValue: {
|
|
135
137
|
<ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>): ValueType;
|
|
136
138
|
<ValueType extends boolean | number | string>(ability: Ability, value?: AbilityDependentValue<ValueType>): ValueType | undefined;
|
package/package.json
CHANGED