warscript 0.0.1-dev.c60b168 → 0.0.1-dev.c677d41
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/handle.lua +1 -1
- 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 +8 -2
- package/decl/native.d.ts +2 -2
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +10 -2
- package/engine/behavior.lua +157 -76
- 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 +9 -5
- package/engine/behaviour/unit/stun-immunity.lua +17 -7
- package/engine/behaviour/unit.d.ts +9 -3
- package/engine/behaviour/unit.lua +106 -24
- package/engine/buff.d.ts +19 -4
- package/engine/buff.lua +122 -41
- package/engine/internal/ability.lua +6 -5
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +59 -48
- 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/ability.d.ts +14 -14
- package/engine/internal/unit/ability.lua +72 -45
- 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.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -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-missile-launch.lua +51 -20
- package/engine/internal/unit.d.ts +16 -20
- package/engine/internal/unit.lua +159 -160
- 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/unit.d.ts +20 -5
- package/engine/object-field/unit.lua +61 -0
- package/engine/object-field.d.ts +9 -1
- package/engine/object-field.lua +265 -122
- 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 +11 -3
- package/engine/standard/fields/unit.lua +15 -2
- 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 +4 -0
- package/engine/unit.lua +4 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +10 -8
- package/package.json +2 -2
- package/patch-lua.lua +15 -0
- 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 +5 -1
- package/utility/callback-array.lua +16 -1
- package/utility/linked-map.d.ts +26 -0
- package/utility/linked-map.lua +66 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +23 -1
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/records.lua +20 -1
- package/utility/types.d.ts +3 -0
|
@@ -21,36 +21,56 @@ 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
|
-
local
|
|
26
|
-
local
|
|
27
|
-
local
|
|
28
|
-
local
|
|
27
|
+
local createBehaviorFunctionsByUnitTypeId = {}
|
|
28
|
+
local behaviorsByOwningPlayerEvent = {}
|
|
29
|
+
local listenerByBehaviorByOwningPlayerEvent = {}
|
|
30
|
+
local owningPlayerEventsByBehavior = {}
|
|
31
|
+
local behaviorsByInRangeUnitEvent = {}
|
|
32
|
+
local rangeByBehaviorByInRangeUnitEvent = {}
|
|
33
|
+
local listenerByBehaviorByInRangeUnitEvent = {}
|
|
34
|
+
local inRangeUnitEventsByBehavior = {}
|
|
29
35
|
____exports.UnitBehavior = __TS__Class()
|
|
30
36
|
local UnitBehavior = ____exports.UnitBehavior
|
|
31
37
|
UnitBehavior.name = "UnitBehavior"
|
|
32
38
|
__TS__ClassExtends(UnitBehavior, Behavior)
|
|
33
|
-
function UnitBehavior.prototype.____constructor(self, unit)
|
|
34
|
-
Behavior.prototype.____constructor(self, unit)
|
|
39
|
+
function UnitBehavior.prototype.____constructor(self, unit, priority)
|
|
40
|
+
Behavior.prototype.____constructor(self, unit, priority)
|
|
35
41
|
end
|
|
36
42
|
function UnitBehavior.prototype.onDestroy(self)
|
|
37
|
-
local
|
|
38
|
-
if
|
|
39
|
-
for event in pairs(
|
|
40
|
-
local ____opt_0 =
|
|
43
|
+
local owningPlayerEvents = owningPlayerEventsByBehavior[self]
|
|
44
|
+
if owningPlayerEvents ~= nil then
|
|
45
|
+
for event in pairs(owningPlayerEvents) do
|
|
46
|
+
local ____opt_0 = behaviorsByOwningPlayerEvent[event]
|
|
41
47
|
if ____opt_0 ~= nil then
|
|
42
48
|
____opt_0:remove(self)
|
|
43
49
|
end
|
|
44
|
-
local ____opt_2 =
|
|
50
|
+
local ____opt_2 = listenerByBehaviorByOwningPlayerEvent[event]
|
|
45
51
|
if ____opt_2 ~= nil then
|
|
46
52
|
____opt_2[self] = nil
|
|
47
53
|
end
|
|
48
|
-
|
|
54
|
+
end
|
|
55
|
+
owningPlayerEventsByBehavior[self] = nil
|
|
56
|
+
end
|
|
57
|
+
local inRangeUnitEvents = inRangeUnitEventsByBehavior[self]
|
|
58
|
+
if inRangeUnitEvents ~= nil then
|
|
59
|
+
for event in pairs(inRangeUnitEvents) do
|
|
60
|
+
local ____opt_4 = behaviorsByInRangeUnitEvent[event]
|
|
49
61
|
if ____opt_4 ~= nil then
|
|
50
|
-
____opt_4
|
|
62
|
+
____opt_4:remove(self)
|
|
63
|
+
end
|
|
64
|
+
local ____opt_6 = rangeByBehaviorByInRangeUnitEvent[event]
|
|
65
|
+
if ____opt_6 ~= nil then
|
|
66
|
+
____opt_6[self] = nil
|
|
67
|
+
end
|
|
68
|
+
local ____opt_8 = listenerByBehaviorByInRangeUnitEvent[event]
|
|
69
|
+
if ____opt_8 ~= nil then
|
|
70
|
+
____opt_8[self] = nil
|
|
51
71
|
end
|
|
52
72
|
end
|
|
53
|
-
|
|
73
|
+
inRangeUnitEventsByBehavior[self] = nil
|
|
54
74
|
end
|
|
55
75
|
if self._bonusIdByBonusType ~= nil then
|
|
56
76
|
for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
|
|
@@ -60,28 +80,60 @@ function UnitBehavior.prototype.onDestroy(self)
|
|
|
60
80
|
return Behavior.prototype.onDestroy(self)
|
|
61
81
|
end
|
|
62
82
|
function UnitBehavior.prototype.getUnitBonus(self, bonusType)
|
|
63
|
-
local
|
|
64
|
-
local bonusId =
|
|
83
|
+
local ____opt_10 = self._bonusIdByBonusType
|
|
84
|
+
local bonusId = ____opt_10 and ____opt_10:get(bonusType)
|
|
65
85
|
return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
|
|
66
86
|
end
|
|
67
87
|
function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
|
|
68
88
|
local bonusIdByBonusType = self._bonusIdByBonusType
|
|
69
89
|
if bonusIdByBonusType == nil then
|
|
70
|
-
bonusIdByBonusType =
|
|
90
|
+
bonusIdByBonusType = __TS__New(LinkedMap)
|
|
71
91
|
self._bonusIdByBonusType = bonusIdByBonusType
|
|
72
92
|
end
|
|
73
|
-
bonusIdByBonusType
|
|
93
|
+
bonusIdByBonusType:put(
|
|
94
|
+
bonusType,
|
|
95
|
+
addOrUpdateOrRemoveUnitBonus(
|
|
96
|
+
self.object,
|
|
97
|
+
bonusType,
|
|
98
|
+
bonusIdByBonusType:get(bonusType),
|
|
99
|
+
value
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
end
|
|
103
|
+
function UnitBehavior.prototype.registerOwningPlayerEvent(self, event, extractPlayer, listener)
|
|
104
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByOwningPlayerEvent, event, mutableLuaMap)
|
|
105
|
+
listenerByBehavior[self] = listener
|
|
106
|
+
getOrPut(inRangeUnitEventsByBehavior, self, mutableLuaSet)[event] = true
|
|
107
|
+
local behaviors = behaviorsByOwningPlayerEvent[event]
|
|
108
|
+
if behaviors == nil then
|
|
109
|
+
event:addListener(function(...)
|
|
110
|
+
local behaviors = behaviorsByOwningPlayerEvent[event]
|
|
111
|
+
if behaviors ~= nil then
|
|
112
|
+
local player = extractPlayer(...)
|
|
113
|
+
if player ~= nil then
|
|
114
|
+
for behavior in pairs(behaviors) do
|
|
115
|
+
if behavior.unit.owner == player then
|
|
116
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end)
|
|
122
|
+
behaviors = __TS__New(LinkedSet)
|
|
123
|
+
behaviorsByOwningPlayerEvent[event] = behaviors
|
|
124
|
+
end
|
|
125
|
+
behaviors:add(self)
|
|
74
126
|
end
|
|
75
127
|
function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
|
|
76
|
-
local rangeByBehavior = getOrPut(
|
|
128
|
+
local rangeByBehavior = getOrPut(rangeByBehaviorByInRangeUnitEvent, event, mutableLuaMap)
|
|
77
129
|
rangeByBehavior[self] = range
|
|
78
|
-
local listenerByBehavior = getOrPut(
|
|
130
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByInRangeUnitEvent, event, mutableLuaMap)
|
|
79
131
|
listenerByBehavior[self] = listener
|
|
80
|
-
getOrPut(
|
|
81
|
-
local behaviors =
|
|
132
|
+
getOrPut(inRangeUnitEventsByBehavior, self, mutableLuaSet)[event] = true
|
|
133
|
+
local behaviors = behaviorsByInRangeUnitEvent[event]
|
|
82
134
|
if behaviors == nil then
|
|
83
135
|
event:addListener(function(...)
|
|
84
|
-
local behaviors =
|
|
136
|
+
local behaviors = behaviorsByInRangeUnitEvent[event]
|
|
85
137
|
if behaviors ~= nil then
|
|
86
138
|
local unit = extractUnit(...)
|
|
87
139
|
if unit ~= nil then
|
|
@@ -95,7 +147,7 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUni
|
|
|
95
147
|
end
|
|
96
148
|
end)
|
|
97
149
|
behaviors = __TS__New(LinkedSet)
|
|
98
|
-
|
|
150
|
+
behaviorsByInRangeUnitEvent[event] = behaviors
|
|
99
151
|
end
|
|
100
152
|
behaviors:add(self)
|
|
101
153
|
end
|
|
@@ -151,6 +203,8 @@ function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
|
|
|
151
203
|
end
|
|
152
204
|
function UnitBehavior.prototype.onBuffGained(self, buff)
|
|
153
205
|
end
|
|
206
|
+
function UnitBehavior.prototype.onBuffLost(self, buff)
|
|
207
|
+
end
|
|
154
208
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
155
209
|
end
|
|
156
210
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
|
@@ -165,6 +219,23 @@ function UnitBehavior.prototype.onKill(self, target)
|
|
|
165
219
|
end
|
|
166
220
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
167
221
|
end
|
|
222
|
+
function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
|
|
223
|
+
end
|
|
224
|
+
function UnitBehavior.bindUnitType(self, unitTypeId, ...)
|
|
225
|
+
local args = {...}
|
|
226
|
+
local createBehaviorFunctions = createBehaviorFunctionsByUnitTypeId[unitTypeId]
|
|
227
|
+
if createBehaviorFunctions == nil then
|
|
228
|
+
createBehaviorFunctions = {}
|
|
229
|
+
createBehaviorFunctionsByUnitTypeId[unitTypeId] = createBehaviorFunctions
|
|
230
|
+
end
|
|
231
|
+
createBehaviorFunctions[#createBehaviorFunctions + 1] = function(unit)
|
|
232
|
+
return __TS__New(
|
|
233
|
+
self,
|
|
234
|
+
unit,
|
|
235
|
+
table.unpack(args)
|
|
236
|
+
)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
168
239
|
__TS__SetDescriptor(
|
|
169
240
|
UnitBehavior.prototype,
|
|
170
241
|
"unit",
|
|
@@ -276,7 +347,18 @@ __TS__SetDescriptor(
|
|
|
276
347
|
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
277
348
|
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
278
349
|
end)
|
|
350
|
+
Unit.onOwnerChange:addListener(function(unit, previousOwner)
|
|
351
|
+
____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
|
|
352
|
+
end)
|
|
279
353
|
end)(UnitBehavior)
|
|
354
|
+
Unit.onCreate:addListener(function(unit)
|
|
355
|
+
local createBehaviorFunctions = createBehaviorFunctionsByUnitTypeId[unit.typeId]
|
|
356
|
+
if createBehaviorFunctions ~= nil then
|
|
357
|
+
for ____, createBehavior in ipairs(createBehaviorFunctions) do
|
|
358
|
+
createBehavior(unit)
|
|
359
|
+
end
|
|
360
|
+
end
|
|
361
|
+
end)
|
|
280
362
|
Unit.destroyEvent:addListener(function(unit)
|
|
281
363
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
|
282
364
|
end)
|
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;
|
|
@@ -79,6 +83,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
79
83
|
healingOnExpiration?: NumberParameterValueType;
|
|
80
84
|
killsOnExpiration?: BooleanParameterValueType;
|
|
81
85
|
explodesOnExpiration?: BooleanParameterValueType;
|
|
86
|
+
abilityCooldownFactor?: NumberParameterValueType;
|
|
82
87
|
uniqueGroup?: BuffUniqueGroup;
|
|
83
88
|
} : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
|
|
84
89
|
declare const enum BuffPropertyKey {
|
|
@@ -124,7 +129,9 @@ declare const enum BuffPropertyKey {
|
|
|
124
129
|
PROVIDES_INVULNERABILITY = 139,
|
|
125
130
|
KILLS_ON_EXPIRATION = 140,
|
|
126
131
|
EXPLODES_ON_EXPIRATION = 141,
|
|
127
|
-
MISS_PROBABILITY = 142
|
|
132
|
+
MISS_PROBABILITY = 142,
|
|
133
|
+
ABILITY_COOLDOWN_FACTOR = 143,
|
|
134
|
+
ABILITY_COOLDOWN_MODIFIER = 144
|
|
128
135
|
}
|
|
129
136
|
export declare const enum BuffTypeIdSelectionPolicy {
|
|
130
137
|
LEAST_DURATION = 0
|
|
@@ -138,7 +145,7 @@ export type BuffConstructorParameters<AdditionalParameters extends BuffAdditiona
|
|
|
138
145
|
polarity: BuffPolarityParameterType,
|
|
139
146
|
resistanceType: BuffResistanceTypeParameterType,
|
|
140
147
|
...abilityOrParameters: [
|
|
141
|
-
ability?: Ability,
|
|
148
|
+
ability?: Ability | AbilityBehavior,
|
|
142
149
|
parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
|
|
143
150
|
] | [parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>]
|
|
144
151
|
];
|
|
@@ -187,6 +194,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
187
194
|
private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
|
|
188
195
|
private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
|
|
189
196
|
private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
|
|
197
|
+
private [BuffPropertyKey.ABILITY_COOLDOWN_FACTOR]?;
|
|
198
|
+
private [BuffPropertyKey.ABILITY_COOLDOWN_MODIFIER]?;
|
|
190
199
|
protected static readonly defaultParameters: BuffParameters;
|
|
191
200
|
get source(): Unit;
|
|
192
201
|
readonly typeId: ApplicableBuffTypeId;
|
|
@@ -259,9 +268,15 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
259
268
|
set movementSpeedIncreaseFactor(movementSpeedIncreaseFactor: number);
|
|
260
269
|
get evasionProbability(): number;
|
|
261
270
|
set evasionProbability(evasionProbability: number);
|
|
271
|
+
get manaRegenerationRateIncreaseFactor(): number;
|
|
272
|
+
set manaRegenerationRateIncreaseFactor(manaRegenerationRateIncreaseFactor: number);
|
|
262
273
|
get duration(): number;
|
|
263
274
|
get remainingDuration(): number;
|
|
264
275
|
set remainingDuration(remainingDuration: number);
|
|
276
|
+
get abilityCooldownFactor(): number;
|
|
277
|
+
set abilityCooldownFactor(abilityCooldownFactor: number);
|
|
278
|
+
onAbilityGained(ability: Ability): void;
|
|
279
|
+
onAbilityLost(ability: Ability): void;
|
|
265
280
|
flashEffect(...parameters: [
|
|
266
281
|
...widgetOrXY: [] | [Widget] | [x: number, x: number],
|
|
267
282
|
...parametersOrDuration: [] | [EffectParameters] | [number]
|
package/engine/buff.lua
CHANGED
|
@@ -16,6 +16,7 @@ local internalApplyBuff = ____applicable.internalApplyBuff
|
|
|
16
16
|
local removeBuff = ____applicable.removeBuff
|
|
17
17
|
local ____ability = require("engine.internal.ability")
|
|
18
18
|
local Ability = ____ability.Ability
|
|
19
|
+
local UnitAbility = ____ability.UnitAbility
|
|
19
20
|
local ____ability = require("engine.object-field.ability")
|
|
20
21
|
local AbilityBooleanField = ____ability.AbilityBooleanField
|
|
21
22
|
local AbilityNumberField = ____ability.AbilityNumberField
|
|
@@ -41,6 +42,7 @@ local BuffType = ____buff_2Dtype.BuffType
|
|
|
41
42
|
local ____unit = require("engine.behaviour.unit")
|
|
42
43
|
local UnitBehavior = ____unit.UnitBehavior
|
|
43
44
|
local ____arrays = require("utility.arrays")
|
|
45
|
+
local emptyArray = ____arrays.emptyArray
|
|
44
46
|
local forEach = ____arrays.forEach
|
|
45
47
|
local ____event = require("event")
|
|
46
48
|
local Event = ____event.Event
|
|
@@ -50,6 +52,12 @@ local ____item = require("engine.internal.item")
|
|
|
50
52
|
local Item = ____item.Item
|
|
51
53
|
local ____destructable = require("core.types.destructable")
|
|
52
54
|
local Destructable = ____destructable.Destructable
|
|
55
|
+
local ____ability = require("engine.standard.fields.ability")
|
|
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
|
|
53
61
|
local getUnitAbility = BlzGetUnitAbility
|
|
54
62
|
local stringValueByBuffTypeIdByFieldId = postcompile(function()
|
|
55
63
|
local stringValueByBuffTypeIdByFieldId = {}
|
|
@@ -98,6 +106,7 @@ local buffParametersKeys = {
|
|
|
98
106
|
armorIncreaseFactor = true,
|
|
99
107
|
attackSpeedIncreaseFactor = true,
|
|
100
108
|
movementSpeedIncreaseFactor = true,
|
|
109
|
+
manaRegenerationRateIncreaseFactor = true,
|
|
101
110
|
evasionProbability = true,
|
|
102
111
|
missProbability = true,
|
|
103
112
|
damageFactor = true,
|
|
@@ -121,7 +130,8 @@ local buffParametersKeys = {
|
|
|
121
130
|
damageOnExpiration = true,
|
|
122
131
|
healingOnExpiration = true,
|
|
123
132
|
killsOnExpiration = true,
|
|
124
|
-
explodesOnExpiration = true
|
|
133
|
+
explodesOnExpiration = true,
|
|
134
|
+
abilityCooldownFactor = true
|
|
125
135
|
}
|
|
126
136
|
local function resolveEnumValue(ability, level, value)
|
|
127
137
|
if value == nil or type(value) == "number" then
|
|
@@ -184,6 +194,7 @@ local buffNumberParameters = {
|
|
|
184
194
|
"durationIncreaseOnAutoAttack",
|
|
185
195
|
"attackSpeedIncreaseFactor",
|
|
186
196
|
"movementSpeedIncreaseFactor",
|
|
197
|
+
"manaRegenerationRateIncreaseFactor",
|
|
187
198
|
"evasionProbability",
|
|
188
199
|
"armorIncrease",
|
|
189
200
|
"damageFactor",
|
|
@@ -198,7 +209,8 @@ local buffNumberParameters = {
|
|
|
198
209
|
"healingPerInterval",
|
|
199
210
|
"healingOverDuration",
|
|
200
211
|
"damageOnExpiration",
|
|
201
|
-
"healingOnExpiration"
|
|
212
|
+
"healingOnExpiration",
|
|
213
|
+
"abilityCooldownFactor"
|
|
202
214
|
}
|
|
203
215
|
local unsuccessfulApplicationMarker = {}
|
|
204
216
|
local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
|
|
@@ -317,33 +329,38 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
317
329
|
local polarity
|
|
318
330
|
local resistanceType
|
|
319
331
|
local ability
|
|
332
|
+
local abilityBehavior
|
|
320
333
|
if type(typeIdOrTypeIds) ~= "number" then
|
|
321
334
|
typeId = selectBuffTypeIdWithLeastDuration(typeIdOrTypeIds, _unit)
|
|
322
335
|
polarity = resistanceTypeOrPolarity
|
|
323
336
|
resistanceType = abilityOrParametersOrResistanceType
|
|
324
|
-
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
|
|
325
341
|
ability = parametersOrAbility
|
|
326
|
-
|
|
327
|
-
ability = nil
|
|
342
|
+
elseif parametersOrAbility ~= nil then
|
|
328
343
|
parameters = parametersOrAbility
|
|
329
344
|
end
|
|
330
345
|
else
|
|
331
346
|
typeId = typeIdOrTypeIds
|
|
332
347
|
polarity = polarityOrTypeIdSelectionPolicy
|
|
333
348
|
resistanceType = resistanceTypeOrPolarity
|
|
334
|
-
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
|
|
335
354
|
ability = abilityOrParametersOrResistanceType
|
|
336
355
|
parameters = parametersOrAbility
|
|
337
|
-
|
|
338
|
-
ability = nil
|
|
356
|
+
elseif abilityOrParametersOrResistanceType ~= nil then
|
|
339
357
|
parameters = abilityOrParametersOrResistanceType
|
|
358
|
+
else
|
|
359
|
+
parameters = parametersOrAbility
|
|
340
360
|
end
|
|
341
361
|
end
|
|
362
|
+
self.sourceAbilityBehavior = abilityBehavior
|
|
342
363
|
self.typeId = typeId
|
|
343
|
-
if not (__TS__InstanceOf(ability, Ability) or ability == nil) then
|
|
344
|
-
parameters = ability
|
|
345
|
-
ability = nil
|
|
346
|
-
end
|
|
347
364
|
local defaultParameters = self.constructor.defaultParameters
|
|
348
365
|
local level = parameters and parameters.level or defaultParameters.level
|
|
349
366
|
local spellStealPriority = parameters and parameters.spellStealPriority or defaultParameters.spellStealPriority
|
|
@@ -454,24 +471,22 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
454
471
|
abilityTypeIds = {}
|
|
455
472
|
self._abilityTypeIds = abilityTypeIds
|
|
456
473
|
end
|
|
457
|
-
for
|
|
474
|
+
for ____, abilityTypeId in ipairs(sortedKeysUnnested(parametersAbilityTypeIds)) do
|
|
475
|
+
local abilityParameters = parametersAbilityTypeIds[abilityTypeId]
|
|
458
476
|
local addedAbility = _unit:addAbility(abilityTypeId)
|
|
459
477
|
if addedAbility ~= nil then
|
|
460
478
|
_unit:makeAbilityPermanent(abilityTypeId, true)
|
|
461
479
|
_unit:setAbilityLevel(abilityTypeId, 1 + (abilityParameters.level or ability and ability.level or 0))
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
resolveNumberValue(ability, level, abilityParameterValue)
|
|
471
|
-
)
|
|
472
|
-
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
|
+
)
|
|
473
488
|
end
|
|
474
|
-
abilityTypeIds[
|
|
489
|
+
abilityTypeIds[#abilityTypeIds + 1] = abilityTypeId
|
|
475
490
|
end
|
|
476
491
|
end
|
|
477
492
|
local behaviorConstructors = parameters and parameters.behaviorConstructors or defaultParameters.behaviorConstructors
|
|
@@ -483,18 +498,20 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
483
498
|
self._behaviors = behaviors
|
|
484
499
|
end
|
|
485
500
|
end
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
if
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
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
|
|
493
510
|
end
|
|
494
511
|
end
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
512
|
+
if (next(additionalParameters)) ~= nil then
|
|
513
|
+
self.parameters = additionalParameters
|
|
514
|
+
end
|
|
498
515
|
end
|
|
499
516
|
end
|
|
500
517
|
if duration ~= nil and duration > 0 then
|
|
@@ -506,6 +523,22 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
506
523
|
self[100] = 1
|
|
507
524
|
Event.invoke(buffCreatedEvent, self)
|
|
508
525
|
end
|
|
526
|
+
function Buff.prototype.onAbilityGained(self, ability)
|
|
527
|
+
if __TS__InstanceOf(ability, UnitAbility) then
|
|
528
|
+
local abilityCooldownModifier = self[144]
|
|
529
|
+
if abilityCooldownModifier then
|
|
530
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, abilityCooldownModifier)
|
|
531
|
+
end
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
function Buff.prototype.onAbilityLost(self, ability)
|
|
535
|
+
if __TS__InstanceOf(ability, UnitAbility) then
|
|
536
|
+
local abilityCooldownModifier = self[144]
|
|
537
|
+
if abilityCooldownModifier then
|
|
538
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, abilityCooldownModifier)
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
end
|
|
509
542
|
function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
510
543
|
if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
|
|
511
544
|
Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
@@ -580,6 +613,12 @@ function Buff.prototype.onDestroy(self)
|
|
|
580
613
|
behavior:destroy()
|
|
581
614
|
end
|
|
582
615
|
end
|
|
616
|
+
local previousAbilityCooldownModifier = self[144]
|
|
617
|
+
if previousAbilityCooldownModifier then
|
|
618
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
619
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
|
|
620
|
+
end
|
|
621
|
+
end
|
|
583
622
|
if self[139] then
|
|
584
623
|
unit:decrementInvulnerabilityCounter()
|
|
585
624
|
end
|
|
@@ -588,7 +627,7 @@ function Buff.prototype.onDestroy(self)
|
|
|
588
627
|
end
|
|
589
628
|
if self[136] then
|
|
590
629
|
if self[137] then
|
|
591
|
-
unit:
|
|
630
|
+
unit:decrementForceStunCounter()
|
|
592
631
|
end
|
|
593
632
|
unit:decrementStunCounter()
|
|
594
633
|
end
|
|
@@ -596,7 +635,7 @@ function Buff.prototype.onDestroy(self)
|
|
|
596
635
|
unit:decrementGhostCounter()
|
|
597
636
|
end
|
|
598
637
|
if self._abilityTypeIds ~= nil then
|
|
599
|
-
for abilityTypeId in
|
|
638
|
+
for ____, abilityTypeId in ipairs(self._abilityTypeIds) do
|
|
600
639
|
unit:removeAbility(abilityTypeId)
|
|
601
640
|
end
|
|
602
641
|
end
|
|
@@ -987,13 +1026,13 @@ __TS__SetDescriptor(
|
|
|
987
1026
|
set = function(self, stuns)
|
|
988
1027
|
if not stuns and self[136] then
|
|
989
1028
|
if self[137] then
|
|
990
|
-
self.object:
|
|
1029
|
+
self.object:decrementForceStunCounter()
|
|
991
1030
|
end
|
|
992
1031
|
self.object:decrementStunCounter()
|
|
993
1032
|
self[136] = nil
|
|
994
1033
|
elseif stuns and not self[136] then
|
|
995
1034
|
if self[137] then
|
|
996
|
-
self.object:
|
|
1035
|
+
self.object:incrementForceStunCounter()
|
|
997
1036
|
end
|
|
998
1037
|
self.object:incrementStunCounter()
|
|
999
1038
|
self[136] = true
|
|
@@ -1016,12 +1055,12 @@ __TS__SetDescriptor(
|
|
|
1016
1055
|
set = function(self, ignoresStunImmunity)
|
|
1017
1056
|
if not ignoresStunImmunity and self[137] then
|
|
1018
1057
|
if self[136] then
|
|
1019
|
-
self.object:
|
|
1058
|
+
self.object:decrementForceStunCounter()
|
|
1020
1059
|
end
|
|
1021
1060
|
self[137] = nil
|
|
1022
1061
|
elseif ignoresStunImmunity and not self[137] then
|
|
1023
1062
|
if self[136] then
|
|
1024
|
-
self.object:
|
|
1063
|
+
self.object:incrementForceStunCounter()
|
|
1025
1064
|
end
|
|
1026
1065
|
self[137] = true
|
|
1027
1066
|
end
|
|
@@ -1220,6 +1259,19 @@ __TS__SetDescriptor(
|
|
|
1220
1259
|
},
|
|
1221
1260
|
true
|
|
1222
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
|
+
)
|
|
1223
1275
|
__TS__SetDescriptor(
|
|
1224
1276
|
Buff.prototype,
|
|
1225
1277
|
"duration",
|
|
@@ -1269,6 +1321,32 @@ __TS__SetDescriptor(
|
|
|
1269
1321
|
},
|
|
1270
1322
|
true
|
|
1271
1323
|
)
|
|
1324
|
+
__TS__SetDescriptor(
|
|
1325
|
+
Buff.prototype,
|
|
1326
|
+
"abilityCooldownFactor",
|
|
1327
|
+
{
|
|
1328
|
+
get = function(self)
|
|
1329
|
+
return self[143] or 1
|
|
1330
|
+
end,
|
|
1331
|
+
set = function(self, abilityCooldownFactor)
|
|
1332
|
+
local previousAbilityCooldownModifier = self[144]
|
|
1333
|
+
if previousAbilityCooldownModifier then
|
|
1334
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
1335
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
|
|
1336
|
+
end
|
|
1337
|
+
end
|
|
1338
|
+
local function modifier(ability, level, cooldown)
|
|
1339
|
+
return cooldown * abilityCooldownFactor
|
|
1340
|
+
end
|
|
1341
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
1342
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
|
|
1343
|
+
end
|
|
1344
|
+
self[144] = modifier
|
|
1345
|
+
self[143] = abilityCooldownFactor
|
|
1346
|
+
end
|
|
1347
|
+
},
|
|
1348
|
+
true
|
|
1349
|
+
)
|
|
1272
1350
|
Buff.createdEvent = buffCreatedEvent
|
|
1273
1351
|
Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
|
|
1274
1352
|
(function(self)
|
|
@@ -1327,5 +1405,8 @@ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
|
|
|
1327
1405
|
buffCreatedEvent:addListener(function(buff)
|
|
1328
1406
|
UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
|
|
1329
1407
|
end)
|
|
1408
|
+
buffBeingDestroyedEvent:addListener(function(buff)
|
|
1409
|
+
UnitBehavior:forAll(buff.unit, "onBuffLost", buff)
|
|
1410
|
+
end)
|
|
1330
1411
|
end)(Buff)
|
|
1331
1412
|
return ____exports
|
|
@@ -13,7 +13,6 @@ local ____ability = require("engine.internal.item.ability")
|
|
|
13
13
|
local abilityActionDummy = ____ability.abilityActionDummy
|
|
14
14
|
local doAbilityAction = ____ability.doAbilityAction
|
|
15
15
|
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
16
|
-
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
17
16
|
local startItemCooldown = ____ability.startItemCooldown
|
|
18
17
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
19
18
|
local setUnitAbilityLevel = SetUnitAbilityLevel
|
|
@@ -40,8 +39,6 @@ local getItemBooleanField = BlzGetItemBooleanField
|
|
|
40
39
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
41
40
|
local unitHideAbility = BlzUnitHideAbility
|
|
42
41
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
43
|
-
local unitRemoveAbility = UnitRemoveAbility
|
|
44
|
-
local itemRemoveAbility = BlzItemRemoveAbility
|
|
45
42
|
local match = string.match
|
|
46
43
|
local ____type = _G.type
|
|
47
44
|
local ____tostring = _G.tostring
|
|
@@ -429,7 +426,9 @@ function UnitAbility.prototype.interruptCast(self)
|
|
|
429
426
|
self.owner:interruptCast(self.typeId)
|
|
430
427
|
end
|
|
431
428
|
function UnitAbility.prototype.onDestroy(self)
|
|
432
|
-
|
|
429
|
+
if self.owner.state ~= 2 then
|
|
430
|
+
self.owner:removeAbility(self.typeId)
|
|
431
|
+
end
|
|
433
432
|
return UnitAbility.____super.prototype.onDestroy(self)
|
|
434
433
|
end
|
|
435
434
|
__TS__SetDescriptor(
|
|
@@ -525,7 +524,9 @@ function ItemAbility.prototype.interruptCast(self)
|
|
|
525
524
|
end
|
|
526
525
|
end
|
|
527
526
|
function ItemAbility.prototype.onDestroy(self)
|
|
528
|
-
|
|
527
|
+
if self.owner.state ~= 2 then
|
|
528
|
+
self.owner:removeAbility(self.typeId)
|
|
529
|
+
end
|
|
529
530
|
return ItemAbility.____super.prototype.onDestroy(self)
|
|
530
531
|
end
|
|
531
532
|
__TS__SetDescriptor(
|