warscript 0.0.1-dev.f024cc2 → 0.0.1-dev.f074376
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/attributes.d.ts +1 -0
- package/attributes.lua +9 -0
- package/core/types/frame.lua +14 -9
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +57 -14
- package/core/types/playerCamera.lua +44 -0
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +3 -2
- package/core/types/timer.lua +22 -2
- package/decl/native.d.ts +2 -2
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +12 -1
- package/engine/behavior.lua +199 -65
- package/engine/behaviour/ability/apply-buff.lua +4 -4
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability.d.ts +2 -1
- package/engine/behaviour/ability.lua +2 -1
- package/engine/behaviour/unit/stun-immunity.d.ts +8 -4
- package/engine/behaviour/unit/stun-immunity.lua +12 -3
- package/engine/behaviour/unit.d.ts +15 -5
- package/engine/behaviour/unit.lua +116 -22
- package/engine/buff.d.ts +15 -5
- package/engine/buff.lua +151 -94
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +26 -9
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +63 -49
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +14 -14
- package/engine/internal/unit/ability.lua +72 -45
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +10 -0
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +9 -0
- package/engine/internal/unit-missile-launch.lua +44 -20
- package/engine/internal/unit.d.ts +15 -12
- package/engine/internal/unit.lua +93 -76
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -0
- package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/ability-type.lua +4 -1
- package/engine/object-data/entry/destructible-type.d.ts +27 -1
- package/engine/object-data/entry/destructible-type.lua +155 -0
- package/engine/object-data/entry/unit-type.d.ts +4 -0
- package/engine/object-data/entry/unit-type.lua +76 -32
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +20 -5
- package/engine/object-field/unit.lua +61 -0
- package/engine/object-field.d.ts +9 -3
- package/engine/object-field.lua +237 -114
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/fields/ability.d.ts +2 -2
- package/engine/standard/fields/ability.lua +2 -2
- package/engine/standard/fields/unit.d.ts +4 -1
- package/engine/standard/fields/unit.lua +6 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.lua +3 -2
- package/engine/unit.d.ts +2 -0
- package/engine/unit.lua +2 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +1 -1
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/types.d.ts +3 -0
package/engine/behavior.lua
CHANGED
|
@@ -2,6 +2,7 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
3
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
4
4
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
5
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____destroyable = require("destroyable")
|
|
7
8
|
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
@@ -9,54 +10,79 @@ local ____timer = require("core.types.timer")
|
|
|
9
10
|
local Timer = ____timer.Timer
|
|
10
11
|
local ____functions = require("utility.functions")
|
|
11
12
|
local increment = ____functions.increment
|
|
13
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
14
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
15
|
+
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
16
|
+
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
17
|
+
local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
|
|
18
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
19
|
+
local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
|
|
12
20
|
local safeCall = warpack.safeCall
|
|
13
|
-
local
|
|
14
|
-
local
|
|
21
|
+
local firstBehaviorByObjectByPriority = {[0] = {}, [2] = {}, [1] = {}}
|
|
22
|
+
local lastBehaviorByObjectByPriority = {[0] = {}, [2] = {}, [1] = {}}
|
|
15
23
|
local function invokeBehaviorOnPeriod(behavior, ...)
|
|
16
24
|
behavior.onPeriod(behavior, ...)
|
|
17
25
|
end
|
|
18
26
|
local function reduceBehaviors(behaviorConstructor, object, operation, initial, consumerOrKey, ...)
|
|
19
27
|
local accumulator = initial
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
for priority = 0, 2 do
|
|
29
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
30
|
+
if behavior ~= nil then
|
|
31
|
+
if type(consumerOrKey) == "function" then
|
|
32
|
+
repeat
|
|
33
|
+
do
|
|
34
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
35
|
+
local isSuccessful, result = safeCall(consumerOrKey, behavior, ...)
|
|
36
|
+
if isSuccessful then
|
|
37
|
+
accumulator = operation(accumulator, result)
|
|
38
|
+
end
|
|
29
39
|
end
|
|
40
|
+
behavior = behavior[1]
|
|
30
41
|
end
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
accumulator = operation(accumulator, result)
|
|
42
|
+
until not (behavior ~= nil)
|
|
43
|
+
else
|
|
44
|
+
repeat
|
|
45
|
+
do
|
|
46
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
47
|
+
local isSuccessful, result = safeCall(behavior[consumerOrKey], behavior, ...)
|
|
48
|
+
if isSuccessful then
|
|
49
|
+
accumulator = operation(accumulator, result)
|
|
50
|
+
end
|
|
41
51
|
end
|
|
52
|
+
behavior = behavior[1]
|
|
42
53
|
end
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
until not (behavior ~= nil)
|
|
54
|
+
until not (behavior ~= nil)
|
|
55
|
+
end
|
|
46
56
|
end
|
|
47
57
|
end
|
|
48
58
|
return accumulator
|
|
49
59
|
end
|
|
60
|
+
local behaviorsByGlobalEvent = {}
|
|
61
|
+
local listenerByBehaviorByGlobalEvent = {}
|
|
62
|
+
local globalEventsByBehavior = {}
|
|
63
|
+
local behaviorsByEvent = {}
|
|
64
|
+
local listenerByBehaviorByEvent = {}
|
|
65
|
+
local eventsByBehavior = {}
|
|
66
|
+
local function safeCallBehaviorListener(behavior, behaviors, listenerByBehavior, ...)
|
|
67
|
+
if behaviors[behavior] ~= nil then
|
|
68
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
50
71
|
____exports.Behavior = __TS__Class()
|
|
51
72
|
local Behavior = ____exports.Behavior
|
|
52
73
|
Behavior.name = "Behavior"
|
|
53
74
|
__TS__ClassExtends(Behavior, AbstractDestroyable)
|
|
54
|
-
function Behavior.prototype.____constructor(self, object)
|
|
75
|
+
function Behavior.prototype.____constructor(self, object, priority)
|
|
76
|
+
if priority == nil then
|
|
77
|
+
priority = 1
|
|
78
|
+
end
|
|
55
79
|
AbstractDestroyable.prototype.____constructor(self)
|
|
56
80
|
self.object = object
|
|
81
|
+
self.priority = priority
|
|
82
|
+
local lastBehaviorByObject = lastBehaviorByObjectByPriority[priority]
|
|
57
83
|
local lastBehavior = lastBehaviorByObject[object]
|
|
58
84
|
if lastBehavior == nil then
|
|
59
|
-
|
|
85
|
+
firstBehaviorByObjectByPriority[priority][object] = self
|
|
60
86
|
lastBehaviorByObject[object] = self
|
|
61
87
|
else
|
|
62
88
|
self[0] = lastBehavior
|
|
@@ -69,20 +95,112 @@ function Behavior.prototype.onDestroy(self)
|
|
|
69
95
|
if ____opt_0 ~= nil then
|
|
70
96
|
____opt_0:destroy()
|
|
71
97
|
end
|
|
98
|
+
local globalEvents = globalEventsByBehavior[self]
|
|
99
|
+
if globalEvents ~= nil then
|
|
100
|
+
for event in pairs(globalEvents) do
|
|
101
|
+
local ____opt_2 = behaviorsByGlobalEvent[event]
|
|
102
|
+
if ____opt_2 ~= nil then
|
|
103
|
+
____opt_2:remove(self)
|
|
104
|
+
end
|
|
105
|
+
local ____opt_4 = listenerByBehaviorByGlobalEvent[event]
|
|
106
|
+
if ____opt_4 ~= nil then
|
|
107
|
+
____opt_4[self] = nil
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
globalEventsByBehavior[self] = nil
|
|
111
|
+
end
|
|
112
|
+
local events = eventsByBehavior[self]
|
|
113
|
+
if events ~= nil then
|
|
114
|
+
for event in pairs(events) do
|
|
115
|
+
local ____opt_6 = behaviorsByEvent[event]
|
|
116
|
+
if ____opt_6 ~= nil then
|
|
117
|
+
____opt_6[self] = nil
|
|
118
|
+
end
|
|
119
|
+
local ____opt_8 = listenerByBehaviorByEvent[event]
|
|
120
|
+
if ____opt_8 ~= nil then
|
|
121
|
+
____opt_8[self] = nil
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
eventsByBehavior[self] = nil
|
|
125
|
+
end
|
|
72
126
|
local previousBehavior = self[0]
|
|
73
127
|
local nextBehavior = self[1]
|
|
74
128
|
if previousBehavior ~= nil then
|
|
75
129
|
previousBehavior[1] = nextBehavior
|
|
76
130
|
else
|
|
77
|
-
|
|
131
|
+
firstBehaviorByObjectByPriority[self.priority][self.object] = nextBehavior
|
|
78
132
|
end
|
|
79
133
|
if nextBehavior ~= nil then
|
|
80
134
|
nextBehavior[0] = previousBehavior
|
|
81
135
|
else
|
|
82
|
-
|
|
136
|
+
lastBehaviorByObjectByPriority[self.priority][self.object] = previousBehavior
|
|
83
137
|
end
|
|
84
138
|
return AbstractDestroyable.prototype.onDestroy(self)
|
|
85
139
|
end
|
|
140
|
+
function Behavior.prototype.registerGlobalEvent(self, event, listener)
|
|
141
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByGlobalEvent, event, mutableLuaMap)
|
|
142
|
+
listenerByBehavior[self] = listener
|
|
143
|
+
getOrPut(globalEventsByBehavior, self, mutableLuaSet)[event] = true
|
|
144
|
+
local behaviors = behaviorsByGlobalEvent[event]
|
|
145
|
+
if behaviors == nil then
|
|
146
|
+
event:addListener(function(...)
|
|
147
|
+
local behaviors = behaviorsByGlobalEvent[event]
|
|
148
|
+
if behaviors ~= nil then
|
|
149
|
+
for behavior in pairs(behaviors) do
|
|
150
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end)
|
|
154
|
+
behaviors = __TS__New(LinkedSet)
|
|
155
|
+
behaviorsByGlobalEvent[event] = behaviors
|
|
156
|
+
end
|
|
157
|
+
behaviors:add(self)
|
|
158
|
+
end
|
|
159
|
+
function Behavior.prototype.deregisterGlobalEvent(self, event)
|
|
160
|
+
local behaviors = behaviorsByGlobalEvent[event]
|
|
161
|
+
if behaviors ~= nil and behaviors:remove(self) then
|
|
162
|
+
globalEventsByBehavior[self][event] = nil
|
|
163
|
+
listenerByBehaviorByGlobalEvent[event][self] = nil
|
|
164
|
+
return true
|
|
165
|
+
end
|
|
166
|
+
return false
|
|
167
|
+
end
|
|
168
|
+
function Behavior.prototype.registerEvent(self, event, extractObject, listener)
|
|
169
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
|
|
170
|
+
listenerByBehavior[self] = listener
|
|
171
|
+
getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
|
|
172
|
+
local behaviors = behaviorsByEvent[event]
|
|
173
|
+
if behaviors == nil then
|
|
174
|
+
event:addListener(function(...)
|
|
175
|
+
local behaviors = behaviorsByEvent[event]
|
|
176
|
+
if behaviors ~= nil then
|
|
177
|
+
local object = extractObject(...)
|
|
178
|
+
if object ~= nil then
|
|
179
|
+
____exports.Behavior:forAll(
|
|
180
|
+
object,
|
|
181
|
+
safeCallBehaviorListener,
|
|
182
|
+
behaviors,
|
|
183
|
+
listenerByBehavior,
|
|
184
|
+
...
|
|
185
|
+
)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end)
|
|
189
|
+
behaviors = {}
|
|
190
|
+
behaviorsByEvent[event] = behaviors
|
|
191
|
+
end
|
|
192
|
+
behaviors[self] = true
|
|
193
|
+
end
|
|
194
|
+
function Behavior.prototype.deregisterEvent(self, event)
|
|
195
|
+
local behaviors = behaviorsByEvent[event]
|
|
196
|
+
if behaviors ~= nil and behaviors[self] ~= nil then
|
|
197
|
+
behaviors[self] = nil
|
|
198
|
+
eventsByBehavior[self][event] = nil
|
|
199
|
+
listenerByBehaviorByEvent[event][self] = nil
|
|
200
|
+
return true
|
|
201
|
+
end
|
|
202
|
+
return false
|
|
203
|
+
end
|
|
86
204
|
function Behavior.prototype.onPeriod(self, ...)
|
|
87
205
|
end
|
|
88
206
|
function Behavior.prototype.startPeriodicAction(self, interval, ...)
|
|
@@ -108,78 +226,94 @@ function Behavior.prototype.stopPeriodicAction(self)
|
|
|
108
226
|
end
|
|
109
227
|
function Behavior.count(self, object, limit)
|
|
110
228
|
local behaviorsCount = 0
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
229
|
+
for priority = 0, 2 do
|
|
230
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
231
|
+
while behavior ~= nil and (limit == nil or behaviorsCount < limit) do
|
|
232
|
+
if __TS__InstanceOf(behavior, self) then
|
|
233
|
+
behaviorsCount = behaviorsCount + 1
|
|
234
|
+
end
|
|
235
|
+
behavior = behavior[1]
|
|
115
236
|
end
|
|
116
|
-
behavior = behavior[1]
|
|
117
237
|
end
|
|
118
238
|
return behaviorsCount
|
|
119
239
|
end
|
|
120
240
|
function Behavior.getFirst(self, object, countOrPredicate, ...)
|
|
121
|
-
local behavior = firstBehaviorByObject[object]
|
|
122
241
|
if type(countOrPredicate) ~= "number" then
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
242
|
+
for priority = 0, 2 do
|
|
243
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
244
|
+
while behavior ~= nil do
|
|
245
|
+
if __TS__InstanceOf(behavior, self) and (countOrPredicate == nil or countOrPredicate(behavior, ...)) then
|
|
246
|
+
return behavior
|
|
247
|
+
end
|
|
248
|
+
behavior = behavior[1]
|
|
126
249
|
end
|
|
127
|
-
behavior = behavior[1]
|
|
128
250
|
end
|
|
129
251
|
return nil
|
|
130
252
|
end
|
|
131
253
|
local behaviors = {}
|
|
132
254
|
local behaviorsCount = 0
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
255
|
+
for priority = 0, 2 do
|
|
256
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
257
|
+
while behavior ~= nil and behaviorsCount < countOrPredicate do
|
|
258
|
+
if __TS__InstanceOf(behavior, self) then
|
|
259
|
+
behaviorsCount = behaviorsCount + 1
|
|
260
|
+
behaviors[behaviorsCount] = behavior
|
|
261
|
+
end
|
|
262
|
+
behavior = behavior[1]
|
|
137
263
|
end
|
|
138
|
-
behavior = behavior[1]
|
|
139
264
|
end
|
|
140
265
|
return behaviors
|
|
141
266
|
end
|
|
142
267
|
function Behavior.getLast(self, object)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
268
|
+
for priority = 2, 0, -1 do
|
|
269
|
+
local behavior = lastBehaviorByObjectByPriority[priority][object]
|
|
270
|
+
while behavior ~= nil do
|
|
271
|
+
if __TS__InstanceOf(behavior, self) then
|
|
272
|
+
return behavior
|
|
273
|
+
end
|
|
274
|
+
behavior = behavior[0]
|
|
147
275
|
end
|
|
148
|
-
behavior = behavior[0]
|
|
149
276
|
end
|
|
150
277
|
return nil
|
|
151
278
|
end
|
|
152
279
|
function Behavior.getAll(self, object, predicate, ...)
|
|
153
280
|
local behaviors = {}
|
|
154
281
|
local behaviorsCount = 0
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
282
|
+
for priority = 0, 2 do
|
|
283
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
284
|
+
while behavior ~= nil do
|
|
285
|
+
if __TS__InstanceOf(behavior, self) and (predicate == nil or predicate(behavior, ...)) then
|
|
286
|
+
behaviorsCount = behaviorsCount + 1
|
|
287
|
+
behaviors[behaviorsCount] = behavior
|
|
288
|
+
end
|
|
289
|
+
behavior = behavior[1]
|
|
160
290
|
end
|
|
161
|
-
behavior = behavior[1]
|
|
162
291
|
end
|
|
163
292
|
return behaviors
|
|
164
293
|
end
|
|
165
294
|
function Behavior.forFirst(self, object, count, consumerOrKey, ...)
|
|
166
295
|
local behaviorsCount = 0
|
|
167
|
-
local behavior = firstBehaviorByObject[object]
|
|
168
296
|
if type(consumerOrKey) == "function" then
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
297
|
+
for priority = 0, 2 do
|
|
298
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
299
|
+
while behavior ~= nil and behaviorsCount < count do
|
|
300
|
+
if __TS__InstanceOf(behavior, self) then
|
|
301
|
+
safeCall(consumerOrKey, behavior, ...)
|
|
302
|
+
behaviorsCount = behaviorsCount + 1
|
|
303
|
+
end
|
|
304
|
+
behavior = behavior[1]
|
|
173
305
|
end
|
|
174
|
-
behavior = behavior[1]
|
|
175
306
|
end
|
|
176
307
|
else
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
308
|
+
for priority = 0, 2 do
|
|
309
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
310
|
+
while behavior ~= nil and behaviorsCount < count do
|
|
311
|
+
if __TS__InstanceOf(behavior, self) then
|
|
312
|
+
safeCall(behavior[consumerOrKey], behavior, ...)
|
|
313
|
+
behaviorsCount = behaviorsCount + 1
|
|
314
|
+
end
|
|
315
|
+
behavior = behavior[1]
|
|
181
316
|
end
|
|
182
|
-
behavior = behavior[1]
|
|
183
317
|
end
|
|
184
318
|
end
|
|
185
319
|
return behaviorsCount
|
|
@@ -27,7 +27,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
27
27
|
constructorOrTypeIdOrTypeIds,
|
|
28
28
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
29
29
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
30
|
-
|
|
30
|
+
self,
|
|
31
31
|
resistanceTypeOrPolarityOrParameters
|
|
32
32
|
)
|
|
33
33
|
end
|
|
@@ -39,7 +39,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
39
39
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
40
40
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
41
41
|
resistanceTypeOrPolarityOrParameters,
|
|
42
|
-
|
|
42
|
+
self,
|
|
43
43
|
parametersOrResistanceType
|
|
44
44
|
)
|
|
45
45
|
end
|
|
@@ -50,7 +50,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
50
50
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
51
51
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
52
52
|
resistanceTypeOrPolarityOrParameters,
|
|
53
|
-
|
|
53
|
+
self,
|
|
54
54
|
parametersOrResistanceType
|
|
55
55
|
)
|
|
56
56
|
end
|
|
@@ -62,7 +62,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
62
62
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
63
63
|
resistanceTypeOrPolarityOrParameters,
|
|
64
64
|
parametersOrResistanceType,
|
|
65
|
-
|
|
65
|
+
self,
|
|
66
66
|
parameters
|
|
67
67
|
)
|
|
68
68
|
end
|
|
@@ -14,3 +14,12 @@ export declare class RemoveBuffsSelfAbilityBehavior extends AbilityBehavior {
|
|
|
14
14
|
constructor(ability: Ability, polarity?: AbilityDependentValue<BuffPolarity> | undefined, resistanceType?: AbilityDependentValue<BuffResistanceType> | undefined, includeExpirationTimers?: AbilityDependentValue<boolean> | undefined, includeAuras?: AbilityDependentValue<boolean> | undefined, autoDispel?: AbilityDependentValue<boolean> | undefined);
|
|
15
15
|
onImpact(caster: Unit): void;
|
|
16
16
|
}
|
|
17
|
+
export declare class RemoveBuffsTargetAbilityBehavior extends AbilityBehavior {
|
|
18
|
+
private readonly polarity?;
|
|
19
|
+
private readonly resistanceType?;
|
|
20
|
+
private readonly includeExpirationTimers?;
|
|
21
|
+
private readonly includeAuras?;
|
|
22
|
+
private readonly autoDispel?;
|
|
23
|
+
constructor(ability: Ability, polarity?: AbilityDependentValue<BuffPolarity> | undefined, resistanceType?: AbilityDependentValue<BuffResistanceType> | undefined, includeExpirationTimers?: AbilityDependentValue<boolean> | undefined, includeAuras?: AbilityDependentValue<boolean> | undefined, autoDispel?: AbilityDependentValue<boolean> | undefined);
|
|
24
|
+
onUnitTargetImpact(_: Unit, target: Unit): void;
|
|
25
|
+
}
|
|
@@ -25,4 +25,25 @@ function RemoveBuffsSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
|
25
25
|
self:resolveCurrentAbilityDependentValue(self.autoDispel)
|
|
26
26
|
)
|
|
27
27
|
end
|
|
28
|
+
____exports.RemoveBuffsTargetAbilityBehavior = __TS__Class()
|
|
29
|
+
local RemoveBuffsTargetAbilityBehavior = ____exports.RemoveBuffsTargetAbilityBehavior
|
|
30
|
+
RemoveBuffsTargetAbilityBehavior.name = "RemoveBuffsTargetAbilityBehavior"
|
|
31
|
+
__TS__ClassExtends(RemoveBuffsTargetAbilityBehavior, AbilityBehavior)
|
|
32
|
+
function RemoveBuffsTargetAbilityBehavior.prototype.____constructor(self, ability, polarity, resistanceType, includeExpirationTimers, includeAuras, autoDispel)
|
|
33
|
+
AbilityBehavior.prototype.____constructor(self, ability)
|
|
34
|
+
self.polarity = polarity
|
|
35
|
+
self.resistanceType = resistanceType
|
|
36
|
+
self.includeExpirationTimers = includeExpirationTimers
|
|
37
|
+
self.includeAuras = includeAuras
|
|
38
|
+
self.autoDispel = autoDispel
|
|
39
|
+
end
|
|
40
|
+
function RemoveBuffsTargetAbilityBehavior.prototype.onUnitTargetImpact(self, _, target)
|
|
41
|
+
target:removeBuffs(
|
|
42
|
+
self:resolveCurrentAbilityDependentValue(self.polarity),
|
|
43
|
+
self:resolveCurrentAbilityDependentValue(self.resistanceType),
|
|
44
|
+
self:resolveCurrentAbilityDependentValue(self.includeExpirationTimers),
|
|
45
|
+
self:resolveCurrentAbilityDependentValue(self.includeAuras),
|
|
46
|
+
self:resolveCurrentAbilityDependentValue(self.autoDispel)
|
|
47
|
+
)
|
|
48
|
+
end
|
|
28
49
|
return ____exports
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Behavior } from "../behavior";
|
|
3
|
-
import { Unit } from "../unit";
|
|
3
|
+
import { Unit } from "../internal/unit";
|
|
4
|
+
import "../internal/unit/ability";
|
|
4
5
|
import { Ability } from "../internal/ability";
|
|
5
6
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
6
7
|
import { Widget } from "../../core/types/widget";
|
|
@@ -7,8 +7,9 @@ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
|
7
7
|
local ____exports = {}
|
|
8
8
|
local ____behavior = require("engine.behavior")
|
|
9
9
|
local Behavior = ____behavior.Behavior
|
|
10
|
-
local ____unit = require("engine.unit")
|
|
10
|
+
local ____unit = require("engine.internal.unit")
|
|
11
11
|
local Unit = ____unit.Unit
|
|
12
|
+
require("engine.internal.unit.ability")
|
|
12
13
|
local ____ability = require("engine.internal.ability")
|
|
13
14
|
local Ability = ____ability.Ability
|
|
14
15
|
local ____effect = require("core.types.effect")
|
|
@@ -4,17 +4,21 @@ import { Unit } from "../../unit";
|
|
|
4
4
|
import { BuffTypeId } from "../../object-data/entry/buff-type";
|
|
5
5
|
import { TextTagPreset } from "../../text-tag";
|
|
6
6
|
import { Destructor } from "../../../destroyable";
|
|
7
|
-
|
|
7
|
+
import { BehaviorPriority } from "../../behavior";
|
|
8
|
+
export type StunImmunityUnitBehaviorParameters = {
|
|
9
|
+
readonly priority?: BehaviorPriority;
|
|
8
10
|
buffTypeIds?: LuaSet<BuffTypeId>;
|
|
9
11
|
textTagPreset?: TextTagPreset;
|
|
10
12
|
textTagText?: string;
|
|
13
|
+
additionalAction?: (this: void, unit: Unit) => void;
|
|
11
14
|
};
|
|
12
15
|
export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
13
|
-
readonly parameters: Readonly<
|
|
14
|
-
static defaultParameters:
|
|
15
|
-
constructor(unit: Unit, parameters?: Readonly<
|
|
16
|
+
readonly parameters: Readonly<StunImmunityUnitBehaviorParameters>;
|
|
17
|
+
static defaultParameters: StunImmunityUnitBehaviorParameters;
|
|
18
|
+
constructor(unit: Unit, parameters?: Readonly<StunImmunityUnitBehaviorParameters>);
|
|
16
19
|
protected onDestroy(): Destructor;
|
|
17
20
|
onDamageReceived(): void;
|
|
18
21
|
onTargetingAbilityChannelingStart(): void;
|
|
19
22
|
onTargetingAbilityImpact(): void;
|
|
23
|
+
protected onEffect(): void;
|
|
20
24
|
}
|
|
@@ -48,8 +48,15 @@ local function process(behavior)
|
|
|
48
48
|
for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
|
|
49
49
|
hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
|
|
50
50
|
end
|
|
51
|
-
if hasRemovedBuffs
|
|
52
|
-
|
|
51
|
+
if hasRemovedBuffs then
|
|
52
|
+
behavior.onEffect(behavior)
|
|
53
|
+
if behavior.parameters.textTagText ~= nil then
|
|
54
|
+
TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
|
|
55
|
+
end
|
|
56
|
+
local ____opt_0 = behavior.parameters.additionalAction
|
|
57
|
+
if ____opt_0 ~= nil then
|
|
58
|
+
____opt_0(behavior.unit)
|
|
59
|
+
end
|
|
53
60
|
end
|
|
54
61
|
end
|
|
55
62
|
____exports.StunImmunityUnitBehavior = __TS__Class()
|
|
@@ -60,7 +67,7 @@ function StunImmunityUnitBehavior.prototype.____constructor(self, unit, paramete
|
|
|
60
67
|
if parameters == nil then
|
|
61
68
|
parameters = ____exports.StunImmunityUnitBehavior.defaultParameters
|
|
62
69
|
end
|
|
63
|
-
UnitBehavior.prototype.____constructor(self, unit)
|
|
70
|
+
UnitBehavior.prototype.____constructor(self, unit, parameters.priority)
|
|
64
71
|
self.parameters = parameters
|
|
65
72
|
unit:decrementStunCounter()
|
|
66
73
|
process(self)
|
|
@@ -79,5 +86,7 @@ end
|
|
|
79
86
|
function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
|
|
80
87
|
process(self)
|
|
81
88
|
end
|
|
89
|
+
function StunImmunityUnitBehavior.prototype.onEffect(self)
|
|
90
|
+
end
|
|
82
91
|
StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
|
|
83
92
|
return ____exports
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import { Behavior } from "../behavior";
|
|
2
|
+
import { Behavior, BehaviorPriority } from "../behavior";
|
|
3
3
|
import { Ability } from "../internal/ability";
|
|
4
4
|
import { DamageEvent, DamagingEvent, Unit } from "../internal/unit";
|
|
5
5
|
import "../internal/unit+ability";
|
|
6
6
|
import "../internal/unit-missile-launch";
|
|
7
7
|
import { Item } from "../internal/item";
|
|
8
|
-
import
|
|
8
|
+
import { AbilityBehavior } from "./ability";
|
|
9
9
|
import { Event } from "../../event";
|
|
10
10
|
import { Destructor } from "../../destroyable";
|
|
11
11
|
import type { Widget } from "../../core/types/widget";
|
|
12
12
|
import { Destructable } from "../../core/types/destructable";
|
|
13
13
|
import type { Buff } from "../buff";
|
|
14
|
+
import { UnitBonusType } from "../internal/unit/bonus";
|
|
15
|
+
import { Player } from "../../core/types/player";
|
|
16
|
+
import { UnitTypeId } from "../object-data/entry/unit-type";
|
|
14
17
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
15
18
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
16
|
-
constructor(unit: Unit);
|
|
17
|
-
protected onDestroy(): Destructor;
|
|
18
19
|
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
20
|
+
private _bonusIdByBonusType?;
|
|
21
|
+
constructor(unit: Unit, priority?: BehaviorPriority);
|
|
22
|
+
protected onDestroy(): Destructor;
|
|
19
23
|
get unit(): Unit;
|
|
20
|
-
|
|
24
|
+
protected getUnitBonus(bonusType: UnitBonusType): number;
|
|
25
|
+
protected addOrUpdateOrRemoveUnitBonus(bonusType: UnitBonusType, value: number): void;
|
|
26
|
+
protected registerOwningPlayerEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractPlayer: (...args: Args) => Player | undefined, listener: T): void;
|
|
27
|
+
protected registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractUnit: (...args: Args) => Unit | undefined, range: number, listener: T): void;
|
|
21
28
|
onImmediateOrder(orderId: number): void;
|
|
22
29
|
onTargetOrder(orderId: number, target: Widget): void;
|
|
23
30
|
onPointOrder(orderId: number, x: number, y: number): void;
|
|
@@ -44,6 +51,7 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
44
51
|
onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
|
|
45
52
|
onTargetingAbilityImpact(ability: Ability, source: Unit): void;
|
|
46
53
|
onBuffGained(buff: Buff): void;
|
|
54
|
+
onBuffLost(buff: Buff): void;
|
|
47
55
|
onItemDropped(item: Item): void;
|
|
48
56
|
onItemPickedUp(item: Item): void;
|
|
49
57
|
onItemUsed(item: Item): void;
|
|
@@ -51,4 +59,6 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
51
59
|
onItemChargesChanged(item: Item): void;
|
|
52
60
|
onKill(target: Unit): void;
|
|
53
61
|
onDeath(source: Unit | undefined): void;
|
|
62
|
+
onOwnerChange(previousOwner: Player): void;
|
|
63
|
+
static bindUnitType<Args extends any[]>(this: UnitBehaviorConstructor<Args>, unitTypeId: UnitTypeId, ...args: Args): void;
|
|
54
64
|
}
|