warscript 0.0.1-dev.148c073 → 0.0.1-dev.16a69f9
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/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 +7 -8
- package/core/types/timer.lua +18 -21
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- 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.d.ts +4 -1
- package/engine/behaviour/ability.lua +14 -21
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +24 -0
- package/engine/behaviour/unit.lua +158 -4
- package/engine/buff.d.ts +2 -1
- package/engine/buff.lua +6 -3
- 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 +35 -0
- package/engine/internal/unit/ability.lua +62 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -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-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +21 -3
- package/engine/internal/unit.lua +178 -37
- 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/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.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 +50 -3
- package/engine/object-field/unit.lua +186 -7
- package/engine/object-field.d.ts +15 -4
- package/engine/object-field.lua +184 -90
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/fields/unit.d.ts +3 -0
- package/engine/standard/fields/unit.lua +5 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +175 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -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 +4 -0
- package/utility/lua-maps.lua +20 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
|
@@ -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,
|
|
@@ -44,7 +44,7 @@ local function timerCallback(source, target)
|
|
|
44
44
|
Event.invoke(autoAttackFinishEvent, source, target)
|
|
45
45
|
end
|
|
46
46
|
Unit.autoAttackStartEvent:addListener(function(source, target)
|
|
47
|
-
local attackPoint = source.
|
|
47
|
+
local attackPoint = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
48
48
|
local timer = Timer:simple(attackPoint, timerCallback, source, target)
|
|
49
49
|
eventTimerByUnit[source] = timer
|
|
50
50
|
end)
|
|
@@ -11,6 +11,10 @@ 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";
|
|
17
|
+
import { AttributesHolder } from "../../attributes";
|
|
14
18
|
export type UnitClassification = junittype;
|
|
15
19
|
export declare namespace UnitClassification {
|
|
16
20
|
const STRUCTURE: junittype;
|
|
@@ -19,6 +23,7 @@ export declare namespace UnitClassification {
|
|
|
19
23
|
const GROUND: junittype;
|
|
20
24
|
const SUMMONED: junittype;
|
|
21
25
|
const MECHANICAL: junittype;
|
|
26
|
+
const WORKER: junittype;
|
|
22
27
|
const ANCIENT: junittype;
|
|
23
28
|
const SUICIDAL: junittype;
|
|
24
29
|
const TAUREN: junittype;
|
|
@@ -36,15 +41,18 @@ type AbilityDispatcherTable<T extends any[] = []> = {
|
|
|
36
41
|
readonly [id: number]: Event<[Unit, Ability, ...T]>;
|
|
37
42
|
};
|
|
38
43
|
type AbilityEventDispatcher<T extends any[] = []> = Event<[Unit, Ability, ...T]> & AbilityDispatcherTable<T>;
|
|
39
|
-
export interface DamagingEvent {
|
|
44
|
+
export interface DamagingEvent extends AttributesHolder {
|
|
40
45
|
amount: number;
|
|
41
|
-
attackType:
|
|
46
|
+
attackType: AttackType;
|
|
42
47
|
damageType: jdamagetype;
|
|
43
48
|
weaponType: jweapontype;
|
|
49
|
+
metadata: unknown;
|
|
44
50
|
readonly isAttack: boolean;
|
|
45
51
|
readonly originalAmount: number;
|
|
52
|
+
readonly originalMetadata: unknown;
|
|
53
|
+
preventRetaliation(this: DamagingEvent): void;
|
|
46
54
|
}
|
|
47
|
-
export type DamageEvent = DamagingEvent & {
|
|
55
|
+
export type DamageEvent = Omit<DamagingEvent, "preventRetaliation"> & {
|
|
48
56
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
49
57
|
};
|
|
50
58
|
export type AttackDamageEvent = DamagingEvent & {
|
|
@@ -76,6 +84,8 @@ export declare class UnitWeapon {
|
|
|
76
84
|
set cooldown(cooldown: number);
|
|
77
85
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
|
78
86
|
set damage([minimumDamage, maximumDamage]: [number, number]);
|
|
87
|
+
get allowedTargetCombatClassifications(): CombatClassifications;
|
|
88
|
+
set allowedTargetCombatClassifications(allowedTargetCombatClassifications: CombatClassifications);
|
|
79
89
|
get damageBase(): number;
|
|
80
90
|
set damageBase(damageBase: number);
|
|
81
91
|
get damageDiceCount(): number;
|
|
@@ -157,10 +167,13 @@ export declare class Unit extends Handle<junit> {
|
|
|
157
167
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
158
168
|
get firstWeapon(): UnitWeapon;
|
|
159
169
|
get secondWeapon(): UnitWeapon;
|
|
170
|
+
chooseWeapon(target: Unit): UnitWeapon | undefined;
|
|
160
171
|
get level(): number;
|
|
161
172
|
set level(v: number);
|
|
162
173
|
get xp(): number;
|
|
163
174
|
set xp(v: number);
|
|
175
|
+
get primaryAttribute(): UnitAttribute;
|
|
176
|
+
set primaryAttribute(primaryAttribute: UnitAttribute);
|
|
164
177
|
get strengthBase(): number;
|
|
165
178
|
set strengthBase(strengthBase: number);
|
|
166
179
|
get strengthBonus(): number;
|
|
@@ -235,6 +248,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
235
248
|
set timeScale(v: number);
|
|
236
249
|
get collisionSize(): number;
|
|
237
250
|
get pathingCollisionRange(): number;
|
|
251
|
+
get movementType(): MovementType;
|
|
252
|
+
set movementType(movementType: MovementType);
|
|
238
253
|
set pathing(v: boolean);
|
|
239
254
|
isSelected(player: Player): boolean;
|
|
240
255
|
explode(): void;
|
|
@@ -263,6 +278,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
263
278
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
264
279
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
265
280
|
endAbilityCooldown(abilityId: number): void;
|
|
281
|
+
interruptMovement(): void;
|
|
266
282
|
interruptAttack(): void;
|
|
267
283
|
interruptCast(abilityId: number): void;
|
|
268
284
|
getDistanceTo(target: Unit | Vec2): number;
|
|
@@ -285,6 +301,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
285
301
|
get onUnitInRange(): Record<number, Event<[Unit]>>;
|
|
286
302
|
get onManaEqual(): Record<number, Event<[Unit, number]>>;
|
|
287
303
|
get manaEvent(): Record<Operator, Record<number, Event<[Unit]>>>;
|
|
304
|
+
get targetAcquiredEvent(): Event;
|
|
288
305
|
get onSelect(): Event;
|
|
289
306
|
get onDeselect(): Event;
|
|
290
307
|
get onImmediateOrder(): Event<[number]>;
|
|
@@ -338,6 +355,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
338
355
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
339
356
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
340
357
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
358
|
+
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
341
359
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
342
360
|
static get itemMoveOrderEvent(): Event<[
|
|
343
361
|
unit: Unit,
|
package/engine/internal/unit.lua
CHANGED
|
@@ -53,13 +53,17 @@ 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
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
56
63
|
local match = string.match
|
|
57
64
|
local ____tostring = _G.tostring
|
|
58
65
|
local setUnitAnimation = SetUnitAnimation
|
|
59
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
60
66
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
61
|
-
local resetUnitAnimation = ResetUnitAnimation
|
|
62
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
63
67
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
64
68
|
local getUnitRealField = BlzGetUnitRealField
|
|
65
69
|
local getHeroStr = GetHeroStr
|
|
@@ -81,7 +85,6 @@ local getHandleId = GetHandleId
|
|
|
81
85
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
82
86
|
local createUnit = CreateUnit
|
|
83
87
|
local killUnit = KillUnit
|
|
84
|
-
local setUnitExploded = SetUnitExploded
|
|
85
88
|
local removeUnit = RemoveUnit
|
|
86
89
|
local getUnitTypeId = GetUnitTypeId
|
|
87
90
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -97,8 +100,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
97
100
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
98
101
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
99
102
|
local isUnitInRange = IsUnitInRange
|
|
100
|
-
local setResourceAmount = SetResourceAmount
|
|
101
|
-
local getResourceAmount = GetResourceAmount
|
|
102
103
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
103
104
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
104
105
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -129,8 +130,6 @@ local isUnitType = IsUnitType
|
|
|
129
130
|
local isUnitAlly = IsUnitAlly
|
|
130
131
|
local isUnitEnemy = IsUnitEnemy
|
|
131
132
|
local getOwningPlayer = GetOwningPlayer
|
|
132
|
-
local setUnitColor = SetUnitColor
|
|
133
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
134
133
|
____exports.UnitClassification = {}
|
|
135
134
|
local UnitClassification = ____exports.UnitClassification
|
|
136
135
|
do
|
|
@@ -140,6 +139,7 @@ do
|
|
|
140
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
141
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
142
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
143
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
144
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
145
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -347,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
347
347
|
}
|
|
348
348
|
)
|
|
349
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
350
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
351
354
|
if self[0] ~= nil then
|
|
352
355
|
return
|
|
@@ -358,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
358
361
|
rawset(self, 1 + i, (select(i, ...)))
|
|
359
362
|
end
|
|
360
363
|
end
|
|
361
|
-
local damageSetters = {
|
|
364
|
+
local damageSetters = {
|
|
365
|
+
amount = BlzSetEventDamage,
|
|
366
|
+
attackType = function(attackType)
|
|
367
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
368
|
+
end,
|
|
369
|
+
damageType = BlzSetEventDamageType,
|
|
370
|
+
weaponType = BlzSetEventWeaponType
|
|
371
|
+
}
|
|
362
372
|
local jlimitopByOperator = {
|
|
363
373
|
[0] = LESS_THAN_OR_EQUAL,
|
|
364
374
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -436,6 +446,19 @@ __TS__SetDescriptor(
|
|
|
436
446
|
},
|
|
437
447
|
true
|
|
438
448
|
)
|
|
449
|
+
__TS__SetDescriptor(
|
|
450
|
+
UnitWeapon.prototype,
|
|
451
|
+
"allowedTargetCombatClassifications",
|
|
452
|
+
{
|
|
453
|
+
get = function(self)
|
|
454
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
455
|
+
end,
|
|
456
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
457
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
458
|
+
end
|
|
459
|
+
},
|
|
460
|
+
true
|
|
461
|
+
)
|
|
439
462
|
__TS__SetDescriptor(
|
|
440
463
|
UnitWeapon.prototype,
|
|
441
464
|
"damageBase",
|
|
@@ -640,7 +663,8 @@ local function delayHealthChecksCallback(unit)
|
|
|
640
663
|
end
|
|
641
664
|
end
|
|
642
665
|
local nextSyncId = 1
|
|
643
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
666
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
667
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
644
668
|
____exports.Unit = __TS__Class()
|
|
645
669
|
local Unit = ____exports.Unit
|
|
646
670
|
Unit.name = "Unit"
|
|
@@ -793,16 +817,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
793
817
|
if type(animation) == "number" then
|
|
794
818
|
setUnitAnimationByIndex(self.handle, animation)
|
|
795
819
|
elseif rarity then
|
|
796
|
-
|
|
820
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
797
821
|
else
|
|
798
822
|
setUnitAnimation(self.handle, animation)
|
|
799
823
|
end
|
|
800
824
|
end
|
|
801
825
|
function Unit.prototype.resetAnimation(self)
|
|
802
|
-
|
|
826
|
+
ResetUnitAnimation(self.handle)
|
|
803
827
|
end
|
|
804
828
|
function Unit.prototype.queueAnimation(self, animation)
|
|
805
|
-
|
|
829
|
+
QueueUnitAnimation(self.handle, animation)
|
|
830
|
+
end
|
|
831
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
832
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
833
|
+
return self.firstWeapon
|
|
834
|
+
end
|
|
835
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
836
|
+
return self.secondWeapon
|
|
837
|
+
end
|
|
838
|
+
return nil
|
|
806
839
|
end
|
|
807
840
|
function Unit.prototype.delayHealthChecks(self)
|
|
808
841
|
self[103] = (self[103] or 0) + 1
|
|
@@ -815,7 +848,7 @@ function Unit.prototype.isSelected(self, player)
|
|
|
815
848
|
return IsUnitSelected(self.handle, player.handle)
|
|
816
849
|
end
|
|
817
850
|
function Unit.prototype.explode(self)
|
|
818
|
-
|
|
851
|
+
SetUnitExploded(self.handle, true)
|
|
819
852
|
killUnit(self.handle)
|
|
820
853
|
end
|
|
821
854
|
function Unit.prototype.kill(self)
|
|
@@ -934,6 +967,21 @@ end
|
|
|
934
967
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
935
968
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
936
969
|
end
|
|
970
|
+
function Unit.prototype.interruptMovement(self)
|
|
971
|
+
local handle = self.handle
|
|
972
|
+
unitDisableAbility(
|
|
973
|
+
handle,
|
|
974
|
+
fourCC("Amov"),
|
|
975
|
+
true,
|
|
976
|
+
false
|
|
977
|
+
)
|
|
978
|
+
unitDisableAbility(
|
|
979
|
+
handle,
|
|
980
|
+
fourCC("Amov"),
|
|
981
|
+
false,
|
|
982
|
+
false
|
|
983
|
+
)
|
|
984
|
+
end
|
|
937
985
|
function Unit.prototype.interruptAttack(self)
|
|
938
986
|
unitInterruptAttack(self.handle)
|
|
939
987
|
end
|
|
@@ -1292,6 +1340,19 @@ __TS__SetDescriptor(
|
|
|
1292
1340
|
},
|
|
1293
1341
|
true
|
|
1294
1342
|
)
|
|
1343
|
+
__TS__SetDescriptor(
|
|
1344
|
+
Unit.prototype,
|
|
1345
|
+
"primaryAttribute",
|
|
1346
|
+
{
|
|
1347
|
+
get = function(self)
|
|
1348
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1349
|
+
end,
|
|
1350
|
+
set = function(self, primaryAttribute)
|
|
1351
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1352
|
+
end
|
|
1353
|
+
},
|
|
1354
|
+
true
|
|
1355
|
+
)
|
|
1295
1356
|
__TS__SetDescriptor(
|
|
1296
1357
|
Unit.prototype,
|
|
1297
1358
|
"strengthBase",
|
|
@@ -1416,7 +1477,7 @@ __TS__SetDescriptor(
|
|
|
1416
1477
|
return not self[106]
|
|
1417
1478
|
end,
|
|
1418
1479
|
set = function(self, isTeamGlowVisible)
|
|
1419
|
-
|
|
1480
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1420
1481
|
local ____temp_6
|
|
1421
1482
|
if not isTeamGlowVisible then
|
|
1422
1483
|
____temp_6 = true
|
|
@@ -1432,9 +1493,9 @@ __TS__SetDescriptor(
|
|
|
1432
1493
|
Unit.prototype,
|
|
1433
1494
|
"color",
|
|
1434
1495
|
{set = function(self, color)
|
|
1435
|
-
|
|
1496
|
+
SetUnitColor(self.handle, color.handle)
|
|
1436
1497
|
if self[106] then
|
|
1437
|
-
|
|
1498
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1438
1499
|
end
|
|
1439
1500
|
end},
|
|
1440
1501
|
true
|
|
@@ -1702,10 +1763,10 @@ __TS__SetDescriptor(
|
|
|
1702
1763
|
"gold",
|
|
1703
1764
|
{
|
|
1704
1765
|
get = function(self)
|
|
1705
|
-
return
|
|
1766
|
+
return GetResourceAmount(self.handle)
|
|
1706
1767
|
end,
|
|
1707
1768
|
set = function(self, gold)
|
|
1708
|
-
|
|
1769
|
+
SetResourceAmount(self.handle, gold)
|
|
1709
1770
|
end
|
|
1710
1771
|
},
|
|
1711
1772
|
true
|
|
@@ -1833,6 +1894,19 @@ __TS__SetDescriptor(
|
|
|
1833
1894
|
end},
|
|
1834
1895
|
true
|
|
1835
1896
|
)
|
|
1897
|
+
__TS__SetDescriptor(
|
|
1898
|
+
Unit.prototype,
|
|
1899
|
+
"movementType",
|
|
1900
|
+
{
|
|
1901
|
+
get = function(self)
|
|
1902
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1903
|
+
end,
|
|
1904
|
+
set = function(self, movementType)
|
|
1905
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1906
|
+
end
|
|
1907
|
+
},
|
|
1908
|
+
true
|
|
1909
|
+
)
|
|
1836
1910
|
__TS__SetDescriptor(
|
|
1837
1911
|
Unit.prototype,
|
|
1838
1912
|
"pathing",
|
|
@@ -2014,6 +2088,14 @@ __TS__SetDescriptor(
|
|
|
2014
2088
|
end},
|
|
2015
2089
|
true
|
|
2016
2090
|
)
|
|
2091
|
+
__TS__SetDescriptor(
|
|
2092
|
+
Unit.prototype,
|
|
2093
|
+
"targetAcquiredEvent",
|
|
2094
|
+
{get = function(self)
|
|
2095
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2096
|
+
end},
|
|
2097
|
+
true
|
|
2098
|
+
)
|
|
2017
2099
|
__TS__SetDescriptor(
|
|
2018
2100
|
Unit.prototype,
|
|
2019
2101
|
"onSelect",
|
|
@@ -2375,13 +2457,19 @@ Unit.onDamaging = (function()
|
|
|
2375
2457
|
if source and source.typeId == dummyUnitId then
|
|
2376
2458
|
source = nil
|
|
2377
2459
|
end
|
|
2378
|
-
local target = BlzGetEventDamageTarget()
|
|
2460
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2461
|
+
local metadata = damageMetadataByTarget[target]
|
|
2462
|
+
damageMetadataByTarget[target] = nil
|
|
2379
2463
|
local data = {
|
|
2380
2464
|
amount = GetEventDamage(),
|
|
2381
|
-
attackType = BlzGetEventAttackType(),
|
|
2465
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2382
2466
|
damageType = BlzGetEventDamageType(),
|
|
2383
2467
|
weaponType = BlzGetEventWeaponType(),
|
|
2384
|
-
|
|
2468
|
+
metadata = metadata,
|
|
2469
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2470
|
+
originalAmount = GetEventDamage(),
|
|
2471
|
+
originalMetadata = metadata,
|
|
2472
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2385
2473
|
}
|
|
2386
2474
|
if data.isAttack and source then
|
|
2387
2475
|
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 +2483,36 @@ Unit.onDamaging = (function()
|
|
|
2395
2483
|
invoke(
|
|
2396
2484
|
event,
|
|
2397
2485
|
source,
|
|
2398
|
-
|
|
2486
|
+
target,
|
|
2399
2487
|
setmetatable(
|
|
2400
2488
|
{},
|
|
2401
2489
|
{
|
|
2402
2490
|
__index = data,
|
|
2403
2491
|
__newindex = function(self, key, value)
|
|
2404
|
-
damageSetters[key]
|
|
2492
|
+
local damageSetter = damageSetters[key]
|
|
2493
|
+
if damageSetter ~= nil then
|
|
2494
|
+
damageSetter(value)
|
|
2495
|
+
end
|
|
2405
2496
|
data[key] = value
|
|
2406
2497
|
end
|
|
2407
2498
|
}
|
|
2408
2499
|
)
|
|
2409
2500
|
)
|
|
2501
|
+
if data[0] and source then
|
|
2502
|
+
local sourceOwner = source.owner.handle
|
|
2503
|
+
data[1] = sourceOwner
|
|
2504
|
+
local targetOwner = target.owner.handle
|
|
2505
|
+
data[2] = targetOwner
|
|
2506
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2507
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2508
|
+
data[3] = true
|
|
2509
|
+
end
|
|
2510
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2511
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2512
|
+
data[4] = true
|
|
2513
|
+
end
|
|
2514
|
+
end
|
|
2515
|
+
damagingEventByTarget[target] = data
|
|
2410
2516
|
return
|
|
2411
2517
|
end
|
|
2412
2518
|
BlzSetEventDamage(0)
|
|
@@ -2414,7 +2520,7 @@ Unit.onDamaging = (function()
|
|
|
2414
2520
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2415
2521
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2416
2522
|
local sourceOwner = source.owner.handle
|
|
2417
|
-
local targetOwner =
|
|
2523
|
+
local targetOwner = target.owner.handle
|
|
2418
2524
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2419
2525
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2420
2526
|
Timer:run(function()
|
|
@@ -2430,23 +2536,19 @@ Unit.onDamaging = (function()
|
|
|
2430
2536
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2431
2537
|
local condition = ____value[1]
|
|
2432
2538
|
local action = ____value[2]
|
|
2433
|
-
if condition(
|
|
2434
|
-
source,
|
|
2435
|
-
____exports.Unit:of(target),
|
|
2436
|
-
data
|
|
2437
|
-
) then
|
|
2539
|
+
if condition(source, target, data) then
|
|
2438
2540
|
action(
|
|
2439
2541
|
source,
|
|
2440
|
-
|
|
2542
|
+
target,
|
|
2441
2543
|
setmetatable(
|
|
2442
2544
|
{fire = function()
|
|
2443
2545
|
UnitDamageTarget(
|
|
2444
2546
|
source.handle,
|
|
2445
|
-
target,
|
|
2547
|
+
target.handle,
|
|
2446
2548
|
data.amount,
|
|
2447
2549
|
true,
|
|
2448
2550
|
true,
|
|
2449
|
-
data.attackType,
|
|
2551
|
+
attackTypeToNative(data.attackType),
|
|
2450
2552
|
data.damageType,
|
|
2451
2553
|
data.weaponType
|
|
2452
2554
|
)
|
|
@@ -2473,26 +2575,50 @@ Unit.onDamage = __TS__New(
|
|
|
2473
2575
|
if source and source.typeId == dummyUnitId then
|
|
2474
2576
|
source = nil
|
|
2475
2577
|
end
|
|
2578
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2579
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2580
|
+
damagingEventByTarget[target] = nil
|
|
2476
2581
|
local data = {
|
|
2477
2582
|
amount = GetEventDamage(),
|
|
2478
|
-
attackType = BlzGetEventAttackType(),
|
|
2583
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2479
2584
|
damageType = BlzGetEventDamageType(),
|
|
2480
2585
|
weaponType = BlzGetEventWeaponType(),
|
|
2586
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2481
2587
|
isAttack = BlzGetEventIsAttack(),
|
|
2482
|
-
originalAmount = GetEventDamage(),
|
|
2588
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2589
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2483
2590
|
preventDeath = damageEventPreventDeath
|
|
2484
2591
|
}
|
|
2592
|
+
if damagingEvent then
|
|
2593
|
+
for key, value in pairs(damagingEvent) do
|
|
2594
|
+
if isAttribute(key) then
|
|
2595
|
+
data[key] = value
|
|
2596
|
+
end
|
|
2597
|
+
end
|
|
2598
|
+
local sourceOwner = damagingEvent[1]
|
|
2599
|
+
if sourceOwner then
|
|
2600
|
+
local targetOwner = damagingEvent[2]
|
|
2601
|
+
if damagingEvent[3] then
|
|
2602
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2603
|
+
end
|
|
2604
|
+
if damagingEvent[4] then
|
|
2605
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2606
|
+
end
|
|
2607
|
+
end
|
|
2608
|
+
end
|
|
2485
2609
|
local evData = setmetatable(
|
|
2486
2610
|
{},
|
|
2487
2611
|
{
|
|
2488
2612
|
__index = data,
|
|
2489
2613
|
__newindex = function(self, key, value)
|
|
2490
|
-
damageSetters[key]
|
|
2614
|
+
local damageSetter = damageSetters[key]
|
|
2615
|
+
if damageSetter ~= nil then
|
|
2616
|
+
damageSetter(value)
|
|
2617
|
+
end
|
|
2491
2618
|
data[key] = value
|
|
2492
2619
|
end
|
|
2493
2620
|
}
|
|
2494
2621
|
)
|
|
2495
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2496
2622
|
invoke(event, source, target, evData)
|
|
2497
2623
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2498
2624
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2571,6 +2697,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2571
2697
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2572
2698
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2573
2699
|
)
|
|
2700
|
+
__TS__ObjectDefineProperty(
|
|
2701
|
+
Unit,
|
|
2702
|
+
"itemChargesChangedEvent",
|
|
2703
|
+
{get = function(self)
|
|
2704
|
+
local event = __TS__New(Event)
|
|
2705
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2706
|
+
local unit = item.owner
|
|
2707
|
+
if unit ~= nil then
|
|
2708
|
+
invoke(event, unit, item)
|
|
2709
|
+
end
|
|
2710
|
+
end)
|
|
2711
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2712
|
+
return event
|
|
2713
|
+
end}
|
|
2714
|
+
)
|
|
2574
2715
|
__TS__ObjectDefineProperty(
|
|
2575
2716
|
Unit,
|
|
2576
2717
|
"itemUseOrderEvent",
|
|
@@ -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 ({}))
|