warscript 0.0.1-dev.7c9c5d2 → 0.0.1-dev.7d7d4b4
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/timer.d.ts +1 -1
- package/engine/behavior.d.ts +2 -0
- package/engine/behavior.lua +53 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +11 -3
- package/engine/behaviour/ability.lua +8 -17
- 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 +26 -0
- package/engine/behaviour/unit.lua +163 -4
- package/engine/buff.d.ts +2 -1
- package/engine/buff.lua +9 -3
- package/engine/internal/ability.d.ts +2 -0
- package/engine/internal/ability.lua +18 -2
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item.d.ts +3 -1
- package/engine/internal/item.lua +75 -3
- 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-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +8 -2
- package/engine/internal/unit.lua +136 -58
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +6 -3
- package/engine/object-field.lua +85 -73
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -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/package.json +1 -1
- package/utility/functions.d.ts +5 -0
- package/utility/functions.lua +5 -0
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____attributes = require("attributes")
|
|
5
|
+
local attribute = ____attributes.attribute
|
|
6
|
+
local ____unit = require("engine.internal.unit")
|
|
7
|
+
local Unit = ____unit.Unit
|
|
8
|
+
local ____game = require("core.game")
|
|
9
|
+
local elapsedTime = ____game.elapsedTime
|
|
10
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
11
|
+
local issueImmediateOrderById = IssueImmediateOrderById
|
|
12
|
+
local issuePointOrderById = IssuePointOrderById
|
|
13
|
+
local issueTargetOrderById = IssueTargetOrderById
|
|
14
|
+
local unitLastOrderTypeAttribute = attribute()
|
|
15
|
+
local unitLastOrderIdAttribute = attribute()
|
|
16
|
+
local unitLastOrderStartTimeAttribute = attribute()
|
|
17
|
+
local unitLastOrderStartXAttribute = attribute()
|
|
18
|
+
local unitLastOrderStartYAttribute = attribute()
|
|
19
|
+
local unitLastOrderTargetXAttribute = attribute()
|
|
20
|
+
local unitLastOrderTargetYAttribute = attribute()
|
|
21
|
+
local unitLastOrderTargetAttribute = attribute()
|
|
22
|
+
Unit.onImmediateOrder:addListener(
|
|
23
|
+
4,
|
|
24
|
+
function(unit, orderId)
|
|
25
|
+
unit[unitLastOrderTypeAttribute] = 0
|
|
26
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
27
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
28
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
29
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
30
|
+
unit[unitLastOrderTargetXAttribute] = nil
|
|
31
|
+
unit[unitLastOrderTargetYAttribute] = nil
|
|
32
|
+
unit[unitLastOrderTargetAttribute] = nil
|
|
33
|
+
end
|
|
34
|
+
)
|
|
35
|
+
Unit.onPointOrder:addListener(
|
|
36
|
+
4,
|
|
37
|
+
function(unit, orderId, x, y)
|
|
38
|
+
unit[unitLastOrderTypeAttribute] = 1
|
|
39
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
40
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
41
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
42
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
43
|
+
unit[unitLastOrderTargetXAttribute] = x
|
|
44
|
+
unit[unitLastOrderTargetYAttribute] = y
|
|
45
|
+
unit[unitLastOrderTargetAttribute] = nil
|
|
46
|
+
end
|
|
47
|
+
)
|
|
48
|
+
Unit.onTargetOrder:addListener(
|
|
49
|
+
4,
|
|
50
|
+
function(unit, orderId, target)
|
|
51
|
+
unit[unitLastOrderTypeAttribute] = 2
|
|
52
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
53
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
54
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
55
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
56
|
+
unit[unitLastOrderTargetXAttribute] = target.x
|
|
57
|
+
unit[unitLastOrderTargetYAttribute] = target.y
|
|
58
|
+
unit[unitLastOrderTargetAttribute] = target
|
|
59
|
+
end
|
|
60
|
+
)
|
|
61
|
+
local function toUndefinedIfCurrentOrderDoesNotMatchLast(unit, value)
|
|
62
|
+
local currentOrderId = getUnitCurrentOrder(unit.handle)
|
|
63
|
+
local lastOrderId = unit[unitLastOrderIdAttribute]
|
|
64
|
+
local ____temp_0
|
|
65
|
+
if currentOrderId == lastOrderId or currentOrderId == orderId("patrolAI") and lastOrderId == orderId("patrol") then
|
|
66
|
+
____temp_0 = value
|
|
67
|
+
else
|
|
68
|
+
____temp_0 = nil
|
|
69
|
+
end
|
|
70
|
+
return ____temp_0
|
|
71
|
+
end
|
|
72
|
+
__TS__ObjectDefineProperty(
|
|
73
|
+
Unit.prototype,
|
|
74
|
+
"currentOrderType",
|
|
75
|
+
{get = function(self)
|
|
76
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTypeAttribute]) or 0
|
|
77
|
+
end}
|
|
78
|
+
)
|
|
79
|
+
__TS__ObjectDefineProperty(
|
|
80
|
+
Unit.prototype,
|
|
81
|
+
"currentOrderId",
|
|
82
|
+
{get = function(self)
|
|
83
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderIdAttribute]) or 0
|
|
84
|
+
end}
|
|
85
|
+
)
|
|
86
|
+
__TS__ObjectDefineProperty(
|
|
87
|
+
Unit.prototype,
|
|
88
|
+
"currentOrderStartTime",
|
|
89
|
+
{get = function(self)
|
|
90
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartTimeAttribute]) or 0
|
|
91
|
+
end}
|
|
92
|
+
)
|
|
93
|
+
__TS__ObjectDefineProperty(
|
|
94
|
+
Unit.prototype,
|
|
95
|
+
"currentOrderStartX",
|
|
96
|
+
{get = function(self)
|
|
97
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartXAttribute]) or 0
|
|
98
|
+
end}
|
|
99
|
+
)
|
|
100
|
+
__TS__ObjectDefineProperty(
|
|
101
|
+
Unit.prototype,
|
|
102
|
+
"currentOrderStartY",
|
|
103
|
+
{get = function(self)
|
|
104
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartYAttribute]) or 0
|
|
105
|
+
end}
|
|
106
|
+
)
|
|
107
|
+
__TS__ObjectDefineProperty(
|
|
108
|
+
Unit.prototype,
|
|
109
|
+
"currentOrderTargetX",
|
|
110
|
+
{get = function(self)
|
|
111
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetXAttribute]) or 0
|
|
112
|
+
end}
|
|
113
|
+
)
|
|
114
|
+
__TS__ObjectDefineProperty(
|
|
115
|
+
Unit.prototype,
|
|
116
|
+
"currentOrderTargetY",
|
|
117
|
+
{get = function(self)
|
|
118
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetYAttribute]) or 0
|
|
119
|
+
end}
|
|
120
|
+
)
|
|
121
|
+
__TS__ObjectDefineProperty(
|
|
122
|
+
Unit.prototype,
|
|
123
|
+
"currentOrderTarget",
|
|
124
|
+
{get = function(self)
|
|
125
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetAttribute])
|
|
126
|
+
end}
|
|
127
|
+
)
|
|
128
|
+
local issueOrderByType = {
|
|
129
|
+
[0] = issueImmediateOrderById,
|
|
130
|
+
[1] = issuePointOrderById,
|
|
131
|
+
[2] = function(unitHandle, orderId, widget) return issueTargetOrderById(unitHandle, orderId, widget.handle) end
|
|
132
|
+
}
|
|
133
|
+
Unit.prototype.issueOrder = function(self, orderType, orderId, xOrTarget, y)
|
|
134
|
+
return issueOrderByType[orderType](self.handle, orderId, xOrTarget, y)
|
|
135
|
+
end
|
|
136
|
+
return ____exports
|
|
@@ -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)
|
|
@@ -50,8 +50,9 @@ export interface DamagingEvent extends AttributesHolder {
|
|
|
50
50
|
readonly isAttack: boolean;
|
|
51
51
|
readonly originalAmount: number;
|
|
52
52
|
readonly originalMetadata: unknown;
|
|
53
|
+
preventRetaliation(this: DamagingEvent): void;
|
|
53
54
|
}
|
|
54
|
-
export type DamageEvent = DamagingEvent & {
|
|
55
|
+
export type DamageEvent = Omit<DamagingEvent, "preventRetaliation"> & {
|
|
55
56
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
56
57
|
};
|
|
57
58
|
export type AttackDamageEvent = DamagingEvent & {
|
|
@@ -83,6 +84,8 @@ export declare class UnitWeapon {
|
|
|
83
84
|
set cooldown(cooldown: number);
|
|
84
85
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
|
85
86
|
set damage([minimumDamage, maximumDamage]: [number, number]);
|
|
87
|
+
get allowedTargetCombatClassifications(): CombatClassifications;
|
|
88
|
+
set allowedTargetCombatClassifications(allowedTargetCombatClassifications: CombatClassifications);
|
|
86
89
|
get damageBase(): number;
|
|
87
90
|
set damageBase(damageBase: number);
|
|
88
91
|
get damageDiceCount(): number;
|
|
@@ -164,6 +167,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
164
167
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
165
168
|
get firstWeapon(): UnitWeapon;
|
|
166
169
|
get secondWeapon(): UnitWeapon;
|
|
170
|
+
chooseWeapon(target: Unit): UnitWeapon | undefined;
|
|
167
171
|
get level(): number;
|
|
168
172
|
set level(v: number);
|
|
169
173
|
get xp(): number;
|
|
@@ -263,7 +267,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
263
267
|
dropItemTarget(item: Item, target: Widget): boolean;
|
|
264
268
|
dropItemSlot(item: Item, slot: number): boolean;
|
|
265
269
|
itemInSlot(slot: number): Item | null;
|
|
266
|
-
addAbility(abilityId: number): UnitAbility |
|
|
270
|
+
addAbility(abilityId: number): UnitAbility | undefined;
|
|
267
271
|
makeAbilityPermanent(abilityId: number, permanent: true): boolean;
|
|
268
272
|
setAbilityLevel(abilityId: number, level: number): number;
|
|
269
273
|
getAbilityLevel(abilityId: number): number;
|
|
@@ -274,6 +278,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
274
278
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
275
279
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
276
280
|
endAbilityCooldown(abilityId: number): void;
|
|
281
|
+
interruptMovement(): void;
|
|
277
282
|
interruptAttack(): void;
|
|
278
283
|
interruptCast(abilityId: number): void;
|
|
279
284
|
getDistanceTo(target: Unit | Vec2): number;
|
|
@@ -350,6 +355,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
350
355
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
351
356
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
352
357
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
358
|
+
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
353
359
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
354
360
|
static get itemMoveOrderEvent(): Event<[
|
|
355
361
|
unit: Unit,
|
package/engine/internal/unit.lua
CHANGED
|
@@ -60,6 +60,8 @@ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage
|
|
|
60
60
|
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
61
|
local ____attributes = require("attributes")
|
|
62
62
|
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
63
65
|
local match = string.match
|
|
64
66
|
local ____tostring = _G.tostring
|
|
65
67
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -123,10 +125,6 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
123
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
124
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
125
127
|
local unitAlive = UnitAlive
|
|
126
|
-
local unitAddType = UnitAddType
|
|
127
|
-
local unitRemoveType = UnitRemoveType
|
|
128
|
-
local isUnitIllusion = IsUnitIllusion
|
|
129
|
-
local isUnitType = IsUnitType
|
|
130
128
|
local isUnitAlly = IsUnitAlly
|
|
131
129
|
local isUnitEnemy = IsUnitEnemy
|
|
132
130
|
local getOwningPlayer = GetOwningPlayer
|
|
@@ -347,6 +345,9 @@ local function dispatchAbility(event)
|
|
|
347
345
|
}
|
|
348
346
|
)
|
|
349
347
|
end
|
|
348
|
+
local function damagingEventPreventRetaliation(self)
|
|
349
|
+
self[0] = true
|
|
350
|
+
end
|
|
350
351
|
local function damageEventPreventDeath(self, callback, ...)
|
|
351
352
|
if self[0] ~= nil then
|
|
352
353
|
return
|
|
@@ -443,6 +444,19 @@ __TS__SetDescriptor(
|
|
|
443
444
|
},
|
|
444
445
|
true
|
|
445
446
|
)
|
|
447
|
+
__TS__SetDescriptor(
|
|
448
|
+
UnitWeapon.prototype,
|
|
449
|
+
"allowedTargetCombatClassifications",
|
|
450
|
+
{
|
|
451
|
+
get = function(self)
|
|
452
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
453
|
+
end,
|
|
454
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
455
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
456
|
+
end
|
|
457
|
+
},
|
|
458
|
+
true
|
|
459
|
+
)
|
|
446
460
|
__TS__SetDescriptor(
|
|
447
461
|
UnitWeapon.prototype,
|
|
448
462
|
"damageBase",
|
|
@@ -649,15 +663,24 @@ end
|
|
|
649
663
|
local nextSyncId = 1
|
|
650
664
|
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
651
665
|
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
666
|
+
local function addAbility(unit, abilityTypeId)
|
|
667
|
+
local ____unitAddAbility_result_0
|
|
668
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
669
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
670
|
+
else
|
|
671
|
+
____unitAddAbility_result_0 = nil
|
|
672
|
+
end
|
|
673
|
+
return ____unitAddAbility_result_0
|
|
674
|
+
end
|
|
652
675
|
____exports.Unit = __TS__Class()
|
|
653
676
|
local Unit = ____exports.Unit
|
|
654
677
|
Unit.name = "Unit"
|
|
655
678
|
__TS__ClassExtends(Unit, Handle)
|
|
656
679
|
function Unit.prototype.____constructor(self, handle)
|
|
657
680
|
Handle.prototype.____constructor(self, handle)
|
|
658
|
-
local
|
|
659
|
-
nextSyncId =
|
|
660
|
-
self.syncId =
|
|
681
|
+
local ____nextSyncId_1 = nextSyncId
|
|
682
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
683
|
+
self.syncId = ____nextSyncId_1
|
|
661
684
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
662
685
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
663
686
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -758,17 +781,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
758
781
|
end}
|
|
759
782
|
end
|
|
760
783
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
761
|
-
local
|
|
762
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
784
|
+
local ____combatClassification_2 = combatClassification
|
|
785
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
763
786
|
end
|
|
764
787
|
function Unit.prototype.addClassification(self, classification)
|
|
765
|
-
return
|
|
788
|
+
return UnitAddType(self.handle, classification)
|
|
766
789
|
end
|
|
767
790
|
function Unit.prototype.removeClassification(self, classification)
|
|
768
|
-
return
|
|
791
|
+
return UnitRemoveType(self.handle, classification)
|
|
769
792
|
end
|
|
770
793
|
function Unit.prototype.hasClassification(self, classification)
|
|
771
|
-
return
|
|
794
|
+
return IsUnitType(self.handle, classification)
|
|
772
795
|
end
|
|
773
796
|
function Unit.prototype.isVisibleTo(self, player)
|
|
774
797
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -777,13 +800,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
777
800
|
return isUnitInvisible(self.handle, player.handle)
|
|
778
801
|
end
|
|
779
802
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
780
|
-
local
|
|
803
|
+
local ____temp_3
|
|
781
804
|
if type(x) == "number" then
|
|
782
|
-
|
|
805
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
783
806
|
else
|
|
784
|
-
|
|
807
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
785
808
|
end
|
|
786
|
-
return
|
|
809
|
+
return ____temp_3
|
|
787
810
|
end
|
|
788
811
|
function Unit.prototype.isAllyOf(self, unit)
|
|
789
812
|
return isUnitAlly(
|
|
@@ -812,6 +835,15 @@ end
|
|
|
812
835
|
function Unit.prototype.queueAnimation(self, animation)
|
|
813
836
|
QueueUnitAnimation(self.handle, animation)
|
|
814
837
|
end
|
|
838
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
839
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
840
|
+
return self.firstWeapon
|
|
841
|
+
end
|
|
842
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
843
|
+
return self.secondWeapon
|
|
844
|
+
end
|
|
845
|
+
return nil
|
|
846
|
+
end
|
|
815
847
|
function Unit.prototype.delayHealthChecks(self)
|
|
816
848
|
self[103] = (self[103] or 0) + 1
|
|
817
849
|
Timer:run(delayHealthChecksCallback, self)
|
|
@@ -830,14 +862,14 @@ function Unit.prototype.kill(self)
|
|
|
830
862
|
killUnit(self.handle)
|
|
831
863
|
end
|
|
832
864
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
833
|
-
local
|
|
834
|
-
local
|
|
835
|
-
local
|
|
836
|
-
if
|
|
837
|
-
|
|
865
|
+
local ____ReviveHero_6 = ReviveHero
|
|
866
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
867
|
+
local ____doEffect_4 = doEffect
|
|
868
|
+
if ____doEffect_4 == nil then
|
|
869
|
+
____doEffect_4 = false
|
|
838
870
|
end
|
|
839
|
-
__TS__SparseArrayPush(
|
|
840
|
-
|
|
871
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
872
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
841
873
|
end
|
|
842
874
|
function Unit.prototype.healTarget(self, target, amount)
|
|
843
875
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -880,17 +912,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
880
912
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
881
913
|
end
|
|
882
914
|
function Unit.prototype.addAbility(self, abilityId)
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
915
|
+
local ability = UnitAbility:of(
|
|
916
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
917
|
+
abilityId,
|
|
918
|
+
self
|
|
919
|
+
)
|
|
920
|
+
if ability ~= nil then
|
|
889
921
|
local abilities = self.abilities
|
|
890
922
|
abilities[#abilities + 1] = ability
|
|
891
|
-
return ability
|
|
892
923
|
end
|
|
893
|
-
return
|
|
924
|
+
return ability
|
|
894
925
|
end
|
|
895
926
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
896
927
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -905,19 +936,11 @@ function Unit.prototype.hasAbility(self, abilityId)
|
|
|
905
936
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
906
937
|
end
|
|
907
938
|
function Unit.prototype.getAbilityById(self, abilityId)
|
|
908
|
-
local
|
|
909
|
-
|
|
910
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
911
|
-
return nil
|
|
912
|
-
end
|
|
913
|
-
return UnitAbility:of(
|
|
914
|
-
getUnitAbility(self.handle, abilityId),
|
|
915
|
-
abilityId,
|
|
916
|
-
self
|
|
917
|
-
)
|
|
939
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
918
941
|
end
|
|
919
942
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
920
|
-
if
|
|
943
|
+
if doUnitAbilityAction(self.handle, abilityId, unitRemoveAbility, abilityId) then
|
|
921
944
|
local abilities = self.abilities
|
|
922
945
|
for i = 1, #abilities do
|
|
923
946
|
if abilities[i].typeId == abilityId then
|
|
@@ -942,6 +965,21 @@ end
|
|
|
942
965
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
943
966
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
944
967
|
end
|
|
968
|
+
function Unit.prototype.interruptMovement(self)
|
|
969
|
+
local handle = self.handle
|
|
970
|
+
unitDisableAbility(
|
|
971
|
+
handle,
|
|
972
|
+
fourCC("Amov"),
|
|
973
|
+
true,
|
|
974
|
+
false
|
|
975
|
+
)
|
|
976
|
+
unitDisableAbility(
|
|
977
|
+
handle,
|
|
978
|
+
fourCC("Amov"),
|
|
979
|
+
false,
|
|
980
|
+
false
|
|
981
|
+
)
|
|
982
|
+
end
|
|
945
983
|
function Unit.prototype.interruptAttack(self)
|
|
946
984
|
unitInterruptAttack(self.handle)
|
|
947
985
|
end
|
|
@@ -1215,7 +1253,7 @@ __TS__SetDescriptor(
|
|
|
1215
1253
|
Unit.prototype,
|
|
1216
1254
|
"isIllusion",
|
|
1217
1255
|
{get = function(self)
|
|
1218
|
-
return
|
|
1256
|
+
return IsUnitIllusion(self.handle)
|
|
1219
1257
|
end},
|
|
1220
1258
|
true
|
|
1221
1259
|
)
|
|
@@ -1438,13 +1476,13 @@ __TS__SetDescriptor(
|
|
|
1438
1476
|
end,
|
|
1439
1477
|
set = function(self, isTeamGlowVisible)
|
|
1440
1478
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1441
|
-
local
|
|
1479
|
+
local ____temp_7
|
|
1442
1480
|
if not isTeamGlowVisible then
|
|
1443
|
-
|
|
1481
|
+
____temp_7 = true
|
|
1444
1482
|
else
|
|
1445
|
-
|
|
1483
|
+
____temp_7 = nil
|
|
1446
1484
|
end
|
|
1447
|
-
self[106] =
|
|
1485
|
+
self[106] = ____temp_7
|
|
1448
1486
|
end
|
|
1449
1487
|
},
|
|
1450
1488
|
true
|
|
@@ -2191,25 +2229,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2191
2229
|
InitializingEvent,
|
|
2192
2230
|
function(event)
|
|
2193
2231
|
local function listener(unit, id)
|
|
2194
|
-
local
|
|
2232
|
+
local ____GetSpellTargetUnit_result_10
|
|
2195
2233
|
if GetSpellTargetUnit() then
|
|
2196
|
-
|
|
2234
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2197
2235
|
else
|
|
2198
|
-
local
|
|
2236
|
+
local ____GetSpellTargetItem_result_9
|
|
2199
2237
|
if GetSpellTargetItem() then
|
|
2200
|
-
|
|
2238
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2201
2239
|
else
|
|
2202
|
-
local
|
|
2240
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2203
2241
|
if GetSpellTargetDestructable() then
|
|
2204
|
-
|
|
2242
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2205
2243
|
else
|
|
2206
|
-
|
|
2244
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2207
2245
|
end
|
|
2208
|
-
|
|
2246
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2209
2247
|
end
|
|
2210
|
-
|
|
2248
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2211
2249
|
end
|
|
2212
|
-
local target =
|
|
2250
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2213
2251
|
if target then
|
|
2214
2252
|
invoke(event, unit, id, target)
|
|
2215
2253
|
end
|
|
@@ -2428,7 +2466,8 @@ Unit.onDamaging = (function()
|
|
|
2428
2466
|
metadata = metadata,
|
|
2429
2467
|
isAttack = BlzGetEventIsAttack(),
|
|
2430
2468
|
originalAmount = GetEventDamage(),
|
|
2431
|
-
originalMetadata = metadata
|
|
2469
|
+
originalMetadata = metadata,
|
|
2470
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2432
2471
|
}
|
|
2433
2472
|
if data.isAttack and source then
|
|
2434
2473
|
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
|
|
@@ -2457,6 +2496,20 @@ Unit.onDamaging = (function()
|
|
|
2457
2496
|
}
|
|
2458
2497
|
)
|
|
2459
2498
|
)
|
|
2499
|
+
if data[0] and source then
|
|
2500
|
+
local sourceOwner = source.owner.handle
|
|
2501
|
+
data[1] = sourceOwner
|
|
2502
|
+
local targetOwner = target.owner.handle
|
|
2503
|
+
data[2] = targetOwner
|
|
2504
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2505
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2506
|
+
data[3] = true
|
|
2507
|
+
end
|
|
2508
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2509
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2510
|
+
data[4] = true
|
|
2511
|
+
end
|
|
2512
|
+
end
|
|
2460
2513
|
damagingEventByTarget[target] = data
|
|
2461
2514
|
return
|
|
2462
2515
|
end
|
|
@@ -2540,6 +2593,16 @@ Unit.onDamage = __TS__New(
|
|
|
2540
2593
|
data[key] = value
|
|
2541
2594
|
end
|
|
2542
2595
|
end
|
|
2596
|
+
local sourceOwner = damagingEvent[1]
|
|
2597
|
+
if sourceOwner then
|
|
2598
|
+
local targetOwner = damagingEvent[2]
|
|
2599
|
+
if damagingEvent[3] then
|
|
2600
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2601
|
+
end
|
|
2602
|
+
if damagingEvent[4] then
|
|
2603
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2604
|
+
end
|
|
2605
|
+
end
|
|
2543
2606
|
end
|
|
2544
2607
|
local evData = setmetatable(
|
|
2545
2608
|
{},
|
|
@@ -2632,6 +2695,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2632
2695
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2633
2696
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2634
2697
|
)
|
|
2698
|
+
__TS__ObjectDefineProperty(
|
|
2699
|
+
Unit,
|
|
2700
|
+
"itemChargesChangedEvent",
|
|
2701
|
+
{get = function(self)
|
|
2702
|
+
local event = __TS__New(Event)
|
|
2703
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2704
|
+
local unit = item.owner
|
|
2705
|
+
if unit ~= nil then
|
|
2706
|
+
invoke(event, unit, item)
|
|
2707
|
+
end
|
|
2708
|
+
end)
|
|
2709
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2710
|
+
return event
|
|
2711
|
+
end}
|
|
2712
|
+
)
|
|
2635
2713
|
__TS__ObjectDefineProperty(
|
|
2636
2714
|
Unit,
|
|
2637
2715
|
"itemUseOrderEvent",
|
|
@@ -4,6 +4,7 @@ import { ObjectField, ObjectLevelField, ObjectLevelFieldValueChangeEvent, Readon
|
|
|
4
4
|
import { UnitType, UnitTypeId } from "../object-data/entry/unit-type";
|
|
5
5
|
import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
|
|
6
6
|
import { AttackType } from "../object-data/auxiliary/attack-type";
|
|
7
|
+
import { UnitClassifications } from "../object-data/auxiliary/unit-classification";
|
|
7
8
|
export declare abstract class UnitField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = any> extends ObjectField<UnitType, Unit, ValueType, NativeFieldType> {
|
|
8
9
|
protected get instanceClass(): typeof Unit;
|
|
9
10
|
protected getObjectDataEntryId(instance: Unit): UnitTypeId;
|
|
@@ -56,4 +57,14 @@ export declare abstract class UnitEnumWeaponField<T extends number> extends Unit
|
|
|
56
57
|
export declare class UnitAttackTypeWeaponField extends UnitEnumWeaponField<AttackType> {
|
|
57
58
|
protected values: ReadonlyNonEmptyLinkedSet<AttackType>;
|
|
58
59
|
}
|
|
60
|
+
export declare class UnitClassificationsField extends UnitField<UnitClassifications, junitintegerfield> {
|
|
61
|
+
protected get defaultValue(): UnitClassifications;
|
|
62
|
+
protected getNativeFieldById(id: number): junitintegerfield;
|
|
63
|
+
protected getNativeFieldValue(instance: Unit): UnitClassifications;
|
|
64
|
+
protected setNativeFieldValue(instance: Unit, value: UnitClassifications): boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare class UnitPropulsionWindowField extends UnitFloatField {
|
|
67
|
+
protected getNativeFieldValue(instance: Unit): number;
|
|
68
|
+
protected setNativeFieldValue(instance: Unit, value: number): boolean;
|
|
69
|
+
}
|
|
59
70
|
export {};
|
|
@@ -18,6 +18,8 @@ local convertUnitStringField = ConvertUnitStringField
|
|
|
18
18
|
local convertUnitWeaponIntegerField = ConvertUnitWeaponIntegerField
|
|
19
19
|
local getUnitWeaponIntegerField = BlzGetUnitWeaponIntegerField
|
|
20
20
|
local setUnitWeaponIntegerField = BlzSetUnitWeaponIntegerField
|
|
21
|
+
local getUnitPropulsionWindow = GetUnitPropWindow
|
|
22
|
+
local setUnitPropulsionWindow = SetUnitPropWindow
|
|
21
23
|
____exports.UnitField = __TS__Class()
|
|
22
24
|
local UnitField = ____exports.UnitField
|
|
23
25
|
UnitField.name = "UnitField"
|
|
@@ -215,4 +217,36 @@ function UnitAttackTypeWeaponField.prototype.____constructor(self, ...)
|
|
|
215
217
|
6
|
|
216
218
|
)
|
|
217
219
|
end
|
|
220
|
+
____exports.UnitClassificationsField = __TS__Class()
|
|
221
|
+
local UnitClassificationsField = ____exports.UnitClassificationsField
|
|
222
|
+
UnitClassificationsField.name = "UnitClassificationsField"
|
|
223
|
+
__TS__ClassExtends(UnitClassificationsField, ____exports.UnitField)
|
|
224
|
+
function UnitClassificationsField.prototype.getNativeFieldById(self, id)
|
|
225
|
+
return convertUnitIntegerField(id)
|
|
226
|
+
end
|
|
227
|
+
function UnitClassificationsField.prototype.getNativeFieldValue(self, instance)
|
|
228
|
+
return instance:getField(self.nativeField)
|
|
229
|
+
end
|
|
230
|
+
function UnitClassificationsField.prototype.setNativeFieldValue(self, instance, value)
|
|
231
|
+
return instance:setField(self.nativeField, value)
|
|
232
|
+
end
|
|
233
|
+
__TS__SetDescriptor(
|
|
234
|
+
UnitClassificationsField.prototype,
|
|
235
|
+
"defaultValue",
|
|
236
|
+
{get = function(self)
|
|
237
|
+
return 0
|
|
238
|
+
end},
|
|
239
|
+
true
|
|
240
|
+
)
|
|
241
|
+
____exports.UnitPropulsionWindowField = __TS__Class()
|
|
242
|
+
local UnitPropulsionWindowField = ____exports.UnitPropulsionWindowField
|
|
243
|
+
UnitPropulsionWindowField.name = "UnitPropulsionWindowField"
|
|
244
|
+
__TS__ClassExtends(UnitPropulsionWindowField, ____exports.UnitFloatField)
|
|
245
|
+
function UnitPropulsionWindowField.prototype.getNativeFieldValue(self, instance)
|
|
246
|
+
return getUnitPropulsionWindow(instance.handle)
|
|
247
|
+
end
|
|
248
|
+
function UnitPropulsionWindowField.prototype.setNativeFieldValue(self, instance, value)
|
|
249
|
+
setUnitPropulsionWindow(instance.handle, value)
|
|
250
|
+
return true
|
|
251
|
+
end
|
|
218
252
|
return ____exports
|
package/engine/object-field.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ import { ObjectDataEntry, ObjectDataEntryIdType, ObjectDataEntryLevelFieldValueS
|
|
|
5
5
|
export type ObjectFieldId = number & {
|
|
6
6
|
readonly __objectDataEntryFieldId: unique symbol;
|
|
7
7
|
};
|
|
8
|
-
export type ObjectFieldConstructor<T extends ObjectFieldBase<any, any, any, any>> = OmitConstructor<typeof ObjectFieldBase> & (new (id: number) => T);
|
|
8
|
+
export type ObjectFieldConstructor<T extends ObjectFieldBase<any, any, any, any>> = OmitConstructor<typeof ObjectFieldBase> & (new (id: number, isGlobal?: boolean) => T);
|
|
9
9
|
export type ObjectFieldAbstractConstructor<T extends ObjectFieldBase<any, any, any, any>> = OmitConstructor<typeof ObjectFieldBase> & (abstract new (id: number) => T);
|
|
10
10
|
declare abstract class ObjectFieldBase<ObjectDataEntryType extends ObjectDataEntry, InstanceType extends AnyNotNil, ValueType, NativeFieldType> {
|
|
11
|
+
readonly isGlobal: boolean;
|
|
11
12
|
protected abstract readonly instanceClass: AbstractConstructor<InstanceType> | Function;
|
|
12
13
|
supports(instance: AnyNotNil): instance is InstanceType & {
|
|
13
14
|
readonly __oneSidedTypeGuard: unique symbol;
|
|
@@ -18,8 +19,8 @@ declare abstract class ObjectFieldBase<ObjectDataEntryType extends ObjectDataEnt
|
|
|
18
19
|
protected abstract getObjectDataEntryId(instance: InstanceType): ObjectDataEntryIdType<ObjectDataEntryType>;
|
|
19
20
|
protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
|
|
20
21
|
hasValue(instance: InstanceType): boolean;
|
|
21
|
-
constructor(id: number);
|
|
22
|
-
static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number): T & symbol;
|
|
22
|
+
constructor(id: number, isGlobal?: boolean);
|
|
23
|
+
static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number, isGlobal?: boolean): T & symbol;
|
|
23
24
|
static of<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldAbstractConstructor<T>, id: number): T | undefined;
|
|
24
25
|
}
|
|
25
26
|
export type ObjectFieldValueChangeEvent<T extends ObjectField<any, any, any, any> | ReadonlyObjectFieldType<ObjectField<any, any, any, any>>> = T extends ObjectField<any, infer InstanceType, infer ValueType, any> ? DispatchingEvent<[
|
|
@@ -79,6 +80,8 @@ export declare abstract class ObjectArrayField<ObjectDataEntryType extends Objec
|
|
|
79
80
|
setValue(entry: ObjectDataEntryType | InstanceType, value: ValueType[]): boolean;
|
|
80
81
|
}
|
|
81
82
|
export declare abstract class ObjectLevelField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, InputValueType extends ValueType = never, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType[], NativeFieldType> {
|
|
83
|
+
private originalValueByLevelByInstance?;
|
|
84
|
+
private modifiersByInstance?;
|
|
82
85
|
protected abstract readonly defaultValue: ValueType;
|
|
83
86
|
protected abstract getNativeFieldValue(instance: InstanceType, level: number): ValueType;
|
|
84
87
|
protected abstract setNativeFieldValue(instance: InstanceType, level: number, value: ValueType): boolean;
|