warscript 0.0.1-dev.f566ce7 → 0.0.1-dev.f594e71

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 (185) hide show
  1. package/core/types/frame.d.ts +1 -0
  2. package/core/types/frame.lua +65 -36
  3. package/core/types/handle.lua +9 -9
  4. package/core/types/player.d.ts +2 -1
  5. package/core/types/player.lua +18 -13
  6. package/core/types/playerColor.lua +4 -3
  7. package/core/types/sound.d.ts +1 -1
  8. package/core/types/sound.lua +13 -8
  9. package/core/types/unit.d.ts +4 -0
  10. package/core/types/unit.lua +4 -0
  11. package/decl/native.d.ts +705 -7
  12. package/engine/behaviour/ability/damage.lua +11 -14
  13. package/engine/behaviour/ability.d.ts +1 -0
  14. package/engine/behaviour/ability.lua +11 -0
  15. package/engine/behaviour/unit.d.ts +1 -0
  16. package/engine/behaviour/unit.lua +1 -0
  17. package/engine/buff.d.ts +12 -10
  18. package/engine/buff.lua +64 -16
  19. package/engine/index.d.ts +2 -1
  20. package/engine/internal/ability.d.ts +4 -0
  21. package/engine/internal/ability.lua +37 -18
  22. package/engine/internal/item+owner.d.ts +1 -0
  23. package/engine/internal/item+owner.lua +7 -0
  24. package/engine/internal/item.d.ts +16 -1
  25. package/engine/internal/item.lua +130 -20
  26. package/engine/internal/unit/ability.lua +15 -3
  27. package/engine/internal/unit/appearance.d.ts +15 -0
  28. package/engine/internal/unit/appearance.lua +85 -0
  29. package/engine/internal/unit/bag.d.ts +18 -0
  30. package/engine/internal/unit/bag.lua +63 -0
  31. package/engine/internal/unit/buff.d.ts +2 -2
  32. package/engine/internal/unit/buff.lua +34 -19
  33. package/engine/internal/unit/equipment.d.ts +36 -0
  34. package/engine/internal/unit/equipment.lua +169 -0
  35. package/engine/internal/unit/{item.d.ts → inventory.d.ts} +3 -3
  36. package/engine/internal/unit/{item.lua → inventory.lua} +25 -26
  37. package/engine/internal/unit/pseudo-passive-abilities.d.ts +2 -0
  38. package/engine/internal/unit/pseudo-passive-abilities.lua +11 -0
  39. package/engine/internal/unit+damage.d.ts +9 -0
  40. package/engine/internal/unit+damage.lua +33 -0
  41. package/engine/internal/unit-missile-data.lua +58 -32
  42. package/engine/internal/unit.d.ts +0 -1
  43. package/engine/internal/unit.lua +2 -7
  44. package/engine/local-client.d.ts +20 -0
  45. package/engine/local-client.lua +284 -53
  46. package/engine/object-data/auxiliary/equipment-slot.d.ts +12 -0
  47. package/engine/object-data/auxiliary/equipment-slot.lua +2 -0
  48. package/engine/object-data/auxiliary/equipment-type.d.ts +13 -0
  49. package/engine/object-data/auxiliary/equipment-type.lua +2 -0
  50. package/engine/object-data/auxiliary/item-tag.d.ts +12 -0
  51. package/engine/object-data/auxiliary/item-tag.lua +2 -0
  52. package/engine/object-data/auxiliary/sound-set-name.d.ts +14 -3
  53. package/engine/object-data/entry/ability-type/apprehend.d.ts +22 -0
  54. package/engine/object-data/entry/ability-type/apprehend.lua +66 -0
  55. package/engine/object-data/entry/ability-type/banshee.d.ts +8 -0
  56. package/engine/object-data/entry/ability-type/banshee.lua +13 -0
  57. package/engine/object-data/entry/ability-type/banshees-wail-damage-amp.d.ts +12 -0
  58. package/engine/object-data/entry/ability-type/banshees-wail-damage-amp.lua +27 -0
  59. package/engine/object-data/entry/ability-type/banshees-wail.d.ts +31 -0
  60. package/engine/object-data/entry/ability-type/banshees-wail.lua +117 -0
  61. package/engine/object-data/entry/ability-type/battering-ram.d.ts +33 -0
  62. package/engine/object-data/entry/ability-type/battering-ram.lua +130 -0
  63. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +3 -0
  64. package/engine/object-data/entry/ability-type/blank-configurable.lua +30 -0
  65. package/engine/object-data/entry/ability-type/cleansing-fire.d.ts +27 -0
  66. package/engine/object-data/entry/ability-type/cleansing-fire.lua +104 -0
  67. package/engine/object-data/entry/ability-type/consecration.d.ts +15 -0
  68. package/engine/object-data/entry/ability-type/consecration.lua +52 -0
  69. package/engine/object-data/entry/ability-type/cooldown-reduction.d.ts +12 -0
  70. package/engine/object-data/entry/ability-type/cooldown-reduction.lua +39 -0
  71. package/engine/object-data/entry/ability-type/critical-strike-system.d.ts +18 -0
  72. package/engine/object-data/entry/ability-type/critical-strike-system.lua +65 -0
  73. package/engine/object-data/entry/ability-type/deathseeker-arrows.d.ts +21 -0
  74. package/engine/object-data/entry/ability-type/deathseeker-arrows.lua +78 -0
  75. package/engine/object-data/entry/ability-type/equipment-inventory-interface.d.ts +8 -0
  76. package/engine/object-data/entry/ability-type/equipment-inventory-interface.lua +13 -0
  77. package/engine/object-data/entry/ability-type/equipment-inventory.d.ts +13 -0
  78. package/engine/object-data/entry/ability-type/equipment-inventory.lua +27 -0
  79. package/engine/object-data/entry/ability-type/equipment.d.ts +13 -0
  80. package/engine/object-data/entry/ability-type/equipment.lua +27 -0
  81. package/engine/object-data/entry/ability-type/grant-talent-point.d.ts +8 -0
  82. package/engine/object-data/entry/ability-type/grant-talent-point.lua +13 -0
  83. package/engine/object-data/entry/ability-type/grim-conviction.d.ts +36 -0
  84. package/engine/object-data/entry/ability-type/grim-conviction.lua +131 -0
  85. package/engine/object-data/entry/ability-type/grit.d.ts +18 -0
  86. package/engine/object-data/entry/ability-type/grit.lua +65 -0
  87. package/engine/object-data/entry/ability-type/guiding-hand.d.ts +27 -0
  88. package/engine/object-data/entry/ability-type/guiding-hand.lua +104 -0
  89. package/engine/object-data/entry/ability-type/headsplitter.d.ts +27 -0
  90. package/engine/object-data/entry/ability-type/headsplitter.lua +104 -0
  91. package/engine/object-data/entry/ability-type/healing-modifier.d.ts +9 -0
  92. package/engine/object-data/entry/ability-type/healing-modifier.lua +26 -0
  93. package/engine/object-data/entry/ability-type/heroic-slash.d.ts +18 -0
  94. package/engine/object-data/entry/ability-type/heroic-slash.lua +65 -0
  95. package/engine/object-data/entry/ability-type/holy-wrath.d.ts +30 -0
  96. package/engine/object-data/entry/ability-type/holy-wrath.lua +117 -0
  97. package/engine/object-data/entry/ability-type/inspire-courage.d.ts +18 -0
  98. package/engine/object-data/entry/ability-type/inspire-courage.lua +65 -0
  99. package/engine/object-data/entry/ability-type/lights-mercy.d.ts +27 -0
  100. package/engine/object-data/entry/ability-type/lights-mercy.lua +104 -0
  101. package/engine/object-data/entry/ability-type/mana-efficiency.d.ts +12 -0
  102. package/engine/object-data/entry/ability-type/mana-efficiency.lua +39 -0
  103. package/engine/object-data/entry/ability-type/mind-control.d.ts +21 -0
  104. package/engine/object-data/entry/ability-type/mind-control.lua +78 -0
  105. package/engine/object-data/entry/ability-type/on-attack-cast-spell.d.ts +21 -0
  106. package/engine/object-data/entry/ability-type/on-attack-cast-spell.lua +52 -0
  107. package/engine/object-data/entry/ability-type/on-basic-attack-cast-spell.d.ts +19 -0
  108. package/engine/object-data/entry/ability-type/on-basic-attack-cast-spell.lua +65 -0
  109. package/engine/object-data/entry/ability-type/on-hit-cast-spell.d.ts +15 -0
  110. package/engine/object-data/entry/ability-type/on-hit-cast-spell.lua +26 -0
  111. package/engine/object-data/entry/ability-type/on-magic-attack-cast-spell.d.ts +6 -0
  112. package/engine/object-data/entry/ability-type/on-magic-attack-cast-spell.lua +12 -0
  113. package/engine/object-data/entry/ability-type/provoke.d.ts +21 -0
  114. package/engine/object-data/entry/ability-type/provoke.lua +66 -0
  115. package/engine/object-data/entry/ability-type/raise-the-banner.d.ts +9 -0
  116. package/engine/object-data/entry/ability-type/raise-the-banner.lua +26 -0
  117. package/engine/object-data/entry/ability-type/resolve.d.ts +12 -0
  118. package/engine/object-data/entry/ability-type/resolve.lua +39 -0
  119. package/engine/object-data/entry/ability-type/righteous-fury.d.ts +33 -0
  120. package/engine/object-data/entry/ability-type/righteous-fury.lua +130 -0
  121. package/engine/object-data/entry/ability-type/sacred-aura.d.ts +27 -0
  122. package/engine/object-data/entry/ability-type/sacred-aura.lua +104 -0
  123. package/engine/object-data/entry/ability-type/soul-lantern.d.ts +30 -0
  124. package/engine/object-data/entry/ability-type/soul-lantern.lua +117 -0
  125. package/engine/object-data/entry/ability-type/spell-amp.d.ts +15 -0
  126. package/engine/object-data/entry/ability-type/spell-amp.lua +52 -0
  127. package/engine/object-data/entry/ability-type/spell-critical-strike.d.ts +12 -0
  128. package/engine/object-data/entry/ability-type/spell-critical-strike.lua +39 -0
  129. package/engine/object-data/entry/ability-type/spell-vamp.d.ts +12 -0
  130. package/engine/object-data/entry/ability-type/spell-vamp.lua +39 -0
  131. package/engine/object-data/entry/ability-type/stackable-evasion.d.ts +9 -0
  132. package/engine/object-data/entry/ability-type/stackable-evasion.lua +13 -0
  133. package/engine/object-data/entry/ability-type/stackable-hardened-skin.d.ts +21 -0
  134. package/engine/object-data/entry/ability-type/stackable-hardened-skin.lua +78 -0
  135. package/engine/object-data/entry/ability-type/stackable-life-steal.d.ts +9 -0
  136. package/engine/object-data/entry/ability-type/stackable-life-steal.lua +26 -0
  137. package/engine/object-data/entry/ability-type/stackable-spell-damage-reduction.d.ts +9 -0
  138. package/engine/object-data/entry/ability-type/stackable-spell-damage-reduction.lua +13 -0
  139. package/engine/object-data/entry/ability-type/stackable-thorn-shield.d.ts +9 -0
  140. package/engine/object-data/entry/ability-type/stackable-thorn-shield.lua +13 -0
  141. package/engine/object-data/entry/ability-type/stat-details.d.ts +12 -0
  142. package/engine/object-data/entry/ability-type/stat-details.lua +27 -0
  143. package/engine/object-data/entry/ability-type/surge-of-light.d.ts +33 -0
  144. package/engine/object-data/entry/ability-type/surge-of-light.lua +130 -0
  145. package/engine/object-data/entry/ability-type/sweeping-strike.d.ts +57 -0
  146. package/engine/object-data/entry/ability-type/sweeping-strike.lua +234 -0
  147. package/engine/object-data/entry/ability-type/talents.d.ts +12 -0
  148. package/engine/object-data/entry/ability-type/talents.lua +27 -0
  149. package/engine/object-data/entry/ability-type/unyielding-guard.d.ts +30 -0
  150. package/engine/object-data/entry/ability-type/unyielding-guard.lua +117 -0
  151. package/engine/object-data/entry/ability-type/valiant-charge.d.ts +27 -0
  152. package/engine/object-data/entry/ability-type/valiant-charge.lua +104 -0
  153. package/engine/object-data/entry/ability-type/warcry.d.ts +9 -0
  154. package/engine/object-data/entry/ability-type/warcry.lua +26 -0
  155. package/engine/object-data/entry/ability-type/withering-fire.d.ts +21 -0
  156. package/engine/object-data/entry/ability-type/withering-fire.lua +78 -0
  157. package/engine/object-data/entry/ability-type.d.ts +10 -3
  158. package/engine/object-data/entry/ability-type.lua +53 -0
  159. package/engine/object-data/entry/buff-type.d.ts +6 -2
  160. package/engine/object-data/entry/buff-type.lua +26 -0
  161. package/engine/object-data/entry/destructible-type.d.ts +6 -2
  162. package/engine/object-data/entry/destructible-type.lua +26 -0
  163. package/engine/object-data/entry/item-type.d.ts +12 -3
  164. package/engine/object-data/entry/item-type.lua +52 -0
  165. package/engine/object-data/entry/lightning-type.d.ts +2 -2
  166. package/engine/object-data/entry/sound-preset.d.ts +2 -2
  167. package/engine/object-data/entry/unit-type.d.ts +47 -2
  168. package/engine/object-data/entry/unit-type.lua +383 -49
  169. package/engine/object-data/entry/upgrade.d.ts +2 -2
  170. package/engine/object-data/entry.d.ts +4 -1
  171. package/engine/standard/entries/ability-type.d.ts +3102 -7
  172. package/engine/standard/entries/ability-type.lua +0 -6
  173. package/engine/standard/entries/item-type.d.ts +1299 -0
  174. package/engine/standard/entries/item-type.lua +2 -0
  175. package/engine/standard/entries/unit-type.d.ts +5 -0
  176. package/engine/standard/entries/unit-type.lua +5 -0
  177. package/engine/unit.d.ts +4 -1
  178. package/engine/unit.lua +4 -1
  179. package/event.d.ts +1 -1
  180. package/network.lua +25 -1
  181. package/operation.d.ts +8 -1
  182. package/operation.lua +37 -14
  183. package/package.json +2 -22
  184. package/utility/random.d.ts +102 -0
  185. package/utility/random.lua +273 -0
@@ -1,5 +1,4 @@
1
1
  local ____lualib = require("lualib_bundle")
2
- local __TS__ArrayMap = ____lualib.__TS__ArrayMap
3
2
  local __TS__New = ____lualib.__TS__New
4
3
  local __TS__Class = ____lualib.__TS__Class
5
4
  local __TS__InstanceOf = ____lualib.__TS__InstanceOf
@@ -21,33 +20,175 @@ local ____color = require("core.types.color")
21
20
  local Color = ____color.Color
22
21
  local ____arrays = require("utility.arrays")
23
22
  local array = ____arrays.array
24
- local loadTOCFile = BlzLoadTOCFile
25
- local getLocalClientWidth = BlzGetLocalClientWidth
26
- local getLocalClientHeight = BlzGetLocalClientHeight
27
- local isLocalClientActive = BlzIsLocalClientActive
28
- local isHeroUnitId = IsHeroUnitId
23
+ local ____socket = require("net.socket")
24
+ local Socket = ____socket.Socket
25
+ local frameGetChild = BlzFrameGetChild
26
+ local frameGetChildrenCount = BlzFrameGetChildrenCount
27
+ local frameGetParent = BlzFrameGetParent
28
+ local frameGetWidth = BlzFrameGetWidth
29
+ local frameToPixelX = BlzFrameToPixelX
30
+ local frameToPixelY = BlzFrameToPixelY
31
+ local getFrameByName = BlzGetFrameByName
29
32
  local getHandleId = GetHandleId
33
+ local getLocalClientHeight = BlzGetLocalClientHeight
34
+ local getLocalClientWidth = BlzGetLocalClientWidth
35
+ local getLocale = BlzGetLocale
30
36
  local getMouseFocusUnit = BlzGetMouseFocusUnit
37
+ local getMouseScreenPosX = BlzGetMouseScreenPosX
38
+ local getMouseScreenPosY = BlzGetMouseScreenPosY
31
39
  local getUnitRealField = BlzGetUnitRealField
32
40
  local getUnitTypeId = GetUnitTypeId
33
- local getLocale = BlzGetLocale
41
+ local isHeroUnitId = IsHeroUnitId
42
+ local isKeyPressed = BlzIsKeyPressed
43
+ local isLocalClientActive = BlzIsLocalClientActive
44
+ local isMetaKeyPressed = BlzIsMetaKeyPressed
45
+ local isMouseButtonPressed = BlzIsMouseButtonPressed
46
+ local loadTOCFile = BlzLoadTOCFile
47
+ local location = Location
34
48
  local pingMinimap = PingMinimap
35
49
  local pingMinimapEx = PingMinimapEx
50
+ local pixelToFrameX = BlzPixelToFrameX
51
+ local pixelToFrameY = BlzPixelToFrameY
36
52
  local tableSort = table.sort
37
- local tocPath = "_warscript\\IsHD.toc"
53
+ local hdTocPath = "_warscript\\IsHD.toc"
54
+ local deTocPath = "_warscript\\IsDE.toc"
38
55
  compiletime(function()
39
56
  if currentMap then
40
- local fdfPath = "_warscript\\IsHD.fdf"
41
- currentMap:addFileString("_HD.w3mod\\" .. fdfPath, "\r\n")
42
- currentMap:addFileString("_HD.w3mod\\" .. tocPath, fdfPath .. "\r\n")
57
+ local hdFdfPath = "_warscript\\IsHD.fdf"
58
+ currentMap:addFileString("_HD.w3mod\\" .. hdFdfPath, "\r\n")
59
+ currentMap:addFileString("_HD.w3mod\\" .. hdTocPath, hdFdfPath .. "\r\n")
60
+ local deFdfPath = "_warscript\\IsDE.fdf"
61
+ currentMap:addFileString("_DE.w3mod\\" .. deFdfPath, "\r\n")
62
+ currentMap:addFileString("_DE.w3mod\\" .. deTocPath, deFdfPath .. "\r\n")
43
63
  end
44
64
  end)
45
- local selectionButtons
46
- Timer:run(function()
47
- selectionButtons = __TS__ArrayMap(
48
- Frame:byName("SimpleInfoPanelUnitDetail").parent:getChild(5):getChild(0).children,
49
- function(____, frame) return frame:getChild(1) end
50
- )
65
+ local SELECTION_DETAIL_FRAME_NAME = "SimpleInfoPanelUnitDetail"
66
+ local SELECTION_GROUP_PANEL_INDEX = 5
67
+ local SELECTION_BUTTON_ICON_INDEX = 1
68
+ --- The detail panel, its parent, the group panel and the button grid.
69
+ local SELECTION_LAYOUT_ROOT_HANDLE_COUNT = 4
70
+ local SELECTION_LAYOUT_MAX_BUTTON_COUNT = 24
71
+ --- The root frames plus a button and its icon per slot of the largest layout.
72
+ local SELECTION_LAYOUT_MAX_HANDLE_COUNT = SELECTION_LAYOUT_ROOT_HANDLE_COUNT + 2 * SELECTION_LAYOUT_MAX_BUTTON_COUNT
73
+ --- Registration requests for one local selection before giving up on its layout.
74
+ local SELECTION_LAYOUT_MAX_REQUEST_COUNT = 8
75
+ --- Polling ticks between two registration requests for the same selection.
76
+ local SELECTION_LAYOUT_REQUEST_INTERVAL = 16
77
+ local registeredSelectionGrid
78
+ local registeredSelectionButtonCount = 0
79
+ local registeredSelectionButtons = {}
80
+ local registeredSelectionButtonChildCounts = {}
81
+ local registeredSelectionIcons = {}
82
+ --- The index of the widest (highlighted) button among the registered ones. The first value
83
+ -- is false when the layout no longer matches the registration: the grid or a button has a
84
+ -- different number of children, or an icon reads as zero width, which a destroyed frame does.
85
+ local function getRegisteredMainSelectedUnitIndex()
86
+ local grid = registeredSelectionGrid
87
+ if grid == nil or frameGetChildrenCount(grid) ~= registeredSelectionButtonCount then
88
+ return false, 0
89
+ end
90
+ local mainSelectedUnitIndex = 0
91
+ local maxButtonWidth = 0
92
+ for i = 0, registeredSelectionButtonCount - 1 do
93
+ if frameGetChildrenCount(registeredSelectionButtons[i + 1]) ~= registeredSelectionButtonChildCounts[i + 1] then
94
+ return false, 0
95
+ end
96
+ local width = frameGetWidth(registeredSelectionIcons[i + 1])
97
+ if width <= 0 then
98
+ return false, 0
99
+ end
100
+ if width > maxButtonWidth then
101
+ maxButtonWidth = width
102
+ mainSelectedUnitIndex = i
103
+ end
104
+ end
105
+ return true, mainSelectedUnitIndex
106
+ end
107
+ local function getChildIfPresent(parent, index)
108
+ if parent == nil or index >= frameGetChildrenCount(parent) then
109
+ return nil
110
+ end
111
+ return frameGetChild(parent, index)
112
+ end
113
+ local function padSelectionLayoutFrames(registeredCount)
114
+ do
115
+ local i = registeredCount
116
+ while i < SELECTION_LAYOUT_MAX_HANDLE_COUNT do
117
+ location(0, 0)
118
+ i = i + 1
119
+ end
120
+ end
121
+ end
122
+ --- Wraps every frame of the group selection layout currently shown on this client, in the
123
+ -- order `actualizeMainSelectedUnit` later walks them. Game-owned frames receive a JASS handle
124
+ -- id the first time a script retrieves them, and the game builds the layout's buttons anew
125
+ -- whenever the selection changes, so this must run in a tick every client shares and register
126
+ -- the same number of handles everywhere: every frame reached for the first time counts, and
127
+ -- the remainder up to SELECTION_LAYOUT_MAX_HANDLE_COUNT is padded with locations, the way
128
+ -- `Frame.byOrigin` balances origin frames that appear asynchronously.
129
+ --
130
+ -- Returns the number of buttons found, or undefined when the layout was not fully reachable.
131
+ local function registerShownSelectionLayoutFrames()
132
+ local registeredCount = 0
133
+ local function register(handle)
134
+ if handle == nil or getHandleId(handle) == 0 then
135
+ return nil
136
+ end
137
+ if not Frame:isWrapped(handle) then
138
+ registeredCount = registeredCount + 1
139
+ end
140
+ Frame:of(handle)
141
+ return handle
142
+ end
143
+ local detail = register(getFrameByName(SELECTION_DETAIL_FRAME_NAME, 0))
144
+ local container = register(detail ~= nil and frameGetParent(detail) or nil)
145
+ local groupPanel = register(getChildIfPresent(container, SELECTION_GROUP_PANEL_INDEX))
146
+ local grid = register(getChildIfPresent(groupPanel, 0))
147
+ registeredSelectionGrid = grid
148
+ local buttonCount
149
+ if grid ~= nil then
150
+ local count = frameGetChildrenCount(grid)
151
+ if count <= SELECTION_LAYOUT_MAX_BUTTON_COUNT then
152
+ buttonCount = count
153
+ for i = 0, count - 1 do
154
+ local button = register(getChildIfPresent(grid, i))
155
+ local icon = register(getChildIfPresent(button, SELECTION_BUTTON_ICON_INDEX))
156
+ if button == nil or icon == nil then
157
+ buttonCount = nil
158
+ else
159
+ registeredSelectionButtons[i + 1] = button
160
+ registeredSelectionButtonChildCounts[i + 1] = frameGetChildrenCount(button)
161
+ registeredSelectionIcons[i + 1] = icon
162
+ end
163
+ end
164
+ end
165
+ end
166
+ padSelectionLayoutFrames(registeredCount)
167
+ return buttonCount
168
+ end
169
+ local function getExpectedSelectionLayoutButtonCount(selectionCount)
170
+ return selectionCount <= 12 and 12 or SELECTION_LAYOUT_MAX_BUTTON_COUNT
171
+ end
172
+ local selectionLayoutSocket = __TS__New(Socket)
173
+ local localSelectionSignature = 0
174
+ local localSelectionEpoch = 0
175
+ local localSelectionCount = 0
176
+ local registeredSelectionEpoch = 0
177
+ local selectionLayoutRequestCount = 0
178
+ local selectionLayoutRequestPending = false
179
+ local selectionLayoutPollTick = 0
180
+ local selectionLayoutRequestTick = -SELECTION_LAYOUT_REQUEST_INTERVAL
181
+ selectionLayoutSocket.onMessage:addListener(function(player)
182
+ if player ~= Player["local"] then
183
+ padSelectionLayoutFrames(0)
184
+ return
185
+ end
186
+ selectionLayoutRequestPending = false
187
+ local buttonCount = registerShownSelectionLayoutFrames()
188
+ if buttonCount ~= nil and localSelectionCount > 1 and buttonCount == getExpectedSelectionLayoutButtonCount(localSelectionCount) then
189
+ registeredSelectionEpoch = localSelectionEpoch
190
+ registeredSelectionButtonCount = buttonCount
191
+ end
51
192
  end)
52
193
  local localSelectedUnits = {}
53
194
  local indexByLocalSelectedUnit = {}
@@ -65,6 +206,7 @@ local function compareUnitsSelectionPriority(a, b)
65
206
  end
66
207
  local mainSelectedUnitChangeEvent
67
208
  local previousMainSelectedUnit
209
+ local currentMainSelectedUnit
68
210
  local lastTargetingModeState = false
69
211
  local targetingModeEnterEvent = __TS__New(Event)
70
212
  local targetingModeLeaveEvent = __TS__New(Event)
@@ -99,6 +241,27 @@ function LocalClient.pingMinimap(self, x, y, duration, redOrColor, greenOrFlashy
99
241
  )
100
242
  end
101
243
  end
244
+ function LocalClient.isKeyPressed(self, key)
245
+ return isKeyPressed(key)
246
+ end
247
+ function LocalClient.isMetaKeyPressed(self, key)
248
+ return isMetaKeyPressed(key)
249
+ end
250
+ function LocalClient.isMouseButtonPressed(self, button)
251
+ return isMouseButtonPressed(button)
252
+ end
253
+ function LocalClient.screenToFrameX(self, x)
254
+ return pixelToFrameX(x)
255
+ end
256
+ function LocalClient.screenToFrameY(self, y)
257
+ return pixelToFrameY(y)
258
+ end
259
+ function LocalClient.frameToScreenX(self, x)
260
+ return frameToPixelX(x)
261
+ end
262
+ function LocalClient.frameToScreenY(self, y)
263
+ return frameToPixelY(y)
264
+ end
102
265
  LocalClient.locale = getLocale()
103
266
  __TS__ObjectDefineProperty(
104
267
  LocalClient,
@@ -114,6 +277,13 @@ __TS__ObjectDefineProperty(
114
277
  return getLocalClientHeight()
115
278
  end}
116
279
  )
280
+ __TS__ObjectDefineProperty(
281
+ LocalClient,
282
+ "isSD",
283
+ {get = function(self)
284
+ return true
285
+ end}
286
+ )
117
287
  __TS__ObjectDefineProperty(
118
288
  LocalClient,
119
289
  "isHD",
@@ -121,11 +291,18 @@ __TS__ObjectDefineProperty(
121
291
  return false
122
292
  end}
123
293
  )
294
+ __TS__ObjectDefineProperty(
295
+ LocalClient,
296
+ "isDE",
297
+ {get = function(self)
298
+ return false
299
+ end}
300
+ )
124
301
  __TS__ObjectDefineProperty(
125
302
  LocalClient,
126
303
  "graphicsMode",
127
304
  {get = function(self)
128
- return self.isHD and 1 or 0
305
+ return 0
129
306
  end}
130
307
  )
131
308
  __TS__ObjectDefineProperty(
@@ -142,6 +319,34 @@ __TS__ObjectDefineProperty(
142
319
  return getLocalClientHeight() == 0
143
320
  end}
144
321
  )
322
+ __TS__ObjectDefineProperty(
323
+ LocalClient,
324
+ "mouseScreenX",
325
+ {get = function(self)
326
+ return getMouseScreenPosX()
327
+ end}
328
+ )
329
+ __TS__ObjectDefineProperty(
330
+ LocalClient,
331
+ "mouseScreenY",
332
+ {get = function(self)
333
+ return getMouseScreenPosY()
334
+ end}
335
+ )
336
+ __TS__ObjectDefineProperty(
337
+ LocalClient,
338
+ "mouseFrameX",
339
+ {get = function(self)
340
+ return pixelToFrameX(getMouseScreenPosX())
341
+ end}
342
+ )
343
+ __TS__ObjectDefineProperty(
344
+ LocalClient,
345
+ "mouseFrameY",
346
+ {get = function(self)
347
+ return pixelToFrameY(getMouseScreenPosY())
348
+ end}
349
+ )
145
350
  __TS__ObjectDefineProperty(
146
351
  LocalClient,
147
352
  "mouseFocusUnit",
@@ -153,33 +358,7 @@ __TS__ObjectDefineProperty(
153
358
  LocalClient,
154
359
  "mainSelectedUnit",
155
360
  {get = function(self)
156
- Unit:getSelectionOf(Player["local"], localSelectedUnits)
157
- for i = 1, #localSelectedUnits do
158
- indexByLocalSelectedUnit[localSelectedUnits[i]] = i
159
- end
160
- tableSort(localSelectedUnits, compareUnitsSelectionPriority)
161
- local mainSelectedUnitIndex
162
- if selectionButtons and #localSelectedUnits > 1 then
163
- local maxButtonWidth = 0
164
- for i = 0, #selectionButtons - 1 do
165
- local width = selectionButtons[i + 1].width
166
- if width > maxButtonWidth then
167
- maxButtonWidth = width
168
- mainSelectedUnitIndex = i
169
- end
170
- end
171
- end
172
- local mainSelectedUnit = localSelectedUnits[(mainSelectedUnitIndex or 0) + 1]
173
- for i = 1, #localSelectedUnits do
174
- indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
175
- localSelectedUnits[i] = nil
176
- end
177
- if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
178
- local previousPreviousMainSelectedUnit = previousMainSelectedUnit
179
- previousMainSelectedUnit = mainSelectedUnit
180
- Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
181
- end
182
- return mainSelectedUnit
361
+ return currentMainSelectedUnit
183
362
  end}
184
363
  )
185
364
  __TS__ObjectDefineProperty(
@@ -188,9 +367,6 @@ __TS__ObjectDefineProperty(
188
367
  {get = function(self)
189
368
  if mainSelectedUnitChangeEvent == nil then
190
369
  mainSelectedUnitChangeEvent = __TS__New(Event)
191
- Timer.onPeriod[1 / 64]:addListener(function()
192
- local _ = ____exports.LocalClient.mainSelectedUnit
193
- end)
194
370
  end
195
371
  return mainSelectedUnitChangeEvent
196
372
  end}
@@ -212,6 +388,59 @@ LocalClient.onDisconnect = __TS__New(
212
388
  end,
213
389
  function() return end
214
390
  )
391
+ local function actualizeMainSelectedUnit()
392
+ Unit:getSelectionOf(Player["local"], localSelectedUnits)
393
+ local selectionCount = #localSelectedUnits
394
+ local signature = selectionCount
395
+ for i = 1, selectionCount do
396
+ indexByLocalSelectedUnit[localSelectedUnits[i]] = i
397
+ signature = signature + getHandleId(localSelectedUnits[i].handle)
398
+ end
399
+ selectionLayoutPollTick = selectionLayoutPollTick + 1
400
+ if signature ~= localSelectionSignature then
401
+ localSelectionSignature = signature
402
+ localSelectionEpoch = localSelectionEpoch + 1
403
+ selectionLayoutRequestCount = 0
404
+ selectionLayoutRequestTick = -SELECTION_LAYOUT_REQUEST_INTERVAL
405
+ end
406
+ localSelectionCount = selectionCount
407
+ tableSort(localSelectedUnits, compareUnitsSelectionPriority)
408
+ local mainSelectedUnitIndex
409
+ if selectionCount > 1 then
410
+ local registered = registeredSelectionEpoch == localSelectionEpoch
411
+ if registered then
412
+ local intact, index = getRegisteredMainSelectedUnitIndex()
413
+ if intact then
414
+ mainSelectedUnitIndex = index
415
+ else
416
+ registered = false
417
+ registeredSelectionEpoch = 0
418
+ end
419
+ end
420
+ if not registered and not selectionLayoutRequestPending and selectionLayoutRequestCount < SELECTION_LAYOUT_MAX_REQUEST_COUNT and selectionLayoutPollTick - selectionLayoutRequestTick >= SELECTION_LAYOUT_REQUEST_INTERVAL then
421
+ selectionLayoutRequestPending = true
422
+ selectionLayoutRequestCount = selectionLayoutRequestCount + 1
423
+ selectionLayoutRequestTick = selectionLayoutPollTick
424
+ selectionLayoutSocket:send("")
425
+ end
426
+ end
427
+ local mainSelectedUnit
428
+ if selectionCount <= 1 then
429
+ mainSelectedUnit = localSelectedUnits[1]
430
+ elseif mainSelectedUnitIndex ~= nil then
431
+ mainSelectedUnit = localSelectedUnits[mainSelectedUnitIndex + 1]
432
+ end
433
+ for i = 1, selectionCount do
434
+ indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
435
+ localSelectedUnits[i] = nil
436
+ end
437
+ currentMainSelectedUnit = mainSelectedUnit
438
+ if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
439
+ local previousPreviousMainSelectedUnit = previousMainSelectedUnit
440
+ previousMainSelectedUnit = mainSelectedUnit
441
+ Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
442
+ end
443
+ end
215
444
  local commandButtons = array(
216
445
  12,
217
446
  function(i) return Frame:byOrigin(ORIGIN_FRAME_COMMAND_BUTTON, i) end
@@ -241,13 +470,15 @@ actualizeTargetingModeState = function()
241
470
  return false
242
471
  end
243
472
  Timer.onPeriod[1 / 64]:addListener(function()
473
+ actualizeMainSelectedUnit()
244
474
  actualizeTargetingModeState()
245
475
  end)
246
476
  warpack.afterMapInit(function()
247
- rawset(
248
- ____exports.LocalClient,
249
- "isHD",
250
- loadTOCFile(tocPath)
251
- )
477
+ local isDE = loadTOCFile(deTocPath)
478
+ local isHD = not isDE and loadTOCFile(hdTocPath)
479
+ rawset(____exports.LocalClient, "isDE", isDE)
480
+ rawset(____exports.LocalClient, "isHD", isHD)
481
+ rawset(____exports.LocalClient, "isSD", not isDE and not isHD)
482
+ rawset(____exports.LocalClient, "graphicsMode", isDE and 2 or (isHD and 1 or 0))
252
483
  end)
253
484
  return ____exports
@@ -0,0 +1,12 @@
1
+ /** @noSelfInFile */
2
+ export declare const enum EquipmentSlot {
3
+ HEAD = 0,
4
+ CHEST = 1,
5
+ GLOVES = 2,
6
+ BOOTS = 3,
7
+ RING = 4,
8
+ ALTERNATE_RING = 5,
9
+ PRIMARY = 6,
10
+ OFFHAND = 7,
11
+ TRINKET = 8
12
+ }
@@ -0,0 +1,2 @@
1
+ local ____exports = {}
2
+ return ____exports
@@ -0,0 +1,13 @@
1
+ /** @noSelfInFile */
2
+ export declare const enum EquipmentType {
3
+ NONE = 0,
4
+ HEAD = 1,
5
+ CHEST = 2,
6
+ GLOVES = 3,
7
+ BOOTS = 4,
8
+ RING = 5,
9
+ PRIMARY = 6,
10
+ OFFHAND = 7,
11
+ TRINKET = 8,
12
+ ANY = 9
13
+ }
@@ -0,0 +1,2 @@
1
+ local ____exports = {}
2
+ return ____exports
@@ -0,0 +1,12 @@
1
+ /** @noSelfInFile */
2
+ export declare const enum ItemTag {
3
+ UNDEFINED = 0,
4
+ DROPPABLE = 1,
5
+ QUEST_REWARD = 2,
6
+ BOSS_DROP = 3,
7
+ SECRET = 4,
8
+ PUZZLE = 5,
9
+ WORLD = 6,
10
+ SHOP = 7,
11
+ ANY = 8
12
+ }
@@ -0,0 +1,2 @@
1
+ local ____exports = {}
2
+ return ____exports
@@ -11,8 +11,9 @@ export declare const enum SoundSetName {
11
11
  ALTAR_OF_ELDERS = "AltarOfElders",
12
12
  ALTAR_OF_KINGS = "AltarOfKings",
13
13
  ALTAR_OF_STORMS = "AltarOfStorms",
14
- ARCHMAGE = "HeroArchmage",
14
+ ARCHMAGE = "HeroArchMage",
15
15
  BANDIT = "Bandit",
16
+ BANSHEE = "Banshee",
16
17
  BLOOD_MAGE = "BloodElfSorceror",
17
18
  BREWMASTER = "PandarenBrewmaster",
18
19
  CLOCKWERK_GOBLIN = "ClockwerkGoblin",
@@ -20,16 +21,26 @@ export declare const enum SoundSetName {
20
21
  DEATH_KNIGHT = "HeroDeathKnight",
21
22
  DEMON_HUNTER = "HeroDemonHunter",
22
23
  DEMON_HUNTER_MORPHED = "HeroDemonHunterMorphed",
23
- FOOTMAN = "Footman",
24
+ EVIL_ARTHAS = "EvilArthas",
24
25
  FEL_ORC_GRUNT = "ChaosGrunt",
26
+ FEMALE_CENTAUR = "FemaleCentaur",
25
27
  FEMALE_DEMON_HUNTER = "HeroFemaleDemonHunter",
26
28
  FEMALE_DEMON_HUNTER_MORPHED = "HeroFemaleDemonHunterMorphed",
29
+ FOOTMAN = "Footman",
30
+ FOREST_TROLL = "ForestTroll",
27
31
  FURBOLG = "Furbolg",
28
32
  GOBLIN_SAPPER = "GoblinSapper",
33
+ GROM = "Grom",
29
34
  GRUNT = "Grunt",
35
+ ILLIDAN = "Illidan",
30
36
  MOUNTAIN_KING = "HeroMountainKing",
31
37
  NERUBIAN = "Nerubian",
32
38
  PALADIN = "HeroPaladin",
39
+ PRIEST = "Priest",
40
+ REVENANT = "Revenant",
33
41
  RIFLEMAN = "Rifleman",
34
- TINKER = "HeroTinker"
42
+ SKELETON = "Skeleton",
43
+ SNAP_DRAGON = "SnapDragon",
44
+ TINKER = "HeroTinker",
45
+ WARDEN = "HeroWarden"
35
46
  }
@@ -0,0 +1,22 @@
1
+ /** @noSelfInFile */
2
+ import { EnsnareAbilityType } from "./ensnare";
3
+ import { AbilityTypeId } from "../ability-type";
4
+ import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
5
+ /**
6
+ * Apprehend (Aena) — ensnare with stun/attack speed/bonus damage/silence extensions (Data D-G).
7
+ */
8
+ export declare class ApprehendAbilityType extends EnsnareAbilityType {
9
+ static readonly BASE_ID: AbilityTypeId;
10
+ /** Stun Duration */
11
+ get stunDuration(): number[];
12
+ set stunDuration(stunDuration: ObjectDataEntryLevelFieldValueSupplier<number>);
13
+ /** Attack Speed Reduction Percent */
14
+ get attackSpeedReductionPercentage(): number[];
15
+ set attackSpeedReductionPercentage(attackSpeedReductionPercentage: ObjectDataEntryLevelFieldValueSupplier<number>);
16
+ /** Bonus Damage Taken Percent */
17
+ get bonusDamageTakenPercentage(): number[];
18
+ set bonusDamageTakenPercentage(bonusDamageTakenPercentage: ObjectDataEntryLevelFieldValueSupplier<number>);
19
+ /** Silences When Ensnared */
20
+ get silencesWhenEnsnared(): boolean[];
21
+ set silencesWhenEnsnared(silencesWhenEnsnared: ObjectDataEntryLevelFieldValueSupplier<boolean>);
22
+ }
@@ -0,0 +1,66 @@
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 ____ensnare = require("engine.object-data.entry.ability-type.ensnare")
7
+ local EnsnareAbilityType = ____ensnare.EnsnareAbilityType
8
+ --- Apprehend (Aena) — ensnare with stun/attack speed/bonus damage/silence extensions (Data D-G).
9
+ ____exports.ApprehendAbilityType = __TS__Class()
10
+ local ApprehendAbilityType = ____exports.ApprehendAbilityType
11
+ ApprehendAbilityType.name = "ApprehendAbilityType"
12
+ __TS__ClassExtends(ApprehendAbilityType, EnsnareAbilityType)
13
+ ApprehendAbilityType.BASE_ID = fourCC("Aena")
14
+ __TS__SetDescriptor(
15
+ ApprehendAbilityType.prototype,
16
+ "stunDuration",
17
+ {
18
+ get = function(self)
19
+ return self:getNumberLevelField("Ens4")
20
+ end,
21
+ set = function(self, stunDuration)
22
+ self:setNumberLevelField("Ens4", stunDuration)
23
+ end
24
+ },
25
+ true
26
+ )
27
+ __TS__SetDescriptor(
28
+ ApprehendAbilityType.prototype,
29
+ "attackSpeedReductionPercentage",
30
+ {
31
+ get = function(self)
32
+ return self:getNumberLevelField("Ens5")
33
+ end,
34
+ set = function(self, attackSpeedReductionPercentage)
35
+ self:setNumberLevelField("Ens5", attackSpeedReductionPercentage)
36
+ end
37
+ },
38
+ true
39
+ )
40
+ __TS__SetDescriptor(
41
+ ApprehendAbilityType.prototype,
42
+ "bonusDamageTakenPercentage",
43
+ {
44
+ get = function(self)
45
+ return self:getNumberLevelField("Ens6")
46
+ end,
47
+ set = function(self, bonusDamageTakenPercentage)
48
+ self:setNumberLevelField("Ens6", bonusDamageTakenPercentage)
49
+ end
50
+ },
51
+ true
52
+ )
53
+ __TS__SetDescriptor(
54
+ ApprehendAbilityType.prototype,
55
+ "silencesWhenEnsnared",
56
+ {
57
+ get = function(self)
58
+ return self:getBooleanLevelField("Ens7")
59
+ end,
60
+ set = function(self, silencesWhenEnsnared)
61
+ self:setBooleanLevelField("Ens7", silencesWhenEnsnared)
62
+ end
63
+ },
64
+ true
65
+ )
66
+ return ____exports
@@ -0,0 +1,8 @@
1
+ /** @noSelfInFile */
2
+ import { AbilityType, AbilityTypeId } from "../ability-type";
3
+ /**
4
+ * Banshee (Abns). Has no data fields of its own.
5
+ */
6
+ export declare class BansheeAbilityType extends AbilityType {
7
+ static readonly BASE_ID: AbilityTypeId;
8
+ }
@@ -0,0 +1,13 @@
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_2Dtype = require("engine.object-data.entry.ability-type")
6
+ local AbilityType = ____ability_2Dtype.AbilityType
7
+ --- Banshee (Abns). Has no data fields of its own.
8
+ ____exports.BansheeAbilityType = __TS__Class()
9
+ local BansheeAbilityType = ____exports.BansheeAbilityType
10
+ BansheeAbilityType.name = "BansheeAbilityType"
11
+ __TS__ClassExtends(BansheeAbilityType, AbilityType)
12
+ BansheeAbilityType.BASE_ID = fourCC("Abns")
13
+ return ____exports
@@ -0,0 +1,12 @@
1
+ /** @noSelfInFile */
2
+ import { AbilityType, AbilityTypeId } from "../ability-type";
3
+ import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
4
+ /**
5
+ * Ability damage amplification applied by Banshee's Wail (Amda).
6
+ */
7
+ export declare class BansheesWailDamageAmpAbilityType extends AbilityType {
8
+ static readonly BASE_ID: AbilityTypeId;
9
+ /** Bonus Magic Damage Factor */
10
+ get bonusMagicDamageFactor(): number[];
11
+ set bonusMagicDamageFactor(bonusMagicDamageFactor: ObjectDataEntryLevelFieldValueSupplier<number>);
12
+ }
@@ -0,0 +1,27 @@
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
+ --- Ability damage amplification applied by Banshee's Wail (Amda).
9
+ ____exports.BansheesWailDamageAmpAbilityType = __TS__Class()
10
+ local BansheesWailDamageAmpAbilityType = ____exports.BansheesWailDamageAmpAbilityType
11
+ BansheesWailDamageAmpAbilityType.name = "BansheesWailDamageAmpAbilityType"
12
+ __TS__ClassExtends(BansheesWailDamageAmpAbilityType, AbilityType)
13
+ BansheesWailDamageAmpAbilityType.BASE_ID = fourCC("Amda")
14
+ __TS__SetDescriptor(
15
+ BansheesWailDamageAmpAbilityType.prototype,
16
+ "bonusMagicDamageFactor",
17
+ {
18
+ get = function(self)
19
+ return self:getNumberLevelField("mda1")
20
+ end,
21
+ set = function(self, bonusMagicDamageFactor)
22
+ self:setNumberLevelField("mda1", bonusMagicDamageFactor)
23
+ end
24
+ },
25
+ true
26
+ )
27
+ return ____exports