warscript 0.0.1-dev.f5421e8 → 0.0.1-dev.f9166a3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attributes.d.ts +5 -0
- package/attributes.lua +8 -1
- package/core/types/order.d.ts +1 -0
- package/core/types/order.lua +11 -1
- package/core/types/sound.lua +5 -0
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/damage.d.ts +6 -3
- package/engine/behaviour/ability/damage.lua +24 -36
- package/engine/behaviour/ability/emulate-impact.lua +16 -2
- package/engine/behaviour/ability.lua +1 -1
- package/engine/behaviour/unit.d.ts +15 -0
- package/engine/behaviour/unit.lua +114 -4
- package/engine/internal/ability.d.ts +4 -0
- package/engine/internal/ability.lua +17 -0
- package/engine/internal/item/ability.lua +12 -10
- package/engine/internal/item.d.ts +5 -2
- package/engine/internal/item.lua +75 -3
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/unit/ability.d.ts +5 -0
- package/engine/internal/unit/ability.lua +14 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +20 -3
- package/engine/internal/unit.lua +163 -37
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type.lua +7 -0
- package/engine/object-data/entry/buff-type/applicable.lua +5 -0
- package/engine/object-data/entry/buff-type.d.ts +5 -11
- package/engine/object-data/entry/buff-type.lua +11 -27
- package/engine/object-data/entry/unit-type.d.ts +2 -2
- package/engine/object-data/entry/unit-type.lua +94 -84
- package/engine/object-field/ability.d.ts +1 -1
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +12 -3
- package/engine/object-field.lua +164 -78
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/objutil/buff.lua +1 -2
- package/package.json +2 -2
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +3 -0
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
|
@@ -4,26 +4,29 @@ import { Ability } from "../../internal/ability";
|
|
|
4
4
|
import { Unit } from "../../internal/unit";
|
|
5
5
|
import { AbilityDependentValue } from "../../object-field/ability";
|
|
6
6
|
import { Widget } from "../../../core/types/widget";
|
|
7
|
-
import {
|
|
7
|
+
import { DamageType, WeaponType } from "../../internal/unit+damage";
|
|
8
8
|
import { CombatClassifications } from "../../object-data/auxiliary/combat-classification";
|
|
9
|
+
import { AttackType } from "../../object-data/auxiliary/attack-type";
|
|
9
10
|
export type DamageAbilityBehaviorParameters = {
|
|
10
11
|
damagePerStrength?: AbilityDependentValue<number>;
|
|
11
12
|
damagePerAgility?: AbilityDependentValue<number>;
|
|
12
13
|
damagePerIntelligence?: AbilityDependentValue<number>;
|
|
13
|
-
attackType?: AttackType
|
|
14
|
+
attackType?: AbilityDependentValue<AttackType>;
|
|
14
15
|
damageType?: DamageType;
|
|
15
16
|
weaponType?: WeaponType;
|
|
17
|
+
metadata?: AbilityDependentValue<string | number | boolean>;
|
|
16
18
|
};
|
|
17
19
|
export type DamageAreaAbilityBehaviorParameters = DamageAbilityBehaviorParameters & {
|
|
18
20
|
maximumDamage?: AbilityDependentValue<number>;
|
|
19
21
|
areaOfEffect?: AbilityDependentValue<number>;
|
|
20
22
|
allowedTargetCombatClassifications?: AbilityDependentValue<CombatClassifications>;
|
|
21
23
|
};
|
|
22
|
-
declare abstract class DamageAbilityBehavior<T extends DamageAbilityBehaviorParameters = DamageAbilityBehaviorParameters> extends AbilityBehavior {
|
|
24
|
+
export declare abstract class DamageAbilityBehavior<T extends DamageAbilityBehaviorParameters = DamageAbilityBehaviorParameters> extends AbilityBehavior {
|
|
23
25
|
protected readonly damage: AbilityDependentValue<number>;
|
|
24
26
|
protected readonly parameters?: T | undefined;
|
|
25
27
|
protected constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: T | undefined);
|
|
26
28
|
protected calculateDamage(caster: Unit): number;
|
|
29
|
+
protected damageTarget(caster: Unit, target: Widget, damage?: number): void;
|
|
27
30
|
}
|
|
28
31
|
export declare class DamageSelfAbilityBehavior extends DamageAbilityBehavior {
|
|
29
32
|
constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAbilityBehaviorParameters);
|
|
@@ -9,7 +9,8 @@ local Unit = ____unit.Unit
|
|
|
9
9
|
local ____ability = require("engine.standard.fields.ability")
|
|
10
10
|
local ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD = ____ability.ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD
|
|
11
11
|
local AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD = ____ability.AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD
|
|
12
|
-
|
|
12
|
+
____exports.DamageAbilityBehavior = __TS__Class()
|
|
13
|
+
local DamageAbilityBehavior = ____exports.DamageAbilityBehavior
|
|
13
14
|
DamageAbilityBehavior.name = "DamageAbilityBehavior"
|
|
14
15
|
__TS__ClassExtends(DamageAbilityBehavior, AbilityBehavior)
|
|
15
16
|
function DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
@@ -34,49 +35,44 @@ function DamageAbilityBehavior.prototype.calculateDamage(self, caster)
|
|
|
34
35
|
end
|
|
35
36
|
return damage
|
|
36
37
|
end
|
|
37
|
-
|
|
38
|
-
local DamageSelfAbilityBehavior = ____exports.DamageSelfAbilityBehavior
|
|
39
|
-
DamageSelfAbilityBehavior.name = "DamageSelfAbilityBehavior"
|
|
40
|
-
__TS__ClassExtends(DamageSelfAbilityBehavior, DamageAbilityBehavior)
|
|
41
|
-
function DamageSelfAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
42
|
-
DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
43
|
-
end
|
|
44
|
-
function DamageSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
38
|
+
function DamageAbilityBehavior.prototype.damageTarget(self, caster, target, damage)
|
|
45
39
|
local parameters = self.parameters
|
|
46
40
|
caster:damageTarget(
|
|
47
|
-
|
|
48
|
-
self:calculateDamage(caster),
|
|
41
|
+
target,
|
|
42
|
+
damage or self:calculateDamage(caster),
|
|
49
43
|
nil,
|
|
50
44
|
nil,
|
|
51
|
-
parameters and parameters.attackType,
|
|
45
|
+
self:resolveCurrentAbilityDependentValue(parameters and parameters.attackType),
|
|
52
46
|
parameters and parameters.damageType,
|
|
53
|
-
parameters and parameters.weaponType
|
|
47
|
+
parameters and parameters.weaponType,
|
|
48
|
+
self:resolveCurrentAbilityDependentValue(parameters and parameters.metadata)
|
|
54
49
|
)
|
|
55
50
|
end
|
|
51
|
+
____exports.DamageSelfAbilityBehavior = __TS__Class()
|
|
52
|
+
local DamageSelfAbilityBehavior = ____exports.DamageSelfAbilityBehavior
|
|
53
|
+
DamageSelfAbilityBehavior.name = "DamageSelfAbilityBehavior"
|
|
54
|
+
__TS__ClassExtends(DamageSelfAbilityBehavior, ____exports.DamageAbilityBehavior)
|
|
55
|
+
function DamageSelfAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
56
|
+
DamageSelfAbilityBehavior.____super.prototype.____constructor(self, ability, damage, parameters)
|
|
57
|
+
end
|
|
58
|
+
function DamageSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
59
|
+
self:damageTarget(caster, caster)
|
|
60
|
+
end
|
|
56
61
|
____exports.DamageTargetAbilityBehavior = __TS__Class()
|
|
57
62
|
local DamageTargetAbilityBehavior = ____exports.DamageTargetAbilityBehavior
|
|
58
63
|
DamageTargetAbilityBehavior.name = "DamageTargetAbilityBehavior"
|
|
59
|
-
__TS__ClassExtends(DamageTargetAbilityBehavior, DamageAbilityBehavior)
|
|
64
|
+
__TS__ClassExtends(DamageTargetAbilityBehavior, ____exports.DamageAbilityBehavior)
|
|
60
65
|
function DamageTargetAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
61
|
-
|
|
66
|
+
DamageTargetAbilityBehavior.____super.prototype.____constructor(self, ability, damage, parameters)
|
|
62
67
|
end
|
|
63
68
|
function DamageTargetAbilityBehavior.prototype.onWidgetTargetImpact(self, caster, target)
|
|
64
|
-
|
|
65
|
-
caster:damageTarget(
|
|
66
|
-
target,
|
|
67
|
-
self:calculateDamage(caster),
|
|
68
|
-
nil,
|
|
69
|
-
nil,
|
|
70
|
-
parameters and parameters.attackType,
|
|
71
|
-
parameters and parameters.damageType,
|
|
72
|
-
parameters and parameters.weaponType
|
|
73
|
-
)
|
|
69
|
+
self:damageTarget(caster, target)
|
|
74
70
|
end
|
|
75
71
|
local DamageAreaAbilityBehavior = __TS__Class()
|
|
76
72
|
DamageAreaAbilityBehavior.name = "DamageAreaAbilityBehavior"
|
|
77
|
-
__TS__ClassExtends(DamageAreaAbilityBehavior, DamageAbilityBehavior)
|
|
73
|
+
__TS__ClassExtends(DamageAreaAbilityBehavior, ____exports.DamageAbilityBehavior)
|
|
78
74
|
function DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
79
|
-
|
|
75
|
+
DamageAreaAbilityBehavior.____super.prototype.____constructor(self, ability, damage, parameters)
|
|
80
76
|
end
|
|
81
77
|
function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
|
|
82
78
|
local parameters = self.parameters
|
|
@@ -93,15 +89,7 @@ function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
|
|
|
93
89
|
damage = maximumDamage / #targets
|
|
94
90
|
end
|
|
95
91
|
for ____, target in ipairs(targets) do
|
|
96
|
-
|
|
97
|
-
target,
|
|
98
|
-
damage,
|
|
99
|
-
nil,
|
|
100
|
-
nil,
|
|
101
|
-
parameters and parameters.attackType,
|
|
102
|
-
parameters and parameters.damageType,
|
|
103
|
-
parameters and parameters.weaponType
|
|
104
|
-
)
|
|
92
|
+
self:damageTarget(caster, target, damage)
|
|
105
93
|
end
|
|
106
94
|
end
|
|
107
95
|
____exports.DamageSelfAreaAbilityBehavior = __TS__Class()
|
|
@@ -1,15 +1,25 @@
|
|
|
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 ____exports = {}
|
|
5
6
|
local ____ability = require("engine.behaviour.ability")
|
|
6
7
|
local AbilityBehavior = ____ability.AbilityBehavior
|
|
8
|
+
local ____unit = require("engine.internal.unit")
|
|
9
|
+
local Unit = ____unit.Unit
|
|
7
10
|
local ____ability = require("engine.standard.fields.ability")
|
|
8
11
|
local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
|
|
9
12
|
local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTEGER_LEVEL_FIELD
|
|
10
13
|
local ____math = require("math")
|
|
11
14
|
local max = ____math.max
|
|
12
15
|
local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
16
|
+
local ____sound = require("core.types.sound")
|
|
17
|
+
local Sound3D = ____sound.Sound3D
|
|
18
|
+
local SoundSettings = ____sound.SoundSettings
|
|
19
|
+
local ____ability = require("engine.internal.ability")
|
|
20
|
+
local UnitAbility = ____ability.UnitAbility
|
|
21
|
+
local ____event = require("event")
|
|
22
|
+
local Event = ____event.Event
|
|
13
23
|
____exports.EmulateImpactAbilityBehavior = __TS__Class()
|
|
14
24
|
local EmulateImpactAbilityBehavior = ____exports.EmulateImpactAbilityBehavior
|
|
15
25
|
EmulateImpactAbilityBehavior.name = "EmulateImpactAbilityBehavior"
|
|
@@ -17,12 +27,16 @@ __TS__ClassExtends(EmulateImpactAbilityBehavior, AbilityBehavior)
|
|
|
17
27
|
function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
18
28
|
local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
|
|
19
29
|
local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
|
|
20
|
-
if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost then
|
|
30
|
+
if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost or __TS__InstanceOf(self.ability, UnitAbility) and self.ability.isDisabled then
|
|
21
31
|
return
|
|
22
32
|
end
|
|
23
33
|
caster.mana = caster.mana - manaCost
|
|
24
34
|
self.ability.cooldownRemaining = max(cooldown, MINIMUM_POSITIVE_NORMALIZED_FLOAT)
|
|
25
35
|
self:flashCasterEffect(caster)
|
|
26
|
-
|
|
36
|
+
local soundPresetId = self.ability:getField(ABILITY_SF_EFFECT_SOUND)
|
|
37
|
+
if soundPresetId ~= "" then
|
|
38
|
+
Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
|
|
39
|
+
end
|
|
40
|
+
Event.invoke(Unit.abilityImpactEvent, caster, self.ability)
|
|
27
41
|
end
|
|
28
42
|
return ____exports
|
|
@@ -274,7 +274,7 @@ __TS__SetDescriptor(
|
|
|
274
274
|
Unit.abilityDestructibleTargetChannelingStartEvent:addListener(createUnitEventListener("onDestructibleTargetChannelingStart"))
|
|
275
275
|
Unit.abilityPointTargetChannelingStartEvent:addListener(createUnitEventListener("onPointTargetChannelingStart"))
|
|
276
276
|
Unit.abilityNoTargetChannelingStartEvent:addListener(createUnitEventListener("onNoTargetChannelingStart"))
|
|
277
|
-
Unit.
|
|
277
|
+
Unit.abilityImpactEvent:addListener(createUnitEventListener("onImpact"))
|
|
278
278
|
Unit.abilityWidgetTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onWidgetTargetImpact"))
|
|
279
279
|
Unit.abilityUnitTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onUnitTargetImpact"))
|
|
280
280
|
Unit.abilityItemTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onItemTargetImpact"))
|
|
@@ -6,23 +6,38 @@ import "../internal/unit+ability";
|
|
|
6
6
|
import "../internal/unit-missile-launch";
|
|
7
7
|
import { Item } from "../internal/item";
|
|
8
8
|
import type { AbilityBehavior } from "./ability";
|
|
9
|
+
import { Event } from "../../event";
|
|
10
|
+
import { Destructor } from "../../destroyable";
|
|
11
|
+
import type { Widget } from "../../core/types/widget";
|
|
9
12
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
10
13
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
11
14
|
constructor(unit: Unit);
|
|
15
|
+
protected onDestroy(): Destructor;
|
|
12
16
|
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
13
17
|
get unit(): Unit;
|
|
18
|
+
registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, unit: Unit, ...args: Args) => unknown>, event: Event<[Unit, ...Args]>, range: number, listener: T): void;
|
|
19
|
+
onImmediateOrder(orderId: number): void;
|
|
20
|
+
onTargetOrder(orderId: number, target: Widget): void;
|
|
21
|
+
onPointOrder(orderId: number, x: number, y: number): void;
|
|
14
22
|
onAutoAttackStart(target: Unit): void;
|
|
15
23
|
onAutoAttackFinish(target: Unit): void;
|
|
24
|
+
onTargetingAutoAttackStart(source: Unit): void;
|
|
25
|
+
onTargetingAutoAttackFinish(source: Unit): void;
|
|
16
26
|
onDamageDealing(target: Unit, event: DamagingEvent): void;
|
|
17
27
|
onDamageDealt(target: Unit, event: DamageEvent): void;
|
|
18
28
|
onDamageReceiving(source: Unit | undefined, event: DamagingEvent): void;
|
|
19
29
|
onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
|
|
20
30
|
onAbilityGained(ability: Ability): void;
|
|
21
31
|
onAbilityLost(ability: Ability): void;
|
|
32
|
+
onAbilityChannelingStart(ability: Ability): void;
|
|
33
|
+
onAbilityImpact(ability: Ability): void;
|
|
34
|
+
onAbilityChannelingFinish(ability: Ability): void;
|
|
35
|
+
onAbilityStop(ability: Ability): void;
|
|
22
36
|
onItemDropped(item: Item): void;
|
|
23
37
|
onItemPickedUp(item: Item): void;
|
|
24
38
|
onItemUsed(item: Item): void;
|
|
25
39
|
onItemStacked(item: Item): void;
|
|
40
|
+
onItemChargesChanged(item: Item): void;
|
|
26
41
|
onKill(target: Unit): void;
|
|
27
42
|
onDeath(source: Unit | undefined): void;
|
|
28
43
|
}
|
|
@@ -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__New = ____lualib.__TS__New
|
|
4
5
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____behavior = require("engine.behavior")
|
|
@@ -9,6 +10,17 @@ local ____unit = require("engine.internal.unit")
|
|
|
9
10
|
local Unit = ____unit.Unit
|
|
10
11
|
require("engine.internal.unit+ability")
|
|
11
12
|
require("engine.internal.unit-missile-launch")
|
|
13
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
14
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
15
|
+
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
16
|
+
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
17
|
+
local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
|
|
18
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
19
|
+
local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
|
|
20
|
+
local behaviorsByEvent = {}
|
|
21
|
+
local rangeByBehaviorByEvent = {}
|
|
22
|
+
local listenerByBehaviorByEvent = {}
|
|
23
|
+
local eventsByBehavior = {}
|
|
12
24
|
____exports.UnitBehavior = __TS__Class()
|
|
13
25
|
local UnitBehavior = ____exports.UnitBehavior
|
|
14
26
|
UnitBehavior.name = "UnitBehavior"
|
|
@@ -16,10 +28,66 @@ __TS__ClassExtends(UnitBehavior, Behavior)
|
|
|
16
28
|
function UnitBehavior.prototype.____constructor(self, unit)
|
|
17
29
|
Behavior.prototype.____constructor(self, unit)
|
|
18
30
|
end
|
|
31
|
+
function UnitBehavior.prototype.onDestroy(self)
|
|
32
|
+
local events = eventsByBehavior[self]
|
|
33
|
+
if events ~= nil then
|
|
34
|
+
for event in pairs(events) do
|
|
35
|
+
local ____opt_0 = behaviorsByEvent[event]
|
|
36
|
+
if ____opt_0 ~= nil then
|
|
37
|
+
____opt_0:remove(self)
|
|
38
|
+
end
|
|
39
|
+
local ____opt_2 = rangeByBehaviorByEvent[event]
|
|
40
|
+
if ____opt_2 ~= nil then
|
|
41
|
+
____opt_2[self] = nil
|
|
42
|
+
end
|
|
43
|
+
local ____opt_4 = listenerByBehaviorByEvent[event]
|
|
44
|
+
if ____opt_4 ~= nil then
|
|
45
|
+
____opt_4[self] = nil
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
eventsByBehavior[self] = nil
|
|
49
|
+
end
|
|
50
|
+
return Behavior.prototype.onDestroy(self)
|
|
51
|
+
end
|
|
52
|
+
function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, range, listener)
|
|
53
|
+
local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
|
|
54
|
+
rangeByBehavior[self] = range
|
|
55
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
|
|
56
|
+
listenerByBehavior[self] = listener
|
|
57
|
+
getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
|
|
58
|
+
local behaviors = behaviorsByEvent[event]
|
|
59
|
+
if behaviors == nil then
|
|
60
|
+
event:addListener(function(unit, ...)
|
|
61
|
+
local behaviors = behaviorsByEvent[event]
|
|
62
|
+
if behaviors ~= nil then
|
|
63
|
+
for behavior in pairs(behaviors) do
|
|
64
|
+
local range = rangeByBehavior[behavior]
|
|
65
|
+
if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
|
|
66
|
+
local ____self_6 = behavior
|
|
67
|
+
____self_6[listenerByBehavior[behavior]](____self_6, unit, ...)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end)
|
|
72
|
+
behaviors = __TS__New(LinkedSet)
|
|
73
|
+
behaviorsByEvent[event] = behaviors
|
|
74
|
+
end
|
|
75
|
+
behaviors:add(self)
|
|
76
|
+
end
|
|
77
|
+
function UnitBehavior.prototype.onImmediateOrder(self, orderId)
|
|
78
|
+
end
|
|
79
|
+
function UnitBehavior.prototype.onTargetOrder(self, orderId, target)
|
|
80
|
+
end
|
|
81
|
+
function UnitBehavior.prototype.onPointOrder(self, orderId, x, y)
|
|
82
|
+
end
|
|
19
83
|
function UnitBehavior.prototype.onAutoAttackStart(self, target)
|
|
20
84
|
end
|
|
21
85
|
function UnitBehavior.prototype.onAutoAttackFinish(self, target)
|
|
22
86
|
end
|
|
87
|
+
function UnitBehavior.prototype.onTargetingAutoAttackStart(self, source)
|
|
88
|
+
end
|
|
89
|
+
function UnitBehavior.prototype.onTargetingAutoAttackFinish(self, source)
|
|
90
|
+
end
|
|
23
91
|
function UnitBehavior.prototype.onDamageDealing(self, target, event)
|
|
24
92
|
end
|
|
25
93
|
function UnitBehavior.prototype.onDamageDealt(self, target, event)
|
|
@@ -32,6 +100,14 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
|
|
|
32
100
|
end
|
|
33
101
|
function UnitBehavior.prototype.onAbilityLost(self, ability)
|
|
34
102
|
end
|
|
103
|
+
function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
|
|
104
|
+
end
|
|
105
|
+
function UnitBehavior.prototype.onAbilityImpact(self, ability)
|
|
106
|
+
end
|
|
107
|
+
function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
|
|
108
|
+
end
|
|
109
|
+
function UnitBehavior.prototype.onAbilityStop(self, ability)
|
|
110
|
+
end
|
|
35
111
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
36
112
|
end
|
|
37
113
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
|
@@ -40,6 +116,8 @@ function UnitBehavior.prototype.onItemUsed(self, item)
|
|
|
40
116
|
end
|
|
41
117
|
function UnitBehavior.prototype.onItemStacked(self, item)
|
|
42
118
|
end
|
|
119
|
+
function UnitBehavior.prototype.onItemChargesChanged(self, item)
|
|
120
|
+
end
|
|
43
121
|
function UnitBehavior.prototype.onKill(self, target)
|
|
44
122
|
end
|
|
45
123
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
@@ -53,11 +131,28 @@ __TS__SetDescriptor(
|
|
|
53
131
|
true
|
|
54
132
|
);
|
|
55
133
|
(function(self)
|
|
134
|
+
Unit.onImmediateOrder:addListener(function(source, orderId)
|
|
135
|
+
____exports.UnitBehavior:forAll(source, "onImmediateOrder", orderId)
|
|
136
|
+
end)
|
|
137
|
+
Unit.onTargetOrder:addListener(function(source, orderId, target)
|
|
138
|
+
____exports.UnitBehavior:forAll(source, "onTargetOrder", orderId, target)
|
|
139
|
+
end)
|
|
140
|
+
Unit.onPointOrder:addListener(function(source, orderId, x, y)
|
|
141
|
+
____exports.UnitBehavior:forAll(
|
|
142
|
+
source,
|
|
143
|
+
"onPointOrder",
|
|
144
|
+
orderId,
|
|
145
|
+
x,
|
|
146
|
+
y
|
|
147
|
+
)
|
|
148
|
+
end)
|
|
56
149
|
Unit.autoAttackStartEvent:addListener(function(source, target)
|
|
57
150
|
____exports.UnitBehavior:forAll(source, "onAutoAttackStart", target)
|
|
151
|
+
____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackStart", source)
|
|
58
152
|
end)
|
|
59
153
|
Unit.autoAttackFinishEvent:addListener(function(source, target)
|
|
60
154
|
____exports.UnitBehavior:forAll(source, "onAutoAttackFinish", target)
|
|
155
|
+
____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackFinish", source)
|
|
61
156
|
end)
|
|
62
157
|
Unit.onDamaging:addListener(function(source, target, event)
|
|
63
158
|
if source ~= nil then
|
|
@@ -71,11 +166,23 @@ __TS__SetDescriptor(
|
|
|
71
166
|
end
|
|
72
167
|
____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
|
|
73
168
|
end)
|
|
74
|
-
Unit.abilityGainedEvent:addListener(function(source,
|
|
75
|
-
____exports.UnitBehavior:forAll(source, "onAbilityGained",
|
|
169
|
+
Unit.abilityGainedEvent:addListener(function(source, ability)
|
|
170
|
+
____exports.UnitBehavior:forAll(source, "onAbilityGained", ability)
|
|
76
171
|
end)
|
|
77
|
-
Unit.abilityLostEvent:addListener(function(source,
|
|
78
|
-
____exports.UnitBehavior:forAll(source, "onAbilityLost",
|
|
172
|
+
Unit.abilityLostEvent:addListener(function(source, ability)
|
|
173
|
+
____exports.UnitBehavior:forAll(source, "onAbilityLost", ability)
|
|
174
|
+
end)
|
|
175
|
+
Unit.abilityChannelingStartEvent:addListener(function(source, ability)
|
|
176
|
+
____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
|
|
177
|
+
end)
|
|
178
|
+
Unit.abilityImpactEvent:addListener(function(source, ability)
|
|
179
|
+
____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
|
|
180
|
+
end)
|
|
181
|
+
Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
|
|
182
|
+
____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
|
|
183
|
+
end)
|
|
184
|
+
Unit.abilityStopEvent:addListener(function(source, ability)
|
|
185
|
+
____exports.UnitBehavior:forAll(source, "onAbilityStop", ability)
|
|
79
186
|
end)
|
|
80
187
|
Unit.deathEvent:addListener(function(target, source)
|
|
81
188
|
if source ~= nil then
|
|
@@ -95,6 +202,9 @@ __TS__SetDescriptor(
|
|
|
95
202
|
Unit.itemStackedEvent:addListener(function(unit, item)
|
|
96
203
|
____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
|
|
97
204
|
end)
|
|
205
|
+
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
206
|
+
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
207
|
+
end)
|
|
98
208
|
end)(UnitBehavior)
|
|
99
209
|
Unit.destroyEvent:addListener(function(unit)
|
|
100
210
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
|
@@ -55,9 +55,13 @@ export declare class UnrecognizedAbility extends Ability {
|
|
|
55
55
|
export declare class UnitAbility extends Ability {
|
|
56
56
|
readonly owner: Unit;
|
|
57
57
|
private readonly u;
|
|
58
|
+
private d?;
|
|
58
59
|
constructor(handle: jability, typeId: number, owner: Unit);
|
|
59
60
|
incrementHideCounter(): void;
|
|
60
61
|
decrementHideCounter(): void;
|
|
62
|
+
incrementDisableCounter(): void;
|
|
63
|
+
decrementDisableCounter(): void;
|
|
64
|
+
get isDisabled(): boolean;
|
|
61
65
|
get level(): number;
|
|
62
66
|
set level(v: number);
|
|
63
67
|
get cooldownRemaining(): number;
|
|
@@ -38,6 +38,7 @@ local getHandleId = GetHandleId
|
|
|
38
38
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
39
39
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
40
40
|
local unitHideAbility = BlzUnitHideAbility
|
|
41
|
+
local unitDisableAbility = BlzUnitDisableAbility
|
|
41
42
|
local match = string.match
|
|
42
43
|
local ____type = _G.type
|
|
43
44
|
local ____tostring = _G.tostring
|
|
@@ -402,9 +403,25 @@ end
|
|
|
402
403
|
function UnitAbility.prototype.decrementHideCounter(self)
|
|
403
404
|
unitHideAbility(self.u, self.typeId, false)
|
|
404
405
|
end
|
|
406
|
+
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
407
|
+
unitDisableAbility(self.u, self.typeId, true, false)
|
|
408
|
+
self.d = (self.d or 0) + 1
|
|
409
|
+
end
|
|
410
|
+
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
411
|
+
unitDisableAbility(self.u, self.typeId, false, false)
|
|
412
|
+
self.d = (self.d or 0) - 1
|
|
413
|
+
end
|
|
405
414
|
function UnitAbility.prototype.interruptCast(self)
|
|
406
415
|
self.owner:interruptCast(self.typeId)
|
|
407
416
|
end
|
|
417
|
+
__TS__SetDescriptor(
|
|
418
|
+
UnitAbility.prototype,
|
|
419
|
+
"isDisabled",
|
|
420
|
+
{get = function(self)
|
|
421
|
+
return self.d ~= nil and self.d > 0
|
|
422
|
+
end},
|
|
423
|
+
true
|
|
424
|
+
)
|
|
408
425
|
__TS__SetDescriptor(
|
|
409
426
|
UnitAbility.prototype,
|
|
410
427
|
"level",
|
|
@@ -55,22 +55,24 @@ local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
|
|
|
55
55
|
itemType.activelyUsed = true
|
|
56
56
|
return itemType.id
|
|
57
57
|
end)
|
|
58
|
-
|
|
58
|
+
---
|
|
59
|
+
-- @internal For use by internal systems only.
|
|
60
|
+
____exports.itemAbilityDummy = assert(CreateUnit(
|
|
59
61
|
Player.neutralVictim.handle,
|
|
60
62
|
dummyUnitId,
|
|
61
63
|
0,
|
|
62
64
|
0,
|
|
63
65
|
270
|
|
64
66
|
))
|
|
65
|
-
local cooldownStarterItem = UnitAddItemById(
|
|
67
|
+
local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
66
68
|
local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
67
|
-
ShowUnit(
|
|
69
|
+
ShowUnit(____exports.itemAbilityDummy, false)
|
|
68
70
|
local function startItemCooldownInternal(handle, cooldown)
|
|
69
71
|
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
70
72
|
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
71
73
|
setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
|
|
72
|
-
unitResetCooldown(
|
|
73
|
-
unitUseItem(
|
|
74
|
+
unitResetCooldown(____exports.itemAbilityDummy)
|
|
75
|
+
unitUseItem(____exports.itemAbilityDummy, cooldownStarterItem)
|
|
74
76
|
Timer:run(restoreCooldownGroup, handle, cooldownGroup)
|
|
75
77
|
end
|
|
76
78
|
restoreCooldownGroup = function(handle, cooldownGroup)
|
|
@@ -85,7 +87,7 @@ ____exports.startItemCooldown = function(handle, owner, cooldown)
|
|
|
85
87
|
end
|
|
86
88
|
---
|
|
87
89
|
-- @internal For use by internal systems only.
|
|
88
|
-
____exports.abilityActionDummy =
|
|
90
|
+
____exports.abilityActionDummy = ____exports.itemAbilityDummy
|
|
89
91
|
---
|
|
90
92
|
-- @internal For use by internal systems only.
|
|
91
93
|
____exports.doAbilityAction = function(handle, action, ...)
|
|
@@ -104,11 +106,11 @@ ____exports.doAbilityAction = function(handle, action, ...)
|
|
|
104
106
|
end
|
|
105
107
|
x = getItemX(handle)
|
|
106
108
|
y = getItemY(handle)
|
|
107
|
-
unitAddItem(
|
|
109
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
108
110
|
end
|
|
109
111
|
local result = action(handle, ...)
|
|
110
112
|
if not isOwned then
|
|
111
|
-
unitRemoveItem(
|
|
113
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
112
114
|
setItemPosition(handle, x, y)
|
|
113
115
|
if isPowerup then
|
|
114
116
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
@@ -139,9 +141,9 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
|
139
141
|
isPowerup = true
|
|
140
142
|
end
|
|
141
143
|
unitRemoveItem(owner, handle)
|
|
142
|
-
unitAddItem(
|
|
144
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
143
145
|
local result = action(handle, ...)
|
|
144
|
-
unitRemoveItem(
|
|
146
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
145
147
|
unitAddItemToSlot(owner, handle, slot)
|
|
146
148
|
if isPowerup then
|
|
147
149
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
@@ -5,8 +5,8 @@ import { Event } from "../../event";
|
|
|
5
5
|
import { ReadonlyRect } from "../../core/types/rect";
|
|
6
6
|
import { ItemAbility } from "./ability";
|
|
7
7
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
8
|
+
import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
8
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
9
|
-
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
10
10
|
declare const enum ItemPropertyKey {
|
|
11
11
|
ABILITIES = 100,
|
|
12
12
|
LUA_INDEX_BY_ABILITY_TYPE_ID = 101
|
|
@@ -17,7 +17,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
17
17
|
constructor(handle: jitem);
|
|
18
18
|
protected onDestroy(): HandleDestructor;
|
|
19
19
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
|
20
|
-
get typeId():
|
|
20
|
+
get typeId(): ItemTypeId;
|
|
21
21
|
set skinId(v: number);
|
|
22
22
|
get skinId(): number;
|
|
23
23
|
set name(v: string);
|
|
@@ -73,6 +73,8 @@ export declare class Item extends Handle<jitem> {
|
|
|
73
73
|
set position(v: Vec2);
|
|
74
74
|
set charges(v: number);
|
|
75
75
|
get charges(): number;
|
|
76
|
+
consumeCharge(): boolean;
|
|
77
|
+
consumeCharges(count: number): boolean;
|
|
76
78
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
77
79
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
78
80
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
@@ -82,5 +84,6 @@ export declare class Item extends Handle<jitem> {
|
|
|
82
84
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
83
85
|
static get onCreate(): Event<[Item]>;
|
|
84
86
|
static get destroyEvent(): Event<[Item]>;
|
|
87
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
85
88
|
}
|
|
86
89
|
export {};
|