warscript 0.0.1-dev.d408eb6 → 0.0.1-dev.d5494fc
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.d.ts +1 -3
- package/core/types/effect.lua +26 -29
- package/core/types/sound.lua +5 -0
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/damage.d.ts +5 -2
- package/engine/behaviour/ability/damage.lua +16 -29
- package/engine/behaviour/ability/emulate-impact.lua +7 -0
- package/engine/behaviour/ability.d.ts +4 -1
- package/engine/behaviour/ability.lua +6 -4
- package/engine/internal/item.d.ts +2 -1
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- 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+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.d.ts +10 -1
- package/engine/internal/unit.lua +73 -30
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- 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/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.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/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +11 -11
- package/engine/object-data/entry/ability-type.lua +27 -6
- 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 +9 -1
- package/engine/object-field.lua +158 -76
- 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,15 +4,17 @@ 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>;
|
|
@@ -24,6 +26,7 @@ declare abstract class DamageAbilityBehavior<T extends DamageAbilityBehaviorPara
|
|
|
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);
|
|
@@ -34,6 +34,19 @@ function DamageAbilityBehavior.prototype.calculateDamage(self, caster)
|
|
|
34
34
|
end
|
|
35
35
|
return damage
|
|
36
36
|
end
|
|
37
|
+
function DamageAbilityBehavior.prototype.damageTarget(self, caster, target, damage)
|
|
38
|
+
local parameters = self.parameters
|
|
39
|
+
caster:damageTarget(
|
|
40
|
+
target,
|
|
41
|
+
damage or self:calculateDamage(caster),
|
|
42
|
+
nil,
|
|
43
|
+
nil,
|
|
44
|
+
self:resolveCurrentAbilityDependentValue(parameters and parameters.attackType),
|
|
45
|
+
parameters and parameters.damageType,
|
|
46
|
+
parameters and parameters.weaponType,
|
|
47
|
+
self:resolveCurrentAbilityDependentValue(parameters and parameters.metadata)
|
|
48
|
+
)
|
|
49
|
+
end
|
|
37
50
|
____exports.DamageSelfAbilityBehavior = __TS__Class()
|
|
38
51
|
local DamageSelfAbilityBehavior = ____exports.DamageSelfAbilityBehavior
|
|
39
52
|
DamageSelfAbilityBehavior.name = "DamageSelfAbilityBehavior"
|
|
@@ -42,16 +55,7 @@ function DamageSelfAbilityBehavior.prototype.____constructor(self, ability, dama
|
|
|
42
55
|
DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
43
56
|
end
|
|
44
57
|
function DamageSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
45
|
-
|
|
46
|
-
caster:damageTarget(
|
|
47
|
-
caster,
|
|
48
|
-
self:calculateDamage(caster),
|
|
49
|
-
nil,
|
|
50
|
-
nil,
|
|
51
|
-
parameters and parameters.attackType,
|
|
52
|
-
parameters and parameters.damageType,
|
|
53
|
-
parameters and parameters.weaponType
|
|
54
|
-
)
|
|
58
|
+
self:damageTarget(caster, caster)
|
|
55
59
|
end
|
|
56
60
|
____exports.DamageTargetAbilityBehavior = __TS__Class()
|
|
57
61
|
local DamageTargetAbilityBehavior = ____exports.DamageTargetAbilityBehavior
|
|
@@ -61,16 +65,7 @@ function DamageTargetAbilityBehavior.prototype.____constructor(self, ability, da
|
|
|
61
65
|
DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
62
66
|
end
|
|
63
67
|
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
|
-
)
|
|
68
|
+
self:damageTarget(caster, target)
|
|
74
69
|
end
|
|
75
70
|
local DamageAreaAbilityBehavior = __TS__Class()
|
|
76
71
|
DamageAreaAbilityBehavior.name = "DamageAreaAbilityBehavior"
|
|
@@ -93,15 +88,7 @@ function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
|
|
|
93
88
|
damage = maximumDamage / #targets
|
|
94
89
|
end
|
|
95
90
|
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
|
-
)
|
|
91
|
+
self:damageTarget(caster, target, damage)
|
|
105
92
|
end
|
|
106
93
|
end
|
|
107
94
|
____exports.DamageSelfAreaAbilityBehavior = __TS__Class()
|
|
@@ -10,6 +10,9 @@ local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTE
|
|
|
10
10
|
local ____math = require("math")
|
|
11
11
|
local max = ____math.max
|
|
12
12
|
local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_FLOAT
|
|
13
|
+
local ____sound = require("core.types.sound")
|
|
14
|
+
local Sound3D = ____sound.Sound3D
|
|
15
|
+
local SoundSettings = ____sound.SoundSettings
|
|
13
16
|
____exports.EmulateImpactAbilityBehavior = __TS__Class()
|
|
14
17
|
local EmulateImpactAbilityBehavior = ____exports.EmulateImpactAbilityBehavior
|
|
15
18
|
EmulateImpactAbilityBehavior.name = "EmulateImpactAbilityBehavior"
|
|
@@ -23,6 +26,10 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
|
23
26
|
caster.mana = caster.mana - manaCost
|
|
24
27
|
self.ability.cooldownRemaining = max(cooldown, MINIMUM_POSITIVE_NORMALIZED_FLOAT)
|
|
25
28
|
self:flashCasterEffect(caster)
|
|
29
|
+
local soundPresetId = self.ability:getField(ABILITY_SF_EFFECT_SOUND)
|
|
30
|
+
if soundPresetId ~= "" then
|
|
31
|
+
Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
|
|
32
|
+
end
|
|
26
33
|
AbilityBehavior:forAll(self.ability, "onImpact", caster)
|
|
27
34
|
end
|
|
28
35
|
return ____exports
|
|
@@ -29,7 +29,10 @@ export declare abstract class AbilityBehavior<Parameters extends {
|
|
|
29
29
|
protected flashTargetEffect(widget: Widget, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
|
|
30
30
|
protected flashAreaEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
|
|
31
31
|
protected flashEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
|
|
32
|
-
protected flashSpecialEffect(...args: [
|
|
32
|
+
protected flashSpecialEffect(...args: [
|
|
33
|
+
...pointOrWidget: [x: number, y: number] | [widget: Widget],
|
|
34
|
+
...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]
|
|
35
|
+
]): void;
|
|
33
36
|
private static MissileLaunchConfig;
|
|
34
37
|
private get missileLaunchConfig();
|
|
35
38
|
protected onCreate(): void;
|
|
@@ -148,13 +148,14 @@ function AbilityBehavior.prototype.flashEffect(self, x, y, ...)
|
|
|
148
148
|
...
|
|
149
149
|
)
|
|
150
150
|
end
|
|
151
|
-
function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget,
|
|
151
|
+
function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrParametersOrDuration, durationOrParameters, parameters)
|
|
152
152
|
if type(xOrWidget) == "number" then
|
|
153
153
|
Effect:flash(
|
|
154
154
|
SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.ability, 0),
|
|
155
155
|
xOrWidget,
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
yOrParametersOrDuration,
|
|
157
|
+
durationOrParameters,
|
|
158
|
+
parameters
|
|
158
159
|
)
|
|
159
160
|
else
|
|
160
161
|
local attachmentPoint = SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD:getValue(self.ability)
|
|
@@ -162,7 +163,8 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrDurati
|
|
|
162
163
|
SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.ability, 0),
|
|
163
164
|
xOrWidget,
|
|
164
165
|
attachmentPoint ~= "" and attachmentPoint or "origin",
|
|
165
|
-
|
|
166
|
+
yOrParametersOrDuration,
|
|
167
|
+
durationOrParameters
|
|
166
168
|
)
|
|
167
169
|
end
|
|
168
170
|
end
|
|
@@ -5,6 +5,7 @@ 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
10
|
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
10
11
|
declare const enum ItemPropertyKey {
|
|
@@ -17,7 +18,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
17
18
|
constructor(handle: jitem);
|
|
18
19
|
protected onDestroy(): HandleDestructor;
|
|
19
20
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
|
20
|
-
get typeId():
|
|
21
|
+
get typeId(): ItemTypeId;
|
|
21
22
|
set skinId(v: number);
|
|
22
23
|
get skinId(): number;
|
|
23
24
|
set name(v: string);
|
|
@@ -8,6 +8,6 @@ local DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_NORMAL_AB
|
|
|
8
8
|
-- @internal For use by internal systems only.
|
|
9
9
|
____exports.getAbilityDuration = function(ability, target)
|
|
10
10
|
local level = ability.level
|
|
11
|
-
return target ~= nil and target:hasClassification(UnitClassification.RESISTANT) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
11
|
+
return target ~= nil and (target.isHero or target:getField(UNIT_IF_LEVEL) >= 6 or target:hasClassification(UnitClassification.RESISTANT)) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
12
12
|
end
|
|
13
13
|
return ____exports
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Widget } from "../../core/types/widget";
|
|
3
|
-
|
|
4
|
-
export declare namespace AttackType {
|
|
5
|
-
const SPELL: jattacktype;
|
|
6
|
-
const NORMAL: jattacktype;
|
|
7
|
-
const PIERCE: jattacktype;
|
|
8
|
-
const SIEGE: jattacktype;
|
|
9
|
-
const MAGIC: jattacktype;
|
|
10
|
-
const CHAOS: jattacktype;
|
|
11
|
-
const HERO: jattacktype;
|
|
12
|
-
}
|
|
3
|
+
import { AttackType } from "../object-data/auxiliary/attack-type";
|
|
13
4
|
export type DamageType = jdamagetype;
|
|
14
5
|
export declare namespace DamageType {
|
|
15
6
|
const UNKNOWN: jdamagetype;
|
|
@@ -64,6 +55,6 @@ export declare namespace WeaponType {
|
|
|
64
55
|
}
|
|
65
56
|
declare module "./unit" {
|
|
66
57
|
interface Unit {
|
|
67
|
-
damageTarget(target: Widget, amount: number, attack?: boolean, ranged?: boolean, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType): boolean;
|
|
58
|
+
damageTarget(target: Widget, amount: number, attack?: boolean, ranged?: boolean, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType, metadata?: unknown): boolean;
|
|
68
59
|
}
|
|
69
60
|
}
|
|
@@ -7,21 +7,14 @@ local ____player = require("core.types.player")
|
|
|
7
7
|
local Player = ____player.Player
|
|
8
8
|
local ____dummy = require("objutil.dummy")
|
|
9
9
|
local dummyUnitId = ____dummy.dummyUnitId
|
|
10
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
11
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
12
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
13
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
10
14
|
local createUnit = CreateUnit
|
|
11
15
|
local getOwningPlayer = GetOwningPlayer
|
|
12
16
|
local showUnit = ShowUnit
|
|
13
17
|
local unitDamageTarget = UnitDamageTarget
|
|
14
|
-
____exports.AttackType = {}
|
|
15
|
-
local AttackType = ____exports.AttackType
|
|
16
|
-
do
|
|
17
|
-
AttackType.SPELL = ATTACK_TYPE_NORMAL
|
|
18
|
-
AttackType.NORMAL = ATTACK_TYPE_MELEE
|
|
19
|
-
AttackType.PIERCE = ATTACK_TYPE_PIERCE
|
|
20
|
-
AttackType.SIEGE = ATTACK_TYPE_SIEGE
|
|
21
|
-
AttackType.MAGIC = ATTACK_TYPE_MAGIC
|
|
22
|
-
AttackType.CHAOS = ATTACK_TYPE_CHAOS
|
|
23
|
-
AttackType.HERO = ATTACK_TYPE_HERO
|
|
24
|
-
end
|
|
25
18
|
____exports.DamageType = {}
|
|
26
19
|
local DamageType = ____exports.DamageType
|
|
27
20
|
do
|
|
@@ -88,7 +81,7 @@ for ____, player in ipairs(Player.all) do
|
|
|
88
81
|
showUnit(dummy, false)
|
|
89
82
|
dummies[player] = dummy
|
|
90
83
|
end
|
|
91
|
-
Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, attackType, damageType, weaponType)
|
|
84
|
+
Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, attackType, damageType, weaponType, metadata)
|
|
92
85
|
if attack == nil then
|
|
93
86
|
attack = false
|
|
94
87
|
end
|
|
@@ -96,7 +89,7 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
|
|
|
96
89
|
ranged = false
|
|
97
90
|
end
|
|
98
91
|
if attackType == nil then
|
|
99
|
-
attackType =
|
|
92
|
+
attackType = 0
|
|
100
93
|
end
|
|
101
94
|
if damageType == nil then
|
|
102
95
|
damageType = ____exports.DamageType.MAGIC
|
|
@@ -109,13 +102,16 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
|
|
|
109
102
|
if not getOwningPlayer(handle) then
|
|
110
103
|
handle = dummies[__TS__InstanceOf(target, Unit) and target.owner or (self._owner or Player.neutralAggressive)]
|
|
111
104
|
end
|
|
105
|
+
if __TS__InstanceOf(target, Unit) then
|
|
106
|
+
damageMetadataByTarget[target] = metadata
|
|
107
|
+
end
|
|
112
108
|
return unitDamageTarget(
|
|
113
109
|
handle,
|
|
114
110
|
targetHandle,
|
|
115
111
|
amount,
|
|
116
112
|
attack,
|
|
117
113
|
ranged,
|
|
118
|
-
attackType,
|
|
114
|
+
attackTypeToNative(attackType),
|
|
119
115
|
damageType,
|
|
120
116
|
weaponType
|
|
121
117
|
)
|
|
@@ -6,7 +6,6 @@ local ____exports = {}
|
|
|
6
6
|
local ____unit = require("engine.internal.unit")
|
|
7
7
|
local Unit = ____unit.Unit
|
|
8
8
|
local ____unit_2Bdamage = require("engine.internal.unit+damage")
|
|
9
|
-
local AttackType = ____unit_2Bdamage.AttackType
|
|
10
9
|
local DamageType = ____unit_2Bdamage.DamageType
|
|
11
10
|
local ____event = require("event")
|
|
12
11
|
local Event = ____event.Event
|
|
@@ -33,7 +32,7 @@ local spellStealEventStack = {}
|
|
|
33
32
|
Unit.onDamaging:addListener(function(source, target, event)
|
|
34
33
|
if event.amount == 0 and source ~= nil then
|
|
35
34
|
local count = countByUnit[source] or 0
|
|
36
|
-
if count > 0 and event.attackType ==
|
|
35
|
+
if count > 0 and event.attackType == 0 then
|
|
37
36
|
if event.damageType == DamageType.UNKNOWN then
|
|
38
37
|
spellStealEventStack[#spellStealEventStack + 1] = {
|
|
39
38
|
sourceBuffIds = source.buffIds,
|
|
@@ -11,6 +11,9 @@ import { Ability, UnitAbility } from "./ability";
|
|
|
11
11
|
import { Widget } from "../../core/types/widget";
|
|
12
12
|
import type { UnitTypeId } from "../object-data/entry/unit-type";
|
|
13
13
|
import { CombatClassification, CombatClassifications } from "../object-data/auxiliary/combat-classification";
|
|
14
|
+
import { MovementType } from "../object-data/auxiliary/movement-type";
|
|
15
|
+
import { UnitAttribute } from "../object-data/auxiliary/unit-attribute";
|
|
16
|
+
import { AttackType } from "../object-data/auxiliary/attack-type";
|
|
14
17
|
export type UnitClassification = junittype;
|
|
15
18
|
export declare namespace UnitClassification {
|
|
16
19
|
const STRUCTURE: junittype;
|
|
@@ -38,11 +41,13 @@ type AbilityDispatcherTable<T extends any[] = []> = {
|
|
|
38
41
|
type AbilityEventDispatcher<T extends any[] = []> = Event<[Unit, Ability, ...T]> & AbilityDispatcherTable<T>;
|
|
39
42
|
export interface DamagingEvent {
|
|
40
43
|
amount: number;
|
|
41
|
-
attackType:
|
|
44
|
+
attackType: AttackType;
|
|
42
45
|
damageType: jdamagetype;
|
|
43
46
|
weaponType: jweapontype;
|
|
47
|
+
metadata: unknown;
|
|
44
48
|
readonly isAttack: boolean;
|
|
45
49
|
readonly originalAmount: number;
|
|
50
|
+
readonly originalMetadata: unknown;
|
|
46
51
|
}
|
|
47
52
|
export type DamageEvent = DamagingEvent & {
|
|
48
53
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
@@ -161,6 +166,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
161
166
|
set level(v: number);
|
|
162
167
|
get xp(): number;
|
|
163
168
|
set xp(v: number);
|
|
169
|
+
get primaryAttribute(): UnitAttribute;
|
|
170
|
+
set primaryAttribute(primaryAttribute: UnitAttribute);
|
|
164
171
|
get strengthBase(): number;
|
|
165
172
|
set strengthBase(strengthBase: number);
|
|
166
173
|
get strengthBonus(): number;
|
|
@@ -235,6 +242,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
235
242
|
set timeScale(v: number);
|
|
236
243
|
get collisionSize(): number;
|
|
237
244
|
get pathingCollisionRange(): number;
|
|
245
|
+
get movementType(): MovementType;
|
|
246
|
+
set movementType(movementType: MovementType);
|
|
238
247
|
set pathing(v: boolean);
|
|
239
248
|
isSelected(player: Player): boolean;
|
|
240
249
|
explode(): void;
|
package/engine/internal/unit.lua
CHANGED
|
@@ -53,6 +53,11 @@ local ____math = require("math")
|
|
|
53
53
|
local min = ____math.min
|
|
54
54
|
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
55
|
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
|
+
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
56
61
|
local match = string.match
|
|
57
62
|
local ____tostring = _G.tostring
|
|
58
63
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -81,7 +86,6 @@ local getHandleId = GetHandleId
|
|
|
81
86
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
82
87
|
local createUnit = CreateUnit
|
|
83
88
|
local killUnit = KillUnit
|
|
84
|
-
local setUnitExploded = SetUnitExploded
|
|
85
89
|
local removeUnit = RemoveUnit
|
|
86
90
|
local getUnitTypeId = GetUnitTypeId
|
|
87
91
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -97,8 +101,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
97
101
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
98
102
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
99
103
|
local isUnitInRange = IsUnitInRange
|
|
100
|
-
local setResourceAmount = SetResourceAmount
|
|
101
|
-
local getResourceAmount = GetResourceAmount
|
|
102
104
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
103
105
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
104
106
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -129,8 +131,6 @@ local isUnitType = IsUnitType
|
|
|
129
131
|
local isUnitAlly = IsUnitAlly
|
|
130
132
|
local isUnitEnemy = IsUnitEnemy
|
|
131
133
|
local getOwningPlayer = GetOwningPlayer
|
|
132
|
-
local setUnitColor = SetUnitColor
|
|
133
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
134
134
|
____exports.UnitClassification = {}
|
|
135
135
|
local UnitClassification = ____exports.UnitClassification
|
|
136
136
|
do
|
|
@@ -358,7 +358,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
358
358
|
rawset(self, 1 + i, (select(i, ...)))
|
|
359
359
|
end
|
|
360
360
|
end
|
|
361
|
-
local damageSetters = {
|
|
361
|
+
local damageSetters = {
|
|
362
|
+
amount = BlzSetEventDamage,
|
|
363
|
+
attackType = function(attackType)
|
|
364
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
365
|
+
end,
|
|
366
|
+
damageType = BlzSetEventDamageType,
|
|
367
|
+
weaponType = BlzSetEventWeaponType
|
|
368
|
+
}
|
|
362
369
|
local jlimitopByOperator = {
|
|
363
370
|
[0] = LESS_THAN_OR_EQUAL,
|
|
364
371
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -640,7 +647,8 @@ local function delayHealthChecksCallback(unit)
|
|
|
640
647
|
end
|
|
641
648
|
end
|
|
642
649
|
local nextSyncId = 1
|
|
643
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
650
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
651
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
644
652
|
____exports.Unit = __TS__Class()
|
|
645
653
|
local Unit = ____exports.Unit
|
|
646
654
|
Unit.name = "Unit"
|
|
@@ -815,7 +823,7 @@ function Unit.prototype.isSelected(self, player)
|
|
|
815
823
|
return IsUnitSelected(self.handle, player.handle)
|
|
816
824
|
end
|
|
817
825
|
function Unit.prototype.explode(self)
|
|
818
|
-
|
|
826
|
+
SetUnitExploded(self.handle, true)
|
|
819
827
|
killUnit(self.handle)
|
|
820
828
|
end
|
|
821
829
|
function Unit.prototype.kill(self)
|
|
@@ -1292,6 +1300,19 @@ __TS__SetDescriptor(
|
|
|
1292
1300
|
},
|
|
1293
1301
|
true
|
|
1294
1302
|
)
|
|
1303
|
+
__TS__SetDescriptor(
|
|
1304
|
+
Unit.prototype,
|
|
1305
|
+
"primaryAttribute",
|
|
1306
|
+
{
|
|
1307
|
+
get = function(self)
|
|
1308
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1309
|
+
end,
|
|
1310
|
+
set = function(self, primaryAttribute)
|
|
1311
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1312
|
+
end
|
|
1313
|
+
},
|
|
1314
|
+
true
|
|
1315
|
+
)
|
|
1295
1316
|
__TS__SetDescriptor(
|
|
1296
1317
|
Unit.prototype,
|
|
1297
1318
|
"strengthBase",
|
|
@@ -1416,7 +1437,7 @@ __TS__SetDescriptor(
|
|
|
1416
1437
|
return not self[106]
|
|
1417
1438
|
end,
|
|
1418
1439
|
set = function(self, isTeamGlowVisible)
|
|
1419
|
-
|
|
1440
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1420
1441
|
local ____temp_6
|
|
1421
1442
|
if not isTeamGlowVisible then
|
|
1422
1443
|
____temp_6 = true
|
|
@@ -1432,9 +1453,9 @@ __TS__SetDescriptor(
|
|
|
1432
1453
|
Unit.prototype,
|
|
1433
1454
|
"color",
|
|
1434
1455
|
{set = function(self, color)
|
|
1435
|
-
|
|
1456
|
+
SetUnitColor(self.handle, color.handle)
|
|
1436
1457
|
if self[106] then
|
|
1437
|
-
|
|
1458
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1438
1459
|
end
|
|
1439
1460
|
end},
|
|
1440
1461
|
true
|
|
@@ -1702,10 +1723,10 @@ __TS__SetDescriptor(
|
|
|
1702
1723
|
"gold",
|
|
1703
1724
|
{
|
|
1704
1725
|
get = function(self)
|
|
1705
|
-
return
|
|
1726
|
+
return GetResourceAmount(self.handle)
|
|
1706
1727
|
end,
|
|
1707
1728
|
set = function(self, gold)
|
|
1708
|
-
|
|
1729
|
+
SetResourceAmount(self.handle, gold)
|
|
1709
1730
|
end
|
|
1710
1731
|
},
|
|
1711
1732
|
true
|
|
@@ -1833,6 +1854,19 @@ __TS__SetDescriptor(
|
|
|
1833
1854
|
end},
|
|
1834
1855
|
true
|
|
1835
1856
|
)
|
|
1857
|
+
__TS__SetDescriptor(
|
|
1858
|
+
Unit.prototype,
|
|
1859
|
+
"movementType",
|
|
1860
|
+
{
|
|
1861
|
+
get = function(self)
|
|
1862
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1863
|
+
end,
|
|
1864
|
+
set = function(self, movementType)
|
|
1865
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1866
|
+
end
|
|
1867
|
+
},
|
|
1868
|
+
true
|
|
1869
|
+
)
|
|
1836
1870
|
__TS__SetDescriptor(
|
|
1837
1871
|
Unit.prototype,
|
|
1838
1872
|
"pathing",
|
|
@@ -2375,13 +2409,18 @@ Unit.onDamaging = (function()
|
|
|
2375
2409
|
if source and source.typeId == dummyUnitId then
|
|
2376
2410
|
source = nil
|
|
2377
2411
|
end
|
|
2378
|
-
local target = BlzGetEventDamageTarget()
|
|
2412
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2413
|
+
local metadata = damageMetadataByTarget[target]
|
|
2414
|
+
damageMetadataByTarget[target] = nil
|
|
2379
2415
|
local data = {
|
|
2380
2416
|
amount = GetEventDamage(),
|
|
2381
|
-
attackType = BlzGetEventAttackType(),
|
|
2417
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2382
2418
|
damageType = BlzGetEventDamageType(),
|
|
2383
2419
|
weaponType = BlzGetEventWeaponType(),
|
|
2384
|
-
|
|
2420
|
+
metadata = metadata,
|
|
2421
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2422
|
+
originalAmount = GetEventDamage(),
|
|
2423
|
+
originalMetadata = metadata
|
|
2385
2424
|
}
|
|
2386
2425
|
if data.isAttack and source then
|
|
2387
2426
|
local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
|
|
@@ -2395,18 +2434,22 @@ Unit.onDamaging = (function()
|
|
|
2395
2434
|
invoke(
|
|
2396
2435
|
event,
|
|
2397
2436
|
source,
|
|
2398
|
-
|
|
2437
|
+
target,
|
|
2399
2438
|
setmetatable(
|
|
2400
2439
|
{},
|
|
2401
2440
|
{
|
|
2402
2441
|
__index = data,
|
|
2403
2442
|
__newindex = function(self, key, value)
|
|
2404
|
-
damageSetters[key]
|
|
2443
|
+
local damageSetter = damageSetters[key]
|
|
2444
|
+
if damageSetter ~= nil then
|
|
2445
|
+
damageSetter(value)
|
|
2446
|
+
end
|
|
2405
2447
|
data[key] = value
|
|
2406
2448
|
end
|
|
2407
2449
|
}
|
|
2408
2450
|
)
|
|
2409
2451
|
)
|
|
2452
|
+
damagingEventByTarget[target] = data
|
|
2410
2453
|
return
|
|
2411
2454
|
end
|
|
2412
2455
|
BlzSetEventDamage(0)
|
|
@@ -2414,7 +2457,7 @@ Unit.onDamaging = (function()
|
|
|
2414
2457
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2415
2458
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2416
2459
|
local sourceOwner = source.owner.handle
|
|
2417
|
-
local targetOwner =
|
|
2460
|
+
local targetOwner = target.owner.handle
|
|
2418
2461
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2419
2462
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2420
2463
|
Timer:run(function()
|
|
@@ -2430,23 +2473,19 @@ Unit.onDamaging = (function()
|
|
|
2430
2473
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2431
2474
|
local condition = ____value[1]
|
|
2432
2475
|
local action = ____value[2]
|
|
2433
|
-
if condition(
|
|
2434
|
-
source,
|
|
2435
|
-
____exports.Unit:of(target),
|
|
2436
|
-
data
|
|
2437
|
-
) then
|
|
2476
|
+
if condition(source, target, data) then
|
|
2438
2477
|
action(
|
|
2439
2478
|
source,
|
|
2440
|
-
|
|
2479
|
+
target,
|
|
2441
2480
|
setmetatable(
|
|
2442
2481
|
{fire = function()
|
|
2443
2482
|
UnitDamageTarget(
|
|
2444
2483
|
source.handle,
|
|
2445
|
-
target,
|
|
2484
|
+
target.handle,
|
|
2446
2485
|
data.amount,
|
|
2447
2486
|
true,
|
|
2448
2487
|
true,
|
|
2449
|
-
data.attackType,
|
|
2488
|
+
attackTypeToNative(data.attackType),
|
|
2450
2489
|
data.damageType,
|
|
2451
2490
|
data.weaponType
|
|
2452
2491
|
)
|
|
@@ -2473,13 +2512,18 @@ Unit.onDamage = __TS__New(
|
|
|
2473
2512
|
if source and source.typeId == dummyUnitId then
|
|
2474
2513
|
source = nil
|
|
2475
2514
|
end
|
|
2515
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2516
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2517
|
+
damagingEventByTarget[target] = nil
|
|
2476
2518
|
local data = {
|
|
2477
2519
|
amount = GetEventDamage(),
|
|
2478
|
-
attackType = BlzGetEventAttackType(),
|
|
2520
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2479
2521
|
damageType = BlzGetEventDamageType(),
|
|
2480
2522
|
weaponType = BlzGetEventWeaponType(),
|
|
2523
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2481
2524
|
isAttack = BlzGetEventIsAttack(),
|
|
2482
|
-
originalAmount = GetEventDamage(),
|
|
2525
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2526
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2483
2527
|
preventDeath = damageEventPreventDeath
|
|
2484
2528
|
}
|
|
2485
2529
|
local evData = setmetatable(
|
|
@@ -2492,7 +2536,6 @@ Unit.onDamage = __TS__New(
|
|
|
2492
2536
|
end
|
|
2493
2537
|
}
|
|
2494
2538
|
)
|
|
2495
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2496
2539
|
invoke(event, source, target, evData)
|
|
2497
2540
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2498
2541
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
import { ModelNodeName } from "./model-node-name";
|
|
3
3
|
import { ModelNodeQualifier } from "./model-node-qualifier";
|
|
4
4
|
import { Optional } from "../../../utility/types";
|
|
5
|
+
import { EffectParameters } from "../../../core/types/effect";
|
|
5
6
|
export type AttachmentPreset = {
|
|
6
7
|
modelPath: string;
|
|
7
8
|
nodeName: ModelNodeName;
|
|
8
9
|
nodeQualifiers: ModelNodeQualifier[];
|
|
9
10
|
};
|
|
10
|
-
export type
|
|
11
|
-
|
|
11
|
+
export type EffectPresetWithParameters = AttachmentPreset & {
|
|
12
|
+
parameters?: EffectParameters;
|
|
13
|
+
};
|
|
14
|
+
export type AttachmentPresetInput<T extends AttachmentPreset = AttachmentPreset> = Optional<T, "nodeName" | "nodeQualifiers"> | string;
|
|
15
|
+
export type EffectPresetWithParametersInput = AttachmentPresetInput<EffectPresetWithParameters>;
|
|
16
|
+
export declare const toEffectPreset: (effectPresetInput: EffectPresetWithParametersInput) => EffectPresetWithParameters;
|
|
12
17
|
export declare const extractAttachmentPresetInputModelPath: (attachmentPresetInput: AttachmentPresetInput | undefined) => string;
|
|
13
18
|
export declare const extractAttachmentPresetInputNodeFQN: (attachmentPresetInput: AttachmentPresetInput | undefined) => string;
|
|
14
19
|
export declare const splitAttachmentNodeFQN: (attachmentNodeFQN: string) => LuaMultiReturn<[attachmentNodeName: ModelNodeName, attachmentNodeQualifiers: ModelNodeQualifier[]]>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArrayJoin = ____lualib.__TS__ArrayJoin
|
|
2
3
|
local __TS__StringSplit = ____lualib.__TS__StringSplit
|
|
3
4
|
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
|
|
4
5
|
local ____exports = {}
|
|
5
|
-
____exports.
|
|
6
|
-
return type(
|
|
6
|
+
____exports.toEffectPreset = function(effectPresetInput)
|
|
7
|
+
return type(effectPresetInput) == "string" and ({modelPath = effectPresetInput, nodeName = "origin", nodeQualifiers = {}}) or ({modelPath = effectPresetInput.modelPath, nodeName = effectPresetInput.nodeName or "origin", nodeQualifiers = effectPresetInput.nodeQualifiers or ({}), parameters = effectPresetInput.parameters})
|
|
7
8
|
end
|
|
8
9
|
____exports.extractAttachmentPresetInputModelPath = function(attachmentPresetInput)
|
|
9
10
|
return type(attachmentPresetInput) == "string" and attachmentPresetInput or (attachmentPresetInput and attachmentPresetInput.modelPath or "")
|
|
@@ -12,7 +13,7 @@ ____exports.extractAttachmentPresetInputNodeFQN = function(attachmentPresetInput
|
|
|
12
13
|
if type(attachmentPresetInput) == "string" or attachmentPresetInput == nil then
|
|
13
14
|
return ""
|
|
14
15
|
end
|
|
15
|
-
return
|
|
16
|
+
return __TS__ArrayJoin(
|
|
16
17
|
{
|
|
17
18
|
attachmentPresetInput.nodeName,
|
|
18
19
|
table.unpack(attachmentPresetInput.nodeQualifiers or ({}))
|