warscript 0.0.1-dev.738793 → 0.0.1-dev.73fbafc
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 +6 -0
- package/attributes.lua +17 -1
- package/core/types/frame.lua +24 -21
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +3 -1
- package/core/types/timer.lua +27 -2
- package/decl/native.d.ts +6 -4
- package/engine/behavior.d.ts +5 -0
- package/engine/behavior.lua +106 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/damage.d.ts +4 -2
- package/engine/behaviour/ability/damage.lua +24 -36
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +11 -3
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.lua +8 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
- package/engine/behaviour/unit/stun-immunity.lua +52 -27
- package/engine/behaviour/unit.d.ts +33 -1
- package/engine/behaviour/unit.lua +190 -4
- package/engine/buff.d.ts +2 -4
- package/engine/buff.lua +68 -83
- package/engine/internal/ability.d.ts +7 -1
- package/engine/internal/ability.lua +49 -9
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +16 -16
- package/engine/internal/item.lua +135 -49
- 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/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +98 -9
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit+damage.d.ts +1 -1
- package/engine/internal/unit+damage.lua +6 -1
- package/engine/internal/unit-missile-launch.lua +42 -14
- package/engine/internal/unit.d.ts +20 -8
- package/engine/internal/unit.lua +221 -101
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -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.lua +5 -4
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +8 -5
- package/engine/object-field.lua +90 -76
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +249 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +1 -1
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
- package/utility/lua-maps.d.ts +12 -2
- package/utility/lua-maps.lua +37 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
- package/utility/types.d.ts +3 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
|
@@ -14,6 +14,7 @@ import { CombatClassification, CombatClassifications } from "../object-data/auxi
|
|
|
14
14
|
import { MovementType } from "../object-data/auxiliary/movement-type";
|
|
15
15
|
import { UnitAttribute } from "../object-data/auxiliary/unit-attribute";
|
|
16
16
|
import { AttackType } from "../object-data/auxiliary/attack-type";
|
|
17
|
+
import { AttributesHolder } from "../../attributes";
|
|
17
18
|
export type UnitClassification = junittype;
|
|
18
19
|
export declare namespace UnitClassification {
|
|
19
20
|
const STRUCTURE: junittype;
|
|
@@ -22,6 +23,7 @@ export declare namespace UnitClassification {
|
|
|
22
23
|
const GROUND: junittype;
|
|
23
24
|
const SUMMONED: junittype;
|
|
24
25
|
const MECHANICAL: junittype;
|
|
26
|
+
const WORKER: junittype;
|
|
25
27
|
const ANCIENT: junittype;
|
|
26
28
|
const SUICIDAL: junittype;
|
|
27
29
|
const TAUREN: junittype;
|
|
@@ -39,15 +41,18 @@ type AbilityDispatcherTable<T extends any[] = []> = {
|
|
|
39
41
|
readonly [id: number]: Event<[Unit, Ability, ...T]>;
|
|
40
42
|
};
|
|
41
43
|
type AbilityEventDispatcher<T extends any[] = []> = Event<[Unit, Ability, ...T]> & AbilityDispatcherTable<T>;
|
|
42
|
-
export interface DamagingEvent {
|
|
44
|
+
export interface DamagingEvent extends AttributesHolder {
|
|
43
45
|
amount: number;
|
|
44
46
|
attackType: AttackType;
|
|
45
47
|
damageType: jdamagetype;
|
|
46
48
|
weaponType: jweapontype;
|
|
49
|
+
metadata: unknown;
|
|
47
50
|
readonly isAttack: boolean;
|
|
48
51
|
readonly originalAmount: number;
|
|
52
|
+
readonly originalMetadata: unknown;
|
|
53
|
+
preventRetaliation(this: DamagingEvent): void;
|
|
49
54
|
}
|
|
50
|
-
export type DamageEvent = DamagingEvent & {
|
|
55
|
+
export type DamageEvent = Omit<DamagingEvent, "preventRetaliation"> & {
|
|
51
56
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
52
57
|
};
|
|
53
58
|
export type AttackDamageEvent = DamagingEvent & {
|
|
@@ -75,10 +80,14 @@ export declare class UnitWeapon {
|
|
|
75
80
|
readonly unit: Unit;
|
|
76
81
|
readonly index: 0 | 1;
|
|
77
82
|
constructor(unit: Unit, index: 0 | 1);
|
|
83
|
+
get isEnabled(): boolean;
|
|
84
|
+
set isEnabled(isEnabled: boolean);
|
|
78
85
|
get cooldown(): number;
|
|
79
86
|
set cooldown(cooldown: number);
|
|
80
87
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
|
81
88
|
set damage([minimumDamage, maximumDamage]: [number, number]);
|
|
89
|
+
get allowedTargetCombatClassifications(): CombatClassifications;
|
|
90
|
+
set allowedTargetCombatClassifications(allowedTargetCombatClassifications: CombatClassifications);
|
|
82
91
|
get damageBase(): number;
|
|
83
92
|
set damageBase(damageBase: number);
|
|
84
93
|
get damageDiceCount(): number;
|
|
@@ -153,13 +162,13 @@ export declare class Unit extends Handle<junit> {
|
|
|
153
162
|
isInRangeOf(unit: Unit, range: number): boolean;
|
|
154
163
|
isAllyOf(unit: Unit): boolean;
|
|
155
164
|
isEnemyOf(unit: Unit): boolean;
|
|
156
|
-
playAnimation(animation: string, rarity?: jraritycontrol): void;
|
|
157
|
-
playAnimation(animation: number): void;
|
|
165
|
+
playAnimation(...parameters: [animation: number] | [animation: string, rarity?: jraritycontrol]): void;
|
|
158
166
|
resetAnimation(): void;
|
|
159
167
|
queueAnimation(animation: string): void;
|
|
160
168
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
161
169
|
get firstWeapon(): UnitWeapon;
|
|
162
170
|
get secondWeapon(): UnitWeapon;
|
|
171
|
+
chooseWeapon(target: Unit): UnitWeapon | undefined;
|
|
163
172
|
get level(): number;
|
|
164
173
|
set level(v: number);
|
|
165
174
|
get xp(): number;
|
|
@@ -259,17 +268,18 @@ export declare class Unit extends Handle<junit> {
|
|
|
259
268
|
dropItemTarget(item: Item, target: Widget): boolean;
|
|
260
269
|
dropItemSlot(item: Item, slot: number): boolean;
|
|
261
270
|
itemInSlot(slot: number): Item | null;
|
|
262
|
-
addAbility(abilityId: number): UnitAbility |
|
|
271
|
+
addAbility(abilityId: number): UnitAbility | undefined;
|
|
263
272
|
makeAbilityPermanent(abilityId: number, permanent: true): boolean;
|
|
264
273
|
setAbilityLevel(abilityId: number, level: number): number;
|
|
265
274
|
getAbilityLevel(abilityId: number): number;
|
|
266
275
|
hasAbility(abilityId: number): boolean;
|
|
267
|
-
|
|
268
|
-
removeAbility(
|
|
276
|
+
getAbility(abilityId: number): UnitAbility | undefined;
|
|
277
|
+
removeAbility(abilityTypeId: number): boolean;
|
|
269
278
|
hideAbility(abilityId: number, flag: boolean): void;
|
|
270
279
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
271
280
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
272
281
|
endAbilityCooldown(abilityId: number): void;
|
|
282
|
+
interruptMovement(): void;
|
|
273
283
|
interruptAttack(): void;
|
|
274
284
|
interruptCast(abilityId: number): void;
|
|
275
285
|
getDistanceTo(target: Unit | Vec2): number;
|
|
@@ -292,6 +302,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
292
302
|
get onUnitInRange(): Record<number, Event<[Unit]>>;
|
|
293
303
|
get onManaEqual(): Record<number, Event<[Unit, number]>>;
|
|
294
304
|
get manaEvent(): Record<Operator, Record<number, Event<[Unit]>>>;
|
|
305
|
+
get targetAcquiredEvent(): Event;
|
|
295
306
|
get onSelect(): Event;
|
|
296
307
|
get onDeselect(): Event;
|
|
297
308
|
get onImmediateOrder(): Event<[number]>;
|
|
@@ -344,7 +355,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
344
355
|
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
345
356
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
346
357
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
347
|
-
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
358
|
+
static itemStackedEvent: UnitTriggerEvent<[target: Item, source: Item]>;
|
|
359
|
+
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
348
360
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
349
361
|
static get itemMoveOrderEvent(): Event<[
|
|
350
362
|
unit: Unit,
|
package/engine/internal/unit.lua
CHANGED
|
@@ -56,13 +56,16 @@ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
|
56
56
|
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
57
|
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
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
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
59
65
|
local match = string.match
|
|
60
66
|
local ____tostring = _G.tostring
|
|
61
67
|
local setUnitAnimation = SetUnitAnimation
|
|
62
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
63
68
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
64
|
-
local resetUnitAnimation = ResetUnitAnimation
|
|
65
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
66
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
67
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
68
71
|
local getHeroStr = GetHeroStr
|
|
@@ -122,10 +125,6 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
122
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
123
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
124
127
|
local unitAlive = UnitAlive
|
|
125
|
-
local unitAddType = UnitAddType
|
|
126
|
-
local unitRemoveType = UnitRemoveType
|
|
127
|
-
local isUnitIllusion = IsUnitIllusion
|
|
128
|
-
local isUnitType = IsUnitType
|
|
129
128
|
local isUnitAlly = IsUnitAlly
|
|
130
129
|
local isUnitEnemy = IsUnitEnemy
|
|
131
130
|
local getOwningPlayer = GetOwningPlayer
|
|
@@ -138,6 +137,7 @@ do
|
|
|
138
137
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
139
138
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
140
139
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
140
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
141
141
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
142
142
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
143
143
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -345,6 +345,9 @@ local function dispatchAbility(event)
|
|
|
345
345
|
}
|
|
346
346
|
)
|
|
347
347
|
end
|
|
348
|
+
local function damagingEventPreventRetaliation(self)
|
|
349
|
+
self[0] = true
|
|
350
|
+
end
|
|
348
351
|
local function damageEventPreventDeath(self, callback, ...)
|
|
349
352
|
if self[0] ~= nil then
|
|
350
353
|
return
|
|
@@ -407,6 +410,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
407
410
|
self.unit = unit
|
|
408
411
|
self.index = index
|
|
409
412
|
end
|
|
413
|
+
__TS__SetDescriptor(
|
|
414
|
+
UnitWeapon.prototype,
|
|
415
|
+
"isEnabled",
|
|
416
|
+
{
|
|
417
|
+
get = function(self)
|
|
418
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
419
|
+
end,
|
|
420
|
+
set = function(self, isEnabled)
|
|
421
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
422
|
+
end
|
|
423
|
+
},
|
|
424
|
+
true
|
|
425
|
+
)
|
|
410
426
|
__TS__SetDescriptor(
|
|
411
427
|
UnitWeapon.prototype,
|
|
412
428
|
"cooldown",
|
|
@@ -441,6 +457,19 @@ __TS__SetDescriptor(
|
|
|
441
457
|
},
|
|
442
458
|
true
|
|
443
459
|
)
|
|
460
|
+
__TS__SetDescriptor(
|
|
461
|
+
UnitWeapon.prototype,
|
|
462
|
+
"allowedTargetCombatClassifications",
|
|
463
|
+
{
|
|
464
|
+
get = function(self)
|
|
465
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
466
|
+
end,
|
|
467
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
468
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
469
|
+
end
|
|
470
|
+
},
|
|
471
|
+
true
|
|
472
|
+
)
|
|
444
473
|
__TS__SetDescriptor(
|
|
445
474
|
UnitWeapon.prototype,
|
|
446
475
|
"damageBase",
|
|
@@ -645,16 +674,26 @@ local function delayHealthChecksCallback(unit)
|
|
|
645
674
|
end
|
|
646
675
|
end
|
|
647
676
|
local nextSyncId = 1
|
|
648
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
677
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
678
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
679
|
+
local function addAbility(unit, abilityTypeId)
|
|
680
|
+
local ____unitAddAbility_result_0
|
|
681
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
682
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
683
|
+
else
|
|
684
|
+
____unitAddAbility_result_0 = nil
|
|
685
|
+
end
|
|
686
|
+
return ____unitAddAbility_result_0
|
|
687
|
+
end
|
|
649
688
|
____exports.Unit = __TS__Class()
|
|
650
689
|
local Unit = ____exports.Unit
|
|
651
690
|
Unit.name = "Unit"
|
|
652
691
|
__TS__ClassExtends(Unit, Handle)
|
|
653
692
|
function Unit.prototype.____constructor(self, handle)
|
|
654
693
|
Handle.prototype.____constructor(self, handle)
|
|
655
|
-
local
|
|
656
|
-
nextSyncId =
|
|
657
|
-
self.syncId =
|
|
694
|
+
local ____nextSyncId_1 = nextSyncId
|
|
695
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
696
|
+
self.syncId = ____nextSyncId_1
|
|
658
697
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
659
698
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
660
699
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -755,17 +794,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
755
794
|
end}
|
|
756
795
|
end
|
|
757
796
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
758
|
-
local
|
|
759
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
797
|
+
local ____combatClassification_2 = combatClassification
|
|
798
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
760
799
|
end
|
|
761
800
|
function Unit.prototype.addClassification(self, classification)
|
|
762
|
-
return
|
|
801
|
+
return UnitAddType(self.handle, classification)
|
|
763
802
|
end
|
|
764
803
|
function Unit.prototype.removeClassification(self, classification)
|
|
765
|
-
return
|
|
804
|
+
return UnitRemoveType(self.handle, classification)
|
|
766
805
|
end
|
|
767
806
|
function Unit.prototype.hasClassification(self, classification)
|
|
768
|
-
return
|
|
807
|
+
return IsUnitType(self.handle, classification)
|
|
769
808
|
end
|
|
770
809
|
function Unit.prototype.isVisibleTo(self, player)
|
|
771
810
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -774,13 +813,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
774
813
|
return isUnitInvisible(self.handle, player.handle)
|
|
775
814
|
end
|
|
776
815
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
777
|
-
local
|
|
816
|
+
local ____temp_3
|
|
778
817
|
if type(x) == "number" then
|
|
779
|
-
|
|
818
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
780
819
|
else
|
|
781
|
-
|
|
820
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
782
821
|
end
|
|
783
|
-
return
|
|
822
|
+
return ____temp_3
|
|
784
823
|
end
|
|
785
824
|
function Unit.prototype.isAllyOf(self, unit)
|
|
786
825
|
return isUnitAlly(
|
|
@@ -798,16 +837,27 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
798
837
|
if type(animation) == "number" then
|
|
799
838
|
setUnitAnimationByIndex(self.handle, animation)
|
|
800
839
|
elseif rarity then
|
|
801
|
-
|
|
840
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
802
841
|
else
|
|
803
842
|
setUnitAnimation(self.handle, animation)
|
|
804
843
|
end
|
|
805
844
|
end
|
|
806
845
|
function Unit.prototype.resetAnimation(self)
|
|
807
|
-
|
|
846
|
+
ResetUnitAnimation(self.handle)
|
|
808
847
|
end
|
|
809
848
|
function Unit.prototype.queueAnimation(self, animation)
|
|
810
|
-
|
|
849
|
+
QueueUnitAnimation(self.handle, animation)
|
|
850
|
+
end
|
|
851
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
852
|
+
local firstWeapon = self.firstWeapon
|
|
853
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
854
|
+
return firstWeapon
|
|
855
|
+
end
|
|
856
|
+
local secondWeapon = self.secondWeapon
|
|
857
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
858
|
+
return secondWeapon
|
|
859
|
+
end
|
|
860
|
+
return nil
|
|
811
861
|
end
|
|
812
862
|
function Unit.prototype.delayHealthChecks(self)
|
|
813
863
|
self[103] = (self[103] or 0) + 1
|
|
@@ -827,14 +877,14 @@ function Unit.prototype.kill(self)
|
|
|
827
877
|
killUnit(self.handle)
|
|
828
878
|
end
|
|
829
879
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
830
|
-
local
|
|
831
|
-
local
|
|
832
|
-
local
|
|
833
|
-
if
|
|
834
|
-
|
|
880
|
+
local ____ReviveHero_6 = ReviveHero
|
|
881
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
882
|
+
local ____doEffect_4 = doEffect
|
|
883
|
+
if ____doEffect_4 == nil then
|
|
884
|
+
____doEffect_4 = false
|
|
835
885
|
end
|
|
836
|
-
__TS__SparseArrayPush(
|
|
837
|
-
|
|
886
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
887
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
838
888
|
end
|
|
839
889
|
function Unit.prototype.healTarget(self, target, amount)
|
|
840
890
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -877,17 +927,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
877
927
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
878
928
|
end
|
|
879
929
|
function Unit.prototype.addAbility(self, abilityId)
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
930
|
+
local ability = UnitAbility:of(
|
|
931
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
932
|
+
abilityId,
|
|
933
|
+
self
|
|
934
|
+
)
|
|
935
|
+
if ability ~= nil then
|
|
886
936
|
local abilities = self.abilities
|
|
887
937
|
abilities[#abilities + 1] = ability
|
|
888
|
-
return ability
|
|
889
938
|
end
|
|
890
|
-
return
|
|
939
|
+
return ability
|
|
891
940
|
end
|
|
892
941
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
893
942
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -901,31 +950,21 @@ end
|
|
|
901
950
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
902
951
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
903
952
|
end
|
|
904
|
-
function Unit.prototype.
|
|
905
|
-
local
|
|
906
|
-
|
|
907
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
908
|
-
return nil
|
|
909
|
-
end
|
|
910
|
-
return UnitAbility:of(
|
|
911
|
-
getUnitAbility(self.handle, abilityId),
|
|
912
|
-
abilityId,
|
|
913
|
-
self
|
|
914
|
-
)
|
|
953
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
954
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
955
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
915
956
|
end
|
|
916
|
-
function Unit.prototype.removeAbility(self,
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
end
|
|
957
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
958
|
+
local abilities = self.abilities
|
|
959
|
+
for i = 1, #abilities do
|
|
960
|
+
if abilities[i].typeId == abilityTypeId then
|
|
961
|
+
local ability = abilities[i]
|
|
962
|
+
tremove(abilities, i)
|
|
963
|
+
ability:destroy()
|
|
964
|
+
return true
|
|
925
965
|
end
|
|
926
|
-
return true
|
|
927
966
|
end
|
|
928
|
-
return
|
|
967
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
929
968
|
end
|
|
930
969
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
931
970
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -939,6 +978,21 @@ end
|
|
|
939
978
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
940
979
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
941
980
|
end
|
|
981
|
+
function Unit.prototype.interruptMovement(self)
|
|
982
|
+
local handle = self.handle
|
|
983
|
+
unitDisableAbility(
|
|
984
|
+
handle,
|
|
985
|
+
fourCC("Amov"),
|
|
986
|
+
true,
|
|
987
|
+
false
|
|
988
|
+
)
|
|
989
|
+
unitDisableAbility(
|
|
990
|
+
handle,
|
|
991
|
+
fourCC("Amov"),
|
|
992
|
+
false,
|
|
993
|
+
false
|
|
994
|
+
)
|
|
995
|
+
end
|
|
942
996
|
function Unit.prototype.interruptAttack(self)
|
|
943
997
|
unitInterruptAttack(self.handle)
|
|
944
998
|
end
|
|
@@ -1212,7 +1266,7 @@ __TS__SetDescriptor(
|
|
|
1212
1266
|
Unit.prototype,
|
|
1213
1267
|
"isIllusion",
|
|
1214
1268
|
{get = function(self)
|
|
1215
|
-
return
|
|
1269
|
+
return IsUnitIllusion(self.handle)
|
|
1216
1270
|
end},
|
|
1217
1271
|
true
|
|
1218
1272
|
)
|
|
@@ -1435,13 +1489,13 @@ __TS__SetDescriptor(
|
|
|
1435
1489
|
end,
|
|
1436
1490
|
set = function(self, isTeamGlowVisible)
|
|
1437
1491
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1438
|
-
local
|
|
1492
|
+
local ____temp_7
|
|
1439
1493
|
if not isTeamGlowVisible then
|
|
1440
|
-
|
|
1494
|
+
____temp_7 = true
|
|
1441
1495
|
else
|
|
1442
|
-
|
|
1496
|
+
____temp_7 = nil
|
|
1443
1497
|
end
|
|
1444
|
-
self[106] =
|
|
1498
|
+
self[106] = ____temp_7
|
|
1445
1499
|
end
|
|
1446
1500
|
},
|
|
1447
1501
|
true
|
|
@@ -2045,6 +2099,14 @@ __TS__SetDescriptor(
|
|
|
2045
2099
|
end},
|
|
2046
2100
|
true
|
|
2047
2101
|
)
|
|
2102
|
+
__TS__SetDescriptor(
|
|
2103
|
+
Unit.prototype,
|
|
2104
|
+
"targetAcquiredEvent",
|
|
2105
|
+
{get = function(self)
|
|
2106
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2107
|
+
end},
|
|
2108
|
+
true
|
|
2109
|
+
)
|
|
2048
2110
|
__TS__SetDescriptor(
|
|
2049
2111
|
Unit.prototype,
|
|
2050
2112
|
"onSelect",
|
|
@@ -2180,25 +2242,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2180
2242
|
InitializingEvent,
|
|
2181
2243
|
function(event)
|
|
2182
2244
|
local function listener(unit, id)
|
|
2183
|
-
local
|
|
2245
|
+
local ____GetSpellTargetUnit_result_10
|
|
2184
2246
|
if GetSpellTargetUnit() then
|
|
2185
|
-
|
|
2247
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2186
2248
|
else
|
|
2187
|
-
local
|
|
2249
|
+
local ____GetSpellTargetItem_result_9
|
|
2188
2250
|
if GetSpellTargetItem() then
|
|
2189
|
-
|
|
2251
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2190
2252
|
else
|
|
2191
|
-
local
|
|
2253
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2192
2254
|
if GetSpellTargetDestructable() then
|
|
2193
|
-
|
|
2255
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2194
2256
|
else
|
|
2195
|
-
|
|
2257
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2196
2258
|
end
|
|
2197
|
-
|
|
2259
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2198
2260
|
end
|
|
2199
|
-
|
|
2261
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2200
2262
|
end
|
|
2201
|
-
local target =
|
|
2263
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2202
2264
|
if target then
|
|
2203
2265
|
invoke(event, unit, id, target)
|
|
2204
2266
|
end
|
|
@@ -2406,38 +2468,57 @@ Unit.onDamaging = (function()
|
|
|
2406
2468
|
if source and source.typeId == dummyUnitId then
|
|
2407
2469
|
source = nil
|
|
2408
2470
|
end
|
|
2409
|
-
local target = BlzGetEventDamageTarget()
|
|
2471
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2472
|
+
local metadata = damageMetadataByTarget[target]
|
|
2473
|
+
damageMetadataByTarget[target] = nil
|
|
2410
2474
|
local data = {
|
|
2411
2475
|
amount = GetEventDamage(),
|
|
2412
2476
|
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2413
2477
|
damageType = BlzGetEventDamageType(),
|
|
2414
2478
|
weaponType = BlzGetEventWeaponType(),
|
|
2415
|
-
|
|
2479
|
+
metadata = metadata,
|
|
2480
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2481
|
+
originalAmount = GetEventDamage(),
|
|
2482
|
+
originalMetadata = metadata,
|
|
2483
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2416
2484
|
}
|
|
2417
2485
|
if data.isAttack and source then
|
|
2418
|
-
|
|
2419
|
-
if weapon == -1 then
|
|
2420
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2421
|
-
weapon = 0
|
|
2422
|
-
end
|
|
2423
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2486
|
+
data.weapon = source:chooseWeapon(target)
|
|
2424
2487
|
end
|
|
2425
2488
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2426
2489
|
invoke(
|
|
2427
2490
|
event,
|
|
2428
2491
|
source,
|
|
2429
|
-
|
|
2492
|
+
target,
|
|
2430
2493
|
setmetatable(
|
|
2431
2494
|
{},
|
|
2432
2495
|
{
|
|
2433
2496
|
__index = data,
|
|
2434
2497
|
__newindex = function(self, key, value)
|
|
2435
|
-
damageSetters[key]
|
|
2498
|
+
local damageSetter = damageSetters[key]
|
|
2499
|
+
if damageSetter ~= nil then
|
|
2500
|
+
damageSetter(value)
|
|
2501
|
+
end
|
|
2436
2502
|
data[key] = value
|
|
2437
2503
|
end
|
|
2438
2504
|
}
|
|
2439
2505
|
)
|
|
2440
2506
|
)
|
|
2507
|
+
if data[0] and source then
|
|
2508
|
+
local sourceOwner = source.owner.handle
|
|
2509
|
+
data[1] = sourceOwner
|
|
2510
|
+
local targetOwner = target.owner.handle
|
|
2511
|
+
data[2] = targetOwner
|
|
2512
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2513
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2514
|
+
data[3] = true
|
|
2515
|
+
end
|
|
2516
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2517
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2518
|
+
data[4] = true
|
|
2519
|
+
end
|
|
2520
|
+
end
|
|
2521
|
+
damagingEventByTarget[target] = data
|
|
2441
2522
|
return
|
|
2442
2523
|
end
|
|
2443
2524
|
BlzSetEventDamage(0)
|
|
@@ -2445,7 +2526,7 @@ Unit.onDamaging = (function()
|
|
|
2445
2526
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2446
2527
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2447
2528
|
local sourceOwner = source.owner.handle
|
|
2448
|
-
local targetOwner =
|
|
2529
|
+
local targetOwner = target.owner.handle
|
|
2449
2530
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2450
2531
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2451
2532
|
Timer:run(function()
|
|
@@ -2461,19 +2542,15 @@ Unit.onDamaging = (function()
|
|
|
2461
2542
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2462
2543
|
local condition = ____value[1]
|
|
2463
2544
|
local action = ____value[2]
|
|
2464
|
-
if condition(
|
|
2465
|
-
source,
|
|
2466
|
-
____exports.Unit:of(target),
|
|
2467
|
-
data
|
|
2468
|
-
) then
|
|
2545
|
+
if condition(source, target, data) then
|
|
2469
2546
|
action(
|
|
2470
2547
|
source,
|
|
2471
|
-
|
|
2548
|
+
target,
|
|
2472
2549
|
setmetatable(
|
|
2473
2550
|
{fire = function()
|
|
2474
2551
|
UnitDamageTarget(
|
|
2475
2552
|
source.handle,
|
|
2476
|
-
target,
|
|
2553
|
+
target.handle,
|
|
2477
2554
|
data.amount,
|
|
2478
2555
|
true,
|
|
2479
2556
|
true,
|
|
@@ -2504,26 +2581,50 @@ Unit.onDamage = __TS__New(
|
|
|
2504
2581
|
if source and source.typeId == dummyUnitId then
|
|
2505
2582
|
source = nil
|
|
2506
2583
|
end
|
|
2584
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2585
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2586
|
+
damagingEventByTarget[target] = nil
|
|
2507
2587
|
local data = {
|
|
2508
2588
|
amount = GetEventDamage(),
|
|
2509
2589
|
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2510
2590
|
damageType = BlzGetEventDamageType(),
|
|
2511
2591
|
weaponType = BlzGetEventWeaponType(),
|
|
2592
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2512
2593
|
isAttack = BlzGetEventIsAttack(),
|
|
2513
|
-
originalAmount = GetEventDamage(),
|
|
2594
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2595
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2514
2596
|
preventDeath = damageEventPreventDeath
|
|
2515
2597
|
}
|
|
2598
|
+
if damagingEvent then
|
|
2599
|
+
for key, value in pairs(damagingEvent) do
|
|
2600
|
+
if isAttribute(key) then
|
|
2601
|
+
data[key] = value
|
|
2602
|
+
end
|
|
2603
|
+
end
|
|
2604
|
+
local sourceOwner = damagingEvent[1]
|
|
2605
|
+
if sourceOwner then
|
|
2606
|
+
local targetOwner = damagingEvent[2]
|
|
2607
|
+
if damagingEvent[3] then
|
|
2608
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2609
|
+
end
|
|
2610
|
+
if damagingEvent[4] then
|
|
2611
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2612
|
+
end
|
|
2613
|
+
end
|
|
2614
|
+
end
|
|
2516
2615
|
local evData = setmetatable(
|
|
2517
2616
|
{},
|
|
2518
2617
|
{
|
|
2519
2618
|
__index = data,
|
|
2520
2619
|
__newindex = function(self, key, value)
|
|
2521
|
-
damageSetters[key]
|
|
2620
|
+
local damageSetter = damageSetters[key]
|
|
2621
|
+
if damageSetter ~= nil then
|
|
2622
|
+
damageSetter(value)
|
|
2623
|
+
end
|
|
2522
2624
|
data[key] = value
|
|
2523
2625
|
end
|
|
2524
2626
|
}
|
|
2525
2627
|
)
|
|
2526
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2527
2628
|
invoke(event, source, target, evData)
|
|
2528
2629
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2529
2630
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2577,10 +2678,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2577
2678
|
____exports.UnitTriggerEvent,
|
|
2578
2679
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2579
2680
|
function()
|
|
2580
|
-
local
|
|
2581
|
-
local
|
|
2582
|
-
if getUnitTypeId(
|
|
2583
|
-
|
|
2681
|
+
local unitHandle = getTriggerUnit()
|
|
2682
|
+
local itemHandle = getManipulatedItem()
|
|
2683
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2684
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2685
|
+
local item = Item:of(itemHandle)
|
|
2686
|
+
if item.owner ~= unit then
|
|
2687
|
+
return unit, item
|
|
2688
|
+
end
|
|
2584
2689
|
end
|
|
2585
2690
|
return IgnoreEvent
|
|
2586
2691
|
end
|
|
@@ -2600,7 +2705,22 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2600
2705
|
Unit.itemStackedEvent = __TS__New(
|
|
2601
2706
|
____exports.UnitTriggerEvent,
|
|
2602
2707
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2603
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2708
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2709
|
+
)
|
|
2710
|
+
__TS__ObjectDefineProperty(
|
|
2711
|
+
Unit,
|
|
2712
|
+
"itemChargesChangedEvent",
|
|
2713
|
+
{get = function(self)
|
|
2714
|
+
local event = __TS__New(Event)
|
|
2715
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2716
|
+
local unit = item.owner
|
|
2717
|
+
if unit ~= nil then
|
|
2718
|
+
invoke(event, unit, item)
|
|
2719
|
+
end
|
|
2720
|
+
end)
|
|
2721
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2722
|
+
return event
|
|
2723
|
+
end}
|
|
2604
2724
|
)
|
|
2605
2725
|
__TS__ObjectDefineProperty(
|
|
2606
2726
|
Unit,
|