warcraft-3-w3ts-utils 0.1.6 → 0.1.8

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 (81) hide show
  1. package/dist/index.lua +13 -0
  2. package/dist/lua_modules/w3ts/globals/index.lua +23 -0
  3. package/dist/lua_modules/w3ts/globals/order.lua +2 -0
  4. package/dist/lua_modules/w3ts/handles/camera.lua +348 -0
  5. package/dist/lua_modules/w3ts/handles/destructable.lua +237 -0
  6. package/dist/lua_modules/w3ts/handles/dialog.lua +161 -0
  7. package/dist/lua_modules/w3ts/handles/effect.lua +198 -0
  8. package/dist/lua_modules/w3ts/handles/fogmodifier.lua +76 -0
  9. package/dist/lua_modules/w3ts/handles/force.lua +105 -0
  10. package/dist/lua_modules/w3ts/handles/frame.lua +417 -0
  11. package/dist/lua_modules/w3ts/handles/gamecache.lua +132 -0
  12. package/dist/lua_modules/w3ts/handles/group.lua +215 -0
  13. package/dist/lua_modules/w3ts/handles/handle.lua +38 -0
  14. package/dist/lua_modules/w3ts/handles/image.lua +105 -0
  15. package/dist/lua_modules/w3ts/handles/index.lua +226 -0
  16. package/dist/lua_modules/w3ts/handles/item.lua +375 -0
  17. package/dist/lua_modules/w3ts/handles/leaderboard.lua +211 -0
  18. package/dist/lua_modules/w3ts/handles/multiboard.lua +193 -0
  19. package/dist/lua_modules/w3ts/handles/player.lua +311 -0
  20. package/dist/lua_modules/w3ts/handles/point.lua +80 -0
  21. package/dist/lua_modules/w3ts/handles/quest.lua +176 -0
  22. package/dist/lua_modules/w3ts/handles/rect.lua +129 -0
  23. package/dist/lua_modules/w3ts/handles/region.lua +72 -0
  24. package/dist/lua_modules/w3ts/handles/sound.lua +174 -0
  25. package/dist/lua_modules/w3ts/handles/texttag.lua +97 -0
  26. package/dist/lua_modules/w3ts/handles/timer.lua +83 -0
  27. package/dist/lua_modules/w3ts/handles/timerdialog.lua +86 -0
  28. package/dist/lua_modules/w3ts/handles/trigger.lua +265 -0
  29. package/dist/lua_modules/w3ts/handles/ubersplat.lua +84 -0
  30. package/dist/lua_modules/w3ts/handles/unit.lua +1330 -0
  31. package/dist/lua_modules/w3ts/handles/weathereffect.lua +42 -0
  32. package/dist/lua_modules/w3ts/handles/widget.lua +53 -0
  33. package/dist/lua_modules/w3ts/hooks/index.lua +52 -0
  34. package/dist/lua_modules/w3ts/index.lua +36 -0
  35. package/dist/lua_modules/w3ts/system/base64.lua +108 -0
  36. package/dist/lua_modules/w3ts/system/binaryreader.lua +74 -0
  37. package/dist/lua_modules/w3ts/system/binarywriter.lua +88 -0
  38. package/dist/lua_modules/w3ts/system/file.lua +88 -0
  39. package/dist/lua_modules/w3ts/system/gametime.lua +27 -0
  40. package/dist/lua_modules/w3ts/system/host.lua +104 -0
  41. package/dist/lua_modules/w3ts/system/index.lua +58 -0
  42. package/dist/lua_modules/w3ts/system/sync.lua +239 -0
  43. package/dist/lua_modules/w3ts/utils/color.lua +189 -0
  44. package/dist/lua_modules/w3ts/utils/index.lua +38 -0
  45. package/dist/lualib_bundle.lua +2733 -0
  46. package/dist/package.json +41 -0
  47. package/dist/utils/abilities.lua +107 -0
  48. package/dist/utils/camera.lua +46 -0
  49. package/dist/utils/chat-command.lua +30 -0
  50. package/dist/utils/color.lua +41 -0
  51. package/dist/utils/index.lua +125 -0
  52. package/dist/utils/item.lua +173 -0
  53. package/dist/utils/math.lua +17 -0
  54. package/dist/utils/minimapIcons.lua +28 -0
  55. package/dist/utils/misc.lua +143 -0
  56. package/dist/utils/physics.lua +161 -0
  57. package/dist/utils/players.lua +234 -0
  58. package/dist/utils/point.lua +60 -0
  59. package/dist/utils/quests.lua +47 -0
  60. package/dist/utils/textTag.lua +110 -0
  61. package/dist/utils/timer.lua +21 -0
  62. package/dist/utils/units.lua +102 -0
  63. package/package.json +4 -6
  64. package/dist/index.js +0 -18
  65. package/dist/utils/abilities.js +0 -125
  66. package/dist/utils/camera.js +0 -37
  67. package/dist/utils/chat-command.js +0 -22
  68. package/dist/utils/color.js +0 -141
  69. package/dist/utils/index.js +0 -32
  70. package/dist/utils/item.js +0 -124
  71. package/dist/utils/math.js +0 -17
  72. package/dist/utils/minimapIcons.js +0 -27
  73. package/dist/utils/misc.js +0 -175
  74. package/dist/utils/physics.js +0 -194
  75. package/dist/utils/players.js +0 -189
  76. package/dist/utils/point.js +0 -74
  77. package/dist/utils/quests.js +0 -30
  78. package/dist/utils/textTag.js +0 -72
  79. package/dist/utils/timer.js +0 -16
  80. package/dist/utils/units.js +0 -81
  81. package/tsconfig.json +0 -37
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "warcraft-3-w3ts-utils",
3
+ "version": "0.1.8",
4
+ "description": "A library of utility functions for modding Warcraft 3 utilizing the W3TS template.",
5
+ "main": "./src/index.ts",
6
+ "keywords": [
7
+ "Warcraft 3"
8
+ ],
9
+ "scripts": {
10
+ "build": "tstl -p tsconfig.json",
11
+ "prepare": "npm run build && cp package.json ./dist/"
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/bertman12/WC3-W3TS-utils.git"
19
+ },
20
+ "author": "bertman12",
21
+ "license": "MIT",
22
+ "bugs": {
23
+ "url": "https://github.com/bertman12/WC3-W3TS-utils/issues"
24
+ },
25
+ "homepage": "https://github.com/bertman12/WC3-W3TS-utils#readme",
26
+ "dependencies": {
27
+ "war3-types-strict": "^0.1.3"
28
+ },
29
+ "devDependencies": {
30
+ "lua-types": "^2.13.1",
31
+ "typescript-to-lua": "1.31.0",
32
+ "war3-objectdata-th": "^0.2.11",
33
+ "war3-transformer": "^3.0.10",
34
+ "war3tstlhelper": "1.0.1"
35
+ },
36
+ "peerDependencies": {
37
+ "typescript": "^5.0.4",
38
+ "w3ts": "3.0.2",
39
+ "lua-types": "^2.13.1"
40
+ }
41
+ }
@@ -0,0 +1,107 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
3
+ local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local ____w3ts = require("lua_modules.w3ts.index")
7
+ local Timer = ____w3ts.Timer
8
+ local Trigger = ____w3ts.Trigger
9
+ local Unit = ____w3ts.Unit
10
+ --- Good for once a unit gets near you, but not good while they are near you since the event is only triggered on entry, not during
11
+ --
12
+ -- @param unit
13
+ -- @param range
14
+ -- @param cb
15
+ -- @param config
16
+ -- @returns
17
+ function ____exports.unitGetsNearThisUnit(self, unit, range, cb, config)
18
+ local trig = Trigger:create()
19
+ --- A unique set of the units effected
20
+ local effectedUnitPool = {}
21
+ trig:registerUnitInRage(
22
+ unit.handle,
23
+ range,
24
+ config and config.filter or (function() return true end)
25
+ )
26
+ trig:addAction(function()
27
+ local u = Unit:fromEvent()
28
+ if not u then
29
+ return
30
+ end
31
+ if not __TS__ArrayIncludes(effectedUnitPool, u) then
32
+ effectedUnitPool[#effectedUnitPool + 1] = u
33
+ end
34
+ if config and config.uniqueUnitsOnly and not __TS__ArrayIncludes(effectedUnitPool, u) then
35
+ cb(nil, u)
36
+ else
37
+ cb(nil, u)
38
+ end
39
+ end)
40
+ local function destroy()
41
+ if config and config.onDestroy then
42
+ if config ~= nil then
43
+ config:onDestroy(effectedUnitPool)
44
+ end
45
+ end
46
+ trig:destroy()
47
+ end
48
+ local function clearUniqueUnits()
49
+ effectedUnitPool = {}
50
+ end
51
+ return {
52
+ cleanupUnitGetsNearThisUnit = function(____, delay)
53
+ if delay then
54
+ local timer = Timer:create()
55
+ timer:start(
56
+ delay,
57
+ false,
58
+ function()
59
+ destroy(nil)
60
+ timer:destroy()
61
+ end
62
+ )
63
+ return
64
+ end
65
+ destroy(nil)
66
+ end,
67
+ clearUniqueUnits = clearUniqueUnits
68
+ }
69
+ end
70
+ --- Creates a trigger to monitor when a unit is attacked
71
+ --
72
+ -- We could also have all functions execute in this single trigger's context instead of creating new triggers each time the function is used.
73
+ --
74
+ -- @param cb
75
+ -- @param config
76
+ function ____exports.onUnitAttacked(self, cb, config)
77
+ local attackerTriggerCooldown = __TS__New(Set)
78
+ local t = Trigger:create()
79
+ t:registerAnyUnitEvent(EVENT_PLAYER_UNIT_ATTACKED)
80
+ t:addAction(function()
81
+ local attacker = Unit:fromHandle(GetAttacker())
82
+ local victim = Unit:fromHandle(GetAttackedUnitBJ())
83
+ if not attacker or not victim then
84
+ return
85
+ end
86
+ if config.procChance and math.ceil(math.random() * 100) >= config.procChance then
87
+ return
88
+ end
89
+ if config.attackerCooldown and attackerTriggerCooldown:has(attacker) then
90
+ return
91
+ end
92
+ attackerTriggerCooldown:add(attacker)
93
+ cb(nil, attacker, victim)
94
+ local t = Timer:create()
95
+ t:start(
96
+ attacker:getAttackCooldown(0) / 3,
97
+ false,
98
+ function()
99
+ attackerTriggerCooldown:delete(attacker)
100
+ t:destroy()
101
+ end
102
+ )
103
+ end)
104
+ end
105
+ return ____exports
106
+
107
+ --# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9hYmlsaXRpZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxpQkFBcUM7QUFBNUI7QUFBTztBQUFTOzs7Ozs7OztBQVd6QixnREFDRSxNQUNBLE9BQ0EsSUFDQTtBQU1NLGlCQUFPLFFBQVE7O0FBS2pCLDZCQUEyQjtJQUUvQixLQUFLO1FBQW1CO1FBQWE7UUFBTyw0QkFBbUIsWUFBTSxXQUFOOztJQUUvRCxLQUFLLFVBQVU7QUFDUCxrQkFBSSxLQUFLO2VBRVY7QUFDSDs7ZUFHRyxzQ0FBMEI7QUFDN0Isc0RBQXNCOztXQUdwQiwwQ0FBNEIsc0NBQTBCO1lBQ3hELFFBQUc7O1lBRUgsUUFBRzs7SUFkUTtBQWtCVCxVQUFVLFNBQVY7V0FDQTtlQUNGO2dCQUFBLE9BQVEsVUFBVTs7O1FBSXBCLEtBQUs7SUFORDtBQVVBLFVBQW1CLFNBQW5CO0FBQ0osMkJBQW1CO0lBRGY7QUFJTixXQUFPO1FBQ0wsOEJBQTZCLGVBQUM7ZUFDeEI7QUFDSSw4QkFBUSxNQUFNO2dCQUNwQixNQUFNO29CQUFNO29CQUFPO29CQUFPO3dCQUN4Qjt3QkFDQSxNQUFNO29CQUZrQjs7QUFJMUI7O1lBR0Y7UUFWMkI7UUFZN0I7O0FBaEVKOzs7Ozs7O0FBMEdBLDBDQUNFLElBQ0E7QUFFTSxvQ0FBMEIsVUFBSTtBQUM5QixjQUFJLFFBQVE7SUFFbEIsRUFBRSxxQkFBcUI7SUFFdkIsRUFBRSxVQUFVO0FBQ0oseUJBQVcsS0FBSyxXQUFXO0FBQzNCLHVCQUFTLEtBQUssV0FBVztXQUUzQixJQUFDLGdCQUFhO0FBQ2hCOztXQUtBLHNCQUNBLFVBQVUsZ0JBQWdCLFFBQVE7QUFFbEM7O1dBSUUsNEJBQTJCLHdCQUF3QixJQUFJO0FBQ3pEOztRQUdGLHdCQUF3QixJQUFJO1FBRzVCLFFBQUcsVUFBVTtBQUVQLGtCQUFJLE1BQU07UUFHaEIsRUFBRTtZQUFNLFNBQVMsa0JBQWtCLEtBQUs7WUFBRztZQUFPO2dCQUNoRCx3QkFBd0IsT0FBTztnQkFDL0IsRUFBRTtZQUY4Qzs7SUE3QnhDO0FBVGQiLCJmaWxlIjoiYWJpbGl0aWVzLmx1YSIsInNvdXJjZVJvb3QiOiIifQ==
@@ -0,0 +1,46 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__StringSplit = ____lualib.__TS__StringSplit
3
+ local __TS__Unpack = ____lualib.__TS__Unpack
4
+ local __TS__Number = ____lualib.__TS__Number
5
+ local ____exports = {}
6
+ local ____w3ts = require("lua_modules.w3ts.index")
7
+ local Trigger = ____w3ts.Trigger
8
+ local ____players = require("utils.players")
9
+ local forEachPlayer = ____players.forEachPlayer
10
+ function ____exports.enableCameraZoom(self)
11
+ local t = Trigger:create()
12
+ forEachPlayer(
13
+ nil,
14
+ function(____, p)
15
+ SetCameraFieldForPlayer(p.handle, CAMERA_FIELD_FARZ, 10000, 0.25)
16
+ t:registerPlayerChatEvent(p, "-cam", false)
17
+ t:addAction(function()
18
+ local str = GetEventPlayerChatString()
19
+ local triggeringPlayer = GetTriggerPlayer()
20
+ if str and triggeringPlayer then
21
+ local ____opt_0 = str
22
+ local command, distance = __TS__Unpack(____opt_0 and __TS__StringSplit(str, " "))
23
+ SetCameraFieldForPlayer(triggeringPlayer, CAMERA_FIELD_FARZ, 10000, 0.25)
24
+ if distance == "mid" then
25
+ SetCameraFieldForPlayer(triggeringPlayer, CAMERA_FIELD_TARGET_DISTANCE, 4500, 0.25)
26
+ return
27
+ elseif distance == "far" then
28
+ SetCameraFieldForPlayer(triggeringPlayer, CAMERA_FIELD_TARGET_DISTANCE, 6000, 0.25)
29
+ return
30
+ elseif distance == "max" then
31
+ SetCameraFieldForPlayer(triggeringPlayer, CAMERA_FIELD_TARGET_DISTANCE, 7800, 0.25)
32
+ return
33
+ end
34
+ local distanceAsNumber = __TS__Number(distance)
35
+ if type(distanceAsNumber) ~= "number" then
36
+ return
37
+ end
38
+ SetCameraFieldForPlayer(triggeringPlayer, CAMERA_FIELD_TARGET_DISTANCE, distanceAsNumber, 0.25)
39
+ end
40
+ end)
41
+ end
42
+ )
43
+ end
44
+ return ____exports
45
+
46
+ --# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9jYW1lcmEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxpQkFBd0I7QUFBZjtBQUNULG9CQUE4QjtBQUFyQjtBQUlUO0FBQ1EsY0FBSSxRQUFRO0lBQ2xCOztRQUFjLGVBQUM7WUFDYix3QkFBd0IsVUFBVSxtQkFBbUIsT0FBTztZQUU1RCxFQUFFLHdCQUF3QixHQUFHLFFBQVE7WUFFckMsRUFBRSxVQUFVO0FBQ0osNEJBQU07QUFDTix5Q0FBbUI7bUJBQ3JCLFFBQU87c0NBQ21CO0FBQUEsMEJBQXJCLFNBQVMsV0FBWSxrREFBVztvQkFDdkMsd0JBQ0Usa0JBQ0EsbUJBQ0EsT0FDQTt1QkFHRSxZQUFrQzt3QkFDcEMsd0JBQ0Usa0JBQ0EsOEJBQ0EsTUFDQTtBQUVGOzJCQUNTLFlBQWtDO3dCQUMzQyx3QkFDRSxrQkFDQSw4QkFDQSxNQUNBO0FBRUY7MkJBQ1MsWUFBa0M7d0JBQzNDLHdCQUNFLGtCQUNBLDhCQUNBLE1BQ0E7QUFFRjs7QUFHSSw2Q0FBbUIsYUFBTzt1QkFDNUIsS0FBTyxxQkFBcUI7QUFBVTs7b0JBRTFDLHdCQUNFLGtCQUNBLDhCQUNBLGtCQUNBOztZQTdDTTtRQUxBOztBQUZoQiIsImZpbGUiOiJjYW1lcmEubHVhIiwic291cmNlUm9vdCI6IiJ9
@@ -0,0 +1,30 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__StringSplit = ____lualib.__TS__StringSplit
3
+ local __TS__Unpack = ____lualib.__TS__Unpack
4
+ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
5
+ local ____exports = {}
6
+ local ____w3ts = require("lua_modules.w3ts.index")
7
+ local Trigger = ____w3ts.Trigger
8
+ --- Setup trigger to listen for a chat command for the players specified in the array. Execute function when triggered
9
+ --
10
+ -- @param command -cam , -name, -start, etc
11
+ -- @param players
12
+ -- @param fn
13
+ function ____exports.createChatCommand(self, players, command, exact, fn)
14
+ local trigger = Trigger:create()
15
+ __TS__ArrayForEach(
16
+ players,
17
+ function(____, p)
18
+ trigger:registerPlayerChatEvent(p, command, exact)
19
+ trigger:addAction(function()
20
+ local str = GetEventPlayerChatString()
21
+ local ____opt_0 = str
22
+ local _, data = __TS__Unpack(____opt_0 and __TS__StringSplit(str, " ") or ({}))
23
+ fn(nil, p, {trigger = trigger, command = command, data = data})
24
+ end)
25
+ end
26
+ )
27
+ end
28
+ return ____exports
29
+
30
+ --# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9jaGF0LWNvbW1hbmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxpQkFBbUM7QUFBZjs7Ozs7O0FBUXBCLDZDQUFrQyxTQUFzQixTQUFpQixPQUFnQjtBQUMvRSxvQkFBVSxRQUFRO0lBRXhCO1FBQUE7UUFBZ0IsZUFBQztZQUNiLFFBQVEsd0JBQXdCLEdBQUcsU0FBUztZQUU1QyxRQUFRLFVBQVU7QUFDUiw0QkFBTTtrQ0FDTTtBQUFBLHNCQUFYLEdBQUcsT0FBUSxrREFBVyxRQUFRO2dCQUVyQyxRQUFHLEdBQUcsQ0FBRSxtQkFBUyxtQkFBUztZQUpaO1FBSE47O0FBSHBCIiwiZmlsZSI6ImNoYXQtY29tbWFuZC5sdWEiLCJzb3VyY2VSb290IjoiIn0=
@@ -0,0 +1,41 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ ____exports.playerRGBMap = __TS__New(Map, {
6
+ {0, {r = 255, g = 0, b = 0}},
7
+ {1, {r = 0, g = 0, b = 255}},
8
+ {2, {r = 0, g = 255, b = 255}},
9
+ {3, {r = 128, g = 0, b = 128}},
10
+ {4, {r = 255, g = 255, b = 0}},
11
+ {5, {r = 254, g = 137, b = 13}},
12
+ {6, {r = 32, g = 192, b = 0}},
13
+ {7, {r = 229, g = 91, b = 176}},
14
+ {8, {r = 149, g = 150, b = 151}},
15
+ {9, {r = 126, g = 191, b = 241}},
16
+ {10, {r = 16, g = 98, b = 70}},
17
+ {11, {r = 78, g = 42, b = 4}},
18
+ {12, {r = 155, g = 0, b = 0}},
19
+ {13, {r = 0, g = 0, b = 195}},
20
+ {14, {r = 155, g = 234, b = 255}},
21
+ {15, {r = 190, g = 0, b = 254}},
22
+ {16, {r = 235, g = 205, b = 135}},
23
+ {17, {r = 248, g = 164, b = 139}},
24
+ {18, {r = 191, g = 255, b = 128}},
25
+ {19, {r = 220, g = 185, b = 235}},
26
+ {20, {r = 40, g = 40, b = 40}},
27
+ {21, {r = 235, g = 240, b = 255}},
28
+ {22, {r = 0, g = 120, b = 30}},
29
+ {23, {r = 164, g = 111, b = 51}}
30
+ })
31
+ ____exports.playerHexColorMap = __TS__New(Map, {
32
+ {0, "ff0303"},
33
+ {1, "0042ff"},
34
+ {2, "1ce6b9"},
35
+ {3, "540081"},
36
+ {4, "fffc00"},
37
+ {5, "fe8a0e"}
38
+ })
39
+ return ____exports
40
+
41
+ --# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9jb2xvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQWEsMkJBQWUsVUFBSSxLQUFpRDtJQUM3RSxDQUFDLEdBQUcsQ0FBRSxJQUFHLEtBQUssSUFBRyxHQUFHLElBQUc7SUFDdkIsQ0FBQyxHQUFHLENBQUUsSUFBRyxHQUFHLElBQUcsR0FBRyxJQUFHO0lBQ3JCLENBQUMsR0FBRyxDQUFFLElBQUcsR0FBRyxJQUFHLEtBQUssSUFBRztJQUN2QixDQUFDLEdBQUcsQ0FBRSxJQUFHLEtBQUssSUFBRyxHQUFHLElBQUc7SUFDdkIsQ0FBQyxHQUFHLENBQUUsSUFBRyxLQUFLLElBQUcsS0FBSyxJQUFHO0lBQ3pCLENBQUMsR0FBRyxDQUFFLElBQUcsS0FBSyxJQUFHLEtBQUssSUFBRztJQUN6QixDQUFDLEdBQUcsQ0FBRSxJQUFHLElBQUksSUFBRyxLQUFLLElBQUc7SUFDeEIsQ0FBQyxHQUFHLENBQUUsSUFBRyxLQUFLLElBQUcsSUFBSSxJQU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FBQyxHQUFHO0lBQ0osQ0FBQyxHQUFHO0lBQ0osQ0FBQyxHQUFHO0lBQ0osQ0FBQyxHQUFHIiwiZmlsZSI6ImNvbG9yLmx1YSIsInNvdXJjZVJvb3QiOiIifQ==
@@ -0,0 +1,125 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ do
4
+ local ____export = require("utils.abilities")
5
+ for ____exportKey, ____exportValue in pairs(____export) do
6
+ if ____exportKey ~= "default" then
7
+ ____exports[____exportKey] = ____exportValue
8
+ end
9
+ end
10
+ end
11
+ do
12
+ local ____export = require("utils.camera")
13
+ for ____exportKey, ____exportValue in pairs(____export) do
14
+ if ____exportKey ~= "default" then
15
+ ____exports[____exportKey] = ____exportValue
16
+ end
17
+ end
18
+ end
19
+ do
20
+ local ____export = require("utils.chat-command")
21
+ for ____exportKey, ____exportValue in pairs(____export) do
22
+ if ____exportKey ~= "default" then
23
+ ____exports[____exportKey] = ____exportValue
24
+ end
25
+ end
26
+ end
27
+ do
28
+ local ____export = require("utils.color")
29
+ for ____exportKey, ____exportValue in pairs(____export) do
30
+ if ____exportKey ~= "default" then
31
+ ____exports[____exportKey] = ____exportValue
32
+ end
33
+ end
34
+ end
35
+ do
36
+ local ____export = require("utils.item")
37
+ for ____exportKey, ____exportValue in pairs(____export) do
38
+ if ____exportKey ~= "default" then
39
+ ____exports[____exportKey] = ____exportValue
40
+ end
41
+ end
42
+ end
43
+ do
44
+ local ____export = require("utils.math")
45
+ for ____exportKey, ____exportValue in pairs(____export) do
46
+ if ____exportKey ~= "default" then
47
+ ____exports[____exportKey] = ____exportValue
48
+ end
49
+ end
50
+ end
51
+ do
52
+ local ____export = require("utils.minimapIcons")
53
+ for ____exportKey, ____exportValue in pairs(____export) do
54
+ if ____exportKey ~= "default" then
55
+ ____exports[____exportKey] = ____exportValue
56
+ end
57
+ end
58
+ end
59
+ do
60
+ local ____export = require("utils.misc")
61
+ for ____exportKey, ____exportValue in pairs(____export) do
62
+ if ____exportKey ~= "default" then
63
+ ____exports[____exportKey] = ____exportValue
64
+ end
65
+ end
66
+ end
67
+ do
68
+ local ____export = require("utils.physics")
69
+ for ____exportKey, ____exportValue in pairs(____export) do
70
+ if ____exportKey ~= "default" then
71
+ ____exports[____exportKey] = ____exportValue
72
+ end
73
+ end
74
+ end
75
+ do
76
+ local ____export = require("utils.players")
77
+ for ____exportKey, ____exportValue in pairs(____export) do
78
+ if ____exportKey ~= "default" then
79
+ ____exports[____exportKey] = ____exportValue
80
+ end
81
+ end
82
+ end
83
+ do
84
+ local ____export = require("utils.point")
85
+ for ____exportKey, ____exportValue in pairs(____export) do
86
+ if ____exportKey ~= "default" then
87
+ ____exports[____exportKey] = ____exportValue
88
+ end
89
+ end
90
+ end
91
+ do
92
+ local ____export = require("utils.quests")
93
+ for ____exportKey, ____exportValue in pairs(____export) do
94
+ if ____exportKey ~= "default" then
95
+ ____exports[____exportKey] = ____exportValue
96
+ end
97
+ end
98
+ end
99
+ do
100
+ local ____export = require("utils.textTag")
101
+ for ____exportKey, ____exportValue in pairs(____export) do
102
+ if ____exportKey ~= "default" then
103
+ ____exports[____exportKey] = ____exportValue
104
+ end
105
+ end
106
+ end
107
+ do
108
+ local ____export = require("utils.timer")
109
+ for ____exportKey, ____exportValue in pairs(____export) do
110
+ if ____exportKey ~= "default" then
111
+ ____exports[____exportKey] = ____exportValue
112
+ end
113
+ end
114
+ end
115
+ do
116
+ local ____export = require("utils.units")
117
+ for ____exportKey, ____exportValue in pairs(____export) do
118
+ if ____exportKey ~= "default" then
119
+ ____exports[____exportKey] = ____exportValue
120
+ end
121
+ end
122
+ end
123
+ return ____exports
124
+
125
+ --# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7dUJBQWM7Ozs7Ozs7O3VCQUNBOzs7Ozs7Ozt1QkFDQTs7Ozs7Ozs7dUJBQ0E7Ozs7Ozs7O3VCQUNBOzs7Ozs7Ozt1QkFDQTs7Ozs7Ozs7dUJBQ0E7Ozs7Ozs7O3VCQUNBOzs7Ozs7Ozt1QkFDQTs7Ozs7Ozs7dUJBQ0E7Ozs7Ozs7O3VCQUNBOzs7Ozs7Ozt1QkFDQTs7Ozs7Ozs7dUJBQ0E7Ozs7Ozs7O3VCQUNBOzs7Ozs7Ozt1QkFDQSIsImZpbGUiOiJpbmRleC5sdWEiLCJzb3VyY2VSb290IjoiIn0=
@@ -0,0 +1,173 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__StringIncludes = ____lualib.__TS__StringIncludes
3
+ local Map = ____lualib.Map
4
+ local __TS__Iterator = ____lualib.__TS__Iterator
5
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
6
+ local __TS__ArrayFindIndex = ____lualib.__TS__ArrayFindIndex
7
+ local __TS__ArrayFind = ____lualib.__TS__ArrayFind
8
+ local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
9
+ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
10
+ local __TS__New = ____lualib.__TS__New
11
+ local ____exports = {}
12
+ local checkItemRecipeRequirements, itemRecipesMap
13
+ local ____w3ts = require("lua_modules.w3ts.index")
14
+ local Effect = ____w3ts.Effect
15
+ local Item = ____w3ts.Item
16
+ local Trigger = ____w3ts.Trigger
17
+ local Unit = ____w3ts.Unit
18
+ local ____misc = require("utils.misc")
19
+ local notifyPlayer = ____misc.notifyPlayer
20
+ local useTempEffect = ____misc.useTempEffect
21
+ function checkItemRecipeRequirements(self, unit, recipeItem)
22
+ if __TS__StringIncludes(
23
+ string.lower(recipeItem.name),
24
+ "recipe"
25
+ ) then
26
+ local requiredItems = nil
27
+ local itemToCreateId = nil
28
+ for ____, ____value in __TS__Iterator(itemRecipesMap:entries()) do
29
+ local key = ____value[1]
30
+ local value = ____value[2]
31
+ if key.recipeId == recipeItem.typeId then
32
+ requiredItems = value
33
+ itemToCreateId = key.itemId
34
+ end
35
+ end
36
+ if not requiredItems then
37
+ print("Missing required items data for the recipe ", recipeItem.name)
38
+ return
39
+ end
40
+ --- unique list of item types and their quantity and charges that we found on the unit
41
+ local matchingItems = {}
42
+ do
43
+ local x = 0
44
+ while x < 6 do
45
+ local currItem = unit and unit:getItemInSlot(x)
46
+ if currItem and __TS__ArraySome(
47
+ requiredItems,
48
+ function(____, req) return req.itemTypeId == currItem.typeId end
49
+ ) then
50
+ local alreadyStoredItemIndex = __TS__ArrayFindIndex(
51
+ matchingItems,
52
+ function(____, itemReq) return itemReq.itemTypeId == currItem.typeId end
53
+ )
54
+ if alreadyStoredItemIndex and matchingItems[alreadyStoredItemIndex + 1] then
55
+ local ____matchingItems_index_12, ____quantity_13 = matchingItems[alreadyStoredItemIndex + 1], "quantity"
56
+ ____matchingItems_index_12[____quantity_13] = ____matchingItems_index_12[____quantity_13] + 1
57
+ else
58
+ matchingItems[#matchingItems + 1] = {itemTypeId = currItem.typeId, quantity = 1, charges = 0}
59
+ end
60
+ end
61
+ x = x + 1
62
+ end
63
+ end
64
+ local satisfiesRecipe = __TS__ArrayEvery(
65
+ requiredItems,
66
+ function(____, reqItemData)
67
+ local ____opt_14 = matchingItems
68
+ local matching = ____opt_14 and __TS__ArrayFind(
69
+ matchingItems,
70
+ function(____, matchingItemData) return matchingItemData.itemTypeId == reqItemData.itemTypeId end
71
+ )
72
+ if matching then
73
+ return matching.quantity >= reqItemData.quantity
74
+ end
75
+ return false
76
+ end
77
+ ) and #matchingItems > 0
78
+ if not itemToCreateId then
79
+ print("Missing the item type id of the item to create for this recipe: ", recipeItem.name)
80
+ end
81
+ if satisfiesRecipe and itemToCreateId then
82
+ __TS__ArrayForEach(
83
+ requiredItems,
84
+ function(____, req)
85
+ do
86
+ local x = 0
87
+ while x < req.quantity do
88
+ do
89
+ local x = 0
90
+ while x < 6 do
91
+ local currItem = unit and unit:getItemInSlot(x)
92
+ if (currItem and currItem.typeId) == req.itemTypeId then
93
+ if currItem ~= nil then
94
+ currItem:destroy()
95
+ end
96
+ break
97
+ end
98
+ x = x + 1
99
+ end
100
+ end
101
+ x = x + 1
102
+ end
103
+ end
104
+ end
105
+ )
106
+ recipeItem:destroy()
107
+ unit:addItemById(itemToCreateId)
108
+ useTempEffect(
109
+ nil,
110
+ Effect:create("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl", unit.x, unit.y)
111
+ )
112
+ local clap = Effect:create("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", unit.x, unit.y)
113
+ if clap ~= nil then
114
+ clap:setScaleMatrix(0.5, 0.5, 0.5)
115
+ end
116
+ useTempEffect(nil, clap)
117
+ end
118
+ if not satisfiesRecipe then
119
+ notifyPlayer(nil, ("Missing recipe requirements for: " .. recipeItem.name) .. ".")
120
+ end
121
+ end
122
+ end
123
+ --- Checks if the unit has an item in their item slots
124
+ --
125
+ -- @param u
126
+ -- @param itemTypeId
127
+ -- @returns
128
+ function ____exports.unitHasItem(self, u, itemTypeId)
129
+ do
130
+ local x = 0
131
+ while x < 6 do
132
+ local ____opt_0 = u:getItemInSlot(x)
133
+ if (____opt_0 and ____opt_0.typeId) == itemTypeId then
134
+ return true
135
+ end
136
+ x = x + 1
137
+ end
138
+ end
139
+ return false
140
+ end
141
+ function ____exports.trig_itemRecipeSystem(self)
142
+ local t = Trigger:create()
143
+ t:registerAnyUnitEvent(EVENT_PLAYER_UNIT_PICKUP_ITEM)
144
+ t:addAction(function()
145
+ local recipeItem = Item:fromEvent()
146
+ local unit = Unit:fromHandle(GetTriggerUnit())
147
+ if not unit or not recipeItem then
148
+ return
149
+ end
150
+ do
151
+ local x = 0
152
+ while x < 6 do
153
+ local currItem = unit and unit:getItemInSlot(x)
154
+ local ____opt_4 = currItem
155
+ if ____opt_4 ~= nil then
156
+ local ____opt_5 = currItem
157
+ ____opt_4 = __TS__StringIncludes(
158
+ ____opt_5 and string.lower(currItem and currItem.name),
159
+ "recipe"
160
+ )
161
+ end
162
+ if ____opt_4 then
163
+ checkItemRecipeRequirements(nil, unit, currItem)
164
+ end
165
+ x = x + 1
166
+ end
167
+ end
168
+ end)
169
+ end
170
+ itemRecipesMap = __TS__New(Map, {})
171
+ return ____exports
172
+
173
+ --# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9pdGVtLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O01BNENTLDZCQXNHSDtBQWxKTixpQkFBNEM7QUFBbkM7QUFBUTtBQUFNO0FBQVM7QUFDaEMsaUJBQTRDO0FBQW5DO0FBQWM7QUEyQ3ZCLFNBQVMsa0NBQTRCLE1BQVk7T0FDekM7UUFBQTtRQUF1Qzs7QUFDbkMsOEJBQWdEO0FBQ2hELCtCQUFnQztBQUVwQywrQkFBMkIsOEJBQWU7a0JBQTlCO2tCQUFLO2VBQ1QsZ0JBQWlCO0FBQ2pCLGdDQUFnQjtBQUNoQixpQ0FBaUI7OztlQUlwQjtZQUNELE1BQU0sK0NBQStDO0FBQ3JEOzs7QUFNRSw4QkFBeUM7O0FBR3RDLHNCQUFJO2tCQUFHLElBQUk7QUFDVixpQ0FBVyxjQUFNLGNBQWM7bUJBR2pDLGFBQVk7b0JBQUE7b0JBQW1CLGVBQUMsS0FBUSx5QkFBbUIsZUFBNUI7O0FBQ3pCLG1EQUF5Qjt3QkFBQTt3QkFBd0IsZUFBQyxTQUFZLDZCQUF1QixlQUFwQzs7dUJBR25ELDJCQUEwQixjQUFjOzhCQUN4Qyw0REFBYzt3QkFBZDs7QUFJQSw0REFBbUIsQ0FBRSxhQUFZLGlCQUFpQixXQUFVLEdBQUcsVUFBUzs7O0FBYjdEOzs7QUFtQmpCLGdDQUNGO1lBQUE7WUFBb0IsZUFBQzttQ0FDQTtBQUFYLGlDQUFXO29CQUFBO29CQUFvQixlQUFDLGtCQUFx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aEI7QUE4SE0saUJBQWlCLFVBQUksS0FBeUMiLCJmaWxlIjoiaXRlbS5sdWEiLCJzb3VyY2VSb290IjoiIn0=
@@ -0,0 +1,17 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ ---
4
+ -- @deprecated
5
+ -- @param a
6
+ -- @param b
7
+ -- @returns
8
+ function ____exports.distanceBetweenCoords(self, a, b)
9
+ local deltaX = a.x - b.x
10
+ local deltaY = a.y - b.y
11
+ local squaredDist = deltaX ^ 2 + deltaY ^ 2
12
+ local dist = math.sqrt(squaredDist)
13
+ return dist
14
+ end
15
+ return ____exports
16
+
17
+ --# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9tYXRoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFNQSxpREFBc0MsR0FBNkI7QUFDekQsbUJBQVMsTUFBTTtBQUNmLG1CQUFTLE1BQU07QUFDZix3QkFBYyxTQUFpQixJQUFLLFNBQWlCO0FBQ3JELGlCQUFPLFVBQVU7QUFFdkIsV0FBTztBQU5YIiwiZmlsZSI6Im1hdGgubHVhIiwic291cmNlUm9vdCI6IiJ9
@@ -0,0 +1,28 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ ____exports.MinimapIconPath = MinimapIconPath or ({})
6
+ ____exports.MinimapIconPath.controlPoint = "UI\\Minimap\\MiniMap-ControlPoint.mdl"
7
+ ____exports.MinimapIconPath.questGiver = "UI\\Minimap\\MiniMap-QuestGiver.mdl"
8
+ ____exports.MinimapIconPath.questObjectiveBonus = "UI\\Minimap\\Minimap-QuestObjectiveBonus.mdl"
9
+ ____exports.MinimapIconPath.questObjectivePrimary = "UI\\Minimap\\Minimap-QuestObjectivePrimary.mdl"
10
+ ____exports.MinimapIconPath.questTurnIn = "UI\\Minimap\\Minimap-QuestTurnIn.mdl"
11
+ ____exports.MinimapIconPath.hero = "UI\\Minimap\\MiniMap-Hero.mdl"
12
+ ____exports.MinimapIconPath.item = "UI\\Minimap\\MiniMap-Item.mdl"
13
+ ____exports.MinimapIconPath.neutralBuilding = "UI\\Minimap\\MiniMap-NeutralBuilding.mdl"
14
+ ____exports.MinimapIconPath.ping = "UI\\Minimap\\Minimap-Ping.mdl"
15
+ ____exports.minimapIconPathsSet = __TS__New(Set, {
16
+ "UI\\Minimap\\MiniMap-ControlPoint.mdl",
17
+ "UI\\Minimap\\MiniMap-Hero.mdl",
18
+ "UI\\Minimap\\MiniMap-Item.mdl",
19
+ "UI\\Minimap\\MiniMap-NeutralBuilding.mdl",
20
+ "UI\\Minimap\\MiniMap-QuestGiver.mdl",
21
+ "UI\\Minimap\\Minimap-Ping.mdl",
22
+ "UI\\Minimap\\Minimap-QuestObjectiveBonus.mdl",
23
+ "UI\\Minimap\\Minimap-QuestObjectivePrimary.mdl",
24
+ "UI\\Minimap\\Minimap-QuestTurnIn.mdl"
25
+ })
26
+ return ____exports
27
+
28
+ --# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9taW5pbWFwSWNvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQVdBO0FBQ0k7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBR1Msa0NBQXNCLFVBQUksS0FBbUI7SUFDdEQ7SUFDQTtJQUNBO0lBQ0E7SUFDQTtJQUNBO0lBQ0E7SUFDQTtJQUNBIiwiZmlsZSI6Im1pbmltYXBJY29ucy5sdWEiLCJzb3VyY2VSb290IjoiIn0=