warscript 0.0.1-dev.aaf0a9d → 0.0.1-dev.ac556d2

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 (157) 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/effect.d.ts +13 -3
  6. package/core/types/effect.lua +116 -17
  7. package/core/types/frame.d.ts +8 -1
  8. package/core/types/frame.lua +93 -1
  9. package/core/types/group.d.ts +0 -1
  10. package/core/types/handle.d.ts +2 -1
  11. package/core/types/handle.lua +5 -0
  12. package/core/types/image.d.ts +0 -1
  13. package/core/types/missile.d.ts +2 -2
  14. package/core/types/missile.lua +8 -2
  15. package/core/types/unit.lua +8 -0
  16. package/core/util.d.ts +1 -1
  17. package/core/util.lua +12 -0
  18. package/decl/index.d.ts +1 -0
  19. package/engine/ability.d.ts +1 -1
  20. package/engine/behavior.d.ts +10 -10
  21. package/engine/behavior.lua +6 -6
  22. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  23. package/engine/behaviour/ability/always-enabled.lua +31 -0
  24. package/engine/behaviour/ability/apply-buff.d.ts +3 -5
  25. package/engine/behaviour/ability/apply-unit-behavior.d.ts +13 -4
  26. package/engine/behaviour/ability/apply-unit-behavior.lua +31 -9
  27. package/engine/behaviour/ability/damage.d.ts +33 -11
  28. package/engine/behaviour/ability/damage.lua +89 -31
  29. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  30. package/engine/behaviour/ability/emulate-impact.lua +29 -0
  31. package/engine/behaviour/ability/heal.d.ts +33 -6
  32. package/engine/behaviour/ability/heal.lua +89 -10
  33. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  34. package/engine/behaviour/ability/instant-impact.lua +4 -15
  35. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  36. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  37. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  38. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  39. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  40. package/engine/behaviour/ability/restore-mana.lua +29 -0
  41. package/engine/behaviour/ability.d.ts +16 -2
  42. package/engine/behaviour/ability.lua +88 -12
  43. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  44. package/engine/behaviour/unit.d.ts +8 -2
  45. package/engine/behaviour/unit.lua +27 -0
  46. package/engine/buff.d.ts +68 -21
  47. package/engine/buff.lua +276 -90
  48. package/engine/game-map.d.ts +7 -0
  49. package/engine/game-map.lua +32 -0
  50. package/engine/internal/ability.d.ts +17 -14
  51. package/engine/internal/ability.lua +79 -76
  52. package/engine/internal/item/ability.lua +90 -0
  53. package/engine/internal/item+owner.lua +2 -2
  54. package/engine/internal/mechanics/ability-duration.d.ts +1 -3
  55. package/engine/internal/mechanics/ability-duration.lua +2 -0
  56. package/engine/internal/mechanics/cast-ability.d.ts +2 -0
  57. package/engine/internal/mechanics/cast-ability.lua +86 -0
  58. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  59. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  60. package/engine/internal/unit/ability.d.ts +10 -1
  61. package/engine/internal/unit/ability.lua +36 -14
  62. package/engine/internal/unit/bonus.d.ts +9 -8
  63. package/engine/internal/unit/bonus.lua +6 -1
  64. package/engine/internal/unit/detach-missiles.d.ts +7 -0
  65. package/engine/internal/unit/detach-missiles.lua +30 -0
  66. package/engine/internal/unit/item.d.ts +24 -0
  67. package/engine/internal/unit/item.lua +79 -0
  68. package/engine/internal/unit/main-selected.d.ts +13 -0
  69. package/engine/internal/unit/main-selected.lua +51 -0
  70. package/engine/internal/unit+ability.lua +2 -2
  71. package/engine/internal/unit+transport.lua +4 -10
  72. package/engine/internal/unit-missile-launch.lua +25 -6
  73. package/engine/internal/unit.d.ts +58 -16
  74. package/engine/internal/unit.lua +346 -126
  75. package/engine/internal/utility.lua +12 -0
  76. package/engine/local-client.d.ts +7 -2
  77. package/engine/local-client.lua +82 -0
  78. package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
  79. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  80. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  81. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  82. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  83. package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
  84. package/engine/object-data/entry/ability-type/blink.lua +39 -0
  85. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  86. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  87. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  88. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  89. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  90. package/engine/object-data/entry/ability-type.d.ts +1 -1
  91. package/engine/object-data/entry/ability-type.lua +9 -12
  92. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  93. package/engine/object-data/entry/buff-type/applicable.lua +27 -71
  94. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  95. package/engine/object-data/entry/buff-type.d.ts +0 -1
  96. package/engine/object-data/entry/destructible-type.d.ts +0 -1
  97. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  98. package/engine/object-data/entry/item-type.d.ts +14 -1
  99. package/engine/object-data/entry/item-type.lua +91 -0
  100. package/engine/object-data/entry/lightning-type.d.ts +0 -1
  101. package/engine/object-data/entry/unit-type.d.ts +42 -2
  102. package/engine/object-data/entry/unit-type.lua +378 -50
  103. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  104. package/engine/object-data/entry/upgrade.d.ts +0 -1
  105. package/engine/object-data/entry.d.ts +2 -3
  106. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  107. package/engine/object-field/ability.d.ts +28 -6
  108. package/engine/object-field/ability.lua +57 -1
  109. package/engine/object-field/unit.d.ts +1 -0
  110. package/engine/object-field/unit.lua +3 -0
  111. package/engine/object-field.d.ts +6 -5
  112. package/engine/object-field.lua +37 -15
  113. package/engine/random.d.ts +1 -0
  114. package/engine/random.lua +9 -0
  115. package/engine/standard/entries/unit-type.d.ts +42 -1
  116. package/engine/standard/entries/unit-type.lua +42 -1
  117. package/engine/standard/fields/ability.d.ts +3 -1
  118. package/engine/standard/fields/ability.lua +3 -1
  119. package/engine/unit.d.ts +3 -0
  120. package/engine/unit.lua +12 -2
  121. package/event.d.ts +2 -3
  122. package/event.lua +9 -5
  123. package/global/vec2.lua +1 -0
  124. package/index.d.ts +1 -0
  125. package/index.lua +1 -0
  126. package/lualib_bundle.lua +146 -42
  127. package/math/vec2.d.ts +2 -9
  128. package/math.d.ts +0 -2
  129. package/net/socket.d.ts +7 -1
  130. package/net/socket.lua +45 -4
  131. package/network.d.ts +1 -0
  132. package/network.lua +3 -2
  133. package/objutil/ability.d.ts +0 -1
  134. package/objutil/buff.d.ts +0 -1
  135. package/objutil/buff.lua +1 -1
  136. package/objutil/object.d.ts +0 -1
  137. package/objutil/unit.d.ts +0 -1
  138. package/package.json +13 -14
  139. package/patch-lua.d.ts +0 -0
  140. package/patch-lua.lua +10 -0
  141. package/property.d.ts +55 -0
  142. package/property.lua +374 -0
  143. package/string.d.ts +30 -0
  144. package/string.lua +14 -0
  145. package/util/stream.d.ts +0 -1
  146. package/utility/arrays.d.ts +11 -5
  147. package/utility/arrays.lua +34 -3
  148. package/utility/bit-set.d.ts +0 -2
  149. package/utility/lazy.d.ts +2 -0
  150. package/utility/lazy.lua +14 -0
  151. package/utility/linked-set.d.ts +12 -3
  152. package/utility/linked-set.lua +21 -2
  153. package/utility/lua-maps.d.ts +1 -2
  154. package/utility/lua-sets.d.ts +1 -2
  155. package/utility/types.d.ts +3 -2
  156. package/core/mapbounds.d.ts +0 -8
  157. 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
@@ -1,6 +1,6 @@
1
1
  /** @noSelfInFile */
2
- import { AbilityBehavior } from "../ability";
3
2
  import { Unit } from "../../internal/unit";
4
- export declare class InstantImpactAbilityBehavior extends AbilityBehavior {
3
+ import { EmulateImpactAbilityBehavior } from "./emulate-impact";
4
+ export declare class InstantImpactAbilityBehavior extends EmulateImpactAbilityBehavior {
5
5
  onCastingStart(caster: Unit): void;
6
6
  }
@@ -2,24 +2,13 @@ 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 ____ability = require("engine.behaviour.ability")
6
- local AbilityBehavior = ____ability.AbilityBehavior
7
- local ____ability = require("engine.standard.fields.ability")
8
- local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
9
- local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTEGER_LEVEL_FIELD
5
+ local ____emulate_2Dimpact = require("engine.behaviour.ability.emulate-impact")
6
+ local EmulateImpactAbilityBehavior = ____emulate_2Dimpact.EmulateImpactAbilityBehavior
10
7
  ____exports.InstantImpactAbilityBehavior = __TS__Class()
11
8
  local InstantImpactAbilityBehavior = ____exports.InstantImpactAbilityBehavior
12
9
  InstantImpactAbilityBehavior.name = "InstantImpactAbilityBehavior"
13
- __TS__ClassExtends(InstantImpactAbilityBehavior, AbilityBehavior)
10
+ __TS__ClassExtends(InstantImpactAbilityBehavior, EmulateImpactAbilityBehavior)
14
11
  function InstantImpactAbilityBehavior.prototype.onCastingStart(self, caster)
15
- local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
16
- local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
17
- caster.mana = caster.mana - manaCost
18
- if cooldown == 0 then
19
- caster:interruptCast(self.ability.typeId)
20
- else
21
- caster:startAbilityCooldown(self.ability.typeId, cooldown)
22
- end
23
- AbilityBehavior:forAll(self.ability, "onImpact", caster)
12
+ self:emulateImpact(caster)
24
13
  end
25
14
  return ____exports
@@ -0,0 +1,8 @@
1
+ /** @noSelfInFile */
2
+ import { Unit } from "../../internal/unit";
3
+ import { EmulateImpactAbilityBehavior } from "./emulate-impact";
4
+ import { Ability } from "../../internal/ability";
5
+ export declare class OnCommandImpactAbilityBehavior extends EmulateImpactAbilityBehavior {
6
+ constructor(ability: Ability);
7
+ onCommand(caster: Unit): void;
8
+ }
@@ -0,0 +1,25 @@
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 ____unit = require("engine.internal.unit")
6
+ local Unit = ____unit.Unit
7
+ local ____emulate_2Dimpact = require("engine.behaviour.ability.emulate-impact")
8
+ local EmulateImpactAbilityBehavior = ____emulate_2Dimpact.EmulateImpactAbilityBehavior
9
+ ____exports.OnCommandImpactAbilityBehavior = __TS__Class()
10
+ local OnCommandImpactAbilityBehavior = ____exports.OnCommandImpactAbilityBehavior
11
+ OnCommandImpactAbilityBehavior.name = "OnCommandImpactAbilityBehavior"
12
+ __TS__ClassExtends(OnCommandImpactAbilityBehavior, EmulateImpactAbilityBehavior)
13
+ function OnCommandImpactAbilityBehavior.prototype.____constructor(self, ability)
14
+ EmulateImpactAbilityBehavior.prototype.____constructor(self, ability)
15
+ self:registerCommandEvent()
16
+ end
17
+ function OnCommandImpactAbilityBehavior.prototype.onCommand(self, caster)
18
+ self:emulateImpact(caster)
19
+ end
20
+ Unit.itemUseOrderEvent:addListener(function(unit, item)
21
+ for ____, ability in ipairs(item.abilities) do
22
+ ____exports.OnCommandImpactAbilityBehavior:forAll(ability, "onCommand", unit)
23
+ end
24
+ end)
25
+ return ____exports
@@ -0,0 +1,16 @@
1
+ /** @noSelfInFile */
2
+ import { AbilityBehavior } from "../ability";
3
+ import { Unit } from "../../internal/unit";
4
+ import { Ability } from "../../internal/ability";
5
+ import { AbilityDependentValue } from "../../object-field/ability";
6
+ import { BuffPolarity } from "../../object-data/auxiliary/buff-polarity";
7
+ import { BuffResistanceType } from "../../object-data/auxiliary/buff-resistance-type";
8
+ export declare class RemoveBuffsSelfAbilityBehavior extends AbilityBehavior {
9
+ private readonly polarity?;
10
+ private readonly resistanceType?;
11
+ private readonly includeExpirationTimers?;
12
+ private readonly includeAuras?;
13
+ private readonly autoDispel?;
14
+ constructor(ability: Ability, polarity?: AbilityDependentValue<BuffPolarity> | undefined, resistanceType?: AbilityDependentValue<BuffResistanceType> | undefined, includeExpirationTimers?: AbilityDependentValue<boolean> | undefined, includeAuras?: AbilityDependentValue<boolean> | undefined, autoDispel?: AbilityDependentValue<boolean> | undefined);
15
+ onImpact(caster: Unit): void;
16
+ }
@@ -0,0 +1,28 @@
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.RemoveBuffsSelfAbilityBehavior = __TS__Class()
8
+ local RemoveBuffsSelfAbilityBehavior = ____exports.RemoveBuffsSelfAbilityBehavior
9
+ RemoveBuffsSelfAbilityBehavior.name = "RemoveBuffsSelfAbilityBehavior"
10
+ __TS__ClassExtends(RemoveBuffsSelfAbilityBehavior, AbilityBehavior)
11
+ function RemoveBuffsSelfAbilityBehavior.prototype.____constructor(self, ability, polarity, resistanceType, includeExpirationTimers, includeAuras, autoDispel)
12
+ AbilityBehavior.prototype.____constructor(self, ability)
13
+ self.polarity = polarity
14
+ self.resistanceType = resistanceType
15
+ self.includeExpirationTimers = includeExpirationTimers
16
+ self.includeAuras = includeAuras
17
+ self.autoDispel = autoDispel
18
+ end
19
+ function RemoveBuffsSelfAbilityBehavior.prototype.onImpact(self, caster)
20
+ caster:removeBuffs(
21
+ self:resolveCurrentAbilityDependentValue(self.polarity),
22
+ self:resolveCurrentAbilityDependentValue(self.resistanceType),
23
+ self:resolveCurrentAbilityDependentValue(self.includeExpirationTimers),
24
+ self:resolveCurrentAbilityDependentValue(self.includeAuras),
25
+ self:resolveCurrentAbilityDependentValue(self.autoDispel)
26
+ )
27
+ end
28
+ return ____exports
@@ -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,15 +9,29 @@ 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> {
13
- constructor(ability: Ability);
12
+ export type AbilityBehaviorParameters = {
13
+ isExclusiveOnImpactHandler?: boolean;
14
+ };
15
+ export declare abstract class AbilityBehavior<Parameters extends {
16
+ periodicActionParameters?: any[];
17
+ missileParameters?: any[];
18
+ } = {}> extends Behavior<Ability, NonNullable<Parameters["periodicActionParameters"]>> {
19
+ constructor(ability: Ability, parameters?: AbilityBehaviorParameters);
20
+ protected registerCommandEvent(orderTypeStringId?: string): void;
14
21
  get ability(): Ability;
15
22
  protected resolveCurrentAbilityDependentValue<T extends boolean | number | string>(value: AbilityDependentValue<T>): T;
23
+ protected resolveCurrentAbilityDependentValue<T extends boolean | number | string>(value?: AbilityDependentValue<T>): T | undefined;
24
+ protected flashCasterEffect(widget: Widget): void;
16
25
  protected flashAreaEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
17
26
  protected flashEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
18
27
  protected flashSpecialEffect(...args: [...pointOrWidget: [x: number, y: number] | [widget: Widget], duration?: number]): void;
28
+ private static MissileLaunchConfig;
29
+ private get missileLaunchConfig();
30
+ protected onCreate(): void;
31
+ onMissileArrival(...parameters: NonNullable<Parameters["missileParameters"]>): void;
19
32
  onUnitGainAbility(_unit: Unit): void;
20
33
  onUnitLoseAbility(_unit: Unit): void;
34
+ onCommand(caster: Unit, orderTypeStringId: string): void;
21
35
  onCastingStart(caster: Unit): void;
22
36
  onCastingFinish(caster: Unit): void;
23
37
  onChannelingStart(caster: Unit): void;
@@ -4,6 +4,7 @@ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
6
6
  local ____exports = {}
7
+ local createUnitEventListener
7
8
  local ____behavior = require("engine.behavior")
8
9
  local Behavior = ____behavior.Behavior
9
10
  local ____unit = require("engine.unit")
@@ -14,7 +15,12 @@ local ____effect = require("core.types.effect")
14
15
  local Effect = ____effect.Effect
15
16
  local ____ability = require("engine.standard.fields.ability")
16
17
  local AREA_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.AREA_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
18
+ local CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD = ____ability.CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD
19
+ local CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
17
20
  local EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
21
+ local MISSILE_ARC_ABILITY_FLOAT_FIELD = ____ability.MISSILE_ARC_ABILITY_FLOAT_FIELD
22
+ local MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
23
+ local MISSILE_SPEED_ABILITY_INTEGER_FIELD = ____ability.MISSILE_SPEED_ABILITY_INTEGER_FIELD
18
24
  local SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD = ____ability.SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD
19
25
  local SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
20
26
  local ____ability = require("engine.object-field.ability")
@@ -22,16 +28,80 @@ local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDep
22
28
  local ____timer = require("core.types.timer")
23
29
  local Timer = ____timer.Timer
24
30
  local createBehaviorFunctionsByAbilityTypeId = {}
31
+ local exclusiveOnImpactHandlerAbilityBehaviorByAbility = setmetatable({}, {__mode = "k"})
32
+ local function createZeroTimerUnitEventListener(key)
33
+ local unitEventListener = createUnitEventListener(key)
34
+ return function(unit, ability, ...)
35
+ Timer:run(unitEventListener, unit, ability, ...)
36
+ end
37
+ end
38
+ createUnitEventListener = function(key)
39
+ return function(unit, ability, ...)
40
+ ____exports.AbilityBehavior:forAll(ability, key, unit, ...)
41
+ end
42
+ end
43
+ local registeredCommandEventIds = {}
44
+ local ____class_2 = __TS__Class()
45
+ ____class_2.name = ""
46
+ function ____class_2.prototype.____constructor(self, abilityBehavior)
47
+ self.abilityBehavior = abilityBehavior
48
+ end
49
+ __TS__SetDescriptor(
50
+ ____class_2.prototype,
51
+ "art",
52
+ {get = function(self)
53
+ return MISSILE_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.abilityBehavior.ability, 0)
54
+ end},
55
+ true
56
+ )
57
+ __TS__SetDescriptor(
58
+ ____class_2.prototype,
59
+ "arc",
60
+ {get = function(self)
61
+ return MISSILE_ARC_ABILITY_FLOAT_FIELD:getValue(self.abilityBehavior.ability)
62
+ end},
63
+ true
64
+ )
65
+ __TS__SetDescriptor(
66
+ ____class_2.prototype,
67
+ "speed",
68
+ {get = function(self)
69
+ return MISSILE_SPEED_ABILITY_INTEGER_FIELD:getValue(self.abilityBehavior.ability)
70
+ end},
71
+ true
72
+ )
25
73
  ____exports.AbilityBehavior = __TS__Class()
26
74
  local AbilityBehavior = ____exports.AbilityBehavior
27
75
  AbilityBehavior.name = "AbilityBehavior"
28
76
  __TS__ClassExtends(AbilityBehavior, Behavior)
29
- function AbilityBehavior.prototype.____constructor(self, ability)
77
+ function AbilityBehavior.prototype.____constructor(self, ability, parameters)
30
78
  Behavior.prototype.____constructor(self, ability)
79
+ if parameters and parameters.isExclusiveOnImpactHandler then
80
+ exclusiveOnImpactHandlerAbilityBehaviorByAbility[ability] = self
81
+ end
82
+ self:onCreate()
83
+ end
84
+ function AbilityBehavior.prototype.registerCommandEvent(self, orderTypeStringId)
85
+ if orderTypeStringId == nil then
86
+ orderTypeStringId = self.ability.orderTypeStringId
87
+ end
88
+ local commandEventId = (tostring(self.ability.typeId) .. "#") .. orderTypeStringId
89
+ if not (registeredCommandEventIds[commandEventId] ~= nil) then
90
+ registeredCommandEventIds[commandEventId] = true
91
+ Unit.abilityCommandEvent[self.ability.typeId][orderTypeStringId]:addListener(createUnitEventListener("onCommand"))
92
+ end
31
93
  end
32
94
  function AbilityBehavior.prototype.resolveCurrentAbilityDependentValue(self, value)
33
95
  return resolveCurrentAbilityDependentValue(self.ability, value)
34
96
  end
97
+ function AbilityBehavior.prototype.flashCasterEffect(self, widget)
98
+ local attachmentPoint = CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD:getValue(self.ability)
99
+ Effect:flash(
100
+ CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.ability, 0),
101
+ widget,
102
+ attachmentPoint ~= "" and attachmentPoint or "origin"
103
+ )
104
+ end
35
105
  function AbilityBehavior.prototype.flashAreaEffect(self, x, y, ...)
36
106
  Effect:flash(
37
107
  AREA_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.ability, 0),
@@ -65,10 +135,16 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrDurati
65
135
  )
66
136
  end
67
137
  end
138
+ function AbilityBehavior.prototype.onCreate(self)
139
+ end
140
+ function AbilityBehavior.prototype.onMissileArrival(self, ...)
141
+ end
68
142
  function AbilityBehavior.prototype.onUnitGainAbility(self, _unit)
69
143
  end
70
144
  function AbilityBehavior.prototype.onUnitLoseAbility(self, _unit)
71
145
  end
146
+ function AbilityBehavior.prototype.onCommand(self, caster, orderTypeStringId)
147
+ end
72
148
  function AbilityBehavior.prototype.onCastingStart(self, caster)
73
149
  end
74
150
  function AbilityBehavior.prototype.onCastingFinish(self, caster)
@@ -127,19 +203,19 @@ __TS__SetDescriptor(
127
203
  return self.object
128
204
  end},
129
205
  true
206
+ )
207
+ AbilityBehavior.MissileLaunchConfig = ____class_2
208
+ __TS__SetDescriptor(
209
+ AbilityBehavior.prototype,
210
+ "missileLaunchConfig",
211
+ {get = function(self)
212
+ local missileLaunchConfig = __TS__New(____exports.AbilityBehavior.MissileLaunchConfig, self)
213
+ rawset(self, "missileLaunchConfig", missileLaunchConfig)
214
+ return missileLaunchConfig
215
+ end},
216
+ true
130
217
  );
131
218
  (function(self)
132
- local function createUnitEventListener(key)
133
- return function(unit, ability, ...)
134
- ____exports.AbilityBehavior:forAll(ability, key, unit, ...)
135
- end
136
- end
137
- local function createZeroTimerUnitEventListener(key)
138
- local unitEventListener = createUnitEventListener(key)
139
- return function(unit, ability, ...)
140
- Timer:run(unitEventListener, unit, ability, ...)
141
- end
142
- end
143
219
  Unit.abilityGainedEvent:addListener(createUnitEventListener("onUnitGainAbility"))
144
220
  Unit.abilityLostEvent:addListener(createUnitEventListener("onUnitLoseAbility"))
145
221
  Unit.abilityCastingStartEvent:addListener(createUnitEventListener("onCastingStart"))
@@ -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,7 +2,9 @@
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";
7
+ import { Item } from "../internal/item";
6
8
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
7
9
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
8
10
  constructor(unit: Unit);
@@ -13,8 +15,12 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
13
15
  onDamageDealt(target: Unit, event: DamageEvent): void;
14
16
  onDamageReceiving(source: Unit | undefined, event: DamagingEvent): void;
15
17
  onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
16
- protected onAbilityGained(ability: Ability): void;
17
- protected onAbilityLost(ability: Ability): void;
18
+ onAbilityGained(ability: Ability): void;
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;
18
24
  onKill(target: Unit): void;
19
25
  onDeath(source: Unit | undefined): void;
20
26
  }
@@ -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
@@ -31,6 +32,14 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
31
32
  end
32
33
  function UnitBehavior.prototype.onAbilityLost(self, ability)
33
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
34
43
  function UnitBehavior.prototype.onKill(self, target)
35
44
  end
36
45
  function UnitBehavior.prototype.onDeath(self, source)
@@ -62,12 +71,30 @@ __TS__SetDescriptor(
62
71
  end
63
72
  ____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
64
73
  end)
74
+ Unit.abilityGainedEvent:addListener(function(source, target)
75
+ ____exports.UnitBehavior:forAll(source, "onAbilityGained", target)
76
+ end)
77
+ Unit.abilityLostEvent:addListener(function(source, target)
78
+ ____exports.UnitBehavior:forAll(source, "onAbilityLost", target)
79
+ end)
65
80
  Unit.deathEvent:addListener(function(target, source)
66
81
  if source ~= nil then
67
82
  ____exports.UnitBehavior:forAll(source, "onKill", target)
68
83
  end
69
84
  ____exports.UnitBehavior:forAll(target, "onDeath", source)
70
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)
71
98
  end)(UnitBehavior)
72
99
  Unit.destroyEvent:addListener(function(unit)
73
100
  ____exports.UnitBehavior:forAll(unit, "destroy")