warscript 0.0.1-dev.e72b4b0 → 0.0.1-dev.ea102a7
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/frame.lua +24 -21
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +2 -1
- package/core/types/timer.lua +21 -2
- package/decl/native.d.ts +6 -4
- package/engine/behavior.d.ts +5 -0
- package/engine/behavior.lua +106 -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/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.lua +7 -16
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
- package/engine/behaviour/unit/stun-immunity.lua +52 -27
- package/engine/behaviour/unit.d.ts +12 -2
- package/engine/behaviour/unit.lua +47 -7
- package/engine/buff.d.ts +2 -4
- package/engine/buff.lua +68 -83
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +34 -11
- package/engine/internal/item/ability.lua +51 -1
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +63 -49
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/unit/ability.lua +13 -5
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit-missile-launch.lua +18 -5
- package/engine/internal/unit.d.ts +5 -6
- package/engine/internal/unit.lua +73 -73
- 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 +5 -4
- 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/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +7 -0
- package/engine/object-field/unit.lua +21 -0
- package/engine/object-field.d.ts +2 -2
- package/engine/object-field.lua +8 -6
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/fields/unit.d.ts +2 -1
- package/engine/standard/fields/unit.lua +2 -0
- package/engine/text-tag.d.ts +1 -1
- package/engine/text-tag.lua +91 -17
- 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 +13 -0
- package/utility/callback-array.lua +46 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
package/engine/behavior.lua
CHANGED
|
@@ -1,18 +1,63 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
-
local
|
|
5
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____destroyable = require("destroyable")
|
|
7
8
|
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
8
9
|
local ____timer = require("core.types.timer")
|
|
9
10
|
local Timer = ____timer.Timer
|
|
11
|
+
local ____functions = require("utility.functions")
|
|
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
|
|
10
20
|
local safeCall = warpack.safeCall
|
|
11
21
|
local firstBehaviorByObject = {}
|
|
12
22
|
local lastBehaviorByObject = {}
|
|
13
23
|
local function invokeBehaviorOnPeriod(behavior, ...)
|
|
14
24
|
behavior.onPeriod(behavior, ...)
|
|
15
25
|
end
|
|
26
|
+
local function reduceBehaviors(behaviorConstructor, object, operation, initial, consumerOrKey, ...)
|
|
27
|
+
local accumulator = initial
|
|
28
|
+
local behavior = firstBehaviorByObject[object]
|
|
29
|
+
if behavior ~= nil then
|
|
30
|
+
if type(consumerOrKey) == "function" then
|
|
31
|
+
repeat
|
|
32
|
+
do
|
|
33
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
34
|
+
local isSuccessful, result = safeCall(consumerOrKey, behavior, ...)
|
|
35
|
+
if isSuccessful then
|
|
36
|
+
accumulator = operation(accumulator, result)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
behavior = behavior[1]
|
|
40
|
+
end
|
|
41
|
+
until not (behavior ~= nil)
|
|
42
|
+
else
|
|
43
|
+
repeat
|
|
44
|
+
do
|
|
45
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
46
|
+
local isSuccessful, result = safeCall(behavior[consumerOrKey], behavior, ...)
|
|
47
|
+
if isSuccessful then
|
|
48
|
+
accumulator = operation(accumulator, result)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
behavior = behavior[1]
|
|
52
|
+
end
|
|
53
|
+
until not (behavior ~= nil)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
return accumulator
|
|
57
|
+
end
|
|
58
|
+
local behaviorsByEvent = {}
|
|
59
|
+
local listenerByBehaviorByEvent = {}
|
|
60
|
+
local eventsByBehavior = {}
|
|
16
61
|
____exports.Behavior = __TS__Class()
|
|
17
62
|
local Behavior = ____exports.Behavior
|
|
18
63
|
Behavior.name = "Behavior"
|
|
@@ -35,6 +80,20 @@ function Behavior.prototype.onDestroy(self)
|
|
|
35
80
|
if ____opt_0 ~= nil then
|
|
36
81
|
____opt_0:destroy()
|
|
37
82
|
end
|
|
83
|
+
local events = eventsByBehavior[self]
|
|
84
|
+
if events ~= nil then
|
|
85
|
+
for event in pairs(events) do
|
|
86
|
+
local ____opt_2 = behaviorsByEvent[event]
|
|
87
|
+
if ____opt_2 ~= nil then
|
|
88
|
+
____opt_2:remove(self)
|
|
89
|
+
end
|
|
90
|
+
local ____opt_4 = listenerByBehaviorByEvent[event]
|
|
91
|
+
if ____opt_4 ~= nil then
|
|
92
|
+
____opt_4[self] = nil
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
eventsByBehavior[self] = nil
|
|
96
|
+
end
|
|
38
97
|
local previousBehavior = self[0]
|
|
39
98
|
local nextBehavior = self[1]
|
|
40
99
|
if previousBehavior ~= nil then
|
|
@@ -49,6 +108,34 @@ function Behavior.prototype.onDestroy(self)
|
|
|
49
108
|
end
|
|
50
109
|
return AbstractDestroyable.prototype.onDestroy(self)
|
|
51
110
|
end
|
|
111
|
+
function Behavior.prototype.registerEvent(self, event, listener)
|
|
112
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
|
|
113
|
+
listenerByBehavior[self] = listener
|
|
114
|
+
getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
|
|
115
|
+
local behaviors = behaviorsByEvent[event]
|
|
116
|
+
if behaviors == nil then
|
|
117
|
+
event:addListener(function(...)
|
|
118
|
+
local behaviors = behaviorsByEvent[event]
|
|
119
|
+
if behaviors ~= nil then
|
|
120
|
+
for behavior in pairs(behaviors) do
|
|
121
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end)
|
|
125
|
+
behaviors = __TS__New(LinkedSet)
|
|
126
|
+
behaviorsByEvent[event] = behaviors
|
|
127
|
+
end
|
|
128
|
+
behaviors:add(self)
|
|
129
|
+
end
|
|
130
|
+
function Behavior.prototype.deregisterEvent(self, event)
|
|
131
|
+
local behaviors = behaviorsByEvent[event]
|
|
132
|
+
if behaviors ~= nil and behaviors:remove(self) then
|
|
133
|
+
eventsByBehavior[self][event] = nil
|
|
134
|
+
listenerByBehaviorByEvent[event][self] = nil
|
|
135
|
+
return true
|
|
136
|
+
end
|
|
137
|
+
return false
|
|
138
|
+
end
|
|
52
139
|
function Behavior.prototype.onPeriod(self, ...)
|
|
53
140
|
end
|
|
54
141
|
function Behavior.prototype.startPeriodicAction(self, interval, ...)
|
|
@@ -151,31 +238,23 @@ function Behavior.forFirst(self, object, count, consumerOrKey, ...)
|
|
|
151
238
|
return behaviorsCount
|
|
152
239
|
end
|
|
153
240
|
function Behavior.forAll(self, object, consumerOrKey, ...)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
behaviorsCount = behaviorsCount + 1
|
|
173
|
-
end
|
|
174
|
-
behavior = behavior[1]
|
|
175
|
-
end
|
|
176
|
-
until not (behavior ~= nil)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
return behaviorsCount
|
|
241
|
+
return reduceBehaviors(
|
|
242
|
+
self,
|
|
243
|
+
object,
|
|
244
|
+
increment,
|
|
245
|
+
0,
|
|
246
|
+
consumerOrKey,
|
|
247
|
+
...
|
|
248
|
+
)
|
|
249
|
+
end
|
|
250
|
+
function Behavior.reduce(self, object, operation, initial, consumerOrKey, ...)
|
|
251
|
+
return reduceBehaviors(
|
|
252
|
+
self,
|
|
253
|
+
object,
|
|
254
|
+
operation,
|
|
255
|
+
initial,
|
|
256
|
+
consumerOrKey,
|
|
257
|
+
...
|
|
258
|
+
)
|
|
180
259
|
end
|
|
181
260
|
return ____exports
|
|
@@ -148,7 +148,7 @@ function ApplyBuffChannelingTargetAbilityBehavior.prototype.onStop(self)
|
|
|
148
148
|
self.buff = nil
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
|
-
Buff.
|
|
151
|
+
Buff.beingDestroyedEvent:addListener(function(buff)
|
|
152
152
|
local behavior = behaviorByBuff[buff]
|
|
153
153
|
if behavior ~= nil then
|
|
154
154
|
behaviorByBuff[buff] = nil
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { AbilityBehavior } from "../ability";
|
|
3
3
|
import { Unit } from "../../internal/unit";
|
|
4
4
|
export declare abstract class EmulateImpactAbilityBehavior extends AbilityBehavior {
|
|
5
|
-
protected emulateImpact(caster: Unit):
|
|
5
|
+
protected emulateImpact(caster: Unit): boolean;
|
|
6
6
|
}
|
|
@@ -28,7 +28,7 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
|
28
28
|
local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
|
|
29
29
|
local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
|
|
30
30
|
if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost or __TS__InstanceOf(self.ability, UnitAbility) and self.ability.isDisabled then
|
|
31
|
-
return
|
|
31
|
+
return false
|
|
32
32
|
end
|
|
33
33
|
caster.mana = caster.mana - manaCost
|
|
34
34
|
self.ability.cooldownRemaining = max(cooldown, MINIMUM_POSITIVE_NORMALIZED_FLOAT)
|
|
@@ -38,5 +38,6 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
|
38
38
|
Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
|
|
39
39
|
end
|
|
40
40
|
Event.invoke(Unit.abilityImpactEvent, caster, self.ability)
|
|
41
|
+
return true
|
|
41
42
|
end
|
|
42
43
|
return ____exports
|
|
@@ -8,7 +8,7 @@ export declare class RestoreManaSelfAbilityBehavior extends AbilityBehavior {
|
|
|
8
8
|
constructor(ability: Ability, mana: AbilityDependentValue<number>);
|
|
9
9
|
onImpact(caster: Unit): void;
|
|
10
10
|
}
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class RestoreManaTargetAbilityBehavior extends AbilityBehavior {
|
|
12
12
|
private readonly mana;
|
|
13
13
|
constructor(ability: Ability, mana: AbilityDependentValue<number>);
|
|
14
14
|
onUnitTargetImpact(caster: Unit, target: Unit): void;
|
|
@@ -15,15 +15,15 @@ end
|
|
|
15
15
|
function RestoreManaSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
16
16
|
caster.mana = caster.mana + self:resolveCurrentAbilityDependentValue(self.mana)
|
|
17
17
|
end
|
|
18
|
-
____exports.
|
|
19
|
-
local
|
|
20
|
-
|
|
21
|
-
__TS__ClassExtends(
|
|
22
|
-
function
|
|
18
|
+
____exports.RestoreManaTargetAbilityBehavior = __TS__Class()
|
|
19
|
+
local RestoreManaTargetAbilityBehavior = ____exports.RestoreManaTargetAbilityBehavior
|
|
20
|
+
RestoreManaTargetAbilityBehavior.name = "RestoreManaTargetAbilityBehavior"
|
|
21
|
+
__TS__ClassExtends(RestoreManaTargetAbilityBehavior, AbilityBehavior)
|
|
22
|
+
function RestoreManaTargetAbilityBehavior.prototype.____constructor(self, ability, mana)
|
|
23
23
|
AbilityBehavior.prototype.____constructor(self, ability)
|
|
24
24
|
self.mana = mana
|
|
25
25
|
end
|
|
26
|
-
function
|
|
26
|
+
function RestoreManaTargetAbilityBehavior.prototype.onUnitTargetImpact(self, caster, target)
|
|
27
27
|
target.mana = target.mana + self:resolveCurrentAbilityDependentValue(self.mana)
|
|
28
28
|
end
|
|
29
29
|
return ____exports
|
|
@@ -5,7 +5,6 @@ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
|
5
5
|
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
7
7
|
local ____exports = {}
|
|
8
|
-
local createUnitEventListener
|
|
9
8
|
local ____behavior = require("engine.behavior")
|
|
10
9
|
local Behavior = ____behavior.Behavior
|
|
11
10
|
local ____unit = require("engine.unit")
|
|
@@ -30,17 +29,9 @@ local ____ability = require("engine.object-field.ability")
|
|
|
30
29
|
local AbilityField = ____ability.AbilityField
|
|
31
30
|
local AbilityLevelField = ____ability.AbilityLevelField
|
|
32
31
|
local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
|
|
33
|
-
local ____timer = require("core.types.timer")
|
|
34
|
-
local Timer = ____timer.Timer
|
|
35
32
|
local createBehaviorFunctionsByAbilityTypeId = {}
|
|
36
33
|
local exclusiveOnImpactHandlerAbilityBehaviorByAbility = setmetatable({}, {__mode = "k"})
|
|
37
|
-
local function
|
|
38
|
-
local unitEventListener = createUnitEventListener(key)
|
|
39
|
-
return function(unit, ability, ...)
|
|
40
|
-
Timer:run(unitEventListener, unit, ability, ...)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
createUnitEventListener = function(key)
|
|
34
|
+
local function createUnitEventListener(key)
|
|
44
35
|
return function(unit, ability, ...)
|
|
45
36
|
____exports.AbilityBehavior:forAll(ability, key, unit, ...)
|
|
46
37
|
end
|
|
@@ -275,12 +266,12 @@ __TS__SetDescriptor(
|
|
|
275
266
|
Unit.abilityPointTargetChannelingStartEvent:addListener(createUnitEventListener("onPointTargetChannelingStart"))
|
|
276
267
|
Unit.abilityNoTargetChannelingStartEvent:addListener(createUnitEventListener("onNoTargetChannelingStart"))
|
|
277
268
|
Unit.abilityImpactEvent:addListener(createUnitEventListener("onImpact"))
|
|
278
|
-
Unit.
|
|
279
|
-
Unit.
|
|
280
|
-
Unit.
|
|
281
|
-
Unit.
|
|
282
|
-
Unit.
|
|
283
|
-
Unit.
|
|
269
|
+
Unit.abilityWidgetTargetImpactEvent:addListener(createUnitEventListener("onWidgetTargetImpact"))
|
|
270
|
+
Unit.abilityUnitTargetImpactEvent:addListener(createUnitEventListener("onUnitTargetImpact"))
|
|
271
|
+
Unit.abilityItemTargetImpactEvent:addListener(createUnitEventListener("onItemTargetImpact"))
|
|
272
|
+
Unit.abilityDestructibleTargetImpactEvent:addListener(createUnitEventListener("onDestructibleTargetImpact"))
|
|
273
|
+
Unit.abilityPointTargetImpactEvent:addListener(createUnitEventListener("onPointTargetImpact"))
|
|
274
|
+
Unit.abilityNoTargetImpactEvent:addListener(createUnitEventListener("onNoTargetImpact"))
|
|
284
275
|
Unit.abilityChannelingFinishEvent:addListener(createUnitEventListener("onChannelingFinish"))
|
|
285
276
|
Unit.abilityStopEvent:addListener(createUnitEventListener("onStop"))
|
|
286
277
|
end)(AbilityBehavior)
|
|
@@ -8,11 +8,15 @@ export type StunImmunityUnitBehaviourParameters = {
|
|
|
8
8
|
buffTypeIds?: LuaSet<BuffTypeId>;
|
|
9
9
|
textTagPreset?: TextTagPreset;
|
|
10
10
|
textTagText?: string;
|
|
11
|
+
additionalAction?: (this: void, unit: Unit) => void;
|
|
11
12
|
};
|
|
12
13
|
export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
13
|
-
|
|
14
|
+
readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
|
|
14
15
|
static defaultParameters: StunImmunityUnitBehaviourParameters;
|
|
15
|
-
constructor(unit: Unit, parameters?: StunImmunityUnitBehaviourParameters);
|
|
16
|
+
constructor(unit: Unit, parameters?: Readonly<StunImmunityUnitBehaviourParameters>);
|
|
16
17
|
protected onDestroy(): Destructor;
|
|
17
|
-
|
|
18
|
+
onDamageReceived(): void;
|
|
19
|
+
onTargetingAbilityChannelingStart(): void;
|
|
20
|
+
onTargetingAbilityImpact(): void;
|
|
21
|
+
protected onEffect(): void;
|
|
18
22
|
}
|
|
@@ -12,31 +12,53 @@ local flatMapToLuaSet = ____arrays.flatMapToLuaSet
|
|
|
12
12
|
local map = ____arrays.map
|
|
13
13
|
local ____text_2Dtag = require("engine.text-tag")
|
|
14
14
|
local TextTag = ____text_2Dtag.TextTag
|
|
15
|
+
local ____timer = require("core.types.timer")
|
|
16
|
+
local Timer = ____timer.Timer
|
|
15
17
|
local DEFAULT_BUFF_TYPE_IDS = postcompile(function()
|
|
16
18
|
return flatMapToLuaSet(
|
|
17
19
|
AbilityType:getAllByBaseIds(map({
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
20
|
+
"AHtb",
|
|
21
|
+
"AHbh",
|
|
22
|
+
"AOws",
|
|
23
|
+
"AOw2",
|
|
24
|
+
"AUim",
|
|
25
|
+
"Acyc",
|
|
26
|
+
"ANfb",
|
|
27
|
+
"ANsb",
|
|
28
|
+
"ANcs",
|
|
29
|
+
"ANc1",
|
|
30
|
+
"ANc2",
|
|
31
|
+
"ANc3",
|
|
32
|
+
"ACbh",
|
|
33
|
+
"ANbh",
|
|
34
|
+
"SCc1",
|
|
35
|
+
"ACcy",
|
|
36
|
+
"ANb2",
|
|
37
|
+
"Awrs",
|
|
38
|
+
"Awrh",
|
|
39
|
+
"Awrg",
|
|
40
|
+
"ACtb",
|
|
41
|
+
"ACcb"
|
|
36
42
|
}, fourCC)),
|
|
37
43
|
function(abilityType) return __TS__ArrayFlat(abilityType.buffTypeIds) end
|
|
38
44
|
)
|
|
39
45
|
end)
|
|
46
|
+
local function process(behavior)
|
|
47
|
+
local hasRemovedBuffs = false
|
|
48
|
+
for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
|
|
49
|
+
hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
|
|
50
|
+
end
|
|
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
|
|
60
|
+
end
|
|
61
|
+
end
|
|
40
62
|
____exports.StunImmunityUnitBehavior = __TS__Class()
|
|
41
63
|
local StunImmunityUnitBehavior = ____exports.StunImmunityUnitBehavior
|
|
42
64
|
StunImmunityUnitBehavior.name = "StunImmunityUnitBehavior"
|
|
@@ -48,20 +70,23 @@ function StunImmunityUnitBehavior.prototype.____constructor(self, unit, paramete
|
|
|
48
70
|
UnitBehavior.prototype.____constructor(self, unit)
|
|
49
71
|
self.parameters = parameters
|
|
50
72
|
unit:decrementStunCounter()
|
|
51
|
-
self
|
|
73
|
+
process(self)
|
|
52
74
|
end
|
|
53
75
|
function StunImmunityUnitBehavior.prototype.onDestroy(self)
|
|
54
76
|
self.unit:incrementStunCounter()
|
|
55
77
|
return UnitBehavior.prototype.onDestroy(self)
|
|
56
78
|
end
|
|
57
|
-
function StunImmunityUnitBehavior.prototype.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
function StunImmunityUnitBehavior.prototype.onDamageReceived(self)
|
|
80
|
+
process(self)
|
|
81
|
+
Timer:run(process, self)
|
|
82
|
+
end
|
|
83
|
+
function StunImmunityUnitBehavior.prototype.onTargetingAbilityChannelingStart(self)
|
|
84
|
+
process(self)
|
|
85
|
+
end
|
|
86
|
+
function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
|
|
87
|
+
process(self)
|
|
88
|
+
end
|
|
89
|
+
function StunImmunityUnitBehavior.prototype.onEffect(self)
|
|
65
90
|
end
|
|
66
91
|
StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
|
|
67
92
|
return ____exports
|
|
@@ -10,13 +10,19 @@ 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
|
+
import type { Buff } from "../buff";
|
|
14
|
+
import { UnitBonusType } from "../internal/unit/bonus";
|
|
15
|
+
import { Player } from "../../core/types/player";
|
|
13
16
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
14
17
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
18
|
+
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
19
|
+
private _bonusIdByBonusType?;
|
|
15
20
|
constructor(unit: Unit);
|
|
16
21
|
protected onDestroy(): Destructor;
|
|
17
|
-
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
18
22
|
get unit(): Unit;
|
|
19
|
-
|
|
23
|
+
protected getUnitBonus(bonusType: UnitBonusType): number;
|
|
24
|
+
protected addOrUpdateOrRemoveUnitBonus(bonusType: UnitBonusType, value: number): void;
|
|
25
|
+
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;
|
|
20
26
|
onImmediateOrder(orderId: number): void;
|
|
21
27
|
onTargetOrder(orderId: number, target: Widget): void;
|
|
22
28
|
onPointOrder(orderId: number, x: number, y: number): void;
|
|
@@ -40,6 +46,9 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
40
46
|
onAbilityNoTargetImpact(ability: Ability): void;
|
|
41
47
|
onAbilityChannelingFinish(ability: Ability): void;
|
|
42
48
|
onAbilityStop(ability: Ability): void;
|
|
49
|
+
onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
|
|
50
|
+
onTargetingAbilityImpact(ability: Ability, source: Unit): void;
|
|
51
|
+
onBuffGained(buff: Buff): void;
|
|
43
52
|
onItemDropped(item: Item): void;
|
|
44
53
|
onItemPickedUp(item: Item): void;
|
|
45
54
|
onItemUsed(item: Item): void;
|
|
@@ -47,4 +56,5 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
47
56
|
onItemChargesChanged(item: Item): void;
|
|
48
57
|
onKill(target: Unit): void;
|
|
49
58
|
onDeath(source: Unit | undefined): void;
|
|
59
|
+
onOwnerChange(previousOwner: Player): void;
|
|
50
60
|
}
|
|
@@ -17,6 +17,11 @@ local getOrPut = ____lua_2Dmaps.getOrPut
|
|
|
17
17
|
local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
|
|
18
18
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
19
19
|
local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
|
|
20
|
+
local ____bonus = require("engine.internal.unit.bonus")
|
|
21
|
+
local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
|
|
22
|
+
local getUnitBonus = ____bonus.getUnitBonus
|
|
23
|
+
local removeUnitBonus = ____bonus.removeUnitBonus
|
|
24
|
+
local safeCall = warpack.safeCall
|
|
20
25
|
local behaviorsByEvent = {}
|
|
21
26
|
local rangeByBehaviorByEvent = {}
|
|
22
27
|
local listenerByBehaviorByEvent = {}
|
|
@@ -47,9 +52,27 @@ function UnitBehavior.prototype.onDestroy(self)
|
|
|
47
52
|
end
|
|
48
53
|
eventsByBehavior[self] = nil
|
|
49
54
|
end
|
|
55
|
+
if self._bonusIdByBonusType ~= nil then
|
|
56
|
+
for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
|
|
57
|
+
removeUnitBonus(self.object, bonusType, bonusId)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
50
60
|
return Behavior.prototype.onDestroy(self)
|
|
51
61
|
end
|
|
52
|
-
function UnitBehavior.prototype.
|
|
62
|
+
function UnitBehavior.prototype.getUnitBonus(self, bonusType)
|
|
63
|
+
local ____opt_6 = self._bonusIdByBonusType
|
|
64
|
+
local bonusId = ____opt_6 and ____opt_6[bonusType]
|
|
65
|
+
return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
|
|
66
|
+
end
|
|
67
|
+
function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
|
|
68
|
+
local bonusIdByBonusType = self._bonusIdByBonusType
|
|
69
|
+
if bonusIdByBonusType == nil then
|
|
70
|
+
bonusIdByBonusType = {}
|
|
71
|
+
self._bonusIdByBonusType = bonusIdByBonusType
|
|
72
|
+
end
|
|
73
|
+
bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self.object, bonusType, bonusIdByBonusType[bonusType], value)
|
|
74
|
+
end
|
|
75
|
+
function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
|
|
53
76
|
local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
|
|
54
77
|
rangeByBehavior[self] = range
|
|
55
78
|
local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
|
|
@@ -57,14 +80,16 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, range, lis
|
|
|
57
80
|
getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
|
|
58
81
|
local behaviors = behaviorsByEvent[event]
|
|
59
82
|
if behaviors == nil then
|
|
60
|
-
event:addListener(function(
|
|
83
|
+
event:addListener(function(...)
|
|
61
84
|
local behaviors = behaviorsByEvent[event]
|
|
62
85
|
if behaviors ~= nil then
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
local
|
|
67
|
-
|
|
86
|
+
local unit = extractUnit(...)
|
|
87
|
+
if unit ~= nil then
|
|
88
|
+
for behavior in pairs(behaviors) do
|
|
89
|
+
local range = rangeByBehavior[behavior]
|
|
90
|
+
if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
|
|
91
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
92
|
+
end
|
|
68
93
|
end
|
|
69
94
|
end
|
|
70
95
|
end
|
|
@@ -120,6 +145,12 @@ function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
|
|
|
120
145
|
end
|
|
121
146
|
function UnitBehavior.prototype.onAbilityStop(self, ability)
|
|
122
147
|
end
|
|
148
|
+
function UnitBehavior.prototype.onTargetingAbilityChannelingStart(self, ability, source)
|
|
149
|
+
end
|
|
150
|
+
function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
|
|
151
|
+
end
|
|
152
|
+
function UnitBehavior.prototype.onBuffGained(self, buff)
|
|
153
|
+
end
|
|
123
154
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
124
155
|
end
|
|
125
156
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
|
@@ -134,6 +165,8 @@ function UnitBehavior.prototype.onKill(self, target)
|
|
|
134
165
|
end
|
|
135
166
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
136
167
|
end
|
|
168
|
+
function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
|
|
169
|
+
end
|
|
137
170
|
__TS__SetDescriptor(
|
|
138
171
|
UnitBehavior.prototype,
|
|
139
172
|
"unit",
|
|
@@ -187,6 +220,9 @@ __TS__SetDescriptor(
|
|
|
187
220
|
Unit.abilityChannelingStartEvent:addListener(function(source, ability)
|
|
188
221
|
____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
|
|
189
222
|
end)
|
|
223
|
+
Unit.abilityUnitTargetChannelingStartEvent:addListener(function(source, ability, target)
|
|
224
|
+
____exports.UnitBehavior:forAll(target, "onTargetingAbilityChannelingStart", ability, source)
|
|
225
|
+
end)
|
|
190
226
|
Unit.abilityImpactEvent:addListener(function(source, ability)
|
|
191
227
|
____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
|
|
192
228
|
end)
|
|
@@ -195,6 +231,7 @@ __TS__SetDescriptor(
|
|
|
195
231
|
end)
|
|
196
232
|
Unit.abilityUnitTargetImpactEvent:addListener(function(source, ability, target)
|
|
197
233
|
____exports.UnitBehavior:forAll(source, "onAbilityUnitTargetImpact", ability, target)
|
|
234
|
+
____exports.UnitBehavior:forAll(target, "onTargetingAbilityImpact", ability, source)
|
|
198
235
|
end)
|
|
199
236
|
Unit.abilityItemTargetImpactEvent:addListener(function(source, ability, target)
|
|
200
237
|
____exports.UnitBehavior:forAll(source, "onAbilityItemTargetImpact", ability, target)
|
|
@@ -241,6 +278,9 @@ __TS__SetDescriptor(
|
|
|
241
278
|
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
242
279
|
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
243
280
|
end)
|
|
281
|
+
Unit.onOwnerChange:addListener(function(unit, previousOwner)
|
|
282
|
+
____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
|
|
283
|
+
end)
|
|
244
284
|
end)(UnitBehavior)
|
|
245
285
|
Unit.destroyEvent:addListener(function(unit)
|
|
246
286
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
package/engine/buff.d.ts
CHANGED
|
@@ -201,11 +201,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
201
201
|
private readonly _spellStealPriority?;
|
|
202
202
|
private readonly _learnLevelMinimum?;
|
|
203
203
|
private readonly [BuffPropertyKey.MISS_PROBABILITY]?;
|
|
204
|
-
private _bonusIdByBonusType?;
|
|
205
204
|
private readonly _abilityTypeIds?;
|
|
206
205
|
private _behaviors?;
|
|
207
|
-
private getUnitBonus;
|
|
208
|
-
private addOrUpdateOrRemoveUnitBonus;
|
|
209
206
|
constructor(target: Unit, ...parameters: BuffConstructorParameters<AdditionalParameters>);
|
|
210
207
|
get level(): number;
|
|
211
208
|
get remainingDamageOverDuration(): number;
|
|
@@ -278,6 +275,7 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
278
275
|
onDeath(source: Unit | undefined): void;
|
|
279
276
|
onDamageDealt(target: Unit, event: DamageEvent): void;
|
|
280
277
|
onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
|
|
281
|
-
static readonly
|
|
278
|
+
static readonly createdEvent: Event<[Buff<object>]>;
|
|
279
|
+
static readonly beingDestroyedEvent: Event<[Buff<object>]>;
|
|
282
280
|
}
|
|
283
281
|
export {};
|