warscript 0.0.1-dev.91a4dce → 0.0.1-dev.91da42b
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/player.d.ts +2 -1
- package/core/types/player.lua +24 -12
- package/core/types/tileCell.d.ts +2 -1
- package/core/types/tileCell.lua +5 -0
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +10 -2
- package/engine/behavior.lua +157 -76
- package/engine/behaviour/ability/apply-buff.lua +4 -4
- package/engine/behaviour/ability.d.ts +2 -1
- package/engine/behaviour/ability.lua +2 -1
- package/engine/behaviour/unit/stun-immunity.d.ts +6 -4
- package/engine/behaviour/unit/stun-immunity.lua +1 -1
- package/engine/behaviour/unit.d.ts +7 -3
- package/engine/behaviour/unit.lua +89 -22
- package/engine/buff.d.ts +15 -2
- package/engine/buff.lua +95 -17
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +10 -0
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit-missile-launch.lua +16 -6
- package/engine/internal/unit.d.ts +12 -18
- package/engine/internal/unit.lua +68 -116
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -0
- package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/destructible-type.d.ts +27 -1
- package/engine/object-data/entry/destructible-type.lua +155 -0
- package/engine/object-data/entry/unit-type.d.ts +4 -0
- package/engine/object-data/entry/unit-type.lua +76 -32
- package/engine/object-field/unit.d.ts +20 -5
- package/engine/object-field/unit.lua +61 -0
- package/engine/object-field.d.ts +9 -1
- package/engine/object-field.lua +265 -122
- package/engine/standard/fields/ability.d.ts +2 -2
- package/engine/standard/fields/ability.lua +2 -2
- package/engine/standard/fields/unit.d.ts +11 -3
- package/engine/standard/fields/unit.lua +15 -2
- package/engine/text-tag.lua +2 -1
- package/engine/unit.d.ts +4 -0
- package/engine/unit.lua +4 -0
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____unit = require("engine.internal.unit")
|
|
5
|
+
local Unit = ____unit.Unit
|
|
6
|
+
local ____unit = require("engine.standard.fields.unit")
|
|
7
|
+
local FLY_HEIGHT_UNIT_FIELD = ____unit.FLY_HEIGHT_UNIT_FIELD
|
|
8
|
+
__TS__ObjectDefineProperty(
|
|
9
|
+
Unit.prototype,
|
|
10
|
+
"flyHeight",
|
|
11
|
+
{
|
|
12
|
+
get = function(self)
|
|
13
|
+
return FLY_HEIGHT_UNIT_FIELD:getValue(self)
|
|
14
|
+
end,
|
|
15
|
+
set = function(self, value)
|
|
16
|
+
FLY_HEIGHT_UNIT_FIELD:setValue(self, value)
|
|
17
|
+
end
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
return ____exports
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____unit = require("engine.internal.unit")
|
|
3
|
+
local Unit = ____unit.Unit
|
|
4
|
+
local ____unit_2Dmissile_2Dlaunch = require("engine.internal.unit-missile-launch")
|
|
5
|
+
local resetAutoAttackTimer = ____unit_2Dmissile_2Dlaunch.resetAutoAttackTimer
|
|
6
|
+
local unitDisableAbility = BlzUnitDisableAbility
|
|
7
|
+
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
8
|
+
Unit.prototype.interruptAttack = function(self)
|
|
9
|
+
unitInterruptAttack(self.handle)
|
|
10
|
+
resetAutoAttackTimer(self)
|
|
11
|
+
end
|
|
12
|
+
Unit.prototype.interruptMovement = function(self)
|
|
13
|
+
local handle = self.handle
|
|
14
|
+
unitDisableAbility(
|
|
15
|
+
handle,
|
|
16
|
+
fourCC("Amov"),
|
|
17
|
+
true,
|
|
18
|
+
false
|
|
19
|
+
)
|
|
20
|
+
unitDisableAbility(
|
|
21
|
+
handle,
|
|
22
|
+
fourCC("Amov"),
|
|
23
|
+
false,
|
|
24
|
+
false
|
|
25
|
+
)
|
|
26
|
+
resetAutoAttackTimer(self)
|
|
27
|
+
end
|
|
28
|
+
return ____exports
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____unit = require("engine.internal.unit")
|
|
5
|
+
local Unit = ____unit.Unit
|
|
6
|
+
local ____unit = require("engine.standard.fields.unit")
|
|
7
|
+
local SCALING_VALUE_UNIT_FIELD = ____unit.SCALING_VALUE_UNIT_FIELD
|
|
8
|
+
__TS__ObjectDefineProperty(
|
|
9
|
+
Unit.prototype,
|
|
10
|
+
"scale",
|
|
11
|
+
{
|
|
12
|
+
get = function(self)
|
|
13
|
+
return SCALING_VALUE_UNIT_FIELD:getValue(self)
|
|
14
|
+
end,
|
|
15
|
+
set = function(self, value)
|
|
16
|
+
SCALING_VALUE_UNIT_FIELD:setValue(self, value)
|
|
17
|
+
end
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
return ____exports
|
|
@@ -13,6 +13,8 @@ local ____attributes = require("attributes")
|
|
|
13
13
|
local attribute = ____attributes.attribute
|
|
14
14
|
local ____linked_2Dset = require("utility.linked-set")
|
|
15
15
|
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
16
|
+
local ____math = require("math")
|
|
17
|
+
local ceil = ____math.ceil
|
|
16
18
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
17
19
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
18
20
|
local units = __TS__New(LinkedSet)
|
|
@@ -34,11 +36,18 @@ local instantOrderIds = luaSetOf(
|
|
|
34
36
|
orderId("undivineshield"),
|
|
35
37
|
orderId("unimmolation")
|
|
36
38
|
)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
---
|
|
40
|
+
-- @internal For use by internal systems only.
|
|
41
|
+
____exports.resetAutoAttackTimer = function(unit)
|
|
42
|
+
if units:remove(unit) then
|
|
43
|
+
unit[targetAttribute] = nil
|
|
44
|
+
unit[impactDelayAttribute] = nil
|
|
45
|
+
unit[passedTimeAttribute] = nil
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
local function reset(unit, orderId)
|
|
49
|
+
if not (instantOrderIds[orderId] ~= nil) then
|
|
50
|
+
____exports.resetAutoAttackTimer(unit)
|
|
42
51
|
end
|
|
43
52
|
end
|
|
44
53
|
Unit.onImmediateOrder:addListener(reset)
|
|
@@ -55,7 +64,8 @@ local function invokeEvent(unit)
|
|
|
55
64
|
end
|
|
56
65
|
local function checkUnit(unit)
|
|
57
66
|
local passedTime = unit[passedTimeAttribute] + timerPeriod
|
|
58
|
-
|
|
67
|
+
local impactDelay = unit[impactDelayAttribute]
|
|
68
|
+
if passedTime >= impactDelay and ceil(passedTime / 0.02) >= ceil(impactDelay / 0.02) then
|
|
59
69
|
invokeEvent(unit)
|
|
60
70
|
else
|
|
61
71
|
unit[passedTimeAttribute] = passedTime
|
|
@@ -109,12 +109,13 @@ declare const enum UnitPropertyKey {
|
|
|
109
109
|
SYNC_ID = 100,
|
|
110
110
|
IS_PAUSED = 101,
|
|
111
111
|
STUN_COUNTER = 102,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
118
119
|
}
|
|
119
120
|
export type UnitSyncId = number & {
|
|
120
121
|
readonly __unitSyncId: unique symbol;
|
|
@@ -123,6 +124,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
123
124
|
readonly syncId: UnitSyncId;
|
|
124
125
|
private [UnitPropertyKey.IS_PAUSED]?;
|
|
125
126
|
private [UnitPropertyKey.STUN_COUNTER]?;
|
|
127
|
+
private [UnitPropertyKey.FORCE_STUN_COUNTER]?;
|
|
126
128
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
|
|
127
129
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
|
|
128
130
|
private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
|
|
@@ -175,16 +177,10 @@ export declare class Unit extends Handle<junit> {
|
|
|
175
177
|
set xp(v: number);
|
|
176
178
|
get primaryAttribute(): UnitAttribute;
|
|
177
179
|
set primaryAttribute(primaryAttribute: UnitAttribute);
|
|
178
|
-
get strengthBase(): number;
|
|
179
|
-
set strengthBase(strengthBase: number);
|
|
180
180
|
get strengthBonus(): number;
|
|
181
181
|
get strength(): number;
|
|
182
|
-
get agilityBase(): number;
|
|
183
|
-
set agilityBase(agilityBase: number);
|
|
184
182
|
get agilityBonus(): number;
|
|
185
183
|
get agility(): number;
|
|
186
|
-
get intelligenceBase(): number;
|
|
187
|
-
set intelligenceBase(intelligenceBase: number);
|
|
188
184
|
get intelligenceBonus(): number;
|
|
189
185
|
get intelligence(): number;
|
|
190
186
|
get name(): string;
|
|
@@ -218,8 +214,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
218
214
|
set facing(v: number);
|
|
219
215
|
get speed(): number;
|
|
220
216
|
set speed(v: number);
|
|
221
|
-
get flyHeight(): number;
|
|
222
|
-
set flyHeight(v: number);
|
|
223
217
|
get x(): number;
|
|
224
218
|
set x(v: number);
|
|
225
219
|
get y(): number;
|
|
@@ -243,8 +237,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
243
237
|
get isInvulnerable(): boolean;
|
|
244
238
|
get vertexColor(): Color;
|
|
245
239
|
set vertexColor(v: Color);
|
|
246
|
-
get scale(): number;
|
|
247
|
-
set scale(v: number);
|
|
248
240
|
get timeScale(): number;
|
|
249
241
|
set timeScale(v: number);
|
|
250
242
|
get collisionSize(): number;
|
|
@@ -279,8 +271,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
279
271
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
280
272
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
281
273
|
endAbilityCooldown(abilityId: number): void;
|
|
282
|
-
interruptMovement(): void;
|
|
283
|
-
interruptAttack(): void;
|
|
284
274
|
interruptCast(abilityId: number): void;
|
|
285
275
|
getDistanceTo(target: Unit | Vec2): number;
|
|
286
276
|
getCollisionDistanceTo(...target: [Unit] | [targetX: number, targetY: number]): number;
|
|
@@ -294,6 +284,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
294
284
|
unpauseEx(): void;
|
|
295
285
|
incrementStunCounter(): void;
|
|
296
286
|
decrementStunCounter(): void;
|
|
287
|
+
incrementForceStunCounter(): void;
|
|
288
|
+
decrementForceStunCounter(): void;
|
|
297
289
|
set waygateActive(v: boolean);
|
|
298
290
|
get waygateActive(): boolean;
|
|
299
291
|
set waygateDestination(v: Vec2);
|
|
@@ -318,6 +310,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
318
310
|
static getInCollisionRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
|
|
319
311
|
static getInSector(pos: Vec2, range: number, offsetAngle: number, centralAngle: number): Unit[];
|
|
320
312
|
static getSelectionOf(player: Player, target?: Unit[]): Unit[];
|
|
313
|
+
static readonly levelChangedEvent: UnitTriggerEvent<[]>;
|
|
321
314
|
static readonly deathEvent: UnitTriggerEvent<[Unit]>;
|
|
322
315
|
static readonly onDecay: UnitTriggerEvent<[]>;
|
|
323
316
|
static readonly onResurrect: InitializingEvent<[Unit], void>;
|
|
@@ -375,5 +368,6 @@ export declare class Unit extends Handle<junit> {
|
|
|
375
368
|
setField(field: junitstringfield, value: string): boolean;
|
|
376
369
|
toString(): string;
|
|
377
370
|
static getBySyncId(syncId: UnitSyncId): Unit | undefined;
|
|
371
|
+
static synchronize: (player: Player, object: Unit | undefined) => Promise<Unit | undefined>;
|
|
378
372
|
}
|
|
379
373
|
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
|
|
@@ -71,16 +73,12 @@ local getUnitRealField = BlzGetUnitRealField
|
|
|
71
73
|
local getHeroStr = GetHeroStr
|
|
72
74
|
local getHeroAgi = GetHeroAgi
|
|
73
75
|
local getHeroInt = GetHeroInt
|
|
74
|
-
local setHeroStr = SetHeroStr
|
|
75
|
-
local setHeroAgi = SetHeroAgi
|
|
76
|
-
local setHeroInt = SetHeroInt
|
|
77
76
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
78
77
|
local getUnitStringField = BlzGetUnitStringField
|
|
79
78
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
80
79
|
local setUnitRealField = BlzSetUnitRealField
|
|
81
80
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
82
81
|
local setUnitStringField = BlzSetUnitStringField
|
|
83
|
-
local setUnitScale = SetUnitScale
|
|
84
82
|
local setUnitPosition = SetUnitPosition
|
|
85
83
|
local setUnitTimeScale = SetUnitTimeScale
|
|
86
84
|
local getHandleId = GetHandleId
|
|
@@ -108,7 +106,6 @@ local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
|
108
106
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
109
107
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
110
108
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
111
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
112
109
|
local isUnitInvisible = IsUnitInvisible
|
|
113
110
|
local isUnitVisible = IsUnitVisible
|
|
114
111
|
local getUnitX = GetUnitX
|
|
@@ -657,15 +654,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
657
654
|
dummies[player] = dummy
|
|
658
655
|
end
|
|
659
656
|
local function delayHealthChecksCallback(unit)
|
|
660
|
-
local counter = (unit[
|
|
657
|
+
local counter = (unit[104] or 0) - 1
|
|
661
658
|
if counter ~= 0 then
|
|
662
|
-
unit[
|
|
659
|
+
unit[104] = counter
|
|
663
660
|
return
|
|
664
661
|
end
|
|
665
|
-
unit[
|
|
666
|
-
local healthBonus = unit[
|
|
662
|
+
unit[104] = nil
|
|
663
|
+
local healthBonus = unit[105]
|
|
667
664
|
if healthBonus ~= nil then
|
|
668
|
-
unit[
|
|
665
|
+
unit[105] = nil
|
|
669
666
|
local handle = unit.handle
|
|
670
667
|
BlzSetUnitMaxHP(
|
|
671
668
|
handle,
|
|
@@ -725,8 +722,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
725
722
|
end
|
|
726
723
|
function Unit.prototype.onDestroy(self)
|
|
727
724
|
local handle = self.handle
|
|
728
|
-
self[
|
|
729
|
-
self[
|
|
725
|
+
self[108] = getUnitX(handle)
|
|
726
|
+
self[109] = getUnitY(handle)
|
|
730
727
|
if not self._owner then
|
|
731
728
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
732
729
|
end
|
|
@@ -860,7 +857,7 @@ function Unit.prototype.chooseWeapon(self, target)
|
|
|
860
857
|
return nil
|
|
861
858
|
end
|
|
862
859
|
function Unit.prototype.delayHealthChecks(self)
|
|
863
|
-
self[
|
|
860
|
+
self[104] = (self[104] or 0) + 1
|
|
864
861
|
Timer:run(delayHealthChecksCallback, self)
|
|
865
862
|
end
|
|
866
863
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -978,24 +975,6 @@ end
|
|
|
978
975
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
979
976
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
980
977
|
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
|
|
996
|
-
function Unit.prototype.interruptAttack(self)
|
|
997
|
-
unitInterruptAttack(self.handle)
|
|
998
|
-
end
|
|
999
978
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
1000
979
|
local handle = self.handle
|
|
1001
980
|
unitDisableAbility(handle, abilityId, true, false)
|
|
@@ -1066,18 +1045,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1066
1045
|
end
|
|
1067
1046
|
function Unit.prototype.incrementStunCounter(self)
|
|
1068
1047
|
local stunCounter = self[102] or 0
|
|
1069
|
-
if not self[101] or stunCounter >= 0 then
|
|
1048
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1070
1049
|
BlzPauseUnitEx(self.handle, true)
|
|
1071
1050
|
end
|
|
1072
1051
|
self[102] = stunCounter + 1
|
|
1073
1052
|
end
|
|
1074
1053
|
function Unit.prototype.decrementStunCounter(self)
|
|
1075
1054
|
local stunCounter = self[102] or 0
|
|
1076
|
-
if not self[101] or stunCounter >= 1 then
|
|
1055
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1077
1056
|
BlzPauseUnitEx(self.handle, false)
|
|
1078
1057
|
end
|
|
1079
1058
|
self[102] = stunCounter - 1
|
|
1080
1059
|
end
|
|
1060
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1061
|
+
local forceStunCounter = self[103] or 0
|
|
1062
|
+
if forceStunCounter == 0 then
|
|
1063
|
+
local handle = self.handle
|
|
1064
|
+
if not self[101] then
|
|
1065
|
+
for _ = self[102] or 0, -1 do
|
|
1066
|
+
BlzPauseUnitEx(handle, true)
|
|
1067
|
+
end
|
|
1068
|
+
end
|
|
1069
|
+
BlzPauseUnitEx(handle, true)
|
|
1070
|
+
end
|
|
1071
|
+
self[103] = forceStunCounter + 1
|
|
1072
|
+
end
|
|
1073
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1074
|
+
local forceStunCounter = self[103] or 0
|
|
1075
|
+
if forceStunCounter == 1 then
|
|
1076
|
+
local handle = self.handle
|
|
1077
|
+
if not self[101] then
|
|
1078
|
+
for _ = self[102] or 0, -1 do
|
|
1079
|
+
BlzPauseUnitEx(handle, false)
|
|
1080
|
+
end
|
|
1081
|
+
end
|
|
1082
|
+
BlzPauseUnitEx(handle, false)
|
|
1083
|
+
end
|
|
1084
|
+
self[103] = forceStunCounter - 1
|
|
1085
|
+
end
|
|
1081
1086
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1082
1087
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1083
1088
|
owner.handle,
|
|
@@ -1364,19 +1369,6 @@ __TS__SetDescriptor(
|
|
|
1364
1369
|
},
|
|
1365
1370
|
true
|
|
1366
1371
|
)
|
|
1367
|
-
__TS__SetDescriptor(
|
|
1368
|
-
Unit.prototype,
|
|
1369
|
-
"strengthBase",
|
|
1370
|
-
{
|
|
1371
|
-
get = function(self)
|
|
1372
|
-
return getHeroStr(self.handle, false)
|
|
1373
|
-
end,
|
|
1374
|
-
set = function(self, strengthBase)
|
|
1375
|
-
setHeroStr(self.handle, strengthBase, true)
|
|
1376
|
-
end
|
|
1377
|
-
},
|
|
1378
|
-
true
|
|
1379
|
-
)
|
|
1380
1372
|
__TS__SetDescriptor(
|
|
1381
1373
|
Unit.prototype,
|
|
1382
1374
|
"strengthBonus",
|
|
@@ -1394,19 +1386,6 @@ __TS__SetDescriptor(
|
|
|
1394
1386
|
end},
|
|
1395
1387
|
true
|
|
1396
1388
|
)
|
|
1397
|
-
__TS__SetDescriptor(
|
|
1398
|
-
Unit.prototype,
|
|
1399
|
-
"agilityBase",
|
|
1400
|
-
{
|
|
1401
|
-
get = function(self)
|
|
1402
|
-
return getHeroAgi(self.handle, false)
|
|
1403
|
-
end,
|
|
1404
|
-
set = function(self, agilityBase)
|
|
1405
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1406
|
-
end
|
|
1407
|
-
},
|
|
1408
|
-
true
|
|
1409
|
-
)
|
|
1410
1389
|
__TS__SetDescriptor(
|
|
1411
1390
|
Unit.prototype,
|
|
1412
1391
|
"agilityBonus",
|
|
@@ -1424,19 +1403,6 @@ __TS__SetDescriptor(
|
|
|
1424
1403
|
end},
|
|
1425
1404
|
true
|
|
1426
1405
|
)
|
|
1427
|
-
__TS__SetDescriptor(
|
|
1428
|
-
Unit.prototype,
|
|
1429
|
-
"intelligenceBase",
|
|
1430
|
-
{
|
|
1431
|
-
get = function(self)
|
|
1432
|
-
return getHeroInt(self.handle, false)
|
|
1433
|
-
end,
|
|
1434
|
-
set = function(self, intelligenceBase)
|
|
1435
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1436
|
-
end
|
|
1437
|
-
},
|
|
1438
|
-
true
|
|
1439
|
-
)
|
|
1440
1406
|
__TS__SetDescriptor(
|
|
1441
1407
|
Unit.prototype,
|
|
1442
1408
|
"intelligenceBonus",
|
|
@@ -1485,7 +1451,7 @@ __TS__SetDescriptor(
|
|
|
1485
1451
|
"isTeamGlowVisible",
|
|
1486
1452
|
{
|
|
1487
1453
|
get = function(self)
|
|
1488
|
-
return not self[
|
|
1454
|
+
return not self[107]
|
|
1489
1455
|
end,
|
|
1490
1456
|
set = function(self, isTeamGlowVisible)
|
|
1491
1457
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
@@ -1495,7 +1461,7 @@ __TS__SetDescriptor(
|
|
|
1495
1461
|
else
|
|
1496
1462
|
____temp_7 = nil
|
|
1497
1463
|
end
|
|
1498
|
-
self[
|
|
1464
|
+
self[107] = ____temp_7
|
|
1499
1465
|
end
|
|
1500
1466
|
},
|
|
1501
1467
|
true
|
|
@@ -1505,7 +1471,7 @@ __TS__SetDescriptor(
|
|
|
1505
1471
|
"color",
|
|
1506
1472
|
{set = function(self, color)
|
|
1507
1473
|
SetUnitColor(self.handle, color.handle)
|
|
1508
|
-
if self[
|
|
1474
|
+
if self[107] then
|
|
1509
1475
|
BlzShowUnitTeamGlow(self.handle, false)
|
|
1510
1476
|
end
|
|
1511
1477
|
end},
|
|
@@ -1529,14 +1495,14 @@ __TS__SetDescriptor(
|
|
|
1529
1495
|
"maxHealth",
|
|
1530
1496
|
{
|
|
1531
1497
|
get = function(self)
|
|
1532
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1498
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1533
1499
|
end,
|
|
1534
1500
|
set = function(self, maxHealth)
|
|
1535
|
-
if maxHealth < 1 and self[
|
|
1536
|
-
self[
|
|
1501
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1502
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1537
1503
|
maxHealth = 1
|
|
1538
1504
|
end
|
|
1539
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1505
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1540
1506
|
end
|
|
1541
1507
|
},
|
|
1542
1508
|
true
|
|
@@ -1578,10 +1544,10 @@ __TS__SetDescriptor(
|
|
|
1578
1544
|
"health",
|
|
1579
1545
|
{
|
|
1580
1546
|
get = function(self)
|
|
1581
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1547
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1582
1548
|
end,
|
|
1583
1549
|
set = function(self, health)
|
|
1584
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1550
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1585
1551
|
end
|
|
1586
1552
|
},
|
|
1587
1553
|
true
|
|
@@ -1657,25 +1623,12 @@ __TS__SetDescriptor(
|
|
|
1657
1623
|
},
|
|
1658
1624
|
true
|
|
1659
1625
|
)
|
|
1660
|
-
__TS__SetDescriptor(
|
|
1661
|
-
Unit.prototype,
|
|
1662
|
-
"flyHeight",
|
|
1663
|
-
{
|
|
1664
|
-
get = function(self)
|
|
1665
|
-
return getUnitFlyHeight(self.handle)
|
|
1666
|
-
end,
|
|
1667
|
-
set = function(self, v)
|
|
1668
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1669
|
-
end
|
|
1670
|
-
},
|
|
1671
|
-
true
|
|
1672
|
-
)
|
|
1673
1626
|
__TS__SetDescriptor(
|
|
1674
1627
|
Unit.prototype,
|
|
1675
1628
|
"x",
|
|
1676
1629
|
{
|
|
1677
1630
|
get = function(self)
|
|
1678
|
-
return self[
|
|
1631
|
+
return self[108] or getUnitX(self.handle)
|
|
1679
1632
|
end,
|
|
1680
1633
|
set = function(self, v)
|
|
1681
1634
|
SetUnitX(self.handle, v)
|
|
@@ -1688,7 +1641,7 @@ __TS__SetDescriptor(
|
|
|
1688
1641
|
"y",
|
|
1689
1642
|
{
|
|
1690
1643
|
get = function(self)
|
|
1691
|
-
return self[
|
|
1644
|
+
return self[109] or getUnitY(self.handle)
|
|
1692
1645
|
end,
|
|
1693
1646
|
set = function(self, v)
|
|
1694
1647
|
SetUnitY(self.handle, v)
|
|
@@ -1793,14 +1746,18 @@ __TS__SetDescriptor(
|
|
|
1793
1746
|
local handle = self.handle
|
|
1794
1747
|
if isPaused and not IsUnitPaused(handle) then
|
|
1795
1748
|
self[101] = true
|
|
1796
|
-
|
|
1797
|
-
|
|
1749
|
+
if (self[103] or 0) <= 0 then
|
|
1750
|
+
for _ = self[102] or 0, -1 do
|
|
1751
|
+
BlzPauseUnitEx(handle, true)
|
|
1752
|
+
end
|
|
1798
1753
|
end
|
|
1799
1754
|
PauseUnit(handle, true)
|
|
1800
1755
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1801
1756
|
PauseUnit(handle, false)
|
|
1802
|
-
|
|
1803
|
-
|
|
1757
|
+
if (self[103] or 0) <= 0 then
|
|
1758
|
+
for _ = self[102] or 0, -1 do
|
|
1759
|
+
BlzPauseUnitEx(handle, false)
|
|
1760
|
+
end
|
|
1804
1761
|
end
|
|
1805
1762
|
self[101] = nil
|
|
1806
1763
|
end
|
|
@@ -1858,20 +1815,6 @@ __TS__SetDescriptor(
|
|
|
1858
1815
|
},
|
|
1859
1816
|
true
|
|
1860
1817
|
)
|
|
1861
|
-
__TS__SetDescriptor(
|
|
1862
|
-
Unit.prototype,
|
|
1863
|
-
"scale",
|
|
1864
|
-
{
|
|
1865
|
-
get = function(self)
|
|
1866
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1867
|
-
end,
|
|
1868
|
-
set = function(self, v)
|
|
1869
|
-
setUnitScale(self.handle, v, v, v)
|
|
1870
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1871
|
-
end
|
|
1872
|
-
},
|
|
1873
|
-
true
|
|
1874
|
-
)
|
|
1875
1818
|
__TS__SetDescriptor(
|
|
1876
1819
|
Unit.prototype,
|
|
1877
1820
|
"timeScale",
|
|
@@ -2167,6 +2110,11 @@ __TS__SetDescriptor(
|
|
|
2167
2110
|
end},
|
|
2168
2111
|
true
|
|
2169
2112
|
)
|
|
2113
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2114
|
+
____exports.UnitTriggerEvent,
|
|
2115
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2116
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2117
|
+
)
|
|
2170
2118
|
Unit.deathEvent = __TS__New(
|
|
2171
2119
|
____exports.UnitTriggerEvent,
|
|
2172
2120
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2628,7 +2576,7 @@ Unit.onDamage = __TS__New(
|
|
|
2628
2576
|
invoke(event, source, target, evData)
|
|
2629
2577
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2630
2578
|
local bonusHealth = math.ceil(evData.amount)
|
|
2631
|
-
target[
|
|
2579
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2632
2580
|
BlzSetUnitMaxHP(
|
|
2633
2581
|
target.handle,
|
|
2634
2582
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2642,7 +2590,7 @@ Unit.onDamage = __TS__New(
|
|
|
2642
2590
|
evData[0],
|
|
2643
2591
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2644
2592
|
)
|
|
2645
|
-
target[
|
|
2593
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2646
2594
|
SetWidgetLife(
|
|
2647
2595
|
target.handle,
|
|
2648
2596
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2792,6 +2740,10 @@ __TS__ObjectDefineProperty(
|
|
|
2792
2740
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2793
2741
|
return destroyEvent
|
|
2794
2742
|
end}
|
|
2743
|
+
)
|
|
2744
|
+
Unit.synchronize = synchronizer(
|
|
2745
|
+
function(unit) return unit.syncId end,
|
|
2746
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2795
2747
|
);
|
|
2796
2748
|
(function(self)
|
|
2797
2749
|
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, flashy?: boolean] | [color: Color, flashy?: 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, greenOrFlashy, blue, flashy)
|
|
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
|
+
greenOrFlashy or false
|
|
82
|
+
)
|
|
83
|
+
else
|
|
84
|
+
pingMinimapEx(
|
|
85
|
+
x,
|
|
86
|
+
y,
|
|
87
|
+
duration,
|
|
88
|
+
redOrColor,
|
|
89
|
+
greenOrFlashy,
|
|
90
|
+
blue,
|
|
91
|
+
flashy or false
|
|
92
|
+
)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
65
95
|
LocalClient.locale = getLocale()
|
|
66
96
|
__TS__ObjectDefineProperty(
|
|
67
97
|
LocalClient,
|