warscript 0.0.1-dev.07e3832 → 0.0.1-dev.099f0af

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.
Files changed (38) hide show
  1. package/binaryreader.d.ts +1 -0
  2. package/binaryreader.lua +3 -0
  3. package/core/types/frame.d.ts +2 -0
  4. package/core/types/frame.lua +20 -1
  5. package/engine/behaviour/ability/apply-buff.d.ts +3 -5
  6. package/engine/behaviour/ability/damage.d.ts +25 -21
  7. package/engine/behaviour/ability/damage.lua +54 -55
  8. package/engine/behaviour/ability/heal.d.ts +33 -6
  9. package/engine/behaviour/ability/heal.lua +89 -10
  10. package/engine/behaviour/unit.d.ts +5 -0
  11. package/engine/behaviour/unit.lua +20 -0
  12. package/engine/buff.d.ts +60 -18
  13. package/engine/buff.lua +239 -62
  14. package/engine/internal/item+owner.lua +2 -2
  15. package/engine/internal/unit/bonus.d.ts +4 -2
  16. package/engine/internal/unit/bonus.lua +6 -1
  17. package/engine/internal/unit/item.d.ts +22 -0
  18. package/engine/internal/unit/item.lua +63 -0
  19. package/engine/internal/unit+ability.lua +2 -2
  20. package/engine/internal/unit.d.ts +5 -3
  21. package/engine/internal/unit.lua +11 -5
  22. package/engine/object-data/entry/item-type.d.ts +12 -0
  23. package/engine/object-data/entry/item-type.lua +78 -0
  24. package/engine/object-field/ability.d.ts +17 -0
  25. package/engine/object-field/ability.lua +50 -0
  26. package/engine/unit.d.ts +1 -0
  27. package/engine/unit.lua +1 -0
  28. package/net/socket.d.ts +7 -1
  29. package/net/socket.lua +45 -4
  30. package/network.d.ts +1 -0
  31. package/network.lua +3 -2
  32. package/objutil/buff.lua +1 -1
  33. package/package.json +2 -2
  34. package/property.d.ts +55 -0
  35. package/property.lua +374 -0
  36. package/utility/linked-set.d.ts +11 -2
  37. package/utility/linked-set.lua +5 -2
  38. package/utility/types.d.ts +1 -0
package/binaryreader.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare class BinaryReader {
3
3
  private readonly s;
4
4
  private i;
5
5
  constructor(data: string);
6
+ toString(): string;
6
7
  read(fmt: string): any;
7
8
  readBytes(size: number): string;
8
9
  readDouble(): number;
package/binaryreader.lua CHANGED
@@ -9,6 +9,9 @@ function BinaryReader.prototype.____constructor(self, data)
9
9
  self.i = 1
10
10
  self.s = data
11
11
  end
12
+ function BinaryReader.prototype.__tostring(self)
13
+ return self.s
14
+ end
12
15
  function BinaryReader.prototype.read(self, fmt)
13
16
  local value, pos = ____unpack(">" .. fmt, self.s, self.i)
14
17
  self.i = pos
@@ -25,11 +25,13 @@ export declare class Frame extends Handle<jframehandle> {
25
25
  static readonly GAME_UI: Frame;
26
26
  static readonly CONSOLE_UI: Frame;
27
27
  static readonly CONSOLE_UI_BACKDROP: Frame;
28
+ private static readonly CONSOLE_UI_BACKDROP_UI_SCALE_HELPER_CHILD;
28
29
  static readonly CONSOLE_TOP_BAR: Frame;
29
30
  static readonly CONSOLE_BOTTOM_BAR: Frame;
30
31
  static readonly WORLD: Frame;
31
32
  static readonly CHAT: Frame;
32
33
  static readonly TIME_OF_DAY_CLOCK: Frame;
34
+ static get uiScale(): number;
33
35
  static get leftBorder(): Frame;
34
36
  static get rightBorder(): Frame;
35
37
  static get minX(): number;
@@ -62,8 +62,10 @@ local function updateBorders()
62
62
  local width4by3 = (w - h / 600 * 800) / 2
63
63
  local pxtodpi = 0.6 / h
64
64
  BlzFrameSetAbsPoint(leftBorder, FRAMEPOINT_TOPLEFT, -width4by3 * pxtodpi, 0.6)
65
+ BlzFrameSetScale(leftBorder, 1)
65
66
  BlzFrameSetSize(leftBorder, 0.001, 0.6)
66
67
  BlzFrameSetAbsPoint(rightBorder, FRAMEPOINT_TOPRIGHT, (-width4by3 + w) * pxtodpi, 0.6)
68
+ BlzFrameSetScale(rightBorder, 1)
67
69
  BlzFrameSetSize(rightBorder, 0.001, 0.6)
68
70
  end
69
71
  local worldFrame = BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0)
@@ -267,7 +269,16 @@ function Frame.createSimple(self, name, parent, createContext)
267
269
  ))
268
270
  end
269
271
  function Frame.create(self, name, parent, priority, createContext)
270
- return self:of(BlzCreateFrame(name, parent.handle, priority or 0, createContext or 0))
272
+ if parent == ____exports.Frame.CONSOLE_UI_BACKDROP then
273
+ local helper = ____exports.Frame.CONSOLE_UI_BACKDROP_UI_SCALE_HELPER_CHILD.handle
274
+ BlzFrameSetScale(helper, 1)
275
+ local frame = BlzCreateFrame(name, helper, priority or 0, createContext or 0)
276
+ BlzFrameSetScale(helper, ____exports.Frame.uiScale)
277
+ BlzFrameSetParent(frame, ____exports.Frame.CONSOLE_UI_BACKDROP.handle)
278
+ return self:of(frame)
279
+ else
280
+ return self:of(BlzCreateFrame(name, parent.handle, priority or 0, createContext or 0))
281
+ end
271
282
  end
272
283
  function Frame.createByType(self, typeName, name, parent, inherits, createContext)
273
284
  return self:of(BlzCreateFrameByType(
@@ -293,11 +304,19 @@ end
293
304
  Frame.GAME_UI = ____exports.Frame:byOrigin(ORIGIN_FRAME_GAME_UI)
294
305
  Frame.CONSOLE_UI = ____exports.Frame:byOrigin(ORIGIN_FRAME_SIMPLE_UI_PARENT)
295
306
  Frame.CONSOLE_UI_BACKDROP = ____exports.Frame:byName("ConsoleUIBackdrop")
307
+ Frame.CONSOLE_UI_BACKDROP_UI_SCALE_HELPER_CHILD = ____exports.Frame:createByType("FRAME", "ConsoleUIBackdropUIScaleHelperChild", ____exports.Frame.CONSOLE_UI_BACKDROP)
296
308
  Frame.CONSOLE_TOP_BAR = ____exports.Frame:byName("ConsoleTopBar")
297
309
  Frame.CONSOLE_BOTTOM_BAR = ____exports.Frame:byName("ConsoleBottomBar")
298
310
  Frame.WORLD = ____exports.Frame:byOrigin(ORIGIN_FRAME_WORLD_FRAME)
299
311
  Frame.CHAT = ____exports.Frame:byOrigin(ORIGIN_FRAME_CHAT_MSG)
300
312
  Frame.TIME_OF_DAY_CLOCK = ____exports.Frame.GAME_UI:getChild(5):getChild(0)
313
+ __TS__ObjectDefineProperty(
314
+ Frame,
315
+ "uiScale",
316
+ {get = function(self)
317
+ return ____exports.Frame.CONSOLE_BOTTOM_BAR.width / 0.8
318
+ end}
319
+ )
301
320
  __TS__ObjectDefineProperty(
302
321
  Frame,
303
322
  "leftBorder",
@@ -1,11 +1,9 @@
1
1
  /** @noSelfInFile */
2
2
  import { AbilityBehavior } from "../ability";
3
3
  import { Ability } from "../../internal/ability";
4
- import { Buff, BuffConstructor, BuffParameters, BuffTypeIdSelectionPolicy } from "../../buff";
4
+ import { Buff, BuffConstructor, BuffParameters, BuffPolarityParameterType, BuffResistanceTypeParameterType, BuffTypeIdSelectionPolicy } from "../../buff";
5
5
  import { Unit } from "../../internal/unit";
6
6
  import { ApplicableBuffTypeId } from "../../object-data/entry/buff-type/applicable";
7
- import { BuffResistanceType } from "../../object-data/auxiliary/buff-resistance-type";
8
- import { BuffPolarity } from "../../object-data/auxiliary/buff-polarity";
9
7
  import { Widget } from "../../../core/types/widget";
10
8
  type BuffParametersType<T extends BuffConstructor> = BuffParameters & Omit<BuffAdditionalParametersType<T>, keyof BuffParameters>;
11
9
  type BuffAdditionalParametersType<T extends BuffConstructor> = T extends BuffConstructor<Buff<infer AdditionalParameters>> ? AdditionalParameters : never;
@@ -17,8 +15,8 @@ export declare abstract class ApplyBuffAbilityBehavior<T extends BuffConstructor
17
15
  typeIds: [ApplicableBuffTypeId, ...ApplicableBuffTypeId[]],
18
16
  typeIdSelectionPolicy: BuffTypeIdSelectionPolicy
19
17
  ],
20
- polarity: BuffPolarity,
21
- resistanceType: BuffResistanceType,
18
+ polarity: BuffPolarityParameterType,
19
+ resistanceType: BuffResistanceTypeParameterType,
22
20
  parameters?: BuffParametersType<T>
23
21
  ]);
24
22
  }
@@ -5,37 +5,41 @@ import { Unit } from "../../internal/unit";
5
5
  import { AbilityDependentValue } from "../../object-field/ability";
6
6
  import { Widget } from "../../../core/types/widget";
7
7
  import { AttackType, DamageType, WeaponType } from "../../internal/unit+damage";
8
- export declare class DamageSelfAbilityBehavior extends AbilityBehavior {
9
- private readonly damage;
10
- private readonly attackType?;
11
- private readonly damageType?;
12
- private readonly weaponType?;
13
- constructor(ability: Ability, damage: AbilityDependentValue<number>, attackType?: AttackType | undefined, damageType?: DamageType | undefined, weaponType?: WeaponType | undefined);
8
+ export type DamageAbilityBehaviorParameters = {
9
+ damagePerStrength?: AbilityDependentValue<number>;
10
+ damagePerAgility?: AbilityDependentValue<number>;
11
+ damagePerIntelligence?: AbilityDependentValue<number>;
12
+ attackType?: AttackType;
13
+ damageType?: DamageType;
14
+ weaponType?: WeaponType;
15
+ };
16
+ export type DamageAreaAbilityBehaviorParameters = DamageAbilityBehaviorParameters & {
17
+ maximumDamage?: AbilityDependentValue<number>;
18
+ };
19
+ declare abstract class DamageAbilityBehavior<T extends DamageAbilityBehaviorParameters = DamageAbilityBehaviorParameters> extends AbilityBehavior {
20
+ protected readonly damage: AbilityDependentValue<number>;
21
+ protected readonly parameters?: T | undefined;
22
+ protected constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: T | undefined);
23
+ protected calculateDamage(caster: Unit): number;
24
+ }
25
+ export declare class DamageSelfAbilityBehavior extends DamageAbilityBehavior {
26
+ constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAbilityBehaviorParameters);
14
27
  onImpact(caster: Unit): void;
15
28
  }
16
- export declare class DamageTargetAbilityBehavior extends AbilityBehavior {
17
- private readonly damage;
18
- private readonly attackType?;
19
- private readonly damageType?;
20
- private readonly weaponType?;
21
- constructor(ability: Ability, damage: AbilityDependentValue<number>, attackType?: AttackType | undefined, damageType?: DamageType | undefined, weaponType?: WeaponType | undefined);
29
+ export declare class DamageTargetAbilityBehavior extends DamageAbilityBehavior {
30
+ constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAbilityBehaviorParameters);
22
31
  onWidgetTargetImpact(caster: Unit, target: Widget): void;
23
32
  }
24
- declare abstract class DamageAreaAbilityBehavior extends AbilityBehavior {
25
- private readonly damage;
26
- private readonly maximumDamage?;
27
- private readonly attackType?;
28
- private readonly damageType?;
29
- private readonly weaponType?;
30
- protected constructor(ability: Ability, damage: AbilityDependentValue<number>, maximumDamage?: AbilityDependentValue<number> | undefined, attackType?: AttackType | undefined, damageType?: DamageType | undefined, weaponType?: WeaponType | undefined);
33
+ declare abstract class DamageAreaAbilityBehavior extends DamageAbilityBehavior<DamageAreaAbilityBehaviorParameters> {
34
+ protected constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAreaAbilityBehaviorParameters);
31
35
  protected damageArea(caster: Unit, x: number, y: number): void;
32
36
  }
33
37
  export declare class DamageSelfAreaAbilityBehavior extends DamageAreaAbilityBehavior {
34
- constructor(ability: Ability, damage: AbilityDependentValue<number>, maximumDamage?: AbilityDependentValue<number>, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType);
38
+ constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAreaAbilityBehaviorParameters);
35
39
  onImpact(caster: Unit): void;
36
40
  }
37
41
  export declare class DamageTargetAreaAbilityBehavior extends DamageAreaAbilityBehavior {
38
- constructor(ability: Ability, damage: AbilityDependentValue<number>, maximumDamage?: AbilityDependentValue<number>, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType);
42
+ constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAreaAbilityBehaviorParameters);
39
43
  onNoTargetImpact(caster: Unit): void;
40
44
  onWidgetTargetImpact(caster: Unit, target: Widget): void;
41
45
  onPointTargetImpact(caster: Unit, x: number, y: number): void;
@@ -9,62 +9,77 @@ local Unit = ____unit.Unit
9
9
  local ____ability = require("engine.standard.fields.ability")
10
10
  local ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD = ____ability.ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD
11
11
  local AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD = ____ability.AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD
12
+ local DamageAbilityBehavior = __TS__Class()
13
+ DamageAbilityBehavior.name = "DamageAbilityBehavior"
14
+ __TS__ClassExtends(DamageAbilityBehavior, AbilityBehavior)
15
+ function DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
16
+ AbilityBehavior.prototype.____constructor(self, ability)
17
+ self.damage = damage
18
+ self.parameters = parameters
19
+ end
20
+ function DamageAbilityBehavior.prototype.calculateDamage(self, caster)
21
+ local parameters = self.parameters
22
+ local damage = self:resolveCurrentAbilityDependentValue(self.damage)
23
+ local damagePerStrength = self:resolveCurrentAbilityDependentValue(parameters and parameters.damagePerStrength or 0)
24
+ if damagePerStrength ~= 0 then
25
+ damage = damage + damagePerStrength * caster.strength
26
+ end
27
+ local damagePerAgility = self:resolveCurrentAbilityDependentValue(parameters and parameters.damagePerAgility or 0)
28
+ if damagePerAgility ~= 0 then
29
+ damage = damage + damagePerAgility * caster.agility
30
+ end
31
+ local damagePerIntelligence = self:resolveCurrentAbilityDependentValue(parameters and parameters.damagePerIntelligence or 0)
32
+ if damagePerIntelligence ~= 0 then
33
+ damage = damage + damagePerIntelligence * caster.intelligence
34
+ end
35
+ return damage
36
+ end
12
37
  ____exports.DamageSelfAbilityBehavior = __TS__Class()
13
38
  local DamageSelfAbilityBehavior = ____exports.DamageSelfAbilityBehavior
14
39
  DamageSelfAbilityBehavior.name = "DamageSelfAbilityBehavior"
15
- __TS__ClassExtends(DamageSelfAbilityBehavior, AbilityBehavior)
16
- function DamageSelfAbilityBehavior.prototype.____constructor(self, ability, damage, attackType, damageType, weaponType)
17
- AbilityBehavior.prototype.____constructor(self, ability)
18
- self.damage = damage
19
- self.attackType = attackType
20
- self.damageType = damageType
21
- self.weaponType = weaponType
40
+ __TS__ClassExtends(DamageSelfAbilityBehavior, DamageAbilityBehavior)
41
+ function DamageSelfAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
42
+ DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
22
43
  end
23
44
  function DamageSelfAbilityBehavior.prototype.onImpact(self, caster)
45
+ local parameters = self.parameters
24
46
  caster:damageTarget(
25
47
  caster,
26
- self:resolveCurrentAbilityDependentValue(self.damage),
48
+ self:calculateDamage(caster),
27
49
  nil,
28
50
  nil,
29
- self.attackType,
30
- self.damageType,
31
- self.weaponType
51
+ parameters and parameters.attackType,
52
+ parameters and parameters.damageType,
53
+ parameters and parameters.weaponType
32
54
  )
33
55
  end
34
56
  ____exports.DamageTargetAbilityBehavior = __TS__Class()
35
57
  local DamageTargetAbilityBehavior = ____exports.DamageTargetAbilityBehavior
36
58
  DamageTargetAbilityBehavior.name = "DamageTargetAbilityBehavior"
37
- __TS__ClassExtends(DamageTargetAbilityBehavior, AbilityBehavior)
38
- function DamageTargetAbilityBehavior.prototype.____constructor(self, ability, damage, attackType, damageType, weaponType)
39
- AbilityBehavior.prototype.____constructor(self, ability)
40
- self.damage = damage
41
- self.attackType = attackType
42
- self.damageType = damageType
43
- self.weaponType = weaponType
59
+ __TS__ClassExtends(DamageTargetAbilityBehavior, DamageAbilityBehavior)
60
+ function DamageTargetAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
61
+ DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
44
62
  end
45
63
  function DamageTargetAbilityBehavior.prototype.onWidgetTargetImpact(self, caster, target)
64
+ local parameters = self.parameters
46
65
  caster:damageTarget(
47
66
  target,
48
- self:resolveCurrentAbilityDependentValue(self.damage),
67
+ self:calculateDamage(caster),
49
68
  nil,
50
69
  nil,
51
- self.attackType,
52
- self.damageType,
53
- self.weaponType
70
+ parameters and parameters.attackType,
71
+ parameters and parameters.damageType,
72
+ parameters and parameters.weaponType
54
73
  )
55
74
  end
56
75
  local DamageAreaAbilityBehavior = __TS__Class()
57
76
  DamageAreaAbilityBehavior.name = "DamageAreaAbilityBehavior"
58
- __TS__ClassExtends(DamageAreaAbilityBehavior, AbilityBehavior)
59
- function DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage, maximumDamage, attackType, damageType, weaponType)
60
- AbilityBehavior.prototype.____constructor(self, ability)
61
- self.damage = damage
62
- self.maximumDamage = maximumDamage
63
- self.attackType = attackType
64
- self.damageType = damageType
65
- self.weaponType = weaponType
77
+ __TS__ClassExtends(DamageAreaAbilityBehavior, DamageAbilityBehavior)
78
+ function DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
79
+ DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
66
80
  end
67
81
  function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
82
+ local parameters = self.parameters
68
83
  local targets = Unit.getAllowedTargetsInCollisionRange(
69
84
  caster,
70
85
  self:resolveCurrentAbilityDependentValue(ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD),
@@ -72,8 +87,8 @@ function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
72
87
  y,
73
88
  self:resolveCurrentAbilityDependentValue(AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD)
74
89
  )
75
- local damage = self:resolveCurrentAbilityDependentValue(self.damage)
76
- local maximumDamage = self:resolveCurrentAbilityDependentValue(self.maximumDamage or 0)
90
+ local damage = self:calculateDamage(caster)
91
+ local maximumDamage = self:resolveCurrentAbilityDependentValue(parameters and parameters.maximumDamage or 0)
77
92
  if maximumDamage ~= 0 and damage > maximumDamage then
78
93
  damage = maximumDamage / #targets
79
94
  end
@@ -83,9 +98,9 @@ function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
83
98
  damage,
84
99
  nil,
85
100
  nil,
86
- self.attackType,
87
- self.damageType,
88
- self.weaponType
101
+ parameters and parameters.attackType,
102
+ parameters and parameters.damageType,
103
+ parameters and parameters.weaponType
89
104
  )
90
105
  end
91
106
  end
@@ -93,16 +108,8 @@ ____exports.DamageSelfAreaAbilityBehavior = __TS__Class()
93
108
  local DamageSelfAreaAbilityBehavior = ____exports.DamageSelfAreaAbilityBehavior
94
109
  DamageSelfAreaAbilityBehavior.name = "DamageSelfAreaAbilityBehavior"
95
110
  __TS__ClassExtends(DamageSelfAreaAbilityBehavior, DamageAreaAbilityBehavior)
96
- function DamageSelfAreaAbilityBehavior.prototype.____constructor(self, ability, damage, maximumDamage, attackType, damageType, weaponType)
97
- DamageAreaAbilityBehavior.prototype.____constructor(
98
- self,
99
- ability,
100
- damage,
101
- maximumDamage,
102
- attackType,
103
- damageType,
104
- weaponType
105
- )
111
+ function DamageSelfAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
112
+ DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
106
113
  end
107
114
  function DamageSelfAreaAbilityBehavior.prototype.onImpact(self, caster)
108
115
  self:damageArea(caster, caster.x, caster.y)
@@ -111,16 +118,8 @@ ____exports.DamageTargetAreaAbilityBehavior = __TS__Class()
111
118
  local DamageTargetAreaAbilityBehavior = ____exports.DamageTargetAreaAbilityBehavior
112
119
  DamageTargetAreaAbilityBehavior.name = "DamageTargetAreaAbilityBehavior"
113
120
  __TS__ClassExtends(DamageTargetAreaAbilityBehavior, DamageAreaAbilityBehavior)
114
- function DamageTargetAreaAbilityBehavior.prototype.____constructor(self, ability, damage, maximumDamage, attackType, damageType, weaponType)
115
- DamageAreaAbilityBehavior.prototype.____constructor(
116
- self,
117
- ability,
118
- damage,
119
- maximumDamage,
120
- attackType,
121
- damageType,
122
- weaponType
123
- )
121
+ function DamageTargetAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
122
+ DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
124
123
  end
125
124
  function DamageTargetAreaAbilityBehavior.prototype.onNoTargetImpact(self, caster)
126
125
  self:damageArea(caster, caster.x, caster.y)
@@ -4,13 +4,40 @@ import { Ability } from "../../internal/ability";
4
4
  import { Unit } from "../../internal/unit";
5
5
  import { AbilityDependentValue } from "../../object-field/ability";
6
6
  import { AbilityBehavior } from "../ability";
7
- export declare class HealSelfAbilityBehavior extends AbilityBehavior {
8
- private readonly healing;
9
- constructor(ability: Ability, healing: AbilityDependentValue<number>);
7
+ export type HealAbilityBehaviorParameters = {
8
+ healingPerStrength?: AbilityDependentValue<number>;
9
+ healingPerAgility?: AbilityDependentValue<number>;
10
+ healingPerIntelligence?: AbilityDependentValue<number>;
11
+ };
12
+ export type HealAreaAbilityBehaviorParameters = HealAbilityBehaviorParameters & {
13
+ maximumHealing?: AbilityDependentValue<number>;
14
+ };
15
+ declare abstract class HealAbilityBehavior<T extends HealAbilityBehaviorParameters = HealAbilityBehaviorParameters> extends AbilityBehavior {
16
+ protected readonly healing: AbilityDependentValue<number>;
17
+ protected readonly parameters?: T | undefined;
18
+ protected constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: T | undefined);
19
+ protected calculateHealing(caster: Unit): number;
20
+ }
21
+ export declare class HealSelfAbilityBehavior extends HealAbilityBehavior {
22
+ constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAbilityBehaviorParameters);
23
+ onImpact(caster: Unit): void;
24
+ }
25
+ export declare class HealTargetAbilityBehavior extends HealAbilityBehavior {
26
+ constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAbilityBehaviorParameters);
27
+ onWidgetTargetImpact(caster: Unit, target: Widget): void;
28
+ }
29
+ declare abstract class HealAreaAbilityBehavior extends HealAbilityBehavior<HealAreaAbilityBehaviorParameters> {
30
+ protected constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAreaAbilityBehaviorParameters);
31
+ protected healArea(caster: Unit, x: number, y: number): void;
32
+ }
33
+ export declare class HealSelfAreaAbilityBehavior extends HealAreaAbilityBehavior {
34
+ constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAreaAbilityBehaviorParameters);
10
35
  onImpact(caster: Unit): void;
11
36
  }
12
- export declare class HealTargetAbilityBehavior extends AbilityBehavior {
13
- private readonly healing;
14
- constructor(ability: Ability, healing: AbilityDependentValue<number>);
37
+ export declare class HealTargetAreaAbilityBehavior extends HealAreaAbilityBehavior {
38
+ constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAreaAbilityBehaviorParameters);
39
+ onNoTargetImpact(caster: Unit): void;
15
40
  onWidgetTargetImpact(caster: Unit, target: Widget): void;
41
+ onPointTargetImpact(caster: Unit, x: number, y: number): void;
16
42
  }
43
+ export {};
@@ -2,34 +2,113 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
4
  local ____exports = {}
5
+ local ____unit = require("engine.internal.unit")
6
+ local Unit = ____unit.Unit
5
7
  local ____ability = require("engine.behaviour.ability")
6
8
  local AbilityBehavior = ____ability.AbilityBehavior
9
+ local ____ability = require("engine.standard.fields.ability")
10
+ local ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD = ____ability.ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD
11
+ local AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD = ____ability.AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD
12
+ local HealAbilityBehavior = __TS__Class()
13
+ HealAbilityBehavior.name = "HealAbilityBehavior"
14
+ __TS__ClassExtends(HealAbilityBehavior, AbilityBehavior)
15
+ function HealAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
16
+ AbilityBehavior.prototype.____constructor(self, ability)
17
+ self.healing = healing
18
+ self.parameters = parameters
19
+ end
20
+ function HealAbilityBehavior.prototype.calculateHealing(self, caster)
21
+ local parameters = self.parameters
22
+ local healing = self:resolveCurrentAbilityDependentValue(self.healing)
23
+ local healingPerStrength = self:resolveCurrentAbilityDependentValue(parameters and parameters.healingPerStrength or 0)
24
+ if healingPerStrength ~= 0 then
25
+ healing = healing + healingPerStrength * caster.strength
26
+ end
27
+ local healingPerAgility = self:resolveCurrentAbilityDependentValue(parameters and parameters.healingPerAgility or 0)
28
+ if healingPerAgility ~= 0 then
29
+ healing = healing + healingPerAgility * caster.agility
30
+ end
31
+ local healingPerIntelligence = self:resolveCurrentAbilityDependentValue(parameters and parameters.healingPerIntelligence or 0)
32
+ if healingPerIntelligence ~= 0 then
33
+ healing = healing + healingPerIntelligence * caster.intelligence
34
+ end
35
+ return healing
36
+ end
7
37
  ____exports.HealSelfAbilityBehavior = __TS__Class()
8
38
  local HealSelfAbilityBehavior = ____exports.HealSelfAbilityBehavior
9
39
  HealSelfAbilityBehavior.name = "HealSelfAbilityBehavior"
10
- __TS__ClassExtends(HealSelfAbilityBehavior, AbilityBehavior)
11
- function HealSelfAbilityBehavior.prototype.____constructor(self, ability, healing)
12
- AbilityBehavior.prototype.____constructor(self, ability)
13
- self.healing = healing
40
+ __TS__ClassExtends(HealSelfAbilityBehavior, HealAbilityBehavior)
41
+ function HealSelfAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
42
+ HealAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
14
43
  end
15
44
  function HealSelfAbilityBehavior.prototype.onImpact(self, caster)
16
45
  caster:healTarget(
17
46
  caster,
18
- self:resolveCurrentAbilityDependentValue(self.healing)
47
+ self:calculateHealing(caster)
19
48
  )
20
49
  end
21
50
  ____exports.HealTargetAbilityBehavior = __TS__Class()
22
51
  local HealTargetAbilityBehavior = ____exports.HealTargetAbilityBehavior
23
52
  HealTargetAbilityBehavior.name = "HealTargetAbilityBehavior"
24
- __TS__ClassExtends(HealTargetAbilityBehavior, AbilityBehavior)
25
- function HealTargetAbilityBehavior.prototype.____constructor(self, ability, healing)
26
- AbilityBehavior.prototype.____constructor(self, ability)
27
- self.healing = healing
53
+ __TS__ClassExtends(HealTargetAbilityBehavior, HealAbilityBehavior)
54
+ function HealTargetAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
55
+ HealAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
28
56
  end
29
57
  function HealTargetAbilityBehavior.prototype.onWidgetTargetImpact(self, caster, target)
30
58
  caster:healTarget(
31
59
  target,
32
- self:resolveCurrentAbilityDependentValue(self.healing)
60
+ self:calculateHealing(caster)
61
+ )
62
+ end
63
+ local HealAreaAbilityBehavior = __TS__Class()
64
+ HealAreaAbilityBehavior.name = "HealAreaAbilityBehavior"
65
+ __TS__ClassExtends(HealAreaAbilityBehavior, HealAbilityBehavior)
66
+ function HealAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
67
+ HealAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
68
+ end
69
+ function HealAreaAbilityBehavior.prototype.healArea(self, caster, x, y)
70
+ local targets = Unit.getAllowedTargetsInCollisionRange(
71
+ caster,
72
+ self:resolveCurrentAbilityDependentValue(ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD),
73
+ x,
74
+ y,
75
+ self:resolveCurrentAbilityDependentValue(AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD)
33
76
  )
77
+ local healing = self:calculateHealing(caster)
78
+ local ____self_resolveCurrentAbilityDependentValue_8 = self.resolveCurrentAbilityDependentValue
79
+ local ____opt_6 = self.parameters
80
+ local maximumHealing = ____self_resolveCurrentAbilityDependentValue_8(self, ____opt_6 and ____opt_6.maximumHealing or 0)
81
+ if maximumHealing ~= 0 and healing > maximumHealing then
82
+ healing = maximumHealing / #targets
83
+ end
84
+ for ____, target in ipairs(targets) do
85
+ caster:healTarget(target, healing)
86
+ end
87
+ end
88
+ ____exports.HealSelfAreaAbilityBehavior = __TS__Class()
89
+ local HealSelfAreaAbilityBehavior = ____exports.HealSelfAreaAbilityBehavior
90
+ HealSelfAreaAbilityBehavior.name = "HealSelfAreaAbilityBehavior"
91
+ __TS__ClassExtends(HealSelfAreaAbilityBehavior, HealAreaAbilityBehavior)
92
+ function HealSelfAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
93
+ HealAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
94
+ end
95
+ function HealSelfAreaAbilityBehavior.prototype.onImpact(self, caster)
96
+ self:healArea(caster, caster.x, caster.y)
97
+ end
98
+ ____exports.HealTargetAreaAbilityBehavior = __TS__Class()
99
+ local HealTargetAreaAbilityBehavior = ____exports.HealTargetAreaAbilityBehavior
100
+ HealTargetAreaAbilityBehavior.name = "HealTargetAreaAbilityBehavior"
101
+ __TS__ClassExtends(HealTargetAreaAbilityBehavior, HealAreaAbilityBehavior)
102
+ function HealTargetAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
103
+ HealAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
104
+ end
105
+ function HealTargetAreaAbilityBehavior.prototype.onNoTargetImpact(self, caster)
106
+ self:healArea(caster, caster.x, caster.y)
107
+ end
108
+ function HealTargetAreaAbilityBehavior.prototype.onWidgetTargetImpact(self, caster, target)
109
+ self:healArea(caster, target.x, target.y)
110
+ end
111
+ function HealTargetAreaAbilityBehavior.prototype.onPointTargetImpact(self, caster, x, y)
112
+ self:healArea(caster, x, y)
34
113
  end
35
114
  return ____exports
@@ -4,6 +4,7 @@ import { Ability } from "../internal/ability";
4
4
  import { DamageEvent, DamagingEvent, Unit } from "../internal/unit";
5
5
  import "../internal/unit+ability";
6
6
  import "../internal/unit-missile-launch";
7
+ import { Item } from "../internal/item";
7
8
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
8
9
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
9
10
  constructor(unit: Unit);
@@ -16,6 +17,10 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
16
17
  onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
17
18
  onAbilityGained(ability: Ability): void;
18
19
  onAbilityLost(ability: Ability): void;
20
+ onItemDropped(item: Item): void;
21
+ onItemPickedUp(item: Item): void;
22
+ onItemUsed(item: Item): void;
23
+ onItemStacked(item: Item): void;
19
24
  onKill(target: Unit): void;
20
25
  onDeath(source: Unit | undefined): void;
21
26
  }
@@ -32,6 +32,14 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
32
32
  end
33
33
  function UnitBehavior.prototype.onAbilityLost(self, ability)
34
34
  end
35
+ function UnitBehavior.prototype.onItemDropped(self, item)
36
+ end
37
+ function UnitBehavior.prototype.onItemPickedUp(self, item)
38
+ end
39
+ function UnitBehavior.prototype.onItemUsed(self, item)
40
+ end
41
+ function UnitBehavior.prototype.onItemStacked(self, item)
42
+ end
35
43
  function UnitBehavior.prototype.onKill(self, target)
36
44
  end
37
45
  function UnitBehavior.prototype.onDeath(self, source)
@@ -75,6 +83,18 @@ __TS__SetDescriptor(
75
83
  end
76
84
  ____exports.UnitBehavior:forAll(target, "onDeath", source)
77
85
  end)
86
+ Unit.itemDroppedEvent:addListener(function(unit, item)
87
+ ____exports.UnitBehavior:forAll(unit, "onItemDropped", item)
88
+ end)
89
+ Unit.itemPickedUpEvent:addListener(function(unit, item)
90
+ ____exports.UnitBehavior:forAll(unit, "onItemPickedUp", item)
91
+ end)
92
+ Unit.itemUsedEvent:addListener(function(unit, item)
93
+ ____exports.UnitBehavior:forAll(unit, "onItemUsed", item)
94
+ end)
95
+ Unit.itemStackedEvent:addListener(function(unit, item)
96
+ ____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
97
+ end)
78
98
  end)(UnitBehavior)
79
99
  Unit.destroyEvent:addListener(function(unit)
80
100
  ____exports.UnitBehavior:forAll(unit, "destroy")