warscript 0.0.1-dev.aaf0a9d → 0.0.1-dev.b3e4d60

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 (111) hide show
  1. package/attributes.d.ts +12 -0
  2. package/attributes.lua +16 -0
  3. package/binaryreader.d.ts +1 -0
  4. package/binaryreader.lua +3 -0
  5. package/core/types/frame.d.ts +2 -1
  6. package/core/types/frame.lua +2 -0
  7. package/core/types/group.d.ts +0 -1
  8. package/core/types/handle.d.ts +2 -1
  9. package/core/types/handle.lua +5 -0
  10. package/core/types/image.d.ts +0 -1
  11. package/core/types/missile.d.ts +2 -2
  12. package/core/types/missile.lua +8 -2
  13. package/core/types/unit.lua +8 -0
  14. package/decl/index.d.ts +1 -0
  15. package/engine/ability.d.ts +1 -1
  16. package/engine/behavior.d.ts +10 -10
  17. package/engine/behaviour/ability/apply-unit-behavior.d.ts +13 -4
  18. package/engine/behaviour/ability/apply-unit-behavior.lua +31 -9
  19. package/engine/behaviour/ability/damage.d.ts +33 -11
  20. package/engine/behaviour/ability/damage.lua +89 -31
  21. package/engine/behaviour/ability/heal.d.ts +33 -6
  22. package/engine/behaviour/ability/heal.lua +89 -10
  23. package/engine/behaviour/ability/instant-impact.lua +4 -0
  24. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  25. package/engine/behaviour/ability/restore-mana.lua +29 -0
  26. package/engine/behaviour/ability.d.ts +8 -1
  27. package/engine/behaviour/ability.lua +62 -0
  28. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  29. package/engine/behaviour/unit.d.ts +3 -2
  30. package/engine/behaviour/unit.lua +7 -0
  31. package/engine/buff.d.ts +2 -2
  32. package/engine/buff.lua +8 -10
  33. package/engine/game-map.d.ts +7 -0
  34. package/engine/game-map.lua +32 -0
  35. package/engine/internal/ability.d.ts +1 -1
  36. package/engine/internal/mechanics/ability-duration.d.ts +1 -3
  37. package/engine/internal/mechanics/ability-duration.lua +2 -0
  38. package/engine/internal/mechanics/cast-ability.d.ts +2 -0
  39. package/engine/internal/mechanics/cast-ability.lua +86 -0
  40. package/engine/internal/unit/bonus.d.ts +5 -6
  41. package/engine/internal/unit/detach-missiles.d.ts +7 -0
  42. package/engine/internal/unit/detach-missiles.lua +30 -0
  43. package/engine/internal/unit+transport.lua +4 -10
  44. package/engine/internal/unit-missile-launch.lua +1 -1
  45. package/engine/internal/unit.d.ts +37 -10
  46. package/engine/internal/unit.lua +248 -88
  47. package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
  48. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  49. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  50. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  51. package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
  52. package/engine/object-data/entry/ability-type/blink.lua +39 -0
  53. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  54. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  55. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  56. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  57. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  58. package/engine/object-data/entry/ability-type.d.ts +1 -1
  59. package/engine/object-data/entry/ability-type.lua +1 -0
  60. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  61. package/engine/object-data/entry/buff-type/applicable.lua +27 -71
  62. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  63. package/engine/object-data/entry/buff-type.d.ts +0 -1
  64. package/engine/object-data/entry/destructible-type.d.ts +0 -1
  65. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  66. package/engine/object-data/entry/item-type.d.ts +0 -1
  67. package/engine/object-data/entry/lightning-type.d.ts +0 -1
  68. package/engine/object-data/entry/unit-type.d.ts +42 -2
  69. package/engine/object-data/entry/unit-type.lua +378 -50
  70. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  71. package/engine/object-data/entry/upgrade.d.ts +0 -1
  72. package/engine/object-data/entry.d.ts +2 -3
  73. package/engine/object-field/ability.d.ts +8 -6
  74. package/engine/object-field/ability.lua +6 -0
  75. package/engine/object-field/unit.d.ts +1 -0
  76. package/engine/object-field/unit.lua +3 -0
  77. package/engine/object-field.d.ts +6 -5
  78. package/engine/object-field.lua +37 -15
  79. package/engine/random.d.ts +1 -0
  80. package/engine/random.lua +9 -0
  81. package/engine/standard/entries/unit-type.d.ts +42 -1
  82. package/engine/standard/entries/unit-type.lua +42 -1
  83. package/engine/standard/fields/ability.d.ts +1 -1
  84. package/engine/standard/fields/ability.lua +1 -1
  85. package/engine/unit.d.ts +1 -0
  86. package/engine/unit.lua +10 -2
  87. package/event.d.ts +2 -3
  88. package/event.lua +9 -5
  89. package/global/vec2.lua +1 -0
  90. package/lualib_bundle.lua +146 -42
  91. package/math/vec2.d.ts +2 -9
  92. package/math.d.ts +0 -2
  93. package/objutil/ability.d.ts +0 -1
  94. package/objutil/buff.d.ts +0 -1
  95. package/objutil/object.d.ts +0 -1
  96. package/objutil/unit.d.ts +0 -1
  97. package/package.json +13 -14
  98. package/property.d.ts +55 -0
  99. package/property.lua +378 -0
  100. package/string.d.ts +30 -0
  101. package/string.lua +14 -0
  102. package/util/stream.d.ts +0 -1
  103. package/utility/arrays.d.ts +3 -4
  104. package/utility/bit-set.d.ts +0 -2
  105. package/utility/linked-set.d.ts +2 -2
  106. package/utility/linked-set.lua +16 -0
  107. package/utility/lua-maps.d.ts +1 -2
  108. package/utility/lua-sets.d.ts +1 -2
  109. package/utility/types.d.ts +2 -2
  110. package/core/mapbounds.d.ts +0 -8
  111. package/core/mapbounds.lua +0 -12
@@ -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
@@ -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)
@@ -0,0 +1,15 @@
1
+ /** @noSelfInFile */
2
+ import { Ability } from "../../internal/ability";
3
+ import { Unit } from "../../internal/unit";
4
+ import { AbilityDependentValue } from "../../object-field/ability";
5
+ import { AbilityBehavior } from "../ability";
6
+ export declare class RestoreManaSelfAbilityBehavior extends AbilityBehavior {
7
+ private readonly mana;
8
+ constructor(ability: Ability, mana: AbilityDependentValue<number>);
9
+ onImpact(caster: Unit): void;
10
+ }
11
+ export declare class RestoreManaAbilityBehavior extends AbilityBehavior {
12
+ private readonly mana;
13
+ constructor(ability: Ability, mana: AbilityDependentValue<number>);
14
+ onUnitTargetImpact(caster: Unit, target: Unit): void;
15
+ }
@@ -0,0 +1,29 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local ____exports = {}
5
+ local ____ability = require("engine.behaviour.ability")
6
+ local AbilityBehavior = ____ability.AbilityBehavior
7
+ ____exports.RestoreManaSelfAbilityBehavior = __TS__Class()
8
+ local RestoreManaSelfAbilityBehavior = ____exports.RestoreManaSelfAbilityBehavior
9
+ RestoreManaSelfAbilityBehavior.name = "RestoreManaSelfAbilityBehavior"
10
+ __TS__ClassExtends(RestoreManaSelfAbilityBehavior, AbilityBehavior)
11
+ function RestoreManaSelfAbilityBehavior.prototype.____constructor(self, ability, mana)
12
+ AbilityBehavior.prototype.____constructor(self, ability)
13
+ self.mana = mana
14
+ end
15
+ function RestoreManaSelfAbilityBehavior.prototype.onImpact(self, caster)
16
+ caster.mana = caster.mana + self:resolveCurrentAbilityDependentValue(self.mana)
17
+ end
18
+ ____exports.RestoreManaAbilityBehavior = __TS__Class()
19
+ local RestoreManaAbilityBehavior = ____exports.RestoreManaAbilityBehavior
20
+ RestoreManaAbilityBehavior.name = "RestoreManaAbilityBehavior"
21
+ __TS__ClassExtends(RestoreManaAbilityBehavior, AbilityBehavior)
22
+ function RestoreManaAbilityBehavior.prototype.____constructor(self, ability, mana)
23
+ AbilityBehavior.prototype.____constructor(self, ability)
24
+ self.mana = mana
25
+ end
26
+ function RestoreManaAbilityBehavior.prototype.onUnitTargetImpact(self, caster, target)
27
+ target.mana = target.mana + self:resolveCurrentAbilityDependentValue(self.mana)
28
+ end
29
+ return ____exports
@@ -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)
@@ -1,4 +1,3 @@
1
- /// <reference types="@typescript-to-lua/language-extensions" />
2
1
  /** @noSelfInFile */
3
2
  import { UnitBehavior } from "../unit";
4
3
  import { Unit } from "../../unit";
@@ -2,6 +2,7 @@
2
2
  import { Behavior } from "../behavior";
3
3
  import { Ability } from "../internal/ability";
4
4
  import { DamageEvent, DamagingEvent, Unit } from "../internal/unit";
5
+ import "../internal/unit+ability";
5
6
  import "../internal/unit-missile-launch";
6
7
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
7
8
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
@@ -13,8 +14,8 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
13
14
  onDamageDealt(target: Unit, event: DamageEvent): void;
14
15
  onDamageReceiving(source: Unit | undefined, event: DamagingEvent): void;
15
16
  onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
16
- protected onAbilityGained(ability: Ability): void;
17
- protected onAbilityLost(ability: Ability): void;
17
+ onAbilityGained(ability: Ability): void;
18
+ onAbilityLost(ability: Ability): void;
18
19
  onKill(target: Unit): void;
19
20
  onDeath(source: Unit | undefined): void;
20
21
  }
@@ -7,6 +7,7 @@ local ____behavior = require("engine.behavior")
7
7
  local Behavior = ____behavior.Behavior
8
8
  local ____unit = require("engine.internal.unit")
9
9
  local Unit = ____unit.Unit
10
+ require("engine.internal.unit+ability")
10
11
  require("engine.internal.unit-missile-launch")
11
12
  ____exports.UnitBehavior = __TS__Class()
12
13
  local UnitBehavior = ____exports.UnitBehavior
@@ -62,6 +63,12 @@ __TS__SetDescriptor(
62
63
  end
63
64
  ____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
64
65
  end)
66
+ Unit.abilityGainedEvent:addListener(function(source, target)
67
+ ____exports.UnitBehavior:forAll(source, "onAbilityGained", target)
68
+ end)
69
+ Unit.abilityLostEvent:addListener(function(source, target)
70
+ ____exports.UnitBehavior:forAll(source, "onAbilityLost", target)
71
+ end)
65
72
  Unit.deathEvent:addListener(function(target, source)
66
73
  if source ~= nil then
67
74
  ____exports.UnitBehavior:forAll(source, "onKill", target)
package/engine/buff.d.ts CHANGED
@@ -65,7 +65,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
65
65
  destroysOnDamage?: BooleanParameterValueType;
66
66
  maximumAutoAttackCount?: IntegerParameterValueType;
67
67
  uniqueGroup?: BuffUniqueGroup;
68
- } : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : {});
68
+ } : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
69
69
  declare const enum BuffPropertyKey {
70
70
  UNIT = 100,
71
71
  SOURCE = 101,
@@ -116,7 +116,7 @@ export type BuffConstructorParameters<AdditionalParameters extends BuffAdditiona
116
116
  parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
117
117
  ] | [parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>]
118
118
  ];
119
- export declare class Buff<AdditionalParameters extends Prohibit<Record<string, any>, keyof BuffParameters> = {}> extends UnitBehavior {
119
+ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, any>, keyof BuffParameters> = object> extends UnitBehavior {
120
120
  private _unit;
121
121
  protected readonly __additionalParametersBrand?: AdditionalParameters;
122
122
  private [BuffPropertyKey.UNIT];
package/engine/buff.lua CHANGED
@@ -1035,24 +1035,22 @@ __TS__SetDescriptor(
1035
1035
  true
1036
1036
  );
1037
1037
  (function(self)
1038
+ local function destroyBuffIfNeeded(buff)
1039
+ if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1040
+ buff:destroy()
1041
+ end
1042
+ end
1038
1043
  ____exports.checkBuff = function(unit, buffTypeId)
1039
1044
  local buffByTypeId = buffByTypeIdByUnit[unit]
1040
1045
  if buffByTypeId ~= nil then
1041
1046
  local buff = buffByTypeId[buffTypeId]
1042
- if buff ~= nil and getUnitAbility(unit.handle, buffTypeId) ~= buff.handle then
1043
- buff:destroy()
1047
+ if buff ~= nil then
1048
+ destroyBuffIfNeeded(buff)
1044
1049
  end
1045
1050
  end
1046
1051
  end
1047
1052
  ____exports.checkBuffs = function(unit)
1048
- local buffByTypeId = buffByTypeIdByUnit[unit]
1049
- if buffByTypeId ~= nil then
1050
- for ____, buff in pairs(buffByTypeId) do
1051
- if getUnitAbility(unit.handle, buff.typeId) ~= buff.handle then
1052
- buff:destroy()
1053
- end
1054
- end
1055
- end
1053
+ ____exports.Buff:forAll(unit, destroyBuffIfNeeded)
1056
1054
  end
1057
1055
  Unit.abilityChannelingStartEvent:addListener(
1058
1056
  0,
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ import { Rect } from "../core/types/rect";
3
+ import { Region } from "../core/types/region";
4
+ export declare class GameMap {
5
+ static get worldBoundsRect(): Rect;
6
+ static get worldBoundsRegion(): Region;
7
+ }
@@ -0,0 +1,32 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
4
+ local ____exports = {}
5
+ local ____rect = require("core.types.rect")
6
+ local Rect = ____rect.Rect
7
+ local ____region = require("core.types.region")
8
+ local Region = ____region.Region
9
+ ____exports.GameMap = __TS__Class()
10
+ local GameMap = ____exports.GameMap
11
+ GameMap.name = "GameMap"
12
+ function GameMap.prototype.____constructor(self)
13
+ end
14
+ __TS__ObjectDefineProperty(
15
+ GameMap,
16
+ "worldBoundsRect",
17
+ {get = function(self)
18
+ local rect = Rect:of(GetWorldBounds())
19
+ rawset(self, "worldBoundsRect", rect)
20
+ return rect
21
+ end}
22
+ )
23
+ __TS__ObjectDefineProperty(
24
+ GameMap,
25
+ "worldBoundsRegion",
26
+ {get = function(self)
27
+ local region = Region:create(self.worldBoundsRect)
28
+ rawset(self, "worldBoundsRegion", region)
29
+ return region
30
+ end}
31
+ )
32
+ return ____exports
@@ -12,7 +12,7 @@ interface Fields<K, V> {
12
12
  interface AbilityLevel {
13
13
  realFields: Fields<jabilityreallevelfield, number>;
14
14
  }
15
- type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
15
+ export type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
16
16
  export declare class AbilitySnapshot {
17
17
  }
18
18
  export declare abstract class Ability extends Handle<jability> {
@@ -1,4 +1,2 @@
1
1
  /** @noSelfInFile */
2
- import { Ability } from "../ability";
3
- import { Unit } from "../unit";
4
- export declare const getAbilityDuration: (ability: Ability, target?: Unit) => number;
2
+ export {};
@@ -4,6 +4,8 @@ local UnitClassification = ____unit.UnitClassification
4
4
  local ____ability = require("engine.standard.fields.ability")
5
5
  local DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD
6
6
  local DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD
7
+ ---
8
+ -- @internal For use by internal systems only.
7
9
  ____exports.getAbilityDuration = function(ability, target)
8
10
  local level = ability.level
9
11
  return target ~= nil and target:hasClassification(UnitClassification.RESISTANT) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,86 @@
1
+ local ____exports = {}
2
+ local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
3
+ local AbilityType = ____ability_2Dtype.AbilityType
4
+ local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
5
+ local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
6
+ local ____dummy_2Dunits = require("engine.internal.misc.dummy-units")
7
+ local INVENTORY_DUMMY_NATIVE_UNIT = ____dummy_2Dunits.INVENTORY_DUMMY_NATIVE_UNIT
8
+ local ____preconditions = require("utility.preconditions")
9
+ local checkNotNull = ____preconditions.checkNotNull
10
+ local ____dummy_2Dinventory = require("engine.internal.object-data.dummy-inventory")
11
+ local INVENTORY_ABILITY_TYPE_ID = ____dummy_2Dinventory.INVENTORY_ABILITY_TYPE_ID
12
+ local ____arrays = require("utility.arrays")
13
+ local map = ____arrays.map
14
+ local toLuaSet = ____arrays.toLuaSet
15
+ local createItem = CreateItem
16
+ local getAbilityId = BlzGetAbilityId
17
+ local getItemAbility = BlzGetItemAbility
18
+ local getUnitAbilityByIndex = BlzGetUnitAbilityByIndex
19
+ local itemAddAbility = BlzItemAddAbility
20
+ local setItemBooleanField = BlzSetItemBooleanField
21
+ local removeItem = RemoveItem
22
+ local unitAddAbility = UnitAddAbility
23
+ local unitAddItem = UnitAddItem
24
+ local unitDropItemSlot = UnitDropItemSlot
25
+ local unitInventorySize = UnitInventorySize
26
+ local unitRemoveAbility = UnitRemoveAbility
27
+ local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
28
+ local INVENTORY_ABILITY_TYPE_IDS = postcompile(function()
29
+ return toLuaSet(AbilityType:getAllIdsByBaseIds(map({
30
+ "AInv",
31
+ "Aihn",
32
+ "Aien",
33
+ "Aion",
34
+ "Aiun"
35
+ }, fourCC)))
36
+ end)
37
+ ---
38
+ -- @internal For use by internal systems only.
39
+ ____exports.castAbility = function(nativeUnit, abilityTypeId, prepareAbility, ...)
40
+ local nativeItem = createItem(DUMMY_ITEM_ID, 0, 0)
41
+ unitAddItem(INVENTORY_DUMMY_NATIVE_UNIT, nativeItem)
42
+ itemAddAbility(nativeItem, abilityTypeId)
43
+ local nativeAbility = checkNotNull(getItemAbility(nativeItem, abilityTypeId))
44
+ if prepareAbility ~= nil then
45
+ prepareAbility(nativeAbility, ...)
46
+ end
47
+ setItemBooleanField(nativeItem, ITEM_BF_ACTIVELY_USED, true)
48
+ setItemBooleanField(nativeItem, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
49
+ local success
50
+ if unitAddItem(nativeUnit, nativeItem) then
51
+ success = true
52
+ else
53
+ local latestInventoryAbilityTypeId = 0
54
+ local nativeItemBySlot = {}
55
+ local inventorySize = unitInventorySize(nativeUnit)
56
+ if inventorySize ~= 0 then
57
+ for slot = 0, inventorySize - 1 do
58
+ nativeItemBySlot[slot] = unitRemoveItemFromSlot(nativeUnit, slot)
59
+ end
60
+ local unitNativeAbility = getUnitAbilityByIndex(nativeUnit, 0)
61
+ local i = 1
62
+ while unitNativeAbility ~= nil do
63
+ local abilityTypeId = getAbilityId(unitNativeAbility)
64
+ if INVENTORY_ABILITY_TYPE_IDS[abilityTypeId] ~= nil then
65
+ latestInventoryAbilityTypeId = abilityTypeId
66
+ end
67
+ unitNativeAbility = getUnitAbilityByIndex(nativeUnit, i)
68
+ i = i + 1
69
+ end
70
+ unitRemoveAbility(nativeUnit, latestInventoryAbilityTypeId)
71
+ end
72
+ unitAddAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
73
+ success = unitAddItem(nativeUnit, nativeItem)
74
+ unitRemoveAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
75
+ if latestInventoryAbilityTypeId ~= 0 then
76
+ unitAddAbility(nativeUnit, latestInventoryAbilityTypeId)
77
+ for slot, nativeItem in pairs(nativeItemBySlot) do
78
+ unitAddItem(nativeUnit, nativeItem)
79
+ unitDropItemSlot(nativeUnit, nativeItem, slot)
80
+ end
81
+ end
82
+ end
83
+ removeItem(nativeItem)
84
+ return success
85
+ end
86
+ return ____exports
@@ -1,4 +1,3 @@
1
- /// <reference types="@typescript-to-lua/language-extensions" />
2
1
  /** @noSelfInFile */
3
2
  import { Unit } from "../unit";
4
3
  import { AbilityTypeId } from "../../object-data/entry/ability-type";
@@ -34,8 +33,8 @@ export declare namespace UnitBonusType {
34
33
  const DAMAGE: UnitBonusType<UnitDamageBonusId>;
35
34
  const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
36
35
  }
37
- export declare const addUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
38
- export declare const removeUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
39
- export declare const updateUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id, value: number) => boolean;
40
- export declare const addOrUpdateOrRemoveUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id | undefined, value: number) => Id | undefined;
41
- export declare const getUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => number;
36
+ export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
37
+ export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
38
+ export declare const updateUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id, value: number) => boolean;
39
+ export declare const addOrUpdateOrRemoveUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id | undefined, value: number) => Id | undefined;
40
+ export declare const getUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => number;
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ detachMissiles(this: Unit): void;
5
+ }
6
+ }
7
+ export {};
@@ -0,0 +1,30 @@
1
+ local ____exports = {}
2
+ local ____unit = require("engine.internal.unit")
3
+ local Unit = ____unit.Unit
4
+ local ____cast_2Dability = require("engine.internal.mechanics.cast-ability")
5
+ local castAbility = ____cast_2Dability.castAbility
6
+ local ____blink = require("engine.object-data.entry.ability-type.blink")
7
+ local BlinkAbilityType = ____blink.BlinkAbilityType
8
+ local ____math = require("math")
9
+ local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
10
+ local getUnitX = GetUnitX
11
+ local getUnitY = GetUnitY
12
+ local setUnitX = SetUnitX
13
+ local setUnitY = SetUnitY
14
+ local BLINK_ABILITY_TYPE_ID = compiletime(function()
15
+ local abilityType = BlinkAbilityType:create()
16
+ abilityType.minimumRange = 0
17
+ abilityType.maximumRange = MAXIMUM_INTEGER
18
+ abilityType.manaCost = 0
19
+ abilityType.cooldown = 0
20
+ return abilityType.id
21
+ end)
22
+ Unit.prototype.detachMissiles = function(self)
23
+ local nativeUnit = self.handle
24
+ local x = getUnitX(nativeUnit)
25
+ local y = getUnitY(nativeUnit)
26
+ castAbility(nativeUnit, BLINK_ABILITY_TYPE_ID)
27
+ setUnitX(nativeUnit, x)
28
+ setUnitY(nativeUnit, y)
29
+ end
30
+ return ____exports
@@ -6,9 +6,8 @@ local ____unit = require("engine.internal.unit")
6
6
  local Unit = ____unit.Unit
7
7
  local ____event = require("event")
8
8
  local Event = ____event.Event
9
- local ____mapbounds = require("core.mapbounds")
10
- local boundMax = ____mapbounds.boundMax
11
- local boundRegion = ____mapbounds.boundRegion
9
+ local ____game_2Dmap = require("engine.game-map")
10
+ local GameMap = ____game_2Dmap.GameMap
12
11
  local eventInvoke = Event.invoke
13
12
  local tableRemove = table.remove
14
13
  local ____assert = _G.assert
@@ -58,8 +57,8 @@ triggerAddCondition(
58
57
  deboard(unit)
59
58
  end
60
59
  if not unitAlive(handle) then
61
- unit.x = boundMax.x
62
- unit.y = boundMax.y
60
+ unit.x = GameMap.worldBoundsRect.maxX
61
+ unit.y = GameMap.worldBoundsRect.maxY
63
62
  end
64
63
  local transport = Unit:of(getTransportUnit())
65
64
  transportByUnit[unit] = transport
@@ -68,11 +67,6 @@ triggerAddCondition(
68
67
  eventInvoke(onBoardEvent, unit, transport)
69
68
  end)
70
69
  )
71
- boundRegion.onUnitEnter:addListener(function(unit)
72
- if transportByUnit[unit] ~= nil and not isUnitLoaded(unit.handle) then
73
- deboard(unit)
74
- end
75
- end)
76
70
  Unit.deathEvent:addListener(function(unit)
77
71
  if transportByUnit[unit] ~= nil then
78
72
  deboard(unit)