warscript 0.0.1-dev.83957b1 → 0.0.1-dev.83ffb73
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/core/types/timer.d.ts +2 -1
- package/core/types/timer.lua +7 -2
- package/decl/native.d.ts +4 -2
- package/engine/behavior.d.ts +2 -0
- package/engine/behavior.lua +53 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +2 -1
- package/engine/behaviour/ability.lua +7 -16
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +12 -1
- package/engine/behaviour/unit.lua +56 -7
- package/engine/buff.d.ts +2 -1
- package/engine/buff.lua +9 -3
- package/engine/internal/ability.lua +8 -2
- package/engine/internal/item/ability.lua +51 -1
- package/engine/internal/unit/ability.d.ts +30 -0
- package/engine/internal/unit/ability.lua +48 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit.d.ts +3 -3
- package/engine/internal/unit.lua +70 -57
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/entry/ability-type.lua +1 -3
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +2 -0
- package/engine/object-field.lua +76 -69
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +175 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +2 -2
- package/utility/functions.d.ts +5 -0
- package/utility/functions.lua +5 -0
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
- package/core/types/order.d.ts +0 -26
- package/core/types/order.lua +0 -65
package/engine/text-tag.lua
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
3
6
|
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
|
|
4
7
|
local ____exports = {}
|
|
5
8
|
local ____color = require("core.types.color")
|
|
6
9
|
local Color = ____color.Color
|
|
10
|
+
local ____timer = require("core.types.timer")
|
|
11
|
+
local Timer = ____timer.Timer
|
|
12
|
+
local ____destroyable = require("destroyable")
|
|
13
|
+
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
7
14
|
local createTextTag = CreateTextTag
|
|
8
15
|
local destroyTextTag = DestroyTextTag
|
|
9
16
|
local setTextTagText = SetTextTagText
|
|
@@ -18,16 +25,7 @@ local setTextTagAge = SetTextTagAge
|
|
|
18
25
|
local setTextTagLifespan = SetTextTagLifespan
|
|
19
26
|
local setTextTagFadepoint = SetTextTagFadepoint
|
|
20
27
|
local DEFAULT_FONT_SIZE = 0.024
|
|
21
|
-
|
|
22
|
-
local TextTag = ____exports.TextTag
|
|
23
|
-
TextTag.name = "TextTag"
|
|
24
|
-
function TextTag.prototype.____constructor(self, handle)
|
|
25
|
-
self.handle = handle
|
|
26
|
-
end
|
|
27
|
-
function TextTag.flash(self, configuration, text, x, y, z)
|
|
28
|
-
local textTag = createTextTag()
|
|
29
|
-
setTextTagText(textTag, text, DEFAULT_FONT_SIZE)
|
|
30
|
-
setTextTagPos(textTag, x + configuration.offsetX, y + configuration.offsetY, (z or 0) + configuration.offsetZ)
|
|
28
|
+
local function applyConfiguration(textTag, configuration)
|
|
31
29
|
setTextTagFadepoint(textTag, configuration.fadepoint)
|
|
32
30
|
setTextTagLifespan(textTag, configuration.lifespan)
|
|
33
31
|
local color = configuration.color
|
|
@@ -42,6 +40,168 @@ function TextTag.flash(self, configuration, text, x, y, z)
|
|
|
42
40
|
setTextTagPermanent(textTag, false)
|
|
43
41
|
setTextTagVisibility(textTag, true)
|
|
44
42
|
end
|
|
43
|
+
local unitTextTags = setmetatable({}, {__mode = "k"})
|
|
44
|
+
____exports.TextTag = __TS__Class()
|
|
45
|
+
local TextTag = ____exports.TextTag
|
|
46
|
+
TextTag.name = "TextTag"
|
|
47
|
+
__TS__ClassExtends(TextTag, AbstractDestroyable)
|
|
48
|
+
function TextTag.prototype.____constructor(self, handle)
|
|
49
|
+
AbstractDestroyable.prototype.____constructor(self)
|
|
50
|
+
self[101] = handle
|
|
51
|
+
end
|
|
52
|
+
function TextTag.prototype.onDestroy(self)
|
|
53
|
+
destroyTextTag(self[101])
|
|
54
|
+
unitTextTags[self] = nil
|
|
55
|
+
return AbstractDestroyable.prototype.onDestroy(self)
|
|
56
|
+
end
|
|
57
|
+
function TextTag.flash(self, configuration, text, x, y, z)
|
|
58
|
+
local textTag = createTextTag()
|
|
59
|
+
setTextTagText(textTag, text, DEFAULT_FONT_SIZE)
|
|
60
|
+
setTextTagPos(textTag, x + configuration.offsetX, y + configuration.offsetY, (z or 0) + configuration.offsetZ)
|
|
61
|
+
applyConfiguration(textTag, configuration)
|
|
62
|
+
end
|
|
63
|
+
function TextTag.create(self, configuration, text, unit)
|
|
64
|
+
local handle = createTextTag()
|
|
65
|
+
setTextTagText(handle, text, DEFAULT_FONT_SIZE)
|
|
66
|
+
setTextTagPosUnit(handle, unit.handle, configuration.offsetZ)
|
|
67
|
+
applyConfiguration(handle, configuration)
|
|
68
|
+
setTextTagPermanent(handle, true)
|
|
69
|
+
local textTag = __TS__New(____exports.TextTag, handle)
|
|
70
|
+
textTag[100] = unit
|
|
71
|
+
textTag[102] = configuration
|
|
72
|
+
unitTextTags[textTag] = true
|
|
73
|
+
return textTag
|
|
74
|
+
end
|
|
75
|
+
__TS__SetDescriptor(
|
|
76
|
+
TextTag.prototype,
|
|
77
|
+
"text",
|
|
78
|
+
{
|
|
79
|
+
get = function(self)
|
|
80
|
+
return self[103] or ""
|
|
81
|
+
end,
|
|
82
|
+
set = function(self, text)
|
|
83
|
+
setTextTagText(self[101], text, self[104] or DEFAULT_FONT_SIZE)
|
|
84
|
+
self[103] = text
|
|
85
|
+
end
|
|
86
|
+
},
|
|
87
|
+
true
|
|
88
|
+
)
|
|
89
|
+
__TS__SetDescriptor(
|
|
90
|
+
TextTag.prototype,
|
|
91
|
+
"fontSize",
|
|
92
|
+
{
|
|
93
|
+
get = function(self)
|
|
94
|
+
return self[104] or DEFAULT_FONT_SIZE
|
|
95
|
+
end,
|
|
96
|
+
set = function(self, fontSize)
|
|
97
|
+
setTextTagText(self[101], self[103] or "", DEFAULT_FONT_SIZE)
|
|
98
|
+
self[104] = fontSize
|
|
99
|
+
end
|
|
100
|
+
},
|
|
101
|
+
true
|
|
102
|
+
)
|
|
103
|
+
__TS__SetDescriptor(
|
|
104
|
+
TextTag.prototype,
|
|
105
|
+
"color",
|
|
106
|
+
{
|
|
107
|
+
get = function(self)
|
|
108
|
+
return self[105] or Color.white
|
|
109
|
+
end,
|
|
110
|
+
set = function(self, color)
|
|
111
|
+
setTextTagColor(
|
|
112
|
+
self[101],
|
|
113
|
+
color.r,
|
|
114
|
+
color.g,
|
|
115
|
+
color.b,
|
|
116
|
+
color.a
|
|
117
|
+
)
|
|
118
|
+
self[105] = color
|
|
119
|
+
end
|
|
120
|
+
},
|
|
121
|
+
true
|
|
122
|
+
)
|
|
123
|
+
__TS__SetDescriptor(
|
|
124
|
+
TextTag.prototype,
|
|
125
|
+
"unit",
|
|
126
|
+
{
|
|
127
|
+
get = function(self)
|
|
128
|
+
return self[100]
|
|
129
|
+
end,
|
|
130
|
+
set = function(self, unit)
|
|
131
|
+
if unit ~= nil then
|
|
132
|
+
setTextTagPosUnit(self[101], unit.handle, 0)
|
|
133
|
+
self[106] = nil
|
|
134
|
+
self[107] = nil
|
|
135
|
+
unitTextTags[self] = true
|
|
136
|
+
elseif self[100] ~= nil then
|
|
137
|
+
local unit = self[100]
|
|
138
|
+
local x = unit.x
|
|
139
|
+
local y = unit.y
|
|
140
|
+
setTextTagPos(self[101], x, y, 0)
|
|
141
|
+
self[106] = x
|
|
142
|
+
self[107] = y
|
|
143
|
+
unitTextTags[self] = nil
|
|
144
|
+
end
|
|
145
|
+
self[100] = unit
|
|
146
|
+
end
|
|
147
|
+
},
|
|
148
|
+
true
|
|
149
|
+
)
|
|
150
|
+
__TS__SetDescriptor(
|
|
151
|
+
TextTag.prototype,
|
|
152
|
+
"x",
|
|
153
|
+
{
|
|
154
|
+
get = function(self)
|
|
155
|
+
local ____self__106_2 = self[106]
|
|
156
|
+
if ____self__106_2 == nil then
|
|
157
|
+
local ____opt_0 = self[100]
|
|
158
|
+
____self__106_2 = ____opt_0 and ____opt_0.x
|
|
159
|
+
end
|
|
160
|
+
return ____self__106_2 or 0
|
|
161
|
+
end,
|
|
162
|
+
set = function(self, x)
|
|
163
|
+
local ____self__101_6 = self[101]
|
|
164
|
+
local ____x_7 = x
|
|
165
|
+
local ____self__107_5 = self[107]
|
|
166
|
+
if ____self__107_5 == nil then
|
|
167
|
+
local ____opt_3 = self[100]
|
|
168
|
+
____self__107_5 = ____opt_3 and ____opt_3.y
|
|
169
|
+
end
|
|
170
|
+
setTextTagPos(____self__101_6, ____x_7, ____self__107_5 or 0, 0)
|
|
171
|
+
self[106] = x
|
|
172
|
+
self[100] = nil
|
|
173
|
+
unitTextTags[self] = nil
|
|
174
|
+
end
|
|
175
|
+
},
|
|
176
|
+
true
|
|
177
|
+
)
|
|
178
|
+
__TS__SetDescriptor(
|
|
179
|
+
TextTag.prototype,
|
|
180
|
+
"y",
|
|
181
|
+
{
|
|
182
|
+
get = function(self)
|
|
183
|
+
local ____self__107_10 = self[107]
|
|
184
|
+
if ____self__107_10 == nil then
|
|
185
|
+
local ____opt_8 = self[100]
|
|
186
|
+
____self__107_10 = ____opt_8 and ____opt_8.y
|
|
187
|
+
end
|
|
188
|
+
return ____self__107_10 or 0
|
|
189
|
+
end,
|
|
190
|
+
set = function(self, y)
|
|
191
|
+
local ____self__101_14 = self[101]
|
|
192
|
+
local ____self__106_13 = self[106]
|
|
193
|
+
if ____self__106_13 == nil then
|
|
194
|
+
local ____opt_11 = self[100]
|
|
195
|
+
____self__106_13 = ____opt_11 and ____opt_11.x
|
|
196
|
+
end
|
|
197
|
+
setTextTagPos(____self__101_14, ____self__106_13 or 0, y, 0)
|
|
198
|
+
self[107] = y
|
|
199
|
+
self[100] = nil
|
|
200
|
+
unitTextTags[self] = nil
|
|
201
|
+
end
|
|
202
|
+
},
|
|
203
|
+
true
|
|
204
|
+
)
|
|
45
205
|
TextTag.BASE = {
|
|
46
206
|
fadepoint = 2,
|
|
47
207
|
lifespan = 3,
|
|
@@ -106,4 +266,9 @@ TextTag.SHADOW_STRIKE = __TS__ObjectAssign(
|
|
|
106
266
|
lifespan = 5
|
|
107
267
|
}
|
|
108
268
|
)
|
|
269
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
270
|
+
for textTag in pairs(unitTextTags) do
|
|
271
|
+
setTextTagPosUnit(textTag[101], textTag[100].handle, textTag[102].offsetZ)
|
|
272
|
+
end
|
|
273
|
+
end)
|
|
109
274
|
return ____exports
|
package/engine/unit.d.ts
CHANGED
package/engine/unit.lua
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "warscript",
|
|
4
|
-
"version": "0.0.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.83ffb73",
|
|
5
5
|
"description": "A typescript library for Warcraft III using Warpack.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"warcraft",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@warscript/language-extensions": "^0.0.1",
|
|
25
25
|
"@warscript/tstl-plugin": "^0.0.4",
|
|
26
26
|
"lua-types": "^2.13.1",
|
|
27
|
-
"warpack": "0.0.1-dev.
|
|
27
|
+
"warpack": "0.0.1-dev.78d2c64"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
package/utility/functions.d.ts
CHANGED
|
@@ -4,3 +4,8 @@ export declare const apply: {
|
|
|
4
4
|
<T, ConsumerParameters extends any[], K extends KeysOfType<T, (...parameters: ConsumerParameters) => void>>(object: T, key: K, ...parameters: ConsumerParameters): T;
|
|
5
5
|
};
|
|
6
6
|
export declare const identity: <T>(value: T) => T;
|
|
7
|
+
export declare const firstArgument: <T>(value: T) => T;
|
|
8
|
+
export declare const secondArgument: <T>(_: unknown, value: T) => T;
|
|
9
|
+
export declare const thirdArgument: <T>(_first: unknown, _second: unknown, value: T) => T;
|
|
10
|
+
export declare const increment: (value: number) => number;
|
|
11
|
+
export declare const or: (lhs: boolean, rhs: boolean) => boolean;
|
package/utility/functions.lua
CHANGED
|
@@ -88,4 +88,9 @@ ____exports.apply = function(object, transform, ...)
|
|
|
88
88
|
return object
|
|
89
89
|
end
|
|
90
90
|
____exports.identity = function(value) return value end
|
|
91
|
+
____exports.firstArgument = ____exports.identity
|
|
92
|
+
____exports.secondArgument = function(_, value) return value end
|
|
93
|
+
____exports.thirdArgument = function(_first, _second, value) return value end
|
|
94
|
+
____exports.increment = function(value) return value + 1 end
|
|
95
|
+
____exports["or"] = function(lhs, rhs) return lhs or rhs end
|
|
91
96
|
return ____exports
|
package/utility/lua-maps.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Flatten, TupleOf } from "./types";
|
|
3
|
+
export declare const emptyLuaMap: <K extends AnyNotNil, V>() => ReadonlyLuaMap<K, V>;
|
|
3
4
|
export declare const mutableLuaMap: <K extends AnyNotNil, V>() => LuaMap<K, V>;
|
|
4
5
|
export declare const mutableWeakLuaMap: <K extends AnyNotNil, V>() => LuaMap<K, V>;
|
|
5
6
|
export declare const luaMapOf: <K extends AnyNotNil, V>(...pairs: Flatten<TupleOf<[K, V], 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40>>) => LuaMap<K, V>;
|
package/utility/lua-maps.lua
CHANGED
|
@@ -2,6 +2,10 @@ local ____exports = {}
|
|
|
2
2
|
local select = _G.select
|
|
3
3
|
local setmetatable = _G.setmetatable
|
|
4
4
|
local weakKeysMetatable = {__mode = "k"}
|
|
5
|
+
local EMPTY_LUA_MAP = {}
|
|
6
|
+
____exports.emptyLuaMap = function()
|
|
7
|
+
return EMPTY_LUA_MAP
|
|
8
|
+
end
|
|
5
9
|
____exports.mutableLuaMap = function()
|
|
6
10
|
return {}
|
|
7
11
|
end
|
package/core/types/order.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** @noSelfInFile */
|
|
2
|
-
import { Unit } from "./unit";
|
|
3
|
-
import { Item } from "./item";
|
|
4
|
-
import { Destructable } from "./destructable";
|
|
5
|
-
export type Order = {
|
|
6
|
-
id: number;
|
|
7
|
-
startX: number;
|
|
8
|
-
startY: number;
|
|
9
|
-
issueTime: number;
|
|
10
|
-
} & ({
|
|
11
|
-
type: "immediate";
|
|
12
|
-
} | {
|
|
13
|
-
type: "point";
|
|
14
|
-
targetX: number;
|
|
15
|
-
targetY: number;
|
|
16
|
-
} | {
|
|
17
|
-
type: "target";
|
|
18
|
-
target: Unit | Item | Destructable;
|
|
19
|
-
});
|
|
20
|
-
declare module "../../engine/internal/unit" {
|
|
21
|
-
interface Unit {
|
|
22
|
-
readonly currentOrder: Order;
|
|
23
|
-
readonly lastOrder: Order;
|
|
24
|
-
issueOrder(order: Order): void;
|
|
25
|
-
}
|
|
26
|
-
}
|
package/core/types/order.lua
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
-
local ____exports = {}
|
|
4
|
-
local ____unit = require("core.types.unit")
|
|
5
|
-
local Unit = ____unit.Unit
|
|
6
|
-
local ____game = require("core.game")
|
|
7
|
-
local elapsedTime = ____game.elapsedTime
|
|
8
|
-
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
9
|
-
local orders = setmetatable({}, {__mode = "k"})
|
|
10
|
-
Unit.onImmediateOrder:addListener(function(unit, orderId)
|
|
11
|
-
orders[unit] = {
|
|
12
|
-
id = orderId,
|
|
13
|
-
startX = unit.x,
|
|
14
|
-
startY = unit.y,
|
|
15
|
-
issueTime = elapsedTime(),
|
|
16
|
-
type = "immediate"
|
|
17
|
-
}
|
|
18
|
-
end)
|
|
19
|
-
Unit.onPointOrder:addListener(function(unit, orderId, x, y)
|
|
20
|
-
orders[unit] = {
|
|
21
|
-
id = orderId,
|
|
22
|
-
startX = unit.x,
|
|
23
|
-
startY = unit.y,
|
|
24
|
-
issueTime = elapsedTime(),
|
|
25
|
-
type = "point",
|
|
26
|
-
targetX = x,
|
|
27
|
-
targetY = y
|
|
28
|
-
}
|
|
29
|
-
end)
|
|
30
|
-
Unit.onTargetOrder:addListener(function(unit, orderId, target)
|
|
31
|
-
orders[unit] = {
|
|
32
|
-
id = orderId,
|
|
33
|
-
startX = unit.x,
|
|
34
|
-
startY = unit.y,
|
|
35
|
-
issueTime = elapsedTime(),
|
|
36
|
-
type = "target",
|
|
37
|
-
target = target
|
|
38
|
-
}
|
|
39
|
-
end)
|
|
40
|
-
__TS__ObjectDefineProperty(
|
|
41
|
-
Unit.prototype,
|
|
42
|
-
"currentOrder",
|
|
43
|
-
{get = function(self)
|
|
44
|
-
local currentOrderId = getUnitCurrentOrder(self.handle)
|
|
45
|
-
local lastOrder = orders[self]
|
|
46
|
-
return lastOrder and (lastOrder.id == currentOrderId or currentOrderId == orderId("patrolAI") and lastOrder.id == orderId("patrol")) and lastOrder or ({id = 0, type = "immediate"})
|
|
47
|
-
end}
|
|
48
|
-
)
|
|
49
|
-
__TS__ObjectDefineProperty(
|
|
50
|
-
Unit.prototype,
|
|
51
|
-
"lastOrder",
|
|
52
|
-
{get = function(self)
|
|
53
|
-
return orders[self] or ({id = 0, type = "immediate"})
|
|
54
|
-
end}
|
|
55
|
-
)
|
|
56
|
-
Unit.prototype.issueOrder = function(self, order)
|
|
57
|
-
if order.type == "immediate" then
|
|
58
|
-
IssueImmediateOrderById(self.handle, order.id)
|
|
59
|
-
elseif order.type == "point" then
|
|
60
|
-
IssuePointOrderById(self.handle, order.id, order.targetX, order.targetY)
|
|
61
|
-
else
|
|
62
|
-
IssueTargetOrderById(self.handle, order.id, order.target.handle)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
return ____exports
|