warscript 0.0.1-dev.6fc443a → 0.0.1-dev.702d52d
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/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +4 -2
- package/engine/behavior.lua +69 -11
- package/engine/behaviour/ability/apply-buff.lua +4 -4
- package/engine/behaviour/ability.d.ts +2 -1
- package/engine/behaviour/ability.lua +2 -1
- package/engine/behaviour/unit/stun-immunity.d.ts +1 -1
- package/engine/behaviour/unit/stun-immunity.lua +5 -4
- package/engine/behaviour/unit.d.ts +1 -0
- package/engine/behaviour/unit.lua +15 -3
- package/engine/buff.d.ts +9 -3
- package/engine/buff.lua +62 -34
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +10 -0
- package/engine/internal/unit/fly-height.lua +3 -3
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/scale.lua +3 -3
- package/engine/internal/unit-missile-launch.lua +12 -5
- package/engine/internal/unit.d.ts +1 -8
- package/engine/internal/unit.lua +70 -91
- package/engine/local-client.d.ts +1 -1
- package/engine/local-client.lua +4 -4
- 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/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/unit.d.ts +7 -4
- package/engine/object-field/unit.lua +4 -0
- package/engine/object-field.d.ts +2 -0
- package/engine/object-field.lua +171 -115
- package/engine/standard/fields/ability.d.ts +2 -2
- package/engine/standard/fields/ability.lua +2 -2
- package/engine/standard/fields/unit.d.ts +11 -5
- package/engine/standard/fields/unit.lua +13 -4
- package/engine/unit.d.ts +2 -0
- package/engine/unit.lua +2 -0
- package/objutil/buff.lua +9 -7
- package/package.json +2 -2
- package/patch-lua.lua +15 -0
- package/utility/linked-map.d.ts +26 -0
- package/utility/linked-map.lua +66 -0
- package/utility/linked-set.lua +4 -0
- package/utility/records.lua +20 -1
package/destroyable.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface Destroyable {
|
|
|
10
10
|
destroy(): void;
|
|
11
11
|
}
|
|
12
12
|
export declare abstract class AbstractDestroyable implements Destroyable {
|
|
13
|
+
get isDestroyed(): boolean;
|
|
13
14
|
/**
|
|
14
15
|
* An overriding function should always call the super one at the end of it,
|
|
15
16
|
* in the following manner: `return super.onDestroy()`.
|
package/destroyable.lua
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
4
5
|
local ____exports = {}
|
|
5
6
|
local ____exception = require("exception")
|
|
6
7
|
local IllegalStateException = ____exception.IllegalStateException
|
|
@@ -28,4 +29,12 @@ function AbstractDestroyable.prototype.destroy(self)
|
|
|
28
29
|
end
|
|
29
30
|
return true
|
|
30
31
|
end
|
|
32
|
+
__TS__SetDescriptor(
|
|
33
|
+
AbstractDestroyable.prototype,
|
|
34
|
+
"isDestroyed",
|
|
35
|
+
{get = function(self)
|
|
36
|
+
return stateByDestroyable[self] ~= nil
|
|
37
|
+
end},
|
|
38
|
+
true
|
|
39
|
+
)
|
|
31
40
|
return ____exports
|
package/engine/behavior.d.ts
CHANGED
|
@@ -18,9 +18,11 @@ export declare abstract class Behavior<T extends AnyNotNil, PeriodicActionParame
|
|
|
18
18
|
private [BehaviorPropertyKey.PREVIOUS_BEHAVIOR]?;
|
|
19
19
|
private [BehaviorPropertyKey.NEXT_BEHAVIOR]?;
|
|
20
20
|
private [BehaviorPropertyKey.TIMER]?;
|
|
21
|
-
|
|
21
|
+
constructor(object: T, priority?: BehaviorPriority);
|
|
22
22
|
protected onDestroy(): Destructor;
|
|
23
|
-
protected
|
|
23
|
+
protected registerGlobalEvent<K extends string, Args extends any[]>(this: Behavior<any, PeriodicActionParameters> & Record<K, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, listener: K): void;
|
|
24
|
+
protected deregisterGlobalEvent(event: Event<any>): boolean;
|
|
25
|
+
protected registerEvent<K extends string, Args extends any[]>(this: Behavior<any, PeriodicActionParameters> & Record<K, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractObject: (...args: Args) => T | undefined, listener: K): void;
|
|
24
26
|
protected deregisterEvent(event: Event<any>): boolean;
|
|
25
27
|
protected onPeriod(...parameters: PeriodicActionParameters): void;
|
|
26
28
|
protected startPeriodicAction(interval: number, ...parameters: PeriodicActionParameters): void;
|
package/engine/behavior.lua
CHANGED
|
@@ -57,9 +57,17 @@ local function reduceBehaviors(behaviorConstructor, object, operation, initial,
|
|
|
57
57
|
end
|
|
58
58
|
return accumulator
|
|
59
59
|
end
|
|
60
|
+
local behaviorsByGlobalEvent = {}
|
|
61
|
+
local listenerByBehaviorByGlobalEvent = {}
|
|
62
|
+
local globalEventsByBehavior = {}
|
|
60
63
|
local behaviorsByEvent = {}
|
|
61
64
|
local listenerByBehaviorByEvent = {}
|
|
62
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
|
|
63
71
|
____exports.Behavior = __TS__Class()
|
|
64
72
|
local Behavior = ____exports.Behavior
|
|
65
73
|
Behavior.name = "Behavior"
|
|
@@ -87,18 +95,32 @@ function Behavior.prototype.onDestroy(self)
|
|
|
87
95
|
if ____opt_0 ~= nil then
|
|
88
96
|
____opt_0:destroy()
|
|
89
97
|
end
|
|
90
|
-
local
|
|
91
|
-
if
|
|
92
|
-
for event in pairs(
|
|
93
|
-
local ____opt_2 =
|
|
98
|
+
local globalEvents = globalEventsByBehavior[self]
|
|
99
|
+
if globalEvents ~= nil then
|
|
100
|
+
for event in pairs(globalEvents) do
|
|
101
|
+
local ____opt_2 = behaviorsByGlobalEvent[event]
|
|
94
102
|
if ____opt_2 ~= nil then
|
|
95
103
|
____opt_2:remove(self)
|
|
96
104
|
end
|
|
97
|
-
local ____opt_4 =
|
|
105
|
+
local ____opt_4 = listenerByBehaviorByGlobalEvent[event]
|
|
98
106
|
if ____opt_4 ~= nil then
|
|
99
107
|
____opt_4[self] = nil
|
|
100
108
|
end
|
|
101
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
|
|
102
124
|
eventsByBehavior[self] = nil
|
|
103
125
|
end
|
|
104
126
|
local previousBehavior = self[0]
|
|
@@ -115,7 +137,35 @@ function Behavior.prototype.onDestroy(self)
|
|
|
115
137
|
end
|
|
116
138
|
return AbstractDestroyable.prototype.onDestroy(self)
|
|
117
139
|
end
|
|
118
|
-
function Behavior.prototype.
|
|
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)
|
|
119
169
|
local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
|
|
120
170
|
listenerByBehavior[self] = listener
|
|
121
171
|
getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
|
|
@@ -124,19 +174,27 @@ function Behavior.prototype.registerEvent(self, event, listener)
|
|
|
124
174
|
event:addListener(function(...)
|
|
125
175
|
local behaviors = behaviorsByEvent[event]
|
|
126
176
|
if behaviors ~= nil then
|
|
127
|
-
|
|
128
|
-
|
|
177
|
+
local object = extractObject(...)
|
|
178
|
+
if object ~= nil then
|
|
179
|
+
____exports.Behavior:forAll(
|
|
180
|
+
object,
|
|
181
|
+
safeCallBehaviorListener,
|
|
182
|
+
behaviors,
|
|
183
|
+
listenerByBehavior,
|
|
184
|
+
...
|
|
185
|
+
)
|
|
129
186
|
end
|
|
130
187
|
end
|
|
131
188
|
end)
|
|
132
|
-
behaviors =
|
|
189
|
+
behaviors = {}
|
|
133
190
|
behaviorsByEvent[event] = behaviors
|
|
134
191
|
end
|
|
135
|
-
behaviors
|
|
192
|
+
behaviors[self] = true
|
|
136
193
|
end
|
|
137
194
|
function Behavior.prototype.deregisterEvent(self, event)
|
|
138
195
|
local behaviors = behaviorsByEvent[event]
|
|
139
|
-
if behaviors ~= nil and behaviors
|
|
196
|
+
if behaviors ~= nil and behaviors[self] ~= nil then
|
|
197
|
+
behaviors[self] = nil
|
|
140
198
|
eventsByBehavior[self][event] = nil
|
|
141
199
|
listenerByBehaviorByEvent[event][self] = nil
|
|
142
200
|
return true
|
|
@@ -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
|
|
@@ -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")
|
|
@@ -7,7 +7,7 @@ import { Destructor } from "../../../destroyable";
|
|
|
7
7
|
import { BehaviorPriority } from "../../behavior";
|
|
8
8
|
export type StunImmunityUnitBehaviorParameters = {
|
|
9
9
|
readonly priority?: BehaviorPriority;
|
|
10
|
-
buffTypeIds?:
|
|
10
|
+
buffTypeIds?: readonly BuffTypeId[];
|
|
11
11
|
textTagPreset?: TextTagPreset;
|
|
12
12
|
textTagText?: string;
|
|
13
13
|
additionalAction?: (this: void, unit: Unit) => void;
|
|
@@ -8,14 +8,15 @@ local UnitBehavior = ____unit.UnitBehavior
|
|
|
8
8
|
local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
|
|
9
9
|
local AbilityType = ____ability_2Dtype.AbilityType
|
|
10
10
|
local ____arrays = require("utility.arrays")
|
|
11
|
-
local
|
|
11
|
+
local distinct = ____arrays.distinct
|
|
12
|
+
local flatMap = ____arrays.flatMap
|
|
12
13
|
local map = ____arrays.map
|
|
13
14
|
local ____text_2Dtag = require("engine.text-tag")
|
|
14
15
|
local TextTag = ____text_2Dtag.TextTag
|
|
15
16
|
local ____timer = require("core.types.timer")
|
|
16
17
|
local Timer = ____timer.Timer
|
|
17
18
|
local DEFAULT_BUFF_TYPE_IDS = postcompile(function()
|
|
18
|
-
return
|
|
19
|
+
return distinct(flatMap(
|
|
19
20
|
AbilityType:getAllByBaseIds(map({
|
|
20
21
|
"AHtb",
|
|
21
22
|
"AHbh",
|
|
@@ -41,11 +42,11 @@ local DEFAULT_BUFF_TYPE_IDS = postcompile(function()
|
|
|
41
42
|
"ACcb"
|
|
42
43
|
}, fourCC)),
|
|
43
44
|
function(abilityType) return __TS__ArrayFlat(abilityType.buffTypeIds) end
|
|
44
|
-
)
|
|
45
|
+
))
|
|
45
46
|
end)
|
|
46
47
|
local function process(behavior)
|
|
47
48
|
local hasRemovedBuffs = false
|
|
48
|
-
for buffTypeId in
|
|
49
|
+
for ____, buffTypeId in ipairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
|
|
49
50
|
hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
|
|
50
51
|
end
|
|
51
52
|
if hasRemovedBuffs then
|
|
@@ -51,6 +51,7 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
51
51
|
onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
|
|
52
52
|
onTargetingAbilityImpact(ability: Ability, source: Unit): void;
|
|
53
53
|
onBuffGained(buff: Buff): void;
|
|
54
|
+
onBuffLost(buff: Buff): void;
|
|
54
55
|
onItemDropped(item: Item): void;
|
|
55
56
|
onItemPickedUp(item: Item): void;
|
|
56
57
|
onItemUsed(item: Item): void;
|
|
@@ -21,6 +21,8 @@ local ____bonus = require("engine.internal.unit.bonus")
|
|
|
21
21
|
local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
|
|
22
22
|
local getUnitBonus = ____bonus.getUnitBonus
|
|
23
23
|
local removeUnitBonus = ____bonus.removeUnitBonus
|
|
24
|
+
local ____linked_2Dmap = require("utility.linked-map")
|
|
25
|
+
local LinkedMap = ____linked_2Dmap.LinkedMap
|
|
24
26
|
local safeCall = warpack.safeCall
|
|
25
27
|
local createBehaviorFunctionsByUnitTypeId = {}
|
|
26
28
|
local behaviorsByOwningPlayerEvent = {}
|
|
@@ -79,16 +81,24 @@ function UnitBehavior.prototype.onDestroy(self)
|
|
|
79
81
|
end
|
|
80
82
|
function UnitBehavior.prototype.getUnitBonus(self, bonusType)
|
|
81
83
|
local ____opt_10 = self._bonusIdByBonusType
|
|
82
|
-
local bonusId = ____opt_10 and ____opt_10
|
|
84
|
+
local bonusId = ____opt_10 and ____opt_10:get(bonusType)
|
|
83
85
|
return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
|
|
84
86
|
end
|
|
85
87
|
function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
|
|
86
88
|
local bonusIdByBonusType = self._bonusIdByBonusType
|
|
87
89
|
if bonusIdByBonusType == nil then
|
|
88
|
-
bonusIdByBonusType =
|
|
90
|
+
bonusIdByBonusType = __TS__New(LinkedMap)
|
|
89
91
|
self._bonusIdByBonusType = bonusIdByBonusType
|
|
90
92
|
end
|
|
91
|
-
bonusIdByBonusType
|
|
93
|
+
bonusIdByBonusType:put(
|
|
94
|
+
bonusType,
|
|
95
|
+
addOrUpdateOrRemoveUnitBonus(
|
|
96
|
+
self.object,
|
|
97
|
+
bonusType,
|
|
98
|
+
bonusIdByBonusType:get(bonusType),
|
|
99
|
+
value
|
|
100
|
+
)
|
|
101
|
+
)
|
|
92
102
|
end
|
|
93
103
|
function UnitBehavior.prototype.registerOwningPlayerEvent(self, event, extractPlayer, listener)
|
|
94
104
|
local listenerByBehavior = getOrPut(listenerByBehaviorByOwningPlayerEvent, event, mutableLuaMap)
|
|
@@ -193,6 +203,8 @@ function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
|
|
|
193
203
|
end
|
|
194
204
|
function UnitBehavior.prototype.onBuffGained(self, buff)
|
|
195
205
|
end
|
|
206
|
+
function UnitBehavior.prototype.onBuffLost(self, buff)
|
|
207
|
+
end
|
|
196
208
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
197
209
|
end
|
|
198
210
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
package/engine/buff.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { UnitBehavior } from "./behaviour/unit";
|
|
|
13
13
|
import type { Widget } from "../core/types/widget";
|
|
14
14
|
import { Destructor } from "../destroyable";
|
|
15
15
|
import { Event } from "../event";
|
|
16
|
+
import { AbilityBehavior } from "./behaviour/ability";
|
|
16
17
|
export type BuffConstructor<T extends Buff<any> = Buff<any>, Args extends any[] = any> = OmitConstructor<typeof Buff<any>> & (new (...args: Args) => T);
|
|
17
18
|
type EnumParameterValueType<T extends number> = T | AbilityEnumLevelField<T>;
|
|
18
19
|
type NumberParameterValueType = number | AbilityNumberField | AbilityNumberLevelField;
|
|
@@ -30,8 +31,10 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
30
31
|
source?: Unit;
|
|
31
32
|
behaviorConstructors?: (new (unit: Unit) => UnitBehavior)[];
|
|
32
33
|
abilityTypeIds?: Record<AbilityTypeId, {
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
readonly fields?: [
|
|
35
|
+
AbilityNumberField | AbilityNumberLevelField,
|
|
36
|
+
NumberParameterValueType
|
|
37
|
+
][];
|
|
35
38
|
/** Default `true`. */
|
|
36
39
|
readonly isButtonVisible?: boolean;
|
|
37
40
|
/** Default is the level of the source ability or 0 if it is absent. */
|
|
@@ -56,6 +59,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
56
59
|
armorIncreaseFactor?: NumberParameterValueType;
|
|
57
60
|
attackSpeedIncreaseFactor?: NumberParameterValueType;
|
|
58
61
|
movementSpeedIncreaseFactor?: NumberParameterValueType;
|
|
62
|
+
manaRegenerationRateIncreaseFactor?: NumberParameterValueType;
|
|
59
63
|
evasionProbability?: NumberParameterValueType;
|
|
60
64
|
missProbability?: NumberParameterValueType;
|
|
61
65
|
damageFactor?: NumberParameterValueType;
|
|
@@ -141,7 +145,7 @@ export type BuffConstructorParameters<AdditionalParameters extends BuffAdditiona
|
|
|
141
145
|
polarity: BuffPolarityParameterType,
|
|
142
146
|
resistanceType: BuffResistanceTypeParameterType,
|
|
143
147
|
...abilityOrParameters: [
|
|
144
|
-
ability?: Ability,
|
|
148
|
+
ability?: Ability | AbilityBehavior,
|
|
145
149
|
parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
|
|
146
150
|
] | [parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>]
|
|
147
151
|
];
|
|
@@ -264,6 +268,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
264
268
|
set movementSpeedIncreaseFactor(movementSpeedIncreaseFactor: number);
|
|
265
269
|
get evasionProbability(): number;
|
|
266
270
|
set evasionProbability(evasionProbability: number);
|
|
271
|
+
get manaRegenerationRateIncreaseFactor(): number;
|
|
272
|
+
set manaRegenerationRateIncreaseFactor(manaRegenerationRateIncreaseFactor: number);
|
|
267
273
|
get duration(): number;
|
|
268
274
|
get remainingDuration(): number;
|
|
269
275
|
set remainingDuration(remainingDuration: number);
|
package/engine/buff.lua
CHANGED
|
@@ -42,6 +42,7 @@ local BuffType = ____buff_2Dtype.BuffType
|
|
|
42
42
|
local ____unit = require("engine.behaviour.unit")
|
|
43
43
|
local UnitBehavior = ____unit.UnitBehavior
|
|
44
44
|
local ____arrays = require("utility.arrays")
|
|
45
|
+
local emptyArray = ____arrays.emptyArray
|
|
45
46
|
local forEach = ____arrays.forEach
|
|
46
47
|
local ____event = require("event")
|
|
47
48
|
local Event = ____event.Event
|
|
@@ -53,6 +54,10 @@ local ____destructable = require("core.types.destructable")
|
|
|
53
54
|
local Destructable = ____destructable.Destructable
|
|
54
55
|
local ____ability = require("engine.standard.fields.ability")
|
|
55
56
|
local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
|
|
57
|
+
local ____ability = require("engine.behaviour.ability")
|
|
58
|
+
local AbilityBehavior = ____ability.AbilityBehavior
|
|
59
|
+
local ____records = require("utility.records")
|
|
60
|
+
local sortedKeysUnnested = ____records.sortedKeysUnnested
|
|
56
61
|
local getUnitAbility = BlzGetUnitAbility
|
|
57
62
|
local stringValueByBuffTypeIdByFieldId = postcompile(function()
|
|
58
63
|
local stringValueByBuffTypeIdByFieldId = {}
|
|
@@ -101,6 +106,7 @@ local buffParametersKeys = {
|
|
|
101
106
|
armorIncreaseFactor = true,
|
|
102
107
|
attackSpeedIncreaseFactor = true,
|
|
103
108
|
movementSpeedIncreaseFactor = true,
|
|
109
|
+
manaRegenerationRateIncreaseFactor = true,
|
|
104
110
|
evasionProbability = true,
|
|
105
111
|
missProbability = true,
|
|
106
112
|
damageFactor = true,
|
|
@@ -188,6 +194,7 @@ local buffNumberParameters = {
|
|
|
188
194
|
"durationIncreaseOnAutoAttack",
|
|
189
195
|
"attackSpeedIncreaseFactor",
|
|
190
196
|
"movementSpeedIncreaseFactor",
|
|
197
|
+
"manaRegenerationRateIncreaseFactor",
|
|
191
198
|
"evasionProbability",
|
|
192
199
|
"armorIncrease",
|
|
193
200
|
"damageFactor",
|
|
@@ -322,33 +329,38 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
322
329
|
local polarity
|
|
323
330
|
local resistanceType
|
|
324
331
|
local ability
|
|
332
|
+
local abilityBehavior
|
|
325
333
|
if type(typeIdOrTypeIds) ~= "number" then
|
|
326
334
|
typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
|
|
327
335
|
polarity = resistanceTypeOrPolarity
|
|
328
336
|
resistanceType = abilityOrParametersOrResistanceType
|
|
329
|
-
if __TS__InstanceOf(parametersOrAbility,
|
|
337
|
+
if __TS__InstanceOf(parametersOrAbility, AbilityBehavior) then
|
|
338
|
+
abilityBehavior = parametersOrAbility
|
|
339
|
+
ability = abilityBehavior.ability
|
|
340
|
+
elseif __TS__InstanceOf(parametersOrAbility, Ability) then
|
|
330
341
|
ability = parametersOrAbility
|
|
331
|
-
|
|
332
|
-
ability = nil
|
|
342
|
+
elseif parametersOrAbility ~= nil then
|
|
333
343
|
parameters = parametersOrAbility
|
|
334
344
|
end
|
|
335
345
|
else
|
|
336
346
|
typeId = typeIdOrTypeIds
|
|
337
347
|
polarity = polarityOrTypeIdSelectionPolicy
|
|
338
348
|
resistanceType = resistanceTypeOrPolarity
|
|
339
|
-
if __TS__InstanceOf(abilityOrParametersOrResistanceType,
|
|
349
|
+
if __TS__InstanceOf(abilityOrParametersOrResistanceType, AbilityBehavior) then
|
|
350
|
+
abilityBehavior = abilityOrParametersOrResistanceType
|
|
351
|
+
ability = abilityBehavior.ability
|
|
352
|
+
parameters = parametersOrAbility
|
|
353
|
+
elseif __TS__InstanceOf(abilityOrParametersOrResistanceType, Ability) then
|
|
340
354
|
ability = abilityOrParametersOrResistanceType
|
|
341
355
|
parameters = parametersOrAbility
|
|
342
|
-
|
|
343
|
-
ability = nil
|
|
356
|
+
elseif abilityOrParametersOrResistanceType ~= nil then
|
|
344
357
|
parameters = abilityOrParametersOrResistanceType
|
|
358
|
+
else
|
|
359
|
+
parameters = parametersOrAbility
|
|
345
360
|
end
|
|
346
361
|
end
|
|
362
|
+
self.sourceAbilityBehavior = abilityBehavior
|
|
347
363
|
self.typeId = typeId
|
|
348
|
-
if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
|
|
349
|
-
parameters = ability
|
|
350
|
-
ability = nil
|
|
351
|
-
end
|
|
352
364
|
local defaultParameters = self.constructor.defaultParameters
|
|
353
365
|
local level = parameters and parameters.level or defaultParameters.level
|
|
354
366
|
local spellStealPriority = parameters and parameters.spellStealPriority or defaultParameters.spellStealPriority
|
|
@@ -459,24 +471,22 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
459
471
|
abilityTypeIds = {}
|
|
460
472
|
self._abilityTypeIds = abilityTypeIds
|
|
461
473
|
end
|
|
462
|
-
for
|
|
474
|
+
for ____, abilityTypeId in ipairs(sortedKeysUnnested(parametersAbilityTypeIds)) do
|
|
475
|
+
local abilityParameters = parametersAbilityTypeIds[abilityTypeId]
|
|
463
476
|
local addedAbility = _unit:addAbility(abilityTypeId)
|
|
464
477
|
if addedAbility ~= nil then
|
|
465
478
|
_unit:makeAbilityPermanent(abilityTypeId, true)
|
|
466
479
|
_unit:setAbilityLevel(abilityTypeId, 1 + (abilityParameters.level or ability and ability.level or 0))
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
resolveNumberValue(ability, level, abilityParameterValue)
|
|
476
|
-
)
|
|
477
|
-
end
|
|
480
|
+
if abilityParameters.isButtonVisible == false then
|
|
481
|
+
_unit:hideAbility(abilityTypeId, true)
|
|
482
|
+
end
|
|
483
|
+
for ____, field in ipairs(abilityParameters.fields or emptyArray()) do
|
|
484
|
+
field[1]:setValue(
|
|
485
|
+
addedAbility,
|
|
486
|
+
resolveNumberValue(ability, level, field[2])
|
|
487
|
+
)
|
|
478
488
|
end
|
|
479
|
-
abilityTypeIds[
|
|
489
|
+
abilityTypeIds[#abilityTypeIds + 1] = abilityTypeId
|
|
480
490
|
end
|
|
481
491
|
end
|
|
482
492
|
local behaviorConstructors = parameters and parameters.behaviorConstructors or defaultParameters.behaviorConstructors
|
|
@@ -488,18 +498,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
488
498
|
self._behaviors = behaviors
|
|
489
499
|
end
|
|
490
500
|
end
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
501
|
+
if parameters ~= nil then
|
|
502
|
+
local additionalParameters = {}
|
|
503
|
+
for ____, key in ipairs(sortedKeysUnnested(parameters)) do
|
|
504
|
+
if not buffParametersKeys[key] then
|
|
505
|
+
if ability then
|
|
506
|
+
additionalParameters[key] = resolveCurrentAbilityDependentValue(ability, parameters[key])
|
|
507
|
+
else
|
|
508
|
+
additionalParameters[key] = parameters[key]
|
|
509
|
+
end
|
|
498
510
|
end
|
|
499
511
|
end
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
512
|
+
if (next(additionalParameters)) ~= nil then
|
|
513
|
+
self.parameters = additionalParameters
|
|
514
|
+
end
|
|
503
515
|
end
|
|
504
516
|
end
|
|
505
517
|
if duration ~= nil and duration > 0 then
|
|
@@ -623,7 +635,7 @@ function Buff.prototype.onDestroy(self)
|
|
|
623
635
|
unit:decrementGhostCounter()
|
|
624
636
|
end
|
|
625
637
|
if self._abilityTypeIds ~= nil then
|
|
626
|
-
for abilityTypeId in
|
|
638
|
+
for ____, abilityTypeId in ipairs(self._abilityTypeIds) do
|
|
627
639
|
unit:removeAbility(abilityTypeId)
|
|
628
640
|
end
|
|
629
641
|
end
|
|
@@ -1247,6 +1259,19 @@ __TS__SetDescriptor(
|
|
|
1247
1259
|
},
|
|
1248
1260
|
true
|
|
1249
1261
|
)
|
|
1262
|
+
__TS__SetDescriptor(
|
|
1263
|
+
Buff.prototype,
|
|
1264
|
+
"manaRegenerationRateIncreaseFactor",
|
|
1265
|
+
{
|
|
1266
|
+
get = function(self)
|
|
1267
|
+
return self:getUnitBonus(UnitBonusType.MANA_REGENERATION_RATE_FACTOR)
|
|
1268
|
+
end,
|
|
1269
|
+
set = function(self, manaRegenerationRateIncreaseFactor)
|
|
1270
|
+
self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.MANA_REGENERATION_RATE_FACTOR, manaRegenerationRateIncreaseFactor)
|
|
1271
|
+
end
|
|
1272
|
+
},
|
|
1273
|
+
true
|
|
1274
|
+
)
|
|
1250
1275
|
__TS__SetDescriptor(
|
|
1251
1276
|
Buff.prototype,
|
|
1252
1277
|
"duration",
|
|
@@ -1380,5 +1405,8 @@ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
|
|
|
1380
1405
|
buffCreatedEvent:addListener(function(buff)
|
|
1381
1406
|
UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
|
|
1382
1407
|
end)
|
|
1408
|
+
buffBeingDestroyedEvent:addListener(function(buff)
|
|
1409
|
+
UnitBehavior:forAll(buff.unit, "onBuffLost", buff)
|
|
1410
|
+
end)
|
|
1383
1411
|
end)(Buff)
|
|
1384
1412
|
return ____exports
|
|
@@ -74,9 +74,12 @@ ____exports.castAbility = function(nativeUnit, abilityTypeId, prepareAbility, ..
|
|
|
74
74
|
unitRemoveAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
|
|
75
75
|
if latestInventoryAbilityTypeId ~= 0 then
|
|
76
76
|
unitAddAbility(nativeUnit, latestInventoryAbilityTypeId)
|
|
77
|
-
for slot,
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
for slot = 0, inventorySize - 1 do
|
|
78
|
+
local nativeItem = nativeItemBySlot[slot]
|
|
79
|
+
if nativeItem ~= nil then
|
|
80
|
+
unitAddItem(nativeUnit, nativeItem)
|
|
81
|
+
unitDropItemSlot(nativeUnit, nativeItem, slot)
|
|
82
|
+
end
|
|
80
83
|
end
|
|
81
84
|
end
|
|
82
85
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____mana_2Dregeneration = require("engine.object-data.entry.ability-type.mana-regeneration")
|
|
3
|
+
local ManaRegenerationAbilityType = ____mana_2Dregeneration.ManaRegenerationAbilityType
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems.
|
|
6
|
+
____exports.MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = compiletime(function()
|
|
7
|
+
local abilityType = ManaRegenerationAbilityType:create()
|
|
8
|
+
abilityType.isInternal = true
|
|
9
|
+
abilityType.isButtonVisible = false
|
|
10
|
+
abilityType.manaRegenerationRateIncreaseFactor = 4
|
|
11
|
+
return abilityType.id
|
|
12
|
+
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems.
|
|
15
|
+
____exports.MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD = ABILITY_RLF_MANA_REGENERATION_BONUS_AS_FRACTION_OF_NORMAL
|
|
16
|
+
return ____exports
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
declare module "../unit" {
|
|
3
|
+
interface Unit {
|
|
4
|
+
strengthBase: number;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare module "../unit" {
|
|
8
|
+
interface Unit {
|
|
9
|
+
agilityBase: number;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare module "../unit" {
|
|
13
|
+
interface Unit {
|
|
14
|
+
intelligenceBase: number;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____unit = require("engine.internal.unit")
|
|
5
|
+
local Unit = ____unit.Unit
|
|
6
|
+
local ____unit = require("engine.standard.fields.unit")
|
|
7
|
+
local AGILITY_UNIT_FIELD = ____unit.AGILITY_UNIT_FIELD
|
|
8
|
+
local INTELLIGENCE_UNIT_FIELD = ____unit.INTELLIGENCE_UNIT_FIELD
|
|
9
|
+
local STRENGTH_UNIT_FIELD = ____unit.STRENGTH_UNIT_FIELD
|
|
10
|
+
__TS__ObjectDefineProperty(
|
|
11
|
+
Unit.prototype,
|
|
12
|
+
"strengthBase",
|
|
13
|
+
{
|
|
14
|
+
get = function(self)
|
|
15
|
+
return STRENGTH_UNIT_FIELD:getValue(self)
|
|
16
|
+
end,
|
|
17
|
+
set = function(self, value)
|
|
18
|
+
STRENGTH_UNIT_FIELD:setValue(self, value)
|
|
19
|
+
end
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
__TS__ObjectDefineProperty(
|
|
23
|
+
Unit.prototype,
|
|
24
|
+
"agilityBase",
|
|
25
|
+
{
|
|
26
|
+
get = function(self)
|
|
27
|
+
return AGILITY_UNIT_FIELD:getValue(self)
|
|
28
|
+
end,
|
|
29
|
+
set = function(self, value)
|
|
30
|
+
AGILITY_UNIT_FIELD:setValue(self, value)
|
|
31
|
+
end
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
__TS__ObjectDefineProperty(
|
|
35
|
+
Unit.prototype,
|
|
36
|
+
"intelligenceBase",
|
|
37
|
+
{
|
|
38
|
+
get = function(self)
|
|
39
|
+
return INTELLIGENCE_UNIT_FIELD:getValue(self)
|
|
40
|
+
end,
|
|
41
|
+
set = function(self, value)
|
|
42
|
+
INTELLIGENCE_UNIT_FIELD:setValue(self, value)
|
|
43
|
+
end
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
return ____exports
|