warscript 0.0.1-dev.78d01a4 → 0.0.1-dev.7912f28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/types/effect.lua +39 -10
- package/engine/behaviour/ability/emulate-impact.lua +5 -7
- package/engine/behaviour/ability/on-command-impact.lua +7 -0
- package/engine/behaviour/ability.d.ts +5 -1
- package/engine/behaviour/ability.lua +32 -0
- package/engine/internal/ability.d.ts +11 -1
- package/engine/internal/ability.lua +67 -2
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +50 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.lua +6 -12
- package/engine/internal/unit.d.ts +1 -0
- package/engine/internal/unit.lua +39 -11
- package/engine/internal/utility.lua +12 -0
- package/engine/object-data/entry/ability-type.lua +8 -12
- package/engine/object-data/entry/item-type.d.ts +2 -0
- package/engine/object-data/entry/item-type.lua +13 -0
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +5 -2
- package/engine/object-field/ability.lua +3 -0
- package/engine/object-field.d.ts +2 -2
- package/engine/object-field.lua +4 -0
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +1 -1
package/core/types/effect.lua
CHANGED
|
@@ -123,6 +123,13 @@ dummyPlayer = Player.neutralExtra
|
|
|
123
123
|
local temporaryEffects = {}
|
|
124
124
|
local temporaryEffectsDurations = {}
|
|
125
125
|
local temporaryEffectsCount = 0
|
|
126
|
+
local delayedEffectsModelPath = {}
|
|
127
|
+
local delayedEffectsXOrWidget = {}
|
|
128
|
+
local delayedEffectsYOrAttachmentPoint = {}
|
|
129
|
+
local delayedEffectsDuration = {}
|
|
130
|
+
local delayedEffectsParameters = {}
|
|
131
|
+
local delayedEffectsDelay = {}
|
|
132
|
+
local delayedEffectsCount = 0
|
|
126
133
|
local period = 1 / 32
|
|
127
134
|
Timer.onPeriod[period]:addListener(function()
|
|
128
135
|
local i = 1
|
|
@@ -131,12 +138,36 @@ Timer.onPeriod[period]:addListener(function()
|
|
|
131
138
|
if duration <= 0 then
|
|
132
139
|
destroyEffect(temporaryEffects[i])
|
|
133
140
|
temporaryEffects[i] = temporaryEffects[temporaryEffectsCount]
|
|
141
|
+
temporaryEffectsDurations[i] = temporaryEffectsDurations[temporaryEffectsCount]
|
|
134
142
|
temporaryEffectsCount = temporaryEffectsCount - 1
|
|
135
143
|
else
|
|
136
144
|
temporaryEffectsDurations[i] = duration - period
|
|
137
145
|
i = i + 1
|
|
138
146
|
end
|
|
139
147
|
end
|
|
148
|
+
i = 1
|
|
149
|
+
while i <= delayedEffectsCount do
|
|
150
|
+
local delay = delayedEffectsDelay[i]
|
|
151
|
+
if delay <= 0 then
|
|
152
|
+
flash(
|
|
153
|
+
delayedEffectsModelPath[i],
|
|
154
|
+
delayedEffectsXOrWidget[i],
|
|
155
|
+
delayedEffectsYOrAttachmentPoint[i],
|
|
156
|
+
delayedEffectsDuration[i],
|
|
157
|
+
delayedEffectsParameters[i]
|
|
158
|
+
)
|
|
159
|
+
delayedEffectsModelPath[i] = delayedEffectsModelPath[delayedEffectsCount]
|
|
160
|
+
delayedEffectsXOrWidget[i] = delayedEffectsXOrWidget[delayedEffectsCount]
|
|
161
|
+
delayedEffectsYOrAttachmentPoint[i] = delayedEffectsYOrAttachmentPoint[delayedEffectsCount]
|
|
162
|
+
delayedEffectsDuration[i] = delayedEffectsDuration[delayedEffectsCount]
|
|
163
|
+
delayedEffectsParameters[i] = delayedEffectsParameters[delayedEffectsCount]
|
|
164
|
+
delayedEffectsDelay[i] = delayedEffectsDelay[delayedEffectsCount]
|
|
165
|
+
delayedEffectsCount = delayedEffectsCount - 1
|
|
166
|
+
else
|
|
167
|
+
delayedEffectsDelay[i] = delay - period
|
|
168
|
+
i = i + 1
|
|
169
|
+
end
|
|
170
|
+
end
|
|
140
171
|
end)
|
|
141
172
|
____exports.Effect = __TS__Class()
|
|
142
173
|
local Effect = ____exports.Effect
|
|
@@ -157,16 +188,14 @@ function Effect.flash(self, modelPath, xOrWidget, yOrOrAttachmentPoint, paramete
|
|
|
157
188
|
parameters = parametersOrDuration
|
|
158
189
|
parametersOrDuration = nil
|
|
159
190
|
end
|
|
160
|
-
if parameters and parameters.delay
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
parameters
|
|
169
|
-
)
|
|
191
|
+
if parameters and (parameters.delay or 0) > 0 then
|
|
192
|
+
delayedEffectsCount = delayedEffectsCount + 1
|
|
193
|
+
delayedEffectsModelPath[delayedEffectsCount] = modelPath
|
|
194
|
+
delayedEffectsXOrWidget[delayedEffectsCount] = xOrWidget
|
|
195
|
+
delayedEffectsYOrAttachmentPoint[delayedEffectsCount] = yOrOrAttachmentPoint
|
|
196
|
+
delayedEffectsDuration[delayedEffectsCount] = parametersOrDuration
|
|
197
|
+
delayedEffectsParameters[delayedEffectsCount] = parameters
|
|
198
|
+
delayedEffectsDelay[delayedEffectsCount] = parameters.delay
|
|
170
199
|
return
|
|
171
200
|
end
|
|
172
201
|
flash(
|
|
@@ -7,23 +7,21 @@ 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"
|
|
13
16
|
__TS__ClassExtends(EmulateImpactAbilityBehavior, AbilityBehavior)
|
|
14
17
|
function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
15
|
-
local abilityTypeId = self.ability.typeId
|
|
16
18
|
local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
|
|
17
19
|
local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
|
|
18
|
-
if
|
|
20
|
+
if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost then
|
|
19
21
|
return
|
|
20
22
|
end
|
|
21
23
|
caster.mana = caster.mana - manaCost
|
|
22
|
-
|
|
23
|
-
caster:interruptCast(self.ability.typeId)
|
|
24
|
-
else
|
|
25
|
-
caster:startAbilityCooldown(self.ability.typeId, cooldown)
|
|
26
|
-
end
|
|
24
|
+
self.ability.cooldownRemaining = max(cooldown, MINIMUM_POSITIVE_NORMALIZED_FLOAT)
|
|
27
25
|
self:flashCasterEffect(caster)
|
|
28
26
|
AbilityBehavior:forAll(self.ability, "onImpact", caster)
|
|
29
27
|
end
|
|
@@ -2,6 +2,8 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
4
|
local ____exports = {}
|
|
5
|
+
local ____unit = require("engine.internal.unit")
|
|
6
|
+
local Unit = ____unit.Unit
|
|
5
7
|
local ____emulate_2Dimpact = require("engine.behaviour.ability.emulate-impact")
|
|
6
8
|
local EmulateImpactAbilityBehavior = ____emulate_2Dimpact.EmulateImpactAbilityBehavior
|
|
7
9
|
____exports.OnCommandImpactAbilityBehavior = __TS__Class()
|
|
@@ -15,4 +17,9 @@ end
|
|
|
15
17
|
function OnCommandImpactAbilityBehavior.prototype.onCommand(self, caster)
|
|
16
18
|
self:emulateImpact(caster)
|
|
17
19
|
end
|
|
20
|
+
Unit.itemUseOrderEvent:addListener(function(unit, item)
|
|
21
|
+
for ____, ability in ipairs(item.abilities) do
|
|
22
|
+
____exports.OnCommandImpactAbilityBehavior:forAll(ability, "onCommand", unit)
|
|
23
|
+
end
|
|
24
|
+
end)
|
|
18
25
|
return ____exports
|
|
@@ -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,9 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
35
35
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
36
36
|
get levelCount(): number;
|
|
37
37
|
abstract get level(): number;
|
|
38
|
+
abstract get cooldownRemaining(): number;
|
|
39
|
+
abstract set cooldownRemaining(cooldownRemaining: number);
|
|
40
|
+
abstract interruptCast(): void;
|
|
38
41
|
static get onCreate(): Event<[Ability]>;
|
|
39
42
|
static get destroyEvent(): Event<[Ability]>;
|
|
40
43
|
}
|
|
@@ -45,6 +48,9 @@ export declare class UnrecognizedAbility extends Ability {
|
|
|
45
48
|
readonly owner: Unit;
|
|
46
49
|
constructor(typeId: number, owner: Unit);
|
|
47
50
|
get level(): number;
|
|
51
|
+
get cooldownRemaining(): number;
|
|
52
|
+
set cooldownRemaining(_: number);
|
|
53
|
+
interruptCast(): void;
|
|
48
54
|
}
|
|
49
55
|
export declare class UnitAbility extends Ability {
|
|
50
56
|
readonly owner: Unit;
|
|
@@ -55,7 +61,8 @@ export declare class UnitAbility extends Ability {
|
|
|
55
61
|
get level(): number;
|
|
56
62
|
set level(v: number);
|
|
57
63
|
get cooldownRemaining(): number;
|
|
58
|
-
set cooldownRemaining(
|
|
64
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
65
|
+
interruptCast(): void;
|
|
59
66
|
static get onCreate(): Event<[UnitAbility]>;
|
|
60
67
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
61
68
|
}
|
|
@@ -79,6 +86,9 @@ export declare class ItemAbility extends Ability {
|
|
|
79
86
|
setField(field: jabilitybooleanlevelfield, level: number, value: boolean): boolean;
|
|
80
87
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
81
88
|
get level(): number;
|
|
89
|
+
get cooldownRemaining(): number;
|
|
90
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
91
|
+
interruptCast(): void;
|
|
82
92
|
static get onCreate(): Event<[ItemAbility]>;
|
|
83
93
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
84
94
|
}
|
|
@@ -10,7 +10,10 @@ local ____exports = {}
|
|
|
10
10
|
local ____handle = require("core.types.handle")
|
|
11
11
|
local Handle = ____handle.Handle
|
|
12
12
|
local ____ability = require("engine.internal.item.ability")
|
|
13
|
+
local abilityActionDummy = ____ability.abilityActionDummy
|
|
13
14
|
local doAbilityAction = ____ability.doAbilityAction
|
|
15
|
+
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
16
|
+
local startItemCooldown = ____ability.startItemCooldown
|
|
14
17
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
15
18
|
local setUnitAbilityLevel = SetUnitAbilityLevel
|
|
16
19
|
local setAbilityIntegerField = BlzSetAbilityIntegerField
|
|
@@ -32,6 +35,8 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
|
|
|
32
35
|
local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
|
|
33
36
|
local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
|
|
34
37
|
local getHandleId = GetHandleId
|
|
38
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
39
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
35
40
|
local unitHideAbility = BlzUnitHideAbility
|
|
36
41
|
local match = string.match
|
|
37
42
|
local ____type = _G.type
|
|
@@ -326,6 +331,17 @@ __TS__SetDescriptor(
|
|
|
326
331
|
end},
|
|
327
332
|
true
|
|
328
333
|
)
|
|
334
|
+
__TS__SetDescriptor(
|
|
335
|
+
Ability.prototype,
|
|
336
|
+
"cooldownRemaining",
|
|
337
|
+
{
|
|
338
|
+
get = function(self)
|
|
339
|
+
end,
|
|
340
|
+
set = function(self, cooldownRemaining)
|
|
341
|
+
end
|
|
342
|
+
},
|
|
343
|
+
true
|
|
344
|
+
)
|
|
329
345
|
__TS__ObjectDefineProperty(
|
|
330
346
|
Ability,
|
|
331
347
|
"onCreate",
|
|
@@ -349,6 +365,8 @@ function UnrecognizedAbility.prototype.____constructor(self, typeId, owner)
|
|
|
349
365
|
UnrecognizedAbility.____super.prototype.____constructor(self, nil, typeId)
|
|
350
366
|
self.owner = owner
|
|
351
367
|
end
|
|
368
|
+
function UnrecognizedAbility.prototype.interruptCast(self)
|
|
369
|
+
end
|
|
352
370
|
__TS__SetDescriptor(
|
|
353
371
|
UnrecognizedAbility.prototype,
|
|
354
372
|
"level",
|
|
@@ -357,6 +375,18 @@ __TS__SetDescriptor(
|
|
|
357
375
|
end},
|
|
358
376
|
true
|
|
359
377
|
)
|
|
378
|
+
__TS__SetDescriptor(
|
|
379
|
+
UnrecognizedAbility.prototype,
|
|
380
|
+
"cooldownRemaining",
|
|
381
|
+
{
|
|
382
|
+
get = function(self)
|
|
383
|
+
return 0
|
|
384
|
+
end,
|
|
385
|
+
set = function(self, _)
|
|
386
|
+
end
|
|
387
|
+
},
|
|
388
|
+
true
|
|
389
|
+
)
|
|
360
390
|
____exports.UnitAbility = __TS__Class()
|
|
361
391
|
local UnitAbility = ____exports.UnitAbility
|
|
362
392
|
UnitAbility.name = "UnitAbility"
|
|
@@ -372,6 +402,9 @@ end
|
|
|
372
402
|
function UnitAbility.prototype.decrementHideCounter(self)
|
|
373
403
|
unitHideAbility(self.u, self.typeId, false)
|
|
374
404
|
end
|
|
405
|
+
function UnitAbility.prototype.interruptCast(self)
|
|
406
|
+
self.owner:interruptCast(self.typeId)
|
|
407
|
+
end
|
|
375
408
|
__TS__SetDescriptor(
|
|
376
409
|
UnitAbility.prototype,
|
|
377
410
|
"level",
|
|
@@ -392,8 +425,8 @@ __TS__SetDescriptor(
|
|
|
392
425
|
get = function(self)
|
|
393
426
|
return getUnitAbilityCooldownRemaining(self.u, self.typeId)
|
|
394
427
|
end,
|
|
395
|
-
set = function(self,
|
|
396
|
-
startUnitAbilityCooldown(self.u, self.typeId,
|
|
428
|
+
set = function(self, cooldownRemaining)
|
|
429
|
+
startUnitAbilityCooldown(self.u, self.typeId, cooldownRemaining)
|
|
397
430
|
end
|
|
398
431
|
},
|
|
399
432
|
true
|
|
@@ -418,6 +451,9 @@ end
|
|
|
418
451
|
local function setAbilityField(_, ability, field, levelOrValue, value)
|
|
419
452
|
return ____exports.Ability.prototype.setField(ability, field, levelOrValue, value)
|
|
420
453
|
end
|
|
454
|
+
local function getAbilityCooldown(_, abilityTypeId)
|
|
455
|
+
return getUnitAbilityCooldownRemaining(abilityActionDummy, abilityTypeId)
|
|
456
|
+
end
|
|
421
457
|
____exports.ItemAbility = __TS__Class()
|
|
422
458
|
local ItemAbility = ____exports.ItemAbility
|
|
423
459
|
ItemAbility.name = "ItemAbility"
|
|
@@ -445,6 +481,14 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
|
|
|
445
481
|
value
|
|
446
482
|
)
|
|
447
483
|
end
|
|
484
|
+
function ItemAbility.prototype.interruptCast(self)
|
|
485
|
+
local handle = self.owner.handle
|
|
486
|
+
local activelyUsed = getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED)
|
|
487
|
+
if activelyUsed then
|
|
488
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, false)
|
|
489
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
490
|
+
end
|
|
491
|
+
end
|
|
448
492
|
__TS__SetDescriptor(
|
|
449
493
|
ItemAbility.prototype,
|
|
450
494
|
"level",
|
|
@@ -453,6 +497,27 @@ __TS__SetDescriptor(
|
|
|
453
497
|
end},
|
|
454
498
|
true
|
|
455
499
|
)
|
|
500
|
+
__TS__SetDescriptor(
|
|
501
|
+
ItemAbility.prototype,
|
|
502
|
+
"cooldownRemaining",
|
|
503
|
+
{
|
|
504
|
+
get = function(self)
|
|
505
|
+
local item = self.owner
|
|
506
|
+
local ____doAbilityActionForceDummy_4 = doAbilityActionForceDummy
|
|
507
|
+
local ____item_handle_3 = item.handle
|
|
508
|
+
local ____opt_1 = item.owner
|
|
509
|
+
return ____doAbilityActionForceDummy_4(____item_handle_3, ____opt_1 and ____opt_1.handle, getAbilityCooldown, self.typeId)
|
|
510
|
+
end,
|
|
511
|
+
set = function(self, cooldownRemaining)
|
|
512
|
+
local item = self.owner
|
|
513
|
+
local ____startItemCooldown_8 = startItemCooldown
|
|
514
|
+
local ____item_handle_7 = item.handle
|
|
515
|
+
local ____opt_5 = item.owner
|
|
516
|
+
____startItemCooldown_8(____item_handle_7, ____opt_5 and ____opt_5.handle, cooldownRemaining)
|
|
517
|
+
end
|
|
518
|
+
},
|
|
519
|
+
true
|
|
520
|
+
)
|
|
456
521
|
__TS__ObjectDefineProperty(
|
|
457
522
|
ItemAbility,
|
|
458
523
|
"onCreate",
|
|
@@ -1,16 +1,60 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
local restoreCooldownGroup
|
|
2
3
|
local ____player = require("core.types.player")
|
|
3
4
|
local Player = ____player.Player
|
|
4
5
|
local ____dummy = require("objutil.dummy")
|
|
5
6
|
local dummyUnitId = ____dummy.dummyUnitId
|
|
7
|
+
local ____utility = require("engine.internal.utility")
|
|
8
|
+
local findUnitItemSlot = ____utility.findUnitItemSlot
|
|
9
|
+
local ____blank = require("engine.object-data.entry.item-type.blank")
|
|
10
|
+
local BlankItemType = ____blank.BlankItemType
|
|
11
|
+
local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
|
|
12
|
+
local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
|
|
13
|
+
local ____math = require("math")
|
|
14
|
+
local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
15
|
+
local ____timer = require("core.types.timer")
|
|
16
|
+
local Timer = ____timer.Timer
|
|
17
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
18
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
19
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
20
|
+
local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
|
|
6
21
|
local isItemOwned = IsItemOwned
|
|
7
22
|
local isItemPowerup = IsItemPowerup
|
|
8
23
|
local getItemX = GetItemX
|
|
9
24
|
local getItemY = GetItemY
|
|
25
|
+
local setAbilityRealLevelField = BlzSetAbilityRealLevelField
|
|
26
|
+
local setItemIntegerField = BlzSetItemIntegerField
|
|
27
|
+
local getItemIntegerField = BlzGetItemIntegerField
|
|
10
28
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
11
29
|
local setItemPosition = SetItemPosition
|
|
12
30
|
local unitAddItem = UnitAddItem
|
|
13
31
|
local unitRemoveItem = UnitRemoveItem
|
|
32
|
+
local unitUseItem = UnitUseItem
|
|
33
|
+
local unitResetCooldown = UnitResetCooldown
|
|
34
|
+
local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
|
|
35
|
+
if not currentMap then
|
|
36
|
+
return 0
|
|
37
|
+
end
|
|
38
|
+
local abilityType = currentMap.objects.ability:newObject(
|
|
39
|
+
util.id2s(abilityTypeIdGenerator:next()),
|
|
40
|
+
"Absk"
|
|
41
|
+
)
|
|
42
|
+
abilityType["bsk1+0"] = 0
|
|
43
|
+
abilityType["bsk2+0"] = 0
|
|
44
|
+
abilityType["bsk3+0"] = 0
|
|
45
|
+
abilityType["amcs+0"] = 0
|
|
46
|
+
abilityType["adur+0"] = MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
47
|
+
abilityType["ahdu+0"] = MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
48
|
+
return util.s2id(abilityType.id)
|
|
49
|
+
end)
|
|
50
|
+
local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
|
|
51
|
+
local itemType = BlankItemType:create()
|
|
52
|
+
itemType.name = "[Warscript/Dummy] Item Cooldown Starter"
|
|
53
|
+
itemType.abilityTypeIds = {COOLDOWN_STARTER_ABILITY_TYPE_ID}
|
|
54
|
+
itemType.cooldownGroupId = COOLDOWN_STARTER_ABILITY_TYPE_ID
|
|
55
|
+
itemType.activelyUsed = true
|
|
56
|
+
return itemType.id
|
|
57
|
+
end)
|
|
14
58
|
local dummy = assert(CreateUnit(
|
|
15
59
|
Player.neutralVictim.handle,
|
|
16
60
|
dummyUnitId,
|
|
@@ -18,10 +62,37 @@ local dummy = assert(CreateUnit(
|
|
|
18
62
|
0,
|
|
19
63
|
270
|
|
20
64
|
))
|
|
65
|
+
local cooldownStarterItem = UnitAddItemById(dummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
66
|
+
local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
21
67
|
ShowUnit(dummy, false)
|
|
68
|
+
local function startItemCooldownInternal(handle, cooldown)
|
|
69
|
+
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
70
|
+
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
71
|
+
setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
|
|
72
|
+
unitResetCooldown(dummy)
|
|
73
|
+
unitUseItem(dummy, cooldownStarterItem)
|
|
74
|
+
Timer:run(restoreCooldownGroup, handle, cooldownGroup)
|
|
75
|
+
end
|
|
76
|
+
restoreCooldownGroup = function(handle, cooldownGroup)
|
|
77
|
+
if getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP) == COOLDOWN_STARTER_ABILITY_TYPE_ID then
|
|
78
|
+
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, cooldownGroup)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
---
|
|
82
|
+
-- @internal For use by internal systems only.
|
|
83
|
+
____exports.startItemCooldown = function(handle, owner, cooldown)
|
|
84
|
+
____exports.doAbilityActionForceDummy(handle, owner, startItemCooldownInternal, cooldown)
|
|
85
|
+
end
|
|
86
|
+
---
|
|
87
|
+
-- @internal For use by internal systems only.
|
|
88
|
+
____exports.abilityActionDummy = dummy
|
|
22
89
|
---
|
|
23
90
|
-- @internal For use by internal systems only.
|
|
24
91
|
____exports.doAbilityAction = function(handle, action, ...)
|
|
92
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
|
|
93
|
+
if not isAlreadyIgnoredInEvents then
|
|
94
|
+
ignoreEventsItems[handle] = true
|
|
95
|
+
end
|
|
25
96
|
local isOwned = isItemOwned(handle)
|
|
26
97
|
local isPowerup
|
|
27
98
|
local x
|
|
@@ -43,6 +114,41 @@ ____exports.doAbilityAction = function(handle, action, ...)
|
|
|
43
114
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
44
115
|
end
|
|
45
116
|
end
|
|
117
|
+
if not isAlreadyIgnoredInEvents then
|
|
118
|
+
ignoreEventsItems[handle] = nil
|
|
119
|
+
end
|
|
120
|
+
return result
|
|
121
|
+
end
|
|
122
|
+
---
|
|
123
|
+
-- @internal For use by internal systems only.
|
|
124
|
+
____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
125
|
+
if owner == nil then
|
|
126
|
+
return ____exports.doAbilityAction(handle, action, ...)
|
|
127
|
+
end
|
|
128
|
+
local slot = findUnitItemSlot(owner, handle)
|
|
129
|
+
if slot == nil then
|
|
130
|
+
return ____exports.doAbilityAction(handle, action, ...)
|
|
131
|
+
end
|
|
132
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
|
|
133
|
+
if not isAlreadyIgnoredInEvents then
|
|
134
|
+
ignoreEventsItems[handle] = true
|
|
135
|
+
end
|
|
136
|
+
local isPowerup
|
|
137
|
+
if isItemPowerup(handle) then
|
|
138
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
139
|
+
isPowerup = true
|
|
140
|
+
end
|
|
141
|
+
unitRemoveItem(owner, handle)
|
|
142
|
+
unitAddItem(dummy, handle)
|
|
143
|
+
local result = action(handle, ...)
|
|
144
|
+
unitRemoveItem(dummy, handle)
|
|
145
|
+
unitAddItemToSlot(owner, handle, slot)
|
|
146
|
+
if isPowerup then
|
|
147
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
148
|
+
end
|
|
149
|
+
if not isAlreadyIgnoredInEvents then
|
|
150
|
+
ignoreEventsItems[handle] = nil
|
|
151
|
+
end
|
|
46
152
|
return result
|
|
47
153
|
end
|
|
48
154
|
return ____exports
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____unit = require("engine.internal.unit")
|
|
3
|
+
local Unit = ____unit.Unit
|
|
4
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
5
|
+
local fillerItems = ____add_2Ditem_2Dto_2Dslot.fillerItems
|
|
6
|
+
local unitsWithFillerItems = ____add_2Ditem_2Dto_2Dslot.unitsWithFillerItems
|
|
7
|
+
local setItemVisible = SetItemVisible
|
|
8
|
+
local unitRemoveItem = UnitRemoveItem
|
|
9
|
+
Unit.itemPickedUpEvent:addListener(
|
|
10
|
+
4,
|
|
11
|
+
function(unit)
|
|
12
|
+
local handle = unit.handle
|
|
13
|
+
if unitsWithFillerItems[handle] ~= nil then
|
|
14
|
+
for previousSlot = 1, 6 do
|
|
15
|
+
local fillerItem = fillerItems[previousSlot]
|
|
16
|
+
unitRemoveItem(handle, fillerItem)
|
|
17
|
+
setItemVisible(fillerItem, false)
|
|
18
|
+
end
|
|
19
|
+
unitsWithFillerItems[handle] = nil
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
)
|
|
23
|
+
return ____exports
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____blank = require("engine.object-data.entry.item-type.blank")
|
|
3
|
+
local BlankItemType = ____blank.BlankItemType
|
|
4
|
+
local ____arrays = require("utility.arrays")
|
|
5
|
+
local array = ____arrays.array
|
|
6
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
7
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
8
|
+
local setItemVisible = SetItemVisible
|
|
9
|
+
local unitAddItem = UnitAddItem
|
|
10
|
+
local unitItemInSlot = UnitItemInSlot
|
|
11
|
+
local unitRemoveItem = UnitRemoveItem
|
|
12
|
+
local FILLER_ITEM_TYPE_ID = compiletime(function()
|
|
13
|
+
local itemType = BlankItemType:create()
|
|
14
|
+
itemType.name = "[Warscript/Dummy] Slot Filler"
|
|
15
|
+
return itemType.id
|
|
16
|
+
end)
|
|
17
|
+
---
|
|
18
|
+
-- @internal For use by internal systems only.
|
|
19
|
+
____exports.fillerItems = array(
|
|
20
|
+
6,
|
|
21
|
+
function()
|
|
22
|
+
local item = CreateItem(FILLER_ITEM_TYPE_ID, 0, 0)
|
|
23
|
+
setItemVisible(item, false)
|
|
24
|
+
ignoreEventsItems[item] = true
|
|
25
|
+
return item
|
|
26
|
+
end
|
|
27
|
+
)
|
|
28
|
+
---
|
|
29
|
+
-- @internal For use by internal systems only.
|
|
30
|
+
____exports.unitsWithFillerItems = {}
|
|
31
|
+
---
|
|
32
|
+
-- @internal For use by internal systems only.
|
|
33
|
+
____exports.unitAddItemToSlot = function(unit, item, slot)
|
|
34
|
+
for previousSlot = 0, slot - 1 do
|
|
35
|
+
if unitItemInSlot(unit, previousSlot) == nil then
|
|
36
|
+
unitAddItem(unit, ____exports.fillerItems[previousSlot + 1])
|
|
37
|
+
____exports.unitsWithFillerItems[unit] = true
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
unitAddItem(unit, item)
|
|
41
|
+
if ____exports.unitsWithFillerItems[unit] ~= nil then
|
|
42
|
+
for previousSlot = 0, slot - 1 do
|
|
43
|
+
local fillerItem = ____exports.fillerItems[previousSlot + 1]
|
|
44
|
+
unitRemoveItem(unit, fillerItem)
|
|
45
|
+
setItemVisible(fillerItem, false)
|
|
46
|
+
end
|
|
47
|
+
____exports.unitsWithFillerItems[unit] = nil
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
return ____exports
|
|
@@ -7,12 +7,14 @@ local ____item = require("engine.internal.item")
|
|
|
7
7
|
local Item = ____item.Item
|
|
8
8
|
local ____unit = require("engine.internal.unit")
|
|
9
9
|
local Unit = ____unit.Unit
|
|
10
|
+
local ____utility = require("engine.internal.utility")
|
|
11
|
+
local findUnitItemSlot = ____utility.findUnitItemSlot
|
|
12
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
13
|
+
local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
|
|
10
14
|
local rawset = _G.rawset
|
|
11
15
|
local ____type = _G.type
|
|
12
16
|
local isItemPowerup = IsItemPowerup
|
|
13
17
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
14
|
-
local unitAddItem = UnitAddItem
|
|
15
|
-
local unitDropItemSlot = UnitDropItemSlot
|
|
16
18
|
local unitInventorySize = UnitInventorySize
|
|
17
19
|
local unitItemInSlot = UnitItemInSlot
|
|
18
20
|
local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
|
|
@@ -31,14 +33,7 @@ function UnitItems.prototype.____constructor(self, handle)
|
|
|
31
33
|
handleByUnitItems[self] = handle
|
|
32
34
|
end
|
|
33
35
|
function UnitItems.prototype.findSlot(self, item)
|
|
34
|
-
|
|
35
|
-
local itemHandle = item.handle
|
|
36
|
-
for slot = 0, unitInventorySize(handle) - 1 do
|
|
37
|
-
if itemHandle == unitItemInSlot(handle, slot) then
|
|
38
|
-
return slot
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
return nil
|
|
36
|
+
return findUnitItemSlot(handleByUnitItems[self], item.handle)
|
|
42
37
|
end
|
|
43
38
|
function UnitItems.prototype.__newindex(self, slot, item)
|
|
44
39
|
local handle = handleByUnitItems[self]
|
|
@@ -52,8 +47,7 @@ function UnitItems.prototype.__newindex(self, slot, item)
|
|
|
52
47
|
if isPowerup then
|
|
53
48
|
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
54
49
|
end
|
|
55
|
-
|
|
56
|
-
unitDropItemSlot(handle, itemHandle, slot - 1)
|
|
50
|
+
unitAddItemToSlot(handle, itemHandle, slot - 1)
|
|
57
51
|
if isPowerup then
|
|
58
52
|
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
59
53
|
end
|
|
@@ -133,6 +133,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
133
133
|
get isAlive(): boolean;
|
|
134
134
|
get isDead(): boolean;
|
|
135
135
|
get isIllusion(): boolean;
|
|
136
|
+
get isStunned(): boolean;
|
|
136
137
|
get combatClassifications(): CombatClassifications;
|
|
137
138
|
set combatClassifications(combatClassifications: CombatClassifications);
|
|
138
139
|
hasCombatClassification(combatClassification: CombatClassification): boolean;
|
package/engine/internal/unit.lua
CHANGED
|
@@ -51,6 +51,8 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
54
56
|
local match = string.match
|
|
55
57
|
local ____tostring = _G.tostring
|
|
56
58
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -929,8 +931,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
929
931
|
unitInterruptAttack(self.handle)
|
|
930
932
|
end
|
|
931
933
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
932
|
-
|
|
933
|
-
unitDisableAbility(
|
|
934
|
+
local handle = self.handle
|
|
935
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
936
|
+
Timer:run(
|
|
937
|
+
unitDisableAbility,
|
|
938
|
+
handle,
|
|
939
|
+
abilityId,
|
|
940
|
+
false,
|
|
941
|
+
false
|
|
942
|
+
)
|
|
934
943
|
end
|
|
935
944
|
function Unit.prototype.getDistanceTo(self, target)
|
|
936
945
|
local handle = self.handle
|
|
@@ -1195,6 +1204,14 @@ __TS__SetDescriptor(
|
|
|
1195
1204
|
end},
|
|
1196
1205
|
true
|
|
1197
1206
|
)
|
|
1207
|
+
__TS__SetDescriptor(
|
|
1208
|
+
Unit.prototype,
|
|
1209
|
+
"isStunned",
|
|
1210
|
+
{get = function(self)
|
|
1211
|
+
return isUnitType(self.handle, UNIT_TYPE_STUNNED)
|
|
1212
|
+
end},
|
|
1213
|
+
true
|
|
1214
|
+
)
|
|
1198
1215
|
__TS__SetDescriptor(
|
|
1199
1216
|
Unit.prototype,
|
|
1200
1217
|
"combatClassifications",
|
|
@@ -2315,10 +2332,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2315
2332
|
____exports.UnitTriggerEvent,
|
|
2316
2333
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2317
2334
|
function()
|
|
2318
|
-
local
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2335
|
+
local handle = getOrderedUnit()
|
|
2336
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2337
|
+
local unit = ____exports.Unit:of(handle)
|
|
2338
|
+
if unit.state == 1 then
|
|
2339
|
+
return unit, getIssuedOrderId()
|
|
2340
|
+
end
|
|
2322
2341
|
end
|
|
2323
2342
|
return IgnoreEvent
|
|
2324
2343
|
end
|
|
@@ -2509,8 +2528,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2509
2528
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2510
2529
|
function()
|
|
2511
2530
|
local unit = getTriggerUnit()
|
|
2512
|
-
|
|
2513
|
-
|
|
2531
|
+
local item = getManipulatedItem()
|
|
2532
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2533
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2514
2534
|
end
|
|
2515
2535
|
return IgnoreEvent
|
|
2516
2536
|
end
|
|
@@ -2520,8 +2540,9 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2520
2540
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2521
2541
|
function()
|
|
2522
2542
|
local unit = getTriggerUnit()
|
|
2523
|
-
|
|
2524
|
-
|
|
2543
|
+
local item = getManipulatedItem()
|
|
2544
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2545
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2525
2546
|
end
|
|
2526
2547
|
return IgnoreEvent
|
|
2527
2548
|
end
|
|
@@ -2529,7 +2550,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2529
2550
|
Unit.itemUsedEvent = __TS__New(
|
|
2530
2551
|
____exports.UnitTriggerEvent,
|
|
2531
2552
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
function()
|
|
2553
|
+
function()
|
|
2554
|
+
local unit = getTriggerUnit()
|
|
2555
|
+
local item = getManipulatedItem()
|
|
2556
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2557
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2558
|
+
end
|
|
2559
|
+
return IgnoreEvent
|
|
2560
|
+
end
|
|
2533
2561
|
)
|
|
2534
2562
|
Unit.itemStackedEvent = __TS__New(
|
|
2535
2563
|
____exports.UnitTriggerEvent,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local getUnitAbility = BlzGetUnitAbility
|
|
3
3
|
local unitAddAbility = UnitAddAbility
|
|
4
|
+
local unitInventorySize = UnitInventorySize
|
|
5
|
+
local unitItemInSlot = UnitItemInSlot
|
|
4
6
|
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
5
7
|
---
|
|
6
8
|
-- @internal For use by internal systems only.
|
|
@@ -10,4 +12,14 @@ ____exports.addInternalAbility = function(unit, abilityTypeId)
|
|
|
10
12
|
end
|
|
11
13
|
return getUnitAbility(unit, abilityTypeId)
|
|
12
14
|
end
|
|
15
|
+
---
|
|
16
|
+
-- @internal For use by internal systems only.
|
|
17
|
+
____exports.findUnitItemSlot = function(unit, item)
|
|
18
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
19
|
+
if item == unitItemInSlot(unit, slot) then
|
|
20
|
+
return slot
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
return nil
|
|
24
|
+
end
|
|
13
25
|
return ____exports
|
|
@@ -1,7 +1,6 @@
|
|
|
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__New = ____lualib.__TS__New
|
|
5
4
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
6
5
|
local ____exports = {}
|
|
7
6
|
local ____unit = require("engine.internal.unit")
|
|
@@ -31,7 +30,7 @@ local ____entry = require("engine.object-data.entry")
|
|
|
31
30
|
local extractObjectDataEntryLevelFieldValue = ____entry.extractObjectDataEntryLevelFieldValue
|
|
32
31
|
local ObjectDataEntry = ____entry.ObjectDataEntry
|
|
33
32
|
local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
|
|
34
|
-
local
|
|
33
|
+
local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
|
|
35
34
|
local ____upgrade = require("engine.object-data.entry.upgrade")
|
|
36
35
|
local Upgrade = ____upgrade.Upgrade
|
|
37
36
|
local castAnimationFQNByAbilityTypeId = {}
|
|
@@ -53,10 +52,7 @@ end
|
|
|
53
52
|
function AbilityType.getObjectData(self, map)
|
|
54
53
|
return map.objects.ability
|
|
55
54
|
end
|
|
56
|
-
AbilityType.idGenerator =
|
|
57
|
-
ObjectDataEntryIdGenerator,
|
|
58
|
-
fourCC("A000")
|
|
59
|
-
)
|
|
55
|
+
AbilityType.idGenerator = abilityTypeIdGenerator
|
|
60
56
|
__TS__SetDescriptor(
|
|
61
57
|
AbilityType.prototype,
|
|
62
58
|
"channelingAnimation",
|
|
@@ -999,7 +995,7 @@ local function handleAbilityCastingStartEvent(caster, ability)
|
|
|
999
995
|
end
|
|
1000
996
|
casterCastingEffectsByCaster[caster] = effects
|
|
1001
997
|
end
|
|
1002
|
-
local function
|
|
998
|
+
local function handleAbilityStopCastingEvent(caster)
|
|
1003
999
|
local effects = casterCastingEffectsByCaster[caster]
|
|
1004
1000
|
if effects ~= nil then
|
|
1005
1001
|
for i = 1, #effects do
|
|
@@ -1010,8 +1006,8 @@ local function handleAbilityStopEvent(caster)
|
|
|
1010
1006
|
end
|
|
1011
1007
|
for abilityTypeId in pairs(casterCastingEffectModelPathsByAbilityTypeId) do
|
|
1012
1008
|
Unit.abilityCastingStartEvent[abilityTypeId]:addListener(4, handleAbilityCastingStartEvent)
|
|
1013
|
-
Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4,
|
|
1014
|
-
Unit.abilityStopEvent[abilityTypeId]:addListener(4,
|
|
1009
|
+
Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityStopCastingEvent)
|
|
1010
|
+
Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopCastingEvent)
|
|
1015
1011
|
end
|
|
1016
1012
|
local casterChannelingEffectModelPathsByAbilityTypeId = postcompile(function()
|
|
1017
1013
|
return mapValues(
|
|
@@ -1042,7 +1038,7 @@ local function handleAbilityChannelingStartEvent(caster, ability)
|
|
|
1042
1038
|
end
|
|
1043
1039
|
casterChannelingEffectsByCaster[caster] = effects
|
|
1044
1040
|
end
|
|
1045
|
-
local function
|
|
1041
|
+
local function handleAbilityStopChannelingEvent(caster)
|
|
1046
1042
|
local effects = casterChannelingEffectsByCaster[caster]
|
|
1047
1043
|
if effects ~= nil then
|
|
1048
1044
|
for i = 1, #effects do
|
|
@@ -1053,7 +1049,7 @@ local function handleAbilityStopEventV2(caster)
|
|
|
1053
1049
|
end
|
|
1054
1050
|
for abilityTypeId in pairs(casterChannelingEffectModelPathsByAbilityTypeId) do
|
|
1055
1051
|
Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityChannelingStartEvent)
|
|
1056
|
-
Unit.abilityChannelingFinishEvent[abilityTypeId]:addListener(4,
|
|
1057
|
-
Unit.abilityStopEvent[abilityTypeId]:addListener(4,
|
|
1052
|
+
Unit.abilityChannelingFinishEvent[abilityTypeId]:addListener(4, handleAbilityStopChannelingEvent)
|
|
1053
|
+
Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopChannelingEvent)
|
|
1058
1054
|
end
|
|
1059
1055
|
return ____exports
|
|
@@ -45,6 +45,8 @@ export declare class ItemType extends ObjectDataEntry<ItemTypeId> {
|
|
|
45
45
|
set tooltipText(tooltipText: string);
|
|
46
46
|
get tooltipExtendedText(): string;
|
|
47
47
|
set tooltipExtendedText(tooltipText: string);
|
|
48
|
+
get cooldownGroupId(): number;
|
|
49
|
+
set cooldownGroupId(cooldownGroupId: number);
|
|
48
50
|
get goldCost(): number;
|
|
49
51
|
set goldCost(goldCost: number);
|
|
50
52
|
get lumberCost(): number;
|
|
@@ -256,6 +256,19 @@ __TS__SetDescriptor(
|
|
|
256
256
|
},
|
|
257
257
|
true
|
|
258
258
|
)
|
|
259
|
+
__TS__SetDescriptor(
|
|
260
|
+
ItemType.prototype,
|
|
261
|
+
"cooldownGroupId",
|
|
262
|
+
{
|
|
263
|
+
get = function(self)
|
|
264
|
+
return self:getObjectDataEntryIdField("icid")
|
|
265
|
+
end,
|
|
266
|
+
set = function(self, cooldownGroupId)
|
|
267
|
+
self:setObjectDataEntryIdField("icid", cooldownGroupId)
|
|
268
|
+
end
|
|
269
|
+
},
|
|
270
|
+
true
|
|
271
|
+
)
|
|
259
272
|
__TS__SetDescriptor(
|
|
260
273
|
ItemType.prototype,
|
|
261
274
|
"goldCost",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
3
4
|
local ____exports = {}
|
|
4
5
|
local ____preconditions = require("utility.preconditions")
|
|
5
6
|
local checkNotNull = ____preconditions.checkNotNull
|
|
@@ -60,4 +61,10 @@ function ObjectDataEntryIdGenerator.prototype.next(self)
|
|
|
60
61
|
self.id = id
|
|
61
62
|
return id
|
|
62
63
|
end
|
|
64
|
+
---
|
|
65
|
+
-- @internal For use by internal systems only.
|
|
66
|
+
____exports.abilityTypeIdGenerator = __TS__New(
|
|
67
|
+
____exports.ObjectDataEntryIdGenerator,
|
|
68
|
+
fourCC("A000")
|
|
69
|
+
)
|
|
63
70
|
return ____exports
|
|
@@ -45,9 +45,10 @@ export declare class AbilityStringField extends AbilityField<string, jabilitystr
|
|
|
45
45
|
protected setNativeFieldValue(instance: Ability, value: string): boolean;
|
|
46
46
|
static get valueChangeEvent(): ObjectFieldValueChangeEvent<AbilityStringField>;
|
|
47
47
|
}
|
|
48
|
-
export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType =
|
|
48
|
+
export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectArrayField<AbilityType, Ability, ValueType, NativeFieldType> {
|
|
49
49
|
protected get instanceClass(): typeof Ability;
|
|
50
50
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
51
|
+
protected hasNativeFieldValue(instance: Ability): boolean;
|
|
51
52
|
}
|
|
52
53
|
export declare class AbilityStringArrayField extends AbilityArrayField<string, jabilitystringlevelfield> {
|
|
53
54
|
protected get defaultValue(): string;
|
|
@@ -130,7 +131,9 @@ export declare class AbilityCombatClassificationsLevelField extends AbilityLevel
|
|
|
130
131
|
protected getNativeFieldValue(instance: Ability, level: number): CombatClassifications;
|
|
131
132
|
protected setNativeFieldValue(instance: Ability, level: number, value: CombatClassifications): boolean;
|
|
132
133
|
}
|
|
133
|
-
export type
|
|
134
|
+
export type ReadonlySubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | ReadonlyObjectFieldType<AbilityField<ValueType>> | ReadonlyObjectLevelFieldType<AbilityLevelField<ValueType>>;
|
|
135
|
+
export type SubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType>;
|
|
136
|
+
export type AbilityDependentValue<ValueType extends boolean | number | string> = SubscribableAbilityDependentValue<ValueType> | ((ability: Ability) => ValueType);
|
|
134
137
|
export declare const resolveCurrentAbilityDependentValue: {
|
|
135
138
|
<ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>): ValueType;
|
|
136
139
|
<ValueType extends boolean | number | string>(ability: Ability, value?: AbilityDependentValue<ValueType>): ValueType | undefined;
|
|
@@ -197,6 +197,9 @@ __TS__ClassExtends(AbilityArrayField, ObjectArrayField)
|
|
|
197
197
|
function AbilityArrayField.prototype.getObjectDataEntryId(self, instance)
|
|
198
198
|
return instance.typeId
|
|
199
199
|
end
|
|
200
|
+
function AbilityArrayField.prototype.hasNativeFieldValue(self, instance)
|
|
201
|
+
return instance:hasField(self.nativeField)
|
|
202
|
+
end
|
|
200
203
|
__TS__SetDescriptor(
|
|
201
204
|
AbilityArrayField.prototype,
|
|
202
205
|
"instanceClass",
|
package/engine/object-field.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ declare abstract class ObjectFieldBase<ObjectDataEntryType extends ObjectDataEnt
|
|
|
16
16
|
readonly id: ObjectFieldId;
|
|
17
17
|
protected abstract getNativeFieldById(id: number): NativeFieldType;
|
|
18
18
|
protected abstract getObjectDataEntryId(instance: InstanceType): ObjectDataEntryIdType<ObjectDataEntryType>;
|
|
19
|
+
protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
|
|
20
|
+
hasValue(instance: InstanceType): boolean;
|
|
19
21
|
constructor(id: number);
|
|
20
22
|
static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number): T & symbol;
|
|
21
23
|
static of<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldAbstractConstructor<T>, id: number): T | undefined;
|
|
@@ -35,7 +37,6 @@ export type ReadonlyObjectFieldType<T extends ObjectField<any, any, any, any>> =
|
|
|
35
37
|
type ReadonlyObjectFieldConstructor<T extends ObjectField> = OmitConstructor<typeof ObjectField> & (abstract new (...args: any[]) => ReadonlyObjectFieldType<T>);
|
|
36
38
|
export declare abstract class ObjectField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType, NativeFieldType> {
|
|
37
39
|
protected abstract readonly defaultValue: ValueType;
|
|
38
|
-
protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
|
|
39
40
|
protected abstract getNativeFieldValue(instance: InstanceType): ValueType;
|
|
40
41
|
protected abstract setNativeFieldValue(instance: InstanceType, value: ValueType): boolean;
|
|
41
42
|
getValue(entry: ObjectDataEntryType | InstanceType): ValueType;
|
|
@@ -71,7 +72,6 @@ export declare abstract class ObjectArrayField<ObjectDataEntryType extends Objec
|
|
|
71
72
|
}
|
|
72
73
|
export declare abstract class ObjectLevelField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, InputValueType extends ValueType = never, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType[], NativeFieldType> {
|
|
73
74
|
protected abstract readonly defaultValue: ValueType;
|
|
74
|
-
protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
|
|
75
75
|
protected abstract getNativeFieldValue(instance: InstanceType, level: number): ValueType;
|
|
76
76
|
protected abstract setNativeFieldValue(instance: InstanceType, level: number, value: ValueType): boolean;
|
|
77
77
|
protected abstract getLevelCount(entry: ObjectDataEntryType | InstanceType): number;
|
package/engine/object-field.lua
CHANGED
|
@@ -46,6 +46,10 @@ end
|
|
|
46
46
|
function ObjectFieldBase.prototype.supports(self, instance)
|
|
47
47
|
return __TS__InstanceOf(instance, self.instanceClass)
|
|
48
48
|
end
|
|
49
|
+
function ObjectFieldBase.prototype.hasValue(self, instance)
|
|
50
|
+
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
51
|
+
return defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
52
|
+
end
|
|
49
53
|
function ObjectFieldBase.create(self, id)
|
|
50
54
|
return __TS__New(
|
|
51
55
|
self,
|
package/engine/unit.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import "./internal/unit/ghost-counter";
|
|
|
17
17
|
import "./internal/unit/invulnerability-counter";
|
|
18
18
|
import "./internal/unit/detach-missiles";
|
|
19
19
|
import "./internal/unit/main-selected";
|
|
20
|
+
import "./internal/unit/add-item-to-slot-init";
|
|
20
21
|
import "./internal/unit/band-aids/ancestral-spirit-cannibalize";
|
|
21
22
|
export { Unit, DamagingEvent, DamageEvent } from "./internal/unit";
|
|
22
23
|
export * from "./internal/unit+damage";
|
package/engine/unit.lua
CHANGED
|
@@ -17,6 +17,7 @@ require("engine.internal.unit.ghost-counter")
|
|
|
17
17
|
require("engine.internal.unit.invulnerability-counter")
|
|
18
18
|
require("engine.internal.unit.detach-missiles")
|
|
19
19
|
require("engine.internal.unit.main-selected")
|
|
20
|
+
require("engine.internal.unit.add-item-to-slot-init")
|
|
20
21
|
require("engine.internal.unit.band-aids.ancestral-spirit-cannibalize")
|
|
21
22
|
do
|
|
22
23
|
local ____unit = require("engine.internal.unit")
|
package/package.json
CHANGED