warscript 0.0.1-dev.3370e98 → 0.0.1-dev.352d2b1
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 +1 -0
- package/attributes.lua +9 -0
- package/core/types/frame.lua +14 -9
- package/core/types/player.d.ts +15 -0
- package/core/types/player.lua +53 -13
- package/core/types/playerCamera.lua +44 -0
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +3 -2
- package/core/types/timer.lua +22 -2
- package/decl/native.d.ts +2 -2
- package/engine/behavior.d.ts +3 -0
- package/engine/behavior.lua +53 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/unit/stun-immunity.d.ts +2 -0
- package/engine/behaviour/unit/stun-immunity.lua +11 -2
- package/engine/behaviour/unit.d.ts +8 -2
- package/engine/behaviour/unit.lua +29 -2
- package/engine/buff.d.ts +10 -4
- package/engine/buff.lua +116 -84
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +26 -9
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +63 -49
- package/engine/internal/unit/ability.d.ts +14 -14
- package/engine/internal/unit/ability.lua +72 -45
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit+ability.lua +9 -0
- package/engine/internal/unit-missile-launch.lua +44 -20
- package/engine/internal/unit.d.ts +16 -11
- package/engine/internal/unit.lua +94 -63
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -0
- package/engine/object-data/entry/ability-type.lua +4 -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 +4 -0
- package/engine/object-field/unit.lua +13 -0
- package/engine/object-field.d.ts +9 -3
- package/engine/object-field.lua +198 -115
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/fields/unit.d.ts +2 -1
- package/engine/standard/fields/unit.lua +2 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.lua +3 -2
- 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/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/types.d.ts +3 -0
|
@@ -9,11 +9,18 @@ local ____timer = require("core.types.timer")
|
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
10
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
11
|
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
12
|
+
local ____attributes = require("attributes")
|
|
13
|
+
local attribute = ____attributes.attribute
|
|
14
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
15
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
12
16
|
local ____math = require("math")
|
|
13
|
-
local
|
|
17
|
+
local ceil = ____math.ceil
|
|
14
18
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
15
19
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
16
|
-
local
|
|
20
|
+
local units = __TS__New(LinkedSet)
|
|
21
|
+
local targetAttribute = attribute()
|
|
22
|
+
local impactDelayAttribute = attribute()
|
|
23
|
+
local passedTimeAttribute = attribute()
|
|
17
24
|
local instantOrderIds = luaSetOf(
|
|
18
25
|
orderId("avatar"),
|
|
19
26
|
orderId("berserk"),
|
|
@@ -30,29 +37,46 @@ local instantOrderIds = luaSetOf(
|
|
|
30
37
|
orderId("unimmolation")
|
|
31
38
|
)
|
|
32
39
|
local function reset(source, orderId)
|
|
33
|
-
if not (instantOrderIds[orderId] ~= nil) then
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
eventTimerByUnit[source] = nil
|
|
38
|
-
end
|
|
40
|
+
if not (instantOrderIds[orderId] ~= nil) and units:remove(source) then
|
|
41
|
+
source[targetAttribute] = nil
|
|
42
|
+
source[impactDelayAttribute] = nil
|
|
43
|
+
source[passedTimeAttribute] = nil
|
|
39
44
|
end
|
|
40
45
|
end
|
|
41
46
|
Unit.onImmediateOrder:addListener(reset)
|
|
42
47
|
Unit.onPointOrder:addListener(reset)
|
|
43
48
|
Unit.onTargetOrder:addListener(reset)
|
|
44
|
-
local
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
local timerPeriod = 1 / 64
|
|
50
|
+
local function invokeEvent(unit)
|
|
51
|
+
units:remove(unit)
|
|
52
|
+
local target = unit[targetAttribute]
|
|
53
|
+
unit[targetAttribute] = nil
|
|
54
|
+
unit[impactDelayAttribute] = nil
|
|
55
|
+
unit[passedTimeAttribute] = nil
|
|
56
|
+
Event.invoke(autoAttackFinishEvent, unit, target)
|
|
57
|
+
end
|
|
58
|
+
local function checkUnit(unit)
|
|
59
|
+
local passedTime = unit[passedTimeAttribute] + timerPeriod
|
|
60
|
+
local impactDelay = unit[impactDelayAttribute]
|
|
61
|
+
if passedTime >= impactDelay and ceil(passedTime / 0.02) >= ceil(impactDelay / 0.02) then
|
|
62
|
+
invokeEvent(unit)
|
|
63
|
+
else
|
|
64
|
+
unit[passedTimeAttribute] = passedTime
|
|
65
|
+
end
|
|
47
66
|
end
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
local timer = Timer:simple(
|
|
51
|
-
attackPoint + min(0.001, attackPoint / 2),
|
|
52
|
-
timerCallback,
|
|
53
|
-
source,
|
|
54
|
-
target
|
|
55
|
-
)
|
|
56
|
-
eventTimerByUnit[source] = timer
|
|
67
|
+
Timer.onPeriod[timerPeriod]:addListener(function()
|
|
68
|
+
units:forEach(checkUnit)
|
|
57
69
|
end)
|
|
70
|
+
Unit.autoAttackStartEvent:addListener(
|
|
71
|
+
999999,
|
|
72
|
+
function(source, target)
|
|
73
|
+
if source[targetAttribute] ~= nil then
|
|
74
|
+
invokeEvent(source)
|
|
75
|
+
end
|
|
76
|
+
source[targetAttribute] = target
|
|
77
|
+
source[impactDelayAttribute] = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
78
|
+
source[passedTimeAttribute] = -timerPeriod
|
|
79
|
+
units:add(source)
|
|
80
|
+
end
|
|
81
|
+
)
|
|
58
82
|
return ____exports
|
|
@@ -80,6 +80,8 @@ export declare class UnitWeapon {
|
|
|
80
80
|
readonly unit: Unit;
|
|
81
81
|
readonly index: 0 | 1;
|
|
82
82
|
constructor(unit: Unit, index: 0 | 1);
|
|
83
|
+
get isEnabled(): boolean;
|
|
84
|
+
set isEnabled(isEnabled: boolean);
|
|
83
85
|
get cooldown(): number;
|
|
84
86
|
set cooldown(cooldown: number);
|
|
85
87
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
|
@@ -107,12 +109,13 @@ declare const enum UnitPropertyKey {
|
|
|
107
109
|
SYNC_ID = 100,
|
|
108
110
|
IS_PAUSED = 101,
|
|
109
111
|
STUN_COUNTER = 102,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
FORCE_STUN_COUNTER = 103,
|
|
113
|
+
DELAY_HEALTH_CHECKS_COUNTER = 104,
|
|
114
|
+
DELAY_HEALTH_CHECKS_HEALTH_BONUS = 105,
|
|
115
|
+
PREVENT_DEATH_HEALTH_BONUS = 106,
|
|
116
|
+
IS_TEAM_GLOW_HIDDEN = 107,
|
|
117
|
+
LAST_X = 108,
|
|
118
|
+
LAST_Y = 109
|
|
116
119
|
}
|
|
117
120
|
export type UnitSyncId = number & {
|
|
118
121
|
readonly __unitSyncId: unique symbol;
|
|
@@ -121,6 +124,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
121
124
|
readonly syncId: UnitSyncId;
|
|
122
125
|
private [UnitPropertyKey.IS_PAUSED]?;
|
|
123
126
|
private [UnitPropertyKey.STUN_COUNTER]?;
|
|
127
|
+
private [UnitPropertyKey.FORCE_STUN_COUNTER]?;
|
|
124
128
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
|
|
125
129
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
|
|
126
130
|
private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
|
|
@@ -216,8 +220,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
216
220
|
set facing(v: number);
|
|
217
221
|
get speed(): number;
|
|
218
222
|
set speed(v: number);
|
|
219
|
-
get flyHeight(): number;
|
|
220
|
-
set flyHeight(v: number);
|
|
221
223
|
get x(): number;
|
|
222
224
|
set x(v: number);
|
|
223
225
|
get y(): number;
|
|
@@ -271,8 +273,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
271
273
|
setAbilityLevel(abilityId: number, level: number): number;
|
|
272
274
|
getAbilityLevel(abilityId: number): number;
|
|
273
275
|
hasAbility(abilityId: number): boolean;
|
|
274
|
-
|
|
275
|
-
removeAbility(
|
|
276
|
+
getAbility(abilityId: number): UnitAbility | undefined;
|
|
277
|
+
removeAbility(abilityTypeId: number): boolean;
|
|
276
278
|
hideAbility(abilityId: number, flag: boolean): void;
|
|
277
279
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
278
280
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
@@ -292,6 +294,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
292
294
|
unpauseEx(): void;
|
|
293
295
|
incrementStunCounter(): void;
|
|
294
296
|
decrementStunCounter(): void;
|
|
297
|
+
incrementForceStunCounter(): void;
|
|
298
|
+
decrementForceStunCounter(): void;
|
|
295
299
|
set waygateActive(v: boolean);
|
|
296
300
|
get waygateActive(): boolean;
|
|
297
301
|
set waygateDestination(v: Vec2);
|
|
@@ -353,7 +357,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
353
357
|
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
354
358
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
355
359
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
356
|
-
static itemStackedEvent: UnitTriggerEvent<[
|
|
360
|
+
static itemStackedEvent: UnitTriggerEvent<[target: Item, source: Item]>;
|
|
357
361
|
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
358
362
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
359
363
|
static get itemMoveOrderEvent(): Event<[
|
|
@@ -373,5 +377,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
373
377
|
setField(field: junitstringfield, value: string): boolean;
|
|
374
378
|
toString(): string;
|
|
375
379
|
static getBySyncId(syncId: UnitSyncId): Unit | undefined;
|
|
380
|
+
static synchronize: (player: Player, object: Unit | undefined) => Promise<Unit | undefined>;
|
|
376
381
|
}
|
|
377
382
|
export {};
|
package/engine/internal/unit.lua
CHANGED
|
@@ -62,6 +62,8 @@ local ____attributes = require("attributes")
|
|
|
62
62
|
local isAttribute = ____attributes.isAttribute
|
|
63
63
|
local ____ability = require("engine.internal.item.ability")
|
|
64
64
|
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
65
|
+
local ____synchronization = require("engine.synchronization")
|
|
66
|
+
local synchronizer = ____synchronization.synchronizer
|
|
65
67
|
local match = string.match
|
|
66
68
|
local ____tostring = _G.tostring
|
|
67
69
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -410,6 +412,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
410
412
|
self.unit = unit
|
|
411
413
|
self.index = index
|
|
412
414
|
end
|
|
415
|
+
__TS__SetDescriptor(
|
|
416
|
+
UnitWeapon.prototype,
|
|
417
|
+
"isEnabled",
|
|
418
|
+
{
|
|
419
|
+
get = function(self)
|
|
420
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
421
|
+
end,
|
|
422
|
+
set = function(self, isEnabled)
|
|
423
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
424
|
+
end
|
|
425
|
+
},
|
|
426
|
+
true
|
|
427
|
+
)
|
|
413
428
|
__TS__SetDescriptor(
|
|
414
429
|
UnitWeapon.prototype,
|
|
415
430
|
"cooldown",
|
|
@@ -644,15 +659,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
644
659
|
dummies[player] = dummy
|
|
645
660
|
end
|
|
646
661
|
local function delayHealthChecksCallback(unit)
|
|
647
|
-
local counter = (unit[
|
|
662
|
+
local counter = (unit[104] or 0) - 1
|
|
648
663
|
if counter ~= 0 then
|
|
649
|
-
unit[
|
|
664
|
+
unit[104] = counter
|
|
650
665
|
return
|
|
651
666
|
end
|
|
652
|
-
unit[
|
|
653
|
-
local healthBonus = unit[
|
|
667
|
+
unit[104] = nil
|
|
668
|
+
local healthBonus = unit[105]
|
|
654
669
|
if healthBonus ~= nil then
|
|
655
|
-
unit[
|
|
670
|
+
unit[105] = nil
|
|
656
671
|
local handle = unit.handle
|
|
657
672
|
BlzSetUnitMaxHP(
|
|
658
673
|
handle,
|
|
@@ -712,8 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
712
727
|
end
|
|
713
728
|
function Unit.prototype.onDestroy(self)
|
|
714
729
|
local handle = self.handle
|
|
715
|
-
self[
|
|
716
|
-
self[
|
|
730
|
+
self[108] = getUnitX(handle)
|
|
731
|
+
self[109] = getUnitY(handle)
|
|
717
732
|
if not self._owner then
|
|
718
733
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
719
734
|
end
|
|
@@ -836,16 +851,18 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
836
851
|
QueueUnitAnimation(self.handle, animation)
|
|
837
852
|
end
|
|
838
853
|
function Unit.prototype.chooseWeapon(self, target)
|
|
839
|
-
|
|
840
|
-
|
|
854
|
+
local firstWeapon = self.firstWeapon
|
|
855
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
856
|
+
return firstWeapon
|
|
841
857
|
end
|
|
842
|
-
|
|
843
|
-
|
|
858
|
+
local secondWeapon = self.secondWeapon
|
|
859
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
860
|
+
return secondWeapon
|
|
844
861
|
end
|
|
845
862
|
return nil
|
|
846
863
|
end
|
|
847
864
|
function Unit.prototype.delayHealthChecks(self)
|
|
848
|
-
self[
|
|
865
|
+
self[104] = (self[104] or 0) + 1
|
|
849
866
|
Timer:run(delayHealthChecksCallback, self)
|
|
850
867
|
end
|
|
851
868
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -935,23 +952,21 @@ end
|
|
|
935
952
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
936
953
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
937
954
|
end
|
|
938
|
-
function Unit.prototype.
|
|
955
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
939
956
|
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
957
|
return UnitAbility:of(ability, abilityId, self)
|
|
941
958
|
end
|
|
942
|
-
function Unit.prototype.removeAbility(self,
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
end
|
|
959
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
960
|
+
local abilities = self.abilities
|
|
961
|
+
for i = 1, #abilities do
|
|
962
|
+
if abilities[i].typeId == abilityTypeId then
|
|
963
|
+
local ability = abilities[i]
|
|
964
|
+
tremove(abilities, i)
|
|
965
|
+
ability:destroy()
|
|
966
|
+
return true
|
|
951
967
|
end
|
|
952
|
-
return true
|
|
953
968
|
end
|
|
954
|
-
return
|
|
969
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
955
970
|
end
|
|
956
971
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
957
972
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -1053,18 +1068,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1053
1068
|
end
|
|
1054
1069
|
function Unit.prototype.incrementStunCounter(self)
|
|
1055
1070
|
local stunCounter = self[102] or 0
|
|
1056
|
-
if not self[101] or stunCounter >= 0 then
|
|
1071
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1057
1072
|
BlzPauseUnitEx(self.handle, true)
|
|
1058
1073
|
end
|
|
1059
1074
|
self[102] = stunCounter + 1
|
|
1060
1075
|
end
|
|
1061
1076
|
function Unit.prototype.decrementStunCounter(self)
|
|
1062
1077
|
local stunCounter = self[102] or 0
|
|
1063
|
-
if not self[101] or stunCounter >= 1 then
|
|
1078
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1064
1079
|
BlzPauseUnitEx(self.handle, false)
|
|
1065
1080
|
end
|
|
1066
1081
|
self[102] = stunCounter - 1
|
|
1067
1082
|
end
|
|
1083
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1084
|
+
local forceStunCounter = self[103] or 0
|
|
1085
|
+
if forceStunCounter == 0 then
|
|
1086
|
+
local handle = self.handle
|
|
1087
|
+
if not self[101] then
|
|
1088
|
+
for _ = self[102] or 0, -1 do
|
|
1089
|
+
BlzPauseUnitEx(handle, true)
|
|
1090
|
+
end
|
|
1091
|
+
end
|
|
1092
|
+
BlzPauseUnitEx(handle, true)
|
|
1093
|
+
end
|
|
1094
|
+
self[103] = forceStunCounter + 1
|
|
1095
|
+
end
|
|
1096
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1097
|
+
local forceStunCounter = self[103] or 0
|
|
1098
|
+
if forceStunCounter == 1 then
|
|
1099
|
+
local handle = self.handle
|
|
1100
|
+
if not self[101] then
|
|
1101
|
+
for _ = self[102] or 0, -1 do
|
|
1102
|
+
BlzPauseUnitEx(handle, false)
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
BlzPauseUnitEx(handle, false)
|
|
1106
|
+
end
|
|
1107
|
+
self[103] = forceStunCounter - 1
|
|
1108
|
+
end
|
|
1068
1109
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1069
1110
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1070
1111
|
owner.handle,
|
|
@@ -1472,7 +1513,7 @@ __TS__SetDescriptor(
|
|
|
1472
1513
|
"isTeamGlowVisible",
|
|
1473
1514
|
{
|
|
1474
1515
|
get = function(self)
|
|
1475
|
-
return not self[
|
|
1516
|
+
return not self[107]
|
|
1476
1517
|
end,
|
|
1477
1518
|
set = function(self, isTeamGlowVisible)
|
|
1478
1519
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
@@ -1482,7 +1523,7 @@ __TS__SetDescriptor(
|
|
|
1482
1523
|
else
|
|
1483
1524
|
____temp_7 = nil
|
|
1484
1525
|
end
|
|
1485
|
-
self[
|
|
1526
|
+
self[107] = ____temp_7
|
|
1486
1527
|
end
|
|
1487
1528
|
},
|
|
1488
1529
|
true
|
|
@@ -1492,7 +1533,7 @@ __TS__SetDescriptor(
|
|
|
1492
1533
|
"color",
|
|
1493
1534
|
{set = function(self, color)
|
|
1494
1535
|
SetUnitColor(self.handle, color.handle)
|
|
1495
|
-
if self[
|
|
1536
|
+
if self[107] then
|
|
1496
1537
|
BlzShowUnitTeamGlow(self.handle, false)
|
|
1497
1538
|
end
|
|
1498
1539
|
end},
|
|
@@ -1516,14 +1557,14 @@ __TS__SetDescriptor(
|
|
|
1516
1557
|
"maxHealth",
|
|
1517
1558
|
{
|
|
1518
1559
|
get = function(self)
|
|
1519
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1560
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1520
1561
|
end,
|
|
1521
1562
|
set = function(self, maxHealth)
|
|
1522
|
-
if maxHealth < 1 and self[
|
|
1523
|
-
self[
|
|
1563
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1564
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1524
1565
|
maxHealth = 1
|
|
1525
1566
|
end
|
|
1526
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1567
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1527
1568
|
end
|
|
1528
1569
|
},
|
|
1529
1570
|
true
|
|
@@ -1565,10 +1606,10 @@ __TS__SetDescriptor(
|
|
|
1565
1606
|
"health",
|
|
1566
1607
|
{
|
|
1567
1608
|
get = function(self)
|
|
1568
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1609
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1569
1610
|
end,
|
|
1570
1611
|
set = function(self, health)
|
|
1571
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1612
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1572
1613
|
end
|
|
1573
1614
|
},
|
|
1574
1615
|
true
|
|
@@ -1644,25 +1685,12 @@ __TS__SetDescriptor(
|
|
|
1644
1685
|
},
|
|
1645
1686
|
true
|
|
1646
1687
|
)
|
|
1647
|
-
__TS__SetDescriptor(
|
|
1648
|
-
Unit.prototype,
|
|
1649
|
-
"flyHeight",
|
|
1650
|
-
{
|
|
1651
|
-
get = function(self)
|
|
1652
|
-
return getUnitFlyHeight(self.handle)
|
|
1653
|
-
end,
|
|
1654
|
-
set = function(self, v)
|
|
1655
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1656
|
-
end
|
|
1657
|
-
},
|
|
1658
|
-
true
|
|
1659
|
-
)
|
|
1660
1688
|
__TS__SetDescriptor(
|
|
1661
1689
|
Unit.prototype,
|
|
1662
1690
|
"x",
|
|
1663
1691
|
{
|
|
1664
1692
|
get = function(self)
|
|
1665
|
-
return self[
|
|
1693
|
+
return self[108] or getUnitX(self.handle)
|
|
1666
1694
|
end,
|
|
1667
1695
|
set = function(self, v)
|
|
1668
1696
|
SetUnitX(self.handle, v)
|
|
@@ -1675,7 +1703,7 @@ __TS__SetDescriptor(
|
|
|
1675
1703
|
"y",
|
|
1676
1704
|
{
|
|
1677
1705
|
get = function(self)
|
|
1678
|
-
return self[
|
|
1706
|
+
return self[109] or getUnitY(self.handle)
|
|
1679
1707
|
end,
|
|
1680
1708
|
set = function(self, v)
|
|
1681
1709
|
SetUnitY(self.handle, v)
|
|
@@ -1780,14 +1808,18 @@ __TS__SetDescriptor(
|
|
|
1780
1808
|
local handle = self.handle
|
|
1781
1809
|
if isPaused and not IsUnitPaused(handle) then
|
|
1782
1810
|
self[101] = true
|
|
1783
|
-
|
|
1784
|
-
|
|
1811
|
+
if (self[103] or 0) <= 0 then
|
|
1812
|
+
for _ = self[102] or 0, -1 do
|
|
1813
|
+
BlzPauseUnitEx(handle, true)
|
|
1814
|
+
end
|
|
1785
1815
|
end
|
|
1786
1816
|
PauseUnit(handle, true)
|
|
1787
1817
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1788
1818
|
PauseUnit(handle, false)
|
|
1789
|
-
|
|
1790
|
-
|
|
1819
|
+
if (self[103] or 0) <= 0 then
|
|
1820
|
+
for _ = self[102] or 0, -1 do
|
|
1821
|
+
BlzPauseUnitEx(handle, false)
|
|
1822
|
+
end
|
|
1791
1823
|
end
|
|
1792
1824
|
self[101] = nil
|
|
1793
1825
|
end
|
|
@@ -2470,12 +2502,7 @@ Unit.onDamaging = (function()
|
|
|
2470
2502
|
preventRetaliation = damagingEventPreventRetaliation
|
|
2471
2503
|
}
|
|
2472
2504
|
if data.isAttack and source then
|
|
2473
|
-
|
|
2474
|
-
if weapon == -1 then
|
|
2475
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2476
|
-
weapon = 0
|
|
2477
|
-
end
|
|
2478
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2505
|
+
data.weapon = source:chooseWeapon(target)
|
|
2479
2506
|
end
|
|
2480
2507
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2481
2508
|
invoke(
|
|
@@ -2620,7 +2647,7 @@ Unit.onDamage = __TS__New(
|
|
|
2620
2647
|
invoke(event, source, target, evData)
|
|
2621
2648
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2622
2649
|
local bonusHealth = math.ceil(evData.amount)
|
|
2623
|
-
target[
|
|
2650
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2624
2651
|
BlzSetUnitMaxHP(
|
|
2625
2652
|
target.handle,
|
|
2626
2653
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2634,7 +2661,7 @@ Unit.onDamage = __TS__New(
|
|
|
2634
2661
|
evData[0],
|
|
2635
2662
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2636
2663
|
)
|
|
2637
|
-
target[
|
|
2664
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2638
2665
|
SetWidgetLife(
|
|
2639
2666
|
target.handle,
|
|
2640
2667
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2697,7 +2724,7 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2697
2724
|
Unit.itemStackedEvent = __TS__New(
|
|
2698
2725
|
____exports.UnitTriggerEvent,
|
|
2699
2726
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2700
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2727
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2701
2728
|
)
|
|
2702
2729
|
__TS__ObjectDefineProperty(
|
|
2703
2730
|
Unit,
|
|
@@ -2784,6 +2811,10 @@ __TS__ObjectDefineProperty(
|
|
|
2784
2811
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2785
2812
|
return destroyEvent
|
|
2786
2813
|
end}
|
|
2814
|
+
)
|
|
2815
|
+
Unit.synchronize = synchronizer(
|
|
2816
|
+
function(unit) return unit.syncId end,
|
|
2817
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2787
2818
|
);
|
|
2788
2819
|
(function(self)
|
|
2789
2820
|
local leaveAbilityIds = postcompile(function()
|
package/engine/local-client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Unit } from "../core/types/unit";
|
|
|
3
3
|
import { Async } from "../core/types/async";
|
|
4
4
|
import { Event, TriggerEvent } from "../event";
|
|
5
5
|
import { GraphicsMode } from "./index";
|
|
6
|
+
import { Color } from "../core/types/color";
|
|
6
7
|
export declare class LocalClient {
|
|
7
8
|
private constructor();
|
|
8
9
|
static readonly locale: string;
|
|
@@ -11,6 +12,7 @@ export declare class LocalClient {
|
|
|
11
12
|
static get isHD(): boolean;
|
|
12
13
|
static get graphicsMode(): GraphicsMode;
|
|
13
14
|
static get isActive(): boolean;
|
|
15
|
+
static pingMinimap(x: number, y: number, duration: number, ...parameters: [] | [red: number, green: number, blue: number, extraEffects?: boolean] | [color: Color, extraEffects?: boolean]): void;
|
|
14
16
|
static get mouseFocusUnit(): Async<Unit> | undefined;
|
|
15
17
|
static get mainSelectedUnit(): Async<Unit> | undefined;
|
|
16
18
|
static get mainSelectedUnitChangeEvent(): Event<[
|
package/engine/local-client.lua
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
3
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
5
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
5
6
|
local __TS__New = ____lualib.__TS__New
|
|
6
7
|
local ____exports = {}
|
|
@@ -15,6 +16,8 @@ local ____player = require("core.types.player")
|
|
|
15
16
|
local Player = ____player.Player
|
|
16
17
|
local ____timer = require("core.types.timer")
|
|
17
18
|
local Timer = ____timer.Timer
|
|
19
|
+
local ____color = require("core.types.color")
|
|
20
|
+
local Color = ____color.Color
|
|
18
21
|
local loadTOCFile = BlzLoadTOCFile
|
|
19
22
|
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
20
23
|
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
@@ -25,6 +28,8 @@ local getMouseFocusUnit = BlzGetMouseFocusUnit
|
|
|
25
28
|
local getUnitRealField = BlzGetUnitRealField
|
|
26
29
|
local getUnitTypeId = GetUnitTypeId
|
|
27
30
|
local getLocale = BlzGetLocale
|
|
31
|
+
local pingMinimap = PingMinimap
|
|
32
|
+
local pingMinimapEx = PingMinimapEx
|
|
28
33
|
local tableSort = table.sort
|
|
29
34
|
local tocPath = "_warscript\\IsHD.toc"
|
|
30
35
|
compiletime(function()
|
|
@@ -62,6 +67,31 @@ local LocalClient = ____exports.LocalClient
|
|
|
62
67
|
LocalClient.name = "LocalClient"
|
|
63
68
|
function LocalClient.prototype.____constructor(self)
|
|
64
69
|
end
|
|
70
|
+
function LocalClient.pingMinimap(self, x, y, duration, redOrColor, greenOrExtraEffects, blue, extraEffects)
|
|
71
|
+
if redOrColor == nil then
|
|
72
|
+
pingMinimap(x, y, duration)
|
|
73
|
+
elseif __TS__InstanceOf(redOrColor, Color) then
|
|
74
|
+
pingMinimapEx(
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
duration,
|
|
78
|
+
redOrColor.r,
|
|
79
|
+
redOrColor.g,
|
|
80
|
+
redOrColor.b,
|
|
81
|
+
greenOrExtraEffects or false
|
|
82
|
+
)
|
|
83
|
+
else
|
|
84
|
+
pingMinimapEx(
|
|
85
|
+
x,
|
|
86
|
+
y,
|
|
87
|
+
duration,
|
|
88
|
+
redOrColor,
|
|
89
|
+
greenOrExtraEffects,
|
|
90
|
+
blue,
|
|
91
|
+
extraEffects or false
|
|
92
|
+
)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
65
95
|
LocalClient.locale = getLocale()
|
|
66
96
|
__TS__ObjectDefineProperty(
|
|
67
97
|
LocalClient,
|
|
@@ -38,6 +38,8 @@ local ____sound = require("core.types.sound")
|
|
|
38
38
|
local isSoundLabelCustom = ____sound.isSoundLabelCustom
|
|
39
39
|
local Sound3D = ____sound.Sound3D
|
|
40
40
|
local SoundSettings = ____sound.SoundSettings
|
|
41
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
42
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
41
43
|
local castAnimationFQNByAbilityTypeId = {}
|
|
42
44
|
local isButtonVisibleFalseAbilityTypes = {}
|
|
43
45
|
local casterCastingEffectPresetsByAbilityTypeId = {}
|
|
@@ -1004,9 +1006,10 @@ for abilityTypeId, soundPresetId in pairs(postcompile(function() return targetEf
|
|
|
1004
1006
|
)
|
|
1005
1007
|
end
|
|
1006
1008
|
end
|
|
1009
|
+
local unsupportedEffectSoundAbilityTypeIds = luaSetOf(fourCC("AAns"))
|
|
1007
1010
|
Unit.abilityChannelingStartEvent:addListener(function(caster, ability)
|
|
1008
1011
|
local soundPresetId = ability:getField(ABILITY_SF_EFFECT_SOUND)
|
|
1009
|
-
if isSoundLabelCustom(soundPresetId) then
|
|
1012
|
+
if isSoundLabelCustom(soundPresetId) or soundPresetId ~= "" and unsupportedEffectSoundAbilityTypeIds[ability.parentTypeId] ~= nil then
|
|
1010
1013
|
Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
|
|
1011
1014
|
end
|
|
1012
1015
|
end)
|
|
@@ -12,7 +12,7 @@ import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
|
|
|
12
12
|
export declare abstract class AbilityField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectField<AbilityType, Ability, ValueType, NativeFieldType> {
|
|
13
13
|
protected get instanceClass(): typeof Ability;
|
|
14
14
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
15
|
-
protected hasNativeFieldValue(
|
|
15
|
+
protected hasNativeFieldValue(abilityTypeId: AbilityTypeId): boolean;
|
|
16
16
|
static get valueChangeEvent(): ObjectFieldValueChangeEvent<ReadonlyObjectFieldType<AbilityField>>;
|
|
17
17
|
}
|
|
18
18
|
export declare class AbilityBooleanField extends AbilityField<boolean, jabilitybooleanfield> {
|
|
@@ -48,7 +48,7 @@ export declare class AbilityStringField extends AbilityField<string, jabilitystr
|
|
|
48
48
|
export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectArrayField<AbilityType, Ability, ValueType, NativeFieldType> {
|
|
49
49
|
protected get instanceClass(): typeof Ability;
|
|
50
50
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
51
|
-
protected hasNativeFieldValue(
|
|
51
|
+
protected hasNativeFieldValue(abilityTypeId: AbilityTypeId): boolean;
|
|
52
52
|
}
|
|
53
53
|
export declare class AbilityStringArrayField extends AbilityArrayField<string, jabilitystringlevelfield> {
|
|
54
54
|
protected get defaultValue(): string;
|
|
@@ -68,7 +68,7 @@ export declare abstract class AbilityLevelField<ValueType extends number | strin
|
|
|
68
68
|
protected get instanceClass(): typeof Ability;
|
|
69
69
|
protected getLevelCount(entry: AbilityType | Ability): number;
|
|
70
70
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
71
|
-
protected hasNativeFieldValue(
|
|
71
|
+
protected hasNativeFieldValue(abilityTypeId: AbilityTypeId): boolean;
|
|
72
72
|
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<ReadonlyObjectLevelFieldType<AbilityLevelField>>;
|
|
73
73
|
}
|
|
74
74
|
export declare class AbilityBooleanLevelField extends AbilityLevelField<boolean, boolean, jabilityintegerlevelfield> {
|
|
@@ -7,6 +7,7 @@ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
|
7
7
|
local ____exports = {}
|
|
8
8
|
local ____ability = require("engine.internal.ability")
|
|
9
9
|
local Ability = ____ability.Ability
|
|
10
|
+
local abilityTypeHasField = ____ability.abilityTypeHasField
|
|
10
11
|
local ____object_2Dfield = require("engine.object-field")
|
|
11
12
|
local ObjectArrayField = ____object_2Dfield.ObjectArrayField
|
|
12
13
|
local ObjectField = ____object_2Dfield.ObjectField
|
|
@@ -29,8 +30,8 @@ __TS__ClassExtends(AbilityField, ObjectField)
|
|
|
29
30
|
function AbilityField.prototype.getObjectDataEntryId(self, instance)
|
|
30
31
|
return instance.typeId
|
|
31
32
|
end
|
|
32
|
-
function AbilityField.prototype.hasNativeFieldValue(self,
|
|
33
|
-
return
|
|
33
|
+
function AbilityField.prototype.hasNativeFieldValue(self, abilityTypeId)
|
|
34
|
+
return abilityTypeHasField(abilityTypeId, self.nativeField)
|
|
34
35
|
end
|
|
35
36
|
__TS__SetDescriptor(
|
|
36
37
|
AbilityField.prototype,
|
|
@@ -197,8 +198,8 @@ __TS__ClassExtends(AbilityArrayField, ObjectArrayField)
|
|
|
197
198
|
function AbilityArrayField.prototype.getObjectDataEntryId(self, instance)
|
|
198
199
|
return instance.typeId
|
|
199
200
|
end
|
|
200
|
-
function AbilityArrayField.prototype.hasNativeFieldValue(self,
|
|
201
|
-
return
|
|
201
|
+
function AbilityArrayField.prototype.hasNativeFieldValue(self, abilityTypeId)
|
|
202
|
+
return abilityTypeHasField(abilityTypeId, self.nativeField)
|
|
202
203
|
end
|
|
203
204
|
__TS__SetDescriptor(
|
|
204
205
|
AbilityArrayField.prototype,
|
|
@@ -269,8 +270,8 @@ end
|
|
|
269
270
|
function AbilityLevelField.prototype.getObjectDataEntryId(self, instance)
|
|
270
271
|
return instance.typeId
|
|
271
272
|
end
|
|
272
|
-
function AbilityLevelField.prototype.hasNativeFieldValue(self,
|
|
273
|
-
return
|
|
273
|
+
function AbilityLevelField.prototype.hasNativeFieldValue(self, abilityTypeId)
|
|
274
|
+
return abilityTypeHasField(abilityTypeId, self.nativeField)
|
|
274
275
|
end
|
|
275
276
|
__TS__SetDescriptor(
|
|
276
277
|
AbilityLevelField.prototype,
|
|
@@ -63,6 +63,10 @@ export declare class UnitClassificationsField extends UnitField<UnitClassificati
|
|
|
63
63
|
protected getNativeFieldValue(instance: Unit): UnitClassifications;
|
|
64
64
|
protected setNativeFieldValue(instance: Unit, value: UnitClassifications): boolean;
|
|
65
65
|
}
|
|
66
|
+
export declare class UnitFlyHeightField extends UnitFloatField {
|
|
67
|
+
protected getNativeFieldValue(instance: Unit): number;
|
|
68
|
+
protected setNativeFieldValue(instance: Unit, value: number): boolean;
|
|
69
|
+
}
|
|
66
70
|
export declare class UnitPropulsionWindowField extends UnitFloatField {
|
|
67
71
|
protected getNativeFieldValue(instance: Unit): number;
|
|
68
72
|
protected setNativeFieldValue(instance: Unit, value: number): boolean;
|