warscript 0.0.1-dev.ba37a78 → 0.0.1-dev.c59dd14

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.
@@ -0,0 +1,13 @@
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
+ /** @noSelfInFile */
3
+ export type Attribute<T> = {
4
+ readonly __attribute: unique symbol;
5
+ readonly __type: T;
6
+ } & symbol;
7
+ export declare namespace Attribute {
8
+ const create: <T>() => Attribute<T>;
9
+ }
10
+ export declare class AttributesHolder {
11
+ readonly get: (<T>(attribute: Attribute<T>) => T | undefined) & LuaExtension<"TableGetMethod">;
12
+ readonly set: (<T>(attribute: Attribute<T>, value: T | undefined) => void) & LuaExtension<"TableSetMethod">;
13
+ }
package/attributes.lua ADDED
@@ -0,0 +1,16 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local ____exports = {}
4
+ ____exports.Attribute = {}
5
+ local Attribute = ____exports.Attribute
6
+ do
7
+ Attribute.create = function()
8
+ return {}
9
+ end
10
+ end
11
+ ____exports.AttributesHolder = __TS__Class()
12
+ local AttributesHolder = ____exports.AttributesHolder
13
+ AttributesHolder.name = "AttributesHolder"
14
+ function AttributesHolder.prototype.____constructor(self)
15
+ end
16
+ return ____exports
@@ -1,5 +1,6 @@
1
1
  /** @noSelfInFile */
2
2
  import { Event } from "../../event";
3
+ import { AttributesHolder } from "../../attributes";
3
4
  export type HandleConstructor<H extends jhandle, T extends Handle<H>, Args extends any[]> = new (handle: H, ...args: Args) => T;
4
5
  export type HandleDestructor = {
5
6
  readonly __handleDestructor: unique symbol;
@@ -11,7 +12,7 @@ type NoOverride = {
11
12
  declare const enum HandlePropertyKey {
12
13
  STATE = 0
13
14
  }
14
- export declare class Handle<H extends jhandle, DestroyParameters extends any[] = []> implements Destroyable {
15
+ export declare class Handle<H extends jhandle, DestroyParameters extends any[] = []> extends AttributesHolder implements Destroyable {
15
16
  readonly handle: H;
16
17
  private [HandlePropertyKey.STATE]?;
17
18
  private onDestroyEvent?;
@@ -1,5 +1,6 @@
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__Delete = ____lualib.__TS__Delete
5
6
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
@@ -12,13 +13,17 @@ local getClass = ____reflection.getClass
12
13
  local getSuperclass = ____reflection.getSuperclass
13
14
  local ____exception = require("exception")
14
15
  local IllegalStateException = ____exception.IllegalStateException
16
+ local ____attributes = require("attributes")
17
+ local AttributesHolder = ____attributes.AttributesHolder
15
18
  local getHandleId = GetHandleId
16
19
  local onCreateEventByHandleConstructor = {}
17
20
  local onDestroyEventByHandleConstructor = {}
18
21
  ____exports.Handle = __TS__Class()
19
22
  local Handle = ____exports.Handle
20
23
  Handle.name = "Handle"
24
+ __TS__ClassExtends(Handle, AttributesHolder)
21
25
  function Handle.prototype.____constructor(self, handle)
26
+ AttributesHolder.prototype.____constructor(self)
22
27
  self[0] = 0
23
28
  local id = getHandleId(handle)
24
29
  local clazz = self.constructor
@@ -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
@@ -3,14 +3,13 @@ import { AbilityBehavior } from "../ability";
3
3
  import { Ability } from "../../internal/ability";
4
4
  import { UnitBehavior } from "../unit";
5
5
  import { Unit } from "../../internal/unit";
6
- import { MutableKeys } from "../../../utility/types";
7
6
  import { AbilityDependentValue } from "../../object-field/ability";
8
7
  export declare class ApplyUnitBehaviorAbilityBehavior<T extends UnitBehavior> extends AbilityBehavior {
9
8
  private readonly unitBehaviorConstructor;
10
9
  private readonly parameters?;
11
10
  private readonly keys?;
12
11
  private unitBehavior?;
13
- constructor(ability: Ability, unitBehaviorConstructor: new (unit: Unit) => T, parameters?: Partial<{ [K in MutableKeys<T> & KeysOfType<T, string | number | boolean>]: T[K] extends string | number | boolean ? AbilityDependentValue<T[K]> : never; }> | undefined);
12
+ constructor(ability: Ability, unitBehaviorConstructor: new (unit: Unit) => T, parameters?: Partial<{ [K in keyof T & { [P in keyof T]-?: (<T_1>() => T_1 extends { [Q in P]: T[P]; } ? 1 : 2) extends <T_2>() => T_2 extends { -readonly [Q_1 in P]: T[P]; } ? 1 : 2 ? P : never; }[keyof T] & KeysOfType<T, string | number | boolean>]: T[K] extends string | number | boolean ? AbilityDependentValue<T[K]> : never; }> | undefined);
14
13
  update(): void;
15
14
  onUnitGainAbility(unit: Unit): void;
16
15
  onUnitLoseAbility(): void;
@@ -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;