warscript 0.0.1-dev.c8d6bc0 → 0.0.1-dev.cc63edd

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.
@@ -5,7 +5,7 @@ export declare class Missile implements Destroyable {
5
5
  readonly retarget: (this: void, target: Unit | Vec2) => void;
6
6
  private readonly update;
7
7
  protected constructor(effect: jeffect, retarget: (this: void, target: Unit | Vec2) => void, update: (this: Missile) => boolean);
8
- static launch(config: Readonly<{
8
+ static launch<T extends any[]>(config: Readonly<{
9
9
  art: string;
10
10
  scale?: number;
11
11
  acceleration?: number;
@@ -15,7 +15,7 @@ export declare class Missile implements Destroyable {
15
15
  maxSpeed?: number;
16
16
  sourceOffset?: Vec2;
17
17
  targetOffset?: Vec2;
18
- }>, source: Unit | Vec2, target: Unit | Vec2, onArrival: (missile: Missile, success: boolean) => void): Missile;
18
+ }>, source: Unit | Vec2, target: Unit | Vec2, onArrival: (missile: Missile, success: boolean, ...parameters: T) => void, ...parameters: T): Missile;
19
19
  destroy(): void;
20
20
  }
21
21
  export declare namespace Missile {
@@ -41,7 +41,8 @@ function Missile.prototype.____constructor(self, effect, retarget, update)
41
41
  end
42
42
  head = self
43
43
  end
44
- function Missile.launch(self, config, source, target, onArrival)
44
+ function Missile.launch(self, config, source, target, onArrival, ...)
45
+ local parameters = {...}
45
46
  local ____opt_0 = config.sourceOffset
46
47
  local offsetX = ____opt_0 and ____opt_0.x or 0
47
48
  local ____opt_2 = config.sourceOffset
@@ -142,7 +143,12 @@ function Missile.launch(self, config, source, target, onArrival)
142
143
  visualPositionArcY = currentVisualTargetY
143
144
  visualPositionArcZ = currentVisualTargetZ
144
145
  retarget = false
145
- safeCall(onArrival, self, true)
146
+ safeCall(
147
+ onArrival,
148
+ self,
149
+ true,
150
+ table.unpack(parameters)
151
+ )
146
152
  return not retarget
147
153
  end
148
154
  if arcVSpeed ~= 0 and (currentTargetX ~= initialTargetX or currentTargetY ~= initialTargetY) then
@@ -12,8 +12,12 @@ local InstantImpactAbilityBehavior = ____exports.InstantImpactAbilityBehavior
12
12
  InstantImpactAbilityBehavior.name = "InstantImpactAbilityBehavior"
13
13
  __TS__ClassExtends(InstantImpactAbilityBehavior, AbilityBehavior)
14
14
  function InstantImpactAbilityBehavior.prototype.onCastingStart(self, caster)
15
+ local abilityTypeId = self.ability.typeId
15
16
  local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
16
17
  local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
18
+ if caster:getAbilityRemainingCooldown(abilityTypeId) ~= 0 or caster.mana < manaCost then
19
+ return
20
+ end
17
21
  caster.mana = caster.mana - manaCost
18
22
  if cooldown == 0 then
19
23
  caster:interruptCast(self.ability.typeId)
@@ -9,13 +9,20 @@ import { Destructable } from "../../core/types/destructable";
9
9
  import { EffectParameters } from "../../core/types/effect";
10
10
  import { AbilityDependentValue } from "../object-field/ability";
11
11
  export type AbilityBehaviorConstructor<Args extends any[]> = new (ability: Ability, ...args: Args) => AbilityBehavior;
12
- export declare abstract class AbilityBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Ability, PeriodicActionParameters> {
12
+ export declare abstract class AbilityBehavior<Parameters extends {
13
+ periodicActionParameters?: any[];
14
+ missileParameters?: any[];
15
+ } = {}> extends Behavior<Ability, NonNullable<Parameters["periodicActionParameters"]>> {
13
16
  constructor(ability: Ability);
14
17
  get ability(): Ability;
15
18
  protected resolveCurrentAbilityDependentValue<T extends boolean | number | string>(value: AbilityDependentValue<T>): T;
16
19
  protected flashAreaEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
17
20
  protected flashEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
18
21
  protected flashSpecialEffect(...args: [...pointOrWidget: [x: number, y: number] | [widget: Widget], duration?: number]): void;
22
+ private static MissileLaunchConfig;
23
+ private get missileLaunchConfig();
24
+ protected launchMissile(source: Unit, target: Unit, ...parameters: NonNullable<Parameters["missileParameters"]>): void;
25
+ onMissileArrival(...parameters: NonNullable<Parameters["missileParameters"]>): void;
19
26
  onUnitGainAbility(_unit: Unit): void;
20
27
  onUnitLoseAbility(_unit: Unit): void;
21
28
  onCastingStart(caster: Unit): void;
@@ -15,13 +15,52 @@ local Effect = ____effect.Effect
15
15
  local ____ability = require("engine.standard.fields.ability")
16
16
  local AREA_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.AREA_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
17
17
  local EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
18
+ local MISSILE_ARC_ABILITY_FLOAT_FIELD = ____ability.MISSILE_ARC_ABILITY_FLOAT_FIELD
19
+ local MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
20
+ local MISSILE_SPEED_ABILITY_INTEGER_FIELD = ____ability.MISSILE_SPEED_ABILITY_INTEGER_FIELD
18
21
  local SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD = ____ability.SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD
19
22
  local SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
20
23
  local ____ability = require("engine.object-field.ability")
21
24
  local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
22
25
  local ____timer = require("core.types.timer")
23
26
  local Timer = ____timer.Timer
27
+ local ____missile = require("core.types.missile")
28
+ local Missile = ____missile.Missile
24
29
  local createBehaviorFunctionsByAbilityTypeId = {}
30
+ local function invokeOnMissileArrival(_missile, success, abilityBehavior, ...)
31
+ if success then
32
+ abilityBehavior:onMissileArrival(...)
33
+ end
34
+ end
35
+ local ____class_0 = __TS__Class()
36
+ ____class_0.name = ""
37
+ function ____class_0.prototype.____constructor(self, abilityBehavior)
38
+ self.abilityBehavior = abilityBehavior
39
+ end
40
+ __TS__SetDescriptor(
41
+ ____class_0.prototype,
42
+ "art",
43
+ {get = function(self)
44
+ return MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.abilityBehavior.ability, 0)
45
+ end},
46
+ true
47
+ )
48
+ __TS__SetDescriptor(
49
+ ____class_0.prototype,
50
+ "arc",
51
+ {get = function(self)
52
+ return MISSILE_ARC_ABILITY_FLOAT_FIELD:getValue(self.abilityBehavior.ability)
53
+ end},
54
+ true
55
+ )
56
+ __TS__SetDescriptor(
57
+ ____class_0.prototype,
58
+ "speed",
59
+ {get = function(self)
60
+ return MISSILE_SPEED_ABILITY_INTEGER_FIELD:getValue(self.abilityBehavior.ability)
61
+ end},
62
+ true
63
+ )
25
64
  ____exports.AbilityBehavior = __TS__Class()
26
65
  local AbilityBehavior = ____exports.AbilityBehavior
27
66
  AbilityBehavior.name = "AbilityBehavior"
@@ -65,6 +104,18 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrDurati
65
104
  )
66
105
  end
67
106
  end
107
+ function AbilityBehavior.prototype.launchMissile(self, source, target, ...)
108
+ Missile:launch(
109
+ self.missileLaunchConfig,
110
+ source,
111
+ target,
112
+ invokeOnMissileArrival,
113
+ self,
114
+ ...
115
+ )
116
+ end
117
+ function AbilityBehavior.prototype.onMissileArrival(self, ...)
118
+ end
68
119
  function AbilityBehavior.prototype.onUnitGainAbility(self, _unit)
69
120
  end
70
121
  function AbilityBehavior.prototype.onUnitLoseAbility(self, _unit)
@@ -127,6 +178,17 @@ __TS__SetDescriptor(
127
178
  return self.object
128
179
  end},
129
180
  true
181
+ )
182
+ AbilityBehavior.MissileLaunchConfig = ____class_0
183
+ __TS__SetDescriptor(
184
+ AbilityBehavior.prototype,
185
+ "missileLaunchConfig",
186
+ {get = function(self)
187
+ local missileLaunchConfig = __TS__New(____exports.AbilityBehavior.MissileLaunchConfig, self)
188
+ rawset(self, "missileLaunchConfig", missileLaunchConfig)
189
+ return missileLaunchConfig
190
+ end},
191
+ true
130
192
  );
131
193
  (function(self)
132
194
  local function createUnitEventListener(key)
@@ -25,7 +25,7 @@ local function timerCallback(source, target)
25
25
  Event.invoke(autoAttackFinishEvent, source, target)
26
26
  end
27
27
  Unit.autoAttackStartEvent:addListener(function(source, target)
28
- local attackPoint = source.weapons[1].attackPoint
28
+ local attackPoint = source.weapons[1].impactDelay
29
29
  local timer = Timer:simple(attackPoint, timerCallback, source, target)
30
30
  eventTimerByUnit[source] = timer
31
31
  end)
@@ -68,23 +68,44 @@ declare const modifiers: {
68
68
  speed: (unit: junit, value: number) => void;
69
69
  armor: (unit: junit, value: number) => void;
70
70
  };
71
- interface UnitWeapon {
71
+ export declare class UnitWeapon {
72
+ readonly unit: Unit;
72
73
  readonly index: 0 | 1;
73
- cooldown: number;
74
- projectileArc: number;
75
- projectileArt: string;
76
- projectileSpeed: number;
77
- attackPoint: number;
74
+ constructor(unit: Unit, index: 0 | 1);
75
+ get cooldown(): number;
76
+ set cooldown(cooldown: number);
77
+ get damage(): [minimumDamage: number, maximumDamage: number];
78
+ set damage([minimumDamage, maximumDamage]: [number, number]);
79
+ get damageBase(): number;
80
+ set damageBase(damageBase: number);
81
+ get damageDiceCount(): number;
82
+ set damageDiceCount(damageDiceCount: number);
83
+ get damageDiceSideCount(): number;
84
+ set damageDiceSideCount(damageDiceSideCount: number);
85
+ get range(): number;
86
+ set range(range: number);
87
+ get impactDelay(): number;
88
+ set impactDelay(impactDelay: number);
89
+ get missileArc(): number;
90
+ set missileArc(missileArc: number);
91
+ get missileModelPath(): string;
92
+ set missileModelPath(missileModelPath: string);
93
+ get missileSpeed(): number;
94
+ set missileSpeed(missileSpeed: number);
78
95
  }
79
96
  declare const enum UnitPropertyKey {
80
97
  IS_PAUSED = 100,
81
98
  STUN_COUNTER = 101,
82
- PREVENT_DEATH_HEALTH_BONUS = 102,
83
- IS_TEAM_GLOW_HIDDEN = 103
99
+ DELAY_HEALTH_CHECKS_COUNTER = 102,
100
+ DELAY_HEALTH_CHECKS_HEALTH_BONUS = 103,
101
+ PREVENT_DEATH_HEALTH_BONUS = 104,
102
+ IS_TEAM_GLOW_HIDDEN = 105
84
103
  }
85
104
  export declare class Unit extends Handle<junit> {
86
105
  private [UnitPropertyKey.IS_PAUSED]?;
87
106
  private [UnitPropertyKey.STUN_COUNTER]?;
107
+ private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
108
+ private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
88
109
  private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
89
110
  private [UnitPropertyKey.IS_TEAM_GLOW_HIDDEN]?;
90
111
  private _owner?;
@@ -123,6 +144,8 @@ export declare class Unit extends Handle<junit> {
123
144
  playAnimation(animation: number): void;
124
145
  queueAnimation(animation: string): void;
125
146
  get weapons(): [UnitWeapon, UnitWeapon];
147
+ get firstWeapon(): UnitWeapon;
148
+ get secondWeapon(): UnitWeapon;
126
149
  get level(): number;
127
150
  set level(v: number);
128
151
  get xp(): number;
@@ -148,6 +171,10 @@ export declare class Unit extends Handle<junit> {
148
171
  set color(color: PlayerColor);
149
172
  get acquisitionRange(): number;
150
173
  set acquisitionRange(v: number);
174
+ /**
175
+ * Keeps this unit alive even if its health becomes negative until the current game thread yields.
176
+ */
177
+ delayHealthChecks(): void;
151
178
  get maxHealth(): number;
152
179
  set maxHealth(maxHealth: number);
153
180
  get healthRegenerationRate(): number;
@@ -222,6 +249,7 @@ export declare class Unit extends Handle<junit> {
222
249
  getAbilityById(abilityId: number): UnitAbility | undefined;
223
250
  removeAbility(abilityId: number): boolean;
224
251
  hideAbility(abilityId: number, flag: boolean): void;
252
+ getAbilityRemainingCooldown(abilityId: number): number;
225
253
  startAbilityCooldown(abilityId: number, cooldown: number): void;
226
254
  endAbilityCooldown(abilityId: number): void;
227
255
  interruptAttack(): void;
@@ -5,9 +5,9 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
5
5
  local __TS__New = ____lualib.__TS__New
6
6
  local __TS__Class = ____lualib.__TS__Class
7
7
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
8
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
8
9
  local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
9
10
  local __TS__InstanceOf = ____lualib.__TS__InstanceOf
10
- local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
11
11
  local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
12
12
  local Set = ____lualib.Set
13
13
  local __TS__Spread = ____lualib.__TS__Spread
@@ -92,6 +92,10 @@ local isUnitInRangeXY = IsUnitInRangeXY
92
92
  local isUnitInRange = IsUnitInRange
93
93
  local setResourceAmount = SetResourceAmount
94
94
  local getResourceAmount = GetResourceAmount
95
+ local getUnitWeaponRealField = BlzGetUnitWeaponRealField
96
+ local setUnitWeaponRealField = BlzSetUnitWeaponRealField
97
+ local getUnitWeaponStringField = BlzGetUnitWeaponStringField
98
+ local setUnitWeaponStringField = BlzSetUnitWeaponStringField
95
99
  local getUnitAbilityLevel = GetUnitAbilityLevel
96
100
  local unitDisableAbility = BlzUnitDisableAbility
97
101
  local unitInterruptAttack = BlzUnitInterruptAttack
@@ -387,51 +391,158 @@ local getters = {
387
391
  return BlzGetUnitArmor(unit)
388
392
  end
389
393
  }
390
- local weaponGetters = {
391
- index = function(self, handle, index)
392
- return index
393
- end,
394
- cooldown = function(self, handle, index)
395
- return BlzGetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, index)
396
- end,
397
- projectileArc = function(self, handle, index)
398
- return BlzGetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, index)
399
- end,
400
- projectileArt = function(self, handle, index)
401
- return BlzGetUnitWeaponStringField(handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, index)
402
- end,
403
- projectileSpeed = function(self, handle, index)
404
- return BlzGetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, index)
405
- end,
406
- attackPoint = function(self, handle, index)
407
- return BlzGetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, index)
408
- end
409
- }
410
- local weaponSetters = {
411
- cooldown = function(self, handle, index, value)
412
- assert(BlzSetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, index, value))
413
- end,
414
- projectileArc = function(self, handle, index, value)
415
- assert(BlzSetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, index, value))
416
- end,
417
- projectileArt = function(self, handle, index, value)
418
- assert(BlzSetUnitWeaponStringField(handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, index, value))
419
- end,
420
- projectileSpeed = function(self, handle, index, value)
421
- assert(BlzSetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, index, value))
422
- end,
423
- attackPoint = function(self, handle, index, value)
424
- assert(BlzSetUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, index, value))
425
- end
426
- }
427
- local weaponMetatable = {
428
- __index = function(self, key)
429
- return weaponGetters[key](weaponGetters, self.h, self.i)
430
- end,
431
- __newindex = function(self, key, value)
432
- weaponSetters[key](weaponSetters, self.h, self.i, value)
433
- end
434
- }
394
+ ____exports.UnitWeapon = __TS__Class()
395
+ local UnitWeapon = ____exports.UnitWeapon
396
+ UnitWeapon.name = "UnitWeapon"
397
+ function UnitWeapon.prototype.____constructor(self, unit, index)
398
+ self.unit = unit
399
+ self.index = index
400
+ end
401
+ __TS__SetDescriptor(
402
+ UnitWeapon.prototype,
403
+ "cooldown",
404
+ {
405
+ get = function(self)
406
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
407
+ end,
408
+ set = function(self, cooldown)
409
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
410
+ end
411
+ },
412
+ true
413
+ )
414
+ __TS__SetDescriptor(
415
+ UnitWeapon.prototype,
416
+ "damage",
417
+ {
418
+ get = function(self)
419
+ local minimumDamage = self.damageBase + self.damageDiceCount
420
+ local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
421
+ return {minimumDamage, maximumDamage}
422
+ end,
423
+ set = function(self, ____bindingPattern0)
424
+ local maximumDamage
425
+ local minimumDamage
426
+ minimumDamage = ____bindingPattern0[1]
427
+ maximumDamage = ____bindingPattern0[2]
428
+ self.damageBase = minimumDamage - 1
429
+ self.damageDiceCount = 1
430
+ self.damageDiceSideCount = maximumDamage - minimumDamage + 1
431
+ end
432
+ },
433
+ true
434
+ )
435
+ __TS__SetDescriptor(
436
+ UnitWeapon.prototype,
437
+ "damageBase",
438
+ {
439
+ get = function(self)
440
+ return BlzGetUnitBaseDamage(self.unit.handle, self.index)
441
+ end,
442
+ set = function(self, damageBase)
443
+ BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
444
+ end
445
+ },
446
+ true
447
+ )
448
+ __TS__SetDescriptor(
449
+ UnitWeapon.prototype,
450
+ "damageDiceCount",
451
+ {
452
+ get = function(self)
453
+ return BlzGetUnitDiceNumber(self.unit.handle, self.index)
454
+ end,
455
+ set = function(self, damageDiceCount)
456
+ BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
457
+ end
458
+ },
459
+ true
460
+ )
461
+ __TS__SetDescriptor(
462
+ UnitWeapon.prototype,
463
+ "damageDiceSideCount",
464
+ {
465
+ get = function(self)
466
+ return BlzGetUnitDiceSides(self.unit.handle, self.index)
467
+ end,
468
+ set = function(self, damageDiceSideCount)
469
+ BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
470
+ end
471
+ },
472
+ true
473
+ )
474
+ __TS__SetDescriptor(
475
+ UnitWeapon.prototype,
476
+ "range",
477
+ {
478
+ get = function(self)
479
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
480
+ end,
481
+ set = function(self, range)
482
+ local handle = self.unit.handle
483
+ local index = self.index
484
+ setUnitWeaponRealField(
485
+ handle,
486
+ UNIT_WEAPON_RF_ATTACK_RANGE,
487
+ index + 1,
488
+ getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
489
+ )
490
+ end
491
+ },
492
+ true
493
+ )
494
+ __TS__SetDescriptor(
495
+ UnitWeapon.prototype,
496
+ "impactDelay",
497
+ {
498
+ get = function(self)
499
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
500
+ end,
501
+ set = function(self, impactDelay)
502
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
503
+ end
504
+ },
505
+ true
506
+ )
507
+ __TS__SetDescriptor(
508
+ UnitWeapon.prototype,
509
+ "missileArc",
510
+ {
511
+ get = function(self)
512
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
513
+ end,
514
+ set = function(self, missileArc)
515
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
516
+ end
517
+ },
518
+ true
519
+ )
520
+ __TS__SetDescriptor(
521
+ UnitWeapon.prototype,
522
+ "missileModelPath",
523
+ {
524
+ get = function(self)
525
+ return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
526
+ end,
527
+ set = function(self, missileModelPath)
528
+ setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
529
+ end
530
+ },
531
+ true
532
+ )
533
+ __TS__SetDescriptor(
534
+ UnitWeapon.prototype,
535
+ "missileSpeed",
536
+ {
537
+ get = function(self)
538
+ return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
539
+ end,
540
+ set = function(self, missileSpeed)
541
+ setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
542
+ end
543
+ },
544
+ true
545
+ )
435
546
  local unitInventorySize = UnitInventorySize
436
547
  local unitItemInSlot = UnitItemInSlot
437
548
  local getItemAbility = BlzGetItemAbility
@@ -442,8 +553,6 @@ local getAbilityName = GetAbilityName
442
553
  local unitAddAbility = UnitAddAbility
443
554
  local getUnitGoldCost = GetUnitGoldCost
444
555
  local getUnitLumberCost = GetUnitWoodCost
445
- local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
446
- local unitAddItem = UnitAddItem
447
556
  local unitRemoveAbility = UnitRemoveAbility
448
557
  local function retrieveAbility(unit, ability, abilityId)
449
558
  if ability == nil then
@@ -520,6 +629,23 @@ for ____, player in ipairs(Player.all) do
520
629
  ShowUnit(dummy, false)
521
630
  dummies[player] = dummy
522
631
  end
632
+ local function delayHealthChecksCallback(unit)
633
+ local counter = (unit[102] or 0) - 1
634
+ if counter ~= 0 then
635
+ unit[102] = counter
636
+ return
637
+ end
638
+ unit[102] = nil
639
+ local healthBonus = unit[103]
640
+ if healthBonus ~= nil then
641
+ unit[103] = nil
642
+ local handle = unit.handle
643
+ BlzSetUnitMaxHP(
644
+ handle,
645
+ BlzGetUnitMaxHP(handle) - healthBonus
646
+ )
647
+ end
648
+ end
523
649
  ____exports.Unit = __TS__Class()
524
650
  local Unit = ____exports.Unit
525
651
  Unit.name = "Unit"
@@ -674,6 +800,10 @@ end
674
800
  function Unit.prototype.queueAnimation(self, animation)
675
801
  queueUnitAnimation(self.handle, animation)
676
802
  end
803
+ function Unit.prototype.delayHealthChecks(self)
804
+ self[102] = (self[102] or 0) + 1
805
+ Timer:run(delayHealthChecksCallback, self)
806
+ end
677
807
  function Unit.prototype.setPosition(self, x, y)
678
808
  setUnitPosition(self.handle, x, y)
679
809
  end
@@ -784,6 +914,9 @@ end
784
914
  function Unit.prototype.hideAbility(self, abilityId, flag)
785
915
  BlzUnitHideAbility(self.handle, abilityId, flag)
786
916
  end
917
+ function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
918
+ return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
919
+ end
787
920
  function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
788
921
  BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
789
922
  end
@@ -1071,12 +1204,27 @@ __TS__SetDescriptor(
1071
1204
  Unit.prototype,
1072
1205
  "weapons",
1073
1206
  {get = function(self)
1074
- local weapons = {
1075
- setmetatable({h = self.handle, i = 0}, weaponMetatable),
1076
- setmetatable({h = self.handle, i = 1}, weaponMetatable)
1077
- }
1078
- rawset(self, "weapons", weapons)
1079
- return weapons
1207
+ return {self.firstWeapon, self.secondWeapon}
1208
+ end},
1209
+ true
1210
+ )
1211
+ __TS__SetDescriptor(
1212
+ Unit.prototype,
1213
+ "firstWeapon",
1214
+ {get = function(self)
1215
+ local weapon = __TS__New(____exports.UnitWeapon, self, 0)
1216
+ rawset(self, "firstWeapon", weapon)
1217
+ return weapon
1218
+ end},
1219
+ true
1220
+ )
1221
+ __TS__SetDescriptor(
1222
+ Unit.prototype,
1223
+ "secondWeapon",
1224
+ {get = function(self)
1225
+ local weapon = __TS__New(____exports.UnitWeapon, self, 1)
1226
+ rawset(self, "secondWeapon", weapon)
1227
+ return weapon
1080
1228
  end},
1081
1229
  true
1082
1230
  )
@@ -1233,7 +1381,7 @@ __TS__SetDescriptor(
1233
1381
  "isTeamGlowVisible",
1234
1382
  {
1235
1383
  get = function(self)
1236
- return not self[103]
1384
+ return not self[105]
1237
1385
  end,
1238
1386
  set = function(self, isTeamGlowVisible)
1239
1387
  showUnitTeamGlow(self.handle, isTeamGlowVisible)
@@ -1243,7 +1391,7 @@ __TS__SetDescriptor(
1243
1391
  else
1244
1392
  ____temp_2 = nil
1245
1393
  end
1246
- self[103] = ____temp_2
1394
+ self[105] = ____temp_2
1247
1395
  end
1248
1396
  },
1249
1397
  true
@@ -1253,7 +1401,7 @@ __TS__SetDescriptor(
1253
1401
  "color",
1254
1402
  {set = function(self, color)
1255
1403
  setUnitColor(self.handle, color.handle)
1256
- if self[103] then
1404
+ if self[105] then
1257
1405
  showUnitTeamGlow(self.handle, false)
1258
1406
  end
1259
1407
  end},
@@ -1277,10 +1425,14 @@ __TS__SetDescriptor(
1277
1425
  "maxHealth",
1278
1426
  {
1279
1427
  get = function(self)
1280
- return BlzGetUnitMaxHP(self.handle) - (self[102] or 0)
1428
+ return BlzGetUnitMaxHP(self.handle) - (self[103] or 0) - (self[104] or 0)
1281
1429
  end,
1282
1430
  set = function(self, maxHealth)
1283
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[102] or 0))
1431
+ if maxHealth < 1 and self[102] ~= nil then
1432
+ self[103] = (self[103] or 0) + (1 - maxHealth)
1433
+ maxHealth = 1
1434
+ end
1435
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[104] or 0))
1284
1436
  end
1285
1437
  },
1286
1438
  true
@@ -1322,10 +1474,10 @@ __TS__SetDescriptor(
1322
1474
  "health",
1323
1475
  {
1324
1476
  get = function(self)
1325
- return GetWidgetLife(self.handle) - (self[102] or 0)
1477
+ return GetWidgetLife(self.handle) - (self[104] or 0)
1326
1478
  end,
1327
1479
  set = function(self, health)
1328
- SetWidgetLife(self.handle, health + (self[102] or 0))
1480
+ SetWidgetLife(self.handle, health + (self[104] or 0))
1329
1481
  end
1330
1482
  },
1331
1483
  true
@@ -2308,7 +2460,7 @@ Unit.onDamage = __TS__New(
2308
2460
  invoke(event, source, target, evData)
2309
2461
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2310
2462
  local bonusHealth = math.ceil(evData.amount)
2311
- target[102] = (target[102] or 0) + bonusHealth
2463
+ target[104] = (target[104] or 0) + bonusHealth
2312
2464
  BlzSetUnitMaxHP(
2313
2465
  target.handle,
2314
2466
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2322,7 +2474,7 @@ Unit.onDamage = __TS__New(
2322
2474
  evData[0],
2323
2475
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2324
2476
  )
2325
- target[102] = (target[102] or 0) - bonusHealth
2477
+ target[104] = (target[104] or 0) - bonusHealth
2326
2478
  SetWidgetLife(
2327
2479
  target.handle,
2328
2480
  GetWidgetLife(target.handle) - bonusHealth
@@ -0,0 +1,10 @@
1
+ /** @noSelfInFile */
2
+ import { AbilityType, AbilityTypeId } from "../ability-type";
3
+ import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
4
+ export declare class MineAbilityType extends AbilityType {
5
+ static readonly BASE_ID: AbilityTypeId;
6
+ get activationDelay(): number[];
7
+ set activationDelay(activationDelay: ObjectDataEntryLevelFieldValueSupplier<number>);
8
+ get invisibilityDelay(): number[];
9
+ set invisibilityDelay(invisibilityDelay: ObjectDataEntryLevelFieldValueSupplier<number>);
10
+ }