warscript 0.0.1-dev.ff2a62d → 0.0.1-dev.ff5dbcd
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/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +13 -3
- package/core/types/effect.lua +116 -17
- package/core/types/frame.d.ts +6 -0
- package/core/types/frame.lua +91 -1
- package/core/types/sound.d.ts +1 -0
- package/core/types/sound.lua +36 -2
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/engine/behavior.d.ts +2 -2
- package/engine/behavior.lua +6 -6
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +8 -5
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +28 -0
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -19
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -0
- package/engine/behaviour/ability.d.ts +15 -3
- package/engine/behaviour/ability.lua +93 -34
- package/engine/behaviour/unit.d.ts +5 -0
- package/engine/behaviour/unit.lua +20 -0
- package/engine/buff.d.ts +78 -42
- package/engine/buff.lua +351 -223
- package/engine/internal/ability.d.ts +16 -13
- package/engine/internal/ability.lua +80 -76
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/item.d.ts +2 -2
- package/engine/internal/item.lua +56 -25
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +10 -1
- package/engine/internal/unit/ability.lua +36 -14
- 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 +52 -0
- package/engine/internal/unit/bonus.d.ts +6 -2
- package/engine/internal/unit/bonus.lua +23 -1
- 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.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +51 -0
- package/engine/internal/unit+ability.lua +2 -2
- package/engine/internal/unit-missile-launch.lua +24 -5
- package/engine/internal/unit.d.ts +26 -10
- package/engine/internal/unit.lua +162 -81
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type.d.ts +8 -6
- package/engine/object-data/entry/ability-type.lua +62 -27
- package/engine/object-data/entry/buff-type/applicable.lua +13 -37
- package/engine/object-data/entry/buff-type.d.ts +1 -1
- package/engine/object-data/entry/buff-type.lua +2 -2
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +15 -1
- package/engine/object-data/entry/item-type.lua +93 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +16 -0
- package/engine/object-data/entry/sound-preset.lua +36 -0
- package/engine/object-data/entry/unit-type.d.ts +8 -1
- package/engine/object-data/entry/unit-type.lua +61 -8
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +26 -3
- package/engine/object-field/ability.lua +54 -1
- package/engine/object-field.d.ts +2 -2
- package/engine/object-field.lua +4 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/standard/fields/ability.d.ts +2 -0
- package/engine/standard/fields/ability.lua +2 -0
- package/engine/unit.d.ts +3 -0
- package/engine/unit.lua +3 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/buff.lua +1 -1
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/utility/arrays.d.ts +8 -1
- package/utility/arrays.lua +34 -3
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +11 -2
- package/utility/linked-set.lua +5 -2
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +1 -0
|
@@ -4,14 +4,6 @@ import { Event } from "../../event";
|
|
|
4
4
|
import type { Item } from "../../core/types/item";
|
|
5
5
|
import type { Unit } from "./unit";
|
|
6
6
|
import type { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
7
|
-
interface Fields<K, V> {
|
|
8
|
-
set(field: K, value: V): boolean;
|
|
9
|
-
get(field: K): V;
|
|
10
|
-
has(field: K): boolean;
|
|
11
|
-
}
|
|
12
|
-
interface AbilityLevel {
|
|
13
|
-
realFields: Fields<jabilityreallevelfield, number>;
|
|
14
|
-
}
|
|
15
7
|
export type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
|
|
16
8
|
export declare class AbilitySnapshot {
|
|
17
9
|
}
|
|
@@ -20,7 +12,8 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
20
12
|
protected constructor(handle: jability, typeId: number);
|
|
21
13
|
toString(): string;
|
|
22
14
|
get parentTypeId(): number;
|
|
23
|
-
get
|
|
15
|
+
get orderTypeStringId(): string;
|
|
16
|
+
get orderTypeId(): number;
|
|
24
17
|
abstract readonly owner: Unit | Item;
|
|
25
18
|
getSnapshot(): AbilitySnapshot;
|
|
26
19
|
hasField(field: jabilityfield | number): boolean;
|
|
@@ -40,9 +33,11 @@ export declare abstract class Ability extends Handle<jability> {
|
|
|
40
33
|
setField(field: jabilityintegerlevelfield | jabilityreallevelfield, level: number, value: number): boolean;
|
|
41
34
|
setField(field: jabilitybooleanlevelfield, level: number, value: boolean): boolean;
|
|
42
35
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
43
|
-
get
|
|
44
|
-
get levels(): readonly AbilityLevel[];
|
|
36
|
+
get levelCount(): number;
|
|
45
37
|
abstract get level(): number;
|
|
38
|
+
abstract get cooldownRemaining(): number;
|
|
39
|
+
abstract set cooldownRemaining(cooldownRemaining: number);
|
|
40
|
+
abstract interruptCast(): void;
|
|
46
41
|
static get onCreate(): Event<[Ability]>;
|
|
47
42
|
static get destroyEvent(): Event<[Ability]>;
|
|
48
43
|
}
|
|
@@ -53,15 +48,21 @@ export declare class UnrecognizedAbility extends Ability {
|
|
|
53
48
|
readonly owner: Unit;
|
|
54
49
|
constructor(typeId: number, owner: Unit);
|
|
55
50
|
get level(): number;
|
|
51
|
+
get cooldownRemaining(): number;
|
|
52
|
+
set cooldownRemaining(_: number);
|
|
53
|
+
interruptCast(): void;
|
|
56
54
|
}
|
|
57
55
|
export declare class UnitAbility extends Ability {
|
|
58
56
|
readonly owner: Unit;
|
|
59
57
|
private readonly u;
|
|
60
58
|
constructor(handle: jability, typeId: number, owner: Unit);
|
|
59
|
+
incrementHideCounter(): void;
|
|
60
|
+
decrementHideCounter(): void;
|
|
61
61
|
get level(): number;
|
|
62
62
|
set level(v: number);
|
|
63
63
|
get cooldownRemaining(): number;
|
|
64
|
-
set cooldownRemaining(
|
|
64
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
65
|
+
interruptCast(): void;
|
|
65
66
|
static get onCreate(): Event<[UnitAbility]>;
|
|
66
67
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
67
68
|
}
|
|
@@ -85,7 +86,9 @@ export declare class ItemAbility extends Ability {
|
|
|
85
86
|
setField(field: jabilitybooleanlevelfield, level: number, value: boolean): boolean;
|
|
86
87
|
setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
|
|
87
88
|
get level(): number;
|
|
89
|
+
get cooldownRemaining(): number;
|
|
90
|
+
set cooldownRemaining(cooldownRemaining: number);
|
|
91
|
+
interruptCast(): void;
|
|
88
92
|
static get onCreate(): Event<[ItemAbility]>;
|
|
89
93
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
90
94
|
}
|
|
91
|
-
export {};
|
|
@@ -2,7 +2,6 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
3
3
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
4
4
|
local __TS__Class = ____lualib.__TS__Class
|
|
5
|
-
local __TS__New = ____lualib.__TS__New
|
|
6
5
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
7
6
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
8
7
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
@@ -11,7 +10,10 @@ local ____exports = {}
|
|
|
11
10
|
local ____handle = require("core.types.handle")
|
|
12
11
|
local Handle = ____handle.Handle
|
|
13
12
|
local ____ability = require("engine.internal.item.ability")
|
|
13
|
+
local abilityActionDummy = ____ability.abilityActionDummy
|
|
14
14
|
local doAbilityAction = ____ability.doAbilityAction
|
|
15
|
+
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
16
|
+
local startItemCooldown = ____ability.startItemCooldown
|
|
15
17
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
16
18
|
local setUnitAbilityLevel = SetUnitAbilityLevel
|
|
17
19
|
local setAbilityIntegerField = BlzSetAbilityIntegerField
|
|
@@ -33,7 +35,9 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
|
|
|
33
35
|
local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
|
|
34
36
|
local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
|
|
35
37
|
local getHandleId = GetHandleId
|
|
36
|
-
local
|
|
38
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
39
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
40
|
+
local unitHideAbility = BlzUnitHideAbility
|
|
37
41
|
local match = string.match
|
|
38
42
|
local ____type = _G.type
|
|
39
43
|
local ____tostring = _G.tostring
|
|
@@ -151,55 +155,6 @@ local orders = postcompile(function()
|
|
|
151
155
|
end
|
|
152
156
|
return orders
|
|
153
157
|
end)
|
|
154
|
-
local RealFields = __TS__Class()
|
|
155
|
-
RealFields.name = "RealFields"
|
|
156
|
-
function RealFields.prototype.____constructor(self, handle)
|
|
157
|
-
self.handle = handle
|
|
158
|
-
end
|
|
159
|
-
function RealFields.prototype.set(self, field, value)
|
|
160
|
-
return BlzSetAbilityRealField(self.handle, field, value)
|
|
161
|
-
end
|
|
162
|
-
function RealFields.prototype.get(self, field)
|
|
163
|
-
return BlzGetAbilityRealField(self.handle, field)
|
|
164
|
-
end
|
|
165
|
-
function RealFields.prototype.has(self, field)
|
|
166
|
-
local handle = self.handle
|
|
167
|
-
return BlzSetAbilityRealField(
|
|
168
|
-
handle,
|
|
169
|
-
field,
|
|
170
|
-
BlzGetAbilityRealField(handle, field)
|
|
171
|
-
)
|
|
172
|
-
end
|
|
173
|
-
local RealLevelFields = __TS__Class()
|
|
174
|
-
RealLevelFields.name = "RealLevelFields"
|
|
175
|
-
function RealLevelFields.prototype.____constructor(self, handle, level)
|
|
176
|
-
self.handle = handle
|
|
177
|
-
self.level = level
|
|
178
|
-
end
|
|
179
|
-
function RealLevelFields.prototype.set(self, field, value)
|
|
180
|
-
return BlzSetAbilityRealLevelField(self.handle, field, self.level, value)
|
|
181
|
-
end
|
|
182
|
-
function RealLevelFields.prototype.get(self, field)
|
|
183
|
-
return BlzGetAbilityRealLevelField(self.handle, field, self.level)
|
|
184
|
-
end
|
|
185
|
-
function RealLevelFields.prototype.has(self, field)
|
|
186
|
-
local handle = self.handle
|
|
187
|
-
return BlzSetAbilityRealLevelField(
|
|
188
|
-
handle,
|
|
189
|
-
field,
|
|
190
|
-
0,
|
|
191
|
-
BlzGetAbilityRealLevelField(handle, field, 0)
|
|
192
|
-
)
|
|
193
|
-
end
|
|
194
|
-
local realLevelMetatable = {__index = self}
|
|
195
|
-
local levelDescriptors = {realFields = function(self, handle, level)
|
|
196
|
-
return __TS__New(RealLevelFields, handle, level)
|
|
197
|
-
end}
|
|
198
|
-
local levelMetatable = {__index = function(self, key)
|
|
199
|
-
local fields = levelDescriptors[key](levelDescriptors, self.handle, self.level)
|
|
200
|
-
rawset(self, key, fields)
|
|
201
|
-
return fields
|
|
202
|
-
end}
|
|
203
158
|
local fieldGetters = {
|
|
204
159
|
abilityintegerfield = function(ability, field)
|
|
205
160
|
return getAbilityIntegerField(ability.handle, field)
|
|
@@ -346,43 +301,26 @@ __TS__SetDescriptor(
|
|
|
346
301
|
)
|
|
347
302
|
__TS__SetDescriptor(
|
|
348
303
|
Ability.prototype,
|
|
349
|
-
"
|
|
304
|
+
"orderTypeStringId",
|
|
350
305
|
{get = function(self)
|
|
351
306
|
local field = orderIdFieldByParentTypeId[self.parentTypeId]
|
|
352
|
-
return
|
|
307
|
+
return field ~= nil and getAbilityStringLevelField(self.handle, field, self.level) or (orders[self.parentTypeId] or "")
|
|
353
308
|
end},
|
|
354
309
|
true
|
|
355
310
|
)
|
|
356
311
|
__TS__SetDescriptor(
|
|
357
312
|
Ability.prototype,
|
|
358
|
-
"
|
|
313
|
+
"orderTypeId",
|
|
359
314
|
{get = function(self)
|
|
360
|
-
|
|
361
|
-
rawset(self, "realFields", realFields)
|
|
362
|
-
return realFields
|
|
315
|
+
return order2orderId(self.orderTypeStringId)
|
|
363
316
|
end},
|
|
364
317
|
true
|
|
365
318
|
)
|
|
366
319
|
__TS__SetDescriptor(
|
|
367
320
|
Ability.prototype,
|
|
368
|
-
"
|
|
321
|
+
"levelCount",
|
|
369
322
|
{get = function(self)
|
|
370
|
-
|
|
371
|
-
local levels = setmetatable(
|
|
372
|
-
{},
|
|
373
|
-
{
|
|
374
|
-
__len = function(self)
|
|
375
|
-
return BlzGetAbilityIntegerField(handle, ABILITY_IF_LEVELS)
|
|
376
|
-
end,
|
|
377
|
-
__index = function(self, i)
|
|
378
|
-
local level = setmetatable({handle = handle, level = i - 1}, levelMetatable)
|
|
379
|
-
self[i] = level
|
|
380
|
-
return level
|
|
381
|
-
end
|
|
382
|
-
}
|
|
383
|
-
)
|
|
384
|
-
rawset(self, "levels", levels)
|
|
385
|
-
return levels
|
|
323
|
+
return self:getField(ABILITY_IF_LEVELS)
|
|
386
324
|
end},
|
|
387
325
|
true
|
|
388
326
|
)
|
|
@@ -393,6 +331,17 @@ __TS__SetDescriptor(
|
|
|
393
331
|
end},
|
|
394
332
|
true
|
|
395
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
|
+
)
|
|
396
345
|
__TS__ObjectDefineProperty(
|
|
397
346
|
Ability,
|
|
398
347
|
"onCreate",
|
|
@@ -416,6 +365,8 @@ function UnrecognizedAbility.prototype.____constructor(self, typeId, owner)
|
|
|
416
365
|
UnrecognizedAbility.____super.prototype.____constructor(self, nil, typeId)
|
|
417
366
|
self.owner = owner
|
|
418
367
|
end
|
|
368
|
+
function UnrecognizedAbility.prototype.interruptCast(self)
|
|
369
|
+
end
|
|
419
370
|
__TS__SetDescriptor(
|
|
420
371
|
UnrecognizedAbility.prototype,
|
|
421
372
|
"level",
|
|
@@ -424,6 +375,18 @@ __TS__SetDescriptor(
|
|
|
424
375
|
end},
|
|
425
376
|
true
|
|
426
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
|
+
)
|
|
427
390
|
____exports.UnitAbility = __TS__Class()
|
|
428
391
|
local UnitAbility = ____exports.UnitAbility
|
|
429
392
|
UnitAbility.name = "UnitAbility"
|
|
@@ -433,6 +396,15 @@ function UnitAbility.prototype.____constructor(self, handle, typeId, owner)
|
|
|
433
396
|
self.owner = owner
|
|
434
397
|
self.u = owner.handle
|
|
435
398
|
end
|
|
399
|
+
function UnitAbility.prototype.incrementHideCounter(self)
|
|
400
|
+
unitHideAbility(self.u, self.typeId, true)
|
|
401
|
+
end
|
|
402
|
+
function UnitAbility.prototype.decrementHideCounter(self)
|
|
403
|
+
unitHideAbility(self.u, self.typeId, false)
|
|
404
|
+
end
|
|
405
|
+
function UnitAbility.prototype.interruptCast(self)
|
|
406
|
+
self.owner:interruptCast(self.typeId)
|
|
407
|
+
end
|
|
436
408
|
__TS__SetDescriptor(
|
|
437
409
|
UnitAbility.prototype,
|
|
438
410
|
"level",
|
|
@@ -453,8 +425,8 @@ __TS__SetDescriptor(
|
|
|
453
425
|
get = function(self)
|
|
454
426
|
return getUnitAbilityCooldownRemaining(self.u, self.typeId)
|
|
455
427
|
end,
|
|
456
|
-
set = function(self,
|
|
457
|
-
startUnitAbilityCooldown(self.u, self.typeId,
|
|
428
|
+
set = function(self, cooldownRemaining)
|
|
429
|
+
startUnitAbilityCooldown(self.u, self.typeId, cooldownRemaining)
|
|
458
430
|
end
|
|
459
431
|
},
|
|
460
432
|
true
|
|
@@ -479,6 +451,9 @@ end
|
|
|
479
451
|
local function setAbilityField(_, ability, field, levelOrValue, value)
|
|
480
452
|
return ____exports.Ability.prototype.setField(ability, field, levelOrValue, value)
|
|
481
453
|
end
|
|
454
|
+
local function getAbilityCooldown(_, abilityTypeId)
|
|
455
|
+
return getUnitAbilityCooldownRemaining(abilityActionDummy, abilityTypeId)
|
|
456
|
+
end
|
|
482
457
|
____exports.ItemAbility = __TS__Class()
|
|
483
458
|
local ItemAbility = ____exports.ItemAbility
|
|
484
459
|
ItemAbility.name = "ItemAbility"
|
|
@@ -506,6 +481,14 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
|
|
|
506
481
|
value
|
|
507
482
|
)
|
|
508
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
|
|
509
492
|
__TS__SetDescriptor(
|
|
510
493
|
ItemAbility.prototype,
|
|
511
494
|
"level",
|
|
@@ -514,6 +497,27 @@ __TS__SetDescriptor(
|
|
|
514
497
|
end},
|
|
515
498
|
true
|
|
516
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
|
+
)
|
|
517
521
|
__TS__ObjectDefineProperty(
|
|
518
522
|
ItemAbility,
|
|
519
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
|
|
@@ -6,10 +6,10 @@ local Item = ____item.Item
|
|
|
6
6
|
local ____unit = require("engine.internal.unit")
|
|
7
7
|
local Unit = ____unit.Unit
|
|
8
8
|
local ownerByItem = setmetatable({}, {__mode = "kv"})
|
|
9
|
-
Unit.
|
|
9
|
+
Unit.itemPickedUpEvent:addListener(function(unit, item)
|
|
10
10
|
ownerByItem[item] = unit
|
|
11
11
|
end)
|
|
12
|
-
Unit.
|
|
12
|
+
Unit.itemDroppedEvent:addListener(function(unit, item)
|
|
13
13
|
ownerByItem[item] = nil
|
|
14
14
|
end)
|
|
15
15
|
__TS__ObjectDefineProperty(
|
|
@@ -78,9 +78,9 @@ export declare class Item extends Handle<jitem> {
|
|
|
78
78
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
79
79
|
getAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
80
80
|
get abilities(): readonly ItemAbility[];
|
|
81
|
-
static getInRange(
|
|
81
|
+
static getInRange(x: number, y: number, range: number): Item[];
|
|
82
82
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
83
83
|
static get onCreate(): Event<[Item]>;
|
|
84
|
-
static get
|
|
84
|
+
static get destroyEvent(): Event<[Item]>;
|
|
85
85
|
}
|
|
86
86
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -15,6 +15,12 @@ local ____ability = require("engine.internal.ability")
|
|
|
15
15
|
local ItemAbility = ____ability.ItemAbility
|
|
16
16
|
local ____ability = require("engine.internal.item.ability")
|
|
17
17
|
local doAbilityAction = ____ability.doAbilityAction
|
|
18
|
+
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
19
|
+
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
20
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
21
|
+
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
22
|
+
local ____vec2 = require("math.vec2")
|
|
23
|
+
local distance = ____vec2.distance
|
|
18
24
|
local itemAddAbility = BlzItemAddAbility
|
|
19
25
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
20
26
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -24,6 +30,12 @@ local getAbilityId = BlzGetAbilityId
|
|
|
24
30
|
local getWidgetLife = GetWidgetLife
|
|
25
31
|
local removeItem = RemoveItem
|
|
26
32
|
local getHandleId = GetHandleId
|
|
33
|
+
local setRect = SetRect
|
|
34
|
+
local enumItemsInRect = EnumItemsInRect
|
|
35
|
+
local getEnumItem = GetEnumItem
|
|
36
|
+
local getItemTypeId = GetItemTypeId
|
|
37
|
+
local getItemX = GetItemX
|
|
38
|
+
local getItemY = GetItemY
|
|
27
39
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
28
40
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
29
41
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
@@ -53,6 +65,32 @@ local function getItemAbilities(handle, item)
|
|
|
53
65
|
end
|
|
54
66
|
return abilities
|
|
55
67
|
end
|
|
68
|
+
local targetCollection
|
|
69
|
+
local targetCollectionNextIndex
|
|
70
|
+
local centerX
|
|
71
|
+
local centerY
|
|
72
|
+
local enumRange
|
|
73
|
+
local function collectIntoTarget()
|
|
74
|
+
local item = getEnumItem()
|
|
75
|
+
local typeId = getItemTypeId(item)
|
|
76
|
+
if typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
|
|
77
|
+
targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
|
|
78
|
+
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
local function collectIntoTargetRange()
|
|
82
|
+
local item = getEnumItem()
|
|
83
|
+
local typeId = getItemTypeId(item)
|
|
84
|
+
if distance(
|
|
85
|
+
getItemX(item),
|
|
86
|
+
getItemY(item),
|
|
87
|
+
centerX,
|
|
88
|
+
centerY
|
|
89
|
+
) <= enumRange and typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
|
|
90
|
+
targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
|
|
91
|
+
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
92
|
+
end
|
|
93
|
+
end
|
|
56
94
|
____exports.Item = __TS__Class()
|
|
57
95
|
local Item = ____exports.Item
|
|
58
96
|
Item.name = "Item"
|
|
@@ -111,34 +149,27 @@ function Item.prototype.getAbility(self, abilityTypeId)
|
|
|
111
149
|
local ability = self[101][abilityTypeId] ~= nil and doAbilityAction(self.handle, getItemAbility, abilityTypeId)
|
|
112
150
|
return ability and ItemAbility:of(ability, abilityTypeId, self) or nil
|
|
113
151
|
end
|
|
114
|
-
function Item.getInRange(self,
|
|
115
|
-
|
|
116
|
-
|
|
152
|
+
function Item.getInRange(self, x, y, range)
|
|
153
|
+
targetCollection = {}
|
|
154
|
+
targetCollectionNextIndex = 1
|
|
155
|
+
centerX = x
|
|
156
|
+
centerY = y
|
|
157
|
+
enumRange = range
|
|
158
|
+
setRect(
|
|
117
159
|
enumRect,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
160
|
+
x - range,
|
|
161
|
+
y - range,
|
|
162
|
+
x + range,
|
|
163
|
+
y + range
|
|
122
164
|
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
nil,
|
|
126
|
-
function()
|
|
127
|
-
collection[#collection + 1] = self:of(GetEnumItem())
|
|
128
|
-
end
|
|
129
|
-
)
|
|
130
|
-
return collection
|
|
165
|
+
enumItemsInRect(enumRect, nil, collectIntoTargetRange)
|
|
166
|
+
return targetCollection
|
|
131
167
|
end
|
|
132
168
|
function Item.getInRect(self, rect)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function()
|
|
138
|
-
collection[#collection + 1] = self:of(GetEnumItem())
|
|
139
|
-
end
|
|
140
|
-
)
|
|
141
|
-
return collection
|
|
169
|
+
targetCollection = {}
|
|
170
|
+
targetCollectionNextIndex = 1
|
|
171
|
+
enumItemsInRect(rect.handle, nil, collectIntoTarget)
|
|
172
|
+
return targetCollection
|
|
142
173
|
end
|
|
143
174
|
__TS__SetDescriptor(
|
|
144
175
|
Item.prototype,
|
|
@@ -551,7 +582,7 @@ __TS__ObjectDefineProperty(
|
|
|
551
582
|
)
|
|
552
583
|
__TS__ObjectDefineProperty(
|
|
553
584
|
Item,
|
|
554
|
-
"
|
|
585
|
+
"destroyEvent",
|
|
555
586
|
{get = function(self)
|
|
556
587
|
return self.onDestroyEvent
|
|
557
588
|
end}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local disableAbility = BlzUnitDisableAbility
|
|
3
|
+
---
|
|
4
|
+
-- @internal For use by internal systems only.
|
|
5
|
+
____exports.increaseAbilityDisableCounter = function(unit, abilityTypeId, times)
|
|
6
|
+
for _ = 1, times do
|
|
7
|
+
disableAbility(unit, abilityTypeId, true, false)
|
|
8
|
+
end
|
|
9
|
+
for _ = times, -1 do
|
|
10
|
+
disableAbility(unit, abilityTypeId, false, false)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
return ____exports
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
export
|
|
2
|
+
export {};
|
|
@@ -10,5 +10,7 @@ ____exports.AUTO_ATTACK_SPEED_INCREASE_DUMMY_ABILITY_TYPE_ID = compiletime(funct
|
|
|
10
10
|
abilityType.autoAttackSpeedIncreaseFactor = 0
|
|
11
11
|
return abilityType.id
|
|
12
12
|
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems.
|
|
13
15
|
____exports.AUTO_ATTACK_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ABILITY_RLF_ATTACK_SPEED_INCREASE_ISX1
|
|
14
16
|
return ____exports
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____evasion = require("engine.object-data.entry.ability-type.evasion")
|
|
3
|
+
local EvasionAbilityType = ____evasion.EvasionAbilityType
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems.
|
|
6
|
+
____exports.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = compiletime(function()
|
|
7
|
+
local abilityType = EvasionAbilityType:create()
|
|
8
|
+
abilityType.isInternal = true
|
|
9
|
+
abilityType.isButtonVisible = false
|
|
10
|
+
abilityType.evasionProbability = 0
|
|
11
|
+
return abilityType.id
|
|
12
|
+
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems.
|
|
15
|
+
____exports.EVASION_PROBABILITY_ABILITY_FIELD = ABILITY_RLF_CHANCE_TO_EVADE_EEV1
|
|
16
|
+
return ____exports
|