warscript 0.0.1-dev.a12bd26 → 0.0.1-dev.a228cc0

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 +81 -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 +334 -122
  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 +2 -2
  112. package/engine/object-field.lua +16 -12
  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
@@ -1,6 +1,8 @@
1
1
  local ____exports = {}
2
2
  local getUnitAbility = BlzGetUnitAbility
3
3
  local unitAddAbility = UnitAddAbility
4
+ local unitInventorySize = UnitInventorySize
5
+ local unitItemInSlot = UnitItemInSlot
4
6
  local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
5
7
  ---
6
8
  -- @internal For use by internal systems only.
@@ -10,4 +12,14 @@ ____exports.addInternalAbility = function(unit, abilityTypeId)
10
12
  end
11
13
  return getUnitAbility(unit, abilityTypeId)
12
14
  end
15
+ ---
16
+ -- @internal For use by internal systems only.
17
+ ____exports.findUnitItemSlot = function(unit, item)
18
+ for slot = 0, unitInventorySize(unit) - 1 do
19
+ if item == unitItemInSlot(unit, slot) then
20
+ return slot
21
+ end
22
+ end
23
+ return nil
24
+ end
13
25
  return ____exports
@@ -1,7 +1,7 @@
1
1
  /** @noSelfInFile */
2
2
  import { Unit } from "../core/types/unit";
3
3
  import { Async } from "../core/types/async";
4
- import { TriggerEvent } from "../event";
4
+ import { Event, TriggerEvent } from "../event";
5
5
  import { GraphicsMode } from "./index";
6
6
  export declare class LocalClient {
7
7
  private constructor();
@@ -11,6 +11,11 @@ export declare class LocalClient {
11
11
  static get isHD(): boolean;
12
12
  static get graphicsMode(): GraphicsMode;
13
13
  static get isActive(): boolean;
14
- static get mouseFocusUnit(): Async<Unit>;
14
+ static get mouseFocusUnit(): Async<Unit> | undefined;
15
+ static get mainSelectedUnit(): Async<Unit> | undefined;
16
+ static get mainSelectedUnitChangeEvent(): Event<[
17
+ previousMainSelectedUnit: Unit | undefined,
18
+ newMainSelectedUnit: Unit | undefined
19
+ ]>;
15
20
  static readonly onDisconnect: TriggerEvent<[]>;
16
21
  }
@@ -1,4 +1,5 @@
1
1
  local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
2
3
  local __TS__Class = ____lualib.__TS__Class
3
4
  local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
4
5
  local __TS__New = ____lualib.__TS__New
@@ -6,13 +7,25 @@ local ____exports = {}
6
7
  local ____unit = require("core.types.unit")
7
8
  local Unit = ____unit.Unit
8
9
  local ____event = require("event")
10
+ local Event = ____event.Event
9
11
  local TriggerEvent = ____event.TriggerEvent
12
+ local ____frame = require("core.types.frame")
13
+ local Frame = ____frame.Frame
14
+ local ____player = require("core.types.player")
15
+ local Player = ____player.Player
16
+ local ____timer = require("core.types.timer")
17
+ local Timer = ____timer.Timer
10
18
  local loadTOCFile = BlzLoadTOCFile
11
19
  local getLocalClientWidth = BlzGetLocalClientWidth
12
20
  local getLocalClientHeight = BlzGetLocalClientHeight
13
21
  local isLocalClientActive = BlzIsLocalClientActive
22
+ local isHeroUnitId = IsHeroUnitId
23
+ local getHandleId = GetHandleId
14
24
  local getMouseFocusUnit = BlzGetMouseFocusUnit
25
+ local getUnitRealField = BlzGetUnitRealField
26
+ local getUnitTypeId = GetUnitTypeId
15
27
  local getLocale = BlzGetLocale
28
+ local tableSort = table.sort
16
29
  local tocPath = "_warscript\\IsHD.toc"
17
30
  compiletime(function()
18
31
  if currentMap then
@@ -21,6 +34,29 @@ compiletime(function()
21
34
  currentMap:addFileString("_HD.w3mod\\" .. tocPath, fdfPath .. "\r\n")
22
35
  end
23
36
  end)
37
+ local selectionButtons
38
+ Timer:run(function()
39
+ selectionButtons = __TS__ArrayMap(
40
+ Frame:byName("SimpleInfoPanelUnitDetail").parent:getChild(5):getChild(0).children,
41
+ function(____, frame) return frame:getChild(1) end
42
+ )
43
+ end)
44
+ local localSelectedUnits = {}
45
+ local indexByLocalSelectedUnit = {}
46
+ local function compareUnitsSelectionPriority(a, b)
47
+ local aHandle = a.handle
48
+ local bHandle = b.handle
49
+ local priorityDelta = getUnitRealField(bHandle, UNIT_RF_PRIORITY) - getUnitRealField(aHandle, UNIT_RF_PRIORITY)
50
+ if priorityDelta ~= 0 then
51
+ return priorityDelta < 0
52
+ end
53
+ local aTypeId = getUnitTypeId(aHandle)
54
+ local bTypeId = getUnitTypeId(bHandle)
55
+ local orderDelta = (isHeroUnitId(aTypeId) and getHandleId(aHandle) or aTypeId) - (isHeroUnitId(bTypeId) and getHandleId(bHandle) or bTypeId)
56
+ return (orderDelta ~= 0 and orderDelta or indexByLocalSelectedUnit[a] - indexByLocalSelectedUnit[b]) < 0
57
+ end
58
+ local mainSelectedUnitChangeEvent
59
+ local previousMainSelectedUnit
24
60
  ____exports.LocalClient = __TS__Class()
25
61
  local LocalClient = ____exports.LocalClient
26
62
  LocalClient.name = "LocalClient"
@@ -69,6 +105,52 @@ __TS__ObjectDefineProperty(
69
105
  return Unit:of(getMouseFocusUnit())
70
106
  end}
71
107
  )
108
+ __TS__ObjectDefineProperty(
109
+ LocalClient,
110
+ "mainSelectedUnit",
111
+ {get = function(self)
112
+ Unit:getSelectionOf(Player["local"], localSelectedUnits)
113
+ for i = 1, #localSelectedUnits do
114
+ indexByLocalSelectedUnit[localSelectedUnits[i]] = i
115
+ end
116
+ tableSort(localSelectedUnits, compareUnitsSelectionPriority)
117
+ local mainSelectedUnitIndex
118
+ if selectionButtons and #localSelectedUnits > 1 then
119
+ local maxButtonWidth = 0
120
+ for i = 0, #selectionButtons - 1 do
121
+ local width = selectionButtons[i + 1].width
122
+ if width > maxButtonWidth then
123
+ maxButtonWidth = width
124
+ mainSelectedUnitIndex = i
125
+ end
126
+ end
127
+ end
128
+ local mainSelectedUnit = localSelectedUnits[(mainSelectedUnitIndex or 0) + 1]
129
+ for i = 1, #localSelectedUnits do
130
+ indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
131
+ localSelectedUnits[i] = nil
132
+ end
133
+ if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
134
+ local previousPreviousMainSelectedUnit = previousMainSelectedUnit
135
+ previousMainSelectedUnit = mainSelectedUnit
136
+ Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
137
+ end
138
+ return mainSelectedUnit
139
+ end}
140
+ )
141
+ __TS__ObjectDefineProperty(
142
+ LocalClient,
143
+ "mainSelectedUnitChangeEvent",
144
+ {get = function(self)
145
+ if mainSelectedUnitChangeEvent == nil then
146
+ mainSelectedUnitChangeEvent = __TS__New(Event)
147
+ Timer.onPeriod[1 / 64]:addListener(function()
148
+ local _ = ____exports.LocalClient.mainSelectedUnit
149
+ end)
150
+ end
151
+ return mainSelectedUnitChangeEvent
152
+ end}
153
+ )
72
154
  LocalClient.onDisconnect = __TS__New(
73
155
  TriggerEvent,
74
156
  function(trigger)
@@ -1,4 +1,3 @@
1
- /// <reference types="@typescript-to-lua/language-extensions" />
2
1
  /** @noSelfInFile */
3
2
  import { ModelNodeName } from "./model-node-name";
4
3
  import { ModelNodeQualifier } from "./model-node-qualifier";
@@ -1,5 +1,3 @@
1
- /// <reference types="@warscript/language-extensions" />
2
- /// <reference types="@typescript-to-lua/language-extensions" />
3
1
  /** @noSelfInFile */
4
2
  export declare const enum CombatClassification {
5
3
  NONE = 1,// 2^0
@@ -4,5 +4,9 @@ export declare const enum SoundPresetName {
4
4
  ABOMINATION_PISSED = "AbominationPissed",
5
5
  ABOMINATION_READY = "AbominationReady",
6
6
  ABOMINATION_WAR_CRY = "AbominationWarcry",
7
- AXE_MEDIUM_CHOP_WOOD = "AxeMediumChopWood"
7
+ AXE_MEDIUM_CHOP_WOOD = "AxeMediumChopWood",
8
+ IMPALE = "Impale",
9
+ IMPALE_HIT = "ImpaleHit",
10
+ IMPALE_LAND = "ImpaleLand",
11
+ IMPALE_CAST = "ImpaleCast"
8
12
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ChannelAbilityType, ChannelAbilityTypeTargetingType } from "./channel";
4
3
  import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { DiseaseCloudAbilityType } from "./disease-cloud";
4
3
  export declare class BlankPassiveAbilityType extends DiseaseCloudAbilityType {
@@ -0,0 +1,10 @@
1
+ /** @noSelfInFile */
2
+ import { AbilityType, AbilityTypeId } from "../ability-type";
3
+ import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
4
+ export declare class BlinkAbilityType extends AbilityType {
5
+ static readonly BASE_ID: AbilityTypeId;
6
+ get maximumRange(): number[];
7
+ set maximumRange(maximumRange: ObjectDataEntryLevelFieldValueSupplier<number>);
8
+ get minimumRange(): number[];
9
+ set minimumRange(minimumRange: ObjectDataEntryLevelFieldValueSupplier<number>);
10
+ }
@@ -0,0 +1,39 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
+ local ____exports = {}
6
+ local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
7
+ local AbilityType = ____ability_2Dtype.AbilityType
8
+ ____exports.BlinkAbilityType = __TS__Class()
9
+ local BlinkAbilityType = ____exports.BlinkAbilityType
10
+ BlinkAbilityType.name = "BlinkAbilityType"
11
+ __TS__ClassExtends(BlinkAbilityType, AbilityType)
12
+ BlinkAbilityType.BASE_ID = fourCC("AEbl")
13
+ __TS__SetDescriptor(
14
+ BlinkAbilityType.prototype,
15
+ "maximumRange",
16
+ {
17
+ get = function(self)
18
+ return self:getNumberLevelField("Ebl1")
19
+ end,
20
+ set = function(self, maximumRange)
21
+ self:setNumberLevelField("Ebl1", maximumRange)
22
+ end
23
+ },
24
+ true
25
+ )
26
+ __TS__SetDescriptor(
27
+ BlinkAbilityType.prototype,
28
+ "minimumRange",
29
+ {
30
+ get = function(self)
31
+ return self:getNumberLevelField("Ebl2")
32
+ end,
33
+ set = function(self, minimumRange)
34
+ self:setNumberLevelField("Ebl2", minimumRange)
35
+ end
36
+ },
37
+ true
38
+ )
39
+ return ____exports
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { AbilityType, AbilityTypeId } from "../ability-type";
4
3
  import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
@@ -0,0 +1,10 @@
1
+ /** @noSelfInFile */
2
+ import { AbilityType, AbilityTypeId } from "../ability-type";
3
+ import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
4
+ export declare class MineAbilityType extends AbilityType {
5
+ static readonly BASE_ID: AbilityTypeId;
6
+ get activationDelay(): number[];
7
+ set activationDelay(activationDelay: ObjectDataEntryLevelFieldValueSupplier<number>);
8
+ get invisibilityDelay(): number[];
9
+ set invisibilityDelay(invisibilityDelay: ObjectDataEntryLevelFieldValueSupplier<number>);
10
+ }
@@ -0,0 +1,39 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
+ local ____exports = {}
6
+ local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
7
+ local AbilityType = ____ability_2Dtype.AbilityType
8
+ ____exports.MineAbilityType = __TS__Class()
9
+ local MineAbilityType = ____exports.MineAbilityType
10
+ MineAbilityType.name = "MineAbilityType"
11
+ __TS__ClassExtends(MineAbilityType, AbilityType)
12
+ MineAbilityType.BASE_ID = fourCC("Amin")
13
+ __TS__SetDescriptor(
14
+ MineAbilityType.prototype,
15
+ "activationDelay",
16
+ {
17
+ get = function(self)
18
+ return self:getNumberLevelField("Min1")
19
+ end,
20
+ set = function(self, activationDelay)
21
+ self:setNumberLevelField("Min1", activationDelay)
22
+ end
23
+ },
24
+ true
25
+ )
26
+ __TS__SetDescriptor(
27
+ MineAbilityType.prototype,
28
+ "invisibilityDelay",
29
+ {
30
+ get = function(self)
31
+ return self:getNumberLevelField("Min2")
32
+ end,
33
+ set = function(self, invisibilityDelay)
34
+ self:setNumberLevelField("Min2", invisibilityDelay)
35
+ end
36
+ },
37
+ true
38
+ )
39
+ return ____exports
@@ -7,8 +7,8 @@ export declare class SpiritTouchAbilityType extends AbilityType {
7
7
  set manaGain(manaGain: ObjectDataEntryLevelFieldValueSupplier<number>);
8
8
  get manaRequirement(): number[];
9
9
  set manaRequirement(manaRequirement: ObjectDataEntryLevelFieldValueSupplier<number>);
10
- get maximumTargetCount(): number[];
11
- set maximumTargetCount(maximumTargetCount: ObjectDataEntryLevelFieldValueSupplier<number>);
12
10
  get maximumManaCostFactor(): number[];
13
11
  set maximumManaCostFactor(maximumManaCostFactor: ObjectDataEntryLevelFieldValueSupplier<number>);
12
+ get maximumTargetCount(): number[];
13
+ set maximumTargetCount(maximumTargetCount: ObjectDataEntryLevelFieldValueSupplier<number>);
14
14
  }
@@ -38,26 +38,26 @@ __TS__SetDescriptor(
38
38
  )
39
39
  __TS__SetDescriptor(
40
40
  SpiritTouchAbilityType.prototype,
41
- "maximumTargetCount",
41
+ "maximumManaCostFactor",
42
42
  {
43
43
  get = function(self)
44
44
  return self:getNumberLevelField("Rpb5")
45
45
  end,
46
- set = function(self, maximumTargetCount)
47
- self:setNumberLevelField("Rpb5", maximumTargetCount)
46
+ set = function(self, maximumManaCostFactor)
47
+ self:setNumberLevelField("Rpb5", maximumManaCostFactor)
48
48
  end
49
49
  },
50
50
  true
51
51
  )
52
52
  __TS__SetDescriptor(
53
53
  SpiritTouchAbilityType.prototype,
54
- "maximumManaCostFactor",
54
+ "maximumTargetCount",
55
55
  {
56
56
  get = function(self)
57
57
  return self:getNumberLevelField("Rpb6")
58
58
  end,
59
- set = function(self, maximumManaCostFactor)
60
- self:setNumberLevelField("Rpb6", maximumManaCostFactor)
59
+ set = function(self, maximumTargetCount)
60
+ self:setNumberLevelField("Rpb6", maximumTargetCount)
61
61
  end
62
62
  },
63
63
  true
@@ -1,5 +1,5 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
2
+ import "../../internal/unit/ability";
3
3
  import { TupleOf } from "../../../utility/types";
4
4
  import { AnimationName } from "../auxiliary/animation-name";
5
5
  import { AnimationQualifier } from "../auxiliary/animation-qualifier";
@@ -1,11 +1,11 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
- local __TS__New = ____lualib.__TS__New
5
4
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
6
5
  local ____exports = {}
7
6
  local ____unit = require("engine.internal.unit")
8
7
  local Unit = ____unit.Unit
8
+ require("engine.internal.unit.ability")
9
9
  local ____timer = require("core.types.timer")
10
10
  local Timer = ____timer.Timer
11
11
  local ____effect = require("core.types.effect")
@@ -30,7 +30,7 @@ local ____entry = require("engine.object-data.entry")
30
30
  local extractObjectDataEntryLevelFieldValue = ____entry.extractObjectDataEntryLevelFieldValue
31
31
  local ObjectDataEntry = ____entry.ObjectDataEntry
32
32
  local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
33
- local ObjectDataEntryIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.ObjectDataEntryIdGenerator
33
+ local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
34
34
  local ____upgrade = require("engine.object-data.entry.upgrade")
35
35
  local Upgrade = ____upgrade.Upgrade
36
36
  local castAnimationFQNByAbilityTypeId = {}
@@ -52,10 +52,7 @@ end
52
52
  function AbilityType.getObjectData(self, map)
53
53
  return map.objects.ability
54
54
  end
55
- AbilityType.idGenerator = __TS__New(
56
- ObjectDataEntryIdGenerator,
57
- fourCC("A000")
58
- )
55
+ AbilityType.idGenerator = abilityTypeIdGenerator
59
56
  __TS__SetDescriptor(
60
57
  AbilityType.prototype,
61
58
  "channelingAnimation",
@@ -998,7 +995,7 @@ local function handleAbilityCastingStartEvent(caster, ability)
998
995
  end
999
996
  casterCastingEffectsByCaster[caster] = effects
1000
997
  end
1001
- local function handleAbilityStopEvent(caster)
998
+ local function handleAbilityStopCastingEvent(caster)
1002
999
  local effects = casterCastingEffectsByCaster[caster]
1003
1000
  if effects ~= nil then
1004
1001
  for i = 1, #effects do
@@ -1009,8 +1006,8 @@ local function handleAbilityStopEvent(caster)
1009
1006
  end
1010
1007
  for abilityTypeId in pairs(casterCastingEffectModelPathsByAbilityTypeId) do
1011
1008
  Unit.abilityCastingStartEvent[abilityTypeId]:addListener(4, handleAbilityCastingStartEvent)
1012
- Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityStopEvent)
1013
- Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopEvent)
1009
+ Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityStopCastingEvent)
1010
+ Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopCastingEvent)
1014
1011
  end
1015
1012
  local casterChannelingEffectModelPathsByAbilityTypeId = postcompile(function()
1016
1013
  return mapValues(
@@ -1041,7 +1038,7 @@ local function handleAbilityChannelingStartEvent(caster, ability)
1041
1038
  end
1042
1039
  casterChannelingEffectsByCaster[caster] = effects
1043
1040
  end
1044
- local function handleAbilityStopEventV2(caster)
1041
+ local function handleAbilityStopChannelingEvent(caster)
1045
1042
  local effects = casterChannelingEffectsByCaster[caster]
1046
1043
  if effects ~= nil then
1047
1044
  for i = 1, #effects do
@@ -1052,7 +1049,7 @@ local function handleAbilityStopEventV2(caster)
1052
1049
  end
1053
1050
  for abilityTypeId in pairs(casterChannelingEffectModelPathsByAbilityTypeId) do
1054
1051
  Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityChannelingStartEvent)
1055
- Unit.abilityChannelingFinishEvent[abilityTypeId]:addListener(4, handleAbilityStopEventV2)
1056
- Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopEventV2)
1052
+ Unit.abilityChannelingFinishEvent[abilityTypeId]:addListener(4, handleAbilityStopChannelingEvent)
1053
+ Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopChannelingEvent)
1057
1054
  end
1058
1055
  return ____exports
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { BuffPolarity } from "../../auxiliary/buff-polarity";
4
3
  import { BuffResistanceType } from "../../auxiliary/buff-resistance-type";
@@ -7,6 +7,7 @@ local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
7
7
  local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
8
8
  local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
9
9
  local ____exports = {}
10
+ local preparePhysicalPositiveApplicatorAbility
10
11
  local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
11
12
  local AbilityType = ____ability_2Dtype.AbilityType
12
13
  local ____cripple = require("engine.object-data.entry.ability-type.cripple")
@@ -34,20 +35,14 @@ local ____blood_2Dlust = require("engine.object-data.entry.ability-type.blood-lu
34
35
  local BloodLustAbilityType = ____blood_2Dlust.BloodLustAbilityType
35
36
  local ____berserk = require("engine.object-data.entry.ability-type.berserk")
36
37
  local BerserkAbilityType = ____berserk.BerserkAbilityType
37
- local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
38
- local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
39
- local ____dummy_2Dinventory = require("engine.internal.object-data.dummy-inventory")
40
- local INVENTORY_ABILITY_TYPE_ID = ____dummy_2Dinventory.INVENTORY_ABILITY_TYPE_ID
41
38
  local ____blank = require("engine.object-data.entry.upgrade.blank")
42
39
  local BlankUpgrade = ____blank.BlankUpgrade
43
- local ____dummy_2Dunits = require("engine.internal.misc.dummy-units")
44
- local INVENTORY_DUMMY_NATIVE_UNIT = ____dummy_2Dunits.INVENTORY_DUMMY_NATIVE_UNIT
45
- local ____preconditions = require("utility.preconditions")
46
- local checkNotNull = ____preconditions.checkNotNull
47
40
  local ____unit_2Dtype = require("engine.object-data.entry.unit-type")
48
41
  local UnitType = ____unit_2Dtype.UnitType
49
42
  local ____permanent_2Dimmolation = require("engine.object-data.entry.ability-type.permanent-immolation")
50
43
  local PermanentImmolationAbilityType = ____permanent_2Dimmolation.PermanentImmolationAbilityType
44
+ local ____cast_2Dability = require("engine.internal.mechanics.cast-ability")
45
+ local castAbility = ____cast_2Dability.castAbility
51
46
  local createItem = CreateItem
52
47
  local getAbilityId = BlzGetAbilityId
53
48
  local getItemAbility = BlzGetItemAbility
@@ -260,75 +255,25 @@ ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, r
260
255
  return unitAddAbility(unit.handle, applicatorAbilityTypeId)
261
256
  end
262
257
  if applicatorType == 852100 then
263
- local success
264
- local nativeUnit = unit.handle
265
- local nativeItem = createItem(DUMMY_ITEM_ID, 0, 0)
266
- unitAddItem(INVENTORY_DUMMY_NATIVE_UNIT, nativeItem)
267
- itemAddAbility(nativeItem, applicatorAbilityTypeId)
268
- local applicatorAbility = checkNotNull(getItemAbility(nativeItem, applicatorAbilityTypeId))
269
- if level == nil then
270
- level = 0
271
- setAbilityIntegerField(applicatorAbility, ABILITY_IF_LEVELS, 1)
272
- end
273
- setAbilityRealLevelField(applicatorAbility, ABILITY_RLF_DURATION_NORMAL, level, duration or 0)
274
- setAbilityRealLevelField(applicatorAbility, ABILITY_RLF_DURATION_HERO, level, duration or 0)
275
- if movementSpeedIncreaseFactor ~= nil then
276
- setAbilityRealLevelField(applicatorAbility, ABILITY_RLF_MOVEMENT_SPEED_INCREASE_BSK1, level, movementSpeedIncreaseFactor)
277
- end
278
- setItemBooleanField(nativeItem, ITEM_BF_ACTIVELY_USED, true)
279
- setItemBooleanField(nativeItem, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
280
- if level > 0 then
258
+ local nativePlayer = unit.owner.handle
259
+ if level ~= nil and level > 0 then
281
260
  local upgradeId = applicatorUpgradeIdByApplicatorAbilityTypeId[applicatorAbilityTypeId]
282
261
  if upgradeId ~= nil then
283
- setPlayerTechResearched(
284
- getOwningPlayer(nativeUnit),
285
- upgradeId,
286
- level
287
- )
288
- end
289
- end
290
- if not unitAddItem(nativeUnit, nativeItem) then
291
- local latestInventoryAbilityTypeId = 0
292
- local nativeItemBySlot = {}
293
- local inventorySize = unitInventorySize(nativeUnit)
294
- if inventorySize ~= 0 then
295
- for slot = 0, inventorySize - 1 do
296
- nativeItemBySlot[slot] = UnitRemoveItemFromSlot(nativeUnit, slot)
297
- end
298
- local unitNativeAbility = getUnitAbilityByIndex(nativeUnit, 0)
299
- local i = 1
300
- while unitNativeAbility ~= nil do
301
- local abilityTypeId = getAbilityId(unitNativeAbility)
302
- if INVENTORY_ABILITY_TYPE_IDS[abilityTypeId] ~= nil then
303
- latestInventoryAbilityTypeId = abilityTypeId
304
- end
305
- unitNativeAbility = getUnitAbilityByIndex(nativeUnit, i)
306
- i = i + 1
307
- end
308
- unitRemoveAbility(nativeUnit, latestInventoryAbilityTypeId)
262
+ setPlayerTechResearched(nativePlayer, upgradeId, level)
309
263
  end
310
- unitAddAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
311
- success = unitAddItem(nativeUnit, nativeItem)
312
- unitRemoveAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
313
- if latestInventoryAbilityTypeId ~= 0 then
314
- unitAddAbility(nativeUnit, latestInventoryAbilityTypeId)
315
- for slot, nativeItem in pairs(nativeItemBySlot) do
316
- unitAddItem(nativeUnit, nativeItem)
317
- unitDropItemSlot(nativeUnit, nativeItem, slot)
318
- end
319
- end
320
- else
321
- success = true
322
264
  end
323
- removeItem(nativeItem)
324
- if level ~= nil and level > 1 then
265
+ local success = castAbility(
266
+ unit.handle,
267
+ applicatorAbilityTypeId,
268
+ preparePhysicalPositiveApplicatorAbility,
269
+ level,
270
+ duration or 0,
271
+ movementSpeedIncreaseFactor
272
+ )
273
+ if level ~= nil and level > 0 then
325
274
  local upgradeId = applicatorUpgradeIdByApplicatorAbilityTypeId[applicatorAbilityTypeId]
326
275
  if upgradeId ~= nil then
327
- setPlayerTechResearched(
328
- getOwningPlayer(nativeUnit),
329
- upgradeId,
330
- 0
331
- )
276
+ setPlayerTechResearched(nativePlayer, upgradeId, 0)
332
277
  end
333
278
  end
334
279
  return success
@@ -364,6 +309,17 @@ ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, r
364
309
  end
365
310
  return success
366
311
  end
312
+ preparePhysicalPositiveApplicatorAbility = function(ability, level, duration, movementSpeedIncreaseFactor)
313
+ if level == nil then
314
+ setAbilityIntegerField(ability, ABILITY_IF_LEVELS, 1)
315
+ level = 1
316
+ end
317
+ setAbilityRealLevelField(ability, ABILITY_RLF_DURATION_NORMAL, level, duration)
318
+ setAbilityRealLevelField(ability, ABILITY_RLF_DURATION_HERO, level, duration)
319
+ if movementSpeedIncreaseFactor ~= nil then
320
+ setAbilityRealLevelField(ability, ABILITY_RLF_MOVEMENT_SPEED_INCREASE_BSK1, level, movementSpeedIncreaseFactor)
321
+ end
322
+ end
367
323
  ---
368
324
  -- @internal For use by internal systems only.
369
325
  ____exports.removeBuff = function(unit, applicableBuffTypeId)
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { BuffType, BuffTypeId } from "../buff-type";
4
3
  export declare class BlankBuffType extends BuffType {
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { TupleOf } from "../../../utility/types";
4
3
  import { AttachmentPreset, AttachmentPresetInput } from "../auxiliary/attachment-preset";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ArmorSoundType } from "../auxiliary/armor-sound-type";
4
3
  import { CombatClassifications } from "../auxiliary/combat-classification";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ItemType, ItemTypeId } from "../item-type";
4
3
  export declare class BlankItemType extends ItemType {
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ArmorSoundType } from "../auxiliary/armor-sound-type";
4
3
  import { ObjectDataEntry, ObjectDataEntryId } from "../entry";
@@ -46,4 +45,18 @@ export declare class ItemType extends ObjectDataEntry<ItemTypeId> {
46
45
  set tooltipText(tooltipText: string);
47
46
  get tooltipExtendedText(): string;
48
47
  set tooltipExtendedText(tooltipText: string);
48
+ get cooldownGroupId(): number;
49
+ set cooldownGroupId(cooldownGroupId: number);
50
+ get goldCost(): number;
51
+ set goldCost(goldCost: number);
52
+ get lumberCost(): number;
53
+ set lumberCost(lumberCost: number);
54
+ get activelyUsed(): boolean;
55
+ set activelyUsed(activelyUsed: boolean);
56
+ get perishable(): boolean;
57
+ set perishable(perishable: boolean);
58
+ get initialStackSize(): number;
59
+ set initialStackSize(initialStackSize: number);
60
+ get maximumStackSize(): number;
61
+ set maximumStackSize(maximumStackSize: number);
49
62
  }