warscript 0.0.1-dev.91a4dce → 0.0.1-dev.960a0ea

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.
@@ -64,7 +64,7 @@ export declare class Player extends Handle<jplayer> {
64
64
  setUpgradeLevel(upgradeId: UpgradeId, level: number): void;
65
65
  private static getEvent;
66
66
  private static getMouseEvent;
67
- static get allianceChangedEvent(): Event<[Player]>;
67
+ static get allianceChangedEvent(): Readonly<Record<PlayerAllianceType, Event<[Player]>>>;
68
68
  static get onLeave(): Event<[Player]>;
69
69
  static get onMouseDown(): Event<[Player, jmousebuttontype]>;
70
70
  static get onMouseUp(): Event<[Player, jmousebuttontype]>;
@@ -23,6 +23,8 @@ local ____math = require("math")
23
23
  local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
24
24
  local ____player_2Dlocal_2Dhandle = require("engine.internal.misc.player-local-handle")
25
25
  local PLAYER_LOCAL_HANDLE = ____player_2Dlocal_2Dhandle.PLAYER_LOCAL_HANDLE
26
+ local ____lazy = require("utility.lazy")
27
+ local lazyRecord = ____lazy.lazyRecord
26
28
  local getPlayerAlliance = GetPlayerAlliance
27
29
  local getPlayerColor = GetPlayerColor
28
30
  local getPlayerName = GetPlayerName
@@ -33,6 +35,7 @@ local setPlayerAlliance = SetPlayerAlliance
33
35
  local setPlayerTechMaxAllowed = SetPlayerTechMaxAllowed
34
36
  local setPlayerTechResearched = SetPlayerTechResearched
35
37
  local setPlayerAbilityAvailable = SetPlayerAbilityAvailable
38
+ local triggerRegisterPlayerAllianceChange = TriggerRegisterPlayerAllianceChange
36
39
  local playerNative = _G.Player
37
40
  local nativeByPlayerAllianceType = {
38
41
  [0] = ALLIANCE_PASSIVE,
@@ -145,14 +148,11 @@ function Player.getMouseEvent(self, event, collector)
145
148
  self.events[eventId] = __TS__New(
146
149
  TriggerEvent,
147
150
  function(trigger)
148
- Timer:simple(
149
- 0,
150
- function()
151
- for ____, player in ipairs(____exports.Player.all) do
152
- TriggerRegisterPlayerEvent(trigger, player.handle, event)
153
- end
151
+ Timer:run(function()
152
+ for ____, player in ipairs(____exports.Player.all) do
153
+ TriggerRegisterPlayerEvent(trigger, player.handle, event)
154
154
  end
155
- )
155
+ end)
156
156
  end,
157
157
  collector or (function() return {} end)
158
158
  )
@@ -394,10 +394,19 @@ __TS__ObjectDefineProperty(
394
394
  Player,
395
395
  "allianceChangedEvent",
396
396
  {get = function(self)
397
- return ____exports.Player:getEvent(
398
- EVENT_PLAYER_ALLIANCE_CHANGED,
399
- function() return ____exports.Player:of(getTriggerPlayer()) end
400
- )
397
+ local event = lazyRecord(function(____type)
398
+ return __TS__New(
399
+ TriggerEvent,
400
+ function(trigger)
401
+ for ____, player in ipairs(____exports.Player.all) do
402
+ triggerRegisterPlayerAllianceChange(trigger, player.handle, nativeByPlayerAllianceType[____type])
403
+ end
404
+ end,
405
+ function() return ____exports.Player:of(getTriggerPlayer()) end
406
+ )
407
+ end)
408
+ rawset(self, "allianceChangedEvent", event)
409
+ return event
401
410
  end}
402
411
  )
403
412
  __TS__ObjectDefineProperty(
@@ -1,5 +1,6 @@
1
1
  /** @noSelfInFile */
2
- export declare class TileCell implements Readonly<Vec2> {
2
+ import { AttributesHolder } from "../../attributes";
3
+ export declare class TileCell extends AttributesHolder implements Readonly<Vec2> {
3
4
  private readonly id;
4
5
  readonly x: number;
5
6
  readonly y: number;
@@ -1,8 +1,11 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
3
4
  local __TS__New = ____lualib.__TS__New
4
5
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
6
  local ____exports = {}
7
+ local ____attributes = require("attributes")
8
+ local AttributesHolder = ____attributes.AttributesHolder
6
9
  local getTerrainType = GetTerrainType
7
10
  local setTerrainType = SetTerrainType
8
11
  local getTerrainVariance = GetTerrainVariance
@@ -13,7 +16,9 @@ local tileCellById = {}
13
16
  ____exports.TileCell = __TS__Class()
14
17
  local TileCell = ____exports.TileCell
15
18
  TileCell.name = "TileCell"
19
+ __TS__ClassExtends(TileCell, AttributesHolder)
16
20
  function TileCell.prototype.____constructor(self, id, x, y, z)
21
+ AttributesHolder.prototype.____constructor(self)
17
22
  self.id = id
18
23
  self.x = x
19
24
  self.y = y
package/engine/buff.d.ts CHANGED
@@ -79,6 +79,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
79
79
  healingOnExpiration?: NumberParameterValueType;
80
80
  killsOnExpiration?: BooleanParameterValueType;
81
81
  explodesOnExpiration?: BooleanParameterValueType;
82
+ abilityCooldownFactor?: NumberParameterValueType;
82
83
  uniqueGroup?: BuffUniqueGroup;
83
84
  } : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
84
85
  declare const enum BuffPropertyKey {
@@ -124,7 +125,9 @@ declare const enum BuffPropertyKey {
124
125
  PROVIDES_INVULNERABILITY = 139,
125
126
  KILLS_ON_EXPIRATION = 140,
126
127
  EXPLODES_ON_EXPIRATION = 141,
127
- MISS_PROBABILITY = 142
128
+ MISS_PROBABILITY = 142,
129
+ ABILITY_COOLDOWN_FACTOR = 143,
130
+ ABILITY_COOLDOWN_MODIFIER = 144
128
131
  }
129
132
  export declare const enum BuffTypeIdSelectionPolicy {
130
133
  LEAST_DURATION = 0
@@ -187,6 +190,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
187
190
  private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
188
191
  private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
189
192
  private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
193
+ private [BuffPropertyKey.ABILITY_COOLDOWN_FACTOR]?;
194
+ private [BuffPropertyKey.ABILITY_COOLDOWN_MODIFIER]?;
190
195
  protected static readonly defaultParameters: BuffParameters;
191
196
  get source(): Unit;
192
197
  readonly typeId: ApplicableBuffTypeId;
@@ -262,6 +267,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
262
267
  get duration(): number;
263
268
  get remainingDuration(): number;
264
269
  set remainingDuration(remainingDuration: number);
270
+ get abilityCooldownFactor(): number;
271
+ set abilityCooldownFactor(abilityCooldownFactor: number);
272
+ onAbilityGained(ability: Ability): void;
273
+ onAbilityLost(ability: Ability): void;
265
274
  flashEffect(...parameters: [
266
275
  ...widgetOrXY: [] | [Widget] | [x: number, x: number],
267
276
  ...parametersOrDuration: [] | [EffectParameters] | [number]
package/engine/buff.lua CHANGED
@@ -16,6 +16,7 @@ local internalApplyBuff = ____applicable.internalApplyBuff
16
16
  local removeBuff = ____applicable.removeBuff
17
17
  local ____ability = require("engine.internal.ability")
18
18
  local Ability = ____ability.Ability
19
+ local UnitAbility = ____ability.UnitAbility
19
20
  local ____ability = require("engine.object-field.ability")
20
21
  local AbilityBooleanField = ____ability.AbilityBooleanField
21
22
  local AbilityNumberField = ____ability.AbilityNumberField
@@ -50,6 +51,8 @@ local ____item = require("engine.internal.item")
50
51
  local Item = ____item.Item
51
52
  local ____destructable = require("core.types.destructable")
52
53
  local Destructable = ____destructable.Destructable
54
+ local ____ability = require("engine.standard.fields.ability")
55
+ local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
53
56
  local getUnitAbility = BlzGetUnitAbility
54
57
  local stringValueByBuffTypeIdByFieldId = postcompile(function()
55
58
  local stringValueByBuffTypeIdByFieldId = {}
@@ -121,7 +124,8 @@ local buffParametersKeys = {
121
124
  damageOnExpiration = true,
122
125
  healingOnExpiration = true,
123
126
  killsOnExpiration = true,
124
- explodesOnExpiration = true
127
+ explodesOnExpiration = true,
128
+ abilityCooldownFactor = true
125
129
  }
126
130
  local function resolveEnumValue(ability, level, value)
127
131
  if value == nil or type(value) == "number" then
@@ -198,7 +202,8 @@ local buffNumberParameters = {
198
202
  "healingPerInterval",
199
203
  "healingOverDuration",
200
204
  "damageOnExpiration",
201
- "healingOnExpiration"
205
+ "healingOnExpiration",
206
+ "abilityCooldownFactor"
202
207
  }
203
208
  local unsuccessfulApplicationMarker = {}
204
209
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -506,6 +511,22 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
506
511
  self[100] = 1
507
512
  Event.invoke(buffCreatedEvent, self)
508
513
  end
514
+ function Buff.prototype.onAbilityGained(self, ability)
515
+ if __TS__InstanceOf(ability, UnitAbility) then
516
+ local abilityCooldownModifier = self[144]
517
+ if abilityCooldownModifier then
518
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
519
+ end
520
+ end
521
+ end
522
+ function Buff.prototype.onAbilityLost(self, ability)
523
+ if __TS__InstanceOf(ability, UnitAbility) then
524
+ local abilityCooldownModifier = self[144]
525
+ if abilityCooldownModifier then
526
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
527
+ end
528
+ end
529
+ end
509
530
  function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
510
531
  if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
511
532
  Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
@@ -580,6 +601,12 @@ function Buff.prototype.onDestroy(self)
580
601
  behavior:destroy()
581
602
  end
582
603
  end
604
+ local previousAbilityCooldownModifier = self[144]
605
+ if previousAbilityCooldownModifier then
606
+ for ____, ability in ipairs(self._unit.abilities) do
607
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
608
+ end
609
+ end
583
610
  if self[139] then
584
611
  unit:decrementInvulnerabilityCounter()
585
612
  end
@@ -588,7 +615,7 @@ function Buff.prototype.onDestroy(self)
588
615
  end
589
616
  if self[136] then
590
617
  if self[137] then
591
- unit:decrementStunCounter()
618
+ unit:decrementForceStunCounter()
592
619
  end
593
620
  unit:decrementStunCounter()
594
621
  end
@@ -987,13 +1014,13 @@ __TS__SetDescriptor(
987
1014
  set = function(self, stuns)
988
1015
  if not stuns and self[136] then
989
1016
  if self[137] then
990
- self.object:decrementStunCounter()
1017
+ self.object:decrementForceStunCounter()
991
1018
  end
992
1019
  self.object:decrementStunCounter()
993
1020
  self[136] = nil
994
1021
  elseif stuns and not self[136] then
995
1022
  if self[137] then
996
- self.object:incrementStunCounter()
1023
+ self.object:incrementForceStunCounter()
997
1024
  end
998
1025
  self.object:incrementStunCounter()
999
1026
  self[136] = true
@@ -1016,12 +1043,12 @@ __TS__SetDescriptor(
1016
1043
  set = function(self, ignoresStunImmunity)
1017
1044
  if not ignoresStunImmunity and self[137] then
1018
1045
  if self[136] then
1019
- self.object:decrementStunCounter()
1046
+ self.object:decrementForceStunCounter()
1020
1047
  end
1021
1048
  self[137] = nil
1022
1049
  elseif ignoresStunImmunity and not self[137] then
1023
1050
  if self[136] then
1024
- self.object:incrementStunCounter()
1051
+ self.object:incrementForceStunCounter()
1025
1052
  end
1026
1053
  self[137] = true
1027
1054
  end
@@ -1269,6 +1296,32 @@ __TS__SetDescriptor(
1269
1296
  },
1270
1297
  true
1271
1298
  )
1299
+ __TS__SetDescriptor(
1300
+ Buff.prototype,
1301
+ "abilityCooldownFactor",
1302
+ {
1303
+ get = function(self)
1304
+ return self[143] or 1
1305
+ end,
1306
+ set = function(self, abilityCooldownFactor)
1307
+ local previousAbilityCooldownModifier = self[144]
1308
+ if previousAbilityCooldownModifier then
1309
+ for ____, ability in ipairs(self._unit.abilities) do
1310
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
1311
+ end
1312
+ end
1313
+ local function modifier(ability, level, cooldown)
1314
+ return cooldown * abilityCooldownFactor
1315
+ end
1316
+ for ____, ability in ipairs(self._unit.abilities) do
1317
+ COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
1318
+ end
1319
+ self[144] = modifier
1320
+ self[143] = abilityCooldownFactor
1321
+ end
1322
+ },
1323
+ true
1324
+ )
1272
1325
  Buff.createdEvent = buffCreatedEvent
1273
1326
  Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
1274
1327
  (function(self)
@@ -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)
@@ -55,7 +57,8 @@ local function invokeEvent(unit)
55
57
  end
56
58
  local function checkUnit(unit)
57
59
  local passedTime = unit[passedTimeAttribute] + timerPeriod
58
- if passedTime >= unit[impactDelayAttribute] then
60
+ local impactDelay = unit[impactDelayAttribute]
61
+ if passedTime >= impactDelay and ceil(passedTime / 0.02) >= ceil(impactDelay / 0.02) then
59
62
  invokeEvent(unit)
60
63
  else
61
64
  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
- DELAY_HEALTH_CHECKS_COUNTER = 103,
113
- DELAY_HEALTH_CHECKS_HEALTH_BONUS = 104,
114
- PREVENT_DEATH_HEALTH_BONUS = 105,
115
- IS_TEAM_GLOW_HIDDEN = 106,
116
- LAST_X = 107,
117
- LAST_Y = 108
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]?;
@@ -294,6 +296,8 @@ export declare class Unit extends Handle<junit> {
294
296
  unpauseEx(): void;
295
297
  incrementStunCounter(): void;
296
298
  decrementStunCounter(): void;
299
+ incrementForceStunCounter(): void;
300
+ decrementForceStunCounter(): void;
297
301
  set waygateActive(v: boolean);
298
302
  get waygateActive(): boolean;
299
303
  set waygateDestination(v: Vec2);
@@ -375,5 +379,6 @@ export declare class Unit extends Handle<junit> {
375
379
  setField(field: junitstringfield, value: string): boolean;
376
380
  toString(): string;
377
381
  static getBySyncId(syncId: UnitSyncId): Unit | undefined;
382
+ static synchronize: (player: Player, object: Unit | undefined) => Promise<Unit | undefined>;
378
383
  }
379
384
  export {};
@@ -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
@@ -657,15 +659,15 @@ for ____, player in ipairs(Player.all) do
657
659
  dummies[player] = dummy
658
660
  end
659
661
  local function delayHealthChecksCallback(unit)
660
- local counter = (unit[103] or 0) - 1
662
+ local counter = (unit[104] or 0) - 1
661
663
  if counter ~= 0 then
662
- unit[103] = counter
664
+ unit[104] = counter
663
665
  return
664
666
  end
665
- unit[103] = nil
666
- local healthBonus = unit[104]
667
+ unit[104] = nil
668
+ local healthBonus = unit[105]
667
669
  if healthBonus ~= nil then
668
- unit[104] = nil
670
+ unit[105] = nil
669
671
  local handle = unit.handle
670
672
  BlzSetUnitMaxHP(
671
673
  handle,
@@ -725,8 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
725
727
  end
726
728
  function Unit.prototype.onDestroy(self)
727
729
  local handle = self.handle
728
- self[107] = getUnitX(handle)
729
- self[108] = getUnitY(handle)
730
+ self[108] = getUnitX(handle)
731
+ self[109] = getUnitY(handle)
730
732
  if not self._owner then
731
733
  self._owner = Player:of(getOwningPlayer(handle))
732
734
  end
@@ -860,7 +862,7 @@ function Unit.prototype.chooseWeapon(self, target)
860
862
  return nil
861
863
  end
862
864
  function Unit.prototype.delayHealthChecks(self)
863
- self[103] = (self[103] or 0) + 1
865
+ self[104] = (self[104] or 0) + 1
864
866
  Timer:run(delayHealthChecksCallback, self)
865
867
  end
866
868
  function Unit.prototype.setPosition(self, x, y)
@@ -1066,18 +1068,44 @@ function Unit.prototype.unpauseEx(self)
1066
1068
  end
1067
1069
  function Unit.prototype.incrementStunCounter(self)
1068
1070
  local stunCounter = self[102] or 0
1069
- if not self[101] or stunCounter >= 0 then
1071
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
1070
1072
  BlzPauseUnitEx(self.handle, true)
1071
1073
  end
1072
1074
  self[102] = stunCounter + 1
1073
1075
  end
1074
1076
  function Unit.prototype.decrementStunCounter(self)
1075
1077
  local stunCounter = self[102] or 0
1076
- if not self[101] or stunCounter >= 1 then
1078
+ if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
1077
1079
  BlzPauseUnitEx(self.handle, false)
1078
1080
  end
1079
1081
  self[102] = stunCounter - 1
1080
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
1081
1109
  function Unit.create(self, owner, id, x, y, facing, skinId)
1082
1110
  local handle = skinId and BlzCreateUnitWithSkin(
1083
1111
  owner.handle,
@@ -1485,7 +1513,7 @@ __TS__SetDescriptor(
1485
1513
  "isTeamGlowVisible",
1486
1514
  {
1487
1515
  get = function(self)
1488
- return not self[106]
1516
+ return not self[107]
1489
1517
  end,
1490
1518
  set = function(self, isTeamGlowVisible)
1491
1519
  BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
@@ -1495,7 +1523,7 @@ __TS__SetDescriptor(
1495
1523
  else
1496
1524
  ____temp_7 = nil
1497
1525
  end
1498
- self[106] = ____temp_7
1526
+ self[107] = ____temp_7
1499
1527
  end
1500
1528
  },
1501
1529
  true
@@ -1505,7 +1533,7 @@ __TS__SetDescriptor(
1505
1533
  "color",
1506
1534
  {set = function(self, color)
1507
1535
  SetUnitColor(self.handle, color.handle)
1508
- if self[106] then
1536
+ if self[107] then
1509
1537
  BlzShowUnitTeamGlow(self.handle, false)
1510
1538
  end
1511
1539
  end},
@@ -1529,14 +1557,14 @@ __TS__SetDescriptor(
1529
1557
  "maxHealth",
1530
1558
  {
1531
1559
  get = function(self)
1532
- return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1560
+ return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
1533
1561
  end,
1534
1562
  set = function(self, maxHealth)
1535
- if maxHealth < 1 and self[103] ~= nil then
1536
- self[104] = (self[104] or 0) + (1 - maxHealth)
1563
+ if maxHealth < 1 and self[104] ~= nil then
1564
+ self[105] = (self[105] or 0) + (1 - maxHealth)
1537
1565
  maxHealth = 1
1538
1566
  end
1539
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1567
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
1540
1568
  end
1541
1569
  },
1542
1570
  true
@@ -1578,10 +1606,10 @@ __TS__SetDescriptor(
1578
1606
  "health",
1579
1607
  {
1580
1608
  get = function(self)
1581
- return GetWidgetLife(self.handle) - (self[105] or 0)
1609
+ return GetWidgetLife(self.handle) - (self[106] or 0)
1582
1610
  end,
1583
1611
  set = function(self, health)
1584
- SetWidgetLife(self.handle, health + (self[105] or 0))
1612
+ SetWidgetLife(self.handle, health + (self[106] or 0))
1585
1613
  end
1586
1614
  },
1587
1615
  true
@@ -1675,7 +1703,7 @@ __TS__SetDescriptor(
1675
1703
  "x",
1676
1704
  {
1677
1705
  get = function(self)
1678
- return self[107] or getUnitX(self.handle)
1706
+ return self[108] or getUnitX(self.handle)
1679
1707
  end,
1680
1708
  set = function(self, v)
1681
1709
  SetUnitX(self.handle, v)
@@ -1688,7 +1716,7 @@ __TS__SetDescriptor(
1688
1716
  "y",
1689
1717
  {
1690
1718
  get = function(self)
1691
- return self[108] or getUnitY(self.handle)
1719
+ return self[109] or getUnitY(self.handle)
1692
1720
  end,
1693
1721
  set = function(self, v)
1694
1722
  SetUnitY(self.handle, v)
@@ -1793,14 +1821,18 @@ __TS__SetDescriptor(
1793
1821
  local handle = self.handle
1794
1822
  if isPaused and not IsUnitPaused(handle) then
1795
1823
  self[101] = true
1796
- for _ = self[102] or 0, -1 do
1797
- BlzPauseUnitEx(handle, true)
1824
+ if (self[103] or 0) <= 0 then
1825
+ for _ = self[102] or 0, -1 do
1826
+ BlzPauseUnitEx(handle, true)
1827
+ end
1798
1828
  end
1799
1829
  PauseUnit(handle, true)
1800
1830
  elseif not isPaused and IsUnitPaused(handle) then
1801
1831
  PauseUnit(handle, false)
1802
- for _ = self[102] or 0, -1 do
1803
- BlzPauseUnitEx(handle, false)
1832
+ if (self[103] or 0) <= 0 then
1833
+ for _ = self[102] or 0, -1 do
1834
+ BlzPauseUnitEx(handle, false)
1835
+ end
1804
1836
  end
1805
1837
  self[101] = nil
1806
1838
  end
@@ -2628,7 +2660,7 @@ Unit.onDamage = __TS__New(
2628
2660
  invoke(event, source, target, evData)
2629
2661
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2630
2662
  local bonusHealth = math.ceil(evData.amount)
2631
- target[105] = (target[105] or 0) + bonusHealth
2663
+ target[106] = (target[106] or 0) + bonusHealth
2632
2664
  BlzSetUnitMaxHP(
2633
2665
  target.handle,
2634
2666
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2642,7 +2674,7 @@ Unit.onDamage = __TS__New(
2642
2674
  evData[0],
2643
2675
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2644
2676
  )
2645
- target[105] = (target[105] or 0) - bonusHealth
2677
+ target[106] = (target[106] or 0) - bonusHealth
2646
2678
  SetWidgetLife(
2647
2679
  target.handle,
2648
2680
  GetWidgetLife(target.handle) - bonusHealth
@@ -2792,6 +2824,10 @@ __TS__ObjectDefineProperty(
2792
2824
  rawset(self, "destroyEvent", destroyEvent)
2793
2825
  return destroyEvent
2794
2826
  end}
2827
+ )
2828
+ Unit.synchronize = synchronizer(
2829
+ function(unit) return unit.syncId end,
2830
+ function(syncId) return unitBySyncId[syncId] end
2795
2831
  );
2796
2832
  (function(self)
2797
2833
  local leaveAbilityIds = postcompile(function()
@@ -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<[
@@ -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,
@@ -36,7 +36,8 @@ export type ObjectFieldValueChangeEvent<T extends ObjectField<any, any, any, any
36
36
  ]> : never;
37
37
  export type ReadonlyObjectFieldType<T extends ObjectField<any, any, any, any>> = Omit<T, "setValue" | "removeValue" | "trySetValue">;
38
38
  type ReadonlyObjectFieldConstructor<T extends ObjectField> = OmitConstructor<typeof ObjectField> & (abstract new (...args: any[]) => ReadonlyObjectFieldType<T>);
39
- type ObjectFieldModifier<InstanceType extends AnyNotNil, ValueType extends number | string | boolean> = (instance: InstanceType, currentValue: ValueType, originalValue: ValueType) => ValueType;
39
+ export type ObjectFieldModifier<InstanceType extends AnyNotNil, ValueType extends number | string | boolean> = (instance: InstanceType, currentValue: ValueType, originalValue: ValueType) => ValueType;
40
+ export type ObjectLevelFieldModifier<InstanceType extends AnyNotNil, ValueType extends number | string | boolean> = (instance: InstanceType, level: number, currentValue: ValueType, originalValue: ValueType) => ValueType;
40
41
  export declare abstract class ObjectField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType, NativeFieldType> {
41
42
  protected abstract readonly defaultValue: ValueType;
42
43
  protected abstract getNativeFieldValue(instance: InstanceType): ValueType;
@@ -88,7 +89,12 @@ export declare abstract class ObjectLevelField<ObjectDataEntryType extends Objec
88
89
  protected abstract getLevelCount(entry: ObjectDataEntryType | InstanceType): number;
89
90
  getValue<LevelType extends [number] | []>(entry: ObjectDataEntryType | InstanceType, ...[level]: LevelType): LevelType extends [number] ? ValueType : ValueType[];
90
91
  setValue(entry: ObjectDataEntryType | InstanceType, ...[levelOrValue, value]: [value: ObjectDataEntryLevelFieldValueSupplier<InputValueType, ValueType>] | [level: number, value: InputValueType]): boolean;
92
+ applyModifier(instance: InstanceType, modifier: ObjectLevelFieldModifier<InstanceType, ValueType>): void;
93
+ removeModifier(instance: InstanceType, modifier: ObjectLevelFieldModifier<InstanceType, ValueType>): boolean;
91
94
  trySetValue(entry: ObjectDataEntryType | InstanceType, levelOrValue: number | unknown, value?: unknown): boolean;
95
+ private getActualValue;
96
+ private setActualValue;
97
+ private calculateActualValue;
92
98
  private invokeValueChangeEvent;
93
99
  private invokeValueChangeEventRecursive;
94
100
  protected static getOrCreateValueChangeEvent<T extends ObjectLevelField, R extends ReadonlyObjectLevelFieldType<T>>(this: ReadonlyObjectLevelFieldConstructor<T>): ObjectLevelFieldValueChangeEvent<R>;
@@ -25,6 +25,7 @@ local mutableLinkedSet = ____linked_2Dset.mutableLinkedSet
25
25
  local ____lua_2Dmaps = require("utility.lua-maps")
26
26
  local emptyLuaMap = ____lua_2Dmaps.emptyLuaMap
27
27
  local getOrPut = ____lua_2Dmaps.getOrPut
28
+ local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
28
29
  local mutableWeakLuaMap = ____lua_2Dmaps.mutableWeakLuaMap
29
30
  local ____arrays = require("utility.arrays")
30
31
  local emptyArray = ____arrays.emptyArray
@@ -150,7 +151,13 @@ function ObjectField.prototype.applyModifier(self, instance, modifier)
150
151
  originalValueByInstance = mutableWeakLuaMap()
151
152
  self.originalValueByInstance = originalValueByInstance
152
153
  end
153
- originalValueByInstance[instance] = self:getActualValue(instance)
154
+ local ____originalValueByInstance_1 = originalValueByInstance
155
+ local ____instance_2 = instance
156
+ local ____originalValueByInstance_instance_0 = originalValueByInstance[instance]
157
+ if ____originalValueByInstance_instance_0 == nil then
158
+ ____originalValueByInstance_instance_0 = self:getActualValue(instance)
159
+ end
160
+ ____originalValueByInstance_1[____instance_2] = ____originalValueByInstance_instance_0
154
161
  self:setActualValue(
155
162
  instance,
156
163
  self:calculateActualValue(instance)
@@ -196,22 +203,22 @@ function ObjectField.prototype.getActualValue(self, instance)
196
203
  if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
197
204
  local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(instance)]
198
205
  if defaultValue ~= nil or self.isGlobal then
199
- local ____self_valueByInstance_instance_0 = self.valueByInstance[instance]
200
- if ____self_valueByInstance_instance_0 == nil then
201
- ____self_valueByInstance_instance_0 = defaultValue
206
+ local ____self_valueByInstance_instance_3 = self.valueByInstance[instance]
207
+ if ____self_valueByInstance_instance_3 == nil then
208
+ ____self_valueByInstance_instance_3 = defaultValue
202
209
  end
203
- local ____self_valueByInstance_instance_0_1 = ____self_valueByInstance_instance_0
204
- if ____self_valueByInstance_instance_0_1 == nil then
205
- ____self_valueByInstance_instance_0_1 = self.defaultValue
210
+ local ____self_valueByInstance_instance_3_4 = ____self_valueByInstance_instance_3
211
+ if ____self_valueByInstance_instance_3_4 == nil then
212
+ ____self_valueByInstance_instance_3_4 = self.defaultValue
206
213
  end
207
- return ____self_valueByInstance_instance_0_1
214
+ return ____self_valueByInstance_instance_3_4
208
215
  end
209
216
  end
210
- local ____temp_2 = self:getNativeFieldValue(instance)
211
- if ____temp_2 == nil then
212
- ____temp_2 = self.defaultValue
217
+ local ____temp_5 = self:getNativeFieldValue(instance)
218
+ if ____temp_5 == nil then
219
+ ____temp_5 = self.defaultValue
213
220
  end
214
- return ____temp_2
221
+ return ____temp_5
215
222
  end
216
223
  function ObjectField.prototype.setActualValue(self, instance, value)
217
224
  local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
@@ -219,15 +226,15 @@ function ObjectField.prototype.setActualValue(self, instance, value)
219
226
  if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
220
227
  local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[objectDataEntryId]
221
228
  if defaultValue ~= nil or self.isGlobal then
222
- local ____self_valueByInstance_instance_3 = self.valueByInstance[instance]
223
- if ____self_valueByInstance_instance_3 == nil then
224
- ____self_valueByInstance_instance_3 = defaultValue
229
+ local ____self_valueByInstance_instance_6 = self.valueByInstance[instance]
230
+ if ____self_valueByInstance_instance_6 == nil then
231
+ ____self_valueByInstance_instance_6 = defaultValue
225
232
  end
226
- local ____self_valueByInstance_instance_3_4 = ____self_valueByInstance_instance_3
227
- if ____self_valueByInstance_instance_3_4 == nil then
228
- ____self_valueByInstance_instance_3_4 = self.defaultValue
233
+ local ____self_valueByInstance_instance_6_7 = ____self_valueByInstance_instance_6
234
+ if ____self_valueByInstance_instance_6_7 == nil then
235
+ ____self_valueByInstance_instance_6_7 = self.defaultValue
229
236
  end
230
- local previousValue = ____self_valueByInstance_instance_3_4
237
+ local previousValue = ____self_valueByInstance_instance_6_7
231
238
  if value ~= previousValue then
232
239
  self.valueByInstance[instance] = value
233
240
  self:invokeValueChangeEvent(instance, self, previousValue, value)
@@ -248,10 +255,10 @@ function ObjectField.prototype.setActualValue(self, instance, value)
248
255
  return true
249
256
  end
250
257
  function ObjectField.prototype.calculateActualValue(self, instance)
251
- local ____opt_5 = self.originalValueByInstance
252
- local originalValue = ____opt_5 and ____opt_5[instance]
253
- local ____opt_7 = self.modifiersByInstance
254
- local modifiers = ____opt_7 and ____opt_7[instance]
258
+ local ____opt_8 = self.originalValueByInstance
259
+ local originalValue = ____opt_8 and ____opt_8[instance]
260
+ local ____opt_10 = self.modifiersByInstance
261
+ local modifiers = ____opt_10 and ____opt_10[instance]
255
262
  if originalValue ~= nil then
256
263
  local value = originalValue
257
264
  if modifiers ~= nil then
@@ -316,17 +323,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
316
323
  if defaultValueByObjectDataEntryId ~= nil then
317
324
  local value = defaultValueByObjectDataEntryId[entry.id]
318
325
  if value ~= nil then
319
- local ____temp_10
326
+ local ____temp_13
320
327
  if index == nil then
321
- ____temp_10 = value
328
+ ____temp_13 = value
322
329
  else
323
- local ____value_index_9 = value[index + 1]
324
- if ____value_index_9 == nil then
325
- ____value_index_9 = self.defaultValue
330
+ local ____value_index_12 = value[index + 1]
331
+ if ____value_index_12 == nil then
332
+ ____value_index_12 = self.defaultValue
326
333
  end
327
- ____temp_10 = ____value_index_9
334
+ ____temp_13 = ____value_index_12
328
335
  end
329
- return ____temp_10
336
+ return ____temp_13
330
337
  end
331
338
  end
332
339
  return index == nil and ({}) or self.defaultValue
@@ -336,17 +343,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
336
343
  local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(entry)]
337
344
  if defaultValue ~= nil or self.isGlobal then
338
345
  local value = self.valueByInstance[entry] or defaultValue or emptyArray()
339
- local ____temp_12
346
+ local ____temp_15
340
347
  if index == nil then
341
- ____temp_12 = value
348
+ ____temp_15 = value
342
349
  else
343
- local ____value_index_11 = value[index + 1]
344
- if ____value_index_11 == nil then
345
- ____value_index_11 = self.defaultValue
350
+ local ____value_index_14 = value[index + 1]
351
+ if ____value_index_14 == nil then
352
+ ____value_index_14 = self.defaultValue
346
353
  end
347
- ____temp_12 = ____value_index_11
354
+ ____temp_15 = ____value_index_14
348
355
  end
349
- return ____temp_12
356
+ return ____temp_15
350
357
  end
351
358
  end
352
359
  if index ~= nil then
@@ -391,36 +398,16 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
391
398
  if defaultValueByObjectDataEntryId ~= nil then
392
399
  local valueByLevel = defaultValueByObjectDataEntryId[entry.id]
393
400
  if valueByLevel ~= nil then
394
- local ____valueByLevel_index_13 = valueByLevel[level + 1]
395
- if ____valueByLevel_index_13 == nil then
396
- ____valueByLevel_index_13 = self.defaultValue
401
+ local ____valueByLevel_index_16 = valueByLevel[level + 1]
402
+ if ____valueByLevel_index_16 == nil then
403
+ ____valueByLevel_index_16 = self.defaultValue
397
404
  end
398
- return ____valueByLevel_index_13
405
+ return ____valueByLevel_index_16
399
406
  end
400
407
  end
401
408
  return self.defaultValue
402
409
  end
403
- local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
404
- if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
405
- local defaultValueByLevel = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(entry)]
406
- if defaultValueByLevel ~= nil or self.isGlobal then
407
- local ____opt_14 = self.valueByInstance[entry]
408
- local ____temp_16 = ____opt_14 and ____opt_14[level + 1]
409
- if ____temp_16 == nil then
410
- ____temp_16 = (defaultValueByLevel or emptyArray())[level + 1]
411
- end
412
- local ____temp_16_17 = ____temp_16
413
- if ____temp_16_17 == nil then
414
- ____temp_16_17 = self.defaultValue
415
- end
416
- return ____temp_16_17
417
- end
418
- end
419
- local ____temp_18 = self:getNativeFieldValue(entry, level)
420
- if ____temp_18 == nil then
421
- ____temp_18 = self.defaultValue
422
- end
423
- return ____temp_18
410
+ return self:getActualValue(entry, level)
424
411
  end
425
412
  function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
426
413
  if value == nil then
@@ -460,29 +447,129 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
460
447
  valueByLevel[level + 1] = value
461
448
  return true
462
449
  end
450
+ local modifiersByInstance = self.modifiersByInstance
451
+ if modifiersByInstance ~= nil then
452
+ local modifiers = modifiersByInstance[entry]
453
+ if modifiers ~= nil and modifiers.size ~= 0 then
454
+ local originalValueByLevelByInstance = self.originalValueByLevelByInstance
455
+ if originalValueByLevelByInstance == nil then
456
+ originalValueByLevelByInstance = mutableWeakLuaMap()
457
+ self.originalValueByLevelByInstance = originalValueByLevelByInstance
458
+ end
459
+ getOrPut(originalValueByLevelByInstance, entry, mutableLuaMap)[level] = value
460
+ value = self:calculateActualValue(entry, level)
461
+ end
462
+ end
463
+ return self:setActualValue(entry, level, value)
464
+ end
465
+ function ObjectLevelField.prototype.applyModifier(self, instance, modifier)
466
+ local modifiersByInstance = self.modifiersByInstance
467
+ if modifiersByInstance == nil then
468
+ modifiersByInstance = mutableWeakLuaMap()
469
+ self.modifiersByInstance = modifiersByInstance
470
+ end
471
+ if getOrPut(modifiersByInstance, instance, mutableLinkedSet):add(modifier) then
472
+ local originalValueByLevelByInstance = self.originalValueByLevelByInstance
473
+ if originalValueByLevelByInstance == nil then
474
+ originalValueByLevelByInstance = mutableWeakLuaMap()
475
+ self.originalValueByLevelByInstance = originalValueByLevelByInstance
476
+ end
477
+ local originalValueByLevel = getOrPut(originalValueByLevelByInstance, instance, mutableLuaMap)
478
+ local levelCount = self:getLevelCount(instance)
479
+ for level = 0, levelCount - 1 do
480
+ local ____originalValueByLevel_level_17 = originalValueByLevel[level]
481
+ if ____originalValueByLevel_level_17 == nil then
482
+ ____originalValueByLevel_level_17 = self:getActualValue(instance, level)
483
+ end
484
+ originalValueByLevel[level] = ____originalValueByLevel_level_17
485
+ self:setActualValue(
486
+ instance,
487
+ level,
488
+ self:calculateActualValue(instance, level)
489
+ )
490
+ end
491
+ end
492
+ end
493
+ function ObjectLevelField.prototype.removeModifier(self, instance, modifier)
494
+ local modifiersByInstance = self.modifiersByInstance
495
+ if modifiersByInstance ~= nil then
496
+ local modifiers = modifiersByInstance[instance]
497
+ if modifiers ~= nil and modifiers:remove(modifier) then
498
+ local levelCount = self:getLevelCount(instance)
499
+ for level = 0, levelCount - 1 do
500
+ self:setActualValue(
501
+ instance,
502
+ level,
503
+ self:calculateActualValue(instance, level)
504
+ )
505
+ end
506
+ return true
507
+ end
508
+ end
509
+ return false
510
+ end
511
+ function ObjectLevelField.prototype.trySetValue(self, entry, levelOrValue, value)
512
+ if value ~= nil then
513
+ if __TS__TypeOf(value) ~= __TS__TypeOf(self.defaultValue) then
514
+ return false
515
+ end
516
+ if type(levelOrValue) ~= "number" then
517
+ return false
518
+ end
519
+ return self:setValue(entry, levelOrValue, value)
520
+ end
521
+ if __TS__TypeOf(levelOrValue) ~= __TS__TypeOf(self.defaultValue) then
522
+ return false
523
+ end
524
+ return self:setValue(entry, levelOrValue)
525
+ end
526
+ function ObjectLevelField.prototype.getActualValue(self, instance, level)
527
+ local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
528
+ if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
529
+ local defaultValueByLevel = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(instance)]
530
+ if defaultValueByLevel ~= nil or self.isGlobal then
531
+ local ____opt_18 = self.valueByInstance[instance]
532
+ local ____temp_20 = ____opt_18 and ____opt_18[level + 1]
533
+ if ____temp_20 == nil then
534
+ ____temp_20 = (defaultValueByLevel or emptyArray())[level + 1]
535
+ end
536
+ local ____temp_20_21 = ____temp_20
537
+ if ____temp_20_21 == nil then
538
+ ____temp_20_21 = self.defaultValue
539
+ end
540
+ return ____temp_20_21
541
+ end
542
+ end
543
+ local ____temp_22 = self:getNativeFieldValue(instance, level)
544
+ if ____temp_22 == nil then
545
+ ____temp_22 = self.defaultValue
546
+ end
547
+ return ____temp_22
548
+ end
549
+ function ObjectLevelField.prototype.setActualValue(self, instance, level, value)
463
550
  local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
464
- local objectDataEntryId = self:getObjectDataEntryId(entry)
551
+ local objectDataEntryId = self:getObjectDataEntryId(instance)
465
552
  if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
466
553
  local defaultValueByLevel = (defaultValueByObjectDataEntryId or emptyLuaMap())[objectDataEntryId]
467
554
  if defaultValueByLevel ~= nil or self.isGlobal then
468
- local valueByLevel = self.valueByInstance[entry]
555
+ local valueByLevel = self.valueByInstance[instance]
469
556
  if valueByLevel == nil then
470
557
  valueByLevel = {}
471
- self.valueByInstance[entry] = valueByLevel
558
+ self.valueByInstance[instance] = valueByLevel
472
559
  end
473
- local ____valueByLevel_index_19 = valueByLevel[level + 1]
474
- if ____valueByLevel_index_19 == nil then
475
- ____valueByLevel_index_19 = (defaultValueByLevel or emptyArray())[level + 1]
560
+ local ____valueByLevel_index_23 = valueByLevel[level + 1]
561
+ if ____valueByLevel_index_23 == nil then
562
+ ____valueByLevel_index_23 = (defaultValueByLevel or emptyArray())[level + 1]
476
563
  end
477
- local ____valueByLevel_index_19_20 = ____valueByLevel_index_19
478
- if ____valueByLevel_index_19_20 == nil then
479
- ____valueByLevel_index_19_20 = self.defaultValue
564
+ local ____valueByLevel_index_23_24 = ____valueByLevel_index_23
565
+ if ____valueByLevel_index_23_24 == nil then
566
+ ____valueByLevel_index_23_24 = self.defaultValue
480
567
  end
481
- local previousValue = ____valueByLevel_index_19_20
568
+ local previousValue = ____valueByLevel_index_23_24
482
569
  if value ~= previousValue then
483
570
  valueByLevel[level + 1] = value
484
571
  self:invokeValueChangeEvent(
485
- entry,
572
+ instance,
486
573
  self,
487
574
  level,
488
575
  previousValue,
@@ -495,13 +582,13 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
495
582
  if not self:hasNativeFieldValue(objectDataEntryId) then
496
583
  return false
497
584
  end
498
- local previousValue = self:getNativeFieldValue(entry, level)
585
+ local previousValue = self:getNativeFieldValue(instance, level)
499
586
  if value ~= previousValue then
500
- if not self:setNativeFieldValue(entry, level, value) then
587
+ if not self:setNativeFieldValue(instance, level, value) then
501
588
  return false
502
589
  end
503
590
  self:invokeValueChangeEvent(
504
- entry,
591
+ instance,
505
592
  self,
506
593
  level,
507
594
  previousValue,
@@ -510,20 +597,22 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
510
597
  end
511
598
  return true
512
599
  end
513
- function ObjectLevelField.prototype.trySetValue(self, entry, levelOrValue, value)
514
- if value ~= nil then
515
- if __TS__TypeOf(value) ~= __TS__TypeOf(self.defaultValue) then
516
- return false
517
- end
518
- if type(levelOrValue) ~= "number" then
519
- return false
600
+ function ObjectLevelField.prototype.calculateActualValue(self, instance, level)
601
+ local ____opt_27 = self.originalValueByLevelByInstance
602
+ local ____opt_25 = ____opt_27 and ____opt_27[instance]
603
+ local originalValue = ____opt_25 and ____opt_25[level]
604
+ local ____opt_29 = self.modifiersByInstance
605
+ local modifiers = ____opt_29 and ____opt_29[instance]
606
+ if originalValue ~= nil then
607
+ local value = originalValue
608
+ if modifiers ~= nil then
609
+ for modifier in pairs(modifiers) do
610
+ value = modifier(instance, level, value, originalValue)
611
+ end
520
612
  end
521
- return self:setValue(entry, levelOrValue, value)
522
- end
523
- if __TS__TypeOf(levelOrValue) ~= __TS__TypeOf(self.defaultValue) then
524
- return false
613
+ return value
525
614
  end
526
- return self:setValue(entry, levelOrValue)
615
+ return self.defaultValue
527
616
  end
528
617
  function ObjectLevelField.prototype.invokeValueChangeEvent(self, ...)
529
618
  self:invokeValueChangeEventRecursive(
@@ -36,6 +36,7 @@ local isUnitVisible = IsUnitVisible
36
36
  local getUnitFlyHeight = GetUnitFlyHeight
37
37
  local getUnitX = GetUnitX
38
38
  local getUnitY = GetUnitY
39
+ local unitAlive = UnitAlive
39
40
  local DEFAULT_FONT_SIZE = 0.024
40
41
  local function applyConfiguration(textTag, configuration)
41
42
  setTextTagFadepoint(textTag, configuration.fadepoint)
@@ -333,7 +334,7 @@ Timer.onPeriod[1 / 64]:addListener(function()
333
334
  y,
334
335
  getUnitFlyHeight(unit) + getTerrainZ(x, y)
335
336
  )
336
- if isInView and not isUnitHidden(unit) and not isUnitLoaded(unit) and isUnitVisible(unit, PLAYER_LOCAL_HANDLE) then
337
+ if isInView and not isUnitHidden(unit) and not isUnitLoaded(unit) and isUnitVisible(unit, PLAYER_LOCAL_HANDLE) and unitAlive(unit) then
337
338
  setTextTagPosUnit(
338
339
  ensureHandle(textTag),
339
340
  unit,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "warscript",
4
- "version": "0.0.1-dev.91a4dce",
4
+ "version": "0.0.1-dev.960a0ea",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",