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.
- package/dist/index.lua +13 -0
- package/dist/lua_modules/w3ts/globals/index.lua +23 -0
- package/dist/lua_modules/w3ts/globals/order.lua +2 -0
- package/dist/lua_modules/w3ts/handles/camera.lua +348 -0
- package/dist/lua_modules/w3ts/handles/destructable.lua +237 -0
- package/dist/lua_modules/w3ts/handles/dialog.lua +161 -0
- package/dist/lua_modules/w3ts/handles/effect.lua +198 -0
- package/dist/lua_modules/w3ts/handles/fogmodifier.lua +76 -0
- package/dist/lua_modules/w3ts/handles/force.lua +105 -0
- package/dist/lua_modules/w3ts/handles/frame.lua +417 -0
- package/dist/lua_modules/w3ts/handles/gamecache.lua +132 -0
- package/dist/lua_modules/w3ts/handles/group.lua +215 -0
- package/dist/lua_modules/w3ts/handles/handle.lua +38 -0
- package/dist/lua_modules/w3ts/handles/image.lua +105 -0
- package/dist/lua_modules/w3ts/handles/index.lua +226 -0
- package/dist/lua_modules/w3ts/handles/item.lua +375 -0
- package/dist/lua_modules/w3ts/handles/leaderboard.lua +211 -0
- package/dist/lua_modules/w3ts/handles/multiboard.lua +193 -0
- package/dist/lua_modules/w3ts/handles/player.lua +311 -0
- package/dist/lua_modules/w3ts/handles/point.lua +80 -0
- package/dist/lua_modules/w3ts/handles/quest.lua +176 -0
- package/dist/lua_modules/w3ts/handles/rect.lua +129 -0
- package/dist/lua_modules/w3ts/handles/region.lua +72 -0
- package/dist/lua_modules/w3ts/handles/sound.lua +174 -0
- package/dist/lua_modules/w3ts/handles/texttag.lua +97 -0
- package/dist/lua_modules/w3ts/handles/timer.lua +83 -0
- package/dist/lua_modules/w3ts/handles/timerdialog.lua +86 -0
- package/dist/lua_modules/w3ts/handles/trigger.lua +265 -0
- package/dist/lua_modules/w3ts/handles/ubersplat.lua +84 -0
- package/dist/lua_modules/w3ts/handles/unit.lua +1330 -0
- package/dist/lua_modules/w3ts/handles/weathereffect.lua +42 -0
- package/dist/lua_modules/w3ts/handles/widget.lua +53 -0
- package/dist/lua_modules/w3ts/hooks/index.lua +52 -0
- package/dist/lua_modules/w3ts/index.lua +36 -0
- package/dist/lua_modules/w3ts/system/base64.lua +108 -0
- package/dist/lua_modules/w3ts/system/binaryreader.lua +74 -0
- package/dist/lua_modules/w3ts/system/binarywriter.lua +88 -0
- package/dist/lua_modules/w3ts/system/file.lua +88 -0
- package/dist/lua_modules/w3ts/system/gametime.lua +27 -0
- package/dist/lua_modules/w3ts/system/host.lua +104 -0
- package/dist/lua_modules/w3ts/system/index.lua +58 -0
- package/dist/lua_modules/w3ts/system/sync.lua +239 -0
- package/dist/lua_modules/w3ts/utils/color.lua +189 -0
- package/dist/lua_modules/w3ts/utils/index.lua +38 -0
- package/dist/lualib_bundle.lua +2733 -0
- package/dist/package.json +41 -0
- package/dist/utils/abilities.lua +107 -0
- package/dist/utils/camera.lua +46 -0
- package/dist/utils/chat-command.lua +30 -0
- package/dist/utils/color.lua +41 -0
- package/dist/utils/index.lua +125 -0
- package/dist/utils/item.lua +173 -0
- package/dist/utils/math.lua +17 -0
- package/dist/utils/minimapIcons.lua +28 -0
- package/dist/utils/misc.lua +143 -0
- package/dist/utils/physics.lua +161 -0
- package/dist/utils/players.lua +234 -0
- package/dist/utils/point.lua +60 -0
- package/dist/utils/quests.lua +47 -0
- package/dist/utils/textTag.lua +110 -0
- package/dist/utils/timer.lua +21 -0
- package/dist/utils/units.lua +102 -0
- package/package.json +4 -6
- package/dist/index.js +0 -18
- package/dist/utils/abilities.js +0 -125
- package/dist/utils/camera.js +0 -37
- package/dist/utils/chat-command.js +0 -22
- package/dist/utils/color.js +0 -141
- package/dist/utils/index.js +0 -32
- package/dist/utils/item.js +0 -124
- package/dist/utils/math.js +0 -17
- package/dist/utils/minimapIcons.js +0 -27
- package/dist/utils/misc.js +0 -175
- package/dist/utils/physics.js +0 -194
- package/dist/utils/players.js +0 -189
- package/dist/utils/point.js +0 -74
- package/dist/utils/quests.js +0 -30
- package/dist/utils/textTag.js +0 -72
- package/dist/utils/timer.js +0 -16
- package/dist/utils/units.js +0 -81
- package/tsconfig.json +0 -37
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Map = ____lualib.Map
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local properColorHexes, playerColors
|
|
7
|
+
local ____w3ts = require("lua_modules.w3ts.index")
|
|
8
|
+
local Timer = ____w3ts.Timer
|
|
9
|
+
function ____exports.tColor(self, text, color, hex, alpha)
|
|
10
|
+
if color then
|
|
11
|
+
return ((("|cff" .. (properColorHexes:get(color) or "FFFFFF")) .. (alpha or "")) .. tostring(text)) .. "|r"
|
|
12
|
+
elseif hex then
|
|
13
|
+
return ((("|cff" .. hex) .. (alpha or "")) .. tostring(text)) .. "|r"
|
|
14
|
+
end
|
|
15
|
+
return tostring(text)
|
|
16
|
+
end
|
|
17
|
+
--- Colorizes the string according to the map player
|
|
18
|
+
function ____exports.ptColor(self, player, text)
|
|
19
|
+
return ____exports.tColor(nil, text, nil, playerColors[player.id + 1])
|
|
20
|
+
end
|
|
21
|
+
properColorHexes = __TS__New(Map, {
|
|
22
|
+
{"goldenrod", "ffcc00"},
|
|
23
|
+
{"green", "00FF00"},
|
|
24
|
+
{"yellow", "FFFF00"},
|
|
25
|
+
{"red", "FF0000"},
|
|
26
|
+
{"magenta", "FF00FF"},
|
|
27
|
+
{"player1-red", "ff0303"},
|
|
28
|
+
{"player2-blue", "0042ff"},
|
|
29
|
+
{"player3-teal", "1ce6b9"},
|
|
30
|
+
{"player4-purple", "540081"},
|
|
31
|
+
{"player5-yellow", "fffc00"},
|
|
32
|
+
{"player6-orange", "fe8a0e"}
|
|
33
|
+
})
|
|
34
|
+
____exports.PlayerColorHex = PlayerColorHex or ({})
|
|
35
|
+
____exports.PlayerColorHex.Red = "ff0303"
|
|
36
|
+
____exports.PlayerColorHex.Blue = "0042ff"
|
|
37
|
+
____exports.PlayerColorHex.Teal = "1be7ba"
|
|
38
|
+
____exports.PlayerColorHex.Purple = "550081"
|
|
39
|
+
____exports.PlayerColorHex.Yellow = "fefc00"
|
|
40
|
+
____exports.PlayerColorHex.Orange = "fe890d"
|
|
41
|
+
____exports.PlayerColorHex.Green = "21bf00"
|
|
42
|
+
____exports.PlayerColorHex.Pink = "e45caf"
|
|
43
|
+
____exports.PlayerColorHex.Gray = "939596"
|
|
44
|
+
____exports.PlayerColorHex.LightBlue = "7ebff1"
|
|
45
|
+
____exports.PlayerColorHex.DarkGreen = "106247"
|
|
46
|
+
____exports.PlayerColorHex.Brown = "4f2b05"
|
|
47
|
+
____exports.PlayerColorHex.Maroon = "9c0000"
|
|
48
|
+
____exports.PlayerColorHex.Navy = "0000c3"
|
|
49
|
+
____exports.PlayerColorHex.Turquoise = "00ebff"
|
|
50
|
+
____exports.PlayerColorHex.Violet = "bd00ff"
|
|
51
|
+
____exports.PlayerColorHex.Wheat = "ecce87"
|
|
52
|
+
____exports.PlayerColorHex.Peach = "f7a58b"
|
|
53
|
+
____exports.PlayerColorHex.Mint = "bfff81"
|
|
54
|
+
____exports.PlayerColorHex.Lavender = "dbb8eb"
|
|
55
|
+
____exports.PlayerColorHex.Coal = "4f5055"
|
|
56
|
+
____exports.PlayerColorHex.Snow = "ecf0ff"
|
|
57
|
+
____exports.PlayerColorHex.Emerald = "00781e"
|
|
58
|
+
____exports.PlayerColorHex.Peanut = "a56f34"
|
|
59
|
+
____exports.PlayerColorHex.Black = "2e2d2e"
|
|
60
|
+
playerColors = {
|
|
61
|
+
"ff0303",
|
|
62
|
+
"0042ff",
|
|
63
|
+
"1be7ba",
|
|
64
|
+
"550081",
|
|
65
|
+
"fefc00",
|
|
66
|
+
"fe890d",
|
|
67
|
+
"21bf00",
|
|
68
|
+
"e45caf",
|
|
69
|
+
"939596",
|
|
70
|
+
"7ebff1",
|
|
71
|
+
"106247",
|
|
72
|
+
"4f2b05",
|
|
73
|
+
"9c0000",
|
|
74
|
+
"0000c3",
|
|
75
|
+
"00ebff",
|
|
76
|
+
"bd00ff",
|
|
77
|
+
"ecce87",
|
|
78
|
+
"f7a58b",
|
|
79
|
+
"bfff81",
|
|
80
|
+
"dbb8eb",
|
|
81
|
+
"4f5055",
|
|
82
|
+
"ecf0ff",
|
|
83
|
+
"00781e",
|
|
84
|
+
"a56f34",
|
|
85
|
+
"2e2d2e"
|
|
86
|
+
}
|
|
87
|
+
--- Standardized format for notifying player of events.
|
|
88
|
+
function ____exports.notifyPlayer(self, msg)
|
|
89
|
+
print((____exports.tColor(nil, "!", "goldenrod") .. " - ") .. msg)
|
|
90
|
+
end
|
|
91
|
+
function ____exports.displayError(self, msg)
|
|
92
|
+
print((("[ " .. ____exports.tColor(nil, "WARNING", "red")) .. " ]: ") .. msg)
|
|
93
|
+
end
|
|
94
|
+
--- Returns degrees or radians?
|
|
95
|
+
function ____exports.getRelativeAngleToUnit(self, unit, relativeUnit)
|
|
96
|
+
local locA = GetUnitLoc(unit.handle)
|
|
97
|
+
local locB = GetUnitLoc(relativeUnit.handle)
|
|
98
|
+
local angle = AngleBetweenPoints(locA, locB)
|
|
99
|
+
RemoveLocation(locA)
|
|
100
|
+
RemoveLocation(locB)
|
|
101
|
+
return angle
|
|
102
|
+
end
|
|
103
|
+
--- Manages state of effects in this context so you don't have to!
|
|
104
|
+
function ____exports.useEffects(self)
|
|
105
|
+
local effects = {}
|
|
106
|
+
return {
|
|
107
|
+
addEffect = function(____, effect)
|
|
108
|
+
if effect then
|
|
109
|
+
effects[#effects + 1] = effect
|
|
110
|
+
end
|
|
111
|
+
end,
|
|
112
|
+
getEffects = function()
|
|
113
|
+
return effects
|
|
114
|
+
end,
|
|
115
|
+
destroyAllEffects = function()
|
|
116
|
+
__TS__ArrayForEach(
|
|
117
|
+
effects,
|
|
118
|
+
function(____, e)
|
|
119
|
+
e:destroy()
|
|
120
|
+
end
|
|
121
|
+
)
|
|
122
|
+
end
|
|
123
|
+
}
|
|
124
|
+
end
|
|
125
|
+
function ____exports.useTempEffect(self, effect, duration)
|
|
126
|
+
if duration == nil then
|
|
127
|
+
duration = 1.5
|
|
128
|
+
end
|
|
129
|
+
if effect then
|
|
130
|
+
local timer = Timer:create()
|
|
131
|
+
timer:start(
|
|
132
|
+
duration,
|
|
133
|
+
false,
|
|
134
|
+
function()
|
|
135
|
+
effect:destroy()
|
|
136
|
+
timer:destroy()
|
|
137
|
+
end
|
|
138
|
+
)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
return ____exports
|
|
142
|
+
|
|
143
|
+
--# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9taXNjLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O01BcUJNLGtCQXFFQTtBQTFGTixpQkFBK0M7QUFBbkI7QUFJNUIsa0NBQXVCLE1BQXVCLE9BQTZCLEtBQXNDO09BQ3pHO0FBQ0Esa0JBQU8sVUFBTyxrQkFBaUIsSUFBSSxVQUFVLGNBQVcsVUFBUyxpQkFBSyxVQUFJO1dBQ25FO0FBQ1Asa0JBQU8sVUFBTyxRQUFNLFVBQVMsaUJBQUssVUFBSTs7QUFHMUMsV0FBTyxTQUFPO0FBUGxCOztBQWFBLG1DQUF3QixRQUFtQjtBQUN2QyxXQUFVLHdCQUFPLE1BQU0sS0FBVyxhQUFhO0FBRG5EO0FBSU0sbUJBQW1CLFVBQUksS0FBMEI7SUFDbkQsQ0FBQyxhQUFhO0lBQ2QsQ0FBQyxTQUFTO0lBQ1YsQ0FBQyxVQUFVO0lBQ1gsQ0FBQyxPQUFPO0lBQ1IsQ0FBQyxXQUFXO0lBQ1osQ0FBQyxlQUFlO0lBQ2hCLENBQUMsZ0JBQWdCO0lBQ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FcEIsTUFBTTtZQUFNO1lBQVU7WUFBTztnQkFDekIsT0FBTztnQkFDUCxNQUFNO1lBRm1COzs7QUFKckMiLCJmaWxlIjoibWlzYy5sdWEiLCJzb3VyY2VSb290IjoiIn0=
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____w3ts = require("lua_modules.w3ts.index")
|
|
4
|
+
local Effect = ____w3ts.Effect
|
|
5
|
+
local Timer = ____w3ts.Timer
|
|
6
|
+
local Unit = ____w3ts.Unit
|
|
7
|
+
local ____globals = require("lua_modules.w3ts.globals.index")
|
|
8
|
+
local Players = ____globals.Players
|
|
9
|
+
---
|
|
10
|
+
-- @param angle degrees
|
|
11
|
+
-- @param unit
|
|
12
|
+
-- @param initialSpeed meters per second
|
|
13
|
+
-- @param affectHeight determines whether or not to change unit height whilst force is applied
|
|
14
|
+
function ____exports.applyForce(self, angle, unit, initialSpeed, config)
|
|
15
|
+
local timer = Timer:create()
|
|
16
|
+
local refreshInterval = 0.01
|
|
17
|
+
local updatesPerSecond = 1 / refreshInterval
|
|
18
|
+
local frictionConstant = 4800
|
|
19
|
+
local currentSpeed = initialSpeed
|
|
20
|
+
local timeElapsed = 0
|
|
21
|
+
local clickMoveOrder = 851971
|
|
22
|
+
local moveOrders = {
|
|
23
|
+
851986,
|
|
24
|
+
851984,
|
|
25
|
+
851990,
|
|
26
|
+
851983,
|
|
27
|
+
clickMoveOrder
|
|
28
|
+
}
|
|
29
|
+
local forceDummyUnit = nil
|
|
30
|
+
local defaultX = 11800
|
|
31
|
+
local defaultY = -5700
|
|
32
|
+
--- Prematurely end the force effect
|
|
33
|
+
local function destroyForceEffect(self, runOnEnd)
|
|
34
|
+
if runOnEnd == nil then
|
|
35
|
+
runOnEnd = false
|
|
36
|
+
end
|
|
37
|
+
if runOnEnd and (config and config.onEnd) then
|
|
38
|
+
config:onEnd()
|
|
39
|
+
end
|
|
40
|
+
ResetUnitAnimation(unit.handle)
|
|
41
|
+
if forceDummyUnit ~= nil then
|
|
42
|
+
forceDummyUnit:destroy()
|
|
43
|
+
end
|
|
44
|
+
timer:destroy()
|
|
45
|
+
end
|
|
46
|
+
--- These are the positions the unit would be if there were no minor disturbances
|
|
47
|
+
local theoreticalX = unit.x
|
|
48
|
+
local theoreticalY = unit.y
|
|
49
|
+
if not forceDummyUnit then
|
|
50
|
+
forceDummyUnit = Unit:create(Players[config.dummyUnitPlayerIndex + 1], config.dummyUnitPlayerIndex, defaultX, defaultY)
|
|
51
|
+
end
|
|
52
|
+
if config and config.animationIndexNumber then
|
|
53
|
+
ResetUnitAnimation(unit.handle)
|
|
54
|
+
SetUnitAnimationByIndex(unit.handle, config.animationIndexNumber)
|
|
55
|
+
end
|
|
56
|
+
timer:start(
|
|
57
|
+
refreshInterval,
|
|
58
|
+
true,
|
|
59
|
+
function()
|
|
60
|
+
if not unit then
|
|
61
|
+
destroyForceEffect(nil)
|
|
62
|
+
return destroyForceEffect
|
|
63
|
+
end
|
|
64
|
+
if forceDummyUnit and (config and config.strictPathing) then
|
|
65
|
+
local isWindWalked = UnitHasBuffBJ(
|
|
66
|
+
forceDummyUnit.handle,
|
|
67
|
+
FourCC("BOwk")
|
|
68
|
+
)
|
|
69
|
+
if not isWindWalked then
|
|
70
|
+
forceDummyUnit:issueImmediateOrder(852129)
|
|
71
|
+
end
|
|
72
|
+
forceDummyUnit.x = unit.x
|
|
73
|
+
forceDummyUnit.y = unit.y
|
|
74
|
+
forceDummyUnit:issueImmediateOrder(851972)
|
|
75
|
+
if math.floor(forceDummyUnit.x) ~= math.floor(unit.x) or math.floor(forceDummyUnit.y) ~= math.floor(unit.y) then
|
|
76
|
+
local e = Effect:create("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe", forceDummyUnit.x, forceDummyUnit.y)
|
|
77
|
+
if e ~= nil then
|
|
78
|
+
e:setScaleMatrix(2, 2, 2)
|
|
79
|
+
end
|
|
80
|
+
destroyForceEffect(nil, true)
|
|
81
|
+
return
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
local xVelocity = currentSpeed / updatesPerSecond * math.cos(Deg2Rad(angle))
|
|
85
|
+
local yVelocity = currentSpeed / updatesPerSecond * math.sin(Deg2Rad(angle))
|
|
86
|
+
if currentSpeed <= 0 then
|
|
87
|
+
destroyForceEffect(nil, true)
|
|
88
|
+
return
|
|
89
|
+
end
|
|
90
|
+
if config and config.onStart and currentSpeed == initialSpeed then
|
|
91
|
+
config:onStart(currentSpeed, timeElapsed)
|
|
92
|
+
end
|
|
93
|
+
if config and config.whileActive then
|
|
94
|
+
config:whileActive(currentSpeed, timeElapsed)
|
|
95
|
+
end
|
|
96
|
+
theoreticalX = theoreticalX + xVelocity
|
|
97
|
+
theoreticalY = theoreticalY + yVelocity
|
|
98
|
+
if config and config.strictPathing then
|
|
99
|
+
unit.x = theoreticalX
|
|
100
|
+
unit.y = theoreticalY
|
|
101
|
+
else
|
|
102
|
+
unit.x = unit.x + xVelocity
|
|
103
|
+
unit.y = unit.y + yVelocity
|
|
104
|
+
end
|
|
105
|
+
timeElapsed = timeElapsed + refreshInterval
|
|
106
|
+
if config and config.sustainedForceDuration and timeElapsed <= config.sustainedForceDuration then
|
|
107
|
+
return
|
|
108
|
+
end
|
|
109
|
+
currentSpeed = currentSpeed - frictionConstant / updatesPerSecond
|
|
110
|
+
end
|
|
111
|
+
)
|
|
112
|
+
return {destroyForceEffect = destroyForceEffect}
|
|
113
|
+
end
|
|
114
|
+
---
|
|
115
|
+
-- @param angle degrees
|
|
116
|
+
-- @param effect
|
|
117
|
+
-- @param initialSpeed meters per second
|
|
118
|
+
-- @param affectHeight determines whether or not to change unit height whilst force is applied
|
|
119
|
+
function ____exports.applyForceForEffect(self, angle, effect, initialSpeed, config)
|
|
120
|
+
local timer = Timer:create()
|
|
121
|
+
local refreshInterval = 0.01
|
|
122
|
+
local updatesPerSecond = 1 / refreshInterval
|
|
123
|
+
local frictionConstant = 1200
|
|
124
|
+
local currentSpeed = initialSpeed
|
|
125
|
+
local timeElapsed = 0
|
|
126
|
+
timer:start(
|
|
127
|
+
refreshInterval,
|
|
128
|
+
true,
|
|
129
|
+
function()
|
|
130
|
+
local xVelocity = currentSpeed / updatesPerSecond * math.cos(Deg2Rad(angle))
|
|
131
|
+
local yVelocity = currentSpeed / updatesPerSecond * math.sin(Deg2Rad(angle))
|
|
132
|
+
if config and config.onEnd and currentSpeed <= 0 then
|
|
133
|
+
config:onEnd(currentSpeed, timeElapsed)
|
|
134
|
+
end
|
|
135
|
+
if currentSpeed <= 0 then
|
|
136
|
+
timer:destroy()
|
|
137
|
+
return
|
|
138
|
+
end
|
|
139
|
+
if config and config.onStart and currentSpeed == initialSpeed then
|
|
140
|
+
config:onStart(currentSpeed, timeElapsed)
|
|
141
|
+
end
|
|
142
|
+
if config and config.whileActive then
|
|
143
|
+
config:whileActive(currentSpeed, timeElapsed)
|
|
144
|
+
end
|
|
145
|
+
effect.x = effect.x + xVelocity
|
|
146
|
+
effect.y = effect.y + yVelocity
|
|
147
|
+
timeElapsed = timeElapsed + refreshInterval
|
|
148
|
+
if config and config.sustainedForceDuration and timeElapsed <= config.sustainedForceDuration then
|
|
149
|
+
return
|
|
150
|
+
end
|
|
151
|
+
currentSpeed = currentSpeed - frictionConstant / updatesPerSecond
|
|
152
|
+
end
|
|
153
|
+
)
|
|
154
|
+
local function destroyForceEffect(self)
|
|
155
|
+
timer:destroy()
|
|
156
|
+
end
|
|
157
|
+
return {destroyForceEffect = destroyForceEffect}
|
|
158
|
+
end
|
|
159
|
+
return ____exports
|
|
160
|
+
|
|
161
|
+
--# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9waHlzaWNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBRUEsaUJBQW9DO0FBQTNCO0FBQVE7QUFBTztBQUN4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aHlzaWNzLmx1YSIsInNvdXJjZVJvb3QiOiIifQ==
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
|
|
3
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
|
+
local __TS__StringReplace = ____lualib.__TS__StringReplace
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____w3ts = require("lua_modules.w3ts.index")
|
|
7
|
+
local Group = ____w3ts.Group
|
|
8
|
+
local MapPlayer = ____w3ts.MapPlayer
|
|
9
|
+
local Trigger = ____w3ts.Trigger
|
|
10
|
+
local ____globals = require("lua_modules.w3ts.globals.index")
|
|
11
|
+
local Players = ____globals.Players
|
|
12
|
+
---
|
|
13
|
+
-- @param unitType Unit Type Id or the Unit Type String "hcas", etc
|
|
14
|
+
function ____exports.forEachUnitOfPlayer(self, player, cb)
|
|
15
|
+
local g = Group:create()
|
|
16
|
+
if g ~= nil then
|
|
17
|
+
g:enumUnitsOfPlayer(
|
|
18
|
+
player,
|
|
19
|
+
function()
|
|
20
|
+
local unit = Group:getFilterUnit()
|
|
21
|
+
if not unit then
|
|
22
|
+
print("Enumerating over a unit that doesn't exist!")
|
|
23
|
+
end
|
|
24
|
+
if unit then
|
|
25
|
+
cb(nil, unit)
|
|
26
|
+
end
|
|
27
|
+
return true
|
|
28
|
+
end
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
if g ~= nil then
|
|
32
|
+
g:destroy()
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
--- Does a callback for every unit of the player that has the ability
|
|
36
|
+
--
|
|
37
|
+
-- @param player
|
|
38
|
+
-- @param abilityId
|
|
39
|
+
-- @param cb
|
|
40
|
+
function ____exports.forEachUnitOfPlayerWithAbility(self, player, abilityId, cb)
|
|
41
|
+
____exports.forEachUnitOfPlayer(
|
|
42
|
+
nil,
|
|
43
|
+
player,
|
|
44
|
+
function(____, u)
|
|
45
|
+
do
|
|
46
|
+
local x = 0
|
|
47
|
+
while x < 12 do
|
|
48
|
+
local currentAbility = u:getAbilityByIndex(x)
|
|
49
|
+
if currentAbility and currentAbility == u:getAbility(abilityId) and u:isAlive() then
|
|
50
|
+
cb(nil, u)
|
|
51
|
+
end
|
|
52
|
+
x = x + 1
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
--- Calls a function for each player playing and is an ally of red.
|
|
59
|
+
--
|
|
60
|
+
-- @warning specific to map
|
|
61
|
+
function ____exports.forEachAlliedPlayer(self, cb)
|
|
62
|
+
__TS__ArrayForEach(
|
|
63
|
+
Players,
|
|
64
|
+
function(____, player, index)
|
|
65
|
+
if player.slotState == PLAYER_SLOT_STATE_PLAYING and player:isPlayerAlly(Players[1]) and player ~= Players[26] and player ~= Players[28] then
|
|
66
|
+
cb(nil, player, index)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
)
|
|
70
|
+
end
|
|
71
|
+
function ____exports.forEachPlayer(self, cb)
|
|
72
|
+
__TS__ArrayForEach(
|
|
73
|
+
Players,
|
|
74
|
+
function(____, p, index)
|
|
75
|
+
cb(nil, p, index)
|
|
76
|
+
end
|
|
77
|
+
)
|
|
78
|
+
end
|
|
79
|
+
--- Executes the callback function for each unit matching the unit type for the player
|
|
80
|
+
--
|
|
81
|
+
-- @param unitType Unit Type Id or the Unit Type String "hcas", etc
|
|
82
|
+
function ____exports.forEachUnitTypeOfPlayer(self, unitType, player, cb)
|
|
83
|
+
if type(unitType) == "string" then
|
|
84
|
+
unitType = FourCC(unitType)
|
|
85
|
+
end
|
|
86
|
+
local g = Group:create()
|
|
87
|
+
if g ~= nil then
|
|
88
|
+
g:enumUnitsOfPlayer(
|
|
89
|
+
player,
|
|
90
|
+
function()
|
|
91
|
+
local unit = Group:getFilterUnit()
|
|
92
|
+
if unit and (unit and unit.typeId) == unitType then
|
|
93
|
+
cb(nil, unit)
|
|
94
|
+
end
|
|
95
|
+
return true
|
|
96
|
+
end
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
if g ~= nil then
|
|
100
|
+
g:destroy()
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
--- Doesn;'t appear to actually work?
|
|
104
|
+
--
|
|
105
|
+
-- @broken
|
|
106
|
+
-- @param unitName
|
|
107
|
+
-- @param unitType
|
|
108
|
+
-- @param fn
|
|
109
|
+
function ____exports.forEachUnitOfType(self, unitName, unitType, fn)
|
|
110
|
+
if type(unitType) == "string" then
|
|
111
|
+
unitType = FourCC(unitType)
|
|
112
|
+
end
|
|
113
|
+
print(unitName)
|
|
114
|
+
local g = Group:create()
|
|
115
|
+
if g ~= nil then
|
|
116
|
+
g:enumUnitsOfType(
|
|
117
|
+
unitName,
|
|
118
|
+
function()
|
|
119
|
+
local unit = Group:getFilterUnit()
|
|
120
|
+
if unit and (unit and unit.typeId) == unitType then
|
|
121
|
+
fn(nil, unit)
|
|
122
|
+
end
|
|
123
|
+
return true
|
|
124
|
+
end
|
|
125
|
+
)
|
|
126
|
+
end
|
|
127
|
+
print((("Total units of name " .. unitName) .. " found: ") .. tostring(g and g.size))
|
|
128
|
+
if g ~= nil then
|
|
129
|
+
g:destroy()
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
--- Executes the callback function for each unit matching the unit type for the player
|
|
133
|
+
--
|
|
134
|
+
-- @param unitType Unit Type Id or the Unit Type String "hcas", etc
|
|
135
|
+
function ____exports.forEachUnitInRectangle(self, rectangle, cb)
|
|
136
|
+
local g = Group:create()
|
|
137
|
+
if g ~= nil then
|
|
138
|
+
g:enumUnitsInRect(
|
|
139
|
+
rectangle,
|
|
140
|
+
function()
|
|
141
|
+
local unit = Group:getFilterUnit()
|
|
142
|
+
if unit then
|
|
143
|
+
cb(nil, unit)
|
|
144
|
+
end
|
|
145
|
+
return true
|
|
146
|
+
end
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
if g ~= nil then
|
|
150
|
+
g:destroy()
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
function ____exports.isPlaying(self, player)
|
|
154
|
+
if __TS__InstanceOf(player, MapPlayer) then
|
|
155
|
+
return player.slotState == PLAYER_SLOT_STATE_PLAYING
|
|
156
|
+
end
|
|
157
|
+
return GetPlayerSlotState(player) == PLAYER_SLOT_STATE_PLAYING
|
|
158
|
+
end
|
|
159
|
+
function ____exports.isUser(self, player)
|
|
160
|
+
if __TS__InstanceOf(player, MapPlayer) then
|
|
161
|
+
return GetPlayerController(player.handle) == MAP_CONTROL_USER
|
|
162
|
+
end
|
|
163
|
+
return GetPlayerController(player) == MAP_CONTROL_USER
|
|
164
|
+
end
|
|
165
|
+
function ____exports.isComputer(self, player)
|
|
166
|
+
if __TS__InstanceOf(player, MapPlayer) then
|
|
167
|
+
return GetPlayerController(player.handle) == MAP_CONTROL_COMPUTER
|
|
168
|
+
end
|
|
169
|
+
return GetPlayerController(player) == MAP_CONTROL_COMPUTER
|
|
170
|
+
end
|
|
171
|
+
function ____exports.isPlayingUser(self, player)
|
|
172
|
+
return ____exports.isUser(nil, player) and ____exports.isPlaying(nil, player)
|
|
173
|
+
end
|
|
174
|
+
function ____exports.adjustPlayerState(self, player, whichState, amount)
|
|
175
|
+
player:setState(
|
|
176
|
+
whichState,
|
|
177
|
+
player:getState(whichState) + amount
|
|
178
|
+
)
|
|
179
|
+
end
|
|
180
|
+
function ____exports.adjustGold(self, player, amount)
|
|
181
|
+
player:setState(
|
|
182
|
+
PLAYER_STATE_RESOURCE_GOLD,
|
|
183
|
+
player:getState(PLAYER_STATE_RESOURCE_GOLD) + amount
|
|
184
|
+
)
|
|
185
|
+
end
|
|
186
|
+
function ____exports.adjustLumber(self, player, amount)
|
|
187
|
+
player:setState(
|
|
188
|
+
PLAYER_STATE_RESOURCE_LUMBER,
|
|
189
|
+
player:getState(PLAYER_STATE_RESOURCE_LUMBER) + amount
|
|
190
|
+
)
|
|
191
|
+
end
|
|
192
|
+
function ____exports.adjustFoodCap(self, player, amount)
|
|
193
|
+
player:setState(
|
|
194
|
+
PLAYER_STATE_RESOURCE_FOOD_CAP,
|
|
195
|
+
player:getState(PLAYER_STATE_RESOURCE_FOOD_CAP) + amount
|
|
196
|
+
)
|
|
197
|
+
end
|
|
198
|
+
function ____exports.adjustFoodUsed(self, player, amount)
|
|
199
|
+
player:setState(
|
|
200
|
+
PLAYER_STATE_RESOURCE_FOOD_USED,
|
|
201
|
+
player:getState(PLAYER_STATE_RESOURCE_FOOD_USED) + amount
|
|
202
|
+
)
|
|
203
|
+
end
|
|
204
|
+
function ____exports.playerHasResources(self, player, data)
|
|
205
|
+
local hasGold = true
|
|
206
|
+
local hasLumber = true
|
|
207
|
+
if data.gold and data.gold ~= 0 then
|
|
208
|
+
hasGold = player:getState(PLAYER_STATE_RESOURCE_GOLD) >= data.gold
|
|
209
|
+
end
|
|
210
|
+
if data.lumber and data.lumber ~= 0 then
|
|
211
|
+
hasLumber = player:getState(PLAYER_STATE_RESOURCE_LUMBER) >= data.lumber
|
|
212
|
+
end
|
|
213
|
+
return hasGold and hasLumber
|
|
214
|
+
end
|
|
215
|
+
function ____exports.setPlayerName(self)
|
|
216
|
+
local t = Trigger:create()
|
|
217
|
+
____exports.forEachPlayer(
|
|
218
|
+
nil,
|
|
219
|
+
function(____, p)
|
|
220
|
+
t:registerPlayerChatEvent(p, "-playername ", false)
|
|
221
|
+
t:addAction(function()
|
|
222
|
+
local str = GetEventPlayerChatString()
|
|
223
|
+
local ____opt_22 = str
|
|
224
|
+
local newName = ____opt_22 and __TS__StringReplace(str, "-playername", "")
|
|
225
|
+
if newName then
|
|
226
|
+
SetPlayerName(p.handle, newName)
|
|
227
|
+
end
|
|
228
|
+
end)
|
|
229
|
+
end
|
|
230
|
+
)
|
|
231
|
+
end
|
|
232
|
+
return ____exports
|
|
233
|
+
|
|
234
|
+
--# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9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BQWM7O0FBRDlEO0FBSUEsc0NBQTJCLFFBQW1CO0lBQzFDLE9BQU87UUFBUztRQUE0QixPQUFPLFNBQVMsOEJBQThCOztBQUQ5RjtBQUlBLHdDQUE2QixRQUFtQjtJQUM1QyxPQUFPO1FBQVM7UUFBOEIsT0FBTyxTQUFTLGdDQUFnQzs7QUFEbEc7QUFJQSx5Q0FBOEIsUUFBbUI7SUFDN0MsT0FBTztRQUFTO1FBQWdDLE9BQU8sU0FBUyxrQ0FBa0M7O0FBRHRHO0FBSUEsMENBQStCLFFBQW1CO0lBQzlDLE9BQU87UUFBUztRQUFpQyxPQUFPLFNBQVMsbUNBQW1DOztBQUR4RztBQUlBLDhDQUFtQyxRQUFtQjtBQUM5QyxvQkFBVTtBQUNWLHNCQUFZO09BRVosY0FBYSxhQUFhO0FBQzFCLGtCQUFVLE9BQU8sU0FBUywrQkFBK0I7O09BR3pELGdCQUFlLGVBQWU7QUFDOUIsb0JBQVksT0FBTyxTQUFTLGlDQUFpQzs7QUFHakUsV0FBTyxZQUFXO0FBWnRCO0FBZUE7QUFDVSxjQUFJLFFBQVE7SUFDbEI7O1FBQWMsZUFBQztZQUNYLEVBQUUsd0JBQXdCLEdBQUcsZ0JBQWdCO1lBRTdDLEVBQUUsVUFBVTtBQUNGLDRCQUFNO21DQUNJO0FBQVYsZ0NBQVUsd0NBQWEsZUFBZTttQkFDeEM7b0JBQ0EsY0FBYyxVQUFVOztZQUpwQjtRQUhGOztBQUZsQiIsImZpbGUiOiJwbGF5ZXJzLmx1YSIsInNvdXJjZVJvb3QiOiIifQ==
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____w3ts = require("lua_modules.w3ts.index")
|
|
4
|
+
local Point = ____w3ts.Point
|
|
5
|
+
local Rectangle = ____w3ts.Rectangle
|
|
6
|
+
local MAP_EDGE_BUFFER_DIST = 300
|
|
7
|
+
function ____exports.createValidPoint(self, maxAttempts, validatorFn)
|
|
8
|
+
local MAX_ATTEMPTS = 65000
|
|
9
|
+
local currentAttempts = 0
|
|
10
|
+
local worldBounds = Rectangle:fromHandle(GetWorldBounds())
|
|
11
|
+
if not worldBounds then
|
|
12
|
+
return
|
|
13
|
+
end
|
|
14
|
+
local maxX, maxY = GetCameraBoundMaxX(), GetCameraBoundMaxY()
|
|
15
|
+
while currentAttempts <= MAX_ATTEMPTS do
|
|
16
|
+
local dirX = math.floor(math.random() * 100) >= 50 and 1 or -1
|
|
17
|
+
local dirY = math.floor(math.random() * 100) >= 50 and 1 or -1
|
|
18
|
+
local randX = dirX * math.ceil(math.random() * maxX) - dirX * MAP_EDGE_BUFFER_DIST
|
|
19
|
+
local randY = dirY * math.ceil(math.random() * maxY) - dirY * MAP_EDGE_BUFFER_DIST
|
|
20
|
+
local p = Point:create(randX, randY)
|
|
21
|
+
local isValidPoint = validatorFn(nil, p)
|
|
22
|
+
if isValidPoint then
|
|
23
|
+
return p
|
|
24
|
+
else
|
|
25
|
+
currentAttempts = currentAttempts + 1
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
function ____exports.getRandomCoordinatesInCircularArea(self, relativeX, relativeY, radius)
|
|
30
|
+
local randomTheta = math.random() * 360
|
|
31
|
+
local randomRadius = math.random() * radius
|
|
32
|
+
local randomX = relativeX + randomRadius * Cos(randomTheta)
|
|
33
|
+
local randomY = relativeY + randomRadius * Sin(randomTheta)
|
|
34
|
+
return {x = randomX, y = randomY}
|
|
35
|
+
end
|
|
36
|
+
function ____exports.getRandomCoordinatesOnCircle(self, relativeX, relativeY, radius)
|
|
37
|
+
local randomTheta = math.random() * 360
|
|
38
|
+
local randomX = relativeX + radius * Cos(randomTheta)
|
|
39
|
+
local randomY = relativeY + radius * Sin(randomTheta)
|
|
40
|
+
return {x = randomX, y = randomY}
|
|
41
|
+
end
|
|
42
|
+
--- Returns degrees or radians?
|
|
43
|
+
function ____exports.getAngleBetweenPoints(self, x1, y1, x2, y2)
|
|
44
|
+
local locA = Location(x1, y1)
|
|
45
|
+
local locB = Location(x2, y2)
|
|
46
|
+
local angle = AngleBetweenPoints(locA, locB)
|
|
47
|
+
RemoveLocation(locA)
|
|
48
|
+
RemoveLocation(locB)
|
|
49
|
+
return angle
|
|
50
|
+
end
|
|
51
|
+
function ____exports.distanceBetweenPoints(self, x1, y1, x2, y2)
|
|
52
|
+
local deltaX = x1 - x2
|
|
53
|
+
local deltaY = y1 - y2
|
|
54
|
+
local squaredDist = deltaX * deltaX + deltaY * deltaY
|
|
55
|
+
local dist = math.sqrt(squaredDist)
|
|
56
|
+
return dist
|
|
57
|
+
end
|
|
58
|
+
return ____exports
|
|
59
|
+
|
|
60
|
+
--# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9wb2ludC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGlCQUFpQztBQUF4QjtBQUFPO0FBQ1YsNkJBQXVCO0FBRTdCLDRDQUFpQyxhQUFxQjtBQUM1Qyx5QkFBZTtBQUNqQiw0QkFBa0I7QUFDaEIsd0JBQWMsVUFBVSxXQUFXO1dBQ3BDO0FBQWE7O0FBQ0csVUFBZCxNQUFNLE9BQVMsc0JBQXNCO1VBRXJDLG1CQUFtQjtBQUNoQixxQkFBTyxXQUFXLGdCQUFnQixRQUFRLE9BQUssTUFBSztBQUNwRCxxQkFBTyxXQUFXLGdCQUFnQixRQUFRLE9BQUssTUFBSztBQUdwRCxzQkFBUSxPQUFPLFVBQVUsZ0JBQWdCLFFBQVEsT0FBTztBQUN4RCxzQkFBUSxPQUFPLFVBQVUsZ0JBQWdCLFFBQVEsT0FBTztBQUV4RCxrQkFBSSxNQUFNLE9BQU8sT0FBTztBQUV4Qiw2QkFBZSxpQkFBWTtXQUU3QjtBQUVBLG1CQUFPOztBQUdQOzs7QUF4Qlo7QUE2QkEsOERBQW1ELFdBQW1CLFdBQW1CO0FBQy9FLHdCQUFjLGdCQUFnQjtBQUM5Qix5QkFBZSxnQkFBZ0I7QUFFL0Isb0JBQVUsWUFBWSxlQUFlLElBQUk7QUFDekMsb0JBQVUsWUFBWSxlQUFlLElBQUk7QUFFL0MsV0FBTyxDQUNILElBQUcsU0FDSCxJQUFHO0FBVFg7QUFhQSx3REFBNkMsV0FBbUIsV0FBbUI7QUFDekUsd0JBQWMsZ0JBQWdCO0FBRTlCLG9CQUFVLFlBQVksU0FBUyxJQUFJO0FBQ25DLG9CQUFVLFlBQVksU0FBUyxJQUFJO0FBRXpDLFdBQU8sQ0FDSCxJQUFHLFNBQ0gsSUFBRztBQVJYOztBQWVBLGlEQUFzQyxJQUFZLElBQVksSUFBWTtBQUNoRSxpQkFBTyxTQUFTLElBQUk7QUFDcEIsaUJBQU8sU0FBUyxJQUFJO0FBRXBCLGtCQUFRLG1CQUFtQixNQUFNO0lBRXZDLGVBQWU7SUFDZixlQUFlO0FBRWYsV0FBTztBQVRYO0FBWUEsaURBQXNDLElBQVksSUFBWSxJQUFZO0FBQ2hFLG1CQUFTLEtBQUs7QUFDZCxtQkFBUyxLQUFLO0FBQ2Qsd0JBQWMsU0FBUyxTQUFTLFNBQVM7QUFFekMsaUJBQU8sVUFBVTtBQUV2QixXQUFPO0FBUFgiLCJmaWxlIjoicG9pbnQubHVhIiwic291cmNlUm9vdCI6IiJ9
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____w3ts = require("lua_modules.w3ts.index")
|
|
4
|
+
local Quest = ____w3ts.Quest
|
|
5
|
+
local Timer = ____w3ts.Timer
|
|
6
|
+
local ____misc = require("utils.misc")
|
|
7
|
+
local tColor = ____misc.tColor
|
|
8
|
+
function ____exports.addQuest(self, title, description, iconPath, required)
|
|
9
|
+
if required == nil then
|
|
10
|
+
required = true
|
|
11
|
+
end
|
|
12
|
+
local q = Quest:create()
|
|
13
|
+
if q then
|
|
14
|
+
q:setTitle(title)
|
|
15
|
+
q.required = required
|
|
16
|
+
q:setDescription(description)
|
|
17
|
+
if iconPath then
|
|
18
|
+
q:setIcon(iconPath)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
function ____exports.setup_quests(self)
|
|
23
|
+
Timer:create():start(
|
|
24
|
+
1,
|
|
25
|
+
false,
|
|
26
|
+
function()
|
|
27
|
+
____exports.addQuest(nil, "Basic Game Info", "\nA roguelite base assault game. \nChoose from a wide variety of units that are trained in various schools of magic and skills.\n Outsmart and counter your opponent..\n ", "ReplaceableTextures\\CommandButtons\\BTNPeasant.blp")
|
|
28
|
+
____exports.addQuest(
|
|
29
|
+
nil,
|
|
30
|
+
"Commands",
|
|
31
|
+
("\n \n" .. tColor(nil, "-cam ####", "goldenrod")) .. ": Sets the camera distance.\n \n-playername xxxx This will change your name.\n ",
|
|
32
|
+
"ReplaceableTextures\\WorldEditUI\\Doodad-Cinematic.blp",
|
|
33
|
+
false
|
|
34
|
+
)
|
|
35
|
+
____exports.addQuest(
|
|
36
|
+
nil,
|
|
37
|
+
"|cffffcc00Evolution Castle Assault v0.01|r",
|
|
38
|
+
"Created by JediMindTrix/NihilismIsDeath",
|
|
39
|
+
"ReplaceableTextures\\CommandButtons\\BTNClayFigurine.blp",
|
|
40
|
+
false
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
return ____exports
|
|
46
|
+
|
|
47
|
+
--# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9xdWVzdHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxpQkFBNkI7QUFBcEI7QUFBTztBQUNoQixpQkFBdUI7QUFBZDtBQTBCVCxvQ0FBeUIsT0FBZSxhQUFxQixVQUFtQjtPQUFBO1FBQUEsV0FBb0I7O0FBQzFGLGNBQUksTUFBTTtPQUNaO1FBQ0EsRUFBRSxTQUFTO0FBQ1gscUJBQWE7UUFDYixFQUFFLGVBQWU7V0FDYjtZQUNBLEVBQUUsUUFBUTs7O0FBUHRCO0FBeEJBO0lBQ0ksTUFBTSxTQUFTO1FBQU07UUFBRztRQUFPO1lBQzNCLDBCQUNJLG1CQUNBLG9MQUVBO1lBSUo7O2dCQUNJO2lCQUNBLHNCQUNJLFlBQU8sYUFBYSxpQkFBWTtnQkFHcEM7Z0JBQ0E7O1lBR0o7O2dCQUFTO2dCQUE4QztnQkFBMkM7Z0JBQTREOztRQW5Cbkk7O0FBRG5DIiwiZmlsZSI6InF1ZXN0cy5sdWEiLCJzb3VyY2VSb290IjoiIn0=
|